blob_id
stringlengths 40
40
| __id__
int64 225
39,780B
| directory_id
stringlengths 40
40
| path
stringlengths 6
313
| content_id
stringlengths 40
40
| detected_licenses
list | license_type
stringclasses 2
values | repo_name
stringlengths 6
132
| repo_url
stringlengths 25
151
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
70
| visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 7.28k
689M
⌀ | star_events_count
int64 0
131k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 23
values | gha_fork
bool 2
classes | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_updated_at
timestamp[ns] | gha_pushed_at
timestamp[ns] | gha_size
int64 0
40.4M
⌀ | gha_stargazers_count
int32 0
112k
⌀ | gha_forks_count
int32 0
39.4k
⌀ | gha_open_issues_count
int32 0
11k
⌀ | gha_language
stringlengths 1
21
⌀ | gha_archived
bool 2
classes | gha_disabled
bool 1
class | content
stringlengths 7
4.37M
| src_encoding
stringlengths 3
16
| language
stringclasses 1
value | length_bytes
int64 7
4.37M
| extension
stringclasses 24
values | filename
stringlengths 4
174
| language_id
stringclasses 1
value | entities
list | contaminating_dataset
stringclasses 0
values | malware_signatures
list | redacted_content
stringlengths 7
4.37M
| redacted_length_bytes
int64 7
4.37M
| alphanum_fraction
float32 0.25
0.94
| alpha_fraction
float32 0.25
0.94
| num_lines
int32 1
84k
| avg_line_length
float32 0.76
99.9
| std_line_length
float32 0
220
| max_line_length
int32 5
998
| is_vendor
bool 2
classes | is_generated
bool 1
class | max_hex_length
int32 0
319
| hex_fraction
float32 0
0.38
| max_unicode_length
int32 0
408
| unicode_fraction
float32 0
0.36
| max_base64_length
int32 0
506
| base64_fraction
float32 0
0.5
| avg_csv_sep_count
float32 0
4
| is_autogen_header
bool 1
class | is_empty_html
bool 1
class | shard
stringclasses 16
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2aa2ce253ab103517aa0085596d55d9aa9c3f72e
| 29,892,972,427,901 |
eabebb52b03b6d2397154d13db2f3ce484dad27f
|
/balance/src/main/java/com/jdc/balance/security/filter/EmployeeFilter.java
|
b80007b539a5cfdf69eb0fab10c911962a8f4c45
|
[
"MIT"
] |
permissive
|
minlwin/java-web
|
https://github.com/minlwin/java-web
|
94574458e4af987a98aadda653a14477c216bed4
|
543def887ff051ca69a62da1b9bf20229d208cff
|
refs/heads/main
| 2022-02-17T20:37:44.108000 | 2022-01-24T15:29:06 | 2022-01-24T15:29:06 | 28,694,888 | 8 | 4 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.jdc.balance.security.filter;
import java.io.IOException;
import com.jdc.balance.model.domain.Employee.Role;
import com.jdc.balance.security.LoginUser;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.annotation.WebFilter;
@WebFilter(filterName = "employeeFilter")
public class EmployeeFilter extends SecurityFilter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
LoginUser loginUser = loginIfo(request);
if (Role.Employee.match(loginUser.getRole())
|| Role.Manager.match(loginUser.getRole())) {
chain.doFilter(request, response);
} else {
loginUser.logout();
navigateToLogin(request, response, "You have no authority to use Employee Function.");
}
}
}
|
UTF-8
|
Java
| 922 |
java
|
EmployeeFilter.java
|
Java
|
[] | null |
[] |
package com.jdc.balance.security.filter;
import java.io.IOException;
import com.jdc.balance.model.domain.Employee.Role;
import com.jdc.balance.security.LoginUser;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.annotation.WebFilter;
@WebFilter(filterName = "employeeFilter")
public class EmployeeFilter extends SecurityFilter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
LoginUser loginUser = loginIfo(request);
if (Role.Employee.match(loginUser.getRole())
|| Role.Manager.match(loginUser.getRole())) {
chain.doFilter(request, response);
} else {
loginUser.logout();
navigateToLogin(request, response, "You have no authority to use Employee Function.");
}
}
}
| 922 | 0.785249 | 0.785249 | 32 | 27.8125 | 25.000547 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.5 | false | false |
0
|
37406e4e0714c08bca93272fdbcfa6b16eb99c33
| 18,219,251,277,034 |
06215e0049aec5e6d57b4b2fc517412443dbd0ab
|
/src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java
|
4d0c436a107cd98c04ac3d46a93b7e162bd9677a
|
[
"Apache-2.0"
] |
permissive
|
CyanogenMod/android_packages_apps_CMFileManager
|
https://github.com/CyanogenMod/android_packages_apps_CMFileManager
|
29c50d09eeffecfd2393005dad5307e45ac4f125
|
76e91cf5d0e6856f8e899974366004ecc47827a3
|
refs/heads/cm-13.0
| 2020-04-05T10:57:27.045000 | 2016-12-23T02:14:09 | 2016-12-23T02:14:09 | 6,485,371 | 111 | 177 | null | true | 2016-04-20T05:04:01 | 2012-11-01T05:30:16 | 2016-04-20T05:02:45 | 2016-04-20T04:12:18 | 28,314 | 145 | 185 | 0 |
Java
| null | null |
/*
* Copyright (C) 2012 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.cyanogenmod.filemanager.ui.dialogs;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.HapticFeedbackConstants;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.cyanogenmod.filemanager.FileManagerApplication;
import com.cyanogenmod.filemanager.R;
import com.cyanogenmod.filemanager.activities.NavigationActivity;
import com.cyanogenmod.filemanager.adapters.TwoColumnsMenuListAdapter;
import com.cyanogenmod.filemanager.console.VirtualMountPointConsole;
import com.cyanogenmod.filemanager.listeners.OnRequestRefreshListener;
import com.cyanogenmod.filemanager.listeners.OnSelectionListener;
import com.cyanogenmod.filemanager.model.Bookmark;
import com.cyanogenmod.filemanager.model.Directory;
import com.cyanogenmod.filemanager.model.FileSystemObject;
import com.cyanogenmod.filemanager.model.Symlink;
import com.cyanogenmod.filemanager.model.SystemFile;
import com.cyanogenmod.filemanager.preferences.AccessMode;
import com.cyanogenmod.filemanager.preferences.FileManagerSettings;
import com.cyanogenmod.filemanager.preferences.Preferences;
import com.cyanogenmod.filemanager.ui.ThemeManager;
import com.cyanogenmod.filemanager.ui.ThemeManager.Theme;
import com.cyanogenmod.filemanager.ui.policy.BookmarksActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.CompressActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.CopyMoveActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.CopyMoveActionPolicy.LinkedResource;
import com.cyanogenmod.filemanager.ui.policy.DeleteActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.ExecutionActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.InfoActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.IntentsActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.NavigationActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.NewActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.PrintActionPolicy;
import com.cyanogenmod.filemanager.util.DialogHelper;
import com.cyanogenmod.filemanager.util.ExceptionUtil;
import com.cyanogenmod.filemanager.util.FileHelper;
import com.cyanogenmod.filemanager.util.MimeTypeHelper;
import com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory;
import com.cyanogenmod.filemanager.util.SelectionHelper;
import com.cyanogenmod.filemanager.util.StorageHelper;
import java.io.File;
import java.io.InvalidClassException;
import java.util.ArrayList;
import java.util.List;
/**
* A class that wraps a dialog for showing the list of actions that
* the user can do.
*/
public class ActionsDialog implements OnItemClickListener, OnItemLongClickListener {
/**
* @hide
*/
final Context mContext;
final NavigationActivity mBackRef;
private final boolean mGlobal;
private final boolean mSearch;
private final boolean mChRooted;
/**
* @hide
*/
AlertDialog mDialog;
private ListView mListView;
/**
* @hide
*/
final FileSystemObject mFso;
/**
* @hide
*/
OnRequestRefreshListener mOnRequestRefreshListener;
/**
* @hide
*/
OnSelectionListener mOnSelectionListener;
/**
* Constructor of <code>ActionsDialog</code>.
*
* @param context The current context
* @param fso The file system object associated
* @param global If the menu to display will be the global one (Global actions)
* @param search If the call is from search activity
*/
public ActionsDialog(Context context, NavigationActivity backRef, FileSystemObject fso,
boolean global, boolean search) {
super();
//Save the data
this.mFso = fso;
this.mContext = context;
this.mBackRef = backRef;
this.mGlobal = global;
this.mSearch = search;
this.mChRooted = FileManagerApplication.getAccessMode().compareTo(AccessMode.SAFE) == 0;
//Initialize dialog
init(context, global ? R.id.mnu_actions_global : R.id.mnu_actions_fso);
}
/**
* Method that initializes the dialog.
*
* @param context The current context
* @param group The group of action menus to show
*/
private void init(Context context, int group) {
//Create the menu adapter
TwoColumnsMenuListAdapter adapter =
new TwoColumnsMenuListAdapter(context, R.menu.actions, group, false);
adapter.setOnItemClickListener(this);
adapter.setOnItemLongClickListener(this);
//Create the list view
this.mListView = new ListView(context);
LinearLayout.LayoutParams params =
new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
this.mListView.setLayoutParams(params);
this.mListView.setAdapter(adapter);
// Apply the current theme
Theme theme = ThemeManager.getCurrentTheme(context);
theme.setBackgroundDrawable(context, this.mListView, "background_drawable"); //$NON-NLS-1$
this.mListView.setDivider(
theme.getDrawable(context, "horizontal_divider_drawable")); //$NON-NLS-1$
//Create the dialog
this.mDialog = DialogHelper.createDialog(
context,
0,
R.string.actions_dialog_title,
this.mListView);
this.mDialog.setButton(
DialogInterface.BUTTON_NEGATIVE,
this.mContext.getString(android.R.string.cancel),
(DialogInterface.OnClickListener)null);
}
/**
* Method that sets the listener for communicate a refresh request.
*
* @param onRequestRefreshListener The request refresh listener
*/
public void setOnRequestRefreshListener(OnRequestRefreshListener onRequestRefreshListener) {
this.mOnRequestRefreshListener = onRequestRefreshListener;
}
/**
* Method that sets the listener for requesting selection data
*
* @param onSelectionListener The request selection data listener
*/
public void setOnSelectionListener(OnSelectionListener onSelectionListener) {
this.mOnSelectionListener = onSelectionListener;
}
/**
* Method that shows the dialog.
*/
public void show() {
TwoColumnsMenuListAdapter adapter =
(TwoColumnsMenuListAdapter)this.mListView.getAdapter();
configureMenu(adapter.getMenu());
DialogHelper.delegateDialogShow(this.mContext, this.mDialog);
}
/**
* Method that judges whether the dialog is showing.
*/
public boolean isShowing() {
if (this.mDialog != null) {
return this.mDialog.isShowing();
}
return false;
}
/**
* {@inheritDoc}
*/
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, final long id) {
//Retrieve the menu item
MenuItem menuItem = ((TwoColumnsMenuListAdapter)parent.getAdapter()).getItemById((int)id);
//What action was selected?
switch ((int)id) {
//- Create new object
case R.id.mnu_actions_new_directory:
case R.id.mnu_actions_new_file:
// Dialog is dismissed inside showInputNameDialog
if (this.mOnSelectionListener != null) {
showInputNameDialog(menuItem);
return;
}
break;
//- Rename
case R.id.mnu_actions_rename:
// Dialog is dismissed inside showInputNameDialog
if (this.mOnSelectionListener != null) {
showFsoInputNameDialog(menuItem, this.mFso, false);
return;
}
break;
//- Create link
case R.id.mnu_actions_create_link:
// Dialog is dismissed inside showInputNameDialog
if (this.mOnSelectionListener != null) {
showFsoInputNameDialog(menuItem, this.mFso, true);
return;
}
break;
case R.id.mnu_actions_create_link_global:
// Dialog is dismissed inside showInputNameDialog
if (this.mOnSelectionListener != null) {
// The selection must be only 1 item
List<FileSystemObject> selection =
this.mOnSelectionListener.onRequestSelectedFiles();
if (selection != null && selection.size() == 1) {
showFsoInputNameDialog(menuItem, selection.get(0), true);
}
return;
}
break;
//- Delete
case R.id.mnu_actions_delete:
DeleteActionPolicy.removeFileSystemObject(
this.mContext,
this.mFso,
this.mOnSelectionListener,
this.mOnRequestRefreshListener,
null);
break;
//- Refresh
case R.id.mnu_actions_refresh:
if (this.mOnRequestRefreshListener != null) {
this.mOnRequestRefreshListener.onRequestRefresh(null, false); //Refresh all
}
break;
//- Select/Deselect
case R.id.mnu_actions_select:
case R.id.mnu_actions_deselect:
if (this.mOnSelectionListener != null) {
this.mOnSelectionListener.onToggleSelection(this.mFso);
}
break;
case R.id.mnu_actions_select_all:
if (this.mOnSelectionListener != null) {
this.mOnSelectionListener.onSelectAllVisibleItems();
}
break;
case R.id.mnu_actions_deselect_all:
if (this.mOnSelectionListener != null) {
this.mOnSelectionListener.onDeselectAllVisibleItems();
}
break;
//- Open
case R.id.mnu_actions_open:
IntentsActionPolicy.openFileSystemObject(
this.mContext, this.mFso, false, null);
break;
//- Open with
case R.id.mnu_actions_open_with:
IntentsActionPolicy.openFileSystemObject(
this.mContext, this.mFso, true, null);
break;
//- Execute
case R.id.mnu_actions_execute:
ExecutionActionPolicy.execute(this.mContext, this.mFso);
break;
//- Send
case R.id.mnu_actions_send:
IntentsActionPolicy.sendFileSystemObject(
this.mContext, this.mFso, null);
break;
case R.id.mnu_actions_send_selection:
if (this.mOnSelectionListener != null) {
List<FileSystemObject> selection =
this.mOnSelectionListener.onRequestSelectedFiles();
if (selection.size() == 1) {
IntentsActionPolicy.sendFileSystemObject(
this.mContext, selection.get(0), null);
} else {
IntentsActionPolicy.sendMultipleFileSystemObject(
this.mContext, selection, null);
}
}
break;
// Paste selection
case R.id.mnu_actions_paste_selection:
if (this.mOnSelectionListener != null) {
List<FileSystemObject> selection =
this.mOnSelectionListener.onRequestSelectedFiles();
CopyMoveActionPolicy.copyFileSystemObjects(
this.mContext,
createLinkedResource(selection, this.mFso),
this.mOnSelectionListener,
this.mOnRequestRefreshListener);
}
break;
// Move selection
case R.id.mnu_actions_move_selection:
if (this.mOnSelectionListener != null) {
List<FileSystemObject> selection =
this.mOnSelectionListener.onRequestSelectedFiles();
CopyMoveActionPolicy.moveFileSystemObjects(
this.mContext,
createLinkedResource(selection, this.mFso),
this.mOnSelectionListener,
this.mOnRequestRefreshListener);
}
break;
// Delete selection
case R.id.mnu_actions_delete_selection:
if (this.mOnSelectionListener != null) {
List<FileSystemObject> selection =
this.mOnSelectionListener.onRequestSelectedFiles();
DeleteActionPolicy.removeFileSystemObjects(
this.mContext,
selection,
this.mOnSelectionListener,
this.mOnRequestRefreshListener,
null);
}
break;
//- Uncompress
case R.id.mnu_actions_extract:
CompressActionPolicy.uncompress(
this.mContext,
this.mFso,
this.mOnRequestRefreshListener);
break;
//- Compress
case R.id.mnu_actions_compress:
if (this.mOnSelectionListener != null) {
CompressActionPolicy.compress(
this.mContext,
this.mFso,
this.mOnSelectionListener,
this.mOnRequestRefreshListener);
}
break;
case R.id.mnu_actions_compress_selection:
if (this.mOnSelectionListener != null) {
CompressActionPolicy.compress(
this.mContext,
this.mOnSelectionListener,
this.mOnRequestRefreshListener);
}
break;
//- Create copy
case R.id.mnu_actions_create_copy:
// Create a copy of the fso
if (this.mOnSelectionListener != null) {
CopyMoveActionPolicy.createCopyFileSystemObject(
this.mContext,
this.mFso,
this.mOnSelectionListener,
this.mOnRequestRefreshListener);
}
break;
//- Add to bookmarks
case R.id.mnu_actions_add_to_bookmarks:
case R.id.mnu_actions_add_to_bookmarks_current_folder:
Bookmark bookmark = BookmarksActionPolicy.addToBookmarks(
this.mContext, this.mFso);
if (mBackRef != null && bookmark != null) {
// tell NavigationActivity's drawer to add the bookmark
mBackRef.addBookmark(bookmark);
}
break;
//- Add shortcut
case R.id.mnu_actions_add_shortcut:
case R.id.mnu_actions_add_shortcut_current_folder:
IntentsActionPolicy.createShortcut(this.mContext, this.mFso);
break;
//- Compute checksum
case R.id.mnu_actions_compute_checksum:
InfoActionPolicy.showComputeChecksumDialog(this.mContext, this.mFso);
break;
//- Print
case R.id.mnu_actions_print:
PrintActionPolicy.printDocument(this.mContext, this.mFso);
break;
//- Properties
case R.id.mnu_actions_properties:
case R.id.mnu_actions_properties_current_folder:
FileSystemObject fso = this.mFso;
if (this.mOnSelectionListener != null) {
List<FileSystemObject> selection = this.mOnSelectionListener
.onRequestSelectedFiles();
if (selection.size() == 1) {
fso = selection.get(0);
}
}
InfoActionPolicy.showPropertiesDialog(
this.mContext, fso, this.mOnRequestRefreshListener);
break;
//- Navigate to parent
case R.id.mnu_actions_open_parent_folder:
NavigationActionPolicy.openParentFolder(
this.mContext, this.mFso, this.mOnRequestRefreshListener);
break;
// Set as home
case R.id.mnu_actions_set_as_home:
case R.id.mnu_actions_global_set_as_home:
try {
Preferences.savePreference(
FileManagerSettings.SETTINGS_INITIAL_DIR, mFso.getFullPath(), true);
mOnRequestRefreshListener.onRequestBookmarksRefresh();
DialogHelper.showToast(mContext, R.string.msgs_success, Toast.LENGTH_SHORT);
} catch (InvalidClassException e) {
ExceptionUtil.translateException(mContext, e);
}
break;
default:
break;
}
//Dismiss the dialog
this.mDialog.dismiss();
}
/**
* Method that show a new dialog for input a name.
*
* @param menuItem The item menu associated
*/
private void showInputNameDialog(final MenuItem menuItem) {
//Hide the dialog
this.mDialog.hide();
//Show the input name dialog
final InputNameDialog inputNameDialog =
new InputNameDialog(
this.mContext,
this.mOnSelectionListener.onRequestCurrentDir(),
menuItem.getTitle().toString());
inputNameDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
//Show the menu again
DialogHelper.delegateDialogShow(
ActionsDialog.this.mContext, ActionsDialog.this.mDialog);
}
});
inputNameDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
//Retrieve the name an execute the action
try {
String name = inputNameDialog.getName();
createNewFileSystemObject(menuItem.getItemId(), name);
} finally {
ActionsDialog.this.mDialog.dismiss();
}
}
});
inputNameDialog.show();
}
/**
* Method that show a new dialog for input a name for an existing fso.
*
* @param menuItem The item menu associated
* @param fso The file system object
* @param allowFsoName If allow that the name of the fso will be returned
*/
private void showFsoInputNameDialog(
final MenuItem menuItem, final FileSystemObject fso, final boolean allowFsoName) {
//Hide the dialog
this.mDialog.hide();
//Show the input name dialog
final InputNameDialog inputNameDialog =
new InputNameDialog(
this.mContext,
this.mOnSelectionListener.onRequestCurrentDir(),
fso,
allowFsoName,
menuItem.getTitle().toString());
inputNameDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
//Show the menu again
DialogHelper.delegateDialogShow(
ActionsDialog.this.mContext, ActionsDialog.this.mDialog);
}
});
inputNameDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
//Retrieve the name an execute the action
try {
String name = inputNameDialog.getName();
switch (menuItem.getItemId()) {
case R.id.mnu_actions_rename:
// Rename the fso
if (ActionsDialog.this.mOnSelectionListener != null) {
CopyMoveActionPolicy.renameFileSystemObject(
ActionsDialog.this.mContext,
inputNameDialog.mFso,
name,
ActionsDialog.this.mOnSelectionListener,
ActionsDialog.this.mOnRequestRefreshListener);
}
break;
case R.id.mnu_actions_create_link:
case R.id.mnu_actions_create_link_global:
// Create a link to the fso
if (ActionsDialog.this.mOnSelectionListener != null) {
NewActionPolicy.createSymlink(
ActionsDialog.this.mContext,
inputNameDialog.mFso,
name,
ActionsDialog.this.mOnSelectionListener,
ActionsDialog.this.mOnRequestRefreshListener);
}
break;
default:
break;
}
} finally {
ActionsDialog.this.mDialog.dismiss();
}
}
});
inputNameDialog.show();
}
/**
* {@inheritDoc}
*/
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
DialogHelper.showToast(
this.mContext,
((TextView)view).getText().toString(),
Toast.LENGTH_SHORT);
return true;
}
/**
* Method that create the a new file system object.
*
* @param menuId The menu identifier (need to determine the fso type)
* @param name The name of the file system object
* @hide
*/
void createNewFileSystemObject(final int menuId, final String name) {
switch (menuId) {
case R.id.mnu_actions_new_directory:
NewActionPolicy.createNewDirectory(
this.mContext, name,
this.mOnSelectionListener, this.mOnRequestRefreshListener);
break;
case R.id.mnu_actions_new_file:
NewActionPolicy.createNewFile(
this.mContext, name,
this.mOnSelectionListener, this.mOnRequestRefreshListener);
break;
default:
break;
}
}
/**
* Method that configure the menu to show according the actual information,
* the kind of request, the file selection, the mount point, ...
*
* @param menu The menu to configure
*/
private void configureMenu(Menu menu) {
// Selection
List<FileSystemObject> selection = null;
if (this.mOnSelectionListener != null) {
selection = this.mOnSelectionListener.onRequestSelectedFiles();
}
//- Check actions that needs a valid reference
if (!this.mGlobal && this.mFso != null) {
//- Select/Deselect -> Only one of them
if (this.mOnSelectionListener != null) {
boolean selected =
SelectionHelper.isFileSystemObjectSelected(
this.mOnSelectionListener.onRequestSelectedFiles(),
this.mFso);
menu.removeItem(selected ? R.id.mnu_actions_select : R.id.mnu_actions_deselect);
} else {
// Remove both menus
menu.removeItem(R.id.mnu_actions_select);
menu.removeItem(R.id.mnu_actions_deselect);
// Not allowed because we need a list of the current files (only from navigation
// activity)
menu.removeItem(R.id.mnu_actions_rename);
menu.removeItem(R.id.mnu_actions_create_copy);
}
//- Open/Open with -> Only when the fso is not a folder and is not a system file
if (FileHelper.isDirectory(this.mFso) || FileHelper.isSystemFile(this.mFso)) {
menu.removeItem(R.id.mnu_actions_open);
menu.removeItem(R.id.mnu_actions_open_with);
menu.removeItem(R.id.mnu_actions_send);
}
if (!IntentsActionPolicy.sendHandledByAnyActivity(mContext, this.mFso)) {
menu.removeItem(R.id.mnu_actions_send);
}
// Create link (not allow in storage volume)
if (StorageHelper.isPathInStorageVolume(this.mFso.getFullPath())) {
menu.removeItem(R.id.mnu_actions_create_link);
}
//Execute only if mime/type category is EXEC
MimeTypeCategory category = MimeTypeHelper.getCategory(this.mContext, this.mFso);
if (category.compareTo(MimeTypeCategory.EXEC) != 0) {
menu.removeItem(R.id.mnu_actions_execute);
}
//- Checksum (only supported for files)
if (FileHelper.isDirectory(this.mFso) || this.mFso instanceof Symlink) {
menu.removeItem(R.id.mnu_actions_compute_checksum);
}
//- Print (only for text and image categories)
if (!PrintActionPolicy.isPrintedAllowed(mContext, mFso)) {
menu.removeItem(R.id.mnu_actions_print);
}
}
//- Add to bookmarks -> Only directories
if (this.mFso != null && FileHelper.isRootDirectory(this.mFso)) {
menu.removeItem(R.id.mnu_actions_add_to_bookmarks);
menu.removeItem(R.id.mnu_actions_add_to_bookmarks_current_folder);
}
//- Remove properties option if multiple files selected
// or this selection contains a secure folder.
if ((selection != null && selection.size() > 1) || containsSecureDirectory(selection)) {
menu.removeItem(R.id.mnu_actions_properties);
menu.removeItem(R.id.mnu_actions_properties_current_folder);
}
//- Paste/Move only when have a selection
if (this.mGlobal) {
if (selection == null || selection.size() == 0 ||
(this.mFso != null && !FileHelper.isDirectory(this.mFso))) {
// Remove paste/move actions
menu.removeItem(R.id.mnu_actions_paste_selection);
menu.removeItem(R.id.mnu_actions_move_selection);
menu.removeItem(R.id.mnu_actions_delete_selection);
}
}
//- Create link
if (this.mGlobal && (selection == null || selection.size() == 0
|| selection.size() > 1)) {
// Only when one item is selected
menu.removeItem(R.id.mnu_actions_create_link_global);
} else if (this.mGlobal && selection != null) {
// Create link (not allow in sdcard, secure or remote storage volumes)
FileSystemObject fso = selection.get(0);
if (StorageHelper.isPathInStorageVolume(fso.getFullPath())
|| fso.isSecure() || fso.isRemote()) {
menu.removeItem(R.id.mnu_actions_create_link_global);
}
} else if (!this.mGlobal) {
// Create link (not allow in sdcard, secure or remote storage volumes)
if (StorageHelper.isPathInStorageVolume(this.mFso.getFullPath())
|| mFso.isSecure() || mFso.isRemote()) {
menu.removeItem(R.id.mnu_actions_create_link);
}
}
//- Compress/Uncompress (only when selection is available)
if (this.mOnSelectionListener != null) {
//Compress
if (this.mGlobal) {
if (selection == null || selection.size() == 0) {
menu.removeItem(R.id.mnu_actions_compress_selection);
} else {
for (FileSystemObject fso : selection) {
// Ignore for system, secure or remote files
if (fso instanceof SystemFile || fso.isSecure() || fso.isRemote()) {
menu.removeItem(R.id.mnu_actions_compress_selection);
break;
}
}
}
} else {
// Ignore for system, secure or remote files
if (this.mFso instanceof SystemFile || mFso.isSecure() || mFso.isRemote()) {
menu.removeItem(R.id.mnu_actions_compress);
}
}
//Uncompress (Only supported files)
if (!this.mGlobal && !FileHelper.isSupportedUncompressedFile(this.mFso)) {
menu.removeItem(R.id.mnu_actions_extract);
}
// Send multiple (only regular files)
if (this.mGlobal) {
if (selection == null || selection.size() == 0) {
menu.removeItem(R.id.mnu_actions_send_selection);
} else {
boolean areAllFiles = true;
int cc = selection.size();
for (int i = 0; i < cc; i++) {
FileSystemObject fso = selection.get(i);
if (FileHelper.isDirectory(fso)) {
areAllFiles = false;
break;
}
}
if (!areAllFiles ||
!IntentsActionPolicy.sendHandledByAnyActivity(mContext, selection)) {
menu.removeItem(R.id.mnu_actions_send_selection);
}
}
}
}
// Shotcuts and Bookmarks (not available in virtual filesystems)
if (!mGlobal && (mFso.isSecure() || mFso.isRemote())) {
menu.removeItem(R.id.mnu_actions_add_shortcut);
menu.removeItem(R.id.mnu_actions_add_to_bookmarks);
} else if (mGlobal) {
// Remove shortcuts for secure folders
if (mFso != null && mFso.isSecure()) {
menu.removeItem(R.id.mnu_actions_add_shortcut_current_folder);
}
if (selection != null && selection.size() > 0) {
for (FileSystemObject fso : selection) {
if (fso.isSecure() || fso.isRemote()) {
menu.removeItem(R.id.mnu_actions_add_shortcut_current_folder);
menu.removeItem(R.id.mnu_actions_add_to_bookmarks_current_folder);
break;
}
}
}
}
// Set as home
if (!mGlobal && !FileHelper.isDirectory(mFso)) {
menu.removeItem(R.id.mnu_actions_set_as_home);
} else if (mGlobal && (selection != null && selection.size() > 0)) {
menu.removeItem(R.id.mnu_actions_global_set_as_home);
} else if (!mGlobal && (mFso.isSecure() || mFso.isRemote())) {
menu.removeItem(R.id.mnu_actions_set_as_home);
} else if (mGlobal && (mFso.isSecure() || mFso.isRemote())) {
menu.removeItem(R.id.mnu_actions_global_set_as_home);
}
// Not allowed in search
if (this.mSearch) {
menu.removeItem(R.id.mnu_actions_extract);
menu.removeItem(R.id.mnu_actions_compress);
menu.removeItem(R.id.mnu_actions_create_link);
} else {
// Not allowed if not in search
menu.removeItem(R.id.mnu_actions_open_parent_folder);
}
// Remove unsafe operations over virtual mountpoint directories
List<Directory> virtualDirs = VirtualMountPointConsole.getVirtualMountableDirectories();
if (!mGlobal && FileHelper.isDirectory(mFso) && virtualDirs.contains(mFso)) {
menu.removeItem(R.id.mnu_actions_delete);
menu.removeItem(R.id.mnu_actions_rename);
menu.removeItem(R.id.mnu_actions_compress);
menu.removeItem(R.id.mnu_actions_create_copy);
menu.removeItem(R.id.mnu_actions_create_link);
menu.removeItem(R.id.mnu_actions_add_shortcut);
menu.removeItem(R.id.mnu_actions_add_to_bookmarks);
} else if (mGlobal) {
if (selection != null && selection.size() > 0) {
for (FileSystemObject fso : selection) {
if (FileHelper.isDirectory(fso) && virtualDirs.contains(fso)) {
menu.removeItem(R.id.mnu_actions_paste_selection);
menu.removeItem(R.id.mnu_actions_move_selection);
menu.removeItem(R.id.mnu_actions_delete_selection);
menu.removeItem(R.id.mnu_actions_compress_selection);
menu.removeItem(R.id.mnu_actions_create_link_global);
menu.removeItem(R.id.mnu_actions_send_selection);
menu.removeItem(R.id.mnu_actions_create_link_global);
menu.removeItem(R.id.mnu_actions_create_link_global);
menu.removeItem(R.id.mnu_actions_create_link_global);
menu.removeItem(R.id.mnu_actions_add_shortcut_current_folder);
menu.removeItem(R.id.mnu_actions_add_to_bookmarks_current_folder);
break;
}
}
}
}
// Remove not-ChRooted actions (actions that can't be present when running in
// unprivileged mode)
if (this.mChRooted) {
menu.removeItem(R.id.mnu_actions_create_link);
menu.removeItem(R.id.mnu_actions_create_link_global);
menu.removeItem(R.id.mnu_actions_execute);
// NOTE: This actions are not implemented in chrooted environments. The reason is
// that the main target of this application is CyanogenMod (a rooted environment).
// Adding this actions requires the use of commons-compress, an external Apache
// library that will add more size to the ending apk.
// For now, will maintain without implementation. Maybe, in the future.
menu.removeItem(R.id.mnu_actions_compress);
menu.removeItem(R.id.mnu_actions_compress_selection);
menu.removeItem(R.id.mnu_actions_extract);
}
}
/**
* Method that creates a {@link LinkedResource} for the list of object to the
* destination directory
*
* @param items The list of the source items
* @param directory The destination directory
*/
private static List<LinkedResource> createLinkedResource(
List<FileSystemObject> items, FileSystemObject directory) {
List<LinkedResource> resources =
new ArrayList<LinkedResource>(items.size());
int cc = items.size();
for (int i = 0; i < cc; i++) {
FileSystemObject fso = items.get(i);
File src = new File(fso.getFullPath());
File dst = new File(directory.getFullPath(), fso.getName());
resources.add(new LinkedResource(src, dst));
}
return resources;
}
private boolean containsSecureDirectory(List<FileSystemObject> selection) {
if (mFso != null && FileHelper.isDirectory(mFso) && mFso.isSecure()) {
return true;
}
if (selection == null) {
return false;
}
for (FileSystemObject fso : selection) {
if (FileHelper.isDirectory(fso) && fso.isSecure()) {
return true;
}
}
return false;
}
}
|
UTF-8
|
Java
| 37,895 |
java
|
ActionsDialog.java
|
Java
|
[] | null |
[] |
/*
* Copyright (C) 2012 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.cyanogenmod.filemanager.ui.dialogs;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.HapticFeedbackConstants;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.cyanogenmod.filemanager.FileManagerApplication;
import com.cyanogenmod.filemanager.R;
import com.cyanogenmod.filemanager.activities.NavigationActivity;
import com.cyanogenmod.filemanager.adapters.TwoColumnsMenuListAdapter;
import com.cyanogenmod.filemanager.console.VirtualMountPointConsole;
import com.cyanogenmod.filemanager.listeners.OnRequestRefreshListener;
import com.cyanogenmod.filemanager.listeners.OnSelectionListener;
import com.cyanogenmod.filemanager.model.Bookmark;
import com.cyanogenmod.filemanager.model.Directory;
import com.cyanogenmod.filemanager.model.FileSystemObject;
import com.cyanogenmod.filemanager.model.Symlink;
import com.cyanogenmod.filemanager.model.SystemFile;
import com.cyanogenmod.filemanager.preferences.AccessMode;
import com.cyanogenmod.filemanager.preferences.FileManagerSettings;
import com.cyanogenmod.filemanager.preferences.Preferences;
import com.cyanogenmod.filemanager.ui.ThemeManager;
import com.cyanogenmod.filemanager.ui.ThemeManager.Theme;
import com.cyanogenmod.filemanager.ui.policy.BookmarksActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.CompressActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.CopyMoveActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.CopyMoveActionPolicy.LinkedResource;
import com.cyanogenmod.filemanager.ui.policy.DeleteActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.ExecutionActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.InfoActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.IntentsActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.NavigationActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.NewActionPolicy;
import com.cyanogenmod.filemanager.ui.policy.PrintActionPolicy;
import com.cyanogenmod.filemanager.util.DialogHelper;
import com.cyanogenmod.filemanager.util.ExceptionUtil;
import com.cyanogenmod.filemanager.util.FileHelper;
import com.cyanogenmod.filemanager.util.MimeTypeHelper;
import com.cyanogenmod.filemanager.util.MimeTypeHelper.MimeTypeCategory;
import com.cyanogenmod.filemanager.util.SelectionHelper;
import com.cyanogenmod.filemanager.util.StorageHelper;
import java.io.File;
import java.io.InvalidClassException;
import java.util.ArrayList;
import java.util.List;
/**
* A class that wraps a dialog for showing the list of actions that
* the user can do.
*/
public class ActionsDialog implements OnItemClickListener, OnItemLongClickListener {
/**
* @hide
*/
final Context mContext;
final NavigationActivity mBackRef;
private final boolean mGlobal;
private final boolean mSearch;
private final boolean mChRooted;
/**
* @hide
*/
AlertDialog mDialog;
private ListView mListView;
/**
* @hide
*/
final FileSystemObject mFso;
/**
* @hide
*/
OnRequestRefreshListener mOnRequestRefreshListener;
/**
* @hide
*/
OnSelectionListener mOnSelectionListener;
/**
* Constructor of <code>ActionsDialog</code>.
*
* @param context The current context
* @param fso The file system object associated
* @param global If the menu to display will be the global one (Global actions)
* @param search If the call is from search activity
*/
public ActionsDialog(Context context, NavigationActivity backRef, FileSystemObject fso,
boolean global, boolean search) {
super();
//Save the data
this.mFso = fso;
this.mContext = context;
this.mBackRef = backRef;
this.mGlobal = global;
this.mSearch = search;
this.mChRooted = FileManagerApplication.getAccessMode().compareTo(AccessMode.SAFE) == 0;
//Initialize dialog
init(context, global ? R.id.mnu_actions_global : R.id.mnu_actions_fso);
}
/**
* Method that initializes the dialog.
*
* @param context The current context
* @param group The group of action menus to show
*/
private void init(Context context, int group) {
//Create the menu adapter
TwoColumnsMenuListAdapter adapter =
new TwoColumnsMenuListAdapter(context, R.menu.actions, group, false);
adapter.setOnItemClickListener(this);
adapter.setOnItemLongClickListener(this);
//Create the list view
this.mListView = new ListView(context);
LinearLayout.LayoutParams params =
new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
this.mListView.setLayoutParams(params);
this.mListView.setAdapter(adapter);
// Apply the current theme
Theme theme = ThemeManager.getCurrentTheme(context);
theme.setBackgroundDrawable(context, this.mListView, "background_drawable"); //$NON-NLS-1$
this.mListView.setDivider(
theme.getDrawable(context, "horizontal_divider_drawable")); //$NON-NLS-1$
//Create the dialog
this.mDialog = DialogHelper.createDialog(
context,
0,
R.string.actions_dialog_title,
this.mListView);
this.mDialog.setButton(
DialogInterface.BUTTON_NEGATIVE,
this.mContext.getString(android.R.string.cancel),
(DialogInterface.OnClickListener)null);
}
/**
* Method that sets the listener for communicate a refresh request.
*
* @param onRequestRefreshListener The request refresh listener
*/
public void setOnRequestRefreshListener(OnRequestRefreshListener onRequestRefreshListener) {
this.mOnRequestRefreshListener = onRequestRefreshListener;
}
/**
* Method that sets the listener for requesting selection data
*
* @param onSelectionListener The request selection data listener
*/
public void setOnSelectionListener(OnSelectionListener onSelectionListener) {
this.mOnSelectionListener = onSelectionListener;
}
/**
* Method that shows the dialog.
*/
public void show() {
TwoColumnsMenuListAdapter adapter =
(TwoColumnsMenuListAdapter)this.mListView.getAdapter();
configureMenu(adapter.getMenu());
DialogHelper.delegateDialogShow(this.mContext, this.mDialog);
}
/**
* Method that judges whether the dialog is showing.
*/
public boolean isShowing() {
if (this.mDialog != null) {
return this.mDialog.isShowing();
}
return false;
}
/**
* {@inheritDoc}
*/
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, final long id) {
//Retrieve the menu item
MenuItem menuItem = ((TwoColumnsMenuListAdapter)parent.getAdapter()).getItemById((int)id);
//What action was selected?
switch ((int)id) {
//- Create new object
case R.id.mnu_actions_new_directory:
case R.id.mnu_actions_new_file:
// Dialog is dismissed inside showInputNameDialog
if (this.mOnSelectionListener != null) {
showInputNameDialog(menuItem);
return;
}
break;
//- Rename
case R.id.mnu_actions_rename:
// Dialog is dismissed inside showInputNameDialog
if (this.mOnSelectionListener != null) {
showFsoInputNameDialog(menuItem, this.mFso, false);
return;
}
break;
//- Create link
case R.id.mnu_actions_create_link:
// Dialog is dismissed inside showInputNameDialog
if (this.mOnSelectionListener != null) {
showFsoInputNameDialog(menuItem, this.mFso, true);
return;
}
break;
case R.id.mnu_actions_create_link_global:
// Dialog is dismissed inside showInputNameDialog
if (this.mOnSelectionListener != null) {
// The selection must be only 1 item
List<FileSystemObject> selection =
this.mOnSelectionListener.onRequestSelectedFiles();
if (selection != null && selection.size() == 1) {
showFsoInputNameDialog(menuItem, selection.get(0), true);
}
return;
}
break;
//- Delete
case R.id.mnu_actions_delete:
DeleteActionPolicy.removeFileSystemObject(
this.mContext,
this.mFso,
this.mOnSelectionListener,
this.mOnRequestRefreshListener,
null);
break;
//- Refresh
case R.id.mnu_actions_refresh:
if (this.mOnRequestRefreshListener != null) {
this.mOnRequestRefreshListener.onRequestRefresh(null, false); //Refresh all
}
break;
//- Select/Deselect
case R.id.mnu_actions_select:
case R.id.mnu_actions_deselect:
if (this.mOnSelectionListener != null) {
this.mOnSelectionListener.onToggleSelection(this.mFso);
}
break;
case R.id.mnu_actions_select_all:
if (this.mOnSelectionListener != null) {
this.mOnSelectionListener.onSelectAllVisibleItems();
}
break;
case R.id.mnu_actions_deselect_all:
if (this.mOnSelectionListener != null) {
this.mOnSelectionListener.onDeselectAllVisibleItems();
}
break;
//- Open
case R.id.mnu_actions_open:
IntentsActionPolicy.openFileSystemObject(
this.mContext, this.mFso, false, null);
break;
//- Open with
case R.id.mnu_actions_open_with:
IntentsActionPolicy.openFileSystemObject(
this.mContext, this.mFso, true, null);
break;
//- Execute
case R.id.mnu_actions_execute:
ExecutionActionPolicy.execute(this.mContext, this.mFso);
break;
//- Send
case R.id.mnu_actions_send:
IntentsActionPolicy.sendFileSystemObject(
this.mContext, this.mFso, null);
break;
case R.id.mnu_actions_send_selection:
if (this.mOnSelectionListener != null) {
List<FileSystemObject> selection =
this.mOnSelectionListener.onRequestSelectedFiles();
if (selection.size() == 1) {
IntentsActionPolicy.sendFileSystemObject(
this.mContext, selection.get(0), null);
} else {
IntentsActionPolicy.sendMultipleFileSystemObject(
this.mContext, selection, null);
}
}
break;
// Paste selection
case R.id.mnu_actions_paste_selection:
if (this.mOnSelectionListener != null) {
List<FileSystemObject> selection =
this.mOnSelectionListener.onRequestSelectedFiles();
CopyMoveActionPolicy.copyFileSystemObjects(
this.mContext,
createLinkedResource(selection, this.mFso),
this.mOnSelectionListener,
this.mOnRequestRefreshListener);
}
break;
// Move selection
case R.id.mnu_actions_move_selection:
if (this.mOnSelectionListener != null) {
List<FileSystemObject> selection =
this.mOnSelectionListener.onRequestSelectedFiles();
CopyMoveActionPolicy.moveFileSystemObjects(
this.mContext,
createLinkedResource(selection, this.mFso),
this.mOnSelectionListener,
this.mOnRequestRefreshListener);
}
break;
// Delete selection
case R.id.mnu_actions_delete_selection:
if (this.mOnSelectionListener != null) {
List<FileSystemObject> selection =
this.mOnSelectionListener.onRequestSelectedFiles();
DeleteActionPolicy.removeFileSystemObjects(
this.mContext,
selection,
this.mOnSelectionListener,
this.mOnRequestRefreshListener,
null);
}
break;
//- Uncompress
case R.id.mnu_actions_extract:
CompressActionPolicy.uncompress(
this.mContext,
this.mFso,
this.mOnRequestRefreshListener);
break;
//- Compress
case R.id.mnu_actions_compress:
if (this.mOnSelectionListener != null) {
CompressActionPolicy.compress(
this.mContext,
this.mFso,
this.mOnSelectionListener,
this.mOnRequestRefreshListener);
}
break;
case R.id.mnu_actions_compress_selection:
if (this.mOnSelectionListener != null) {
CompressActionPolicy.compress(
this.mContext,
this.mOnSelectionListener,
this.mOnRequestRefreshListener);
}
break;
//- Create copy
case R.id.mnu_actions_create_copy:
// Create a copy of the fso
if (this.mOnSelectionListener != null) {
CopyMoveActionPolicy.createCopyFileSystemObject(
this.mContext,
this.mFso,
this.mOnSelectionListener,
this.mOnRequestRefreshListener);
}
break;
//- Add to bookmarks
case R.id.mnu_actions_add_to_bookmarks:
case R.id.mnu_actions_add_to_bookmarks_current_folder:
Bookmark bookmark = BookmarksActionPolicy.addToBookmarks(
this.mContext, this.mFso);
if (mBackRef != null && bookmark != null) {
// tell NavigationActivity's drawer to add the bookmark
mBackRef.addBookmark(bookmark);
}
break;
//- Add shortcut
case R.id.mnu_actions_add_shortcut:
case R.id.mnu_actions_add_shortcut_current_folder:
IntentsActionPolicy.createShortcut(this.mContext, this.mFso);
break;
//- Compute checksum
case R.id.mnu_actions_compute_checksum:
InfoActionPolicy.showComputeChecksumDialog(this.mContext, this.mFso);
break;
//- Print
case R.id.mnu_actions_print:
PrintActionPolicy.printDocument(this.mContext, this.mFso);
break;
//- Properties
case R.id.mnu_actions_properties:
case R.id.mnu_actions_properties_current_folder:
FileSystemObject fso = this.mFso;
if (this.mOnSelectionListener != null) {
List<FileSystemObject> selection = this.mOnSelectionListener
.onRequestSelectedFiles();
if (selection.size() == 1) {
fso = selection.get(0);
}
}
InfoActionPolicy.showPropertiesDialog(
this.mContext, fso, this.mOnRequestRefreshListener);
break;
//- Navigate to parent
case R.id.mnu_actions_open_parent_folder:
NavigationActionPolicy.openParentFolder(
this.mContext, this.mFso, this.mOnRequestRefreshListener);
break;
// Set as home
case R.id.mnu_actions_set_as_home:
case R.id.mnu_actions_global_set_as_home:
try {
Preferences.savePreference(
FileManagerSettings.SETTINGS_INITIAL_DIR, mFso.getFullPath(), true);
mOnRequestRefreshListener.onRequestBookmarksRefresh();
DialogHelper.showToast(mContext, R.string.msgs_success, Toast.LENGTH_SHORT);
} catch (InvalidClassException e) {
ExceptionUtil.translateException(mContext, e);
}
break;
default:
break;
}
//Dismiss the dialog
this.mDialog.dismiss();
}
/**
* Method that show a new dialog for input a name.
*
* @param menuItem The item menu associated
*/
private void showInputNameDialog(final MenuItem menuItem) {
//Hide the dialog
this.mDialog.hide();
//Show the input name dialog
final InputNameDialog inputNameDialog =
new InputNameDialog(
this.mContext,
this.mOnSelectionListener.onRequestCurrentDir(),
menuItem.getTitle().toString());
inputNameDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
//Show the menu again
DialogHelper.delegateDialogShow(
ActionsDialog.this.mContext, ActionsDialog.this.mDialog);
}
});
inputNameDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
//Retrieve the name an execute the action
try {
String name = inputNameDialog.getName();
createNewFileSystemObject(menuItem.getItemId(), name);
} finally {
ActionsDialog.this.mDialog.dismiss();
}
}
});
inputNameDialog.show();
}
/**
* Method that show a new dialog for input a name for an existing fso.
*
* @param menuItem The item menu associated
* @param fso The file system object
* @param allowFsoName If allow that the name of the fso will be returned
*/
private void showFsoInputNameDialog(
final MenuItem menuItem, final FileSystemObject fso, final boolean allowFsoName) {
//Hide the dialog
this.mDialog.hide();
//Show the input name dialog
final InputNameDialog inputNameDialog =
new InputNameDialog(
this.mContext,
this.mOnSelectionListener.onRequestCurrentDir(),
fso,
allowFsoName,
menuItem.getTitle().toString());
inputNameDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
//Show the menu again
DialogHelper.delegateDialogShow(
ActionsDialog.this.mContext, ActionsDialog.this.mDialog);
}
});
inputNameDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
//Retrieve the name an execute the action
try {
String name = inputNameDialog.getName();
switch (menuItem.getItemId()) {
case R.id.mnu_actions_rename:
// Rename the fso
if (ActionsDialog.this.mOnSelectionListener != null) {
CopyMoveActionPolicy.renameFileSystemObject(
ActionsDialog.this.mContext,
inputNameDialog.mFso,
name,
ActionsDialog.this.mOnSelectionListener,
ActionsDialog.this.mOnRequestRefreshListener);
}
break;
case R.id.mnu_actions_create_link:
case R.id.mnu_actions_create_link_global:
// Create a link to the fso
if (ActionsDialog.this.mOnSelectionListener != null) {
NewActionPolicy.createSymlink(
ActionsDialog.this.mContext,
inputNameDialog.mFso,
name,
ActionsDialog.this.mOnSelectionListener,
ActionsDialog.this.mOnRequestRefreshListener);
}
break;
default:
break;
}
} finally {
ActionsDialog.this.mDialog.dismiss();
}
}
});
inputNameDialog.show();
}
/**
* {@inheritDoc}
*/
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
DialogHelper.showToast(
this.mContext,
((TextView)view).getText().toString(),
Toast.LENGTH_SHORT);
return true;
}
/**
* Method that create the a new file system object.
*
* @param menuId The menu identifier (need to determine the fso type)
* @param name The name of the file system object
* @hide
*/
void createNewFileSystemObject(final int menuId, final String name) {
switch (menuId) {
case R.id.mnu_actions_new_directory:
NewActionPolicy.createNewDirectory(
this.mContext, name,
this.mOnSelectionListener, this.mOnRequestRefreshListener);
break;
case R.id.mnu_actions_new_file:
NewActionPolicy.createNewFile(
this.mContext, name,
this.mOnSelectionListener, this.mOnRequestRefreshListener);
break;
default:
break;
}
}
/**
* Method that configure the menu to show according the actual information,
* the kind of request, the file selection, the mount point, ...
*
* @param menu The menu to configure
*/
private void configureMenu(Menu menu) {
// Selection
List<FileSystemObject> selection = null;
if (this.mOnSelectionListener != null) {
selection = this.mOnSelectionListener.onRequestSelectedFiles();
}
//- Check actions that needs a valid reference
if (!this.mGlobal && this.mFso != null) {
//- Select/Deselect -> Only one of them
if (this.mOnSelectionListener != null) {
boolean selected =
SelectionHelper.isFileSystemObjectSelected(
this.mOnSelectionListener.onRequestSelectedFiles(),
this.mFso);
menu.removeItem(selected ? R.id.mnu_actions_select : R.id.mnu_actions_deselect);
} else {
// Remove both menus
menu.removeItem(R.id.mnu_actions_select);
menu.removeItem(R.id.mnu_actions_deselect);
// Not allowed because we need a list of the current files (only from navigation
// activity)
menu.removeItem(R.id.mnu_actions_rename);
menu.removeItem(R.id.mnu_actions_create_copy);
}
//- Open/Open with -> Only when the fso is not a folder and is not a system file
if (FileHelper.isDirectory(this.mFso) || FileHelper.isSystemFile(this.mFso)) {
menu.removeItem(R.id.mnu_actions_open);
menu.removeItem(R.id.mnu_actions_open_with);
menu.removeItem(R.id.mnu_actions_send);
}
if (!IntentsActionPolicy.sendHandledByAnyActivity(mContext, this.mFso)) {
menu.removeItem(R.id.mnu_actions_send);
}
// Create link (not allow in storage volume)
if (StorageHelper.isPathInStorageVolume(this.mFso.getFullPath())) {
menu.removeItem(R.id.mnu_actions_create_link);
}
//Execute only if mime/type category is EXEC
MimeTypeCategory category = MimeTypeHelper.getCategory(this.mContext, this.mFso);
if (category.compareTo(MimeTypeCategory.EXEC) != 0) {
menu.removeItem(R.id.mnu_actions_execute);
}
//- Checksum (only supported for files)
if (FileHelper.isDirectory(this.mFso) || this.mFso instanceof Symlink) {
menu.removeItem(R.id.mnu_actions_compute_checksum);
}
//- Print (only for text and image categories)
if (!PrintActionPolicy.isPrintedAllowed(mContext, mFso)) {
menu.removeItem(R.id.mnu_actions_print);
}
}
//- Add to bookmarks -> Only directories
if (this.mFso != null && FileHelper.isRootDirectory(this.mFso)) {
menu.removeItem(R.id.mnu_actions_add_to_bookmarks);
menu.removeItem(R.id.mnu_actions_add_to_bookmarks_current_folder);
}
//- Remove properties option if multiple files selected
// or this selection contains a secure folder.
if ((selection != null && selection.size() > 1) || containsSecureDirectory(selection)) {
menu.removeItem(R.id.mnu_actions_properties);
menu.removeItem(R.id.mnu_actions_properties_current_folder);
}
//- Paste/Move only when have a selection
if (this.mGlobal) {
if (selection == null || selection.size() == 0 ||
(this.mFso != null && !FileHelper.isDirectory(this.mFso))) {
// Remove paste/move actions
menu.removeItem(R.id.mnu_actions_paste_selection);
menu.removeItem(R.id.mnu_actions_move_selection);
menu.removeItem(R.id.mnu_actions_delete_selection);
}
}
//- Create link
if (this.mGlobal && (selection == null || selection.size() == 0
|| selection.size() > 1)) {
// Only when one item is selected
menu.removeItem(R.id.mnu_actions_create_link_global);
} else if (this.mGlobal && selection != null) {
// Create link (not allow in sdcard, secure or remote storage volumes)
FileSystemObject fso = selection.get(0);
if (StorageHelper.isPathInStorageVolume(fso.getFullPath())
|| fso.isSecure() || fso.isRemote()) {
menu.removeItem(R.id.mnu_actions_create_link_global);
}
} else if (!this.mGlobal) {
// Create link (not allow in sdcard, secure or remote storage volumes)
if (StorageHelper.isPathInStorageVolume(this.mFso.getFullPath())
|| mFso.isSecure() || mFso.isRemote()) {
menu.removeItem(R.id.mnu_actions_create_link);
}
}
//- Compress/Uncompress (only when selection is available)
if (this.mOnSelectionListener != null) {
//Compress
if (this.mGlobal) {
if (selection == null || selection.size() == 0) {
menu.removeItem(R.id.mnu_actions_compress_selection);
} else {
for (FileSystemObject fso : selection) {
// Ignore for system, secure or remote files
if (fso instanceof SystemFile || fso.isSecure() || fso.isRemote()) {
menu.removeItem(R.id.mnu_actions_compress_selection);
break;
}
}
}
} else {
// Ignore for system, secure or remote files
if (this.mFso instanceof SystemFile || mFso.isSecure() || mFso.isRemote()) {
menu.removeItem(R.id.mnu_actions_compress);
}
}
//Uncompress (Only supported files)
if (!this.mGlobal && !FileHelper.isSupportedUncompressedFile(this.mFso)) {
menu.removeItem(R.id.mnu_actions_extract);
}
// Send multiple (only regular files)
if (this.mGlobal) {
if (selection == null || selection.size() == 0) {
menu.removeItem(R.id.mnu_actions_send_selection);
} else {
boolean areAllFiles = true;
int cc = selection.size();
for (int i = 0; i < cc; i++) {
FileSystemObject fso = selection.get(i);
if (FileHelper.isDirectory(fso)) {
areAllFiles = false;
break;
}
}
if (!areAllFiles ||
!IntentsActionPolicy.sendHandledByAnyActivity(mContext, selection)) {
menu.removeItem(R.id.mnu_actions_send_selection);
}
}
}
}
// Shotcuts and Bookmarks (not available in virtual filesystems)
if (!mGlobal && (mFso.isSecure() || mFso.isRemote())) {
menu.removeItem(R.id.mnu_actions_add_shortcut);
menu.removeItem(R.id.mnu_actions_add_to_bookmarks);
} else if (mGlobal) {
// Remove shortcuts for secure folders
if (mFso != null && mFso.isSecure()) {
menu.removeItem(R.id.mnu_actions_add_shortcut_current_folder);
}
if (selection != null && selection.size() > 0) {
for (FileSystemObject fso : selection) {
if (fso.isSecure() || fso.isRemote()) {
menu.removeItem(R.id.mnu_actions_add_shortcut_current_folder);
menu.removeItem(R.id.mnu_actions_add_to_bookmarks_current_folder);
break;
}
}
}
}
// Set as home
if (!mGlobal && !FileHelper.isDirectory(mFso)) {
menu.removeItem(R.id.mnu_actions_set_as_home);
} else if (mGlobal && (selection != null && selection.size() > 0)) {
menu.removeItem(R.id.mnu_actions_global_set_as_home);
} else if (!mGlobal && (mFso.isSecure() || mFso.isRemote())) {
menu.removeItem(R.id.mnu_actions_set_as_home);
} else if (mGlobal && (mFso.isSecure() || mFso.isRemote())) {
menu.removeItem(R.id.mnu_actions_global_set_as_home);
}
// Not allowed in search
if (this.mSearch) {
menu.removeItem(R.id.mnu_actions_extract);
menu.removeItem(R.id.mnu_actions_compress);
menu.removeItem(R.id.mnu_actions_create_link);
} else {
// Not allowed if not in search
menu.removeItem(R.id.mnu_actions_open_parent_folder);
}
// Remove unsafe operations over virtual mountpoint directories
List<Directory> virtualDirs = VirtualMountPointConsole.getVirtualMountableDirectories();
if (!mGlobal && FileHelper.isDirectory(mFso) && virtualDirs.contains(mFso)) {
menu.removeItem(R.id.mnu_actions_delete);
menu.removeItem(R.id.mnu_actions_rename);
menu.removeItem(R.id.mnu_actions_compress);
menu.removeItem(R.id.mnu_actions_create_copy);
menu.removeItem(R.id.mnu_actions_create_link);
menu.removeItem(R.id.mnu_actions_add_shortcut);
menu.removeItem(R.id.mnu_actions_add_to_bookmarks);
} else if (mGlobal) {
if (selection != null && selection.size() > 0) {
for (FileSystemObject fso : selection) {
if (FileHelper.isDirectory(fso) && virtualDirs.contains(fso)) {
menu.removeItem(R.id.mnu_actions_paste_selection);
menu.removeItem(R.id.mnu_actions_move_selection);
menu.removeItem(R.id.mnu_actions_delete_selection);
menu.removeItem(R.id.mnu_actions_compress_selection);
menu.removeItem(R.id.mnu_actions_create_link_global);
menu.removeItem(R.id.mnu_actions_send_selection);
menu.removeItem(R.id.mnu_actions_create_link_global);
menu.removeItem(R.id.mnu_actions_create_link_global);
menu.removeItem(R.id.mnu_actions_create_link_global);
menu.removeItem(R.id.mnu_actions_add_shortcut_current_folder);
menu.removeItem(R.id.mnu_actions_add_to_bookmarks_current_folder);
break;
}
}
}
}
// Remove not-ChRooted actions (actions that can't be present when running in
// unprivileged mode)
if (this.mChRooted) {
menu.removeItem(R.id.mnu_actions_create_link);
menu.removeItem(R.id.mnu_actions_create_link_global);
menu.removeItem(R.id.mnu_actions_execute);
// NOTE: This actions are not implemented in chrooted environments. The reason is
// that the main target of this application is CyanogenMod (a rooted environment).
// Adding this actions requires the use of commons-compress, an external Apache
// library that will add more size to the ending apk.
// For now, will maintain without implementation. Maybe, in the future.
menu.removeItem(R.id.mnu_actions_compress);
menu.removeItem(R.id.mnu_actions_compress_selection);
menu.removeItem(R.id.mnu_actions_extract);
}
}
/**
* Method that creates a {@link LinkedResource} for the list of object to the
* destination directory
*
* @param items The list of the source items
* @param directory The destination directory
*/
private static List<LinkedResource> createLinkedResource(
List<FileSystemObject> items, FileSystemObject directory) {
List<LinkedResource> resources =
new ArrayList<LinkedResource>(items.size());
int cc = items.size();
for (int i = 0; i < cc; i++) {
FileSystemObject fso = items.get(i);
File src = new File(fso.getFullPath());
File dst = new File(directory.getFullPath(), fso.getName());
resources.add(new LinkedResource(src, dst));
}
return resources;
}
private boolean containsSecureDirectory(List<FileSystemObject> selection) {
if (mFso != null && FileHelper.isDirectory(mFso) && mFso.isSecure()) {
return true;
}
if (selection == null) {
return false;
}
for (FileSystemObject fso : selection) {
if (FileHelper.isDirectory(fso) && fso.isSecure()) {
return true;
}
}
return false;
}
}
| 37,895 | 0.558702 | 0.557857 | 911 | 40.597145 | 26.207882 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.520307 | false | false |
0
|
12a9afb3310c7f9f2a063b63b1ad6f899f786ced
| 2,087,354,164,619 |
aa3bfcbb33a7ecd8faf0b278ba6f5e878dd62106
|
/gestioncursos/src/main/java/com/ipartek/formacion/pojo/Candidato.java
|
9a8a70d8ce430efae62ca06956929c2833008d22
|
[] |
no_license
|
DesarrolloWebJava/gestionalumnosProfesor
|
https://github.com/DesarrolloWebJava/gestionalumnosProfesor
|
36942bf86e5214681318f18593482f8ec084f668
|
6cac29796d615540676dd0e245f163f82295f38e
|
refs/heads/master
| 2016-09-14T17:10:00.549000 | 2016-09-13T13:47:09 | 2016-09-13T13:47:09 | 61,707,083 | 4 | 4 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.ipartek.formacion.pojo;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.ipartek.formacion.pojo.excepciones.CandidatoException;
import com.ipartek.formacion.service.Genero;
import com.ipartek.formacion.service.Util;
/**
*
* @author Curso
*
*/
public class Candidato {
public static final int CODIGO_ALUMNO = -1;
private int codigo;
private String nombre;
private String apellidos;
protected Date fNacimiento;
protected String dni;
private String email;
private String telefono;
private Double nota;
private Genero genero;
private List<Idioma> idiomas;
/**
* @throws CandidatoException
* excepcion al crear candidato
*/
public Candidato() {
super();
setCodigo(CODIGO_ALUMNO);
setNombre("");
setApellidos("");
this.dni = "";
this.fNacimiento = new Date();
setGenero(Genero.OTROS);
setNota(0.0);
setEmail("");
setTelefono("");
List<Idioma> aux = new ArrayList<Idioma>();
aux.add(Idioma.CASTELLANO);
setIdiomas(aux);
}
/**
*
* @return idioma
*/
public List<Idioma> getIdiomas() {
return idiomas;
}
/**
*
* @param idiomas
* lista de idiomas
*/
public void setIdiomas(List<Idioma> idiomas) {
this.idiomas = idiomas;
}
/**
*
* @return Double nota
*
*/
public Double getNota() {
return nota;
}
/**
*
* @param nota
* nota
*
*/
public void setNota(Double nota) {
this.nota = nota;
}
/**
*
* @return int codigo candidato
*/
public int getCodigo() {
return codigo;
}
/**
*
* @param codigo
* codigo
*/
public void setCodigo(int codigo) {
this.codigo = codigo;
}
/**
*
* @return nombre candidato
*/
public String getNombre() {
return nombre;
}
/**
*
* @param nombre
* nombre del candidato
*/
public void setNombre(String nombre) {
this.nombre = nombre;
}
/**
*
* @return apellidos del candidato
*/
public String getApellidos() {
return apellidos;
}
/**
*
* @param apellidos
* apellidos del candidato
*/
public void setApellidos(String apellidos) {
this.apellidos = apellidos;
}
/**
*
* @return fecha de nacimiento
*/
public Date getfNacimiento() {
return fNacimiento;
}
/**
*
* @param fNacimiento
* Date fecha de nacimiento
* @throws CandidatoException
* fecha no valida
*/
public void setfNacimiento(Date fNacimiento) throws CandidatoException {
if (fNacimiento.compareTo(new Date()) > 0) {
throw new CandidatoException(CandidatoException.CODIGO_ERROR_FECHA_NACIMIENTO,
CandidatoException.MSG_ERROR_FECHA_NACIMIENTO);
} else {
this.fNacimiento = fNacimiento;
}
}
/**
*
* @return DNI
*/
public String getDni() {
return dni;
}
/**
*
* @param dni
* String DNI
* @throws CandidatoException
* DNI no valido
*/
public void setDni(String dni) throws CandidatoException {
if (!Util.validarDni(dni)) {
throw new CandidatoException(CandidatoException.CODIGO_ERROR_DNI,
CandidatoException.MSG_ERROR_DNI);
}
this.dni = dni;
}
/**
*
* @return genero
*/
public Genero getGenero() {
return genero;
}
/**
*
* @param genero
* genero del candidato
*/
public void setGenero(Genero genero) {
this.genero = genero;
}
/**
*
* @return email
*/
public String getEmail() {
return email;
}
/**
*
* @param email
* String
*/
public void setEmail(String email) {
this.email = email;
}
/**
*
* @return telefono
*/
public String getTelefono() {
return telefono;
}
/**
*
* @param telefono
* String
*/
public void setTelefono(String telefono) {
this.telefono = telefono;
}
/**
*
* @return datos
*/
protected String mostrarDatos() {
return this.apellidos + ", " + this.nombre;
}
}
|
UTF-8
|
Java
| 4,148 |
java
|
Candidato.java
|
Java
|
[
{
"context": "partek.formacion.service.Util;\n\n/**\n * \n * @author Curso\n *\n */\npublic class Candidato {\n\n public static ",
"end": 291,
"score": 0.8932439088821411,
"start": 286,
"tag": "NAME",
"value": "Curso"
}
] | null |
[] |
package com.ipartek.formacion.pojo;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.ipartek.formacion.pojo.excepciones.CandidatoException;
import com.ipartek.formacion.service.Genero;
import com.ipartek.formacion.service.Util;
/**
*
* @author Curso
*
*/
public class Candidato {
public static final int CODIGO_ALUMNO = -1;
private int codigo;
private String nombre;
private String apellidos;
protected Date fNacimiento;
protected String dni;
private String email;
private String telefono;
private Double nota;
private Genero genero;
private List<Idioma> idiomas;
/**
* @throws CandidatoException
* excepcion al crear candidato
*/
public Candidato() {
super();
setCodigo(CODIGO_ALUMNO);
setNombre("");
setApellidos("");
this.dni = "";
this.fNacimiento = new Date();
setGenero(Genero.OTROS);
setNota(0.0);
setEmail("");
setTelefono("");
List<Idioma> aux = new ArrayList<Idioma>();
aux.add(Idioma.CASTELLANO);
setIdiomas(aux);
}
/**
*
* @return idioma
*/
public List<Idioma> getIdiomas() {
return idiomas;
}
/**
*
* @param idiomas
* lista de idiomas
*/
public void setIdiomas(List<Idioma> idiomas) {
this.idiomas = idiomas;
}
/**
*
* @return Double nota
*
*/
public Double getNota() {
return nota;
}
/**
*
* @param nota
* nota
*
*/
public void setNota(Double nota) {
this.nota = nota;
}
/**
*
* @return int codigo candidato
*/
public int getCodigo() {
return codigo;
}
/**
*
* @param codigo
* codigo
*/
public void setCodigo(int codigo) {
this.codigo = codigo;
}
/**
*
* @return nombre candidato
*/
public String getNombre() {
return nombre;
}
/**
*
* @param nombre
* nombre del candidato
*/
public void setNombre(String nombre) {
this.nombre = nombre;
}
/**
*
* @return apellidos del candidato
*/
public String getApellidos() {
return apellidos;
}
/**
*
* @param apellidos
* apellidos del candidato
*/
public void setApellidos(String apellidos) {
this.apellidos = apellidos;
}
/**
*
* @return fecha de nacimiento
*/
public Date getfNacimiento() {
return fNacimiento;
}
/**
*
* @param fNacimiento
* Date fecha de nacimiento
* @throws CandidatoException
* fecha no valida
*/
public void setfNacimiento(Date fNacimiento) throws CandidatoException {
if (fNacimiento.compareTo(new Date()) > 0) {
throw new CandidatoException(CandidatoException.CODIGO_ERROR_FECHA_NACIMIENTO,
CandidatoException.MSG_ERROR_FECHA_NACIMIENTO);
} else {
this.fNacimiento = fNacimiento;
}
}
/**
*
* @return DNI
*/
public String getDni() {
return dni;
}
/**
*
* @param dni
* String DNI
* @throws CandidatoException
* DNI no valido
*/
public void setDni(String dni) throws CandidatoException {
if (!Util.validarDni(dni)) {
throw new CandidatoException(CandidatoException.CODIGO_ERROR_DNI,
CandidatoException.MSG_ERROR_DNI);
}
this.dni = dni;
}
/**
*
* @return genero
*/
public Genero getGenero() {
return genero;
}
/**
*
* @param genero
* genero del candidato
*/
public void setGenero(Genero genero) {
this.genero = genero;
}
/**
*
* @return email
*/
public String getEmail() {
return email;
}
/**
*
* @param email
* String
*/
public void setEmail(String email) {
this.email = email;
}
/**
*
* @return telefono
*/
public String getTelefono() {
return telefono;
}
/**
*
* @param telefono
* String
*/
public void setTelefono(String telefono) {
this.telefono = telefono;
}
/**
*
* @return datos
*/
protected String mostrarDatos() {
return this.apellidos + ", " + this.nombre;
}
}
| 4,148 | 0.581003 | 0.580039 | 244 | 16 | 15.661637 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.233607 | false | false |
0
|
6bfe76597d12b89b868bba94f645d00945cb45d6
| 30,056,181,160,009 |
b8e19b888f1b0e868b60e3324c8446a432972f23
|
/app/src/main/java/eugene/com/transferwise/ui/place/list/PlaceListRecyclerAdapter.java
|
ca15fbb3362dafc1255ade0a85345bb3cc3bedf0
|
[] |
no_license
|
EugeneHoran/GooglePlacesApi
|
https://github.com/EugeneHoran/GooglePlacesApi
|
d27a117cecd90ba3e418a617e91fbf1e46dfe5f7
|
80af41bc48af59732716375fbec8b8671ac411e6
|
refs/heads/master
| 2021-05-10T14:11:24.863000 | 2018-01-22T21:11:20 | 2018-01-22T21:11:20 | 118,508,385 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package eugene.com.transferwise.ui.place.list;
import android.support.v7.util.DiffUtil;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
import eugene.com.transferwise.databinding.RecyclerPlaceItemBinding;
import eugene.com.transferwise.db.entity.Place;
import eugene.com.transferwise.ui.common.BaseViewHolder;
import eugene.com.transferwise.util.view.PlacesDiffUtil;
public class PlaceListRecyclerAdapter extends RecyclerView.Adapter<BaseViewHolder> {
private List<Place> places = new ArrayList<>();
private PlaceClickCallback listener;
PlaceListRecyclerAdapter(PlaceClickCallback listener) {
this.listener = listener;
}
void setItems(List<Place> placeList) {
final DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new PlacesDiffUtil(places, placeList));
this.places.clear();
this.places.addAll(placeList);
diffResult.dispatchUpdatesTo(this);
}
@Override
public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new BaseViewHolder(RecyclerPlaceItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
@Override
public void onBindViewHolder(BaseViewHolder holder, int position) {
holder.setListener(listener);
holder.bind(places.get(position));
}
@Override
public int getItemCount() {
return places.size();
}
public interface PlaceClickCallback {
void onPlaceClick(Place place);
}
}
|
UTF-8
|
Java
| 1,615 |
java
|
PlaceListRecyclerAdapter.java
|
Java
|
[] | null |
[] |
package eugene.com.transferwise.ui.place.list;
import android.support.v7.util.DiffUtil;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
import eugene.com.transferwise.databinding.RecyclerPlaceItemBinding;
import eugene.com.transferwise.db.entity.Place;
import eugene.com.transferwise.ui.common.BaseViewHolder;
import eugene.com.transferwise.util.view.PlacesDiffUtil;
public class PlaceListRecyclerAdapter extends RecyclerView.Adapter<BaseViewHolder> {
private List<Place> places = new ArrayList<>();
private PlaceClickCallback listener;
PlaceListRecyclerAdapter(PlaceClickCallback listener) {
this.listener = listener;
}
void setItems(List<Place> placeList) {
final DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new PlacesDiffUtil(places, placeList));
this.places.clear();
this.places.addAll(placeList);
diffResult.dispatchUpdatesTo(this);
}
@Override
public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new BaseViewHolder(RecyclerPlaceItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
@Override
public void onBindViewHolder(BaseViewHolder holder, int position) {
holder.setListener(listener);
holder.bind(places.get(position));
}
@Override
public int getItemCount() {
return places.size();
}
public interface PlaceClickCallback {
void onPlaceClick(Place place);
}
}
| 1,615 | 0.744272 | 0.743034 | 52 | 30.057692 | 29.216969 | 125 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.538462 | false | false |
0
|
50d71fb72dc8795d56c198ba39a6259a87751bc2
| 3,410,204,053,855 |
394b5c3cc965b570697118f97c2deebdbfa45a9d
|
/shared/src/main/java/postit/server/model/ServerAccount.java
|
81188a5413655a768e23bf6f8b69970ea5a30fd4
|
[] |
no_license
|
jjl284/postit
|
https://github.com/jjl284/postit
|
de83e3fd2f67adba3a05503db6a7f0eee5e44647
|
b7c3a45a696e59e001f3b4c2bb4df9a855fc00dd
|
refs/heads/master
| 2021-06-16T08:07:32.263000 | 2017-05-19T03:20:20 | 2017-05-19T03:20:20 | 82,744,503 | 1 | 2 | null | false | 2017-05-16T01:18:23 | 2017-02-22T01:06:09 | 2017-03-15T16:32:32 | 2017-05-16T01:18:22 | 2,765 | 0 | 0 | 2 |
Java
| null | null |
package postit.server.model;
import javax.json.JsonObject;
/**
* Created by Zhan on 2/28/2017.
*/
public class ServerAccount {
//Long id;
String username;
String password;
String email;
String firstName;
String lastName;
String salt;
String phoneNumber;
String keypair;
String publickey;
// CONSTRUCTOR
public ServerAccount(String username, String password, String email, String firstName, String lastName, String phoneNumber) {
this.username = username;
this.password = password;
this.email = email;
this.firstName = firstName;
this.lastName = lastName;
this.phoneNumber = phoneNumber;
}
public ServerAccount(String username, String password, String email, String firstName, String lastName, String phoneNumber, String keypair, String publickey) {
this.username = username;
this.password = password;
this.email = email;
this.firstName = firstName;
this.lastName = lastName;
this.phoneNumber = phoneNumber;
this.keypair = keypair;
this.publickey = publickey;
}
public ServerAccount(ServerAccount a){
this.username = a.username;
this.password = a.password;
this.email = a.email;
this.firstName = a.firstName;
this.lastName = a.lastName;
this.salt = a.salt;
this.phoneNumber = a.phoneNumber;
this.keypair = a.keypair;
this.publickey = a.publickey;
}
// GETTERS
// public Long getId() {
// return id;
// }
public ServerAccount() {
}
public String getUsername(){
return username;
}
public String getPassword() {
return password;
}
public String getEmail(){
return email;
}
public String getFirstname(){
return firstName;
}
public String getLastname(){
return lastName;
}
public String getSalt(){
return salt;
}
public String getPhoneNumber(){ return phoneNumber; }
public String getKeypair() { return this.keypair; }
public String getPublickey() { return this.publickey; }
// SETTERS
public void setUsername(String username){
this.username = username;
}
public void setPassword(String password) {
this.password = password;
}
public void setEmail(String email) { this.email = email; }
public void setFirstname(String firstname){
this.firstName = firstname;
}
public void setLastname(String lastname){
this.lastName = lastname;
}
public void setSalt(String salt){
this.salt = salt;
}
public void setKeypair(String keypair) {this.keypair = keypair; }
public void setPublickey(String publickey) {this.publickey = publickey; }
public void setPhoneNumber(String phoneNumber){
this.phoneNumber = phoneNumber;
}
public static ServerAccount fromJSONObject(JsonObject act){
if (act.getString("keypair") != null) {
return new ServerAccount(
act.getString("username"),
act.getString("password"),
act.getString("email"),
act.getString("firstname"),
act.getString("lastname"),
act.getString("phoneNumber"),
act.getString("keypair"),
act.getString("publickey")
);
}
return new ServerAccount(
act.getString("username"),
act.getString("password"),
act.getString("email"),
act.getString("firstname"),
act.getString("lastname"),
act.getString("phoneNumber")
);
}
}
|
UTF-8
|
Java
| 3,718 |
java
|
ServerAccount.java
|
Java
|
[
{
"context": "\n\nimport javax.json.JsonObject;\n\n/**\n * Created by Zhan on 2/28/2017.\n */\npublic class ServerAccount {\n ",
"end": 83,
"score": 0.9195412397384644,
"start": 79,
"tag": "USERNAME",
"value": "Zhan"
},
{
"context": "ame, String phoneNumber) {\n this.username = username;\n this.password = password;\n this.e",
"end": 515,
"score": 0.9858463406562805,
"start": 507,
"tag": "USERNAME",
"value": "username"
},
{
"context": " this.username = username;\n this.password = password;\n this.email = email;\n this.firstNa",
"end": 549,
"score": 0.9991558790206909,
"start": 541,
"tag": "PASSWORD",
"value": "password"
},
{
"context": " keypair, String publickey) {\n \tthis.username = username;\n \tthis.password = password;\n \tthis.email =",
"end": 889,
"score": 0.9949074983596802,
"start": 881,
"tag": "USERNAME",
"value": "username"
},
{
"context": " \tthis.username = username;\n \tthis.password = password;\n \tthis.email = email;\n \tthis.firstName = f",
"end": 920,
"score": 0.9989832639694214,
"start": 912,
"tag": "PASSWORD",
"value": "password"
},
{
"context": " \tthis.username = a.username;\n \tthis.password = a.password;\n \tthis.email = a.email;\n \tthis.firstName =",
"end": 1224,
"score": 0.9990617632865906,
"start": 1214,
"tag": "PASSWORD",
"value": "a.password"
},
{
"context": "() {\n\t}\n\n\tpublic String getUsername(){\n \treturn username;\n }\n \n public String getPassword() {\n ",
"end": 1619,
"score": 0.7965887784957886,
"start": 1611,
"tag": "USERNAME",
"value": "username"
},
{
"context": "setUsername(String username){\n \tthis.username = username;\n }\n \n public void setPassword(String pa",
"end": 2213,
"score": 0.9942346215248108,
"start": 2205,
"tag": "USERNAME",
"value": "username"
},
{
"context": "assword(String password) {\n this.password = password;\n }\n\n public void setEmail(String email) { ",
"end": 2305,
"score": 0.8266920447349548,
"start": 2297,
"tag": "PASSWORD",
"value": "password"
},
{
"context": "ServerAccount(\n act.getString(\"username\"),\n act.getString(\"password\"),",
"end": 3064,
"score": 0.9932234287261963,
"start": 3056,
"tag": "USERNAME",
"value": "username"
},
{
"context": "rn new ServerAccount(\n \t act.getString(\"username\"),\n act.getString(\"password\"),\n ",
"end": 3489,
"score": 0.9929083585739136,
"start": 3481,
"tag": "USERNAME",
"value": "username"
}
] | null |
[] |
package postit.server.model;
import javax.json.JsonObject;
/**
* Created by Zhan on 2/28/2017.
*/
public class ServerAccount {
//Long id;
String username;
String password;
String email;
String firstName;
String lastName;
String salt;
String phoneNumber;
String keypair;
String publickey;
// CONSTRUCTOR
public ServerAccount(String username, String password, String email, String firstName, String lastName, String phoneNumber) {
this.username = username;
this.password = <PASSWORD>;
this.email = email;
this.firstName = firstName;
this.lastName = lastName;
this.phoneNumber = phoneNumber;
}
public ServerAccount(String username, String password, String email, String firstName, String lastName, String phoneNumber, String keypair, String publickey) {
this.username = username;
this.password = <PASSWORD>;
this.email = email;
this.firstName = firstName;
this.lastName = lastName;
this.phoneNumber = phoneNumber;
this.keypair = keypair;
this.publickey = publickey;
}
public ServerAccount(ServerAccount a){
this.username = a.username;
this.password = <PASSWORD>;
this.email = a.email;
this.firstName = a.firstName;
this.lastName = a.lastName;
this.salt = a.salt;
this.phoneNumber = a.phoneNumber;
this.keypair = a.keypair;
this.publickey = a.publickey;
}
// GETTERS
// public Long getId() {
// return id;
// }
public ServerAccount() {
}
public String getUsername(){
return username;
}
public String getPassword() {
return password;
}
public String getEmail(){
return email;
}
public String getFirstname(){
return firstName;
}
public String getLastname(){
return lastName;
}
public String getSalt(){
return salt;
}
public String getPhoneNumber(){ return phoneNumber; }
public String getKeypair() { return this.keypair; }
public String getPublickey() { return this.publickey; }
// SETTERS
public void setUsername(String username){
this.username = username;
}
public void setPassword(String password) {
this.password = <PASSWORD>;
}
public void setEmail(String email) { this.email = email; }
public void setFirstname(String firstname){
this.firstName = firstname;
}
public void setLastname(String lastname){
this.lastName = lastname;
}
public void setSalt(String salt){
this.salt = salt;
}
public void setKeypair(String keypair) {this.keypair = keypair; }
public void setPublickey(String publickey) {this.publickey = publickey; }
public void setPhoneNumber(String phoneNumber){
this.phoneNumber = phoneNumber;
}
public static ServerAccount fromJSONObject(JsonObject act){
if (act.getString("keypair") != null) {
return new ServerAccount(
act.getString("username"),
act.getString("password"),
act.getString("email"),
act.getString("firstname"),
act.getString("lastname"),
act.getString("phoneNumber"),
act.getString("keypair"),
act.getString("publickey")
);
}
return new ServerAccount(
act.getString("username"),
act.getString("password"),
act.getString("email"),
act.getString("firstname"),
act.getString("lastname"),
act.getString("phoneNumber")
);
}
}
| 3,724 | 0.604626 | 0.602743 | 144 | 24.819445 | 22.951534 | 163 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.791667 | false | false |
0
|
e08a88158fdd572755ebef2aa9a97eac429f908c
| 19,997,367,776,097 |
2b8d35a0d905dedffad947acf634c923bfbf07d8
|
/剑指offer/Offer66.java
|
025c751c14d2a9ac5140512f26f89ac331dfb429
|
[] |
no_license
|
meisiman/code
|
https://github.com/meisiman/code
|
378948c26b35b702a97c058b24e4453e5922d665
|
d665ae886eb99ad6afc36c5d81cddcf56fd7b45a
|
refs/heads/master
| 2023-05-04T12:51:41.760000 | 2021-05-28T06:44:29 | 2021-05-28T06:44:29 | 278,095,519 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package offer;
/**
* @author Mei Siman
* @date 2020/7/18 13:30
*
* 剑指 Offer 66. 构建乘积数组
*
* 给定一个数组 A[0,1,…,n-1],请构建一个数组 B[0,1,…,n-1],其中 B 中的元素 B[i]=A[0]×A[1]×…×A[i-1]×A[i+1]×…×A[n-1]。
* 不能使用除法。
*
*/
public class Offer66 {
public int[] constructArr(int[] a) {
if(a.length==0) return new int[0];
int[] b = new int[a.length];
b[0]=1;
int tmp = 1;
for (int i = 1; i < a.length; i++) {
b[i] = b[i-1]*a[i-1];
}
for (int i = a.length-2; i >= 0; i--) {
tmp *= a[i+1];
b[i]*= tmp;
}
return b;
}
}
|
UTF-8
|
Java
| 701 |
java
|
Offer66.java
|
Java
|
[
{
"context": "package offer;\n\n/**\n * @author Mei Siman\n * @date 2020/7/18 13:30\n *\n * 剑指 Offer 66. 构建乘积数",
"end": 40,
"score": 0.9997532963752747,
"start": 31,
"tag": "NAME",
"value": "Mei Siman"
}
] | null |
[] |
package offer;
/**
* @author <NAME>
* @date 2020/7/18 13:30
*
* 剑指 Offer 66. 构建乘积数组
*
* 给定一个数组 A[0,1,…,n-1],请构建一个数组 B[0,1,…,n-1],其中 B 中的元素 B[i]=A[0]×A[1]×…×A[i-1]×A[i+1]×…×A[n-1]。
* 不能使用除法。
*
*/
public class Offer66 {
public int[] constructArr(int[] a) {
if(a.length==0) return new int[0];
int[] b = new int[a.length];
b[0]=1;
int tmp = 1;
for (int i = 1; i < a.length; i++) {
b[i] = b[i-1]*a[i-1];
}
for (int i = a.length-2; i >= 0; i--) {
tmp *= a[i+1];
b[i]*= tmp;
}
return b;
}
}
| 698 | 0.425775 | 0.365416 | 28 | 20.892857 | 19.896769 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.678571 | false | false |
0
|
8561890b00da31411f05fa4b198fc597bddf9d70
| 27,084,063,794,909 |
c01a80fcee5ede1eb0dd181e1db1250ec9e5c4c7
|
/app/src/main/java/com/alisa/i397_calc/MainActivity.java
|
f201ec8da52a016ebd6bb0659723fd1389479056
|
[] |
no_license
|
AlisaDu/I397_Calc
|
https://github.com/AlisaDu/I397_Calc
|
6673ebd08b3ceeff46f65e9d97141f20d44e53cc
|
c2ea617bdb9fec1b1d3dfca40647689d961bff58
|
refs/heads/master
| 2021-06-07T00:47:14.771000 | 2015-11-26T21:01:11 | 2015-11-26T21:01:11 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.alisa.i397_calc;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import java.io.Serializable;
import java.util.EnumMap;
import static com.alisa.i397_calc.R.string.dflt;
import static com.alisa.i397_calc.R.string.error;
public class MainActivity extends AppCompatActivity {
//screen
private EditText screen;
// operation buttons
private Button btnSum;
private Button btnSub;
private Button btnMlt;
private Button btnDiv;
// map for storing user input
private EnumMap<ExpElement, Object> input = new EnumMap<ExpElement, Object>(ExpElement.class);
private MathOperation operation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
screen = (EditText) findViewById(R.id.txtResult);
if (savedInstanceState != null){
if((savedInstanceState.getString("operationString")) !=null) {
operation = MathOperation.valueOf(savedInstanceState.getString("operationString"));
}
input = (EnumMap) savedInstanceState.getSerializable("inputMap");
}
screen.setText(dflt);
btnSum = (Button) findViewById(R.id.buttonSum);
btnSub = (Button) findViewById(R.id.buttonSub);
btnMlt = (Button) findViewById(R.id. buttonMlt);
btnDiv = (Button) findViewById(R.id. buttonDiv);
btnSum.setTag(MathOperation.SUM);
btnSub.setTag(MathOperation.SUB);
btnMlt.setTag(MathOperation.MLT);
btnDiv.setTag(MathOperation.DIV);
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState){
if (operation != null) {
super.onSaveInstanceState(savedInstanceState);
String operationString = operation.name();
savedInstanceState.putString("operationString", operationString);
}
savedInstanceState.putSerializable("inputMap", input);
}
public void buttonClick (View view){
switch (view.getId()){
// any math operation button
case R.id.buttonSum:
case R.id.buttonSub:
case R.id.buttonMlt:
case R.id.buttonDiv: {
operation = (MathOperation) view.getTag(); //returns SUM, SUB, MLT or DIV
if (!input.containsKey(ExpElement.OPERATOR)) {
if (!input.containsKey(ExpElement.FIRST_OPERAND)){
input.put(ExpElement.FIRST_OPERAND, screen.getText()); // if first operand isn't assigned, assign current screen value
}
input.put(ExpElement.OPERATOR, operation); // if operator isn't assigned, assign current
} else if (!input.containsKey(ExpElement.SECOND_OPERAND)) {
doTheMath();
}
break;
}
case R.id.buttonC:{
screen.setText(dflt);
input.clear();
break;
}
case R.id.buttonEq:{
if (input.containsKey(ExpElement.FIRST_OPERAND) && input.containsKey(ExpElement.OPERATOR)) {
doTheMath();
}
break;
}
// all numeric buttons
default:{
Button b = (Button)view;
// in case of new input, or if operand was just stored in memory, start from scratch
if (screen.getText().toString().equals("0") ||
(input.containsKey(ExpElement.FIRST_OPERAND) &&
getDouble(screen.getText())== getDouble (input.get(ExpElement.FIRST_OPERAND))))
screen.setText(( b.getText()).toString());
else {
// is there is any input that is not stored as operand, continue concatenating to current string
screen.setText(screen.getText() + (b.getText()).toString());
}
}
}
}
private void doTheMath() {
input.put(ExpElement.SECOND_OPERAND, screen.getText()); // assign current screen value to second operand
calculate(); // do the math
input.put(ExpElement.OPERATOR, operation); // stores operator of last clicked operation button
input.remove(ExpElement.SECOND_OPERAND); // clears "used" operand
}
private void calculate() {
MathOperation previousOperand = (MathOperation) input.get (ExpElement.OPERATOR);
double a = getDouble(input.get(ExpElement.FIRST_OPERAND));
double b = getDouble(input.get(ExpElement.SECOND_OPERAND));
double result = operate(previousOperand, a,b);
// if result is integer, cut the ".0" part
if (result % 1 == 0){
screen.setText(String.valueOf((int) result));
} else {
screen.setText(String.valueOf(result));
}
input.put(ExpElement.FIRST_OPERAND, result); // replace first operand with current result
}
private Double operate(MathOperation operand, double a, double b) {
switch (operand) {
case SUM:
return a + b;
case SUB:
return a - b;
case MLT:
return a * b;
case DIV:
return a / b;
}
return null;
}
private double getDouble(Object screenInput) {
double result;
try{
result = Double.valueOf(screenInput.toString());
} catch (Exception e){
screen.setText(error);
e. printStackTrace();
result = 0;
}
return result;
}
}
/*
private EditText screen; // displays current inout and results
private double operand1; //stores number that was on screen before operator btn pressed
private double operand2;
private String operation; // hold current operator +-*//*
private ButtonClickListener btnClick;
private String lastOperator = "x"; // previousOperator, stored until is replased by another operator +-*//*
=
private double intermResult = 0; // holds the result of last "equal" operation - broken, now. check!
private String lastSymbol = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
screen = (EditText) findViewById(R.id.txtResult);
if (savedInstanceState != null){
operand1 =savedInstanceState.getDouble("operand1");
operand2 =savedInstanceState.getDouble("operand2");
operation = savedInstanceState.getString("operation");
lastOperator = savedInstanceState.getString("lastOperator");
intermResult = savedInstanceState.getDouble("intermResult");
lastSymbol = savedInstanceState.getString ("lastSymbol");
}
screen.setText("0");
btnClick = new ButtonClickListener();
int idList[] = {R.id.button0, R.id.button1, R.id.button2, R.id.button3, R.id.button4,
R.id.button5, R.id.button6, R.id.button7, R.id.button8, R.id.button9,
R.id.buttonSub, R.id.buttonSum, R.id.buttonMlt, R.id.buttonDiv,
R.id.buttonEq, R.id.buttonC};
for(int id : idList){
View v = (View)findViewById(id);
v.setOnClickListener(btnClick);
}
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState){
super.onSaveInstanceState(savedInstanceState);
savedInstanceState.putDouble("operand1", operand1);
savedInstanceState.putDouble("operand2", operand2);
savedInstanceState.putString("operation", operation);
savedInstanceState.putString("lastOperator", lastOperator);
savedInstanceState.putDouble("intermResult", intermResult);
savedInstanceState.putString ("lastSymbol", lastSymbol);
}
public void mMath(String operator){
operand1 = Double.parseDouble (String.valueOf(screen.getText()));
operation = operator;
}
public void getKeyboard(String number){
String currentScreen = screen.getText().toString();
if (currentScreen.equals("0") || lastSymbol.equals("+")|| lastSymbol.equals("-")|| lastSymbol.equals("*")|| lastSymbol.equals("/")){
currentScreen = "";
}
if ( lastOperator.equals("=")){
currentScreen = "";
operand1 = intermResult;
lastOperator = "x";
}
currentScreen += number;
screen.setText(currentScreen);
}
public void mResult (){
operand2 = Double.parseDouble (screen.getText().toString());
double result =0;
lastOperator = operation;
if (operation.equals("+")){
result = operand1 + operand2;
}
if (operation.equals("-")){
result = operand1 - operand2;
}
if (operation.equals("*")){
result = operand1 * operand2;
}
if (operation.equals("/")){
result = operand1 / operand2;
}
intermResult = result;
operand1 = result;
operand2 = 0;
screen.setText(String.valueOf(result));
}
private class ButtonClickListener implements OnClickListener{
public void onClick (View v){
switch (v.getId()){
case R.id.buttonC:
screen.setText ("0");
operand1 = 0;
operand2 = 0;
operation = "";
intermResult = 0;
lastOperator = "x";
intermResult = 0;
lastSymbol = "";
break;
case R.id.buttonSum:
mMath ("+");
break;
case R.id.buttonSub:
mMath ("-");
break;
case R.id.buttonMlt:
mMath ("*");
break;
case R.id.buttonDiv:
mMath("/");
break;
case R.id.buttonEq:
mResult();
lastOperator = "=";
break;
default:
String number = ((Button) v). getText().toString();
getKeyboard(number);
break;
}
lastSymbol= ((Button) v). getText().toString();
}
}
}*/
|
UTF-8
|
Java
| 10,764 |
java
|
MainActivity.java
|
Java
|
[] | null |
[] |
package com.alisa.i397_calc;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import java.io.Serializable;
import java.util.EnumMap;
import static com.alisa.i397_calc.R.string.dflt;
import static com.alisa.i397_calc.R.string.error;
public class MainActivity extends AppCompatActivity {
//screen
private EditText screen;
// operation buttons
private Button btnSum;
private Button btnSub;
private Button btnMlt;
private Button btnDiv;
// map for storing user input
private EnumMap<ExpElement, Object> input = new EnumMap<ExpElement, Object>(ExpElement.class);
private MathOperation operation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
screen = (EditText) findViewById(R.id.txtResult);
if (savedInstanceState != null){
if((savedInstanceState.getString("operationString")) !=null) {
operation = MathOperation.valueOf(savedInstanceState.getString("operationString"));
}
input = (EnumMap) savedInstanceState.getSerializable("inputMap");
}
screen.setText(dflt);
btnSum = (Button) findViewById(R.id.buttonSum);
btnSub = (Button) findViewById(R.id.buttonSub);
btnMlt = (Button) findViewById(R.id. buttonMlt);
btnDiv = (Button) findViewById(R.id. buttonDiv);
btnSum.setTag(MathOperation.SUM);
btnSub.setTag(MathOperation.SUB);
btnMlt.setTag(MathOperation.MLT);
btnDiv.setTag(MathOperation.DIV);
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState){
if (operation != null) {
super.onSaveInstanceState(savedInstanceState);
String operationString = operation.name();
savedInstanceState.putString("operationString", operationString);
}
savedInstanceState.putSerializable("inputMap", input);
}
public void buttonClick (View view){
switch (view.getId()){
// any math operation button
case R.id.buttonSum:
case R.id.buttonSub:
case R.id.buttonMlt:
case R.id.buttonDiv: {
operation = (MathOperation) view.getTag(); //returns SUM, SUB, MLT or DIV
if (!input.containsKey(ExpElement.OPERATOR)) {
if (!input.containsKey(ExpElement.FIRST_OPERAND)){
input.put(ExpElement.FIRST_OPERAND, screen.getText()); // if first operand isn't assigned, assign current screen value
}
input.put(ExpElement.OPERATOR, operation); // if operator isn't assigned, assign current
} else if (!input.containsKey(ExpElement.SECOND_OPERAND)) {
doTheMath();
}
break;
}
case R.id.buttonC:{
screen.setText(dflt);
input.clear();
break;
}
case R.id.buttonEq:{
if (input.containsKey(ExpElement.FIRST_OPERAND) && input.containsKey(ExpElement.OPERATOR)) {
doTheMath();
}
break;
}
// all numeric buttons
default:{
Button b = (Button)view;
// in case of new input, or if operand was just stored in memory, start from scratch
if (screen.getText().toString().equals("0") ||
(input.containsKey(ExpElement.FIRST_OPERAND) &&
getDouble(screen.getText())== getDouble (input.get(ExpElement.FIRST_OPERAND))))
screen.setText(( b.getText()).toString());
else {
// is there is any input that is not stored as operand, continue concatenating to current string
screen.setText(screen.getText() + (b.getText()).toString());
}
}
}
}
private void doTheMath() {
input.put(ExpElement.SECOND_OPERAND, screen.getText()); // assign current screen value to second operand
calculate(); // do the math
input.put(ExpElement.OPERATOR, operation); // stores operator of last clicked operation button
input.remove(ExpElement.SECOND_OPERAND); // clears "used" operand
}
private void calculate() {
MathOperation previousOperand = (MathOperation) input.get (ExpElement.OPERATOR);
double a = getDouble(input.get(ExpElement.FIRST_OPERAND));
double b = getDouble(input.get(ExpElement.SECOND_OPERAND));
double result = operate(previousOperand, a,b);
// if result is integer, cut the ".0" part
if (result % 1 == 0){
screen.setText(String.valueOf((int) result));
} else {
screen.setText(String.valueOf(result));
}
input.put(ExpElement.FIRST_OPERAND, result); // replace first operand with current result
}
private Double operate(MathOperation operand, double a, double b) {
switch (operand) {
case SUM:
return a + b;
case SUB:
return a - b;
case MLT:
return a * b;
case DIV:
return a / b;
}
return null;
}
private double getDouble(Object screenInput) {
double result;
try{
result = Double.valueOf(screenInput.toString());
} catch (Exception e){
screen.setText(error);
e. printStackTrace();
result = 0;
}
return result;
}
}
/*
private EditText screen; // displays current inout and results
private double operand1; //stores number that was on screen before operator btn pressed
private double operand2;
private String operation; // hold current operator +-*//*
private ButtonClickListener btnClick;
private String lastOperator = "x"; // previousOperator, stored until is replased by another operator +-*//*
=
private double intermResult = 0; // holds the result of last "equal" operation - broken, now. check!
private String lastSymbol = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
screen = (EditText) findViewById(R.id.txtResult);
if (savedInstanceState != null){
operand1 =savedInstanceState.getDouble("operand1");
operand2 =savedInstanceState.getDouble("operand2");
operation = savedInstanceState.getString("operation");
lastOperator = savedInstanceState.getString("lastOperator");
intermResult = savedInstanceState.getDouble("intermResult");
lastSymbol = savedInstanceState.getString ("lastSymbol");
}
screen.setText("0");
btnClick = new ButtonClickListener();
int idList[] = {R.id.button0, R.id.button1, R.id.button2, R.id.button3, R.id.button4,
R.id.button5, R.id.button6, R.id.button7, R.id.button8, R.id.button9,
R.id.buttonSub, R.id.buttonSum, R.id.buttonMlt, R.id.buttonDiv,
R.id.buttonEq, R.id.buttonC};
for(int id : idList){
View v = (View)findViewById(id);
v.setOnClickListener(btnClick);
}
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState){
super.onSaveInstanceState(savedInstanceState);
savedInstanceState.putDouble("operand1", operand1);
savedInstanceState.putDouble("operand2", operand2);
savedInstanceState.putString("operation", operation);
savedInstanceState.putString("lastOperator", lastOperator);
savedInstanceState.putDouble("intermResult", intermResult);
savedInstanceState.putString ("lastSymbol", lastSymbol);
}
public void mMath(String operator){
operand1 = Double.parseDouble (String.valueOf(screen.getText()));
operation = operator;
}
public void getKeyboard(String number){
String currentScreen = screen.getText().toString();
if (currentScreen.equals("0") || lastSymbol.equals("+")|| lastSymbol.equals("-")|| lastSymbol.equals("*")|| lastSymbol.equals("/")){
currentScreen = "";
}
if ( lastOperator.equals("=")){
currentScreen = "";
operand1 = intermResult;
lastOperator = "x";
}
currentScreen += number;
screen.setText(currentScreen);
}
public void mResult (){
operand2 = Double.parseDouble (screen.getText().toString());
double result =0;
lastOperator = operation;
if (operation.equals("+")){
result = operand1 + operand2;
}
if (operation.equals("-")){
result = operand1 - operand2;
}
if (operation.equals("*")){
result = operand1 * operand2;
}
if (operation.equals("/")){
result = operand1 / operand2;
}
intermResult = result;
operand1 = result;
operand2 = 0;
screen.setText(String.valueOf(result));
}
private class ButtonClickListener implements OnClickListener{
public void onClick (View v){
switch (v.getId()){
case R.id.buttonC:
screen.setText ("0");
operand1 = 0;
operand2 = 0;
operation = "";
intermResult = 0;
lastOperator = "x";
intermResult = 0;
lastSymbol = "";
break;
case R.id.buttonSum:
mMath ("+");
break;
case R.id.buttonSub:
mMath ("-");
break;
case R.id.buttonMlt:
mMath ("*");
break;
case R.id.buttonDiv:
mMath("/");
break;
case R.id.buttonEq:
mResult();
lastOperator = "=";
break;
default:
String number = ((Button) v). getText().toString();
getKeyboard(number);
break;
}
lastSymbol= ((Button) v). getText().toString();
}
}
}*/
| 10,764 | 0.564939 | 0.559365 | 329 | 31.717325 | 28.682663 | 142 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.598784 | false | false |
0
|
2dada6e8b1b890fe365aae02e5ca35cd4d0a511a
| 27,376,121,564,272 |
707cc7d157dadc29d3f5ec78a0847bd6c11c3c84
|
/src/java/br/com/tributocerto/model/pojo/NotaFiscalItemPK.java
|
776e5bbd4d13a12c3c1798d200ab7e0d75dba438
|
[] |
no_license
|
heldercruzh/tc
|
https://github.com/heldercruzh/tc
|
757fc8ac742e62dc8375bd8b4cdbaf7769d8e177
|
caa5acb187ab6f52bb62832d6848bee1f15ff4d2
|
refs/heads/master
| 2020-04-06T04:19:38.413000 | 2014-01-22T00:44:37 | 2014-01-22T00:44:37 | 16,124,321 | 0 | 1 | null | false | 2020-08-19T23:42:38 | 2014-01-22T01:03:01 | 2019-03-20T16:48:03 | 2014-01-22T00:44:38 | 3,083 | 0 | 1 | 1 |
CSS
| false | false |
/*
* 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 br.com.tributocerto.model.pojo;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
/**
*
* @author usuario
*/
@Embeddable
public class NotaFiscalItemPK implements Serializable {
@Basic(optional = false)
@Column(name = "id_nota_fiscal")
private int idNotaFiscal;
@Basic(optional = false)
@Column(name = "id_produto")
private int idProduto;
public NotaFiscalItemPK() {
}
public NotaFiscalItemPK(int idNotaFiscal, int idProduto) {
this.idNotaFiscal = idNotaFiscal;
this.idProduto = idProduto;
}
public int getIdNotaFiscal() {
return idNotaFiscal;
}
public void setIdNotaFiscal(int idNotaFiscal) {
this.idNotaFiscal = idNotaFiscal;
}
public int getIdProduto() {
return idProduto;
}
public void setIdProduto(int idProduto) {
this.idProduto = idProduto;
}
@Override
public int hashCode() {
int hash = 0;
hash += (int) idNotaFiscal;
hash += (int) idProduto;
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof NotaFiscalItemPK)) {
return false;
}
NotaFiscalItemPK other = (NotaFiscalItemPK) object;
if (this.idNotaFiscal != other.idNotaFiscal) {
return false;
}
if (this.idProduto != other.idProduto) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.impostobrasil.model.pojo.NotaFiscalItemPK[ idNotaFiscal=" + idNotaFiscal + ", idProduto=" + idProduto + " ]";
}
}
|
UTF-8
|
Java
| 2,083 |
java
|
NotaFiscalItemPK.java
|
Java
|
[
{
"context": "vax.persistence.Embeddable;\r\n\r\n/**\r\n *\r\n * @author usuario\r\n */\r\n@Embeddable\r\npublic class NotaFiscalItemPK im",
"end": 399,
"score": 0.9954134225845337,
"start": 392,
"tag": "USERNAME",
"value": "usuario"
}
] | null |
[] |
/*
* 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 br.com.tributocerto.model.pojo;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
/**
*
* @author usuario
*/
@Embeddable
public class NotaFiscalItemPK implements Serializable {
@Basic(optional = false)
@Column(name = "id_nota_fiscal")
private int idNotaFiscal;
@Basic(optional = false)
@Column(name = "id_produto")
private int idProduto;
public NotaFiscalItemPK() {
}
public NotaFiscalItemPK(int idNotaFiscal, int idProduto) {
this.idNotaFiscal = idNotaFiscal;
this.idProduto = idProduto;
}
public int getIdNotaFiscal() {
return idNotaFiscal;
}
public void setIdNotaFiscal(int idNotaFiscal) {
this.idNotaFiscal = idNotaFiscal;
}
public int getIdProduto() {
return idProduto;
}
public void setIdProduto(int idProduto) {
this.idProduto = idProduto;
}
@Override
public int hashCode() {
int hash = 0;
hash += (int) idNotaFiscal;
hash += (int) idProduto;
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof NotaFiscalItemPK)) {
return false;
}
NotaFiscalItemPK other = (NotaFiscalItemPK) object;
if (this.idNotaFiscal != other.idNotaFiscal) {
return false;
}
if (this.idProduto != other.idProduto) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.impostobrasil.model.pojo.NotaFiscalItemPK[ idNotaFiscal=" + idNotaFiscal + ", idProduto=" + idProduto + " ]";
}
}
| 2,083 | 0.609698 | 0.609217 | 80 | 24.0375 | 23.29616 | 129 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.35 | false | false |
0
|
a37291f1cf323520679e0794b012c30e2e5692dd
| 1,872,605,805,526 |
0cd0a325f38c339e9300ab5529628318c6ea3537
|
/src/main/java/io/github/frame/prj/util/TaskUtil.java
|
0d234bd9f151b785dac8b928c90e75ef639ac532
|
[
"MIT"
] |
permissive
|
MaAnShanGuider/bootplus
|
https://github.com/MaAnShanGuider/bootplus
|
2667c030b96bda3ca757572687f8dfe15478fdb6
|
247d5f6c209be1a5cf10cd0fa18e1d8cc63cf55d
|
refs/heads/master
| 2022-12-10T01:33:28.426000 | 2020-08-24T09:33:26 | 2020-08-24T09:33:26 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package io.github.frame.prj.util;
import java.util.Calendar;
import java.util.Date;
/**
* 定时任务工具类
*
* @author Created by 思伟 on 2020/8/24
*/
public class TaskUtil {
/**
* 几秒之后的时间表达式
*
* @param before 时间
* @param seconds 秒数
* @return String
*/
public static String getCronForSecondsAfter(Date before, int seconds) {
Date after = addSeconds(before, seconds);
return getCronForTime(after);
}
/**
* 几分钟之后的时间表达式
*
* @param before 时间
* @param minutes 分钟
* @return String
*/
public static String getCronForMinutesAfter(Date before, int minutes) {
Date after = addMinutes(before, minutes);
return getCronForTime(after);
}
/**
* 几天后的时间表达式
*
* @param before 时间
* @param days 天数
* @return String
*/
public static String getCronForDaysAfter(Date before, int days) {
Date after = addDays(before, days);
return getCronForTime(after);
}
/**
* 根据时间获取时间表达式
*
* @param date 时间
* @return 时间表达式
*/
public static String getCronForTime(Date date) {
int year = getYear(date);
int month = getMonth(date);
int day = getDay(date);
int hour = getHour(date);
int minute = getMinute(date);
int second = getSecond(date);
// ? 表示的是week
return second + " " + minute + " " + hour + " " + day + " " + month + " ? " + year;
}
/**
* 增加几秒
*
* @param before 增加前的时间
* @param seconds 增加的秒数
* @return 增加后的时间
*/
private static Date addSeconds(Date before, int seconds) {
if (before == null) {
return null;
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(before);
calendar.add(Calendar.SECOND, seconds);
Date after = calendar.getTime();
return after;
}
/**
* 增加几分钟
*
* @param before 增加前的时间
* @param minutes 分钟
* @return 增加后的时间
*/
private static Date addMinutes(Date before, int minutes) {
if (before == null) {
return null;
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(before);
calendar.add(Calendar.MINUTE, minutes);
Date after = calendar.getTime();
return after;
}
/**
* 增加几天
*
* @param before 增加前的时间
* @param days 增加的天数
* @return 增加后的时间
*/
private static Date addDays(Date before, int days) {
if (before == null) {
return null;
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(before);
calendar.add(Calendar.DAY_OF_MONTH, days);
Date after = calendar.getTime();
return after;
}
/**
* 获得年份
*
* @param date 日期
* @return 年
*/
private static int getYear(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.get(Calendar.YEAR);
}
/**
* 获得月
*
* @param date 日期
* @return 月
*/
private static int getMonth(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 得到月,因为从0开始的,所以要加1
return calendar.get(Calendar.MONTH) + 1;
}
/**
* 获得天
*
* @param date 日期
* @return 天
*/
private static int getDay(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 得到天
return calendar.get(Calendar.DAY_OF_MONTH);
}
/**
* 获得小时
*
* @param date 日期
* @return 小时
*/
private static int getHour(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 得到小时
return calendar.get(Calendar.HOUR_OF_DAY);
}
/**
* 获得分钟
*
* @param date 日期
* @return 分
*/
private static int getMinute(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 得到分钟
return calendar.get(Calendar.MINUTE);
}
/**
* 获得年份
*
* @param date 日期
* @return 年
*/
private static int getSecond(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 得到秒
return calendar.get(Calendar.SECOND);
}
public static void main(String[] args) {
final Date nowDate = new Date();
System.out.println(getCronForSecondsAfter(nowDate, 5));
System.out.println(QuartzUtil.canRun(getCronForSecondsAfter(nowDate, -5)));
System.out.println(QuartzUtil.canRun(getCronForSecondsAfter(nowDate, +5)));
System.out.println(getCronForMinutesAfter(nowDate, 5));
System.out.println(getCronForDaysAfter(nowDate, 5));
}
}
|
UTF-8
|
Java
| 5,307 |
java
|
TaskUtil.java
|
Java
|
[
{
"context": "il.Date;\n\n/**\n * 定时任务工具类\n *\n * @author Created by 思伟 on 2020/8/24\n */\npublic class TaskUtil {\n\n /**",
"end": 128,
"score": 0.9060277938842773,
"start": 126,
"tag": "NAME",
"value": "思伟"
}
] | null |
[] |
package io.github.frame.prj.util;
import java.util.Calendar;
import java.util.Date;
/**
* 定时任务工具类
*
* @author Created by 思伟 on 2020/8/24
*/
public class TaskUtil {
/**
* 几秒之后的时间表达式
*
* @param before 时间
* @param seconds 秒数
* @return String
*/
public static String getCronForSecondsAfter(Date before, int seconds) {
Date after = addSeconds(before, seconds);
return getCronForTime(after);
}
/**
* 几分钟之后的时间表达式
*
* @param before 时间
* @param minutes 分钟
* @return String
*/
public static String getCronForMinutesAfter(Date before, int minutes) {
Date after = addMinutes(before, minutes);
return getCronForTime(after);
}
/**
* 几天后的时间表达式
*
* @param before 时间
* @param days 天数
* @return String
*/
public static String getCronForDaysAfter(Date before, int days) {
Date after = addDays(before, days);
return getCronForTime(after);
}
/**
* 根据时间获取时间表达式
*
* @param date 时间
* @return 时间表达式
*/
public static String getCronForTime(Date date) {
int year = getYear(date);
int month = getMonth(date);
int day = getDay(date);
int hour = getHour(date);
int minute = getMinute(date);
int second = getSecond(date);
// ? 表示的是week
return second + " " + minute + " " + hour + " " + day + " " + month + " ? " + year;
}
/**
* 增加几秒
*
* @param before 增加前的时间
* @param seconds 增加的秒数
* @return 增加后的时间
*/
private static Date addSeconds(Date before, int seconds) {
if (before == null) {
return null;
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(before);
calendar.add(Calendar.SECOND, seconds);
Date after = calendar.getTime();
return after;
}
/**
* 增加几分钟
*
* @param before 增加前的时间
* @param minutes 分钟
* @return 增加后的时间
*/
private static Date addMinutes(Date before, int minutes) {
if (before == null) {
return null;
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(before);
calendar.add(Calendar.MINUTE, minutes);
Date after = calendar.getTime();
return after;
}
/**
* 增加几天
*
* @param before 增加前的时间
* @param days 增加的天数
* @return 增加后的时间
*/
private static Date addDays(Date before, int days) {
if (before == null) {
return null;
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(before);
calendar.add(Calendar.DAY_OF_MONTH, days);
Date after = calendar.getTime();
return after;
}
/**
* 获得年份
*
* @param date 日期
* @return 年
*/
private static int getYear(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.get(Calendar.YEAR);
}
/**
* 获得月
*
* @param date 日期
* @return 月
*/
private static int getMonth(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 得到月,因为从0开始的,所以要加1
return calendar.get(Calendar.MONTH) + 1;
}
/**
* 获得天
*
* @param date 日期
* @return 天
*/
private static int getDay(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 得到天
return calendar.get(Calendar.DAY_OF_MONTH);
}
/**
* 获得小时
*
* @param date 日期
* @return 小时
*/
private static int getHour(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 得到小时
return calendar.get(Calendar.HOUR_OF_DAY);
}
/**
* 获得分钟
*
* @param date 日期
* @return 分
*/
private static int getMinute(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 得到分钟
return calendar.get(Calendar.MINUTE);
}
/**
* 获得年份
*
* @param date 日期
* @return 年
*/
private static int getSecond(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 得到秒
return calendar.get(Calendar.SECOND);
}
public static void main(String[] args) {
final Date nowDate = new Date();
System.out.println(getCronForSecondsAfter(nowDate, 5));
System.out.println(QuartzUtil.canRun(getCronForSecondsAfter(nowDate, -5)));
System.out.println(QuartzUtil.canRun(getCronForSecondsAfter(nowDate, +5)));
System.out.println(getCronForMinutesAfter(nowDate, 5));
System.out.println(getCronForDaysAfter(nowDate, 5));
}
}
| 5,307 | 0.55644 | 0.553378 | 206 | 22.781553 | 19.506182 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.364078 | false | false |
0
|
dd3154f2a0550fee8afeb39a2bdf3a98ae3e5466
| 31,035,433,703,918 |
e138583b9edc3d2d5ecbe3fb05a06768a5933852
|
/src/main/java/projectj/api/user/UserUpdatedEvent.java
|
fba9d03999fe8b1d0ffdd90a0be271358aeb36cd
|
[] |
no_license
|
sebastienlambert/projectj
|
https://github.com/sebastienlambert/projectj
|
3cde961af0b1f02a71c6aa825d3b2ff8b2eea7f0
|
aefac4084a9e0fa972eef947fa391778ce2e797b
|
refs/heads/master
| 2020-12-03T03:48:57.640000 | 2017-07-29T08:04:12 | 2017-07-29T08:04:12 | 95,776,783 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* Copyright (c) 2017. - Sebastien Lambert - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* Written by Sebastien Lambert
*/
package projectj.api.user;
import lombok.*;
import java.util.UUID;
@Value
@Getter
@Builder
@AllArgsConstructor
@EqualsAndHashCode
@ToString
public class UserUpdatedEvent {
private UUID userId;
private String email;
}
|
UTF-8
|
Java
| 444 |
java
|
UserUpdatedEvent.java
|
Java
|
[
{
"context": "/*\n * Copyright (c) 2017. - Sebastien Lambert - All Rights Reserved\n * Unauthorized copying of ",
"end": 46,
"score": 0.9998956322669983,
"start": 29,
"tag": "NAME",
"value": "Sebastien Lambert"
},
{
"context": "ited\n * Proprietary and confidential\n * Written by Sebastien Lambert\n */\n\npackage projectj.api.user;\n\n\nimport lombok.*",
"end": 208,
"score": 0.9998937249183655,
"start": 191,
"tag": "NAME",
"value": "Sebastien Lambert"
}
] | null |
[] |
/*
* Copyright (c) 2017. - <NAME> - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* Written by <NAME>
*/
package projectj.api.user;
import lombok.*;
import java.util.UUID;
@Value
@Getter
@Builder
@AllArgsConstructor
@EqualsAndHashCode
@ToString
public class UserUpdatedEvent {
private UUID userId;
private String email;
}
| 422 | 0.752252 | 0.743243 | 25 | 16.76 | 19.242203 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.24 | false | false |
0
|
b4bf5e0d6633c70389df2a161fe04f1e717d93c4
| 32,693,291,074,552 |
b55109ebc840494418105c441dd4e6a2b5d17a6a
|
/src/main/java/com/emarket/entity/product/Product.java
|
4fbe7132a900f1cc939e7a1ddc2f2219ced37621
|
[] |
no_license
|
fahreza103/emarket
|
https://github.com/fahreza103/emarket
|
2c0aed5d044662a160f5a6737dded7b1fb7d2b93
|
e5a40a3b627aea96d72b0c9d39c9f67340ba3340
|
refs/heads/master
| 2020-03-27T20:32:00.722000 | 2018-09-02T10:38:16 | 2018-09-02T10:38:16 | 147,075,966 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.emarket.entity.product;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import com.emarket.entity.GenericWithIdentifier;
import com.fasterxml.jackson.annotation.JsonBackReference;
@Entity
@DiscriminatorColumn(name="product_type")
@DiscriminatorValue("Physical")
@Table(name="PRODUCT",schema = "product")
public class Product extends GenericWithIdentifier {
public Product() {
super();
}
public Product(String name, String description) {
super(name, description);
}
private static final long serialVersionUID = -4418329007867668069L;
@ManyToOne
@JoinColumn(name = "brand_id", foreignKey = @ForeignKey(name = "product_brand_id_fk"))
@JsonBackReference
private Brand brand;
public Brand getBrand() {
return brand;
}
public Product setBrand(Brand brand) {
this.brand = brand;
return this;
}
}
|
UTF-8
|
Java
| 1,056 |
java
|
Product.java
|
Java
|
[] | null |
[] |
package com.emarket.entity.product;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import com.emarket.entity.GenericWithIdentifier;
import com.fasterxml.jackson.annotation.JsonBackReference;
@Entity
@DiscriminatorColumn(name="product_type")
@DiscriminatorValue("Physical")
@Table(name="PRODUCT",schema = "product")
public class Product extends GenericWithIdentifier {
public Product() {
super();
}
public Product(String name, String description) {
super(name, description);
}
private static final long serialVersionUID = -4418329007867668069L;
@ManyToOne
@JoinColumn(name = "brand_id", foreignKey = @ForeignKey(name = "product_brand_id_fk"))
@JsonBackReference
private Brand brand;
public Brand getBrand() {
return brand;
}
public Product setBrand(Brand brand) {
this.brand = brand;
return this;
}
}
| 1,056 | 0.778409 | 0.760417 | 45 | 22.466667 | 21.552624 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.044444 | false | false |
0
|
e660ebea576a662200a11bad3479822133e165c2
| 19,250,043,443,894 |
203ac289e851ffc745965bf78a464e1db1de04a6
|
/Thing.java
|
54981e6ad8c1961dbdd084c9ff9c4c6e758231cd
|
[] |
no_license
|
edgartheunready/raytracer
|
https://github.com/edgartheunready/raytracer
|
d208bc0a9530314fedbfa0ae63406f3e9e749bec
|
9f6595195d11d051756b199dd24777b879961fef
|
refs/heads/master
| 2016-09-06T14:35:27.273000 | 2014-09-28T20:35:05 | 2014-09-28T20:35:05 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public abstract class Thing {
public final double MIN = .00001;
Scene curScene;
abstract public Point getNormal(Point spot);
abstract public Intersection getIntersection(Point start, Point end);
abstract public Color getDiffuse(Point p);
abstract public Color getAmbient(Point p );
abstract public Color getSpecularWeight();
abstract public boolean hasLighting();
abstract public boolean hasDiffuse();
abstract public void makeColorProportional(double size);
}
|
UTF-8
|
Java
| 485 |
java
|
Thing.java
|
Java
|
[] | null |
[] |
public abstract class Thing {
public final double MIN = .00001;
Scene curScene;
abstract public Point getNormal(Point spot);
abstract public Intersection getIntersection(Point start, Point end);
abstract public Color getDiffuse(Point p);
abstract public Color getAmbient(Point p );
abstract public Color getSpecularWeight();
abstract public boolean hasLighting();
abstract public boolean hasDiffuse();
abstract public void makeColorProportional(double size);
}
| 485 | 0.775258 | 0.764948 | 13 | 35.307693 | 19.256905 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.615385 | false | false |
0
|
b8d3e20bc404f5f94f9056a5df6f3cd249223445
| 10,239,202,065,314 |
64ac4531a748db5fef1ccf96007a52681ba111b0
|
/ApliServicios/src/Modelo/Cliente.java
|
77febf060ab0251333de4e4deba06e249f132ebe
|
[] |
no_license
|
PedroAliOrellana/ProyectoLab2016
|
https://github.com/PedroAliOrellana/ProyectoLab2016
|
968e17359f46e13f81089e3dbb08732cc959c3e9
|
9fc52bead67c24bc0125e5f3172dcd4c6a4cb4a0
|
refs/heads/master
| 2021-01-24T08:15:43.498000 | 2016-10-07T05:49:58 | 2016-10-07T05:49:58 | 70,016,419 | 1 | 4 | null | false | 2016-10-07T02:40:09 | 2016-10-04T23:58:21 | 2016-10-05T00:01:26 | 2016-10-07T02:40:08 | 500 | 0 | 3 | 0 |
Java
| null | null |
package Modelo;
public class Cliente
{
private String rif;
private String razonSocial;
private String telefono;
private String direccion;
private String correo;
public Cliente(String rif, String razonSocial, String telefono, String direccion,String correo)
{
this.rif = rif;
this.razonSocial = razonSocial;
this.direccion = direccion;
this.telefono = telefono;
this.correo= correo;
}
public Cliente()
{
rif = "";
razonSocial = "";
direccion = "";
telefono = "";
correo="";
}
public String getCorreo() {
return correo;
}
public void setCorreo(String correo) {
this.correo = correo;
}
public String getRif()
{
return rif;
}
public void setRif(String rif)
{
this.rif = rif;
}
public String getRazonSocial()
{
return razonSocial;
}
public void setRazonSocial(String razonSocial)
{
this.razonSocial = razonSocial;
}
public String getTelefono()
{
return telefono;
}
public void setTelefono(String telefono)
{
this.telefono = telefono;
}
public String getDireccion()
{
return direccion;
}
public void setDireccion(String direccion)
{
this.direccion = direccion;
}
}
|
UTF-8
|
Java
| 1,434 |
java
|
Cliente.java
|
Java
|
[] | null |
[] |
package Modelo;
public class Cliente
{
private String rif;
private String razonSocial;
private String telefono;
private String direccion;
private String correo;
public Cliente(String rif, String razonSocial, String telefono, String direccion,String correo)
{
this.rif = rif;
this.razonSocial = razonSocial;
this.direccion = direccion;
this.telefono = telefono;
this.correo= correo;
}
public Cliente()
{
rif = "";
razonSocial = "";
direccion = "";
telefono = "";
correo="";
}
public String getCorreo() {
return correo;
}
public void setCorreo(String correo) {
this.correo = correo;
}
public String getRif()
{
return rif;
}
public void setRif(String rif)
{
this.rif = rif;
}
public String getRazonSocial()
{
return razonSocial;
}
public void setRazonSocial(String razonSocial)
{
this.razonSocial = razonSocial;
}
public String getTelefono()
{
return telefono;
}
public void setTelefono(String telefono)
{
this.telefono = telefono;
}
public String getDireccion()
{
return direccion;
}
public void setDireccion(String direccion)
{
this.direccion = direccion;
}
}
| 1,434 | 0.557183 | 0.557183 | 79 | 17.13924 | 16.98304 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.379747 | false | false |
0
|
509db9aa673c0709ee40ca5828de94c7a4f9ba67
| 15,676,630,655,473 |
b26a351422c77eac435b89c495aeec20bf12f577
|
/src/main/java/com/elasticjob/demo/MyDataFlowJob.java
|
af5ffd5f029169d3686663284a8f63af2ee31989
|
[] |
no_license
|
heshuhuacp/elasticjob-learn
|
https://github.com/heshuhuacp/elasticjob-learn
|
24d04432b4dfc7afc334058fb9e1421ded2e770a
|
05027a9494566d0ecec30520fa2869b37c57fc9a
|
refs/heads/master
| 2020-04-05T17:27:17.758000 | 2018-11-11T09:01:01 | 2018-11-11T09:01:01 | 157,061,563 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.elasticjob.demo;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.dataflow.DataflowJob;
import com.elasticjob.mapper.UserMapper;
import com.elasticjob.model.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* Dataflow类型job
*/
public class MyDataFlowJob implements DataflowJob<User> {
private static final Logger logger = LoggerFactory.getLogger(MyDataFlowJob.class);
@Autowired
private UserMapper userMapper;
@Override
public List<User> fetchData(ShardingContext shardingContext) {
logger.info("fetchData province={}",new Object[]{shardingContext.getShardingParameter()});
List<User> list = userMapper.getUserByProvince(shardingContext.getShardingParameter());
return list;
}
@Override
public void processData(ShardingContext shardingContext, List<User> list) {
logger.info("来自{}的用户有{}个", new Object[]{shardingContext.getShardingParameter(), list.size()});
}
}
|
UTF-8
|
Java
| 1,117 |
java
|
MyDataFlowJob.java
|
Java
|
[] | null |
[] |
package com.elasticjob.demo;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.dataflow.DataflowJob;
import com.elasticjob.mapper.UserMapper;
import com.elasticjob.model.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* Dataflow类型job
*/
public class MyDataFlowJob implements DataflowJob<User> {
private static final Logger logger = LoggerFactory.getLogger(MyDataFlowJob.class);
@Autowired
private UserMapper userMapper;
@Override
public List<User> fetchData(ShardingContext shardingContext) {
logger.info("fetchData province={}",new Object[]{shardingContext.getShardingParameter()});
List<User> list = userMapper.getUserByProvince(shardingContext.getShardingParameter());
return list;
}
@Override
public void processData(ShardingContext shardingContext, List<User> list) {
logger.info("来自{}的用户有{}个", new Object[]{shardingContext.getShardingParameter(), list.size()});
}
}
| 1,117 | 0.750682 | 0.748863 | 39 | 27.179487 | 31.769096 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.487179 | false | false |
0
|
89e8bf4011a1ea8543f137c57d3b00637921f9a5
| 15,204,184,253,880 |
5281b616379239d627e05778519913b6a188617b
|
/App04_News/app/src/main/java/com/callor/topnews/MainActivity.java
|
7abda06637a8f8ebff92ae8e6f722cd5f145c8f1
|
[
"Apache-2.0"
] |
permissive
|
paldonenemttin/2021_07_Android
|
https://github.com/paldonenemttin/2021_07_Android
|
74b1a5e6db27c714de3aff68f8c06112e2cece34
|
3dcc9a3d6f95361f462d4c8cfdd957d5aa54786e
|
refs/heads/master
| 2023-07-13T22:52:19.936000 | 2021-08-18T07:42:53 | 2021-08-18T07:42:53 | 389,844,184 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.callor.topnews;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.callor.topnews.databinding.ActivityMainBinding;
import com.callor.topnews.service.NaverService;
import com.callor.topnews.service.impl.NaverNewsServiceImplV1;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;
public class MainActivity extends AppCompatActivity {
/**
* activitu.xml 파일에 선언된 view Component 를
* 사용할때 findbyViewId 를 사용하지 않고
* 접그느 할 수 있도록 선언된 경우
* buildFeature{
* viewBinding true
* }
* activitiy_main.xml 파일이름을 확장하여
* ActivityMainBinding 이라는 클래스가 생성된다
*/
ActivityMainBinding main_binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/**
* 기존에 사용하던
* setContentView(R.layout.activity_main);
*
* main_binding = ActivityMainBinding.inflate((getLayoutInflater()));
* setContentView(main_binding.getRoot());
* 코드로 변경
*
* 이 코드로 시자깅 되면 activity.xml 파일에 있는
* 모든 view Component가 한번에 사용가능한 상태로 변경됨
*
*/
main_binding = ActivityMainBinding.inflate((getLayoutInflater()));
setContentView(main_binding.getRoot());
Date date = new Date(System.currentTimeMillis());
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
String curDate = sd.format(date);
NaverService naverService = new NaverNewsServiceImplV1(main_binding.newsListView);
naverService.getNews(curDate);
}
}
|
UTF-8
|
Java
| 1,891 |
java
|
MainActivity.java
|
Java
|
[] | null |
[] |
package com.callor.topnews;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.callor.topnews.databinding.ActivityMainBinding;
import com.callor.topnews.service.NaverService;
import com.callor.topnews.service.impl.NaverNewsServiceImplV1;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;
public class MainActivity extends AppCompatActivity {
/**
* activitu.xml 파일에 선언된 view Component 를
* 사용할때 findbyViewId 를 사용하지 않고
* 접그느 할 수 있도록 선언된 경우
* buildFeature{
* viewBinding true
* }
* activitiy_main.xml 파일이름을 확장하여
* ActivityMainBinding 이라는 클래스가 생성된다
*/
ActivityMainBinding main_binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/**
* 기존에 사용하던
* setContentView(R.layout.activity_main);
*
* main_binding = ActivityMainBinding.inflate((getLayoutInflater()));
* setContentView(main_binding.getRoot());
* 코드로 변경
*
* 이 코드로 시자깅 되면 activity.xml 파일에 있는
* 모든 view Component가 한번에 사용가능한 상태로 변경됨
*
*/
main_binding = ActivityMainBinding.inflate((getLayoutInflater()));
setContentView(main_binding.getRoot());
Date date = new Date(System.currentTimeMillis());
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
String curDate = sd.format(date);
NaverService naverService = new NaverNewsServiceImplV1(main_binding.newsListView);
naverService.getNews(curDate);
}
}
| 1,891 | 0.661773 | 0.660599 | 58 | 28.379311 | 23.31111 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.37931 | false | false |
0
|
8fc485174282dc3508dcf52106c93c556004d00b
| 17,858,474,042,944 |
6a8cea8ccb945085aa77689af235e3e2b5266ba5
|
/src/main/java/NumberConsumer.java
|
bf1ce947f0d372ac28139eef587a0410a72765d1
|
[] |
no_license
|
IevgenSuturin/JavaSkillsUP_Concurrency
|
https://github.com/IevgenSuturin/JavaSkillsUP_Concurrency
|
8393c4d6842fe139bc8a447dd5231dfb4979cf8e
|
8dfde268c58e76c70c34c6ee56e45bd058d29840
|
refs/heads/master
| 2020-04-05T05:56:51.735000 | 2018-11-07T22:46:36 | 2018-11-07T22:46:36 | 156,618,628 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
public class NumberConsumer implements Runnable {
private static int count = 0;
private int id = count ++;
private final CountDownLatch startGate;
private BlockingQueue<Integer> queue;
private GenerationManager manager;
private int sum;
NumberConsumer(CountDownLatch startGate, BlockingQueue<Integer> queue,
GenerationManager manager) {
this.startGate = startGate;
this.queue = queue;
this.manager = manager;
}
@Override
public String toString() {
return "Consumer"+id;
}
int getQueueNumber() throws IllegalStateException{
return queue.remove();
}
int incSum(int num){
return sum+=num;
}
BlockingQueue<Integer> getQueue(){
return queue;
}
public void run() {
try {
startGate.await();
while (!manager.generateConsumption(this)) {
Thread.sleep(2);
}
}catch (InterruptedException ignored){
System.out.println("\t\t\t\tNum Consumer" + id + " was interrupted");
}
}
}
|
UTF-8
|
Java
| 1,199 |
java
|
NumberConsumer.java
|
Java
|
[] | null |
[] |
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
public class NumberConsumer implements Runnable {
private static int count = 0;
private int id = count ++;
private final CountDownLatch startGate;
private BlockingQueue<Integer> queue;
private GenerationManager manager;
private int sum;
NumberConsumer(CountDownLatch startGate, BlockingQueue<Integer> queue,
GenerationManager manager) {
this.startGate = startGate;
this.queue = queue;
this.manager = manager;
}
@Override
public String toString() {
return "Consumer"+id;
}
int getQueueNumber() throws IllegalStateException{
return queue.remove();
}
int incSum(int num){
return sum+=num;
}
BlockingQueue<Integer> getQueue(){
return queue;
}
public void run() {
try {
startGate.await();
while (!manager.generateConsumption(this)) {
Thread.sleep(2);
}
}catch (InterruptedException ignored){
System.out.println("\t\t\t\tNum Consumer" + id + " was interrupted");
}
}
}
| 1,199 | 0.613011 | 0.611343 | 48 | 23.958334 | 20.424616 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.416667 | false | false |
0
|
32574b4b58f60b1e4fa9e735f56260b8a858f031
| 13,529,147,006,943 |
ed6583a42e2c48ec4ebf4b16bd5149e31761ecf6
|
/01100/BOJ_1159.java
|
efb32ec8b6a4c48ad7fb088c0be8ffd3f9bec4c7
|
[] |
no_license
|
NaHwaSa/BOJ_BaekjunOnlineJudge
|
https://github.com/NaHwaSa/BOJ_BaekjunOnlineJudge
|
582aa9d9cc0064c2fffd072b0a7a7014c0732645
|
264b034df3631f4c1e55f75b4c3fb9b17ac70417
|
refs/heads/master
| 2022-05-14T02:11:04.678000 | 2022-05-13T12:59:45 | 2022-05-13T12:59:45 | 185,815,821 | 8 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int[] cnt = new int['z'-'a'+1];
int n = Integer.parseInt(br.readLine());
for (int i = 0; i < n; i++) {
String s = br.readLine();
cnt[s.charAt(0) - 'a']++;
}
boolean chk = false;
for (int i = 0; i < cnt.length; i++) {
if (cnt[i] >= 5) {
chk = true;
bw.write((char)(i + 'a') + "");
}
}
if (!chk)
bw.write("PREDAJA\n");
else
bw.newLine();
bw.flush();
bw.close();
br.close();
}
}
|
UTF-8
|
Java
| 841 |
java
|
BOJ_1159.java
|
Java
|
[] | null |
[] |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int[] cnt = new int['z'-'a'+1];
int n = Integer.parseInt(br.readLine());
for (int i = 0; i < n; i++) {
String s = br.readLine();
cnt[s.charAt(0) - 'a']++;
}
boolean chk = false;
for (int i = 0; i < cnt.length; i++) {
if (cnt[i] >= 5) {
chk = true;
bw.write((char)(i + 'a') + "");
}
}
if (!chk)
bw.write("PREDAJA\n");
else
bw.newLine();
bw.flush();
bw.close();
br.close();
}
}
| 841 | 0.617122 | 0.611177 | 38 | 21.131578 | 19.451925 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.421053 | false | false |
0
|
9f3123f971c557a8de763c14bcad5ccc49c84af4
| 7,000,796,756,530 |
df8e97cf1a8a937ef7bd2a735400a5147f2af22d
|
/lpoProject/visitors/Visitor.java
|
f687021a179d532e2c4645a2394508567dfdfe6f
|
[] |
no_license
|
giacomobenedetti/LPOProject
|
https://github.com/giacomobenedetti/LPOProject
|
2abf93072b8d139b7ad7335e055c5c204f652d14
|
996132fc453b24b342fff6be5b730018c5948a5a
|
refs/heads/master
| 2021-10-27T07:49:39.211000 | 2019-04-16T21:56:01 | 2019-04-16T21:56:01 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package lpoProject.visitors;
import lpoProject.parser.ast.*;
import lpoProject.visitors.evaluation.PrimValue;
import java.util.Optional;
public interface Visitor<T> {
T visitAdd(Exp left, Exp right);
T visitAssignStmt(Ident ident, Exp exp);
T visitForEachStmt(Ident ident, Exp exp, StmtSeq block);
T visitGet(Exp exp);
T visitIfStmt(Exp guard, StmtSeq block, StmtSeq elseBlock);
T visitDoWhileStmt(StmtSeq block, Exp guard);
T visitDef(Exp exp);
T visitEmpty(Exp exp);
T visitIntLiteral(int value);
T visitBoolLiteral(boolean value);
T visitOptLiteral(Exp value);
T visitListLiteral(ExpSeq exps);
T visitMoreExp(Exp first, ExpSeq rest);
T visitMoreStmt(Stmt first, StmtSeq rest);
T visitMul(Exp left, Exp right);
T visitNot(Exp exp);
T visitAnd(Exp left, Exp right);
T visitEq(Exp left, Exp right);
T visitPrefix(Exp left, Exp right);
T visitPrintStmt(Exp exp);
T visitProg(StmtSeq stmtSeq);
T visitSign(Exp exp);
T visitIdent(String name);
T visitSingleExp(Exp exp);
T visitSingleStmt(Stmt stmt);
T visitVarStmt(Ident ident, Exp exp);
}
|
UTF-8
|
Java
| 1,101 |
java
|
Visitor.java
|
Java
|
[] | null |
[] |
package lpoProject.visitors;
import lpoProject.parser.ast.*;
import lpoProject.visitors.evaluation.PrimValue;
import java.util.Optional;
public interface Visitor<T> {
T visitAdd(Exp left, Exp right);
T visitAssignStmt(Ident ident, Exp exp);
T visitForEachStmt(Ident ident, Exp exp, StmtSeq block);
T visitGet(Exp exp);
T visitIfStmt(Exp guard, StmtSeq block, StmtSeq elseBlock);
T visitDoWhileStmt(StmtSeq block, Exp guard);
T visitDef(Exp exp);
T visitEmpty(Exp exp);
T visitIntLiteral(int value);
T visitBoolLiteral(boolean value);
T visitOptLiteral(Exp value);
T visitListLiteral(ExpSeq exps);
T visitMoreExp(Exp first, ExpSeq rest);
T visitMoreStmt(Stmt first, StmtSeq rest);
T visitMul(Exp left, Exp right);
T visitNot(Exp exp);
T visitAnd(Exp left, Exp right);
T visitEq(Exp left, Exp right);
T visitPrefix(Exp left, Exp right);
T visitPrintStmt(Exp exp);
T visitProg(StmtSeq stmtSeq);
T visitSign(Exp exp);
T visitIdent(String name);
T visitSingleExp(Exp exp);
T visitSingleStmt(Stmt stmt);
T visitVarStmt(Ident ident, Exp exp);
}
| 1,101 | 0.734787 | 0.734787 | 60 | 17.35 | 18.079292 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.116667 | false | false |
0
|
3cdfff3accf53f1277f3dd5b9822c7832b170d98
| 11,012,296,171,961 |
a2321f425f17a566b93de706fd465bc2de5d2c01
|
/app/src/main/java/com/eaglesakura/andriders/computer/central/record/UserRecordCentral.java
|
db9a19bdf21aae9d269f2e435b822caff4220ade
|
[] |
no_license
|
fkmhrk/andriders-central-engine-v3
|
https://github.com/fkmhrk/andriders-central-engine-v3
|
10660ebd8e1e7559eb59baabf9552c8f318ae174
|
9c7fea6d3cce5e4cc81e959a9655e38879118bfc
|
refs/heads/master
| 2020-12-24T13:52:14.442000 | 2016-02-11T08:44:33 | 2016-02-11T08:44:33 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.eaglesakura.andriders.computer.central.record;
import com.eaglesakura.andriders.computer.central.CentralDataManager;
/**
* ユーザーの自己新記録を管理する
*/
public class UserRecordCentral implements CentralDataManager.ICentral {
@Override
public void onUpdate(CentralDataManager parent) {
}
@Override
public boolean isDelete(CentralDataManager parent) {
return false;
}
}
|
UTF-8
|
Java
| 437 |
java
|
UserRecordCentral.java
|
Java
|
[] | null |
[] |
package com.eaglesakura.andriders.computer.central.record;
import com.eaglesakura.andriders.computer.central.CentralDataManager;
/**
* ユーザーの自己新記録を管理する
*/
public class UserRecordCentral implements CentralDataManager.ICentral {
@Override
public void onUpdate(CentralDataManager parent) {
}
@Override
public boolean isDelete(CentralDataManager parent) {
return false;
}
}
| 437 | 0.751843 | 0.751843 | 18 | 21.611111 | 25.68644 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | false | false |
0
|
2ca352525e246c7d9d37c5823b025fef2566b3f0
| 26,061,861,576,726 |
869b4845a43c53b65273edb00a255256f17011c0
|
/regression/TestUnusualLanguageFeatures/src/vuze/InnerFieldClient.java
|
f17379b1cd68c438c5adf88d312bf7d419d5e005
|
[] |
no_license
|
surelogic/regression
|
https://github.com/surelogic/regression
|
62879ef0b7dd197dfc6961e08fc2f71e3e0ced2a
|
a391ebc3959f730d2607e3bdfa9239a999b861c5
|
refs/heads/master
| 2021-04-30T23:41:12.571000 | 2016-04-20T16:50:26 | 2016-04-20T16:50:26 | 50,687,446 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package vuze;
public class InnerFieldClient {
InnerFieldTest.provider az3 = InnerFieldTest.getProvider();
}
|
UTF-8
|
Java
| 115 |
java
|
InnerFieldClient.java
|
Java
|
[] | null |
[] |
package vuze;
public class InnerFieldClient {
InnerFieldTest.provider az3 = InnerFieldTest.getProvider();
}
| 115 | 0.765217 | 0.756522 | 5 | 21 | 22.476654 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false |
0
|
0171c0cc795345fb6ed971d2ffc98fec3d9df410
| 18,081,812,339,782 |
acc44c3749e89e372e1839325c70e0cba6bee404
|
/MeghanaDinesh/que10.java
|
c1e415a9583f66759022bf01eec359b774853805
|
[] |
no_license
|
ignite-plus-2021/Assignments-2021
|
https://github.com/ignite-plus-2021/Assignments-2021
|
fab2f0bf6ea17822cfff0212bc8a82d9a3b5bb29
|
d12b6d257b3c0df88d0f64268129ee68cec8a491
|
refs/heads/main
| 2023-04-27T00:15:23.780000 | 2021-06-08T12:44:26 | 2021-06-08T12:44:26 | 345,991,838 | 0 | 27 | null | false | 2021-05-28T10:57:01 | 2021-03-09T12:02:49 | 2021-05-28T10:49:16 | 2021-05-28T10:57:00 | 484 | 0 | 22 | 4 |
Java
| false | false |
package com.practice;
import java.util.Scanner;
public class que10
{
public static int gcd(int num1,int num2)
{
if(num2==0)
return num1;
return gcd(num2,num1%num2) ;
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the first number:");
int num1=sc.nextInt();
System.out.println("Enter the second number:");
int num2=sc.nextInt();
int ans=gcd(num1,num2);
System.out.println("GCD="+ans);
}
}
|
UTF-8
|
Java
| 553 |
java
|
que10.java
|
Java
|
[] | null |
[] |
package com.practice;
import java.util.Scanner;
public class que10
{
public static int gcd(int num1,int num2)
{
if(num2==0)
return num1;
return gcd(num2,num1%num2) ;
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the first number:");
int num1=sc.nextInt();
System.out.println("Enter the second number:");
int num2=sc.nextInt();
int ans=gcd(num1,num2);
System.out.println("GCD="+ans);
}
}
| 553 | 0.585895 | 0.560579 | 21 | 25.333334 | 16.810804 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false |
0
|
26ba38da560e7015803360496e48c0d1b609e06c
| 14,096,082,732,040 |
fec7f88b4d375285b17463e77150e7067c64ab57
|
/plano-cartesiano/src/Entrada.java
|
c4a061246ce95fbaefb56072310b86bab4d3b1f7
|
[] |
no_license
|
LBezerril/plano-cartesiando
|
https://github.com/LBezerril/plano-cartesiando
|
3c535200ca732f0b801967c2882463c0281cf245
|
f6ca8099f73ef13d1ff7a81d914987240b3be19d
|
refs/heads/master
| 2015-08-14T06:43:34.382000 | 2014-10-25T16:19:04 | 2014-10-25T16:19:04 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.Scanner;
public class Entrada {
Scanner entrada = new Scanner(System.in);
public String defineEntrada() {
return entrada.nextLine();
}
}
|
UTF-8
|
Java
| 163 |
java
|
Entrada.java
|
Java
|
[] | null |
[] |
import java.util.Scanner;
public class Entrada {
Scanner entrada = new Scanner(System.in);
public String defineEntrada() {
return entrada.nextLine();
}
}
| 163 | 0.717791 | 0.717791 | 11 | 13.818182 | 15.331596 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.727273 | false | false |
0
|
9e852336072a54b50859630b7a7386942110a043
| 17,609,365,977,701 |
f1c67d041c3d79c4b05915a25a1602957e74d3dc
|
/src/main/java/br/net/brjdevs/steven/bran/core/currency/DroppedMoney.java
|
ab77ab5bd1d3278ba4a76751e77fea5044aaad0a
|
[] |
no_license
|
StupPlayer/Bran
|
https://github.com/StupPlayer/Bran
|
c36c3e56960064ba2a6ee006ed4f71d936ba7f18
|
a6aed269059dc75d053af30bc42b0e7ed44454db
|
refs/heads/master
| 2019-08-20T12:10:44.976000 | 2017-04-18T00:44:24 | 2017-04-18T00:44:24 | 78,230,483 | 14 | 12 | null | false | 2017-04-17T23:41:59 | 2017-01-06T18:52:58 | 2017-04-08T04:48:19 | 2017-04-17T23:41:58 | 946 | 7 | 3 | 0 |
Java
| null | null |
package br.net.brjdevs.steven.bran.core.currency;
import net.dv8tion.jda.core.entities.TextChannel;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
public class DroppedMoney {
private static final Map<String, AtomicInteger> DROPPED_MONEY = new HashMap<>();
private static Random r = new Random(System.currentTimeMillis());
private final AtomicInteger money;
private DroppedMoney(AtomicInteger money) {
this.money = money;
}
public static DroppedMoney of(String id) {
return new DroppedMoney(DROPPED_MONEY.computeIfAbsent(id, k -> new AtomicInteger(0)));
}
public static DroppedMoney of(TextChannel channel) {
return of(channel.getId());
}
public int collect() {
return money.getAndSet(0);
}
public void drop(int money) {
this.money.addAndGet(money);
}
public boolean dropWithChance(int money, int weight) {
boolean doDrop = r.nextInt(weight) == 0;
if (doDrop) drop(money);
return doDrop;
}
}
|
UTF-8
|
Java
| 1,017 |
java
|
DroppedMoney.java
|
Java
|
[] | null |
[] |
package br.net.brjdevs.steven.bran.core.currency;
import net.dv8tion.jda.core.entities.TextChannel;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
public class DroppedMoney {
private static final Map<String, AtomicInteger> DROPPED_MONEY = new HashMap<>();
private static Random r = new Random(System.currentTimeMillis());
private final AtomicInteger money;
private DroppedMoney(AtomicInteger money) {
this.money = money;
}
public static DroppedMoney of(String id) {
return new DroppedMoney(DROPPED_MONEY.computeIfAbsent(id, k -> new AtomicInteger(0)));
}
public static DroppedMoney of(TextChannel channel) {
return of(channel.getId());
}
public int collect() {
return money.getAndSet(0);
}
public void drop(int money) {
this.money.addAndGet(money);
}
public boolean dropWithChance(int money, int weight) {
boolean doDrop = r.nextInt(weight) == 0;
if (doDrop) drop(money);
return doDrop;
}
}
| 1,017 | 0.738446 | 0.734513 | 42 | 23.214285 | 23.688993 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.404762 | false | false |
0
|
0f08c02316dc58238c0bdc696e78ca33ba12339a
| 8,564,164,834,842 |
a691c3afb36548a8ea69424e8416bfda0a46f3e9
|
/src/android/main/java/fr/dynacare/poc_ihealth_cross_plugin/eventBus/ConnectedData.java
|
9519c4496fa9682dce49aa55e02cd8f9f91ad06c
|
[] |
no_license
|
thedeadofblackfire/plug
|
https://github.com/thedeadofblackfire/plug
|
35c7b171ccbc810587c4e4f7ba4cfd1768d25467
|
d77e472813309aee82660404c2783b73d5e8b6fd
|
refs/heads/master
| 2021-01-19T09:58:52.962000 | 2017-04-11T16:04:09 | 2017-04-11T16:04:09 | 87,806,388 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package fr.dynacare.poc_ihealth_cross_plugin.eventBus;
/**
* Created by guillaumeboufflers on 06/07/2016.
*/
public class ConnectedData {
public String mName;
public String mAddress;
public String mModel;
public ConnectedData(String name, String address, String type){
mName = name;
mAddress = address;
mModel = type;
}
}
|
UTF-8
|
Java
| 370 |
java
|
ConnectedData.java
|
Java
|
[
{
"context": "_ihealth_cross_plugin.eventBus;\n\n/**\n * Created by guillaumeboufflers on 06/07/2016.\n */\npublic class ConnectedData {\n ",
"end": 92,
"score": 0.9964335560798645,
"start": 74,
"tag": "USERNAME",
"value": "guillaumeboufflers"
}
] | null |
[] |
package fr.dynacare.poc_ihealth_cross_plugin.eventBus;
/**
* Created by guillaumeboufflers on 06/07/2016.
*/
public class ConnectedData {
public String mName;
public String mAddress;
public String mModel;
public ConnectedData(String name, String address, String type){
mName = name;
mAddress = address;
mModel = type;
}
}
| 370 | 0.67027 | 0.648649 | 16 | 22.125 | 19.675095 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5625 | false | false |
0
|
879321d34fa39577bb11d61a2ba65c8c845a3572
| 8,693,013,824,574 |
7452a90f5cc5b52bb2880792d8b8a64cbffda6b4
|
/Euler/p001t040/Euler031TwoPounds.java
|
6fa32579ba3682b37d85dfe65d459918e6b76eeb
|
[] |
no_license
|
scyptnex/computing
|
https://github.com/scyptnex/computing
|
33e2100aceb44b79ec10d65e5e1207a61f880209
|
284d6575a02736bb9dd3526429f2348362619a1e
|
refs/heads/master
| 2021-12-15T02:17:21.054000 | 2021-12-10T05:57:42 | 2021-12-10T05:57:42 | 6,026,162 | 0 | 4 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package p001t040;
public class Euler031TwoPounds {
public static final int[] denoms = {200, 100, 50, 20, 10, 5, 2, 1};
public static int[][] memo = new int[201][denoms.length];
/**
* @param args
*/
public static void main(String[] args) {
for(int a=0; a<memo.length; a++){
for(int c=0; c<denoms.length; c++){
memo[a][c] = -1;
}
}
make(200, 0);
System.out.println(memo[200][0]);
}
public static int make(int amt, int fromCoin){
if(fromCoin >= denoms.length){
if(amt == 0) return 1;
return 0;
}
if(memo[amt][fromCoin] != -1) return memo[amt][fromCoin];
int made = 0;
for(int cur=0; cur*denoms[fromCoin]<=amt; cur++){
made += make(amt-(cur*denoms[fromCoin]), fromCoin+1);
}
memo[amt][fromCoin] = made;
return made;
}
}
|
UTF-8
|
Java
| 779 |
java
|
Euler031TwoPounds.java
|
Java
|
[] | null |
[] |
package p001t040;
public class Euler031TwoPounds {
public static final int[] denoms = {200, 100, 50, 20, 10, 5, 2, 1};
public static int[][] memo = new int[201][denoms.length];
/**
* @param args
*/
public static void main(String[] args) {
for(int a=0; a<memo.length; a++){
for(int c=0; c<denoms.length; c++){
memo[a][c] = -1;
}
}
make(200, 0);
System.out.println(memo[200][0]);
}
public static int make(int amt, int fromCoin){
if(fromCoin >= denoms.length){
if(amt == 0) return 1;
return 0;
}
if(memo[amt][fromCoin] != -1) return memo[amt][fromCoin];
int made = 0;
for(int cur=0; cur*denoms[fromCoin]<=amt; cur++){
made += make(amt-(cur*denoms[fromCoin]), fromCoin+1);
}
memo[amt][fromCoin] = made;
return made;
}
}
| 779 | 0.60077 | 0.543004 | 36 | 20.638889 | 20.385387 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.333333 | false | false |
0
|
3b0a5a7eae13f5551a9d66135e04a23f3be8c372
| 8,693,013,823,204 |
cec0c2fa585c3f788fc8becf24365e56bce94368
|
/net/minecraft/world/level/levelgen/synth/NormalNoise.java
|
e726037b27ec4adf6babfb751e4f82b99f340849
|
[] |
no_license
|
maksym-pasichnyk/Server-1.16.3-Remapped
|
https://github.com/maksym-pasichnyk/Server-1.16.3-Remapped
|
358f3c4816cbf41e137947329389edf24e9c6910
|
4d992e2d9d4ada3ecf7cecc039c4aa0083bc461e
|
refs/heads/master
| 2022-12-15T08:54:21.236000 | 2020-09-19T16:13:43 | 2020-09-19T16:13:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/* */ package net.minecraft.world.level.levelgen.synth;
/* */
/* */ import it.unimi.dsi.fastutil.doubles.DoubleList;
/* */ import it.unimi.dsi.fastutil.doubles.DoubleListIterator;
/* */ import net.minecraft.world.level.levelgen.WorldgenRandom;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class NormalNoise
/* */ {
/* */ private final double valueFactor;
/* */ private final PerlinNoise first;
/* */ private final PerlinNoise second;
/* */
/* */ public static NormalNoise create(WorldgenRandom debug0, int debug1, DoubleList debug2) {
/* 31 */ return new NormalNoise(debug0, debug1, debug2);
/* */ }
/* */
/* */ private NormalNoise(WorldgenRandom debug1, int debug2, DoubleList debug3) {
/* 35 */ this.first = PerlinNoise.create(debug1, debug2, debug3);
/* 36 */ this.second = PerlinNoise.create(debug1, debug2, debug3);
/* */
/* 38 */ int debug4 = Integer.MAX_VALUE;
/* 39 */ int debug5 = Integer.MIN_VALUE;
/* */
/* 41 */ DoubleListIterator debug6 = debug3.iterator();
/* 42 */ while (debug6.hasNext()) {
/* 43 */ int debug7 = debug6.nextIndex();
/* 44 */ double debug8 = debug6.nextDouble();
/* 45 */ if (debug8 != 0.0D) {
/* 46 */ debug4 = Math.min(debug4, debug7);
/* 47 */ debug5 = Math.max(debug5, debug7);
/* */ }
/* */ }
/* */
/* 51 */ this.valueFactor = 0.16666666666666666D / expectedDeviation(debug5 - debug4);
/* */ }
/* */
/* */
/* */
/* */
/* */ private static double expectedDeviation(int debug0) {
/* 58 */ return 0.1D * (1.0D + 1.0D / (debug0 + 1));
/* */ }
/* */
/* */ public double getValue(double debug1, double debug3, double debug5) {
/* 62 */ double debug7 = debug1 * 1.0181268882175227D;
/* 63 */ double debug9 = debug3 * 1.0181268882175227D;
/* 64 */ double debug11 = debug5 * 1.0181268882175227D;
/* 65 */ return (this.first.getValue(debug1, debug3, debug5) + this.second.getValue(debug7, debug9, debug11)) * this.valueFactor;
/* */ }
/* */ }
/* Location: C:\Users\Josep\Downloads\Decompile Minecraft\deobfuscated.jar!\net\minecraft\world\level\levelgen\synth\NormalNoise.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/
|
UTF-8
|
Java
| 2,482 |
java
|
NormalNoise.java
|
Java
|
[
{
"context": "}\n/* */ }\n\n\n/* Location: C:\\Users\\Josep\\Downloads\\Decompile Minecraft\\deobfuscated.jar!\\n",
"end": 2304,
"score": 0.9089729189872742,
"start": 2299,
"tag": "NAME",
"value": "Josep"
}
] | null |
[] |
/* */ package net.minecraft.world.level.levelgen.synth;
/* */
/* */ import it.unimi.dsi.fastutil.doubles.DoubleList;
/* */ import it.unimi.dsi.fastutil.doubles.DoubleListIterator;
/* */ import net.minecraft.world.level.levelgen.WorldgenRandom;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class NormalNoise
/* */ {
/* */ private final double valueFactor;
/* */ private final PerlinNoise first;
/* */ private final PerlinNoise second;
/* */
/* */ public static NormalNoise create(WorldgenRandom debug0, int debug1, DoubleList debug2) {
/* 31 */ return new NormalNoise(debug0, debug1, debug2);
/* */ }
/* */
/* */ private NormalNoise(WorldgenRandom debug1, int debug2, DoubleList debug3) {
/* 35 */ this.first = PerlinNoise.create(debug1, debug2, debug3);
/* 36 */ this.second = PerlinNoise.create(debug1, debug2, debug3);
/* */
/* 38 */ int debug4 = Integer.MAX_VALUE;
/* 39 */ int debug5 = Integer.MIN_VALUE;
/* */
/* 41 */ DoubleListIterator debug6 = debug3.iterator();
/* 42 */ while (debug6.hasNext()) {
/* 43 */ int debug7 = debug6.nextIndex();
/* 44 */ double debug8 = debug6.nextDouble();
/* 45 */ if (debug8 != 0.0D) {
/* 46 */ debug4 = Math.min(debug4, debug7);
/* 47 */ debug5 = Math.max(debug5, debug7);
/* */ }
/* */ }
/* */
/* 51 */ this.valueFactor = 0.16666666666666666D / expectedDeviation(debug5 - debug4);
/* */ }
/* */
/* */
/* */
/* */
/* */ private static double expectedDeviation(int debug0) {
/* 58 */ return 0.1D * (1.0D + 1.0D / (debug0 + 1));
/* */ }
/* */
/* */ public double getValue(double debug1, double debug3, double debug5) {
/* 62 */ double debug7 = debug1 * 1.0181268882175227D;
/* 63 */ double debug9 = debug3 * 1.0181268882175227D;
/* 64 */ double debug11 = debug5 * 1.0181268882175227D;
/* 65 */ return (this.first.getValue(debug1, debug3, debug5) + this.second.getValue(debug7, debug9, debug11)) * this.valueFactor;
/* */ }
/* */ }
/* Location: C:\Users\Josep\Downloads\Decompile Minecraft\deobfuscated.jar!\net\minecraft\world\level\levelgen\synth\NormalNoise.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/
| 2,482 | 0.542305 | 0.472603 | 73 | 33.013699 | 31.078554 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.561644 | false | false |
0
|
6b46397ede82a2c924dd124cc6a46d491e41d40f
| 13,383,118,138,109 |
fa91450deb625cda070e82d5c31770be5ca1dec6
|
/Diff-Raw-Data/10/10_df5d853422152d382853aa0d928ea05b20b640d6/ViewMessageActivity/10_df5d853422152d382853aa0d928ea05b20b640d6_ViewMessageActivity_s.java
|
a0e846076b61a68c97410339c058e815693935eb
|
[] |
no_license
|
zhongxingyu/Seer
|
https://github.com/zhongxingyu/Seer
|
48e7e5197624d7afa94d23f849f8ea2075bcaec0
|
c11a3109fdfca9be337e509ecb2c085b60076213
|
refs/heads/master
| 2023-07-06T12:48:55.516000 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | false | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | 2023-06-21T00:53:27 | 2023-06-22T07:55:57 | 2,849,868 | 2 | 2 | 0 | null | false | false |
package edu.utsa.cs.smsmessenger.activity;
import java.text.SimpleDateFormat;
import edu.utsa.cs.smsmessenger.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.FloatMath;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.TableLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import edu.utsa.cs.smsmessenger.model.ContactContainer;
import edu.utsa.cs.smsmessenger.model.MessageContainer;
import edu.utsa.cs.smsmessenger.util.ContactsUtil;
import edu.utsa.cs.smsmessenger.util.SmsMessageHandler;
public class ViewMessageActivity extends Activity {
private TableLayout rootTable;
private TextView txtMsgBody; // Where the body of the message being view is
// shown
private MessageContainer currentMessage; // Message structure that is being
// displayed in the View Message
// activity
private ContactContainer currentContact; // The contact associated with the
// current message being viewed
private SmsMessageHandler smsMessageHandler; // /handler used to the delete
// the message if chosen
private Context context; // Context - this - used for deleting messages
private String contactURI; // string used to get the contact image from the
// contacts app
// Touch event related variables
int touchState;
final int IDLE = 0; // no fingers touching
final int TOUCH = 1; // one finger touching
final int PINCH = 2; // two fingers touching
float dist0, distCurrent; // The distances used to figure out how much to
// zoom
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.conversation_to_message_item);
Bundle extras = getIntent().getExtras();
currentMessage = new MessageContainer();
// Fill in the message container with information from the message
// clicked
currentMessage.setBody(extras.getString("msgBody"));
currentMessage.setDate(extras.getLong("timeAndDate"));
currentMessage.setContactId(extras
.getInt(SmsMessageHandler.COL_NAME_CONTACT_ID));
currentMessage.setPhoneNumber(extras
.getString(SmsMessageHandler.COL_NAME_PHONE_NUMBER));
currentMessage.setType(extras.getString("msgType"));
currentMessage.setId(extras.getLong("msgID"));
currentContact = ContactsUtil.getContactByPhoneNumber(
this.getContentResolver(), currentMessage.getPhoneNumber());
updateUI();
distCurrent = 1; // Dummy default distance
dist0 = 1; // Dummy default distance
rootTable.setOnTouchListener(ZoomListener);
touchState = IDLE;
context = this;
Log.d("ViewMessageActivity",
"view Message Activity: " + currentMessage.getBody() + " from "
+ currentMessage.getContactId());
return;
}
private void updateUI() {
setTitle(currentMessage.getType()
.equals(SmsMessageHandler.MSG_TYPE_OUT) ? getResources()
.getString(R.string.self_reference) : (currentContact
.getDisplayName() != null ? currentContact.getDisplayName()
: currentMessage.getPhoneNumber()));
txtMsgBody = (TextView) findViewById(R.id.msgBodyTextView);
txtMsgBody.setText(currentMessage.getBody());
SimpleDateFormat sdf = new SimpleDateFormat(context.getResources()
.getString(R.string.date_time_format), context.getResources()
.getConfiguration().locale);
TextView txtTimeAndDate = (TextView) findViewById(R.id.msgDateTextView);
txtTimeAndDate.setText(sdf.format(currentMessage.getDate()));
ImageView contactImageView = (ImageView) findViewById(R.id.msgImageView);
if (currentMessage.getType().equals(SmsMessageHandler.MSG_TYPE_IN)) {
if (currentContact.getPhotoUri() != null) {
contactImageView.setImageURI(Uri.parse(currentContact
.getPhotoUri()));
if (contactImageView.getDrawable() == null) {
contactImageView.setImageResource(R.drawable.hg_contact);
}
} else {
contactImageView.setImageResource(R.drawable.hg_contact);
}
} else {
contactImageView.setImageResource(R.drawable.me_icon);
}
rootTable = (TableLayout) findViewById(R.id.viewMsgTable);
// tableRow1
// Find the root view
View root = rootTable.getRootView();
if (currentMessage.getType().equals(SmsMessageHandler.MSG_TYPE_IN)) {
root.setBackgroundColor(getResources().getColor(
R.color.backroundColor));
} else {
root.setBackgroundColor(getResources().getColor(R.color.RowColor1));
}
return;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.view_msg_menu_list, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Toast msg;
switch (item.getItemId()) {
case R.id.action_forward:
msg = Toast.makeText(this, R.string.forward_toast,
Toast.LENGTH_LONG);
msg.show();
Intent forwardIntent = new Intent(this,// Create intent for forward
// - the message body will
// already be filled
NewConversationActivity.class);
forwardIntent.putExtra("fwdBody", currentMessage.getBody());
startActivity(forwardIntent);
break;
case R.id.action_reply:
msg = Toast.makeText(this, R.string.reply_toast, Toast.LENGTH_LONG);
msg.show();
Intent replyIntent = new Intent(this, NewConversationActivity.class); // Create
// intent
// for
// reply
// -
// the
// number
// will
// already
// be
// filled
replyIntent.putExtra("replyContact",
currentMessage.getPhoneNumber());
startActivity(replyIntent);
break;
case R.id.action_delete:
try {
DialogInterface.OnClickListener DeleteOnClick = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
deleteMessage();
break;
case DialogInterface.BUTTON_NEGATIVE:
break;
}
}
};
AlertDialog.Builder b = new AlertDialog.Builder(this);
b.setTitle(R.string.delete_msg_confirmation);
b.setPositiveButton(R.string.acknowlege_descision,
DeleteOnClick);
b.setNegativeButton(R.string.decline_desicion, DeleteOnClick);
b.create().show();
} catch (Exception x) {
Log.d("ViewMessageActivity",
"Threw Error on delete:" + x.getMessage());
}
break;
}
return super.onOptionsItemSelected(item);
}
private void deleteMessage() {
Toast msg = Toast.makeText(this, R.string.delete_toast,
Toast.LENGTH_LONG);
msg.show();
MessageContainer[] msgArr = { currentMessage };
DeleteMessageFromDbTask deleteThread = new DeleteMessageFromDbTask();
deleteThread.execute(msgArr);
Intent converListIntent = new Intent(this,
ConversationsListActivity.class); // Create intent for the root
// screen
converListIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Should
// make it
// so that
// you can't
// go back
// with back
// button
startActivity(converListIntent);
}
private void updateFontSize() {
float newsize;
float curScale = distCurrent / dist0;
if (curScale < 0.1) {
curScale = 0.1f;
}
newsize = (12 * curScale); // 12 is the baseline font size - all
// alterations will be relative to this
if (newsize < 9) {
newsize = 9;
}
if (newsize > 56) {
newsize = 56;
}
txtMsgBody.setTextSize(newsize);
}
OnTouchListener ZoomListener = new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
// TODO Auto-generated method stub
float distx, disty;
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
// A pressed gesture has started, the motion contains the
// initial starting location.
touchState = TOUCH;
break;
case MotionEvent.ACTION_POINTER_DOWN:
// A non-primary pointer has gone down.
touchState = PINCH;
// Get the distance when the second pointer touch
distx = event.getX(0) - event.getX(1);
disty = event.getY(0) - event.getY(1);
dist0 = FloatMath.sqrt(distx * distx + disty * disty);
break;
case MotionEvent.ACTION_MOVE:
// A change has happened during a press gesture (between
// ACTION_DOWN and ACTION_UP).
if (touchState == PINCH) {
// Get the current distance
distx = event.getX(0) - event.getX(1);
disty = event.getY(0) - event.getY(1);
distCurrent = FloatMath.sqrt(distx * distx + disty * disty);
updateFontSize();
}
break;
case MotionEvent.ACTION_UP:
// A pressed gesture has finished.
touchState = IDLE;
break;
case MotionEvent.ACTION_POINTER_UP:
// A non-primary pointer has gone up.
touchState = TOUCH;
break;
}
return true;
}
};
private class DeleteMessageFromDbTask extends
AsyncTask<MessageContainer, Void, Void> {
@Override
protected Void doInBackground(MessageContainer... objects) {
if (context != null) {
for (MessageContainer msg : objects) {
getSmsMessageHandler().deleteMessage(msg);
}
getSmsMessageHandler().close();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
Intent newMsgIntent = new Intent(
SmsMessageHandler.UPDATE_MSG_INTENT);
context.sendBroadcast(newMsgIntent);
}
}
private SmsMessageHandler getSmsMessageHandler() {
if (smsMessageHandler == null)
smsMessageHandler = new SmsMessageHandler(context);
return smsMessageHandler;
}
}
|
UTF-8
|
Java
| 10,550 |
java
|
10_df5d853422152d382853aa0d928ea05b20b640d6_ViewMessageActivity_s.java
|
Java
|
[] | null |
[] |
package edu.utsa.cs.smsmessenger.activity;
import java.text.SimpleDateFormat;
import edu.utsa.cs.smsmessenger.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.FloatMath;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.TableLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import edu.utsa.cs.smsmessenger.model.ContactContainer;
import edu.utsa.cs.smsmessenger.model.MessageContainer;
import edu.utsa.cs.smsmessenger.util.ContactsUtil;
import edu.utsa.cs.smsmessenger.util.SmsMessageHandler;
public class ViewMessageActivity extends Activity {
private TableLayout rootTable;
private TextView txtMsgBody; // Where the body of the message being view is
// shown
private MessageContainer currentMessage; // Message structure that is being
// displayed in the View Message
// activity
private ContactContainer currentContact; // The contact associated with the
// current message being viewed
private SmsMessageHandler smsMessageHandler; // /handler used to the delete
// the message if chosen
private Context context; // Context - this - used for deleting messages
private String contactURI; // string used to get the contact image from the
// contacts app
// Touch event related variables
int touchState;
final int IDLE = 0; // no fingers touching
final int TOUCH = 1; // one finger touching
final int PINCH = 2; // two fingers touching
float dist0, distCurrent; // The distances used to figure out how much to
// zoom
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.conversation_to_message_item);
Bundle extras = getIntent().getExtras();
currentMessage = new MessageContainer();
// Fill in the message container with information from the message
// clicked
currentMessage.setBody(extras.getString("msgBody"));
currentMessage.setDate(extras.getLong("timeAndDate"));
currentMessage.setContactId(extras
.getInt(SmsMessageHandler.COL_NAME_CONTACT_ID));
currentMessage.setPhoneNumber(extras
.getString(SmsMessageHandler.COL_NAME_PHONE_NUMBER));
currentMessage.setType(extras.getString("msgType"));
currentMessage.setId(extras.getLong("msgID"));
currentContact = ContactsUtil.getContactByPhoneNumber(
this.getContentResolver(), currentMessage.getPhoneNumber());
updateUI();
distCurrent = 1; // Dummy default distance
dist0 = 1; // Dummy default distance
rootTable.setOnTouchListener(ZoomListener);
touchState = IDLE;
context = this;
Log.d("ViewMessageActivity",
"view Message Activity: " + currentMessage.getBody() + " from "
+ currentMessage.getContactId());
return;
}
private void updateUI() {
setTitle(currentMessage.getType()
.equals(SmsMessageHandler.MSG_TYPE_OUT) ? getResources()
.getString(R.string.self_reference) : (currentContact
.getDisplayName() != null ? currentContact.getDisplayName()
: currentMessage.getPhoneNumber()));
txtMsgBody = (TextView) findViewById(R.id.msgBodyTextView);
txtMsgBody.setText(currentMessage.getBody());
SimpleDateFormat sdf = new SimpleDateFormat(context.getResources()
.getString(R.string.date_time_format), context.getResources()
.getConfiguration().locale);
TextView txtTimeAndDate = (TextView) findViewById(R.id.msgDateTextView);
txtTimeAndDate.setText(sdf.format(currentMessage.getDate()));
ImageView contactImageView = (ImageView) findViewById(R.id.msgImageView);
if (currentMessage.getType().equals(SmsMessageHandler.MSG_TYPE_IN)) {
if (currentContact.getPhotoUri() != null) {
contactImageView.setImageURI(Uri.parse(currentContact
.getPhotoUri()));
if (contactImageView.getDrawable() == null) {
contactImageView.setImageResource(R.drawable.hg_contact);
}
} else {
contactImageView.setImageResource(R.drawable.hg_contact);
}
} else {
contactImageView.setImageResource(R.drawable.me_icon);
}
rootTable = (TableLayout) findViewById(R.id.viewMsgTable);
// tableRow1
// Find the root view
View root = rootTable.getRootView();
if (currentMessage.getType().equals(SmsMessageHandler.MSG_TYPE_IN)) {
root.setBackgroundColor(getResources().getColor(
R.color.backroundColor));
} else {
root.setBackgroundColor(getResources().getColor(R.color.RowColor1));
}
return;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.view_msg_menu_list, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Toast msg;
switch (item.getItemId()) {
case R.id.action_forward:
msg = Toast.makeText(this, R.string.forward_toast,
Toast.LENGTH_LONG);
msg.show();
Intent forwardIntent = new Intent(this,// Create intent for forward
// - the message body will
// already be filled
NewConversationActivity.class);
forwardIntent.putExtra("fwdBody", currentMessage.getBody());
startActivity(forwardIntent);
break;
case R.id.action_reply:
msg = Toast.makeText(this, R.string.reply_toast, Toast.LENGTH_LONG);
msg.show();
Intent replyIntent = new Intent(this, NewConversationActivity.class); // Create
// intent
// for
// reply
// -
// the
// number
// will
// already
// be
// filled
replyIntent.putExtra("replyContact",
currentMessage.getPhoneNumber());
startActivity(replyIntent);
break;
case R.id.action_delete:
try {
DialogInterface.OnClickListener DeleteOnClick = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
deleteMessage();
break;
case DialogInterface.BUTTON_NEGATIVE:
break;
}
}
};
AlertDialog.Builder b = new AlertDialog.Builder(this);
b.setTitle(R.string.delete_msg_confirmation);
b.setPositiveButton(R.string.acknowlege_descision,
DeleteOnClick);
b.setNegativeButton(R.string.decline_desicion, DeleteOnClick);
b.create().show();
} catch (Exception x) {
Log.d("ViewMessageActivity",
"Threw Error on delete:" + x.getMessage());
}
break;
}
return super.onOptionsItemSelected(item);
}
private void deleteMessage() {
Toast msg = Toast.makeText(this, R.string.delete_toast,
Toast.LENGTH_LONG);
msg.show();
MessageContainer[] msgArr = { currentMessage };
DeleteMessageFromDbTask deleteThread = new DeleteMessageFromDbTask();
deleteThread.execute(msgArr);
Intent converListIntent = new Intent(this,
ConversationsListActivity.class); // Create intent for the root
// screen
converListIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Should
// make it
// so that
// you can't
// go back
// with back
// button
startActivity(converListIntent);
}
private void updateFontSize() {
float newsize;
float curScale = distCurrent / dist0;
if (curScale < 0.1) {
curScale = 0.1f;
}
newsize = (12 * curScale); // 12 is the baseline font size - all
// alterations will be relative to this
if (newsize < 9) {
newsize = 9;
}
if (newsize > 56) {
newsize = 56;
}
txtMsgBody.setTextSize(newsize);
}
OnTouchListener ZoomListener = new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
// TODO Auto-generated method stub
float distx, disty;
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
// A pressed gesture has started, the motion contains the
// initial starting location.
touchState = TOUCH;
break;
case MotionEvent.ACTION_POINTER_DOWN:
// A non-primary pointer has gone down.
touchState = PINCH;
// Get the distance when the second pointer touch
distx = event.getX(0) - event.getX(1);
disty = event.getY(0) - event.getY(1);
dist0 = FloatMath.sqrt(distx * distx + disty * disty);
break;
case MotionEvent.ACTION_MOVE:
// A change has happened during a press gesture (between
// ACTION_DOWN and ACTION_UP).
if (touchState == PINCH) {
// Get the current distance
distx = event.getX(0) - event.getX(1);
disty = event.getY(0) - event.getY(1);
distCurrent = FloatMath.sqrt(distx * distx + disty * disty);
updateFontSize();
}
break;
case MotionEvent.ACTION_UP:
// A pressed gesture has finished.
touchState = IDLE;
break;
case MotionEvent.ACTION_POINTER_UP:
// A non-primary pointer has gone up.
touchState = TOUCH;
break;
}
return true;
}
};
private class DeleteMessageFromDbTask extends
AsyncTask<MessageContainer, Void, Void> {
@Override
protected Void doInBackground(MessageContainer... objects) {
if (context != null) {
for (MessageContainer msg : objects) {
getSmsMessageHandler().deleteMessage(msg);
}
getSmsMessageHandler().close();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
Intent newMsgIntent = new Intent(
SmsMessageHandler.UPDATE_MSG_INTENT);
context.sendBroadcast(newMsgIntent);
}
}
private SmsMessageHandler getSmsMessageHandler() {
if (smsMessageHandler == null)
smsMessageHandler = new SmsMessageHandler(context);
return smsMessageHandler;
}
}
| 10,550 | 0.667393 | 0.664265 | 356 | 28.632023 | 22.970474 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.544944 | false | false |
0
|
09c927ae92de7931014f55860cf2fc15e9fa4e19
| 22,436,909,193,942 |
0e0e93262ed4a97dfb0c7e6bbb34a3786370d035
|
/src/ch13_1_collections/MyeCollectionTest1.java
|
6a64fbb48f876a0acbbfcc40e3b17a6937da49cf
|
[] |
no_license
|
beetrootfarmer/Chapter13_CollectionFramework
|
https://github.com/beetrootfarmer/Chapter13_CollectionFramework
|
33c79d2624713bcde0127d900b9dede0154b9a35
|
c3b17a1d7b4b2852282af264e8ce1bdd12bdded7
|
refs/heads/master
| 2023-07-17T18:46:28.853000 | 2021-08-23T05:07:22 | 2021-08-23T05:07:22 | 398,933,592 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package ch13_1_collections;
import com.libs.collection.MyeMyeList;
public class MyeCollectionTest1 {
public static void main(String[] args) {
MyeMyeList list = new MyeMyeList(3);
list.add(1);
list.add(5);
System.out.println(list);
System.out.println("list[2]의 값: " + list.get(2));
System.out.println("size: " + list.size());
System.out.println("----------------------------");
}
}
//과제야
// 증가
// ArrayIndexOutOfBoundsException 해결하기
// list.add(7);
// 삭제
// list.remove(1);
// [1, 3, 5,] => [1, 5,]
// list.clear(); // 입력된 값들 다 없애고 초기화
|
UTF-8
|
Java
| 623 |
java
|
MyeCollectionTest1.java
|
Java
|
[] | null |
[] |
package ch13_1_collections;
import com.libs.collection.MyeMyeList;
public class MyeCollectionTest1 {
public static void main(String[] args) {
MyeMyeList list = new MyeMyeList(3);
list.add(1);
list.add(5);
System.out.println(list);
System.out.println("list[2]의 값: " + list.get(2));
System.out.println("size: " + list.size());
System.out.println("----------------------------");
}
}
//과제야
// 증가
// ArrayIndexOutOfBoundsException 해결하기
// list.add(7);
// 삭제
// list.remove(1);
// [1, 3, 5,] => [1, 5,]
// list.clear(); // 입력된 값들 다 없애고 초기화
| 623 | 0.593368 | 0.565445 | 31 | 17.483871 | 17.470474 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.354839 | false | false |
0
|
547a25538d2ab462758beb8b165348eeea61d43e
| 18,829,136,684,963 |
fa91450deb625cda070e82d5c31770be5ca1dec6
|
/Diff-Raw-Data/16/16_6df45b61bfc5c4a9c7a163577d63c9979a6d272f/ActividadDAOTest/16_6df45b61bfc5c4a9c7a163577d63c9979a6d272f_ActividadDAOTest_t.java
|
3df504aa45a93824074fec36eebeff9bf4291e66
|
[] |
no_license
|
zhongxingyu/Seer
|
https://github.com/zhongxingyu/Seer
|
48e7e5197624d7afa94d23f849f8ea2075bcaec0
|
c11a3109fdfca9be337e509ecb2c085b60076213
|
refs/heads/master
| 2023-07-06T12:48:55.516000 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | false | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | 2023-06-21T00:53:27 | 2023-06-22T07:55:57 | 2,849,868 | 2 | 2 | 0 | null | false | false |
package com.odea;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.odea.dao.ActividadDAO;
import com.odea.dao.EntradaDAO;
import com.odea.domain.Actividad;
import com.odea.domain.Usuario;
public class ActividadDAOTest extends AbstractTestCase {
@Autowired
private ActividadDAO dao;
@Autowired
EntradaDAO daoe;
public Actividad actividad = new Actividad(1,"Actividad 1");
public List<Integer> lista;
public void setUp(){
super.setUp();
lista = new List<Integer>() {
@Override
public boolean add(Integer e) {
// TODO Auto-generated method stub
return false;
}
@Override
public void add(int index, Integer element) {
// TODO Auto-generated method stub
}
@Override
public boolean addAll(Collection<? extends Integer> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean addAll(int index, Collection<? extends Integer> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public void clear() {
// TODO Auto-generated method stub
}
@Override
public boolean contains(Object o) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean containsAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public Integer get(int index) {
// TODO Auto-generated method stub
return null;
}
@Override
public int indexOf(Object o) {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean isEmpty() {
// TODO Auto-generated method stub
return false;
}
@Override
public Iterator<Integer> iterator() {
// TODO Auto-generated method stub
return null;
}
@Override
public int lastIndexOf(Object o) {
// TODO Auto-generated method stub
return 0;
}
@Override
public ListIterator<Integer> listIterator() {
// TODO Auto-generated method stub
return null;
}
@Override
public ListIterator<Integer> listIterator(int index) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean remove(Object o) {
// TODO Auto-generated method stub
return false;
}
@Override
public Integer remove(int index) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean removeAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean retainAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public Integer set(int index, Integer element) {
// TODO Auto-generated method stub
return null;
}
@Override
public int size() {
// TODO Auto-generated method stub
return 0;
}
@Override
public List<Integer> subList(int fromIndex, int toIndex) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object[] toArray() {
// TODO Auto-generated method stub
return null;
}
@Override
public <T> T[] toArray(T[] a) {
// TODO Auto-generated method stub
return null;
}
};
lista.clear();
lista.add(1);
lista.add(3);
lista.add(5);
lista.add(8);
}
@Test
public void insertarTest(){
System.out.println("hola");
Actividad act = new Actividad(199,"Actividad 1");
System.out.println(actividad.getIdActividad());
dao.insertarActividad(act);
}
@Test
public void relacionarTest (){
//dao.relacionarActividad(actividad,lista);
//TODO:arreglar test
}
@Test
public void borrarTest(){
dao.borrarActividad(actividad);
}
@Test
public void getTotalHoras(){
Usuario user= new Usuario(57,"invitado","invitado");
int total = daoe.getHorasSemanales(user);
Assert.assertFalse("mal calculado", total<1);
}
}
|
UTF-8
|
Java
| 4,230 |
java
|
16_6df45b61bfc5c4a9c7a163577d63c9979a6d272f_ActividadDAOTest_t.java
|
Java
|
[] | null |
[] |
package com.odea;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.odea.dao.ActividadDAO;
import com.odea.dao.EntradaDAO;
import com.odea.domain.Actividad;
import com.odea.domain.Usuario;
public class ActividadDAOTest extends AbstractTestCase {
@Autowired
private ActividadDAO dao;
@Autowired
EntradaDAO daoe;
public Actividad actividad = new Actividad(1,"Actividad 1");
public List<Integer> lista;
public void setUp(){
super.setUp();
lista = new List<Integer>() {
@Override
public boolean add(Integer e) {
// TODO Auto-generated method stub
return false;
}
@Override
public void add(int index, Integer element) {
// TODO Auto-generated method stub
}
@Override
public boolean addAll(Collection<? extends Integer> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean addAll(int index, Collection<? extends Integer> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public void clear() {
// TODO Auto-generated method stub
}
@Override
public boolean contains(Object o) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean containsAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public Integer get(int index) {
// TODO Auto-generated method stub
return null;
}
@Override
public int indexOf(Object o) {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean isEmpty() {
// TODO Auto-generated method stub
return false;
}
@Override
public Iterator<Integer> iterator() {
// TODO Auto-generated method stub
return null;
}
@Override
public int lastIndexOf(Object o) {
// TODO Auto-generated method stub
return 0;
}
@Override
public ListIterator<Integer> listIterator() {
// TODO Auto-generated method stub
return null;
}
@Override
public ListIterator<Integer> listIterator(int index) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean remove(Object o) {
// TODO Auto-generated method stub
return false;
}
@Override
public Integer remove(int index) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean removeAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean retainAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public Integer set(int index, Integer element) {
// TODO Auto-generated method stub
return null;
}
@Override
public int size() {
// TODO Auto-generated method stub
return 0;
}
@Override
public List<Integer> subList(int fromIndex, int toIndex) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object[] toArray() {
// TODO Auto-generated method stub
return null;
}
@Override
public <T> T[] toArray(T[] a) {
// TODO Auto-generated method stub
return null;
}
};
lista.clear();
lista.add(1);
lista.add(3);
lista.add(5);
lista.add(8);
}
@Test
public void insertarTest(){
System.out.println("hola");
Actividad act = new Actividad(199,"Actividad 1");
System.out.println(actividad.getIdActividad());
dao.insertarActividad(act);
}
@Test
public void relacionarTest (){
//dao.relacionarActividad(actividad,lista);
//TODO:arreglar test
}
@Test
public void borrarTest(){
dao.borrarActividad(actividad);
}
@Test
public void getTotalHoras(){
Usuario user= new Usuario(57,"invitado","invitado");
int total = daoe.getHorasSemanales(user);
Assert.assertFalse("mal calculado", total<1);
}
}
| 4,230 | 0.634279 | 0.630496 | 203 | 19.832512 | 16.934574 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.561576 | false | false |
0
|
9e50c5e0a5a313b73d83d00c15d870eeccb77f8c
| 11,184,094,881,885 |
10a65548fe890bc9bdbf9a5266c161c717382f68
|
/app/src/main/java/steiner/bisley/restclient/MainActivity.java
|
356b825c7b8b868b484b2e0f8b86df573a8a529f
|
[] |
no_license
|
SarifIndustries/RestClient
|
https://github.com/SarifIndustries/RestClient
|
f912902d09f12ccc796a5a59c67a1c85f628cb82
|
ccb0b1f2ce669f926d51a6bd410ce42340d64d95
|
refs/heads/master
| 2020-04-08T21:58:31.735000 | 2019-04-05T05:32:29 | 2019-04-05T05:32:29 | 159,765,768 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package steiner.bisley.restclient;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.internal.annotations.EverythingIsNonNull;
public class MainActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener {
private static final String MAIN_ALBUMS_URL = "https://jsonplaceholder.typicode.com/albums";
private static final int DELAY_MILLI = 2000;
private OkHttpClient okHttpClient;
private boolean jsonStatus = false;
ArrayList<Album> albumList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Loading Fragment
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
LoadingFragment loadingFragment = new LoadingFragment();
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.add(R.id.MainFrameLayoutForFragment, loadingFragment);
transaction.commit();
okHttpClient = new OkHttpClient();
// Background thread call HTTP GET
// netRunner() fills this.albumList field
try {
netRunner();
} catch (IOException e) {
e.printStackTrace();
Log.v("MainActivity", "NetRunner Error");
}
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
FragmentManager fragmentManager = MainActivity.this.getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
boolean successJSON = MainActivity.this.getJsonStatus();
Fragment fragment;
if(successJSON) {
fragment = new RecyclerFragment();
}
else {
fragment = new WentWrongFragment();
}
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.replace(R.id.MainFrameLayoutForFragment, fragment);
transaction.commit();
}
}, DELAY_MILLI);
}
private void netRunner() throws IOException {
Log.v("MainActivity", "Netrunner Start");
Request request = new Request.Builder().url(MAIN_ALBUMS_URL).get().build();
okHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull IOException e) {
call.cancel();
Log.v("MainActivity", "NO success");
}
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
final String text = response.body().string();
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
jsonParse(text);
// TODO: catch gson parsing exception
MainActivity.this.setJsonStatus(true);
}
});
Log.v("MainActivity", "success");
}
});
}
void jsonParse(String jsonText) {
Gson gson = new Gson();
// GSON
// GSON git 2
Type ListType = new TypeToken<ArrayList<Album>>(){}.getType();
albumList = gson.fromJson(jsonText, ListType);
}
boolean getJsonStatus() {
return jsonStatus;
}
void setJsonStatus(boolean jsonStatus) {
this.jsonStatus = jsonStatus;
}
/**
* Swipe refresh listener
*/
@Override
public void onRefresh() {
Log.v("MainActivity", "Swipe trigger.");
MainActivity.this.setJsonStatus(false);
try {
netRunner();
} catch (IOException e) {
e.printStackTrace();
Log.v("MainActivity", "NetRunner Error");
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.swipeRefreshLayoutAlbums);
swipeRefreshLayout.setRefreshing(false);
FragmentManager fragmentManager = MainActivity.this.getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
boolean successJSON = MainActivity.this.getJsonStatus();
Fragment fragment;
if(successJSON) {
fragment = new RecyclerFragment();
}
else {
fragment = new WentWrongFragment();
}
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.replace(R.id.MainFrameLayoutForFragment, fragment);
transaction.commit();
}
}, DELAY_MILLI);
}
}
|
UTF-8
|
Java
| 5,726 |
java
|
MainActivity.java
|
Java
|
[] | null |
[] |
package steiner.bisley.restclient;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.internal.annotations.EverythingIsNonNull;
public class MainActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener {
private static final String MAIN_ALBUMS_URL = "https://jsonplaceholder.typicode.com/albums";
private static final int DELAY_MILLI = 2000;
private OkHttpClient okHttpClient;
private boolean jsonStatus = false;
ArrayList<Album> albumList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Loading Fragment
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
LoadingFragment loadingFragment = new LoadingFragment();
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.add(R.id.MainFrameLayoutForFragment, loadingFragment);
transaction.commit();
okHttpClient = new OkHttpClient();
// Background thread call HTTP GET
// netRunner() fills this.albumList field
try {
netRunner();
} catch (IOException e) {
e.printStackTrace();
Log.v("MainActivity", "NetRunner Error");
}
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
FragmentManager fragmentManager = MainActivity.this.getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
boolean successJSON = MainActivity.this.getJsonStatus();
Fragment fragment;
if(successJSON) {
fragment = new RecyclerFragment();
}
else {
fragment = new WentWrongFragment();
}
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.replace(R.id.MainFrameLayoutForFragment, fragment);
transaction.commit();
}
}, DELAY_MILLI);
}
private void netRunner() throws IOException {
Log.v("MainActivity", "Netrunner Start");
Request request = new Request.Builder().url(MAIN_ALBUMS_URL).get().build();
okHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull IOException e) {
call.cancel();
Log.v("MainActivity", "NO success");
}
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
final String text = response.body().string();
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
jsonParse(text);
// TODO: catch gson parsing exception
MainActivity.this.setJsonStatus(true);
}
});
Log.v("MainActivity", "success");
}
});
}
void jsonParse(String jsonText) {
Gson gson = new Gson();
// GSON
// GSON git 2
Type ListType = new TypeToken<ArrayList<Album>>(){}.getType();
albumList = gson.fromJson(jsonText, ListType);
}
boolean getJsonStatus() {
return jsonStatus;
}
void setJsonStatus(boolean jsonStatus) {
this.jsonStatus = jsonStatus;
}
/**
* Swipe refresh listener
*/
@Override
public void onRefresh() {
Log.v("MainActivity", "Swipe trigger.");
MainActivity.this.setJsonStatus(false);
try {
netRunner();
} catch (IOException e) {
e.printStackTrace();
Log.v("MainActivity", "NetRunner Error");
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.swipeRefreshLayoutAlbums);
swipeRefreshLayout.setRefreshing(false);
FragmentManager fragmentManager = MainActivity.this.getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
boolean successJSON = MainActivity.this.getJsonStatus();
Fragment fragment;
if(successJSON) {
fragment = new RecyclerFragment();
}
else {
fragment = new WentWrongFragment();
}
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.replace(R.id.MainFrameLayoutForFragment, fragment);
transaction.commit();
}
}, DELAY_MILLI);
}
}
| 5,726 | 0.612644 | 0.60985 | 174 | 31.908047 | 26.802441 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.545977 | false | false |
0
|
00e2217ae047e05a2072f7bc86fb7e10ab5b3af3
| 33,887,291,982,976 |
02b1ef26e9ddd96a860ef6a3dce7d8386436fd0f
|
/ts-resourceplanning.util/src/main/java/de/trispeedys/resourceplanning/parser/ValueParser.java
|
67eb5703c80d599c46327bee534989c9e7334c25
|
[] |
no_license
|
gheddie/speedys-resourceplanning-redraft
|
https://github.com/gheddie/speedys-resourceplanning-redraft
|
1a4bd0ca1231854129693733f01874b09a677994
|
80bb84147209a6c5f5847113c92012a7df0cf268
|
refs/heads/master
| 2020-05-21T04:22:42.405000 | 2017-01-24T19:10:03 | 2017-01-24T19:10:03 | 64,926,986 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package de.trispeedys.resourceplanning.parser;
import java.util.HashMap;
import org.joda.time.LocalDate;
import de.trispeedys.resourceplanning.parser.impl.DefaultValueParser;
import de.trispeedys.resourceplanning.parser.impl.LocalDateValueParser;
import de.trispeedys.resourceplanning.parser.impl.LongValueParser;
public class ValueParser
{
private static HashMap<Class<?>, AbstractValueParser<?>> parserHash = new HashMap<>();
static
{
parserHash.put(LocalDate.class, new LocalDateValueParser());
parserHash.put(Long.class, new LongValueParser());
parserHash.put(String.class, new DefaultValueParser());
}
@SuppressWarnings("unchecked")
public static <T> T parseValue(String value, Class<?> targetClass)
{
return (T) parserHash.get(targetClass).parseValue(value);
}
public static String formatValue(Object unformattedValue)
{
return parserHash.get(unformattedValue.getClass()).formatValue(unformattedValue);
}
}
|
UTF-8
|
Java
| 1,040 |
java
|
ValueParser.java
|
Java
|
[] | null |
[] |
package de.trispeedys.resourceplanning.parser;
import java.util.HashMap;
import org.joda.time.LocalDate;
import de.trispeedys.resourceplanning.parser.impl.DefaultValueParser;
import de.trispeedys.resourceplanning.parser.impl.LocalDateValueParser;
import de.trispeedys.resourceplanning.parser.impl.LongValueParser;
public class ValueParser
{
private static HashMap<Class<?>, AbstractValueParser<?>> parserHash = new HashMap<>();
static
{
parserHash.put(LocalDate.class, new LocalDateValueParser());
parserHash.put(Long.class, new LongValueParser());
parserHash.put(String.class, new DefaultValueParser());
}
@SuppressWarnings("unchecked")
public static <T> T parseValue(String value, Class<?> targetClass)
{
return (T) parserHash.get(targetClass).parseValue(value);
}
public static String formatValue(Object unformattedValue)
{
return parserHash.get(unformattedValue.getClass()).formatValue(unformattedValue);
}
}
| 1,040 | 0.714423 | 0.714423 | 31 | 31.612904 | 30.962702 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.548387 | false | false |
0
|
b2b6859551a881aa744abfaa4a1bd0c2fecb9c22
| 37,366,215,476,537 |
d7288c7847ee4b1c8886ebd0a0e043155dd8bc1b
|
/pbs_svc/src/network/APNS_Packet.java
|
9097ac85bb79f7f42bda96094a6aac50ff8f0c0e
|
[] |
no_license
|
Deahyun/PushBegins
|
https://github.com/Deahyun/PushBegins
|
ed7c83567b57fcf75d438322f9f117d8ba517fc0
|
c59c3080998a70ba66b5781a226d5508a49dd62c
|
refs/heads/master
| 2021-01-10T18:02:52.207000 | 2016-05-18T02:27:57 | 2016-05-18T02:27:57 | 55,385,619 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package network;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Date;
import org.json.simple.JSONObject;
import utils.UserLog;
public class APNS_Packet {
byte[] byPacket = null;
int nPacketLength = 0;
String tag = "APNS_Packet";
public APNS_Packet() {
byPacket = new byte[256];
}
@SuppressWarnings("unchecked")
void putEx(JSONObject jo, String key, String value) {
jo.put(key, value);
}
@SuppressWarnings("unchecked")
void putEx(JSONObject jo, String key, int value) {
jo.put(key, value);
}
public byte[] hexStringToByteArray(String str)
{
if ( str == null || str.length() == 0 )
return null;
//
str = str.replace(" ", "");
int nStrLength = str.length();
if ( nStrLength != 64 )
return null;
//String strDebug = String.format("%d", nStrLength);
//UserLog.Log(tag, strDebug);
byte[] buffer = new byte[nStrLength / 2];
for (int i = 0; i < nStrLength/2; i++ ) {
buffer[i] = (byte)Integer.parseInt(str.substring(i*2, i*2 + 2), 16);
//strDebug = String.format("range %d -> %d", i*2, i*2 + 2);
//UserLog.Log(tag, strDebug);
}
return buffer;
}
//
public String byteArrayToHexString(byte[] bytes) {
StringBuilder result = new StringBuilder();
for (byte b : bytes) {
String strFmt = String.format("%02x", b);
result.append(strFmt);
//result.append(Integer.toHexString(b));
}
return result.toString();
}
public byte[] GetIntBytes(int value)
{
//ByteBuffer buffer = ByteBuffer.allocate(4).order(ByteOrder.nativeOrder());
ByteBuffer buffer = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN);
buffer.putInt(value);
return buffer.array();
}
public byte[] GetShortBytes(short value)
{
//ByteBuffer buffer = ByteBuffer.allocate(2).order(ByteOrder.nativeOrder());
ByteBuffer buffer = ByteBuffer.allocate(2).order(ByteOrder.BIG_ENDIAN);
buffer.putShort(value);
return buffer.array();
}
public void makePacket(String msg_id, String message, String device_token)
{
if (message == null || device_token == null)
{
UserLog.Log(tag, "message == null || device_token == null");
return;
}
//
int nPos = 0;
//
byte[] byCmd = new byte[1];
byCmd[0] = 0;
System.arraycopy(byCmd, 0, byPacket, 0, 1);
nPos += 1;
//
short token_length = 32;
byte[] byTokenLength = GetShortBytes(token_length);
System.arraycopy(byTokenLength, 0, byPacket, nPos, 2);
nPos += 2;
//
byte[] byToken = hexStringToByteArray(device_token.toUpperCase());
System.arraycopy(byToken, 0, byPacket, nPos, 32);
nPos += 32;
//
byte[] byTmp = new byte[32];
System.arraycopy(byToken, 0, byTmp, 0, 32);
//String strDeviceToken = byteArrayToHexString(byTmp);
//UserLog.Log(tag, strDeviceToken);
//
String payload = "{\"aps\":{\"alert\":\"" + message + "\",\"badge\":1,\"sound\":\"default\"},\"msg_id\":\"" + msg_id + "\"}";
byte[] byData = null;
try {
byData = payload.getBytes("UTF-8");
} catch ( Exception e ) {
e.printStackTrace();
}
//
short payload_length = (short)byData.length;
byte[] byPayloadLength = GetShortBytes(payload_length);
System.arraycopy(byPayloadLength, 0, byPacket, nPos, 2);
nPos += 2;
//
System.arraycopy(byData, 0, byPacket, nPos, payload_length);
nPos += payload_length;
//
int active_length = (token_length + payload_length + 5);
nPacketLength = active_length;
//
//String strDebug = String.format("packet length: %d", nPacketLength);
//UserLog.Log(tag, strDebug);
}
//
public void makePacket(String message, String device_token)
{
if (message == null || device_token == null)
{
UserLog.Log(tag, "message == null || device_token == null");
return;
}
//
int nPos = 0;
//
byte[] byCmd = new byte[1];
byCmd[0] = 0;
System.arraycopy(byCmd, 0, byPacket, 0, 1);
nPos += 1;
//
short token_length = 32;
byte[] byTokenLength = GetShortBytes(token_length);
System.arraycopy(byTokenLength, 0, byPacket, nPos, 2);
nPos += 2;
//
byte[] byToken = hexStringToByteArray(device_token.toUpperCase());
System.arraycopy(byToken, 0, byPacket, nPos, 32);
nPos += 32;
//
byte[] byTmp = new byte[32];
System.arraycopy(byToken, 0, byTmp, 0, 32);
//
//String payload = "{\"aps\":{\"alert\":\"" + message + "\",\"badge\":1,\"sound\":\"default\"}}";
String payload = "{\"aps\":{\"alert\":\"" + message + "\",\"badge\":4,\"sound\":\"default\"}}";
byte[] byData = null;
try {
byData = payload.getBytes("UTF-8");
} catch ( Exception e ) {
e.printStackTrace();
}
//
short payload_length = (short)byData.length;
byte[] byPayloadLength = GetShortBytes(payload_length);
System.arraycopy(byPayloadLength, 0, byPacket, nPos, 2);
nPos += 2;
//
System.arraycopy(byData, 0, byPacket, nPos, payload_length);
nPos += payload_length;
//
int active_length = (token_length + payload_length + 5);
nPacketLength = active_length;
//
//String strDebug = String.format("packet length: %d", nPacketLength);
//UserLog.Log(tag, strDebug);
}
@SuppressWarnings("unchecked")
public boolean makePacket(APNS_Message message, String device_token)
{
if (message == null || device_token == null) {
UserLog.Log(tag, "message == null || device_token == null");
return false;
}
if (message.alert == null || message.alert.length() == 0 ) {
UserLog.Log(tag, "message.alert has no value");
return false;
}
////
final int nUTF8LimitLength = 200;
try {
byte[] utf8_alert = message.alert.getBytes("UTF-8");
//byte[] utf8_user_data = message.user_data.getBytes("UTF-8");
//if ( (utf8_alert.length + utf8_user_data.length) > nUTF8LimitLength ) {
if ( utf8_alert.length > nUTF8LimitLength ) {
UserLog.Log(tag, "message.alert has too long value");
return false;
}
} catch ( Exception e ) {
e.printStackTrace();
return false;
}
////
//
int nPos = 0;
//
byte[] byCmd = new byte[1];
byCmd[0] = 0;
System.arraycopy(byCmd, 0, byPacket, 0, 1);
nPos += 1;
//
short token_length = 32;
byte[] byTokenLength = GetShortBytes(token_length);
System.arraycopy(byTokenLength, 0, byPacket, nPos, 2);
nPos += 2;
//
byte[] byToken = hexStringToByteArray(device_token.toUpperCase());
System.arraycopy(byToken, 0, byPacket, nPos, 32);
nPos += 32;
//
byte[] byTmp = new byte[32];
System.arraycopy(byToken, 0, byTmp, 0, 32);
//
//String payload = "{\"aps\":{\"alert\":\"" + message + "\",\"badge\":1,\"sound\":\"default\"}}";
//String payload = "{\"aps\":{\"alert\":\"" + message.alert + "\",\"badge\":4,\"sound\":\"default\"}}";
JSONObject joRoot = new JSONObject();
JSONObject joAps = new JSONObject();
//JSONObject joExtra = new JSONObject();
//
joAps.put("alert", message.alert);
if ( message.badge > 0 )
joAps.put("badge", message.badge);
if ( message.sound != null && message.sound.length() > 0 ) {
joAps.put("sound", message.sound);
}
//
joAps.put("content-available", 1);
//
if ( message.user_data != null && message.user_data.length() > 0 ) {
//joRoot.put("user_data", message.user_data);
joRoot.put("user_data", message.m_id);
}
//
joRoot.put("aps", joAps);
//
String payload = joRoot.toString();
//UserLog.Log(tag, "payload -> " + payload);
//
// int nPayloadLength = 0;
// //int nPayloadLength = payload.length();
// byte[] utf8 = null;
// try {
// utf8 = payload.getBytes("UTF-8");
// nPayloadLength = utf8.length;
// } catch ( Exception e ) {
//
// }
//UserLog.Log(tag, "payload length -> " + nPayloadLength);
// if ( false && nPayloadLength > byPacket.length ) {
// //String strAlert = message.alert;
// //int nAlert = strAlert.length();
// //strAlert = strAlert.substring(0, nPayloadLength - nAlert);
// byte[] byPayload = new byte[nPayloadLength - byPacket.length];
// System.arraycopy(utf8, 0, byPayload, 0, nPayloadLength - byPacket.length);
// String strAlert = new String(utf8, 0, nPayloadLength - byPacket.length);
// ////
// joRoot.clear();
// joAps.clear();
// joExtra.clear();
// //
// joAps.put("alert", strAlert);
// if ( message.badge > 0 )
// joAps.put("badge", message.badge);
// if ( message.sound == null || message.sound.length() == 0 ) {
// //
// } else {
// joAps.put("sound", message.sound);
// }
// //
// joExtra.put("a", 1234);
// joExtra.put("b", "가나다라");
// joAps.put("json_data", joExtra);
//
// //
// joRoot.put("aps", joAps);
// ////
// payload = joRoot.toString();
// UserLog.Log(tag, "payload2 -> " + payload);
// }
byte[] byData = null;
try {
byData = payload.getBytes("UTF-8");
} catch ( Exception e ) {
e.printStackTrace();
return false;
}
//
short payload_length = (short)byData.length;
byte[] byPayloadLength = GetShortBytes(payload_length);
System.arraycopy(byPayloadLength, 0, byPacket, nPos, 2);
nPos += 2;
//
System.arraycopy(byData, 0, byPacket, nPos, payload_length);
nPos += payload_length;
//
int active_length = (token_length + payload_length + 5);
nPacketLength = active_length;
//
//String strDebug = String.format("packet length: %d", nPacketLength);
//UserLog.Log(tag, strDebug);
//
return true;
}
//////////
public void makePacketEx(String message, String device_token)
{
if (message == null || device_token == null)
{
UserLog.Log(tag, "message == null || device_token == null");
return;
}
//
int nPos = 0;
//
byte[] byCmd = new byte[1];
byCmd[0] = 1;
System.arraycopy(byCmd, 0, byPacket, 0, 1);
nPos += 1;
//
int identifier = 1234;
byte[] byIdentifier = GetIntBytes(identifier);
System.arraycopy(byIdentifier, 0, byPacket, nPos, 4);
nPos += 4;
//
Date now = new Date();
long lExpiry = now.getTime();
int expiry = (int)(lExpiry / 1000L) + 86400;
byte[] byExpiry = GetIntBytes(expiry);
//byExpiry[0] = byExpiry[1] = byExpiry[2] = byExpiry[3] = 0;
System.arraycopy(byExpiry, 0, byPacket, nPos, 4);
nPos += 4;
//
short token_length = 32;
byte[] byTokenLength = GetShortBytes(token_length);
System.arraycopy(byTokenLength, 0, byPacket, nPos, 2);
nPos += 2;
//
byte[] byToken = hexStringToByteArray(device_token.toUpperCase());
System.arraycopy(byToken, 0, byPacket, nPos, 32);
nPos += 32;
//
String payload = "{\"aps\":{\"alert\":\"" + message + "\",\"badge\":1,\"sound\":\"default\"}}";
byte[] byData = null;
try {
byData = payload.getBytes("UTF-8");
} catch ( Exception e ) {
e.printStackTrace();
}
//
short payload_length = (short)byData.length;
byte[] byPayloadLength = GetShortBytes(payload_length);
System.arraycopy(byPayloadLength, 0, byPacket, nPos, 2);
nPos += 2;
//
System.arraycopy(byData, 0, byPacket, nPos, payload_length);
nPos += payload_length;
//
int active_length = (token_length + payload_length + 13);
nPacketLength = active_length;
//
//String strDebug = String.format("packet_ex length: %d", nPacketLength);
//UserLog.Log(tag, strDebug);
}
public byte[] getPacket()
{
byte[] byResult = new byte[nPacketLength];
//Array.Copy(byPacket, byResult, nPacketLength);
System.arraycopy(byPacket, 0, byResult, 0, nPacketLength);
return byResult;
}
}
|
UTF-8
|
Java
| 12,699 |
java
|
APNS_Packet.java
|
Java
|
[] | null |
[] |
package network;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Date;
import org.json.simple.JSONObject;
import utils.UserLog;
public class APNS_Packet {
byte[] byPacket = null;
int nPacketLength = 0;
String tag = "APNS_Packet";
public APNS_Packet() {
byPacket = new byte[256];
}
@SuppressWarnings("unchecked")
void putEx(JSONObject jo, String key, String value) {
jo.put(key, value);
}
@SuppressWarnings("unchecked")
void putEx(JSONObject jo, String key, int value) {
jo.put(key, value);
}
public byte[] hexStringToByteArray(String str)
{
if ( str == null || str.length() == 0 )
return null;
//
str = str.replace(" ", "");
int nStrLength = str.length();
if ( nStrLength != 64 )
return null;
//String strDebug = String.format("%d", nStrLength);
//UserLog.Log(tag, strDebug);
byte[] buffer = new byte[nStrLength / 2];
for (int i = 0; i < nStrLength/2; i++ ) {
buffer[i] = (byte)Integer.parseInt(str.substring(i*2, i*2 + 2), 16);
//strDebug = String.format("range %d -> %d", i*2, i*2 + 2);
//UserLog.Log(tag, strDebug);
}
return buffer;
}
//
public String byteArrayToHexString(byte[] bytes) {
StringBuilder result = new StringBuilder();
for (byte b : bytes) {
String strFmt = String.format("%02x", b);
result.append(strFmt);
//result.append(Integer.toHexString(b));
}
return result.toString();
}
public byte[] GetIntBytes(int value)
{
//ByteBuffer buffer = ByteBuffer.allocate(4).order(ByteOrder.nativeOrder());
ByteBuffer buffer = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN);
buffer.putInt(value);
return buffer.array();
}
public byte[] GetShortBytes(short value)
{
//ByteBuffer buffer = ByteBuffer.allocate(2).order(ByteOrder.nativeOrder());
ByteBuffer buffer = ByteBuffer.allocate(2).order(ByteOrder.BIG_ENDIAN);
buffer.putShort(value);
return buffer.array();
}
public void makePacket(String msg_id, String message, String device_token)
{
if (message == null || device_token == null)
{
UserLog.Log(tag, "message == null || device_token == null");
return;
}
//
int nPos = 0;
//
byte[] byCmd = new byte[1];
byCmd[0] = 0;
System.arraycopy(byCmd, 0, byPacket, 0, 1);
nPos += 1;
//
short token_length = 32;
byte[] byTokenLength = GetShortBytes(token_length);
System.arraycopy(byTokenLength, 0, byPacket, nPos, 2);
nPos += 2;
//
byte[] byToken = hexStringToByteArray(device_token.toUpperCase());
System.arraycopy(byToken, 0, byPacket, nPos, 32);
nPos += 32;
//
byte[] byTmp = new byte[32];
System.arraycopy(byToken, 0, byTmp, 0, 32);
//String strDeviceToken = byteArrayToHexString(byTmp);
//UserLog.Log(tag, strDeviceToken);
//
String payload = "{\"aps\":{\"alert\":\"" + message + "\",\"badge\":1,\"sound\":\"default\"},\"msg_id\":\"" + msg_id + "\"}";
byte[] byData = null;
try {
byData = payload.getBytes("UTF-8");
} catch ( Exception e ) {
e.printStackTrace();
}
//
short payload_length = (short)byData.length;
byte[] byPayloadLength = GetShortBytes(payload_length);
System.arraycopy(byPayloadLength, 0, byPacket, nPos, 2);
nPos += 2;
//
System.arraycopy(byData, 0, byPacket, nPos, payload_length);
nPos += payload_length;
//
int active_length = (token_length + payload_length + 5);
nPacketLength = active_length;
//
//String strDebug = String.format("packet length: %d", nPacketLength);
//UserLog.Log(tag, strDebug);
}
//
public void makePacket(String message, String device_token)
{
if (message == null || device_token == null)
{
UserLog.Log(tag, "message == null || device_token == null");
return;
}
//
int nPos = 0;
//
byte[] byCmd = new byte[1];
byCmd[0] = 0;
System.arraycopy(byCmd, 0, byPacket, 0, 1);
nPos += 1;
//
short token_length = 32;
byte[] byTokenLength = GetShortBytes(token_length);
System.arraycopy(byTokenLength, 0, byPacket, nPos, 2);
nPos += 2;
//
byte[] byToken = hexStringToByteArray(device_token.toUpperCase());
System.arraycopy(byToken, 0, byPacket, nPos, 32);
nPos += 32;
//
byte[] byTmp = new byte[32];
System.arraycopy(byToken, 0, byTmp, 0, 32);
//
//String payload = "{\"aps\":{\"alert\":\"" + message + "\",\"badge\":1,\"sound\":\"default\"}}";
String payload = "{\"aps\":{\"alert\":\"" + message + "\",\"badge\":4,\"sound\":\"default\"}}";
byte[] byData = null;
try {
byData = payload.getBytes("UTF-8");
} catch ( Exception e ) {
e.printStackTrace();
}
//
short payload_length = (short)byData.length;
byte[] byPayloadLength = GetShortBytes(payload_length);
System.arraycopy(byPayloadLength, 0, byPacket, nPos, 2);
nPos += 2;
//
System.arraycopy(byData, 0, byPacket, nPos, payload_length);
nPos += payload_length;
//
int active_length = (token_length + payload_length + 5);
nPacketLength = active_length;
//
//String strDebug = String.format("packet length: %d", nPacketLength);
//UserLog.Log(tag, strDebug);
}
@SuppressWarnings("unchecked")
public boolean makePacket(APNS_Message message, String device_token)
{
if (message == null || device_token == null) {
UserLog.Log(tag, "message == null || device_token == null");
return false;
}
if (message.alert == null || message.alert.length() == 0 ) {
UserLog.Log(tag, "message.alert has no value");
return false;
}
////
final int nUTF8LimitLength = 200;
try {
byte[] utf8_alert = message.alert.getBytes("UTF-8");
//byte[] utf8_user_data = message.user_data.getBytes("UTF-8");
//if ( (utf8_alert.length + utf8_user_data.length) > nUTF8LimitLength ) {
if ( utf8_alert.length > nUTF8LimitLength ) {
UserLog.Log(tag, "message.alert has too long value");
return false;
}
} catch ( Exception e ) {
e.printStackTrace();
return false;
}
////
//
int nPos = 0;
//
byte[] byCmd = new byte[1];
byCmd[0] = 0;
System.arraycopy(byCmd, 0, byPacket, 0, 1);
nPos += 1;
//
short token_length = 32;
byte[] byTokenLength = GetShortBytes(token_length);
System.arraycopy(byTokenLength, 0, byPacket, nPos, 2);
nPos += 2;
//
byte[] byToken = hexStringToByteArray(device_token.toUpperCase());
System.arraycopy(byToken, 0, byPacket, nPos, 32);
nPos += 32;
//
byte[] byTmp = new byte[32];
System.arraycopy(byToken, 0, byTmp, 0, 32);
//
//String payload = "{\"aps\":{\"alert\":\"" + message + "\",\"badge\":1,\"sound\":\"default\"}}";
//String payload = "{\"aps\":{\"alert\":\"" + message.alert + "\",\"badge\":4,\"sound\":\"default\"}}";
JSONObject joRoot = new JSONObject();
JSONObject joAps = new JSONObject();
//JSONObject joExtra = new JSONObject();
//
joAps.put("alert", message.alert);
if ( message.badge > 0 )
joAps.put("badge", message.badge);
if ( message.sound != null && message.sound.length() > 0 ) {
joAps.put("sound", message.sound);
}
//
joAps.put("content-available", 1);
//
if ( message.user_data != null && message.user_data.length() > 0 ) {
//joRoot.put("user_data", message.user_data);
joRoot.put("user_data", message.m_id);
}
//
joRoot.put("aps", joAps);
//
String payload = joRoot.toString();
//UserLog.Log(tag, "payload -> " + payload);
//
// int nPayloadLength = 0;
// //int nPayloadLength = payload.length();
// byte[] utf8 = null;
// try {
// utf8 = payload.getBytes("UTF-8");
// nPayloadLength = utf8.length;
// } catch ( Exception e ) {
//
// }
//UserLog.Log(tag, "payload length -> " + nPayloadLength);
// if ( false && nPayloadLength > byPacket.length ) {
// //String strAlert = message.alert;
// //int nAlert = strAlert.length();
// //strAlert = strAlert.substring(0, nPayloadLength - nAlert);
// byte[] byPayload = new byte[nPayloadLength - byPacket.length];
// System.arraycopy(utf8, 0, byPayload, 0, nPayloadLength - byPacket.length);
// String strAlert = new String(utf8, 0, nPayloadLength - byPacket.length);
// ////
// joRoot.clear();
// joAps.clear();
// joExtra.clear();
// //
// joAps.put("alert", strAlert);
// if ( message.badge > 0 )
// joAps.put("badge", message.badge);
// if ( message.sound == null || message.sound.length() == 0 ) {
// //
// } else {
// joAps.put("sound", message.sound);
// }
// //
// joExtra.put("a", 1234);
// joExtra.put("b", "가나다라");
// joAps.put("json_data", joExtra);
//
// //
// joRoot.put("aps", joAps);
// ////
// payload = joRoot.toString();
// UserLog.Log(tag, "payload2 -> " + payload);
// }
byte[] byData = null;
try {
byData = payload.getBytes("UTF-8");
} catch ( Exception e ) {
e.printStackTrace();
return false;
}
//
short payload_length = (short)byData.length;
byte[] byPayloadLength = GetShortBytes(payload_length);
System.arraycopy(byPayloadLength, 0, byPacket, nPos, 2);
nPos += 2;
//
System.arraycopy(byData, 0, byPacket, nPos, payload_length);
nPos += payload_length;
//
int active_length = (token_length + payload_length + 5);
nPacketLength = active_length;
//
//String strDebug = String.format("packet length: %d", nPacketLength);
//UserLog.Log(tag, strDebug);
//
return true;
}
//////////
public void makePacketEx(String message, String device_token)
{
if (message == null || device_token == null)
{
UserLog.Log(tag, "message == null || device_token == null");
return;
}
//
int nPos = 0;
//
byte[] byCmd = new byte[1];
byCmd[0] = 1;
System.arraycopy(byCmd, 0, byPacket, 0, 1);
nPos += 1;
//
int identifier = 1234;
byte[] byIdentifier = GetIntBytes(identifier);
System.arraycopy(byIdentifier, 0, byPacket, nPos, 4);
nPos += 4;
//
Date now = new Date();
long lExpiry = now.getTime();
int expiry = (int)(lExpiry / 1000L) + 86400;
byte[] byExpiry = GetIntBytes(expiry);
//byExpiry[0] = byExpiry[1] = byExpiry[2] = byExpiry[3] = 0;
System.arraycopy(byExpiry, 0, byPacket, nPos, 4);
nPos += 4;
//
short token_length = 32;
byte[] byTokenLength = GetShortBytes(token_length);
System.arraycopy(byTokenLength, 0, byPacket, nPos, 2);
nPos += 2;
//
byte[] byToken = hexStringToByteArray(device_token.toUpperCase());
System.arraycopy(byToken, 0, byPacket, nPos, 32);
nPos += 32;
//
String payload = "{\"aps\":{\"alert\":\"" + message + "\",\"badge\":1,\"sound\":\"default\"}}";
byte[] byData = null;
try {
byData = payload.getBytes("UTF-8");
} catch ( Exception e ) {
e.printStackTrace();
}
//
short payload_length = (short)byData.length;
byte[] byPayloadLength = GetShortBytes(payload_length);
System.arraycopy(byPayloadLength, 0, byPacket, nPos, 2);
nPos += 2;
//
System.arraycopy(byData, 0, byPacket, nPos, payload_length);
nPos += payload_length;
//
int active_length = (token_length + payload_length + 13);
nPacketLength = active_length;
//
//String strDebug = String.format("packet_ex length: %d", nPacketLength);
//UserLog.Log(tag, strDebug);
}
public byte[] getPacket()
{
byte[] byResult = new byte[nPacketLength];
//Array.Copy(byPacket, byResult, nPacketLength);
System.arraycopy(byPacket, 0, byResult, 0, nPacketLength);
return byResult;
}
}
| 12,699 | 0.551257 | 0.534946 | 398 | 30.886934 | 24.404152 | 133 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.788945 | false | false |
0
|
7d365d90b75f16988cc0cd110c481c76be7e10e1
| 18,631,568,162,053 |
40310768c53feeed1d9362e31f63a59105a3ee95
|
/Project SI_Klinik/SI_Klinik_API/src/database/entity/Pasien.java
|
06a50dd877c55acf081b9dbf5ea9bb8680253eb5
|
[] |
no_license
|
AirlanggaHealthCareIS/Si-Klinik
|
https://github.com/AirlanggaHealthCareIS/Si-Klinik
|
ba9cc3957a25804c806fa76ab555690931ac34d2
|
3daba498f1db9691718524b8e8b7fd209605e6a7
|
refs/heads/master
| 2016-09-09T22:34:01.194000 | 2015-06-10T10:26:12 | 2015-06-10T10:26:12 | 33,188,038 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package database.entity;
import java.io.Serializable;
import java.util.ArrayList;
public class Pasien implements Serializable{
private String Id_Pasien;
private String Nama_Pasien;
private String Alamat;
private String Jenis_Kelamin;
private String Tempat_Lahir;
private String Tanggal_Lahir;
private String Nomor_Telepon;
private String Umur;
private String Agama;
private String Pekerjaan;
private String Nomor_BPJS_Pasien;
private String Golongan_Darah;
private String suku;
private String status;
public String getId_Pasien() {
return Id_Pasien;
}
public void setId_Pasien(String Id_Pasien) {
this.Id_Pasien = Id_Pasien;
}
public String getNama_Pasien() {
return Nama_Pasien;
}
public void setNama_Pasien(String Nama_Pasien) {
this.Nama_Pasien = Nama_Pasien;
}
public String getAlamat() {
return Alamat;
}
public void setAlamat(String Alamat) {
this.Alamat = Alamat;
}
public String getJenis_Kelamin() {
return Jenis_Kelamin;
}
public void setJenis_Kelamin(String Jenis_Kelamin) {
this.Jenis_Kelamin = Jenis_Kelamin;
}
public String getTempat_Lahir() {
return Tempat_Lahir;
}
public void setTempat_Lahir(String Tempat_Lahir) {
this.Tempat_Lahir = Tempat_Lahir;
}
public String getTanggal_Lahir() {
return Tanggal_Lahir;
}
public void setTanggal_Lahir(String Tanggal_Lahir) {
this.Tanggal_Lahir = Tanggal_Lahir;
}
public String getNomor_Telepon () {
return Nomor_Telepon;
}
public void setNomor_Telepon ( String Nomor_Telepon) {
this.Nomor_Telepon = Nomor_Telepon;
}
public String getUmur () {
return Umur;
}
public void setUmur ( String Umur) {
this.Umur = Umur;
}
public String getAgama () {
return Agama;
}
public void setAgama ( String Agama) {
this.Agama = Agama;
}
public String getPekerjaan () {
return Pekerjaan;
}
public void setPekerjaan ( String Pekerjaan) {
this.Pekerjaan = Pekerjaan;
}
public String getNomor_BPJS_Pasien () {
return Nomor_BPJS_Pasien;
}
public void setNomor_BPJS_Pasien ( String Nomor_BPJS_Pasien) {
this.Nomor_BPJS_Pasien = Nomor_BPJS_Pasien;
}
public String getGolongan_Darah () {
return Golongan_Darah;
}
public void setGolongan_Darah ( String Golongan_Darah) {
this.Golongan_Darah = Golongan_Darah;
}
public String getSuku () {
return suku;
}
public void setSuku ( String Suku) {
this.suku = Suku;
}
public String getStatus () {
return status;
}
public void setStatus ( String Status) {
this.status = Status;
}
}
|
UTF-8
|
Java
| 3,217 |
java
|
Pasien.java
|
Java
|
[] | null |
[] |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package database.entity;
import java.io.Serializable;
import java.util.ArrayList;
public class Pasien implements Serializable{
private String Id_Pasien;
private String Nama_Pasien;
private String Alamat;
private String Jenis_Kelamin;
private String Tempat_Lahir;
private String Tanggal_Lahir;
private String Nomor_Telepon;
private String Umur;
private String Agama;
private String Pekerjaan;
private String Nomor_BPJS_Pasien;
private String Golongan_Darah;
private String suku;
private String status;
public String getId_Pasien() {
return Id_Pasien;
}
public void setId_Pasien(String Id_Pasien) {
this.Id_Pasien = Id_Pasien;
}
public String getNama_Pasien() {
return Nama_Pasien;
}
public void setNama_Pasien(String Nama_Pasien) {
this.Nama_Pasien = Nama_Pasien;
}
public String getAlamat() {
return Alamat;
}
public void setAlamat(String Alamat) {
this.Alamat = Alamat;
}
public String getJenis_Kelamin() {
return Jenis_Kelamin;
}
public void setJenis_Kelamin(String Jenis_Kelamin) {
this.Jenis_Kelamin = Jenis_Kelamin;
}
public String getTempat_Lahir() {
return Tempat_Lahir;
}
public void setTempat_Lahir(String Tempat_Lahir) {
this.Tempat_Lahir = Tempat_Lahir;
}
public String getTanggal_Lahir() {
return Tanggal_Lahir;
}
public void setTanggal_Lahir(String Tanggal_Lahir) {
this.Tanggal_Lahir = Tanggal_Lahir;
}
public String getNomor_Telepon () {
return Nomor_Telepon;
}
public void setNomor_Telepon ( String Nomor_Telepon) {
this.Nomor_Telepon = Nomor_Telepon;
}
public String getUmur () {
return Umur;
}
public void setUmur ( String Umur) {
this.Umur = Umur;
}
public String getAgama () {
return Agama;
}
public void setAgama ( String Agama) {
this.Agama = Agama;
}
public String getPekerjaan () {
return Pekerjaan;
}
public void setPekerjaan ( String Pekerjaan) {
this.Pekerjaan = Pekerjaan;
}
public String getNomor_BPJS_Pasien () {
return Nomor_BPJS_Pasien;
}
public void setNomor_BPJS_Pasien ( String Nomor_BPJS_Pasien) {
this.Nomor_BPJS_Pasien = Nomor_BPJS_Pasien;
}
public String getGolongan_Darah () {
return Golongan_Darah;
}
public void setGolongan_Darah ( String Golongan_Darah) {
this.Golongan_Darah = Golongan_Darah;
}
public String getSuku () {
return suku;
}
public void setSuku ( String Suku) {
this.suku = Suku;
}
public String getStatus () {
return status;
}
public void setStatus ( String Status) {
this.status = Status;
}
}
| 3,217 | 0.579111 | 0.579111 | 141 | 20.829786 | 17.700005 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false |
0
|
f81540fa818f063ac23f05bc7e3e21500e0eb67f
| 7,619,272,049,089 |
0aad8cf59fe1a68ad6249cabda74bd5d1f9fcc8c
|
/src/main/java/com/springAnno/TestApp.java
|
fcb56d369a0fd5efcf46645121ce3f95561251dd
|
[] |
no_license
|
ktyagi/java-spring
|
https://github.com/ktyagi/java-spring
|
a7fc02713c7774b05e6372ad4920206ca3629fad
|
d10bce3e1b25c8c10da17c241c30da11dcf23f72
|
refs/heads/master
| 2020-05-20T20:20:09.588000 | 2017-04-10T23:20:19 | 2017-04-10T23:20:19 | 84,519,066 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.springAnno;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
* Created by Kuldeep.Kumar on 22/03/2017.
*/
/*public class TestApp {
public static void main (String[] arg) {
AnnotationConfigApplicationContext ctx =new AnnotationConfigApplicationContext(Config.class);
Knight knight = ctx.getBean("getKnight", Knight.class);
knight.embarkOnQuest();
//No use just for example
Quest q =ctx.getBean("getPrincessQuest", Quest.class);
ctx.close();
}
}*/
public class TestApp {
public static void main (String[] arg) {
AnnotationConfigApplicationContext ctx =new AnnotationConfigApplicationContext(Config.class);
Knight knight = ctx.getBean( Knight.class);
knight.embarkOnQuest();
ctx.close();
}
}
|
UTF-8
|
Java
| 865 |
java
|
TestApp.java
|
Java
|
[
{
"context": "ionConfigApplicationContext;\r\n\r\n/**\r\n * Created by Kuldeep.Kumar on 22/03/2017.\r\n */\r\n/*public class TestApp {\r\n ",
"end": 142,
"score": 0.9998598098754883,
"start": 129,
"tag": "NAME",
"value": "Kuldeep.Kumar"
}
] | null |
[] |
package com.springAnno;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
* Created by Kuldeep.Kumar on 22/03/2017.
*/
/*public class TestApp {
public static void main (String[] arg) {
AnnotationConfigApplicationContext ctx =new AnnotationConfigApplicationContext(Config.class);
Knight knight = ctx.getBean("getKnight", Knight.class);
knight.embarkOnQuest();
//No use just for example
Quest q =ctx.getBean("getPrincessQuest", Quest.class);
ctx.close();
}
}*/
public class TestApp {
public static void main (String[] arg) {
AnnotationConfigApplicationContext ctx =new AnnotationConfigApplicationContext(Config.class);
Knight knight = ctx.getBean( Knight.class);
knight.embarkOnQuest();
ctx.close();
}
}
| 865 | 0.67052 | 0.661272 | 25 | 32.52 | 29.699993 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.52 | false | false |
0
|
3c5a70f7cd8f8bf68500f17a211e5ba981f76f88
| 14,912,126,459,306 |
e5e33953ee80aed300fd2bbb4b84cf535da6c754
|
/SenlaTasks/src/com/company/Task5.java
|
8fe2717a3b60b4cc004acaeae73eeb69e4400d00
|
[] |
no_license
|
gitikx/Payments
|
https://github.com/gitikx/Payments
|
fa64106d5463aee47f46fc9b7e05c479dc6e17ed
|
8f7bdfbc960ed4fffeb3c6960e4d278ca80eed88
|
refs/heads/master
| 2018-07-03T16:02:41.690000 | 2018-05-31T18:30:44 | 2018-05-31T18:30:44 | 121,349,934 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.company;
import java.util.Scanner;
public class Task5 {
public static void run () {
try {
System.out.println("Task 5\nEnter your text:");
String text = new Scanner(System.in).nextLine().toLowerCase();
System.out.println("Enter the word you want to find:");
String word = new Scanner(System.in).next().toLowerCase();
String[] words = text.split("[\\s|,|.|:|;|!|?|-]+");
System.out.println("Number of words: " + words.length);
System.out.println("Count: " + find(words, word));
}
catch (Exception ex){
System.out.println("Wrong input.");
}
}
public static int find(String[] words, String wordFind) {
int i = 0;
for (String word : words){
if(word.equalsIgnoreCase(wordFind)) i = i+1;
}
return i;
}
}
|
UTF-8
|
Java
| 929 |
java
|
Task5.java
|
Java
|
[] | null |
[] |
package com.company;
import java.util.Scanner;
public class Task5 {
public static void run () {
try {
System.out.println("Task 5\nEnter your text:");
String text = new Scanner(System.in).nextLine().toLowerCase();
System.out.println("Enter the word you want to find:");
String word = new Scanner(System.in).next().toLowerCase();
String[] words = text.split("[\\s|,|.|:|;|!|?|-]+");
System.out.println("Number of words: " + words.length);
System.out.println("Count: " + find(words, word));
}
catch (Exception ex){
System.out.println("Wrong input.");
}
}
public static int find(String[] words, String wordFind) {
int i = 0;
for (String word : words){
if(word.equalsIgnoreCase(wordFind)) i = i+1;
}
return i;
}
}
| 929 | 0.523143 | 0.518837 | 28 | 31.178572 | 25.455919 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.857143 | false | false |
3
|
9888194dd51d8ef9140ac4141f98c6aba3373395
| 24,206,435,748,342 |
c4623aa95fb8cdd0ee1bc68962711c33af44604e
|
/src/com/adjust/sdk/a.java
|
4d0c14cd50f6e0d3cec6e5dc8d564ae947e47699
|
[] |
no_license
|
reverseengineeringer/com.yelp.android
|
https://github.com/reverseengineeringer/com.yelp.android
|
48f7f2c830a3a1714112649a6a0a3110f7bdc2b1
|
b0ac8d4f6cd5fc5543f0d8de399b6d7b3a2184c8
|
refs/heads/master
| 2021-01-19T02:07:25.997000 | 2016-07-19T16:37:24 | 2016-07-19T16:37:24 | 38,555,675 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.adjust.sdk;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.preference.PreferenceManager;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class a
extends HandlerThread
{
private static long a;
private static long b;
private static long c;
private static ScheduledExecutorService i;
private d d;
private g e;
private j f;
private ActivityState g;
private Logger h;
private Context j;
private String k;
private String l;
private boolean m;
private boolean n;
private boolean o;
private String p;
private String q;
private String r;
private String s;
private String t;
private String u;
private String v;
public a(Activity paramActivity)
{
super("Adjust", 1);
a(paramActivity);
paramActivity = Message.obtain();
arg1 = 72630;
d.sendMessage(paramActivity);
}
private void a(long paramLong)
{
if (!a(g)) {}
long l1;
do
{
return;
l1 = paramLong - g.lastActivity;
if (l1 < 0L)
{
h.f("Time travel!");
g.lastActivity = paramLong;
return;
}
} while (l1 > b);
ActivityState localActivityState = g;
sessionLength += l1;
localActivityState = g;
timeSpent = (l1 + timeSpent);
g.lastActivity = paramLong;
}
private void a(Activity paramActivity)
{
setDaemon(true);
start();
a = f.b();
b = f.c();
c = f.d();
d = new d(getLooper(), this);
j = paramActivity.getApplicationContext();
v = "android3.3.5";
o = true;
h = f.a();
}
private void a(Uri paramUri)
{
if (paramUri == null) {}
int i1;
do
{
do
{
return;
localObject1 = paramUri.getQuery();
} while (localObject1 == null);
paramUri = new HashMap();
localObject1 = ((String)localObject1).split("&");
int i2 = localObject1.length;
i1 = 0;
if (i1 < i2) {
break;
}
} while (paramUri.size() == 0);
Object localObject1 = new k(j);
((k)localObject1).b(paramUri);
e((k)localObject1);
localObject1 = ((k)localObject1).f();
e.a((ActivityPackage)localObject1);
e.a();
h.c(String.format("Reattribution %s", new Object[] { paramUri.toString() }));
return;
Object localObject2 = localObject1[i1].split("=");
if (localObject2.length != 2) {}
for (;;)
{
i1 += 1;
break;
String str = localObject2[0];
if (str.startsWith("adjust_"))
{
localObject2 = localObject2[1];
if (((String)localObject2).length() != 0)
{
str = str.substring("adjust_".length());
if (str.length() != 0) {
paramUri.put(str, localObject2);
}
}
}
}
}
private void a(k paramk)
{
if (!c(paramk)) {}
while (!g.enabled.booleanValue()) {
return;
}
long l1 = System.currentTimeMillis();
g.createdAt = l1;
ActivityState localActivityState = g;
eventCount += 1;
a(l1);
e(paramk);
g.injectEventAttributes(paramk);
paramk = paramk.d();
e.a(paramk);
if (m) {
h.d(String.format("Buffered event %s", new Object[] { paramk.getSuffix() }));
}
for (;;)
{
g();
h.c(String.format(Locale.US, "Event %d", new Object[] { Integer.valueOf(g.eventCount) }));
return;
e.a();
}
}
private void a(String paramString)
{
k = paramString;
if (k == null)
{
h.g("Missing environment");
h.a(Logger.LogLevel.ASSERT);
k = "unknown";
return;
}
if ("sandbox".equalsIgnoreCase(k))
{
h.g("SANDBOX: Adjust is running in Sandbox mode. Use this setting for testing. Don't forget to set the environment to `production` before publishing!");
return;
}
if ("production".equalsIgnoreCase(k))
{
h.g("PRODUCTION: Adjust is running in Production mode. Use this setting only for the build that you want to publish. Set the environment to `sandbox` if you want to test your app!");
h.a(Logger.LogLevel.ASSERT);
return;
}
h.g(String.format("Malformed environment '%s'", new Object[] { k }));
h.a(Logger.LogLevel.ASSERT);
k = "malformed";
}
private void a(boolean paramBoolean)
{
if (paramBoolean) {
l();
}
while (!c())
{
return;
a(k);
b(m);
}
q = "";
r = "";
s = q.b(j);
t = q.c(j);
u = q.a(j);
if (q.d(j) == null) {
h.d("Unable to get Google Play Services Advertising ID at start time");
}
e = f.a(this, j, n);
f();
}
private boolean a(Context paramContext)
{
boolean bool = true;
if (!a(paramContext, "android.permission.INTERNET"))
{
h.f("Missing permission: INTERNET");
bool = false;
}
if (!a(paramContext, "android.permission.ACCESS_WIFI_STATE")) {
h.e("Missing permission: ACCESS_WIFI_STATE");
}
return bool;
}
private static boolean a(Context paramContext, String paramString)
{
return paramContext.checkCallingOrSelfPermission(paramString) == 0;
}
private boolean a(ActivityState paramActivityState)
{
if (paramActivityState == null)
{
h.f("Missing activity state.");
return false;
}
return true;
}
private void b(k paramk)
{
if (!d(paramk)) {}
while (!g.enabled.booleanValue()) {
return;
}
long l1 = System.currentTimeMillis();
g.createdAt = l1;
ActivityState localActivityState = g;
eventCount += 1;
a(l1);
e(paramk);
g.injectEventAttributes(paramk);
paramk = paramk.e();
e.a(paramk);
if (m) {
h.d(String.format("Buffered revenue %s", new Object[] { paramk.getSuffix() }));
}
for (;;)
{
g();
h.c(String.format(Locale.US, "Event %d (revenue)", new Object[] { Integer.valueOf(g.eventCount) }));
return;
e.a();
}
}
private void b(String paramString)
{
l = paramString;
if (l != null) {
h.d(String.format("Default tracker: '%s'", new Object[] { l }));
}
}
private void b(boolean paramBoolean)
{
m = paramBoolean;
if (m) {
h.d("Event buffering is enabled");
}
}
private boolean b(Context paramContext)
{
if (paramContext == null)
{
h.f("Missing context");
return false;
}
return true;
}
private void c(boolean paramBoolean)
{
n = paramBoolean;
if (n) {
h.d("Offline activities will get dropped");
}
}
private boolean c()
{
return (c(p)) && (d(p)) && (b(j)) && (a(j));
}
private boolean c(k paramk)
{
return (c(p)) && (a(g)) && (paramk.a());
}
private boolean c(String paramString)
{
if (paramString == null)
{
h.f("Missing App Token.");
return false;
}
return true;
}
private void d()
{
if (!c(p)) {}
while ((g != null) && (!g.enabled.booleanValue())) {
return;
}
e.e();
i();
long l1 = System.currentTimeMillis();
if (g == null)
{
g = new ActivityState();
g.sessionCount = 1;
g.createdAt = l1;
h();
g.resetSessionAttributes(l1);
g.enabled = Boolean.valueOf(o);
g();
h.d("First session");
return;
}
long l2 = l1 - g.lastActivity;
if (l2 < 0L)
{
h.f("Time travel!");
g.lastActivity = l1;
g();
return;
}
if (l2 > b)
{
localActivityState = g;
sessionCount += 1;
g.createdAt = l1;
g.lastInterval = l2;
h();
g.resetSessionAttributes(l1);
g();
h.c(String.format(Locale.US, "Session %d", new Object[] { Integer.valueOf(g.sessionCount) }));
return;
}
if (l2 > c)
{
localActivityState = g;
subsessionCount += 1;
h.d(String.format(Locale.US, "Started subsession %d of session %d", new Object[] { Integer.valueOf(g.subsessionCount), Integer.valueOf(g.sessionCount) }));
}
ActivityState localActivityState = g;
sessionLength = (l2 + sessionLength);
g.lastActivity = l1;
g();
}
private boolean d(k paramk)
{
return (c(p)) && (a(g)) && (paramk.b());
}
private boolean d(String paramString)
{
if (12 != paramString.length())
{
h.f(String.format("Malformed App Token '%s'", new Object[] { paramString }));
return false;
}
return true;
}
private void e()
{
if (!c(p)) {
return;
}
e.d();
j();
a(System.currentTimeMillis());
g();
}
private void e(k paramk)
{
paramk.a(p);
paramk.c(r);
paramk.b(q);
paramk.d(s);
paramk.f(t);
paramk.g(u);
paramk.h(v);
paramk.i(k);
paramk.j(l);
}
/* Error */
private void f()
{
// Byte code:
// 0: new 487 java/io/ObjectInputStream
// 3: dup
// 4: new 489 java/io/BufferedInputStream
// 7: dup
// 8: aload_0
// 9: getfield 129 com/adjust/sdk/a:j Landroid/content/Context;
// 12: ldc_w 491
// 15: invokevirtual 495 android/content/Context:openFileInput (Ljava/lang/String;)Ljava/io/FileInputStream;
// 18: invokespecial 498 java/io/BufferedInputStream:<init> (Ljava/io/InputStream;)V
// 21: invokespecial 499 java/io/ObjectInputStream:<init> (Ljava/io/InputStream;)V
// 24: astore_1
// 25: aload_0
// 26: aload_1
// 27: invokevirtual 503 java/io/ObjectInputStream:readObject ()Ljava/lang/Object;
// 30: checkcast 73 com/adjust/sdk/ActivityState
// 33: putfield 68 com/adjust/sdk/a:g Lcom/adjust/sdk/ActivityState;
// 36: aload_0
// 37: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 40: ldc_w 505
// 43: iconst_2
// 44: anewarray 190 java/lang/Object
// 47: dup
// 48: iconst_0
// 49: aload_0
// 50: getfield 68 com/adjust/sdk/a:g Lcom/adjust/sdk/ActivityState;
// 53: aastore
// 54: dup
// 55: iconst_1
// 56: aload_0
// 57: getfield 68 com/adjust/sdk/a:g Lcom/adjust/sdk/ActivityState;
// 60: getfield 508 com/adjust/sdk/ActivityState:uuid Ljava/lang/String;
// 63: aastore
// 64: invokestatic 197 java/lang/String:format (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
// 67: invokeinterface 199 2 0
// 72: aload_1
// 73: invokevirtual 511 java/io/ObjectInputStream:close ()V
// 76: return
// 77: astore_2
// 78: aload_0
// 79: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 82: ldc_w 513
// 85: invokeinterface 85 2 0
// 90: aload_1
// 91: invokevirtual 511 java/io/ObjectInputStream:close ()V
// 94: aload_0
// 95: aconst_null
// 96: putfield 68 com/adjust/sdk/a:g Lcom/adjust/sdk/ActivityState;
// 99: return
// 100: astore_2
// 101: aload_1
// 102: invokevirtual 511 java/io/ObjectInputStream:close ()V
// 105: goto -11 -> 94
// 108: astore_1
// 109: aload_0
// 110: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 113: ldc_w 515
// 116: invokeinterface 516 2 0
// 121: goto -27 -> 94
// 124: astore_2
// 125: aload_0
// 126: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 129: ldc_w 518
// 132: invokeinterface 85 2 0
// 137: aload_1
// 138: invokevirtual 511 java/io/ObjectInputStream:close ()V
// 141: goto -47 -> 94
// 144: astore_1
// 145: aload_0
// 146: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 149: ldc_w 520
// 152: iconst_1
// 153: anewarray 190 java/lang/Object
// 156: dup
// 157: iconst_0
// 158: aload_1
// 159: aastore
// 160: invokestatic 197 java/lang/String:format (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
// 163: invokeinterface 85 2 0
// 168: goto -74 -> 94
// 171: astore_2
// 172: aload_0
// 173: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 176: ldc_w 522
// 179: invokeinterface 85 2 0
// 184: aload_1
// 185: invokevirtual 511 java/io/ObjectInputStream:close ()V
// 188: goto -94 -> 94
// 191: astore_2
// 192: aload_1
// 193: invokevirtual 511 java/io/ObjectInputStream:close ()V
// 196: aload_2
// 197: athrow
// Local variable table:
// start length slot name signature
// 0 198 0 this a
// 24 78 1 localObjectInputStream java.io.ObjectInputStream
// 108 30 1 localFileNotFoundException java.io.FileNotFoundException
// 144 49 1 localException Exception
// 77 1 2 localClassNotFoundException ClassNotFoundException
// 100 1 2 localOptionalDataException java.io.OptionalDataException
// 124 1 2 localIOException java.io.IOException
// 171 1 2 localClassCastException ClassCastException
// 191 6 2 localObject Object
// Exception table:
// from to target type
// 25 72 77 java/lang/ClassNotFoundException
// 25 72 100 java/io/OptionalDataException
// 0 25 108 java/io/FileNotFoundException
// 72 76 108 java/io/FileNotFoundException
// 90 94 108 java/io/FileNotFoundException
// 101 105 108 java/io/FileNotFoundException
// 137 141 108 java/io/FileNotFoundException
// 184 188 108 java/io/FileNotFoundException
// 192 198 108 java/io/FileNotFoundException
// 25 72 124 java/io/IOException
// 0 25 144 java/lang/Exception
// 72 76 144 java/lang/Exception
// 90 94 144 java/lang/Exception
// 101 105 144 java/lang/Exception
// 137 141 144 java/lang/Exception
// 184 188 144 java/lang/Exception
// 192 198 144 java/lang/Exception
// 25 72 171 java/lang/ClassCastException
// 25 72 191 finally
// 78 90 191 finally
// 125 137 191 finally
// 172 184 191 finally
}
private void f(k paramk)
{
try
{
paramk.k(PreferenceManager.getDefaultSharedPreferences(j).getString("AdjustInstallReferrer", null));
return;
}
catch (Exception paramk)
{
h.f(String.format("Failed to inject referrer (%s)", new Object[] { paramk }));
}
}
/* Error */
private void g()
{
// Byte code:
// 0: new 544 java/io/ObjectOutputStream
// 3: dup
// 4: new 546 java/io/BufferedOutputStream
// 7: dup
// 8: aload_0
// 9: getfield 129 com/adjust/sdk/a:j Landroid/content/Context;
// 12: ldc_w 491
// 15: iconst_0
// 16: invokevirtual 550 android/content/Context:openFileOutput (Ljava/lang/String;I)Ljava/io/FileOutputStream;
// 19: invokespecial 553 java/io/BufferedOutputStream:<init> (Ljava/io/OutputStream;)V
// 22: invokespecial 554 java/io/ObjectOutputStream:<init> (Ljava/io/OutputStream;)V
// 25: astore_1
// 26: aload_1
// 27: aload_0
// 28: getfield 68 com/adjust/sdk/a:g Lcom/adjust/sdk/ActivityState;
// 31: invokevirtual 558 java/io/ObjectOutputStream:writeObject (Ljava/lang/Object;)V
// 34: aload_0
// 35: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 38: ldc_w 560
// 41: iconst_1
// 42: anewarray 190 java/lang/Object
// 45: dup
// 46: iconst_0
// 47: aload_0
// 48: getfield 68 com/adjust/sdk/a:g Lcom/adjust/sdk/ActivityState;
// 51: aastore
// 52: invokestatic 197 java/lang/String:format (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
// 55: invokeinterface 199 2 0
// 60: aload_1
// 61: invokevirtual 561 java/io/ObjectOutputStream:close ()V
// 64: return
// 65: astore_2
// 66: aload_0
// 67: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 70: ldc_w 563
// 73: invokeinterface 85 2 0
// 78: aload_1
// 79: invokevirtual 561 java/io/ObjectOutputStream:close ()V
// 82: return
// 83: astore_1
// 84: aload_0
// 85: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 88: ldc_w 565
// 91: iconst_1
// 92: anewarray 190 java/lang/Object
// 95: dup
// 96: iconst_0
// 97: aload_1
// 98: aastore
// 99: invokestatic 197 java/lang/String:format (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
// 102: invokeinterface 85 2 0
// 107: return
// 108: astore_2
// 109: aload_1
// 110: invokevirtual 561 java/io/ObjectOutputStream:close ()V
// 113: aload_2
// 114: athrow
// Local variable table:
// start length slot name signature
// 0 115 0 this a
// 25 54 1 localObjectOutputStream java.io.ObjectOutputStream
// 83 27 1 localException Exception
// 65 1 2 localNotSerializableException java.io.NotSerializableException
// 108 6 2 localObject Object
// Exception table:
// from to target type
// 26 60 65 java/io/NotSerializableException
// 0 26 83 java/lang/Exception
// 60 64 83 java/lang/Exception
// 78 82 83 java/lang/Exception
// 109 115 83 java/lang/Exception
// 26 60 108 finally
// 66 78 108 finally
}
private void h()
{
Object localObject = new k(j);
e((k)localObject);
f((k)localObject);
g.injectSessionAttributes((k)localObject);
localObject = ((k)localObject).c();
e.a((ActivityPackage)localObject);
e.a();
}
private void i()
{
if (i != null) {
j();
}
i = Executors.newSingleThreadScheduledExecutor();
i.scheduleWithFixedDelay(new c(this), 1000L, a, TimeUnit.MILLISECONDS);
}
private void j()
{
try
{
i.shutdown();
return;
}
catch (NullPointerException localNullPointerException)
{
h.f("No timer found");
}
}
private void k()
{
if ((g != null) && (!g.enabled.booleanValue())) {
return;
}
e.a();
a(System.currentTimeMillis());
g();
}
private void l()
{
Bundle localBundle = m();
if (localBundle == null) {
return;
}
p = localBundle.getString("AdjustAppToken");
a(localBundle.getString("AdjustEnvironment"));
b(localBundle.getString("AdjustDefaultTracker"));
b(localBundle.getBoolean("AdjustEventBuffering"));
h.a(localBundle.getString("AdjustLogLevel"));
c(localBundle.getBoolean("AdjustDropOfflineActivities"));
}
private Bundle m()
{
try
{
Object localObject = j.getPackageName();
localObject = j.getPackageManager().getApplicationInfo((String)localObject, 128).metaData;
return (Bundle)localObject;
}
catch (PackageManager.NameNotFoundException localNameNotFoundException)
{
h.f("ApplicationInfo not found");
return null;
}
catch (Exception localException)
{
for (;;)
{
h.f(String.format("Failed to get ApplicationBundle (%s)", new Object[] { localException }));
}
}
}
public void a()
{
Message localMessage = Message.obtain();
arg1 = 72640;
d.sendMessage(localMessage);
}
public void a(p paramp)
{
if (f == null) {
return;
}
new Handler(j.getMainLooper()).post(new b(this, paramp));
}
public void a(String paramString, Map<String, String> paramMap)
{
k localk = new k(j);
localk.l(paramString);
localk.a(paramMap);
paramString = Message.obtain();
arg1 = 72660;
obj = localk;
d.sendMessage(paramString);
}
public void b()
{
Message localMessage = Message.obtain();
arg1 = 72650;
d.sendMessage(localMessage);
}
}
/* Location:
* Qualified Name: com.adjust.sdk.a
* Java Class Version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
|
UTF-8
|
Java
| 20,274 |
java
|
a.java
|
Java
|
[] | null |
[] |
package com.adjust.sdk;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.preference.PreferenceManager;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class a
extends HandlerThread
{
private static long a;
private static long b;
private static long c;
private static ScheduledExecutorService i;
private d d;
private g e;
private j f;
private ActivityState g;
private Logger h;
private Context j;
private String k;
private String l;
private boolean m;
private boolean n;
private boolean o;
private String p;
private String q;
private String r;
private String s;
private String t;
private String u;
private String v;
public a(Activity paramActivity)
{
super("Adjust", 1);
a(paramActivity);
paramActivity = Message.obtain();
arg1 = 72630;
d.sendMessage(paramActivity);
}
private void a(long paramLong)
{
if (!a(g)) {}
long l1;
do
{
return;
l1 = paramLong - g.lastActivity;
if (l1 < 0L)
{
h.f("Time travel!");
g.lastActivity = paramLong;
return;
}
} while (l1 > b);
ActivityState localActivityState = g;
sessionLength += l1;
localActivityState = g;
timeSpent = (l1 + timeSpent);
g.lastActivity = paramLong;
}
private void a(Activity paramActivity)
{
setDaemon(true);
start();
a = f.b();
b = f.c();
c = f.d();
d = new d(getLooper(), this);
j = paramActivity.getApplicationContext();
v = "android3.3.5";
o = true;
h = f.a();
}
private void a(Uri paramUri)
{
if (paramUri == null) {}
int i1;
do
{
do
{
return;
localObject1 = paramUri.getQuery();
} while (localObject1 == null);
paramUri = new HashMap();
localObject1 = ((String)localObject1).split("&");
int i2 = localObject1.length;
i1 = 0;
if (i1 < i2) {
break;
}
} while (paramUri.size() == 0);
Object localObject1 = new k(j);
((k)localObject1).b(paramUri);
e((k)localObject1);
localObject1 = ((k)localObject1).f();
e.a((ActivityPackage)localObject1);
e.a();
h.c(String.format("Reattribution %s", new Object[] { paramUri.toString() }));
return;
Object localObject2 = localObject1[i1].split("=");
if (localObject2.length != 2) {}
for (;;)
{
i1 += 1;
break;
String str = localObject2[0];
if (str.startsWith("adjust_"))
{
localObject2 = localObject2[1];
if (((String)localObject2).length() != 0)
{
str = str.substring("adjust_".length());
if (str.length() != 0) {
paramUri.put(str, localObject2);
}
}
}
}
}
private void a(k paramk)
{
if (!c(paramk)) {}
while (!g.enabled.booleanValue()) {
return;
}
long l1 = System.currentTimeMillis();
g.createdAt = l1;
ActivityState localActivityState = g;
eventCount += 1;
a(l1);
e(paramk);
g.injectEventAttributes(paramk);
paramk = paramk.d();
e.a(paramk);
if (m) {
h.d(String.format("Buffered event %s", new Object[] { paramk.getSuffix() }));
}
for (;;)
{
g();
h.c(String.format(Locale.US, "Event %d", new Object[] { Integer.valueOf(g.eventCount) }));
return;
e.a();
}
}
private void a(String paramString)
{
k = paramString;
if (k == null)
{
h.g("Missing environment");
h.a(Logger.LogLevel.ASSERT);
k = "unknown";
return;
}
if ("sandbox".equalsIgnoreCase(k))
{
h.g("SANDBOX: Adjust is running in Sandbox mode. Use this setting for testing. Don't forget to set the environment to `production` before publishing!");
return;
}
if ("production".equalsIgnoreCase(k))
{
h.g("PRODUCTION: Adjust is running in Production mode. Use this setting only for the build that you want to publish. Set the environment to `sandbox` if you want to test your app!");
h.a(Logger.LogLevel.ASSERT);
return;
}
h.g(String.format("Malformed environment '%s'", new Object[] { k }));
h.a(Logger.LogLevel.ASSERT);
k = "malformed";
}
private void a(boolean paramBoolean)
{
if (paramBoolean) {
l();
}
while (!c())
{
return;
a(k);
b(m);
}
q = "";
r = "";
s = q.b(j);
t = q.c(j);
u = q.a(j);
if (q.d(j) == null) {
h.d("Unable to get Google Play Services Advertising ID at start time");
}
e = f.a(this, j, n);
f();
}
private boolean a(Context paramContext)
{
boolean bool = true;
if (!a(paramContext, "android.permission.INTERNET"))
{
h.f("Missing permission: INTERNET");
bool = false;
}
if (!a(paramContext, "android.permission.ACCESS_WIFI_STATE")) {
h.e("Missing permission: ACCESS_WIFI_STATE");
}
return bool;
}
private static boolean a(Context paramContext, String paramString)
{
return paramContext.checkCallingOrSelfPermission(paramString) == 0;
}
private boolean a(ActivityState paramActivityState)
{
if (paramActivityState == null)
{
h.f("Missing activity state.");
return false;
}
return true;
}
private void b(k paramk)
{
if (!d(paramk)) {}
while (!g.enabled.booleanValue()) {
return;
}
long l1 = System.currentTimeMillis();
g.createdAt = l1;
ActivityState localActivityState = g;
eventCount += 1;
a(l1);
e(paramk);
g.injectEventAttributes(paramk);
paramk = paramk.e();
e.a(paramk);
if (m) {
h.d(String.format("Buffered revenue %s", new Object[] { paramk.getSuffix() }));
}
for (;;)
{
g();
h.c(String.format(Locale.US, "Event %d (revenue)", new Object[] { Integer.valueOf(g.eventCount) }));
return;
e.a();
}
}
private void b(String paramString)
{
l = paramString;
if (l != null) {
h.d(String.format("Default tracker: '%s'", new Object[] { l }));
}
}
private void b(boolean paramBoolean)
{
m = paramBoolean;
if (m) {
h.d("Event buffering is enabled");
}
}
private boolean b(Context paramContext)
{
if (paramContext == null)
{
h.f("Missing context");
return false;
}
return true;
}
private void c(boolean paramBoolean)
{
n = paramBoolean;
if (n) {
h.d("Offline activities will get dropped");
}
}
private boolean c()
{
return (c(p)) && (d(p)) && (b(j)) && (a(j));
}
private boolean c(k paramk)
{
return (c(p)) && (a(g)) && (paramk.a());
}
private boolean c(String paramString)
{
if (paramString == null)
{
h.f("Missing App Token.");
return false;
}
return true;
}
private void d()
{
if (!c(p)) {}
while ((g != null) && (!g.enabled.booleanValue())) {
return;
}
e.e();
i();
long l1 = System.currentTimeMillis();
if (g == null)
{
g = new ActivityState();
g.sessionCount = 1;
g.createdAt = l1;
h();
g.resetSessionAttributes(l1);
g.enabled = Boolean.valueOf(o);
g();
h.d("First session");
return;
}
long l2 = l1 - g.lastActivity;
if (l2 < 0L)
{
h.f("Time travel!");
g.lastActivity = l1;
g();
return;
}
if (l2 > b)
{
localActivityState = g;
sessionCount += 1;
g.createdAt = l1;
g.lastInterval = l2;
h();
g.resetSessionAttributes(l1);
g();
h.c(String.format(Locale.US, "Session %d", new Object[] { Integer.valueOf(g.sessionCount) }));
return;
}
if (l2 > c)
{
localActivityState = g;
subsessionCount += 1;
h.d(String.format(Locale.US, "Started subsession %d of session %d", new Object[] { Integer.valueOf(g.subsessionCount), Integer.valueOf(g.sessionCount) }));
}
ActivityState localActivityState = g;
sessionLength = (l2 + sessionLength);
g.lastActivity = l1;
g();
}
private boolean d(k paramk)
{
return (c(p)) && (a(g)) && (paramk.b());
}
private boolean d(String paramString)
{
if (12 != paramString.length())
{
h.f(String.format("Malformed App Token '%s'", new Object[] { paramString }));
return false;
}
return true;
}
private void e()
{
if (!c(p)) {
return;
}
e.d();
j();
a(System.currentTimeMillis());
g();
}
private void e(k paramk)
{
paramk.a(p);
paramk.c(r);
paramk.b(q);
paramk.d(s);
paramk.f(t);
paramk.g(u);
paramk.h(v);
paramk.i(k);
paramk.j(l);
}
/* Error */
private void f()
{
// Byte code:
// 0: new 487 java/io/ObjectInputStream
// 3: dup
// 4: new 489 java/io/BufferedInputStream
// 7: dup
// 8: aload_0
// 9: getfield 129 com/adjust/sdk/a:j Landroid/content/Context;
// 12: ldc_w 491
// 15: invokevirtual 495 android/content/Context:openFileInput (Ljava/lang/String;)Ljava/io/FileInputStream;
// 18: invokespecial 498 java/io/BufferedInputStream:<init> (Ljava/io/InputStream;)V
// 21: invokespecial 499 java/io/ObjectInputStream:<init> (Ljava/io/InputStream;)V
// 24: astore_1
// 25: aload_0
// 26: aload_1
// 27: invokevirtual 503 java/io/ObjectInputStream:readObject ()Ljava/lang/Object;
// 30: checkcast 73 com/adjust/sdk/ActivityState
// 33: putfield 68 com/adjust/sdk/a:g Lcom/adjust/sdk/ActivityState;
// 36: aload_0
// 37: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 40: ldc_w 505
// 43: iconst_2
// 44: anewarray 190 java/lang/Object
// 47: dup
// 48: iconst_0
// 49: aload_0
// 50: getfield 68 com/adjust/sdk/a:g Lcom/adjust/sdk/ActivityState;
// 53: aastore
// 54: dup
// 55: iconst_1
// 56: aload_0
// 57: getfield 68 com/adjust/sdk/a:g Lcom/adjust/sdk/ActivityState;
// 60: getfield 508 com/adjust/sdk/ActivityState:uuid Ljava/lang/String;
// 63: aastore
// 64: invokestatic 197 java/lang/String:format (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
// 67: invokeinterface 199 2 0
// 72: aload_1
// 73: invokevirtual 511 java/io/ObjectInputStream:close ()V
// 76: return
// 77: astore_2
// 78: aload_0
// 79: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 82: ldc_w 513
// 85: invokeinterface 85 2 0
// 90: aload_1
// 91: invokevirtual 511 java/io/ObjectInputStream:close ()V
// 94: aload_0
// 95: aconst_null
// 96: putfield 68 com/adjust/sdk/a:g Lcom/adjust/sdk/ActivityState;
// 99: return
// 100: astore_2
// 101: aload_1
// 102: invokevirtual 511 java/io/ObjectInputStream:close ()V
// 105: goto -11 -> 94
// 108: astore_1
// 109: aload_0
// 110: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 113: ldc_w 515
// 116: invokeinterface 516 2 0
// 121: goto -27 -> 94
// 124: astore_2
// 125: aload_0
// 126: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 129: ldc_w 518
// 132: invokeinterface 85 2 0
// 137: aload_1
// 138: invokevirtual 511 java/io/ObjectInputStream:close ()V
// 141: goto -47 -> 94
// 144: astore_1
// 145: aload_0
// 146: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 149: ldc_w 520
// 152: iconst_1
// 153: anewarray 190 java/lang/Object
// 156: dup
// 157: iconst_0
// 158: aload_1
// 159: aastore
// 160: invokestatic 197 java/lang/String:format (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
// 163: invokeinterface 85 2 0
// 168: goto -74 -> 94
// 171: astore_2
// 172: aload_0
// 173: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 176: ldc_w 522
// 179: invokeinterface 85 2 0
// 184: aload_1
// 185: invokevirtual 511 java/io/ObjectInputStream:close ()V
// 188: goto -94 -> 94
// 191: astore_2
// 192: aload_1
// 193: invokevirtual 511 java/io/ObjectInputStream:close ()V
// 196: aload_2
// 197: athrow
// Local variable table:
// start length slot name signature
// 0 198 0 this a
// 24 78 1 localObjectInputStream java.io.ObjectInputStream
// 108 30 1 localFileNotFoundException java.io.FileNotFoundException
// 144 49 1 localException Exception
// 77 1 2 localClassNotFoundException ClassNotFoundException
// 100 1 2 localOptionalDataException java.io.OptionalDataException
// 124 1 2 localIOException java.io.IOException
// 171 1 2 localClassCastException ClassCastException
// 191 6 2 localObject Object
// Exception table:
// from to target type
// 25 72 77 java/lang/ClassNotFoundException
// 25 72 100 java/io/OptionalDataException
// 0 25 108 java/io/FileNotFoundException
// 72 76 108 java/io/FileNotFoundException
// 90 94 108 java/io/FileNotFoundException
// 101 105 108 java/io/FileNotFoundException
// 137 141 108 java/io/FileNotFoundException
// 184 188 108 java/io/FileNotFoundException
// 192 198 108 java/io/FileNotFoundException
// 25 72 124 java/io/IOException
// 0 25 144 java/lang/Exception
// 72 76 144 java/lang/Exception
// 90 94 144 java/lang/Exception
// 101 105 144 java/lang/Exception
// 137 141 144 java/lang/Exception
// 184 188 144 java/lang/Exception
// 192 198 144 java/lang/Exception
// 25 72 171 java/lang/ClassCastException
// 25 72 191 finally
// 78 90 191 finally
// 125 137 191 finally
// 172 184 191 finally
}
private void f(k paramk)
{
try
{
paramk.k(PreferenceManager.getDefaultSharedPreferences(j).getString("AdjustInstallReferrer", null));
return;
}
catch (Exception paramk)
{
h.f(String.format("Failed to inject referrer (%s)", new Object[] { paramk }));
}
}
/* Error */
private void g()
{
// Byte code:
// 0: new 544 java/io/ObjectOutputStream
// 3: dup
// 4: new 546 java/io/BufferedOutputStream
// 7: dup
// 8: aload_0
// 9: getfield 129 com/adjust/sdk/a:j Landroid/content/Context;
// 12: ldc_w 491
// 15: iconst_0
// 16: invokevirtual 550 android/content/Context:openFileOutput (Ljava/lang/String;I)Ljava/io/FileOutputStream;
// 19: invokespecial 553 java/io/BufferedOutputStream:<init> (Ljava/io/OutputStream;)V
// 22: invokespecial 554 java/io/ObjectOutputStream:<init> (Ljava/io/OutputStream;)V
// 25: astore_1
// 26: aload_1
// 27: aload_0
// 28: getfield 68 com/adjust/sdk/a:g Lcom/adjust/sdk/ActivityState;
// 31: invokevirtual 558 java/io/ObjectOutputStream:writeObject (Ljava/lang/Object;)V
// 34: aload_0
// 35: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 38: ldc_w 560
// 41: iconst_1
// 42: anewarray 190 java/lang/Object
// 45: dup
// 46: iconst_0
// 47: aload_0
// 48: getfield 68 com/adjust/sdk/a:g Lcom/adjust/sdk/ActivityState;
// 51: aastore
// 52: invokestatic 197 java/lang/String:format (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
// 55: invokeinterface 199 2 0
// 60: aload_1
// 61: invokevirtual 561 java/io/ObjectOutputStream:close ()V
// 64: return
// 65: astore_2
// 66: aload_0
// 67: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 70: ldc_w 563
// 73: invokeinterface 85 2 0
// 78: aload_1
// 79: invokevirtual 561 java/io/ObjectOutputStream:close ()V
// 82: return
// 83: astore_1
// 84: aload_0
// 85: getfield 78 com/adjust/sdk/a:h Lcom/adjust/sdk/Logger;
// 88: ldc_w 565
// 91: iconst_1
// 92: anewarray 190 java/lang/Object
// 95: dup
// 96: iconst_0
// 97: aload_1
// 98: aastore
// 99: invokestatic 197 java/lang/String:format (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
// 102: invokeinterface 85 2 0
// 107: return
// 108: astore_2
// 109: aload_1
// 110: invokevirtual 561 java/io/ObjectOutputStream:close ()V
// 113: aload_2
// 114: athrow
// Local variable table:
// start length slot name signature
// 0 115 0 this a
// 25 54 1 localObjectOutputStream java.io.ObjectOutputStream
// 83 27 1 localException Exception
// 65 1 2 localNotSerializableException java.io.NotSerializableException
// 108 6 2 localObject Object
// Exception table:
// from to target type
// 26 60 65 java/io/NotSerializableException
// 0 26 83 java/lang/Exception
// 60 64 83 java/lang/Exception
// 78 82 83 java/lang/Exception
// 109 115 83 java/lang/Exception
// 26 60 108 finally
// 66 78 108 finally
}
private void h()
{
Object localObject = new k(j);
e((k)localObject);
f((k)localObject);
g.injectSessionAttributes((k)localObject);
localObject = ((k)localObject).c();
e.a((ActivityPackage)localObject);
e.a();
}
private void i()
{
if (i != null) {
j();
}
i = Executors.newSingleThreadScheduledExecutor();
i.scheduleWithFixedDelay(new c(this), 1000L, a, TimeUnit.MILLISECONDS);
}
private void j()
{
try
{
i.shutdown();
return;
}
catch (NullPointerException localNullPointerException)
{
h.f("No timer found");
}
}
private void k()
{
if ((g != null) && (!g.enabled.booleanValue())) {
return;
}
e.a();
a(System.currentTimeMillis());
g();
}
private void l()
{
Bundle localBundle = m();
if (localBundle == null) {
return;
}
p = localBundle.getString("AdjustAppToken");
a(localBundle.getString("AdjustEnvironment"));
b(localBundle.getString("AdjustDefaultTracker"));
b(localBundle.getBoolean("AdjustEventBuffering"));
h.a(localBundle.getString("AdjustLogLevel"));
c(localBundle.getBoolean("AdjustDropOfflineActivities"));
}
private Bundle m()
{
try
{
Object localObject = j.getPackageName();
localObject = j.getPackageManager().getApplicationInfo((String)localObject, 128).metaData;
return (Bundle)localObject;
}
catch (PackageManager.NameNotFoundException localNameNotFoundException)
{
h.f("ApplicationInfo not found");
return null;
}
catch (Exception localException)
{
for (;;)
{
h.f(String.format("Failed to get ApplicationBundle (%s)", new Object[] { localException }));
}
}
}
public void a()
{
Message localMessage = Message.obtain();
arg1 = 72640;
d.sendMessage(localMessage);
}
public void a(p paramp)
{
if (f == null) {
return;
}
new Handler(j.getMainLooper()).post(new b(this, paramp));
}
public void a(String paramString, Map<String, String> paramMap)
{
k localk = new k(j);
localk.l(paramString);
localk.a(paramMap);
paramString = Message.obtain();
arg1 = 72660;
obj = localk;
d.sendMessage(paramString);
}
public void b()
{
Message localMessage = Message.obtain();
arg1 = 72650;
d.sendMessage(localMessage);
}
}
/* Location:
* Qualified Name: com.adjust.sdk.a
* Java Class Version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
| 20,274 | 0.590017 | 0.540249 | 761 | 25.642576 | 23.77956 | 188 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.784494 | false | false |
3
|
1cd0d973615b1aa4ff674dec78aeaefb2632bf26
| 24,206,435,746,058 |
42cd5ce3c9f5bb5c0f2058d3125db41437752a88
|
/gateway-service/src/main/java/com/pphh/demo/gw/controller/TestController.java
|
d1afadd7b623dea8757d5f6b3242355d3f28833d
|
[] |
no_license
|
peipeihh/sample-spring-cloud-gateway
|
https://github.com/peipeihh/sample-spring-cloud-gateway
|
16f3602a027bc884541f06ad25c03dad88514d68
|
05bfa64adbaa2c048d748d2085ba2431d8998e4d
|
refs/heads/master
| 2020-05-23T05:48:33.121000 | 2019-05-15T07:53:59 | 2019-05-15T07:53:59 | 186,655,011 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.pphh.demo.gw.controller;
import com.pphh.demo.gw.service.GwRedisCacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 网关 - 测试接口
*
* @author huangyinhuang
* @date 2019/5/6
*/
@RestController
@RequestMapping("/api/test")
public class TestController {
@Autowired
private GwRedisCacheService gwRedisCacheService;
@RequestMapping(method = RequestMethod.POST, value = "/checkNonce")
public Boolean test(@RequestParam String nonce) {
Boolean isValid = Boolean.FALSE;
try {
isValid = gwRedisCacheService.isNonceValid(nonce);
} catch (Exception ignored) {
}
return isValid;
}
}
|
UTF-8
|
Java
| 953 |
java
|
TestController.java
|
Java
|
[
{
"context": "on.RestController;\n\n/**\n * 网关 - 测试接口\n *\n * @author huangyinhuang\n * @date 2019/5/6\n */\n@RestController\n@RequestMap",
"end": 448,
"score": 0.9872773289680481,
"start": 435,
"tag": "USERNAME",
"value": "huangyinhuang"
}
] | null |
[] |
package com.pphh.demo.gw.controller;
import com.pphh.demo.gw.service.GwRedisCacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 网关 - 测试接口
*
* @author huangyinhuang
* @date 2019/5/6
*/
@RestController
@RequestMapping("/api/test")
public class TestController {
@Autowired
private GwRedisCacheService gwRedisCacheService;
@RequestMapping(method = RequestMethod.POST, value = "/checkNonce")
public Boolean test(@RequestParam String nonce) {
Boolean isValid = Boolean.FALSE;
try {
isValid = gwRedisCacheService.isNonceValid(nonce);
} catch (Exception ignored) {
}
return isValid;
}
}
| 953 | 0.737513 | 0.731137 | 33 | 27.515152 | 24.069496 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.363636 | false | false |
3
|
d4978e9ad792615a3e51e48c1481494943eee127
| 19,464,791,814,218 |
bdeecc6e521b20411fa108b4bcb80f32c7345c30
|
/src/mfiari/fireemblem/game/behaviour/character/CavalierMaleBehaviour.java
|
92fb826abe350c57fbd96a003acd5fd7d33f6644
|
[] |
no_license
|
mfiari/fireemblemgame
|
https://github.com/mfiari/fireemblemgame
|
45d3446761a35747243630f599800c85551f2b0a
|
f10fb1958204ac4f94a2df90fdad501cc734637e
|
refs/heads/master
| 2021-05-10T18:56:03.234000 | 2018-04-20T08:05:46 | 2018-04-20T08:05:46 | 118,137,627 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* 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 mfiari.fireemblem.game.behaviour.character;
import mfiari.fireemblem.game.character.CharacterType;
/**
*
* @author mike
*/
public class CavalierMaleBehaviour extends NonPromotedBehaviour {
public CavalierMaleBehaviour() {
this.name = "cavalier";
this.charactersType = CharacterType.cavalier;
this.pvBase = 20;
this.puissanceBase = 5;
this.magieBase = 0;
this.capaciteBase = 2;
this.vitesseBase = 5;
this.chanceBase = 0;
this.defBase = 6;
this.resistanceBase = 0;
this.constitutionBase = 9;
}
}
|
UTF-8
|
Java
| 792 |
java
|
CavalierMaleBehaviour.java
|
Java
|
[
{
"context": "m.game.character.CharacterType;\n\n/**\n *\n * @author mike\n */\npublic class CavalierMaleBehaviour extends No",
"end": 317,
"score": 0.9948527812957764,
"start": 313,
"tag": "USERNAME",
"value": "mike"
}
] | null |
[] |
/*
* 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 mfiari.fireemblem.game.behaviour.character;
import mfiari.fireemblem.game.character.CharacterType;
/**
*
* @author mike
*/
public class CavalierMaleBehaviour extends NonPromotedBehaviour {
public CavalierMaleBehaviour() {
this.name = "cavalier";
this.charactersType = CharacterType.cavalier;
this.pvBase = 20;
this.puissanceBase = 5;
this.magieBase = 0;
this.capaciteBase = 2;
this.vitesseBase = 5;
this.chanceBase = 0;
this.defBase = 6;
this.resistanceBase = 0;
this.constitutionBase = 9;
}
}
| 792 | 0.662879 | 0.650253 | 32 | 23.75 | 22.150057 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false |
3
|
a17f6b5a604e7768809c2c949eda5dc1bf5608a2
| 34,754,875,361,943 |
52b0106e78cede2b898cee16370a415b3f77abbd
|
/wicket-stateless-example/src/main/java/app/HomePage.java
|
1fd2df59f39ed840b5094c0d887aa89adaa9bb9c
|
[
"MIT"
] |
permissive
|
giruzou/sandbox
|
https://github.com/giruzou/sandbox
|
9d74746b40e8da7ab81fdd460815e54dc54db6d8
|
a5bcbcd1e505812e6917a78dda8163fbb50b4eba
|
refs/heads/master
| 2021-04-27T01:27:35.872000 | 2018-02-23T13:09:17 | 2018-02-23T13:09:17 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package app;
import java.util.Optional;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.StatelessForm;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
public class HomePage extends WebPage {
private final IModel<Integer> left = new Model<>();
private final IModel<Integer> right = new Model<>();
private final IModel<Integer> answer = new AbstractReadOnlyModel<Integer>() {
@Override
public Integer getObject() {
Optional<Integer> l = Optional.ofNullable(left.getObject());
Optional<Integer> r = Optional.ofNullable(right.getObject());
Optional<Integer> a = l.flatMap(x -> r.map(y -> x + y));
return a.orElse(null);
}
};
public HomePage(final PageParameters parameters) {
super(parameters);
//Form<?> form = new Form<>("form");
StatelessForm<?> form = new StatelessForm<>("form");
TextField<Integer> left = new TextField<>("left", this.left,
Integer.class);
TextField<Integer> right = new TextField<>("right", this.right,
Integer.class);
Label answer = new Label("answer", this.answer);
Button calc = new Button("calc");
form.add(left, right, answer, calc);
add(form);
}
}
|
UTF-8
|
Java
| 1,627 |
java
|
HomePage.java
|
Java
|
[] | null |
[] |
package app;
import java.util.Optional;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.StatelessForm;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
public class HomePage extends WebPage {
private final IModel<Integer> left = new Model<>();
private final IModel<Integer> right = new Model<>();
private final IModel<Integer> answer = new AbstractReadOnlyModel<Integer>() {
@Override
public Integer getObject() {
Optional<Integer> l = Optional.ofNullable(left.getObject());
Optional<Integer> r = Optional.ofNullable(right.getObject());
Optional<Integer> a = l.flatMap(x -> r.map(y -> x + y));
return a.orElse(null);
}
};
public HomePage(final PageParameters parameters) {
super(parameters);
//Form<?> form = new Form<>("form");
StatelessForm<?> form = new StatelessForm<>("form");
TextField<Integer> left = new TextField<>("left", this.left,
Integer.class);
TextField<Integer> right = new TextField<>("right", this.right,
Integer.class);
Label answer = new Label("answer", this.answer);
Button calc = new Button("calc");
form.add(left, right, answer, calc);
add(form);
}
}
| 1,627 | 0.660725 | 0.660725 | 49 | 32.204082 | 25.782433 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.714286 | false | false |
3
|
25fab0f58d406f189226a7fdc1db0f40dc963c83
| 29,918,742,236,695 |
3a75d82663fcdb45d88fff4053f8320fb649e3c1
|
/mapo-common/src/main/java/mapo/common/table/TBoxTable.java
|
72f8b9dd889929291d1e9ece8816fd5d42f04c67
|
[] |
no_license
|
jmayaalv/mapo
|
https://github.com/jmayaalv/mapo
|
db48956d27b2cc69d988c1669c115533ede03cfc
|
2d5d8af3e070f21c58fd6c5a2a07bcf3f425e17c
|
refs/heads/master
| 2020-06-04T16:18:32.335000 | 2014-03-14T15:07:46 | 2014-03-14T15:07:46 | 17,749,835 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
*
*/
package mapo.common.table;
/**
* @author jmayaalv
*
*/
public class TBoxTable implements Table {
public static final String TABLE_NAME = "tbox";
@Override
public Column[] getColumns() {
return Columns.values();
}
@Override
public Column[] getIndexes() {
return null;
}
@Override
public String getName() {
return TABLE_NAME;
}
public static enum Columns implements Column {
LHS("data:lhs"), RHS("data:rhs"), EQUIVALENT("data:equivalent");
private final String id;
/**
* @param id
* @author jmayaalv
*/
private Columns(String id) {
this.id = id;
}
/**
* @return the id
*/
public String getId() {
return id;
}
}
}
|
UTF-8
|
Java
| 694 |
java
|
TBoxTable.java
|
Java
|
[
{
"context": " \n */\npackage mapo.common.table;\n\n\n\n/**\n * @author jmayaalv\n * \n */\npublic class TBoxTable implements Table {",
"end": 65,
"score": 0.9995771646499634,
"start": 57,
"tag": "USERNAME",
"value": "jmayaalv"
},
{
"context": "inal String id;\n\n\t\t/**\n\t\t * @param id\n\t\t * @author jmayaalv\n\t\t */\n\t\tprivate Columns(String id) {\n\t\t\tthis.id =",
"end": 553,
"score": 0.9996301531791687,
"start": 545,
"tag": "USERNAME",
"value": "jmayaalv"
}
] | null |
[] |
/**
*
*/
package mapo.common.table;
/**
* @author jmayaalv
*
*/
public class TBoxTable implements Table {
public static final String TABLE_NAME = "tbox";
@Override
public Column[] getColumns() {
return Columns.values();
}
@Override
public Column[] getIndexes() {
return null;
}
@Override
public String getName() {
return TABLE_NAME;
}
public static enum Columns implements Column {
LHS("data:lhs"), RHS("data:rhs"), EQUIVALENT("data:equivalent");
private final String id;
/**
* @param id
* @author jmayaalv
*/
private Columns(String id) {
this.id = id;
}
/**
* @return the id
*/
public String getId() {
return id;
}
}
}
| 694 | 0.616715 | 0.616715 | 52 | 12.346154 | 14.963911 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.173077 | false | false |
3
|
33fcaa4cb49876e7c7c9cfb738fbb5804b2109ea
| 27,273,042,344,902 |
04c5f529cd81831f9a026d50d608d237b1b8b7aa
|
/PiDev/PiDev-ejb/src/main/java/model/Evenement.java
|
e4cea90e3dac4bb527fd938811b38bf539a6b1ef
|
[] |
no_license
|
rim2019/PiDevJee
|
https://github.com/rim2019/PiDevJee
|
72e3836413e5376f7fbbf8607fff8700b0a2fed1
|
1abdbbfff0be282d9c0f86879563b0ac6eed5efc
|
refs/heads/master
| 2020-09-28T01:51:48.716000 | 2019-12-10T00:32:51 | 2019-12-10T00:32:51 | 226,660,451 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package model;
import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
/**
* The persistent class for the evenements database table.
*
*/
@Entity
@Table(name="evenements")
@NamedQuery(name="Evenement.findAll", query="SELECT e FROM Evenement e")
public class Evenement implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int idEvenement;
//bi-directional many-to-many association to Client
@ManyToMany(mappedBy="evenements")
private List<Client> clients;
@Temporal (TemporalType.DATE)
private Date dateEvenement;
private String description;
@Enumerated(EnumType.ORDINAL)
private typeEven image;
@Enumerated(EnumType.ORDINAL)
private LocalisationEven localisation;
private int nbInteresses;
private int nbParticipants;
private int nombrePlace;
public Evenement() {
}
public Evenement(int idEvenement, Date date,String description,typeEven image, LocalisationEven localisation,
int nbInteresses, int nbParticipants,int nombrePlace) {
super();
this.idEvenement = idEvenement;
this.description = description;
this.image = image;
this.localisation = localisation;
this.nbInteresses = nbInteresses;
this.nbParticipants = nbParticipants;
this.nombrePlace=nombrePlace;
}
public Evenement( Date dateEvenement,String description, typeEven image, LocalisationEven localisation,
int nbInteresses, int nbParticipants,int nombrePlace) {
super();
this.dateEvenement =dateEvenement;
this.description = description;
this.image = image;
this.localisation = localisation;
this.nbInteresses = nbInteresses;
this.nbParticipants = nbParticipants;
this.nombrePlace=nombrePlace;
}
public Evenement( String description, typeEven image, LocalisationEven localisation,
int nbInteresses, int nbParticipants) {
super();
this.description = description;
this.image = image;
this.localisation = localisation;
this.nbInteresses = nbInteresses;
this.nbParticipants = nbParticipants;
}
public Evenement(Date dateEvenement,String description, LocalisationEven localisation, int nbInteresses, int nbParticipants) {
super();
this.dateEvenement=dateEvenement;
this.description = description;
this.localisation = localisation;
this.nbInteresses = nbInteresses;
this.nbParticipants = nbParticipants;
}
public int getIdEvenement() {
return idEvenement;
}
public void setIdEvenement(int idEvenement) {
this.idEvenement = idEvenement;
}
public Date getDateEvenement() {
return dateEvenement;
}
public void setDateEvenement(Date dateEvenement) {
this.dateEvenement = dateEvenement;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getNbInteresses() {
return nbInteresses;
}
public void setNbInteresses(int nbInteresses) {
this.nbInteresses = nbInteresses;
}
public int getNbParticipants() {
return nbParticipants;
}
public void setNbParticipants(int nbParticipants) {
this.nbParticipants = nbParticipants;
}
public int getNombrePlace() {
return nombrePlace;
}
public void setNombrePlace(int nombrePlace) {
this.nombrePlace = nombrePlace;
}
public List<Client> getClients() {
return clients;
}
public void setClients(List<Client> clients) {
this.clients = clients;
}
public typeEven getImage() {
return image;
}
public void setImage(typeEven image) {
this.image = image;
}
public LocalisationEven getLocalisation() {
return localisation;
}
public void setLocalisation(LocalisationEven localisation) {
this.localisation = localisation;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}
|
UTF-8
|
Java
| 3,802 |
java
|
Evenement.java
|
Java
|
[] | null |
[] |
package model;
import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
/**
* The persistent class for the evenements database table.
*
*/
@Entity
@Table(name="evenements")
@NamedQuery(name="Evenement.findAll", query="SELECT e FROM Evenement e")
public class Evenement implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int idEvenement;
//bi-directional many-to-many association to Client
@ManyToMany(mappedBy="evenements")
private List<Client> clients;
@Temporal (TemporalType.DATE)
private Date dateEvenement;
private String description;
@Enumerated(EnumType.ORDINAL)
private typeEven image;
@Enumerated(EnumType.ORDINAL)
private LocalisationEven localisation;
private int nbInteresses;
private int nbParticipants;
private int nombrePlace;
public Evenement() {
}
public Evenement(int idEvenement, Date date,String description,typeEven image, LocalisationEven localisation,
int nbInteresses, int nbParticipants,int nombrePlace) {
super();
this.idEvenement = idEvenement;
this.description = description;
this.image = image;
this.localisation = localisation;
this.nbInteresses = nbInteresses;
this.nbParticipants = nbParticipants;
this.nombrePlace=nombrePlace;
}
public Evenement( Date dateEvenement,String description, typeEven image, LocalisationEven localisation,
int nbInteresses, int nbParticipants,int nombrePlace) {
super();
this.dateEvenement =dateEvenement;
this.description = description;
this.image = image;
this.localisation = localisation;
this.nbInteresses = nbInteresses;
this.nbParticipants = nbParticipants;
this.nombrePlace=nombrePlace;
}
public Evenement( String description, typeEven image, LocalisationEven localisation,
int nbInteresses, int nbParticipants) {
super();
this.description = description;
this.image = image;
this.localisation = localisation;
this.nbInteresses = nbInteresses;
this.nbParticipants = nbParticipants;
}
public Evenement(Date dateEvenement,String description, LocalisationEven localisation, int nbInteresses, int nbParticipants) {
super();
this.dateEvenement=dateEvenement;
this.description = description;
this.localisation = localisation;
this.nbInteresses = nbInteresses;
this.nbParticipants = nbParticipants;
}
public int getIdEvenement() {
return idEvenement;
}
public void setIdEvenement(int idEvenement) {
this.idEvenement = idEvenement;
}
public Date getDateEvenement() {
return dateEvenement;
}
public void setDateEvenement(Date dateEvenement) {
this.dateEvenement = dateEvenement;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getNbInteresses() {
return nbInteresses;
}
public void setNbInteresses(int nbInteresses) {
this.nbInteresses = nbInteresses;
}
public int getNbParticipants() {
return nbParticipants;
}
public void setNbParticipants(int nbParticipants) {
this.nbParticipants = nbParticipants;
}
public int getNombrePlace() {
return nombrePlace;
}
public void setNombrePlace(int nombrePlace) {
this.nombrePlace = nombrePlace;
}
public List<Client> getClients() {
return clients;
}
public void setClients(List<Client> clients) {
this.clients = clients;
}
public typeEven getImage() {
return image;
}
public void setImage(typeEven image) {
this.image = image;
}
public LocalisationEven getLocalisation() {
return localisation;
}
public void setLocalisation(LocalisationEven localisation) {
this.localisation = localisation;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}
| 3,802 | 0.763809 | 0.763546 | 155 | 23.535484 | 22.408028 | 127 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.683871 | false | false |
3
|
76639392b54e3096c8f1779aaa17bf537fd6bede
| 3,470,333,635,000 |
fbcf926053bed20331dce8a4236bf73a7aec98f0
|
/spring-week3-exercise1/src/main/java/com/example/springweek3exercise1/Sauna.java
|
5e08e47f2aa4616b6066f145b06d813559d16121
|
[] |
no_license
|
tamaradanhash/Back_End_Projects
|
https://github.com/tamaradanhash/Back_End_Projects
|
c7be87cfc5eac53a95b30c1a10a3f516ac356c2c
|
40e73ca0b6a34375147aeed20936a77f16d50d97
|
refs/heads/master
| 2020-04-24T08:32:05.225000 | 2019-07-10T22:36:11 | 2019-07-10T22:36:11 | 171,833,781 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.springweek3exercise1;
import lombok.Data;
@Data
public class Sauna {
private int availableseats;
private int temerature;
}
|
UTF-8
|
Java
| 153 |
java
|
Sauna.java
|
Java
|
[] | null |
[] |
package com.example.springweek3exercise1;
import lombok.Data;
@Data
public class Sauna {
private int availableseats;
private int temerature;
}
| 153 | 0.764706 | 0.751634 | 9 | 16 | 14.3527 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false |
3
|
14d8eaabc445b7a8ebe5a2569222ba68ef34b41a
| 10,582,799,479,406 |
c94afad2f5f79c122100a9a53bf48126a01b8d40
|
/JavaGeneric/src/com/hebut/generic/wildcard/up/Test.java
|
2d7034068f080c0b2c8cfd044cbf76eefe98a735
|
[] |
no_license
|
jxy421/JavaProgram
|
https://github.com/jxy421/JavaProgram
|
1012943f6e912a22889bc2f18fa9507956e193e3
|
31293577cecb679af2393832b7121e595faf7fc0
|
refs/heads/master
| 2020-12-13T23:29:16.392000 | 2015-07-28T23:19:46 | 2015-07-28T23:19:46 | 39,456,382 | 1 | 0 | null | true | 2015-07-28T14:57:48 | 2015-07-21T16:18:19 | 2015-07-21T16:18:20 | 2015-07-28T14:57:47 | 1,419 | 0 | 0 | 0 |
Java
| null | null |
package com.hebut.generic.wildcard.up;
import java.util.ArrayList;
import java.util.List;
/**
* »Í¼²âÊÔÀà
* @author sunddenly
*/
public class Test {
public static void main(String[] args) {
Canvas cas = new Canvas();
Circle circle = new Circle();
Rectangle rect = new Rectangle();
List<Circle> circleList = new ArrayList<Circle>();
List<Rectangle> rectList = new ArrayList<Rectangle>();
circleList.add(new Circle());
rectList.add(new Rectangle());
cas.drawAll(circleList);
cas.drawAll(rectList);
List<? extends Shape> shapes = new ArrayList<Circle>();
//shapes.add(new Circle());
}
}
|
WINDOWS-1252
|
Java
| 633 |
java
|
Test.java
|
Java
|
[
{
"context": "port java.util.List;\n\n/**\n * »Í¼²âÊÔÀà\n * @author sunddenly\n */\npublic class Test {\n\tpublic static void main(",
"end": 130,
"score": 0.9995881915092468,
"start": 121,
"tag": "USERNAME",
"value": "sunddenly"
}
] | null |
[] |
package com.hebut.generic.wildcard.up;
import java.util.ArrayList;
import java.util.List;
/**
* »Í¼²âÊÔÀà
* @author sunddenly
*/
public class Test {
public static void main(String[] args) {
Canvas cas = new Canvas();
Circle circle = new Circle();
Rectangle rect = new Rectangle();
List<Circle> circleList = new ArrayList<Circle>();
List<Rectangle> rectList = new ArrayList<Rectangle>();
circleList.add(new Circle());
rectList.add(new Rectangle());
cas.drawAll(circleList);
cas.drawAll(rectList);
List<? extends Shape> shapes = new ArrayList<Circle>();
//shapes.add(new Circle());
}
}
| 633 | 0.683788 | 0.680578 | 27 | 22.074074 | 17.515974 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.62963 | false | false |
3
|
02f03896951075088726d764f55c871b036a7bd4
| 11,716,670,815,578 |
d02b49db14a8582cb455a2d2eb3f2da9f04358b0
|
/Day_21_MinNumberOfRoomsForGivenIntervals.java
|
8eb1b70947491dc106a26858932857f8ea26bf24
|
[] |
no_license
|
Datta973/DailyCodingProblem
|
https://github.com/Datta973/DailyCodingProblem
|
499ce53a672b39a2a88dd069d050137ba16b9ddc
|
3f7e87aa00d3e9565fd43e037c543c1d8bfcd520
|
refs/heads/main
| 2023-03-07T15:38:00.532000 | 2021-02-17T08:58:50 | 2021-02-17T08:58:50 | 321,621,459 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
Problem statement :
Given an array of time intervals (start, end) for classroom lectures (possibly overlapping), find the minimum number of rooms required.
For example, given [(30, 75), (0, 50), (60, 150)], you should return 2.
*/
import java.util.TreeMap;
public class Day_21_MinNumberOfRoomsForGivenIntervals{
public static void main(String[] args) {
System.out.println(solve(new int[][]{{30, 75}, {0, 50}, {60, 150}})); // outputs 2
System.out.println(solve(new int[][]{{0, 10}, {3, 11}, {5, 12}, {8, 15}, {17, 25}, {18, 24}, {19, 23}, {20, 22}, {21, 30}})); // outputs 5
}
// Time O(N*logN)
// Space O(N)
private static int solve(int[][] intervals){
TreeMap<Integer, Integer> treeMap = new TreeMap<>();
for(int[] in : intervals){
treeMap.put(in[0], treeMap.getOrDefault(in[0], 0)+1);
treeMap.put(in[1]+1, treeMap.getOrDefault(in[1]+1, 0)-1);
}
int ans = 0;
int sum = 0;
for(int key : treeMap.keySet()){
sum += treeMap.get(key);
ans = Math.max(ans, sum);
}
return ans;
}
}
|
UTF-8
|
Java
| 1,027 |
java
|
Day_21_MinNumberOfRoomsForGivenIntervals.java
|
Java
|
[] | null |
[] |
/*
Problem statement :
Given an array of time intervals (start, end) for classroom lectures (possibly overlapping), find the minimum number of rooms required.
For example, given [(30, 75), (0, 50), (60, 150)], you should return 2.
*/
import java.util.TreeMap;
public class Day_21_MinNumberOfRoomsForGivenIntervals{
public static void main(String[] args) {
System.out.println(solve(new int[][]{{30, 75}, {0, 50}, {60, 150}})); // outputs 2
System.out.println(solve(new int[][]{{0, 10}, {3, 11}, {5, 12}, {8, 15}, {17, 25}, {18, 24}, {19, 23}, {20, 22}, {21, 30}})); // outputs 5
}
// Time O(N*logN)
// Space O(N)
private static int solve(int[][] intervals){
TreeMap<Integer, Integer> treeMap = new TreeMap<>();
for(int[] in : intervals){
treeMap.put(in[0], treeMap.getOrDefault(in[0], 0)+1);
treeMap.put(in[1]+1, treeMap.getOrDefault(in[1]+1, 0)-1);
}
int ans = 0;
int sum = 0;
for(int key : treeMap.keySet()){
sum += treeMap.get(key);
ans = Math.max(ans, sum);
}
return ans;
}
}
| 1,027 | 0.623174 | 0.552094 | 38 | 26.052631 | 34.791824 | 140 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.263158 | false | false |
3
|
df17374504136d7f28c256c9e09edb1facee8a49
| 2,800,318,705,539 |
95263abd353094fe6b2acbee36cd570962b6fc01
|
/src/main/java/br/com/alfa/trabalho/service/impl/PermissaoServiceImpl.java
|
d6482ae660fe7f2710d951309d50bc579f1c83ca
|
[] |
no_license
|
FaculdadeAlfa/grupo-brunno-iagho-eduardo
|
https://github.com/FaculdadeAlfa/grupo-brunno-iagho-eduardo
|
7ce0998360c01a303caa42790b638483d4f80a5a
|
3e62fcb94b33faf602b510dce3e8f660f2c409df
|
refs/heads/master
| 2020-06-13T05:42:57.930000 | 2016-12-29T23:59:11 | 2016-12-29T23:59:11 | 75,485,909 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package br.com.alfa.trabalho.service.impl;
import br.com.alfa.trabalho.model.Permissao;
import br.com.alfa.trabalho.service.PermissaoService;
import org.springframework.stereotype.Service;
import java.io.Serializable;
import java.util.List;
@Service
public class PermissaoServiceImpl implements PermissaoService, Serializable {
private static final long serialVersionUID = 1L;
public List<Permissao> listarTodasPermissoesAtivas() {
return null;
}
public void adicionar(Permissao entity) {
}
public void atualizar(Permissao entity) {
}
public void remover(Permissao entity) {
}
}
|
UTF-8
|
Java
| 633 |
java
|
PermissaoServiceImpl.java
|
Java
|
[] | null |
[] |
package br.com.alfa.trabalho.service.impl;
import br.com.alfa.trabalho.model.Permissao;
import br.com.alfa.trabalho.service.PermissaoService;
import org.springframework.stereotype.Service;
import java.io.Serializable;
import java.util.List;
@Service
public class PermissaoServiceImpl implements PermissaoService, Serializable {
private static final long serialVersionUID = 1L;
public List<Permissao> listarTodasPermissoesAtivas() {
return null;
}
public void adicionar(Permissao entity) {
}
public void atualizar(Permissao entity) {
}
public void remover(Permissao entity) {
}
}
| 633 | 0.747235 | 0.745656 | 30 | 20.133333 | 23.233213 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3 | false | false |
3
|
e6b05d6792a4dfb5b87caef24325673571d6c85f
| 3,530,463,175,571 |
d8a5a2eff0359c8b40ae9cf736bcbb5a24d4ae62
|
/src/main/java/io/zhudy/xim/session/impl/DefaultSession.java
|
5d31a9237618eb9a0d19a922094aaf121ecf9d97
|
[
"Apache-2.0"
] |
permissive
|
fuuqiu/xim
|
https://github.com/fuuqiu/xim
|
5285666c1de8ae475b386524490dc7c67cf1a78a
|
c4391e9afb476ade242759b9e415fc4bfea95ce4
|
refs/heads/master
| 2022-11-16T12:27:58.651000 | 2020-07-20T09:07:49 | 2020-07-20T09:07:49 | 273,207,464 | 0 | 0 | null | true | 2020-06-18T10:20:57 | 2020-06-18T10:20:56 | 2020-06-18T09:39:14 | 2020-06-18T09:39:11 | 117 | 0 | 0 | 0 | null | false | false |
package io.zhudy.xim.session.impl;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.zhudy.xim.auth.AuthContext;
import io.zhudy.xim.packet.Packet;
import io.zhudy.xim.helper.PacketHelper;
import io.zhudy.xim.session.Session;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import lombok.extern.log4j.Log4j2;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.MonoProcessor;
import reactor.netty.http.websocket.WebsocketInbound;
import reactor.netty.http.websocket.WebsocketOutbound;
/**
* 默认会话实现.
*
* @author Kevin Zou (kevinz@weghst.com)
*/
@Log4j2
public final class DefaultSession implements Session {
final long sessionId;
final String uid;
final WebsocketInbound inbound;
final WebsocketOutbound outbound;
final AuthContext authContext;
private final MonoProcessor<Void> closeProcessor = MonoProcessor.create();
private final AtomicBoolean closed = new AtomicBoolean(false);
/**
* 构造默认会话.
*
* @param sessionId 会话 ID
* @param inbound 输入
* @param outbound 输出
* @param authContext 认证上下文
*/
public DefaultSession(
long sessionId,
WebsocketInbound inbound,
WebsocketOutbound outbound,
AuthContext authContext) {
this.sessionId = sessionId;
this.inbound = inbound;
this.outbound = outbound;
this.authContext = authContext;
if (authContext.isAnonymous()) {
this.uid = Long.toHexString(this.sessionId);
} else {
this.uid = authContext.uid();
}
// 连接关闭
this.inbound.withConnection(conn -> conn.onDispose().subscribe(closeProcessor));
}
@Override
public long sessionId() {
return sessionId;
}
@Override
public String uid() {
return uid;
}
@Override
public AuthContext authContext() {
return authContext;
}
@Override
public boolean isClosed() {
return closed.get();
}
@Override
public Mono<Void> sendPacket(Publisher<Packet> packet) {
return Flux.from(packet)
.map(
p -> {
try {
var buf = outbound.alloc().buffer();
OutputStream bbos = new ByteBufOutputStream(buf);
PacketHelper.MAPPER.writeValue(bbos, p);
return buf;
} catch (IOException e) {
log.error(
"序列化 Packet 失败 [sessionId={}, uid={}]\nPacket:\n{}",
this.sessionId,
this.uid(),
p,
e);
throw new RuntimeException("序列化 Packet 失败", e);
}
})
.flatMap(this::send)
.then();
}
@Override
public Mono<Void> send(Publisher<ByteBuf> buf) {
return outbound.send(buf).then();
}
@Override
public Mono<Void> close() {
if (closed.compareAndSet(false, true)) {
// 触发 onClose 事件
return outbound.sendClose();
}
return Mono.empty();
}
@Override
public Mono<Void> onClose() {
return closeProcessor;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DefaultSession that = (DefaultSession) o;
return sessionId == that.sessionId;
}
@Override
public int hashCode() {
return Objects.hash(sessionId);
}
}
|
UTF-8
|
Java
| 3,587 |
java
|
DefaultSession.java
|
Java
|
[
{
"context": "t.WebsocketOutbound;\n\n/**\n * 默认会话实现.\n *\n * @author Kevin Zou (kevinz@weghst.com)\n */\n@Log4j2\npublic final clas",
"end": 734,
"score": 0.9997598528862,
"start": 725,
"tag": "NAME",
"value": "Kevin Zou"
},
{
"context": "utbound;\n\n/**\n * 默认会话实现.\n *\n * @author Kevin Zou (kevinz@weghst.com)\n */\n@Log4j2\npublic final class DefaultSession im",
"end": 753,
"score": 0.9999306797981262,
"start": 736,
"tag": "EMAIL",
"value": "kevinz@weghst.com"
}
] | null |
[] |
package io.zhudy.xim.session.impl;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.zhudy.xim.auth.AuthContext;
import io.zhudy.xim.packet.Packet;
import io.zhudy.xim.helper.PacketHelper;
import io.zhudy.xim.session.Session;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import lombok.extern.log4j.Log4j2;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.MonoProcessor;
import reactor.netty.http.websocket.WebsocketInbound;
import reactor.netty.http.websocket.WebsocketOutbound;
/**
* 默认会话实现.
*
* @author <NAME> (<EMAIL>)
*/
@Log4j2
public final class DefaultSession implements Session {
final long sessionId;
final String uid;
final WebsocketInbound inbound;
final WebsocketOutbound outbound;
final AuthContext authContext;
private final MonoProcessor<Void> closeProcessor = MonoProcessor.create();
private final AtomicBoolean closed = new AtomicBoolean(false);
/**
* 构造默认会话.
*
* @param sessionId 会话 ID
* @param inbound 输入
* @param outbound 输出
* @param authContext 认证上下文
*/
public DefaultSession(
long sessionId,
WebsocketInbound inbound,
WebsocketOutbound outbound,
AuthContext authContext) {
this.sessionId = sessionId;
this.inbound = inbound;
this.outbound = outbound;
this.authContext = authContext;
if (authContext.isAnonymous()) {
this.uid = Long.toHexString(this.sessionId);
} else {
this.uid = authContext.uid();
}
// 连接关闭
this.inbound.withConnection(conn -> conn.onDispose().subscribe(closeProcessor));
}
@Override
public long sessionId() {
return sessionId;
}
@Override
public String uid() {
return uid;
}
@Override
public AuthContext authContext() {
return authContext;
}
@Override
public boolean isClosed() {
return closed.get();
}
@Override
public Mono<Void> sendPacket(Publisher<Packet> packet) {
return Flux.from(packet)
.map(
p -> {
try {
var buf = outbound.alloc().buffer();
OutputStream bbos = new ByteBufOutputStream(buf);
PacketHelper.MAPPER.writeValue(bbos, p);
return buf;
} catch (IOException e) {
log.error(
"序列化 Packet 失败 [sessionId={}, uid={}]\nPacket:\n{}",
this.sessionId,
this.uid(),
p,
e);
throw new RuntimeException("序列化 Packet 失败", e);
}
})
.flatMap(this::send)
.then();
}
@Override
public Mono<Void> send(Publisher<ByteBuf> buf) {
return outbound.send(buf).then();
}
@Override
public Mono<Void> close() {
if (closed.compareAndSet(false, true)) {
// 触发 onClose 事件
return outbound.sendClose();
}
return Mono.empty();
}
@Override
public Mono<Void> onClose() {
return closeProcessor;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DefaultSession that = (DefaultSession) o;
return sessionId == that.sessionId;
}
@Override
public int hashCode() {
return Objects.hash(sessionId);
}
}
| 3,574 | 0.636805 | 0.635378 | 145 | 23.172413 | 18.487404 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.448276 | false | false |
3
|
73ab843d02a7c6a829b2fbe0820416830e6c3d10
| 18,313,740,582,506 |
52bc2be96c221d2e4192096aed4fdbefce0cfcb8
|
/vaccines-service/src/main/java/com/hazemmostafa/vts/vaccines/service/mapper/VaccineMapper.java
|
b85e6897e89987cc68000fd1636869510d2ef33d
|
[] |
no_license
|
Hazem-Mostafa/VTS
|
https://github.com/Hazem-Mostafa/VTS
|
a9d3627c5ab90db796b9c15ccc8a2e34a48e49a8
|
687e50de5a37af8826aa00593677e8695fa8ff4a
|
refs/heads/main
| 2023-03-11T19:53:19.943000 | 2021-02-25T14:11:05 | 2021-02-25T14:11:05 | 342,040,571 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.hazemmostafa.vts.vaccines.service.mapper;
import com.hazemmostafa.vts.vaccines.domain.Vaccine;
import com.hazemmostafa.vts.vaccines.dto.VaccineDTO;
import org.mapstruct.Mapper;
@Mapper(componentModel = "spring")
public interface VaccineMapper extends BaseMapper<Vaccine, VaccineDTO> {
}
|
UTF-8
|
Java
| 301 |
java
|
VaccineMapper.java
|
Java
|
[] | null |
[] |
package com.hazemmostafa.vts.vaccines.service.mapper;
import com.hazemmostafa.vts.vaccines.domain.Vaccine;
import com.hazemmostafa.vts.vaccines.dto.VaccineDTO;
import org.mapstruct.Mapper;
@Mapper(componentModel = "spring")
public interface VaccineMapper extends BaseMapper<Vaccine, VaccineDTO> {
}
| 301 | 0.82392 | 0.82392 | 9 | 32.444443 | 25.534775 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false |
3
|
b9a79dc96c2dd61f38368eb9add3200c172c67f9
| 14,267,881,417,521 |
f2edbcdd448b49858263e958ffcac7e0b5218f65
|
/app/src/main/java/android/lucas/com/mapstep/LastLocationUpdater.java
|
a4967dfe5a7240810641d064d3a7b527ee4feba8
|
[] |
no_license
|
KleberQueiroz/MapStep_GPS
|
https://github.com/KleberQueiroz/MapStep_GPS
|
a8b23b7c85d5c44fea7943b65810422abb355113
|
32d5637ecfd87394b5f7c61e69faa049a01db88e
|
refs/heads/master
| 2021-07-04T23:33:51.927000 | 2017-07-05T19:43:10 | 2017-07-05T19:43:10 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package android.lucas.com.mapstep;
/**
* Created by lucas on 04/04/17.
*/
public class LastLocationUpdater {
public static final double STEP_DISTANCE = 0.60; // tamanho médio de um passo segundo Sistema Internacional de Medidas
public static Point calcNextLocation(double theta, // angulo
double distance, // distancia percorrida
Point init // ponto inicial
) {
theta = convert(theta);
double deltaX = distance * Math.cos(Math.toRadians(theta));
double deltaY = distance * Math.sin(Math.toRadians(theta));
double deltaLon = deltaX / (111320*Math.cos(Math.toRadians(init.lat)));
double deltaLat = deltaY / (110540);
Point finalPosition = new Point();
finalPosition.lat = init.lat + deltaLat;
finalPosition.lon = init.lon + deltaLon;
return finalPosition; // ponto final
}
public static double convert(double theta) { // conversao de sistema cartesiano
return -theta + 90;
}
}
class Point {
double lon;
double lat;
Point(){}
Point(double lat, double lon) {
this.lat = lat;
this.lon = lon;
}
}
|
UTF-8
|
Java
| 1,249 |
java
|
LastLocationUpdater.java
|
Java
|
[
{
"context": "kage android.lucas.com.mapstep;\n\n/**\n * Created by lucas on 04/04/17.\n */\n\npublic class LastLocationUpdate",
"end": 59,
"score": 0.9993230700492859,
"start": 54,
"tag": "USERNAME",
"value": "lucas"
}
] | null |
[] |
package android.lucas.com.mapstep;
/**
* Created by lucas on 04/04/17.
*/
public class LastLocationUpdater {
public static final double STEP_DISTANCE = 0.60; // tamanho médio de um passo segundo Sistema Internacional de Medidas
public static Point calcNextLocation(double theta, // angulo
double distance, // distancia percorrida
Point init // ponto inicial
) {
theta = convert(theta);
double deltaX = distance * Math.cos(Math.toRadians(theta));
double deltaY = distance * Math.sin(Math.toRadians(theta));
double deltaLon = deltaX / (111320*Math.cos(Math.toRadians(init.lat)));
double deltaLat = deltaY / (110540);
Point finalPosition = new Point();
finalPosition.lat = init.lat + deltaLat;
finalPosition.lon = init.lon + deltaLon;
return finalPosition; // ponto final
}
public static double convert(double theta) { // conversao de sistema cartesiano
return -theta + 90;
}
}
class Point {
double lon;
double lat;
Point(){}
Point(double lat, double lon) {
this.lat = lat;
this.lon = lon;
}
}
| 1,249 | 0.589744 | 0.571314 | 50 | 23.98 | 29.529301 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.38 | false | false |
3
|
17acee2f819fa47a41d67153047b9143200ff039
| 28,922,309,825,225 |
227d41b1e171990e0ee4442d6c9d9d61a08fa2cc
|
/order/order/src/main/java/com/brillio/order/model/Product.java
|
6d9afb97d9d461c1d64678b294cdf01463cd18d6
|
[] |
no_license
|
vidhivermabrillio/orderProduct
|
https://github.com/vidhivermabrillio/orderProduct
|
2f6535494b8ae1da083ab1eb2bf66b51b8504512
|
c30462de9ff039736f007abad62588362b19d9dc
|
refs/heads/main
| 2023-05-02T13:04:06.949000 | 2021-05-21T09:06:45 | 2021-05-21T09:06:45 | 365,679,826 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.brillio.order.model;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@Table(name = "PRODUCT_TB")
public class Product implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private int id;
@Column(name = "PRODUCT_NAME")
private String productName;
@Column(name = "PRODUCT_TYPE")
private String productType;
@Column(name = "PRODUCT_COST")
private int productCost;
@ManyToOne(cascade = {CascadeType.ALL})
@JoinColumn(name = "ORDER_ID")
private Order order;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getProductType() {
return productType;
}
public void setProductType(String productType) {
this.productType = productType;
}
public int getProductCost() {
return productCost;
}
public void setProductCost(int productCost) {
this.productCost = productCost;
}
public Order getOrder() {
return order;
}
public void setOrder(Order order) {
this.order = order;
}
}
|
UTF-8
|
Java
| 1,250 |
java
|
Product.java
|
Java
|
[] | null |
[] |
package com.brillio.order.model;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@Table(name = "PRODUCT_TB")
public class Product implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private int id;
@Column(name = "PRODUCT_NAME")
private String productName;
@Column(name = "PRODUCT_TYPE")
private String productType;
@Column(name = "PRODUCT_COST")
private int productCost;
@ManyToOne(cascade = {CascadeType.ALL})
@JoinColumn(name = "ORDER_ID")
private Order order;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getProductType() {
return productType;
}
public void setProductType(String productType) {
this.productType = productType;
}
public int getProductCost() {
return productCost;
}
public void setProductCost(int productCost) {
this.productCost = productCost;
}
public Order getOrder() {
return order;
}
public void setOrder(Order order) {
this.order = order;
}
}
| 1,250 | 0.7112 | 0.7104 | 72 | 16.361111 | 16.140276 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.055556 | false | false |
3
|
545a3bb32c7a9e2b27cace39d29e0abc04cc47f2
| 7,816,840,503,679 |
b04471b102b2285f0b8a94ce6e3dc88fc9c750af
|
/rest-assert-core/src/main/java/com/github/mjeanroy/restassert/core/internal/json/comparators/JsonContext.java
|
2e27cc528f5a5fd7702bc3174710c93c57fc37b8
|
[] |
no_license
|
mjeanroy/rest-assert
|
https://github.com/mjeanroy/rest-assert
|
795f59cbb2e1b6fac59408439a1fae5ee97d88d1
|
b9ea9318c1907cc45a6afd42ac200b1ead97f000
|
refs/heads/master
| 2022-12-25T06:02:07.555000 | 2022-05-21T14:25:43 | 2022-05-21T14:25:43 | 128,626,910 | 0 | 0 | null | false | 2022-11-16T03:00:14 | 2018-04-08T09:58:49 | 2022-05-21T11:48:30 | 2022-11-16T03:00:13 | 5,282 | 0 | 0 | 2 |
Java
| false | false |
/**
* The MIT License (MIT)
*
* Copyright (c) 2014-2021 Mickael Jeanroy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.github.mjeanroy.restassert.core.internal.json.comparators;
import com.github.mjeanroy.restassert.core.internal.json.JsonType;
import java.util.LinkedList;
import java.util.List;
/**
* Json context (a.k.a current fully qualified entry
* name).
*/
class JsonContext {
static JsonContext rootContext() {
return new JsonContext();
}
private final List<String> contexts;
private JsonContext() {
contexts = new LinkedList<>();
}
void append(String entryName) {
contexts.add(entryName);
}
void remove() {
contexts.remove(contexts.size() - 1);
}
String toPath(String last) {
if (contexts.isEmpty()) {
return last;
}
String separator = ".";
StringBuilder sb = new StringBuilder();
int i = 0;
for (String context : contexts) {
if (shouldAddSeparator(i, context)) {
sb.append(separator);
}
sb.append(context);
i++;
}
if (!last.isEmpty() && shouldAddSeparator(i, last)) {
sb.append(separator);
}
// Do not forget to append last value
sb.append(last);
return sb.toString();
}
@Override
public String toString() {
return toPath("");
}
private static boolean shouldAddSeparator(int index, String context) {
return index != 0 && !isArrayNotation(context);
}
private static boolean isArrayNotation(String context) {
return JsonType.ARRAY.is(context);
}
}
|
UTF-8
|
Java
| 2,504 |
java
|
JsonContext.java
|
Java
|
[
{
"context": "he MIT License (MIT)\n *\n * Copyright (c) 2014-2021 Mickael Jeanroy\n *\n * Permission is hereby granted, free of charg",
"end": 74,
"score": 0.999884307384491,
"start": 59,
"tag": "NAME",
"value": "Mickael Jeanroy"
},
{
"context": "LINGS IN\n * THE SOFTWARE.\n */\n\npackage com.github.mjeanroy.restassert.core.internal.json.comparators;\n\nimpor",
"end": 1182,
"score": 0.7098420262336731,
"start": 1174,
"tag": "USERNAME",
"value": "mjeanroy"
},
{
"context": "ore.internal.json.comparators;\n\nimport com.github.mjeanroy.restassert.core.internal.json.JsonType;\n\nimport j",
"end": 1253,
"score": 0.9244680404663086,
"start": 1245,
"tag": "USERNAME",
"value": "mjeanroy"
}
] | null |
[] |
/**
* The MIT License (MIT)
*
* Copyright (c) 2014-2021 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.github.mjeanroy.restassert.core.internal.json.comparators;
import com.github.mjeanroy.restassert.core.internal.json.JsonType;
import java.util.LinkedList;
import java.util.List;
/**
* Json context (a.k.a current fully qualified entry
* name).
*/
class JsonContext {
static JsonContext rootContext() {
return new JsonContext();
}
private final List<String> contexts;
private JsonContext() {
contexts = new LinkedList<>();
}
void append(String entryName) {
contexts.add(entryName);
}
void remove() {
contexts.remove(contexts.size() - 1);
}
String toPath(String last) {
if (contexts.isEmpty()) {
return last;
}
String separator = ".";
StringBuilder sb = new StringBuilder();
int i = 0;
for (String context : contexts) {
if (shouldAddSeparator(i, context)) {
sb.append(separator);
}
sb.append(context);
i++;
}
if (!last.isEmpty() && shouldAddSeparator(i, last)) {
sb.append(separator);
}
// Do not forget to append last value
sb.append(last);
return sb.toString();
}
@Override
public String toString() {
return toPath("");
}
private static boolean shouldAddSeparator(int index, String context) {
return index != 0 && !isArrayNotation(context);
}
private static boolean isArrayNotation(String context) {
return JsonType.ARRAY.is(context);
}
}
| 2,495 | 0.717252 | 0.712859 | 96 | 25.083334 | 26.833464 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.302083 | false | false |
3
|
9e55c3e76c6168bccf577bfa934f0de06887d2b7
| 5,514,738,057,071 |
a1f1467cfee13185ae7a1100824702023b92d74f
|
/app/src/main/java/com/elhazent/picodiploma/online/presenter/LoginRegisPresenter.java
|
88c7db9948c9c63cff51a2999f313201d46f1ac8
|
[] |
no_license
|
elhazent/driverojol
|
https://github.com/elhazent/driverojol
|
7125b4a153a7acc76a2d749cfda2781d8570a16d
|
1871495c7dd8dba2b4b964ffacad0d8b7e450d01
|
refs/heads/master
| 2020-06-20T18:11:14.499000 | 2019-07-16T13:58:22 | 2019-07-16T13:58:22 | 197,204,558 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.elhazent.picodiploma.online.presenter;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.widget.Toast;
import com.elhazent.picodiploma.online.LoginRegisterActivity;
import com.elhazent.picodiploma.online.model.ResponseLoginRegis;
import com.elhazent.picodiploma.online.network.InitRetrofit;
import com.elhazent.picodiploma.online.view.LoginRegisView;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.FirebaseDatabase;
import java.util.HashMap;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class LoginRegisPresenter implements implementLoginPresenter{
LoginRegisView loginRegisView;
public LoginRegisPresenter(LoginRegisView loginRegisView) {
this.loginRegisView = loginRegisView;
}
@Override
public void ProsessRegister(String name, String phone, String email, String password, final DialogInterface dialog) {
loginRegisView.showloading();
InitRetrofit.getInstance().registerUser(name, phone, email, password).enqueue(new Callback<ResponseLoginRegis>() {
@Override
public void onResponse(Call<ResponseLoginRegis> call, Response<ResponseLoginRegis> response) {
loginRegisView.hideloading();
if (response.isSuccessful()) {
String result = response.body().getResult();
String msg = response.body().getMsg();
if (result.equals("true")) {
loginRegisView.showToast(msg);
loginRegisView.hidedialog(dialog);
} else {
loginRegisView.showToast(msg);
}
}
}
@Override
public void onFailure(Call<ResponseLoginRegis> call, Throwable t) {
loginRegisView.showError("gagal format" + t.getLocalizedMessage());
loginRegisView.hideloading();
}
});
}
@Override
public void ProsessLogin(String device, String email, String password, DialogInterface dialog) {
}
}
|
UTF-8
|
Java
| 2,364 |
java
|
LoginRegisPresenter.java
|
Java
|
[] | null |
[] |
package com.elhazent.picodiploma.online.presenter;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.widget.Toast;
import com.elhazent.picodiploma.online.LoginRegisterActivity;
import com.elhazent.picodiploma.online.model.ResponseLoginRegis;
import com.elhazent.picodiploma.online.network.InitRetrofit;
import com.elhazent.picodiploma.online.view.LoginRegisView;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.FirebaseDatabase;
import java.util.HashMap;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class LoginRegisPresenter implements implementLoginPresenter{
LoginRegisView loginRegisView;
public LoginRegisPresenter(LoginRegisView loginRegisView) {
this.loginRegisView = loginRegisView;
}
@Override
public void ProsessRegister(String name, String phone, String email, String password, final DialogInterface dialog) {
loginRegisView.showloading();
InitRetrofit.getInstance().registerUser(name, phone, email, password).enqueue(new Callback<ResponseLoginRegis>() {
@Override
public void onResponse(Call<ResponseLoginRegis> call, Response<ResponseLoginRegis> response) {
loginRegisView.hideloading();
if (response.isSuccessful()) {
String result = response.body().getResult();
String msg = response.body().getMsg();
if (result.equals("true")) {
loginRegisView.showToast(msg);
loginRegisView.hidedialog(dialog);
} else {
loginRegisView.showToast(msg);
}
}
}
@Override
public void onFailure(Call<ResponseLoginRegis> call, Throwable t) {
loginRegisView.showError("gagal format" + t.getLocalizedMessage());
loginRegisView.hideloading();
}
});
}
@Override
public void ProsessLogin(String device, String email, String password, DialogInterface dialog) {
}
}
| 2,364 | 0.683164 | 0.681895 | 63 | 36.523811 | 30.53224 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false |
3
|
db88e302621ac096b4c78514779feee5f7820213
| 10,651,518,921,222 |
8245865d4133e32f39335daf54c98630368a0ef5
|
/com.greenwatch.reports.pollution/src/com/services/jersey/ReportsService.java
|
da0f9bba8afbd9a258c7ea7b538897de8a80f9a5
|
[] |
no_license
|
marcusschiesser/greenwatch
|
https://github.com/marcusschiesser/greenwatch
|
3ef8483ec2f7a8b33219090eb230772f249ea6c7
|
c3bdeb68005f8d3384c766b04c2b198bb1b8024a
|
refs/heads/master
| 2020-05-31T14:38:54.045000 | 2011-09-18T14:58:33 | 2011-09-18T14:58:33 | 32,132,466 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.services.jersey;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.appengine.api.blobstore.BlobstoreService;
import com.google.appengine.api.blobstore.BlobKey;
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;
import com.reports.dao.Dao;
import com.reports.model.ItemMarshaller;
import com.reports.model.Report;
@Path("/reports")
public class ReportsService {
@POST
@Path("/text")
@Produces({"application/xml","application/json"})
@Consumes(MediaType.APPLICATION_XML)
public void postReport(ItemMarshaller t){
System.out.println("Creating new report ");
String summary = t.getSummary();
String longDescription = t.getDescription();
String url = t.getUrl();
Dao.INSTANCE.add("niro", summary, longDescription, url);
}
@POST
@Path("/image")
@Consumes( {MediaType.TEXT_PLAIN, "image/jpeg", "image/png", "image/gif", "application/zip"} )
@Produces( {MediaType.TEXT_PLAIN} )
public void postReportImage(@Context HttpServletRequest req, @Context HttpServletResponse res){
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
String uploadURL = blobstoreService.createUploadUrl("/upload");
if(uploadURL.indexOf("http") == -1)
{
uploadURL = "http://localhost:8888" + uploadURL;
}
URL url = null;
try {
url = new URL(uploadURL);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try{
String boundary = MultiPartFormOutputStream.createBoundary();
URLConnection urlConn = MultiPartFormOutputStream.createConnection(url);
urlConn.setReadTimeout(15000);
urlConn.setRequestProperty("Accept", "*/*");
urlConn.setRequestProperty("Content-Type", MultiPartFormOutputStream.getContentType(boundary));
urlConn.setRequestProperty("Connection", "Keep-Alive");
urlConn.setRequestProperty("Cache-Control", "no-cache");
MultiPartFormOutputStream out = new MultiPartFormOutputStream(urlConn.getOutputStream(), boundary);
out.writeField("param", "value");
out.writeFile("myFile", "text/plain", new File("C:/test.txt"));
out.close();
}catch(IOException e){
e.printStackTrace();
}
}
@GET
@Path("/text")
@Produces({"application/xml","application/json"})
public List<ItemMarshaller> getReports(){
List<Report> reps = new ArrayList<Report>();
List<ItemMarshaller> items = new ArrayList<ItemMarshaller>();
reps = Dao.INSTANCE.getReports("niro");
for (Report rep : reps) {
System.out.println("Summary "+rep.getShortDescription());
System.out.println("Description "+rep.getLongDescription());
System.out.println("URL "+rep.getUrl());
System.out.println("----------");
ItemMarshaller item = new ItemMarshaller();
item.setSummary(rep.getShortDescription());
item.setDescription(rep.getLongDescription());
item.setUrl(rep.getUrl());
items.add(item);
}
return items;
}
}
|
UTF-8
|
Java
| 3,862 |
java
|
ReportsService.java
|
Java
|
[] | null |
[] |
package com.services.jersey;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.appengine.api.blobstore.BlobstoreService;
import com.google.appengine.api.blobstore.BlobKey;
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;
import com.reports.dao.Dao;
import com.reports.model.ItemMarshaller;
import com.reports.model.Report;
@Path("/reports")
public class ReportsService {
@POST
@Path("/text")
@Produces({"application/xml","application/json"})
@Consumes(MediaType.APPLICATION_XML)
public void postReport(ItemMarshaller t){
System.out.println("Creating new report ");
String summary = t.getSummary();
String longDescription = t.getDescription();
String url = t.getUrl();
Dao.INSTANCE.add("niro", summary, longDescription, url);
}
@POST
@Path("/image")
@Consumes( {MediaType.TEXT_PLAIN, "image/jpeg", "image/png", "image/gif", "application/zip"} )
@Produces( {MediaType.TEXT_PLAIN} )
public void postReportImage(@Context HttpServletRequest req, @Context HttpServletResponse res){
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
String uploadURL = blobstoreService.createUploadUrl("/upload");
if(uploadURL.indexOf("http") == -1)
{
uploadURL = "http://localhost:8888" + uploadURL;
}
URL url = null;
try {
url = new URL(uploadURL);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try{
String boundary = MultiPartFormOutputStream.createBoundary();
URLConnection urlConn = MultiPartFormOutputStream.createConnection(url);
urlConn.setReadTimeout(15000);
urlConn.setRequestProperty("Accept", "*/*");
urlConn.setRequestProperty("Content-Type", MultiPartFormOutputStream.getContentType(boundary));
urlConn.setRequestProperty("Connection", "Keep-Alive");
urlConn.setRequestProperty("Cache-Control", "no-cache");
MultiPartFormOutputStream out = new MultiPartFormOutputStream(urlConn.getOutputStream(), boundary);
out.writeField("param", "value");
out.writeFile("myFile", "text/plain", new File("C:/test.txt"));
out.close();
}catch(IOException e){
e.printStackTrace();
}
}
@GET
@Path("/text")
@Produces({"application/xml","application/json"})
public List<ItemMarshaller> getReports(){
List<Report> reps = new ArrayList<Report>();
List<ItemMarshaller> items = new ArrayList<ItemMarshaller>();
reps = Dao.INSTANCE.getReports("niro");
for (Report rep : reps) {
System.out.println("Summary "+rep.getShortDescription());
System.out.println("Description "+rep.getLongDescription());
System.out.println("URL "+rep.getUrl());
System.out.println("----------");
ItemMarshaller item = new ItemMarshaller();
item.setSummary(rep.getShortDescription());
item.setDescription(rep.getLongDescription());
item.setUrl(rep.getUrl());
items.add(item);
}
return items;
}
}
| 3,862 | 0.642931 | 0.640342 | 119 | 30.453781 | 26.385235 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.05042 | false | false |
3
|
7e1670a44a4c229e96481634261818f7f299a73a
| 9,792,525,465,876 |
1939a5c1da8bf1470ea654652462e32d4a193172
|
/src/creation/factory/Factory.java
|
e73d29eacd105a330e772eb773910b09c36428da
|
[] |
no_license
|
pierprogramm/DesignPattern
|
https://github.com/pierprogramm/DesignPattern
|
4beeb4b55a8b50f130fb622765d8819a6f40dff7
|
2f7b8b4aca616c996df93af3111b0781a9f4c239
|
refs/heads/master
| 2021-01-11T02:19:18.904000 | 2016-10-15T09:25:47 | 2016-10-15T09:25:47 | 70,978,665 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package creation.factory;
public interface Factory {
ProductInterface createFactory();
}
|
UTF-8
|
Java
| 91 |
java
|
Factory.java
|
Java
|
[] | null |
[] |
package creation.factory;
public interface Factory {
ProductInterface createFactory();
}
| 91 | 0.802198 | 0.802198 | 5 | 17.200001 | 13.991426 | 34 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false |
3
|
e851ec1a72596dc988869a6d926e8e8aff0c25c7
| 19,155,554,186,468 |
72d879749ad66400b76b3c31bfc951c6f2e08c25
|
/src/main/java/com/example/CustomerServiceApplication.java
|
7b3d6c596cb559d29e6551906a5d33fb549cf861
|
[] |
no_license
|
EvilJinious1/testissue
|
https://github.com/EvilJinious1/testissue
|
a0de48f8f5cd5dbc5393da8084316595c8db84b2
|
98d3393d67022ae13af7e47fe11fa005331394e6
|
refs/heads/master
| 2020-06-11T06:19:20.806000 | 2016-12-06T16:15:35 | 2016-12-06T16:15:35 | 75,748,540 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
//@EnableCircuitBreaker
@EnableDiscoveryClient
@SpringBootApplication(
scanBasePackages = {
// FoundationsPackage.FOUNDATIONS,
// SecurityPackage.SECURITY,
// ClientSecurityPackage.CLIENT_SECURITY,
// CredentialsPackage.CREDENTIALS,
"com.cisco.phisphere.customerservice"
}
)
@Slf4j
public class CustomerServiceApplication {
public static void main(String[] args) {
SpringApplication.run(CustomerServiceApplication.class, args);
}
}
|
UTF-8
|
Java
| 785 |
java
|
CustomerServiceApplication.java
|
Java
|
[] | null |
[] |
package com.example;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
//@EnableCircuitBreaker
@EnableDiscoveryClient
@SpringBootApplication(
scanBasePackages = {
// FoundationsPackage.FOUNDATIONS,
// SecurityPackage.SECURITY,
// ClientSecurityPackage.CLIENT_SECURITY,
// CredentialsPackage.CREDENTIALS,
"com.cisco.phisphere.customerservice"
}
)
@Slf4j
public class CustomerServiceApplication {
public static void main(String[] args) {
SpringApplication.run(CustomerServiceApplication.class, args);
}
}
| 785 | 0.814013 | 0.810191 | 27 | 28.074074 | 23.682978 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.481481 | false | false |
3
|
ca772471849b45299bc7d84d04e63ea1c0e32327
| 11,656,541,249,309 |
748bb89e08072e475ade8e09c74da93cd7a646ed
|
/src/main/java/marfil/raul/exceltomysql/utilities/Nivel_dos.java
|
e9013628a3bbdcc492c126e5ea677da677c562ff
|
[] |
no_license
|
RaulMarfil/PruebaExcel
|
https://github.com/RaulMarfil/PruebaExcel
|
7fdbbda04790f8dabcd2a643ed9f3200a36a9581
|
cecabb591c9abcd6522332621883c7693806ea33
|
refs/heads/master
| 2021-01-10T16:14:47.050000 | 2015-11-15T15:06:56 | 2015-11-15T15:06:56 | 43,517,858 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* 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 marfil.raul.exceltomysql.utilities;
/**
*
* @author rmarfilc
*/
public enum Nivel_dos {
ubicacion_1("COMUNICACIONES TELECONTROL"),
ubicacion_2("COMUNICACIONES REGULACION SECUNDARIA"),
ubicacion_3("COMUNICACIONES HYDRA"),
ubicacion_4("COMUNICACIONES PROTECCIONES"),
ubicacion_5("CENTRAL TELEFONICA CORE"),
ubicacion_6("CENTRAL TELEFONICA"),
ubicacion_7("TELEFONIA"),
ubicacion_8("TELEFONIA MÓVIL"),
ubicacion_9("PUESTOS DE OPERADORAS");
private String ubicacion;
private Nivel_dos(String ubicacion) {
this.ubicacion = ubicacion;
}
public String getNivel_dos(){
return ubicacion;
}
}
|
UTF-8
|
Java
| 871 |
java
|
Nivel_dos.java
|
Java
|
[
{
"context": "il.raul.exceltomysql.utilities;\n\n/**\n *\n * @author rmarfilc\n */\npublic enum Nivel_dos {\n \n \n ubicaci",
"end": 256,
"score": 0.9995889067649841,
"start": 248,
"tag": "USERNAME",
"value": "rmarfilc"
}
] | null |
[] |
/*
* 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 marfil.raul.exceltomysql.utilities;
/**
*
* @author rmarfilc
*/
public enum Nivel_dos {
ubicacion_1("COMUNICACIONES TELECONTROL"),
ubicacion_2("COMUNICACIONES REGULACION SECUNDARIA"),
ubicacion_3("COMUNICACIONES HYDRA"),
ubicacion_4("COMUNICACIONES PROTECCIONES"),
ubicacion_5("CENTRAL TELEFONICA CORE"),
ubicacion_6("CENTRAL TELEFONICA"),
ubicacion_7("TELEFONIA"),
ubicacion_8("TELEFONIA MÓVIL"),
ubicacion_9("PUESTOS DE OPERADORAS");
private String ubicacion;
private Nivel_dos(String ubicacion) {
this.ubicacion = ubicacion;
}
public String getNivel_dos(){
return ubicacion;
}
}
| 871 | 0.681609 | 0.671264 | 36 | 23.166666 | 21.164042 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false |
3
|
a92fb1fe411eac9743d58309e34beef86e4709af
| 34,273,839,031,399 |
bc6f9311395116a049619d686cdfecac2a45a091
|
/MainAdmin_MainAdmin/src/main/java/com/railway/MainAdmin/Controller/MainAdminController.java
|
16cbbf963913e7b117b746d5467d1ceec41365cb
|
[] |
no_license
|
RupsaSarkar/Online-Railway-Reservation-System
|
https://github.com/RupsaSarkar/Online-Railway-Reservation-System
|
4c8721264de4358a635e7584f56666a07097cbf4
|
a9a6c2b07c72e4a7ca27fbd569f554995043f8da
|
refs/heads/master
| 2023-06-10T10:01:11.667000 | 2021-06-28T11:54:51 | 2021-06-28T11:54:51 | 374,527,003 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.railway.MainAdmin.Controller;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.railway.MainAdmin.Service.MainAdminService;
import com.railway.MainAdmin.models.Train;
@RestController
@RequestMapping("/Train")
public class MainAdminController {
@Autowired
private MainAdminService repo;
@PostMapping("/addTrain")
public String saveTrain(@RequestBody Train train) {
repo.addTrain(train);
return "added Train with id:" + train.getId();
}
@GetMapping("/findAllTrain")
public List<Train> getTrains(){
return repo.getAllTrain();
}
@GetMapping("/findAllTrain/{train_no}")
public Train getTrain(@PathVariable String train_no){
return repo.getTrainbyTrain_no(train_no);
}
@DeleteMapping("/delete/{train_no}")
public String deleteTrain(@PathVariable String train_no) {
repo.deleteTrain(train_no);
return "Admin deleted train with train no:" +train_no;
}
@PutMapping("/update/{train_no}")
public Train updateTrain (@PathVariable String train_no,@RequestBody Train train) {
return repo.updateTrain(train_no, train);
}
}
|
UTF-8
|
Java
| 1,633 |
java
|
MainAdminController.java
|
Java
|
[] | null |
[] |
package com.railway.MainAdmin.Controller;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.railway.MainAdmin.Service.MainAdminService;
import com.railway.MainAdmin.models.Train;
@RestController
@RequestMapping("/Train")
public class MainAdminController {
@Autowired
private MainAdminService repo;
@PostMapping("/addTrain")
public String saveTrain(@RequestBody Train train) {
repo.addTrain(train);
return "added Train with id:" + train.getId();
}
@GetMapping("/findAllTrain")
public List<Train> getTrains(){
return repo.getAllTrain();
}
@GetMapping("/findAllTrain/{train_no}")
public Train getTrain(@PathVariable String train_no){
return repo.getTrainbyTrain_no(train_no);
}
@DeleteMapping("/delete/{train_no}")
public String deleteTrain(@PathVariable String train_no) {
repo.deleteTrain(train_no);
return "Admin deleted train with train no:" +train_no;
}
@PutMapping("/update/{train_no}")
public Train updateTrain (@PathVariable String train_no,@RequestBody Train train) {
return repo.updateTrain(train_no, train);
}
}
| 1,633 | 0.785058 | 0.785058 | 57 | 27.649122 | 24.322029 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.070175 | false | false |
3
|
cc3a39ea2ea267281ed22f42562087f08963bd31
| 25,812,753,505,447 |
1e183d53f52bb7449481080c19eea0915b257c78
|
/src/elevatorstopsproblem/Trip.java
|
c965f6fc71237426176435727eee893b565b6a73
|
[] |
no_license
|
AlissonDiniz/elevator-stops-problem
|
https://github.com/AlissonDiniz/elevator-stops-problem
|
7183764e42b7a91ef96d9ba47d4a817bfd255aad
|
98f34c1e62212a4bd26be3912953cf9a0f91be1d
|
refs/heads/master
| 2021-01-19T16:49:44.604000 | 2017-04-14T18:10:11 | 2017-04-14T18:10:11 | 88,289,111 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* 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 elevatorstopsproblem;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Alisson Diniz
*/
public class Trip {
private final List<Passenger> passengers;
public Trip() {
this.passengers = new ArrayList<>();
}
public int getWeight() {
int weight = 0;
for(Passenger p: this.passengers){
weight += p.getWeight();
}
return weight;
}
public List<Passenger> getPassengers() {
return passengers;
}
}
|
UTF-8
|
Java
| 702 |
java
|
Trip.java
|
Java
|
[
{
"context": "rayList;\nimport java.util.List;\n\n/**\n *\n * @author Alisson Diniz\n */\npublic class Trip {\n\n private final List<P",
"end": 299,
"score": 0.9998571276664734,
"start": 286,
"tag": "NAME",
"value": "Alisson Diniz"
}
] | null |
[] |
/*
* 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 elevatorstopsproblem;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author <NAME>
*/
public class Trip {
private final List<Passenger> passengers;
public Trip() {
this.passengers = new ArrayList<>();
}
public int getWeight() {
int weight = 0;
for(Passenger p: this.passengers){
weight += p.getWeight();
}
return weight;
}
public List<Passenger> getPassengers() {
return passengers;
}
}
| 695 | 0.626781 | 0.625356 | 35 | 19.057142 | 19.486176 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.342857 | false | false |
3
|
55a5852fc0912d84d95a0c3b4a65c39011f5aa8a
| 16,836,271,867,619 |
be432f777f0e39da063406f62ffe3c3844f0a433
|
/projects/Framework/src/com/freshdirect/rules/ConditionI.java
|
363edd053652495ef04662c785308c0d2cd36d35
|
[] |
no_license
|
AnthonyCC/sf-temp-ui
|
https://github.com/AnthonyCC/sf-temp-ui
|
29428ae4df2985582d96fd55a55c7e936ba4b0e4
|
0c95b810bc44bd2bd46d0c7e968e9cf4e17a943a
|
refs/heads/master
| 2021-10-19T09:51:17.279000 | 2019-02-15T23:00:09 | 2019-02-15T23:00:09 | 171,323,740 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.freshdirect.rules;
import java.io.Serializable;
public interface ConditionI extends Serializable {
public boolean evaluate(Object target, RuleRuntimeI ctx);
public boolean validate();
}
|
UTF-8
|
Java
| 214 |
java
|
ConditionI.java
|
Java
|
[] | null |
[] |
package com.freshdirect.rules;
import java.io.Serializable;
public interface ConditionI extends Serializable {
public boolean evaluate(Object target, RuleRuntimeI ctx);
public boolean validate();
}
| 214 | 0.761682 | 0.761682 | 11 | 17.636364 | 21.011999 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false |
3
|
9588de1bed835966a941c174bc1e98510358a9f3
| 7,602,092,177,615 |
56e6f5b1de305448a8cade4ac567d9ca7674cb7f
|
/app/src/main/java/com/viatom/smartbp/activity/BaseActivity.java
|
92e577b11547892f41a63d0ccd8afa42f0c2acb3
|
[] |
no_license
|
jiang1991/SmartBP
|
https://github.com/jiang1991/SmartBP
|
dc2527028d705bfc3ca282720b115b49c1158d42
|
cd9a083254166ef5c2d93642c662af46e2c2013c
|
refs/heads/master
| 2021-04-12T10:31:48.362000 | 2017-07-28T09:45:56 | 2017-07-28T09:45:56 | 94,532,328 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.viatom.smartbp.activity;
import android.content.Context;
import android.support.design.widget.Snackbar;
import android.support.v4.app.FragmentTransaction;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.polidea.rxandroidble.RxBleClient;
import com.polidea.rxandroidble.RxBleConnection;
import com.polidea.rxandroidble.RxBleDevice;
import com.polidea.rxandroidble.utils.ConnectionSharingAdapter;
import com.viatom.smartbp.R;
import com.viatom.smartbp.fragment.HistoryFragment;
import com.viatom.smartbp.fragment.MeasureStartFragment;
import com.viatom.smartbp.fragment.SettingFragment;
import com.viatom.smartbp.items.Device;
import com.viatom.smartbp.utility.BtCmdUtils;
import com.viatom.smartbp.utility.Constant;
import com.viatom.smartbp.utility.LogUtils;
import com.viatom.smartbp.utility.StringUtils;
import java.util.UUID;
import rx.Observable;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
public class BaseActivity extends AppCompatActivity {
public static final String EXTRA_MAC_ADDRESS = "extra_mac_address";
public static final String CMD_DEVICE_INFO = "a50000e100000000";
private UUID read_uuid, write_uuid;
public BottomNavigationView bnve;
public Toolbar toolbar;
public int[] titles = new int[]{R.string.nav_measure, R.string.nav_history, R.string.nav_setting};
public RxBleClient bleClient;
private RxBleDevice bleDevice;
private Subscription subscription;
private Observable<RxBleConnection> connection;
public RequestQueue queue;
private String mac_address;
private String device_info;
private Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_base);
context = this;
queue = Volley.newRequestQueue(context);
bleClient = RxBleClient.create(context);
read_uuid = UUID.fromString(Constant.READ_CHARACTERISTIC);
write_uuid = UUID.fromString(Constant.WRTITE_CHARACTERISTIC);
initView();
initFragment();
initEvent();
mac_address = getIntent().getStringExtra(EXTRA_MAC_ADDRESS);
connectDevice(mac_address);
}
public void connectDevice(String mac_address) {
// String mac_address = device.getAddress();
bleDevice = bleClient.getBleDevice(mac_address);
bleDevice.observeConnectionStateChanges()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::onConnectionStateChange);
// listener
connection = bleDevice
.establishConnection(false)
.compose(new ConnectionSharingAdapter())
.observeOn(AndroidSchedulers.mainThread())
.doOnUnsubscribe(this::updateUI);
connection.subscribe(
this::onConnectionReceived,
this::onConnectionFailure
);
}
private boolean isConnected() {
return bleDevice.getConnectionState() == RxBleConnection.RxBleConnectionState.CONNECTED;
}
/* change BNVE style */
private void initView() {
toolbar = (Toolbar) findViewById(R.id.toolBar);
setSupportActionBar(toolbar);
bnve = (BottomNavigationView) findViewById(R.id.bnve);
}
/* create fragments */
private void initFragment() {
iniMeasureFragment();
toolbar.setTitle(titles[0]);
}
/* set listeners */
private void initEvent() {
// select listener
bnve.setOnNavigationItemSelectedListener((@NonNull MenuItem item) -> {
switch (item.getItemId()) {
case R.id.nav_measure:
iniMeasureFragment();
toolbar.setTitle(titles[0]);
return true;
case R.id.nav_history:
toolbar.setTitle(titles[1]);
iniHistoryFragment();
return true;
case R.id.nav_setting:
toolbar.setTitle(titles[2]);
iniSettingFragment();
return true;
}
return false;
});
}
public void updateUI() {
//
}
/* measure main fragment */
public void iniMeasureFragment() {
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
MeasureStartFragment fragment = new MeasureStartFragment();
/* show MAC address */
fragment.showMacAddress(mac_address);
ft.replace(R.id.fragment_container, fragment);
ft.addToBackStack(null);
ft.commit();
}
/* history fragment */
public void iniHistoryFragment() {
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
HistoryFragment fragment = new HistoryFragment();
ft.replace(R.id.fragment_container, fragment);
ft.addToBackStack(null);
ft.commit();
}
/* setting fragment */
public void iniSettingFragment() {
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
SettingFragment fragment = new SettingFragment();
ft.replace(R.id.fragment_container, fragment);
ft.addToBackStack(null);
ft.commit();
}
/*
* get device info
* update the UI
* onDeviceConnected
* */
public void getDeviceInfo() {
// read & write
/*connection
.flatMap(rxBleConnection -> rxBleConnection.readCharacteristic(read_uuid)
.doOnNext(bytes -> {
LogUtils.d(bytes.toString());
})
.flatMap(bytes -> rxBleConnection.writeCharacteristic(write_uuid, StringUtils.hexToBytes(CMD_DEVICE_INFO)))
)
.subscribe(
writeBytes -> {
// Written data.
},
this::onWriteFailure
);*/
/*get device info */
connection
.flatMap(rxBleConnection -> rxBleConnection.setupNotification(read_uuid))
.doOnNext(notificationObservable -> {
// Notification has been set up
})
.flatMap(notificationObservable -> notificationObservable) // <-- Notification has been set up, now observe value changes.
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
this::onNotificationReceived,
this::onNotificationSetupFailure
);
connection
.flatMap(rxBleConnection -> rxBleConnection.writeCharacteristic(write_uuid, BtCmdUtils.getDeviceInfo()))
.subscribe(
bytes -> onWriteSuccess(),
this::onWriteFailure
);
/* get update info */
/*JsonObjectRequest request = new JsonObjectRequest(Constant.DEVICE_UPDATE_EN_URL, null, (JSONObject response) -> {
String updateDfv = response.optString("version");
LogUtils.d("DFV: " + updateDfv);
}, (VolleyError error) -> LogUtils.d(error.toString()));
queue.add(request);*/
}
public void onConnectionStateChange(RxBleConnection.RxBleConnectionState state) {
LogUtils.d(state.toString());
updateUI();
}
public void onConnectionReceived(RxBleConnection connection) {
LogUtils.d("connected");
getDeviceInfo();
}
public void onNotificationReceived(byte[] bytes) {
LogUtils.d("Notification Received: " + StringUtils.bytesToHex(bytes));
Device device = new Device(new Device.DeviceInfo(bytes));
LogUtils.d("sn: " + device.getDeviceInfo().getSn());
}
private void onNotificationSetupFailure(Throwable throwable) {
//noinspection ConstantConditions
LogUtils.d("Notifications error: " + throwable);
Snackbar.make(findViewById(R.id.toolBar), "Notifications error: " + throwable, Snackbar.LENGTH_SHORT).show();
}
private void onWriteSuccess() {
//noinspection ConstantConditions
LogUtils.d("Write success");
Snackbar.make(findViewById(R.id.toolBar), "Write success", Snackbar.LENGTH_SHORT).show();
}
private void onWriteFailure(Throwable throwable) {
//noinspection ConstantConditions
LogUtils.d("Write error: " + throwable);
Snackbar.make(findViewById(R.id.toolBar), "Write error: " + throwable, Snackbar.LENGTH_SHORT).show();
}
private void onConnectionFailure(Throwable throwable) {
//noinspection ConstantConditions
LogUtils.d("Connection error: " + throwable);
Snackbar.make(findViewById(R.id.toolBar), "Connection error: " + throwable, Snackbar.LENGTH_SHORT).show();
}
}
|
UTF-8
|
Java
| 9,378 |
java
|
BaseActivity.java
|
Java
|
[] | null |
[] |
package com.viatom.smartbp.activity;
import android.content.Context;
import android.support.design.widget.Snackbar;
import android.support.v4.app.FragmentTransaction;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.polidea.rxandroidble.RxBleClient;
import com.polidea.rxandroidble.RxBleConnection;
import com.polidea.rxandroidble.RxBleDevice;
import com.polidea.rxandroidble.utils.ConnectionSharingAdapter;
import com.viatom.smartbp.R;
import com.viatom.smartbp.fragment.HistoryFragment;
import com.viatom.smartbp.fragment.MeasureStartFragment;
import com.viatom.smartbp.fragment.SettingFragment;
import com.viatom.smartbp.items.Device;
import com.viatom.smartbp.utility.BtCmdUtils;
import com.viatom.smartbp.utility.Constant;
import com.viatom.smartbp.utility.LogUtils;
import com.viatom.smartbp.utility.StringUtils;
import java.util.UUID;
import rx.Observable;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
public class BaseActivity extends AppCompatActivity {
public static final String EXTRA_MAC_ADDRESS = "extra_mac_address";
public static final String CMD_DEVICE_INFO = "a50000e100000000";
private UUID read_uuid, write_uuid;
public BottomNavigationView bnve;
public Toolbar toolbar;
public int[] titles = new int[]{R.string.nav_measure, R.string.nav_history, R.string.nav_setting};
public RxBleClient bleClient;
private RxBleDevice bleDevice;
private Subscription subscription;
private Observable<RxBleConnection> connection;
public RequestQueue queue;
private String mac_address;
private String device_info;
private Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_base);
context = this;
queue = Volley.newRequestQueue(context);
bleClient = RxBleClient.create(context);
read_uuid = UUID.fromString(Constant.READ_CHARACTERISTIC);
write_uuid = UUID.fromString(Constant.WRTITE_CHARACTERISTIC);
initView();
initFragment();
initEvent();
mac_address = getIntent().getStringExtra(EXTRA_MAC_ADDRESS);
connectDevice(mac_address);
}
public void connectDevice(String mac_address) {
// String mac_address = device.getAddress();
bleDevice = bleClient.getBleDevice(mac_address);
bleDevice.observeConnectionStateChanges()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::onConnectionStateChange);
// listener
connection = bleDevice
.establishConnection(false)
.compose(new ConnectionSharingAdapter())
.observeOn(AndroidSchedulers.mainThread())
.doOnUnsubscribe(this::updateUI);
connection.subscribe(
this::onConnectionReceived,
this::onConnectionFailure
);
}
private boolean isConnected() {
return bleDevice.getConnectionState() == RxBleConnection.RxBleConnectionState.CONNECTED;
}
/* change BNVE style */
private void initView() {
toolbar = (Toolbar) findViewById(R.id.toolBar);
setSupportActionBar(toolbar);
bnve = (BottomNavigationView) findViewById(R.id.bnve);
}
/* create fragments */
private void initFragment() {
iniMeasureFragment();
toolbar.setTitle(titles[0]);
}
/* set listeners */
private void initEvent() {
// select listener
bnve.setOnNavigationItemSelectedListener((@NonNull MenuItem item) -> {
switch (item.getItemId()) {
case R.id.nav_measure:
iniMeasureFragment();
toolbar.setTitle(titles[0]);
return true;
case R.id.nav_history:
toolbar.setTitle(titles[1]);
iniHistoryFragment();
return true;
case R.id.nav_setting:
toolbar.setTitle(titles[2]);
iniSettingFragment();
return true;
}
return false;
});
}
public void updateUI() {
//
}
/* measure main fragment */
public void iniMeasureFragment() {
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
MeasureStartFragment fragment = new MeasureStartFragment();
/* show MAC address */
fragment.showMacAddress(mac_address);
ft.replace(R.id.fragment_container, fragment);
ft.addToBackStack(null);
ft.commit();
}
/* history fragment */
public void iniHistoryFragment() {
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
HistoryFragment fragment = new HistoryFragment();
ft.replace(R.id.fragment_container, fragment);
ft.addToBackStack(null);
ft.commit();
}
/* setting fragment */
public void iniSettingFragment() {
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
SettingFragment fragment = new SettingFragment();
ft.replace(R.id.fragment_container, fragment);
ft.addToBackStack(null);
ft.commit();
}
/*
* get device info
* update the UI
* onDeviceConnected
* */
public void getDeviceInfo() {
// read & write
/*connection
.flatMap(rxBleConnection -> rxBleConnection.readCharacteristic(read_uuid)
.doOnNext(bytes -> {
LogUtils.d(bytes.toString());
})
.flatMap(bytes -> rxBleConnection.writeCharacteristic(write_uuid, StringUtils.hexToBytes(CMD_DEVICE_INFO)))
)
.subscribe(
writeBytes -> {
// Written data.
},
this::onWriteFailure
);*/
/*get device info */
connection
.flatMap(rxBleConnection -> rxBleConnection.setupNotification(read_uuid))
.doOnNext(notificationObservable -> {
// Notification has been set up
})
.flatMap(notificationObservable -> notificationObservable) // <-- Notification has been set up, now observe value changes.
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
this::onNotificationReceived,
this::onNotificationSetupFailure
);
connection
.flatMap(rxBleConnection -> rxBleConnection.writeCharacteristic(write_uuid, BtCmdUtils.getDeviceInfo()))
.subscribe(
bytes -> onWriteSuccess(),
this::onWriteFailure
);
/* get update info */
/*JsonObjectRequest request = new JsonObjectRequest(Constant.DEVICE_UPDATE_EN_URL, null, (JSONObject response) -> {
String updateDfv = response.optString("version");
LogUtils.d("DFV: " + updateDfv);
}, (VolleyError error) -> LogUtils.d(error.toString()));
queue.add(request);*/
}
public void onConnectionStateChange(RxBleConnection.RxBleConnectionState state) {
LogUtils.d(state.toString());
updateUI();
}
public void onConnectionReceived(RxBleConnection connection) {
LogUtils.d("connected");
getDeviceInfo();
}
public void onNotificationReceived(byte[] bytes) {
LogUtils.d("Notification Received: " + StringUtils.bytesToHex(bytes));
Device device = new Device(new Device.DeviceInfo(bytes));
LogUtils.d("sn: " + device.getDeviceInfo().getSn());
}
private void onNotificationSetupFailure(Throwable throwable) {
//noinspection ConstantConditions
LogUtils.d("Notifications error: " + throwable);
Snackbar.make(findViewById(R.id.toolBar), "Notifications error: " + throwable, Snackbar.LENGTH_SHORT).show();
}
private void onWriteSuccess() {
//noinspection ConstantConditions
LogUtils.d("Write success");
Snackbar.make(findViewById(R.id.toolBar), "Write success", Snackbar.LENGTH_SHORT).show();
}
private void onWriteFailure(Throwable throwable) {
//noinspection ConstantConditions
LogUtils.d("Write error: " + throwable);
Snackbar.make(findViewById(R.id.toolBar), "Write error: " + throwable, Snackbar.LENGTH_SHORT).show();
}
private void onConnectionFailure(Throwable throwable) {
//noinspection ConstantConditions
LogUtils.d("Connection error: " + throwable);
Snackbar.make(findViewById(R.id.toolBar), "Connection error: " + throwable, Snackbar.LENGTH_SHORT).show();
}
}
| 9,378 | 0.635103 | 0.632758 | 278 | 32.733814 | 27.150812 | 138 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.517986 | false | false |
3
|
b70df25549e362c129d6d338d406bc5a8eab8453
| 25,323,127,213,243 |
ce5f9210620c188558b3189ec4f41079821c5f56
|
/src/main/java/com/ssm/shop/service/inter/PmsProductFullReductionService.java
|
5a125f801fe1f0569bdf5a62c15a39029d8d7fb9
|
[] |
no_license
|
l398906114/LiuK
|
https://github.com/l398906114/LiuK
|
90fe5254cf3f9a83970b96437f90eceae79aa9d8
|
cd34bccbfb217d5301c35f992773cb0a0a909116
|
refs/heads/master
| 2023-06-27T10:23:50.170000 | 2023-06-16T07:19:37 | 2023-06-16T07:19:37 | 165,583,253 | 0 | 0 | null | false | 2022-12-09T02:05:11 | 2019-01-14T02:37:39 | 2020-07-15T05:45:51 | 2022-12-09T02:05:10 | 28,192 | 0 | 0 | 25 |
HTML
| false | false |
package com.ssm.shop.service.inter;
import java.util.List;
import com.ssm.shop.page.PageResult;
import com.ssm.shop.pojo.PmsProductFullReduction;
public interface PmsProductFullReductionService {
List<PmsProductFullReduction> listPmsProductFullReduction(PmsProductFullReduction pmsProductFullReduction);
PageResult listPmsProductFullReductionByPage(PmsProductFullReduction pmsProductFullReduction);
int selectCount(PmsProductFullReduction pmsProductFullReduction);
void savePmsProductFullReduction(PmsProductFullReduction pmsProductFullReduction);
void deletePmsProductFullReduction(long id);
void updatePmsProductFullReduction(PmsProductFullReduction pmsProductFullReduction);
PmsProductFullReduction getPmsProductFullReduction(long id);
}
|
UTF-8
|
Java
| 757 |
java
|
PmsProductFullReductionService.java
|
Java
|
[] | null |
[] |
package com.ssm.shop.service.inter;
import java.util.List;
import com.ssm.shop.page.PageResult;
import com.ssm.shop.pojo.PmsProductFullReduction;
public interface PmsProductFullReductionService {
List<PmsProductFullReduction> listPmsProductFullReduction(PmsProductFullReduction pmsProductFullReduction);
PageResult listPmsProductFullReductionByPage(PmsProductFullReduction pmsProductFullReduction);
int selectCount(PmsProductFullReduction pmsProductFullReduction);
void savePmsProductFullReduction(PmsProductFullReduction pmsProductFullReduction);
void deletePmsProductFullReduction(long id);
void updatePmsProductFullReduction(PmsProductFullReduction pmsProductFullReduction);
PmsProductFullReduction getPmsProductFullReduction(long id);
}
| 757 | 0.877147 | 0.877147 | 23 | 31.956522 | 35.646183 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.782609 | false | false |
3
|
5dbb1f69470470d189c152b7e0b791c1ebf0d967
| 17,703,855,253,534 |
1b916e5292c943fbe3e6d3e70102af445eb6edef
|
/Algoritimos_de_Ordenação/src/MergeSort.java
|
2f0ee1fd3a12eda44e9956bf82f56e2be838fb8e
|
[] |
no_license
|
YuriAlli/Algoritimos_de_Ordenacao
|
https://github.com/YuriAlli/Algoritimos_de_Ordenacao
|
c8d8390048fc3fc86e213b877e8c8be97da938e1
|
9995c4b69d5fa5099f5ca4c61c9c2e94eb6da904
|
refs/heads/master
| 2018-04-15T03:18:45.757000 | 2017-05-05T16:51:15 | 2017-05-05T16:51:15 | 90,397,304 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class MergeSort {
public static void ordena(int[] vetor) {
long tempoInicial = System.nanoTime();//Marca o tempo inicial para a ordenação do vetor
int[] v = mergeSort(vetor);
long tempoFinal = System.nanoTime();//Marca o tempo final para a ordenação do vetor
System.out.printf(" o sistema ordenou o vetor em %.0f nano segundos%n", (tempoFinal - tempoInicial) / 1d);
/* //se deseja ver o arranjo ordenado retirar comentarios da linha 14 e 19
for (int i = 0; i < v.length; i++) {
System.out.print(v[i] + " - ");
}
System.out.println();
*/
}
public static int[] mergeSort(int[] vetor) {
if (vetor.length <= 1) {
return vetor;
}
int meio = vetor.length / 2;
int[] left = new int[meio];
int[] right;
if (vetor.length % 2 == 0) {
right = new int[meio];
} else {
right = new int[meio + 1];
}
int[] result = new int[vetor.length];
for (int i = 0; i < meio; i++) {
left[i] = vetor[i];
}
int x = 0;
for (int j = meio; j < vetor.length; j++) {
if (x < right.length) {
right[x] = vetor[j];
x++;
}
}
left = mergeSort(left);
right = mergeSort(right); //ordenação por recursividade
result = merge(left, right);
return result;
}
public static int[] merge(int[] left, int[] right) {
int lengthResult = left.length + right.length;
int[] result = new int[lengthResult];
int indexL = 0;
int indexR = 0;
int indexRes = 0;
while (indexL < left.length || indexR < right.length) {
if (indexL < left.length && indexR < right.length) {
if (left[indexL] <= right[indexR]) {
result[indexRes] = left[indexL];
indexL++;
indexRes++;
} else {
result[indexRes] = right[indexR];
indexL++;
indexRes++;
}
} else if (indexL < left.length) {
result[indexRes] = left[indexL];
indexL++;
indexRes++;
} else if (indexR < right.length) {
result[indexRes] = right[indexR];
indexR++;
indexRes++;
}
}
return result;
}
}
|
UTF-8
|
Java
| 2,559 |
java
|
MergeSort.java
|
Java
|
[] | null |
[] |
public class MergeSort {
public static void ordena(int[] vetor) {
long tempoInicial = System.nanoTime();//Marca o tempo inicial para a ordenação do vetor
int[] v = mergeSort(vetor);
long tempoFinal = System.nanoTime();//Marca o tempo final para a ordenação do vetor
System.out.printf(" o sistema ordenou o vetor em %.0f nano segundos%n", (tempoFinal - tempoInicial) / 1d);
/* //se deseja ver o arranjo ordenado retirar comentarios da linha 14 e 19
for (int i = 0; i < v.length; i++) {
System.out.print(v[i] + " - ");
}
System.out.println();
*/
}
public static int[] mergeSort(int[] vetor) {
if (vetor.length <= 1) {
return vetor;
}
int meio = vetor.length / 2;
int[] left = new int[meio];
int[] right;
if (vetor.length % 2 == 0) {
right = new int[meio];
} else {
right = new int[meio + 1];
}
int[] result = new int[vetor.length];
for (int i = 0; i < meio; i++) {
left[i] = vetor[i];
}
int x = 0;
for (int j = meio; j < vetor.length; j++) {
if (x < right.length) {
right[x] = vetor[j];
x++;
}
}
left = mergeSort(left);
right = mergeSort(right); //ordenação por recursividade
result = merge(left, right);
return result;
}
public static int[] merge(int[] left, int[] right) {
int lengthResult = left.length + right.length;
int[] result = new int[lengthResult];
int indexL = 0;
int indexR = 0;
int indexRes = 0;
while (indexL < left.length || indexR < right.length) {
if (indexL < left.length && indexR < right.length) {
if (left[indexL] <= right[indexR]) {
result[indexRes] = left[indexL];
indexL++;
indexRes++;
} else {
result[indexRes] = right[indexR];
indexL++;
indexRes++;
}
} else if (indexL < left.length) {
result[indexRes] = left[indexL];
indexL++;
indexRes++;
} else if (indexR < right.length) {
result[indexRes] = right[indexR];
indexR++;
indexRes++;
}
}
return result;
}
}
| 2,559 | 0.461026 | 0.454367 | 92 | 26.73913 | 23.932364 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.543478 | false | false |
3
|
e3bfb370955e43db0b0dd9bb0ca69d2ca907b8e4
| 37,744,172,599,787 |
8b357c2430c3a109e324ed38674960b37ef99fd5
|
/client/src/main/java/com/farm/scripts/woodcutter/strategy/ge/GrandExchangeListener.java
|
838514e438f388ebb12c8cd3536de2ddbd51d9d6
|
[] |
no_license
|
iant89/ibot
|
https://github.com/iant89/ibot
|
95f8dc4693b8ccc05d94fce7372c8dd6f544609e
|
973d10b1ef44b3bf5de970907fbbc2def6b51368
|
refs/heads/master
| 2023-05-27T00:44:31.396000 | 2021-06-20T01:42:43 | 2021-06-20T01:42:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.farm.scripts.woodcutter.strategy.ge;
import com.farm.ibot.api.data.Skill;
import com.farm.ibot.api.data.definition.ItemDefinition;
import com.farm.ibot.api.methods.Inventory;
import com.farm.ibot.api.methods.banking.Bank;
import com.farm.ibot.api.methods.banking.GrandExchangeOffer;
import com.farm.ibot.api.util.Debug;
import com.farm.ibot.api.util.Time;
import com.farm.ibot.api.wrapper.item.Item;
import com.farm.ibot.core.script.Strategy;
import com.farm.scripts.woodcutter.ChopSettings;
import com.farm.scripts.woodcutter.Chopper;
import com.farm.scripts.woodcutter.Strategies;
public class GrandExchangeListener extends Strategy {
public static final String[] REQUIRED_AXES = new String[]{"Bronze axe", "Iron axe", "Steel axe", "Mithril axe", "Adamant axe", "Rune axe"};
public static final int[] REQUIRED_LVLS = new int[]{1, 1, 6, 21, 31, 41};
public boolean active() {
return true;
}
public void onAction() {
if (!ChopSettings.powerChopping && (Inventory.container().contains("Rune axe") || Bank.getCache().contains("Rune axe") || new GrandExchangeOffer(new Item(ItemDefinition.forName("Rune axe").id, 0), 0, false).findGrandExchangeItem() != null)) {
Strategies.muleManager.wealthToKeep = 0;
return;
}
if (Bank.isOpen()) {
int i = GrandExchangeListener.REQUIRED_AXES.length - 1;
while (i >= 0) {
if (Skill.WOODCUTTING.getRealLevel() >= GrandExchangeListener.REQUIRED_LVLS[i]) {
Debug.log((Object) ("axe check " + GrandExchangeListener.REQUIRED_AXES[i]));
final int finalI = i;
if (Time.sleep(2500, () -> Inventory.container().contains(GrandExchangeListener.REQUIRED_AXES[finalI])) || Time.sleep(2500, () -> Bank.getContainer().contains(GrandExchangeListener.REQUIRED_AXES[finalI]))) {
break;
}
if (Bank.getContainer().getCount(new int[]{995}) + Inventory.getCount(995) >= 4000) {
Debug.log((Object) ("No axe GE: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe GE: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe GE: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe GE: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe GE: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe GE: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Chopper.get().setCurrentlyExecutitng(Strategies.GRAND_EXCHANGE);
return;
}
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Strategies.muleManager.activateResupplyState();
} else {
--i;
}
}
}
}
}
|
UTF-8
|
Java
| 3,799 |
java
|
GrandExchangeListener.java
|
Java
|
[] | null |
[] |
package com.farm.scripts.woodcutter.strategy.ge;
import com.farm.ibot.api.data.Skill;
import com.farm.ibot.api.data.definition.ItemDefinition;
import com.farm.ibot.api.methods.Inventory;
import com.farm.ibot.api.methods.banking.Bank;
import com.farm.ibot.api.methods.banking.GrandExchangeOffer;
import com.farm.ibot.api.util.Debug;
import com.farm.ibot.api.util.Time;
import com.farm.ibot.api.wrapper.item.Item;
import com.farm.ibot.core.script.Strategy;
import com.farm.scripts.woodcutter.ChopSettings;
import com.farm.scripts.woodcutter.Chopper;
import com.farm.scripts.woodcutter.Strategies;
public class GrandExchangeListener extends Strategy {
public static final String[] REQUIRED_AXES = new String[]{"Bronze axe", "Iron axe", "Steel axe", "Mithril axe", "Adamant axe", "Rune axe"};
public static final int[] REQUIRED_LVLS = new int[]{1, 1, 6, 21, 31, 41};
public boolean active() {
return true;
}
public void onAction() {
if (!ChopSettings.powerChopping && (Inventory.container().contains("Rune axe") || Bank.getCache().contains("Rune axe") || new GrandExchangeOffer(new Item(ItemDefinition.forName("Rune axe").id, 0), 0, false).findGrandExchangeItem() != null)) {
Strategies.muleManager.wealthToKeep = 0;
return;
}
if (Bank.isOpen()) {
int i = GrandExchangeListener.REQUIRED_AXES.length - 1;
while (i >= 0) {
if (Skill.WOODCUTTING.getRealLevel() >= GrandExchangeListener.REQUIRED_LVLS[i]) {
Debug.log((Object) ("axe check " + GrandExchangeListener.REQUIRED_AXES[i]));
final int finalI = i;
if (Time.sleep(2500, () -> Inventory.container().contains(GrandExchangeListener.REQUIRED_AXES[finalI])) || Time.sleep(2500, () -> Bank.getContainer().contains(GrandExchangeListener.REQUIRED_AXES[finalI]))) {
break;
}
if (Bank.getContainer().getCount(new int[]{995}) + Inventory.getCount(995) >= 4000) {
Debug.log((Object) ("No axe GE: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe GE: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe GE: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe GE: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe GE: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe GE: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Chopper.get().setCurrentlyExecutitng(Strategies.GRAND_EXCHANGE);
return;
}
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Debug.log((Object) ("No axe: " + GrandExchangeListener.REQUIRED_AXES[finalI]));
Strategies.muleManager.activateResupplyState();
} else {
--i;
}
}
}
}
}
| 3,799 | 0.60358 | 0.595157 | 64 | 58.359375 | 49.53672 | 250 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.953125 | false | false |
3
|
159638bdf43b266340c0512657fd5dc1f3a3f427
| 35,579,509,105,116 |
e3c2605274515c0beb8e2fc3b66a726d3a662038
|
/app/src/main/java/com/example/tomaszmajdan/pracainzynierska/ClinicDoctors/MyDoctorsActivity.java
|
2e0f253878a2ddd2bd8eb8821142e8c42616a3af
|
[] |
no_license
|
TMajdan/PracaInzynierska
|
https://github.com/TMajdan/PracaInzynierska
|
96e71ce2fc77fd89b7379d0c9e9ae7474d7855ac
|
36aec01880e672c0767995197dd4324f07080d52
|
refs/heads/master
| 2021-01-19T13:06:00.126000 | 2017-12-18T16:26:21 | 2017-12-18T16:26:21 | 100,819,816 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.tomaszmajdan.pracainzynierska.ClinicDoctors;
import android.app.Activity;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.Display;
import android.widget.ListView;
import com.example.tomaszmajdan.pracainzynierska.R;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class MyDoctorsActivity extends Activity {
//final static String DB_URL= "https://pracainzynierska-f1b54.firebaseio.com/visits/" + MainActivity.userID;
final static String DB_URL= "https://pracainzynierska-dd3c1.firebaseio.com/doctors";
ListView listView;
FirebaseDoctors firebaseClient;
static Dialog dialog;
protected Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_visit2);
//Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
listView=(ListView)findViewById(R.id.listview);
firebaseClient= new FirebaseDoctors(this, DB_URL,listView);
firebaseClient.refreshdataVisits();
dialog=new Dialog(MyDoctorsActivity.this);
}
}
|
UTF-8
|
Java
| 2,242 |
java
|
MyDoctorsActivity.java
|
Java
|
[
{
"context": "package com.example.tomaszmajdan.pracainzynierska.ClinicDoctors;\n\nimport android.a",
"end": 32,
"score": 0.9028072357177734,
"start": 20,
"tag": "USERNAME",
"value": "tomaszmajdan"
},
{
"context": "port android.widget.ListView;\n\nimport com.example.tomaszmajdan.pracainzynierska.R;\n\nimport java.io.File;\nimport ",
"end": 1150,
"score": 0.984765350818634,
"start": 1138,
"tag": "USERNAME",
"value": "tomaszmajdan"
}
] | null |
[] |
package com.example.tomaszmajdan.pracainzynierska.ClinicDoctors;
import android.app.Activity;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.Display;
import android.widget.ListView;
import com.example.tomaszmajdan.pracainzynierska.R;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class MyDoctorsActivity extends Activity {
//final static String DB_URL= "https://pracainzynierska-f1b54.firebaseio.com/visits/" + MainActivity.userID;
final static String DB_URL= "https://pracainzynierska-dd3c1.firebaseio.com/doctors";
ListView listView;
FirebaseDoctors firebaseClient;
static Dialog dialog;
protected Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_visit2);
//Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
listView=(ListView)findViewById(R.id.listview);
firebaseClient= new FirebaseDoctors(this, DB_URL,listView);
firebaseClient.refreshdataVisits();
dialog=new Dialog(MyDoctorsActivity.this);
}
}
| 2,242 | 0.793042 | 0.790366 | 77 | 28.129869 | 22.916195 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.688312 | false | false |
3
|
9c77cd885743cdd904d85090806f312d2c5fb9a5
| 11,166,915,013,058 |
5a2f36d251fcee4e15b9f5f8de5438a5912133c2
|
/Source/android/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/DisplayController.java
|
8a0920bcce80f221854e505b9c155207f030b61b
|
[] |
no_license
|
zhang873/CubieBoard2
|
https://github.com/zhang873/CubieBoard2
|
569cd676740d0024b7af8ca01a735f2f804af4bc
|
a3bd1d4f4c834fda7f6618ccfbae01bcd87dc939
|
refs/heads/master
| 2021-01-10T01:42:00.565000 | 2016-02-05T02:43:37 | 2016-02-05T02:43:37 | 51,121,197 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.statusbar.policy;
import java.util.ArrayList;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.util.Slog;
import android.widget.ImageView;
import android.widget.TextView;
import android.view.DisplayManagerAw;
import com.android.systemui.statusbar.policy.DisplayHotPlugPolicy;
import android.media.MediaPlayer;
import android.media.AudioSystem;
import android.media.AudioManager;
import com.android.systemui.R;
import android.os.SystemProperties;
import android.provider.Settings;
/* add by Gary. start {{----------------------------------- */
/* 2012-01-29 */
/* add a new function 'getProductName()' in ProducSpec and define some produects' names */
import android.widget.Toast;
import android.view.LayoutInflater;
import android.view.Gravity;
import android.view.DispList;
import android.provider.Settings;
import android.view.View;
import android.os.Handler;
/* add by Gary. end -----------------------------------}} */
import android.database.ContentObserver;
import android.net.Uri;
public class DisplayController extends BroadcastReceiver {
private static final String TAG = "StatusBar.DisplayController";
private Context mContext;
private final DisplayManagerAw mDisplayManager;
private DisplayHotPlugPolicy mDispHotPolicy = null;
private static final boolean SHOW_HDMIPLUG_IN_CALL = true;
private static final boolean SHOW_TVPLUG_IN_CALL = true;
/* add by Gary. start {{----------------------------------- */
/* 2011-12-19 */
/* handle the plug in and out of the display cables */
private final boolean mDeviceHasYpbpr = false;
private HotPlugToast mToast = null;
private boolean mBootCompleted = false;
private boolean mHdmiIsConnected = false;
private boolean mCvbsIsConnected = false;
private boolean mYpbprIsConnected = false;
private boolean mIsStandby = false;
private String mChipType = null;
private Runnable mSetStandbyState = new Runnable() {
public void run(){
mIsStandby = false;
}
};
private final Handler mHandler = new Handler();
/* ¼àÌýpass throughµÄÉèÖñ仯 */
private ContentObserver mContentObserver = new ContentObserver(mHandler){
@Override
public void onChange(boolean selfChange, Uri uri) {
AudioManager mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
ArrayList<String> list = mAudioManager
.getActiveAudioDevices(AudioManager.AUDIO_OUTPUT_ACTIVE);
mAudioManager.setAudioDeviceActive(list, AudioManager.AUDIO_OUTPUT_ACTIVE);
}
};
/* add by Gary. end -----------------------------------}} */
public DisplayController(Context context) {
mContext = context;
mDisplayManager = (DisplayManagerAw) mContext.getSystemService(Context.DISPLAY_SERVICE_AW);
mDispHotPolicy = new HomletHotPlug();
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_HDMISTATUS_CHANGED);
filter.addAction(Intent.ACTION_TVDACSTATUS_CHANGED);
/* add by Gary. start {{----------------------------------- */
/* 2011-12-19 */
/* handle the plug in and out of the display cables */
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_BOOT_COMPLETED);
/* add by Gary. end -----------------------------------}} */
context.registerReceiver(this, filter);
/* add by Gary. start {{----------------------------------- */
/* 2011-12-19 */
/* handle the plug in and out of the display cables */
mToast = new HotPlugToast(mContext);
/* init display cables' connection status */
if (mDisplayManager.getHdmiHotPlugStatus() != 0)
mHdmiIsConnected = true;
int tvStatus = mDisplayManager.getTvHotPlugStatus();
Slog.d(TAG, "tv connect status = " + tvStatus);
if (tvStatus == DisplayManagerAw.DISPLAY_TVDAC_CVBS)
mCvbsIsConnected = true;
else if (tvStatus == DisplayManagerAw.DISPLAY_TVDAC_YPBPR)
mYpbprIsConnected = true;
else if (tvStatus == DisplayManagerAw.DISPLAY_TVDAC_ALL) {
mCvbsIsConnected = true;
mYpbprIsConnected = true;
}
/* add by Gary. end -----------------------------------}} */
mContext.getContentResolver().registerContentObserver(
Settings.System.getUriFor(Settings.System.ENABLE_PASS_THROUGH),
true, mContentObserver);
}
public void onReceive(Context context, Intent intent)
{
final String action = intent.getAction();
if (action.equals(Intent.ACTION_HDMISTATUS_CHANGED))
{
mDispHotPolicy.onHdmiPlugChanged(intent);
}
else if(action.equals(Intent.ACTION_TVDACSTATUS_CHANGED))
{
mDispHotPolicy.onTvDacPlugChanged(intent);
}
/* add by Gary. start {{----------------------------------- */
/* 2011-12-19 */
/* handle the plug in and out of the display cables */
else if (action.equals(Intent.ACTION_BOOT_COMPLETED))
{
mBootCompleted = true;
}
else if (action.equals(Intent.ACTION_SCREEN_ON)) {
mHandler.postDelayed(mSetStandbyState, 3000);
}else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
mHandler.removeCallbacks(mSetStandbyState);
mIsStandby = true;
}
/* add by Gary. end -----------------------------------}} */
}
private class StatusBarPadHotPlug implements DisplayHotPlugPolicy
{
//0:screen0 fix;
//3:screen0 fix,screen1 auto,(same ui,one video on screen1);
//4:screen0 fix,screen1 auto,(same ui,two video);
//5:screen0 auto(ui use fe)
//6:screen0 auto(ui use be)
//7:screen0 auto(fb var)
//8:screen0 auto(ui use be ,use gpu scaler)
public int mDisplay_mode = 3;
public int mHdmiPlugin = -1;
public int mTvPlugin = -1;
StatusBarPadHotPlug()
{
}
private void onHdmiPlugIn(Intent intent)
{
int maxscreen;
int maxhdmimode;
int customhdmimode;
int hdmi_mode;
int AUTO_HDMI_MODE = 0xff;
int MIN_HDMI_MODE = 0;
if (SHOW_HDMIPLUG_IN_CALL)
{
Slog.d(TAG,"onHdmiPlugIn Starting!\n");
if(mDisplay_mode == 4)
{
hdmi_mode = DisplayManagerAw.DISPLAY_TVFORMAT_1080P_60HZ;//zhangxc modify
}
else
{
/*customhdmimode = Settings.System.getInt(mContext.getContentResolver(), Settings.System.HDMI_OUTPUT_MODE, AUTO_HDMI_MODE);
maxhdmimode = mDisplayManager.getMaxHdmiMode();
if (customhdmimode < AUTO_HDMI_MODE) {
hdmi_mode = customhdmimode;
} else {
hdmi_mode = maxhdmimode;
}*/
hdmi_mode = mDisplayManager.getMaxHdmiMode();
}
if(mDisplay_mode == 3)
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI,hdmi_mode);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_DUALSAME);
}
else if(mDisplay_mode == 4)
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI,hdmi_mode);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_DUALSAME_TWO_VIDEO);
}
else if(mDisplay_mode == 5)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI,hdmi_mode);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR);
}
else if(mDisplay_mode == 6)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI,hdmi_mode);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR_BE);
}
else if(mDisplay_mode == 7)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI,hdmi_mode);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_FB_VAR);
}
else if(mDisplay_mode == 8)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI,hdmi_mode);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_FB_GPU);
}
}
}
private void onTvDacYPbPrPlugIn(Intent intent)
{
if(mDisplay_mode == 3)
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_720P_50HZ);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_DUALSAME);
}
else if(mDisplay_mode == 4)
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_720P_50HZ);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_DUALSAME_TWO_VIDEO);
}
else if(mDisplay_mode == 5)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_720P_50HZ);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR);
}
else if(mDisplay_mode == 6)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_720P_50HZ);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR_BE);
}
}
private void onTvDacCVBSPlugIn(Intent intent)
{
if(mDisplay_mode == 3)
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_NTSC);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_DUALSAME);
}
else if(mDisplay_mode == 4)
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_NTSC);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_DUALSAME_TWO_VIDEO);
}
else if(mDisplay_mode == 5)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_NTSC);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR);
}
else if(mDisplay_mode == 6)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_NTSC);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR_BE);
}
}
private void onHdmiPlugOut(Intent intent)
{
int maxscreen;
Slog.d(TAG,"onHdmiPlugOut Starting!\n");
if((mDisplay_mode == 3) || (mDisplay_mode == 4))
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_NONE,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE);
}
else if(mDisplay_mode == 5)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_LCD,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR);
}
else if(mDisplay_mode == 6)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_LCD,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR_BE);
}
else if(mDisplay_mode == 7)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_LCD,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_FB_VAR);
}
else if(mDisplay_mode == 8)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_LCD,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_FB_GPU);
}
}
private void onTvDacPlugOut(Intent intent)
{
Slog.d(TAG,"onTvDacPlugOut Starting!\n");
if((mDisplay_mode == 3) || (mDisplay_mode == 4))
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_NONE,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE);
}
else if(mDisplay_mode == 5)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_LCD,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR);
}
else if(mDisplay_mode == 6)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_LCD,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR_BE);
}
}
public void onHdmiPlugChanged(Intent intent)
{
int hdmiplug;
hdmiplug = intent.getIntExtra(DisplayManagerAw.EXTRA_HDMISTATUS, 0);
if(hdmiplug != mHdmiPlugin)
{
if(hdmiplug == 1)
{
onHdmiPlugIn(intent);
}
else
{
onHdmiPlugOut(intent);
}
mHdmiPlugin = hdmiplug;
}
/*if(hdmiplug == 1)
{
onHdmiPlugIn(intent);
}
else
{
onHdmiPlugOut(intent);
}*/
}
public void onTvDacPlugChanged(Intent intent)
{
int tvdacplug;
tvdacplug = intent.getIntExtra(DisplayManagerAw.EXTRA_TVSTATUS, 0);
if(tvdacplug != mTvPlugin)
{
if(tvdacplug == 1)
{
onTvDacYPbPrPlugIn(intent);
}
else if(tvdacplug == 2)
{
onTvDacCVBSPlugIn(intent);
}
else
{
onTvDacPlugOut(intent);
}
mTvPlugin = tvdacplug;
}
/*if(tvdacplug == 1)
{
onTvDacYPbPrPlugIn(intent);
}
else if(tvdacplug == 2)
{
onTvDacCVBSPlugIn(intent);
}
else
{
onTvDacPlugOut(intent);
}*/
}
}
/* add by Gary. start {{----------------------------------- */
/* 2011-12-19 */
/* handle the plug in and out of the display cables */
private class HomletHotPlug implements DisplayHotPlugPolicy
{
HomletHotPlug()
{
}
public void onHdmiPlugChanged(Intent intent)
{
Slog.d(TAG, "onHdmiPlugChanged and mIsStandby is = " + mIsStandby);
if(!mIsStandby){
int hdmiplug;
hdmiplug = intent.getIntExtra(DisplayManagerAw.EXTRA_HDMISTATUS, 0);
if (hdmiplug == 1) {
if(mBootCompleted)
onHdmiPlugIn(intent);
mHdmiIsConnected = true;
} else {
if(mBootCompleted)
onHdmiPlugOut(intent);
mHdmiIsConnected = false;
}
}
}
public void onTvDacPlugChanged(Intent intent)
{
Slog.d(TAG, "onTvDacPlugChanged and mIsStandby is = " + mIsStandby);
if(!mIsStandby){
int tvStatus;
tvStatus = intent.getIntExtra(DisplayManagerAw.EXTRA_TVSTATUS, 0);
Slog.d(TAG, "tvStatus = " + tvStatus);
boolean cvbsIsConnected = false;
boolean ypbprIsConnected = false;
if(tvStatus == DisplayManagerAw.DISPLAY_TVDAC_CVBS)
cvbsIsConnected = true;
else if(tvStatus == DisplayManagerAw.DISPLAY_TVDAC_YPBPR)
ypbprIsConnected = true;
else if(tvStatus == DisplayManagerAw.DISPLAY_TVDAC_ALL){
cvbsIsConnected = true;
ypbprIsConnected = true;
}
if(mBootCompleted){
if(!mCvbsIsConnected && cvbsIsConnected)
onTvDacCVBSPlugIn(intent);
if(mCvbsIsConnected && !cvbsIsConnected)
onTvDacCVBSPlugOut(intent);
if(!mYpbprIsConnected && ypbprIsConnected && mDeviceHasYpbpr)
onTvDacYPBPRPlugIn(intent);
if(mYpbprIsConnected && !ypbprIsConnected && mDeviceHasYpbpr)
onTvDacYPBPRPlugOut(intent);
}
mCvbsIsConnected = cvbsIsConnected;
mYpbprIsConnected = ypbprIsConnected;
}
}
private void onHdmiPlugIn(Intent intent)
{
if (SHOW_HDMIPLUG_IN_CALL) {
Slog.d(TAG,"onHdmiPlugIn Starting!\n");
int curType = mDisplayManager.getDisplayOutputType(0);
if(curType != DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI){
mToast.setText(com.android.internal.R.string.hdmi_plug_in);
mToast.setOnHideListener(mHDMIPlugInToastOnHide);
mToast.setDuration(Toast.LENGTH_LONG);
mToast.show();
}
}
}
private void onTvDacVGAPlugIn(Intent intent)
{
if (SHOW_TVPLUG_IN_CALL) {
Slog.d(TAG,"onTvDacVGAPlugIn Starting!\n");
int hdmiConnect = mDisplayManager.getHdmiHotPlugStatus();
int tvdacConnect = mDisplayManager.getTvHotPlugStatus();
if(!mHdmiIsConnected && !mCvbsIsConnected){
switchDisplayOutput(DispList.VGA_DEFAULT_FORMAT.mOutputType,
DispList.VGA_DEFAULT_FORMAT.mFormat);
}else {
mToast.setText(com.android.internal.R.string.vga_plug_in);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
}
private void onTvDacYPBPRPlugIn(Intent intent)
{
if (SHOW_TVPLUG_IN_CALL) {
Slog.d(TAG,"onTvDacYPBPRPlugIn Starting!\n");
int hdmiConnect = mDisplayManager.getHdmiHotPlugStatus();
int tvdacConnect = mDisplayManager.getTvHotPlugStatus();
if(!mHdmiIsConnected && !mCvbsIsConnected){
switchDisplayOutput(DispList.YPBPR_DEFAULT_FORMAT.mOutputType,
DispList.YPBPR_DEFAULT_FORMAT.mFormat);
}else {
mToast.setText(com.android.internal.R.string.ypbpr_plug_in);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
}
private void onTvDacCVBSPlugIn(Intent intent)
{
if (SHOW_TVPLUG_IN_CALL) {
Slog.d(TAG,"onCvbsPlugIn Starting!\n");
int hdmiConnect = mDisplayManager.getHdmiHotPlugStatus();
int tvdacConnect = mDisplayManager.getTvHotPlugStatus();
Slog.d(TAG, "hdmiConnect = " + hdmiConnect + "tvdacConnect = " + tvdacConnect);
if(!mHdmiIsConnected && !mYpbprIsConnected){
switchDisplayOutput(DispList.CVBS_DEFAULT_FORMAT.mOutputType,
DispList.CVBS_DEFAULT_FORMAT.mFormat);
}else {
mToast.setText(com.android.internal.R.string.cvbs_plug_in);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
}
private void onHdmiPlugOut(Intent intent)
{
if (SHOW_HDMIPLUG_IN_CALL) {
Slog.d(TAG,"onHdmiPlugOut Starting!\n");
int curType = mDisplayManager.getDisplayOutputType(0);
if(curType == DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI){
DispList.DispFormat format = null;
Slog.v(TAG,"Cvbs " + mCvbsIsConnected + ";Ypbpr " + mYpbprIsConnected);
if(mCvbsIsConnected){
format = DispList.CVBS_DEFAULT_FORMAT;
}else if(mYpbprIsConnected){
format = DispList.VGA_DEFAULT_FORMAT;
}
if(format != null){
switchDisplayOutput(format.mOutputType, format.mFormat);
}
}else{
mToast.setText(com.android.internal.R.string.hdmi_plug_out);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
}
private void onTvDacCVBSPlugOut(Intent intent)
{
if (SHOW_TVPLUG_IN_CALL)
{
Slog.d(TAG,"onCvbsPlugOut Starting!\n");
int curType = mDisplayManager.getDisplayOutputType(0);
if(curType == DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV){
DispList.DispFormat format = null;
Slog.v(TAG,"Cvbs " + mCvbsIsConnected + ";Ypbpr " + mYpbprIsConnected);
if(mHdmiIsConnected){
format = DispList.HDMI_DEFAULT_FORMAT;
}else if(mYpbprIsConnected){
format = DispList.VGA_DEFAULT_FORMAT;
}
if(format != null){
switchDisplayOutput(format.mOutputType, format.mFormat);
}
}else{
mToast.setText(com.android.internal.R.string.cvbs_plug_out);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
}
private void onTvDacVGAPlugOut(Intent intent)
{
if (SHOW_TVPLUG_IN_CALL)
{
Slog.d(TAG,"onVgaPlugOut Starting!\n");
int curType = mDisplayManager.getDisplayOutputType(0);
if(curType != DisplayManagerAw.DISPLAY_OUTPUT_TYPE_VGA){
mToast.setText(com.android.internal.R.string.vga_plug_out);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
}
private void onTvDacYPBPRPlugOut(Intent intent)
{
if (SHOW_TVPLUG_IN_CALL)
{
Slog.d(TAG,"onypbprPlugOut Starting!\n");
mToast.setText(com.android.internal.R.string.ypbpr_plug_out);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
private void switchDisplayOutput(int type, int format){
/* switch display output format */
Slog.d(TAG, "switch diplay to " + DispList.ItemCode2Name(new DispList.DispFormat(type, format)));
//mDisplayManager.setDisplayOutputType(0, type, format);
mDisplayManager.setDisplayParameter(0,type,format);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_FB_GPU);
/* record the display output format */
Settings.System.putString(mContext.getContentResolver(), Settings.System.DISPLY_OUTPUT_FORMAT,
DispList.ItemCode2Name(new DispList.DispFormat(type, format)));
/* switch audio output mode in the same time */
ArrayList<String> channel = new ArrayList<String>();
if(type == DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI){
channel.add(AudioManager.AUDIO_NAME_HDMI);
}else{
channel.add(AudioManager.AUDIO_NAME_CODEC);
}
AudioManager mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
mAudioManager.setAudioDeviceActive(channel,AudioManager.AUDIO_OUTPUT_ACTIVE);
}
private OnHideListener mHDMIPlugInToastOnHide = new OnHideListener(){
public void onHide(){
switchDisplayOutput(DispList.HDMI_DEFAULT_FORMAT.mOutputType, DispList.HDMI_DEFAULT_FORMAT.mFormat);
}
};
}
interface OnHideListener {
public void onHide();
}
private class HotPlugToast extends Toast{
public HotPlugToast(Context context){
super(context);
LayoutInflater inflate = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflate.inflate(com.android.internal.R.layout.transient_notification, null);
super.setGravity(Gravity.CENTER, 0, 0 );
super.setView(v);
super.setDuration(Toast.LENGTH_LONG);
}
public void setOnHideListener(OnHideListener listener){
mOnHideListener = listener;
}
public void onHide(){
Slog.d(TAG, "on Hide in HotPlugToast.\n");
if(mOnHideListener != null)
mOnHideListener.onHide();
}
private OnHideListener mOnHideListener = null;
}
/* add by Gary. end -----------------------------------}} */
private class StatusBarTVDHotPlug implements DisplayHotPlugPolicy
{
StatusBarTVDHotPlug()
{
}
public void onHdmiPlugChanged(Intent intent)
{
}
public void onTvDacPlugChanged(Intent intent)
{
}
}
}
|
WINDOWS-1252
|
Java
| 28,163 |
java
|
DisplayController.java
|
Java
|
[
{
"context": "ties;\nimport android.provider.Settings;\n\n/* add by Gary. start {{----------------------------------- */\n/",
"end": 1289,
"score": 0.9988278746604919,
"start": 1285,
"tag": "NAME",
"value": "Gary"
},
{
"context": "id.view.View;\nimport android.os.Handler;\n/* add by Gary. end -----------------------------------}} */\ni",
"end": 1671,
"score": 0.8102163076400757,
"start": 1667,
"tag": "NAME",
"value": "Gary"
},
{
"context": " boolean SHOW_TVPLUG_IN_CALL = true;\n /* add by Gary. start {{----------------------------------- */\n ",
"end": 2197,
"score": 0.9992024898529053,
"start": 2193,
"tag": "NAME",
"value": "Gary"
},
{
"context": "UTPUT_ACTIVE);\n }\n\n };\n /* add by Gary. end -----------------------------------}} */\n\n",
"end": 3550,
"score": 0.9985542297363281,
"start": 3546,
"tag": "NAME",
"value": "Gary"
},
{
"context": "ent.ACTION_TVDACSTATUS_CHANGED);\n /* add by Gary. start {{----------------------------------- */\n ",
"end": 4017,
"score": 0.9992601871490479,
"start": 4013,
"tag": "NAME",
"value": "Gary"
},
{
"context": "n(Intent.ACTION_BOOT_COMPLETED);\n /* add by Gary. end -----------------------------------}} */\n ",
"end": 4335,
"score": 0.9982238411903381,
"start": 4331,
"tag": "NAME",
"value": "Gary"
},
{
"context": "registerReceiver(this, filter);\n\n /* add by Gary. start {{----------------------------------- */\n ",
"end": 4455,
"score": 0.999092698097229,
"start": 4451,
"tag": "NAME",
"value": "Gary"
},
{
"context": "bprIsConnected = true;\n }\n /* add by Gary. end -----------------------------------}} */\n ",
"end": 5279,
"score": 0.9989056587219238,
"start": 5275,
"tag": "NAME",
"value": "Gary"
},
{
"context": "acPlugChanged(intent);\n }\n /* add by Gary. start {{----------------------------------- */\n ",
"end": 5937,
"score": 0.9985679984092712,
"start": 5933,
"tag": "NAME",
"value": "Gary"
},
{
"context": " mIsStandby = true;\n }\n /* add by Gary. end -----------------------------------}} */\n ",
"end": 6488,
"score": 0.9938276410102844,
"start": 6484,
"tag": "NAME",
"value": "Gary"
},
{
"context": "t);\n }*/\n }\n }\n\n /* add by Gary. start {{----------------------------------- */\n /* 2",
"end": 16508,
"score": 0.9965217113494873,
"start": 16497,
"tag": "NAME",
"value": "Gary. start"
},
{
"context": "stener mOnHideListener = null;\n }\n /* add by Gary. end -----------------------------------}} */\n ",
"end": 27816,
"score": 0.971102237701416,
"start": 27812,
"tag": "NAME",
"value": "Gary"
}
] | null |
[] |
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.statusbar.policy;
import java.util.ArrayList;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.util.Slog;
import android.widget.ImageView;
import android.widget.TextView;
import android.view.DisplayManagerAw;
import com.android.systemui.statusbar.policy.DisplayHotPlugPolicy;
import android.media.MediaPlayer;
import android.media.AudioSystem;
import android.media.AudioManager;
import com.android.systemui.R;
import android.os.SystemProperties;
import android.provider.Settings;
/* add by Gary. start {{----------------------------------- */
/* 2012-01-29 */
/* add a new function 'getProductName()' in ProducSpec and define some produects' names */
import android.widget.Toast;
import android.view.LayoutInflater;
import android.view.Gravity;
import android.view.DispList;
import android.provider.Settings;
import android.view.View;
import android.os.Handler;
/* add by Gary. end -----------------------------------}} */
import android.database.ContentObserver;
import android.net.Uri;
public class DisplayController extends BroadcastReceiver {
private static final String TAG = "StatusBar.DisplayController";
private Context mContext;
private final DisplayManagerAw mDisplayManager;
private DisplayHotPlugPolicy mDispHotPolicy = null;
private static final boolean SHOW_HDMIPLUG_IN_CALL = true;
private static final boolean SHOW_TVPLUG_IN_CALL = true;
/* add by Gary. start {{----------------------------------- */
/* 2011-12-19 */
/* handle the plug in and out of the display cables */
private final boolean mDeviceHasYpbpr = false;
private HotPlugToast mToast = null;
private boolean mBootCompleted = false;
private boolean mHdmiIsConnected = false;
private boolean mCvbsIsConnected = false;
private boolean mYpbprIsConnected = false;
private boolean mIsStandby = false;
private String mChipType = null;
private Runnable mSetStandbyState = new Runnable() {
public void run(){
mIsStandby = false;
}
};
private final Handler mHandler = new Handler();
/* ¼àÌýpass throughµÄÉèÖñ仯 */
private ContentObserver mContentObserver = new ContentObserver(mHandler){
@Override
public void onChange(boolean selfChange, Uri uri) {
AudioManager mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
ArrayList<String> list = mAudioManager
.getActiveAudioDevices(AudioManager.AUDIO_OUTPUT_ACTIVE);
mAudioManager.setAudioDeviceActive(list, AudioManager.AUDIO_OUTPUT_ACTIVE);
}
};
/* add by Gary. end -----------------------------------}} */
public DisplayController(Context context) {
mContext = context;
mDisplayManager = (DisplayManagerAw) mContext.getSystemService(Context.DISPLAY_SERVICE_AW);
mDispHotPolicy = new HomletHotPlug();
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_HDMISTATUS_CHANGED);
filter.addAction(Intent.ACTION_TVDACSTATUS_CHANGED);
/* add by Gary. start {{----------------------------------- */
/* 2011-12-19 */
/* handle the plug in and out of the display cables */
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_BOOT_COMPLETED);
/* add by Gary. end -----------------------------------}} */
context.registerReceiver(this, filter);
/* add by Gary. start {{----------------------------------- */
/* 2011-12-19 */
/* handle the plug in and out of the display cables */
mToast = new HotPlugToast(mContext);
/* init display cables' connection status */
if (mDisplayManager.getHdmiHotPlugStatus() != 0)
mHdmiIsConnected = true;
int tvStatus = mDisplayManager.getTvHotPlugStatus();
Slog.d(TAG, "tv connect status = " + tvStatus);
if (tvStatus == DisplayManagerAw.DISPLAY_TVDAC_CVBS)
mCvbsIsConnected = true;
else if (tvStatus == DisplayManagerAw.DISPLAY_TVDAC_YPBPR)
mYpbprIsConnected = true;
else if (tvStatus == DisplayManagerAw.DISPLAY_TVDAC_ALL) {
mCvbsIsConnected = true;
mYpbprIsConnected = true;
}
/* add by Gary. end -----------------------------------}} */
mContext.getContentResolver().registerContentObserver(
Settings.System.getUriFor(Settings.System.ENABLE_PASS_THROUGH),
true, mContentObserver);
}
public void onReceive(Context context, Intent intent)
{
final String action = intent.getAction();
if (action.equals(Intent.ACTION_HDMISTATUS_CHANGED))
{
mDispHotPolicy.onHdmiPlugChanged(intent);
}
else if(action.equals(Intent.ACTION_TVDACSTATUS_CHANGED))
{
mDispHotPolicy.onTvDacPlugChanged(intent);
}
/* add by Gary. start {{----------------------------------- */
/* 2011-12-19 */
/* handle the plug in and out of the display cables */
else if (action.equals(Intent.ACTION_BOOT_COMPLETED))
{
mBootCompleted = true;
}
else if (action.equals(Intent.ACTION_SCREEN_ON)) {
mHandler.postDelayed(mSetStandbyState, 3000);
}else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
mHandler.removeCallbacks(mSetStandbyState);
mIsStandby = true;
}
/* add by Gary. end -----------------------------------}} */
}
private class StatusBarPadHotPlug implements DisplayHotPlugPolicy
{
//0:screen0 fix;
//3:screen0 fix,screen1 auto,(same ui,one video on screen1);
//4:screen0 fix,screen1 auto,(same ui,two video);
//5:screen0 auto(ui use fe)
//6:screen0 auto(ui use be)
//7:screen0 auto(fb var)
//8:screen0 auto(ui use be ,use gpu scaler)
public int mDisplay_mode = 3;
public int mHdmiPlugin = -1;
public int mTvPlugin = -1;
StatusBarPadHotPlug()
{
}
private void onHdmiPlugIn(Intent intent)
{
int maxscreen;
int maxhdmimode;
int customhdmimode;
int hdmi_mode;
int AUTO_HDMI_MODE = 0xff;
int MIN_HDMI_MODE = 0;
if (SHOW_HDMIPLUG_IN_CALL)
{
Slog.d(TAG,"onHdmiPlugIn Starting!\n");
if(mDisplay_mode == 4)
{
hdmi_mode = DisplayManagerAw.DISPLAY_TVFORMAT_1080P_60HZ;//zhangxc modify
}
else
{
/*customhdmimode = Settings.System.getInt(mContext.getContentResolver(), Settings.System.HDMI_OUTPUT_MODE, AUTO_HDMI_MODE);
maxhdmimode = mDisplayManager.getMaxHdmiMode();
if (customhdmimode < AUTO_HDMI_MODE) {
hdmi_mode = customhdmimode;
} else {
hdmi_mode = maxhdmimode;
}*/
hdmi_mode = mDisplayManager.getMaxHdmiMode();
}
if(mDisplay_mode == 3)
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI,hdmi_mode);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_DUALSAME);
}
else if(mDisplay_mode == 4)
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI,hdmi_mode);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_DUALSAME_TWO_VIDEO);
}
else if(mDisplay_mode == 5)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI,hdmi_mode);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR);
}
else if(mDisplay_mode == 6)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI,hdmi_mode);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR_BE);
}
else if(mDisplay_mode == 7)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI,hdmi_mode);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_FB_VAR);
}
else if(mDisplay_mode == 8)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI,hdmi_mode);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_FB_GPU);
}
}
}
private void onTvDacYPbPrPlugIn(Intent intent)
{
if(mDisplay_mode == 3)
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_720P_50HZ);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_DUALSAME);
}
else if(mDisplay_mode == 4)
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_720P_50HZ);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_DUALSAME_TWO_VIDEO);
}
else if(mDisplay_mode == 5)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_720P_50HZ);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR);
}
else if(mDisplay_mode == 6)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_720P_50HZ);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR_BE);
}
}
private void onTvDacCVBSPlugIn(Intent intent)
{
if(mDisplay_mode == 3)
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_NTSC);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_DUALSAME);
}
else if(mDisplay_mode == 4)
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_NTSC);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_DUALSAME_TWO_VIDEO);
}
else if(mDisplay_mode == 5)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_NTSC);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR);
}
else if(mDisplay_mode == 6)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV,DisplayManagerAw.DISPLAY_TVFORMAT_NTSC);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR_BE);
}
}
private void onHdmiPlugOut(Intent intent)
{
int maxscreen;
Slog.d(TAG,"onHdmiPlugOut Starting!\n");
if((mDisplay_mode == 3) || (mDisplay_mode == 4))
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_NONE,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE);
}
else if(mDisplay_mode == 5)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_LCD,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR);
}
else if(mDisplay_mode == 6)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_LCD,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR_BE);
}
else if(mDisplay_mode == 7)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_LCD,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_FB_VAR);
}
else if(mDisplay_mode == 8)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_LCD,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_FB_GPU);
}
}
private void onTvDacPlugOut(Intent intent)
{
Slog.d(TAG,"onTvDacPlugOut Starting!\n");
if((mDisplay_mode == 3) || (mDisplay_mode == 4))
{
mDisplayManager.setDisplayParameter(1,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_NONE,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE);
}
else if(mDisplay_mode == 5)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_LCD,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR);
}
else if(mDisplay_mode == 6)
{
mDisplayManager.setDisplayParameter(0,DisplayManagerAw.DISPLAY_OUTPUT_TYPE_LCD,0);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_VAR_BE);
}
}
public void onHdmiPlugChanged(Intent intent)
{
int hdmiplug;
hdmiplug = intent.getIntExtra(DisplayManagerAw.EXTRA_HDMISTATUS, 0);
if(hdmiplug != mHdmiPlugin)
{
if(hdmiplug == 1)
{
onHdmiPlugIn(intent);
}
else
{
onHdmiPlugOut(intent);
}
mHdmiPlugin = hdmiplug;
}
/*if(hdmiplug == 1)
{
onHdmiPlugIn(intent);
}
else
{
onHdmiPlugOut(intent);
}*/
}
public void onTvDacPlugChanged(Intent intent)
{
int tvdacplug;
tvdacplug = intent.getIntExtra(DisplayManagerAw.EXTRA_TVSTATUS, 0);
if(tvdacplug != mTvPlugin)
{
if(tvdacplug == 1)
{
onTvDacYPbPrPlugIn(intent);
}
else if(tvdacplug == 2)
{
onTvDacCVBSPlugIn(intent);
}
else
{
onTvDacPlugOut(intent);
}
mTvPlugin = tvdacplug;
}
/*if(tvdacplug == 1)
{
onTvDacYPbPrPlugIn(intent);
}
else if(tvdacplug == 2)
{
onTvDacCVBSPlugIn(intent);
}
else
{
onTvDacPlugOut(intent);
}*/
}
}
/* add by <NAME> {{----------------------------------- */
/* 2011-12-19 */
/* handle the plug in and out of the display cables */
private class HomletHotPlug implements DisplayHotPlugPolicy
{
HomletHotPlug()
{
}
public void onHdmiPlugChanged(Intent intent)
{
Slog.d(TAG, "onHdmiPlugChanged and mIsStandby is = " + mIsStandby);
if(!mIsStandby){
int hdmiplug;
hdmiplug = intent.getIntExtra(DisplayManagerAw.EXTRA_HDMISTATUS, 0);
if (hdmiplug == 1) {
if(mBootCompleted)
onHdmiPlugIn(intent);
mHdmiIsConnected = true;
} else {
if(mBootCompleted)
onHdmiPlugOut(intent);
mHdmiIsConnected = false;
}
}
}
public void onTvDacPlugChanged(Intent intent)
{
Slog.d(TAG, "onTvDacPlugChanged and mIsStandby is = " + mIsStandby);
if(!mIsStandby){
int tvStatus;
tvStatus = intent.getIntExtra(DisplayManagerAw.EXTRA_TVSTATUS, 0);
Slog.d(TAG, "tvStatus = " + tvStatus);
boolean cvbsIsConnected = false;
boolean ypbprIsConnected = false;
if(tvStatus == DisplayManagerAw.DISPLAY_TVDAC_CVBS)
cvbsIsConnected = true;
else if(tvStatus == DisplayManagerAw.DISPLAY_TVDAC_YPBPR)
ypbprIsConnected = true;
else if(tvStatus == DisplayManagerAw.DISPLAY_TVDAC_ALL){
cvbsIsConnected = true;
ypbprIsConnected = true;
}
if(mBootCompleted){
if(!mCvbsIsConnected && cvbsIsConnected)
onTvDacCVBSPlugIn(intent);
if(mCvbsIsConnected && !cvbsIsConnected)
onTvDacCVBSPlugOut(intent);
if(!mYpbprIsConnected && ypbprIsConnected && mDeviceHasYpbpr)
onTvDacYPBPRPlugIn(intent);
if(mYpbprIsConnected && !ypbprIsConnected && mDeviceHasYpbpr)
onTvDacYPBPRPlugOut(intent);
}
mCvbsIsConnected = cvbsIsConnected;
mYpbprIsConnected = ypbprIsConnected;
}
}
private void onHdmiPlugIn(Intent intent)
{
if (SHOW_HDMIPLUG_IN_CALL) {
Slog.d(TAG,"onHdmiPlugIn Starting!\n");
int curType = mDisplayManager.getDisplayOutputType(0);
if(curType != DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI){
mToast.setText(com.android.internal.R.string.hdmi_plug_in);
mToast.setOnHideListener(mHDMIPlugInToastOnHide);
mToast.setDuration(Toast.LENGTH_LONG);
mToast.show();
}
}
}
private void onTvDacVGAPlugIn(Intent intent)
{
if (SHOW_TVPLUG_IN_CALL) {
Slog.d(TAG,"onTvDacVGAPlugIn Starting!\n");
int hdmiConnect = mDisplayManager.getHdmiHotPlugStatus();
int tvdacConnect = mDisplayManager.getTvHotPlugStatus();
if(!mHdmiIsConnected && !mCvbsIsConnected){
switchDisplayOutput(DispList.VGA_DEFAULT_FORMAT.mOutputType,
DispList.VGA_DEFAULT_FORMAT.mFormat);
}else {
mToast.setText(com.android.internal.R.string.vga_plug_in);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
}
private void onTvDacYPBPRPlugIn(Intent intent)
{
if (SHOW_TVPLUG_IN_CALL) {
Slog.d(TAG,"onTvDacYPBPRPlugIn Starting!\n");
int hdmiConnect = mDisplayManager.getHdmiHotPlugStatus();
int tvdacConnect = mDisplayManager.getTvHotPlugStatus();
if(!mHdmiIsConnected && !mCvbsIsConnected){
switchDisplayOutput(DispList.YPBPR_DEFAULT_FORMAT.mOutputType,
DispList.YPBPR_DEFAULT_FORMAT.mFormat);
}else {
mToast.setText(com.android.internal.R.string.ypbpr_plug_in);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
}
private void onTvDacCVBSPlugIn(Intent intent)
{
if (SHOW_TVPLUG_IN_CALL) {
Slog.d(TAG,"onCvbsPlugIn Starting!\n");
int hdmiConnect = mDisplayManager.getHdmiHotPlugStatus();
int tvdacConnect = mDisplayManager.getTvHotPlugStatus();
Slog.d(TAG, "hdmiConnect = " + hdmiConnect + "tvdacConnect = " + tvdacConnect);
if(!mHdmiIsConnected && !mYpbprIsConnected){
switchDisplayOutput(DispList.CVBS_DEFAULT_FORMAT.mOutputType,
DispList.CVBS_DEFAULT_FORMAT.mFormat);
}else {
mToast.setText(com.android.internal.R.string.cvbs_plug_in);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
}
private void onHdmiPlugOut(Intent intent)
{
if (SHOW_HDMIPLUG_IN_CALL) {
Slog.d(TAG,"onHdmiPlugOut Starting!\n");
int curType = mDisplayManager.getDisplayOutputType(0);
if(curType == DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI){
DispList.DispFormat format = null;
Slog.v(TAG,"Cvbs " + mCvbsIsConnected + ";Ypbpr " + mYpbprIsConnected);
if(mCvbsIsConnected){
format = DispList.CVBS_DEFAULT_FORMAT;
}else if(mYpbprIsConnected){
format = DispList.VGA_DEFAULT_FORMAT;
}
if(format != null){
switchDisplayOutput(format.mOutputType, format.mFormat);
}
}else{
mToast.setText(com.android.internal.R.string.hdmi_plug_out);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
}
private void onTvDacCVBSPlugOut(Intent intent)
{
if (SHOW_TVPLUG_IN_CALL)
{
Slog.d(TAG,"onCvbsPlugOut Starting!\n");
int curType = mDisplayManager.getDisplayOutputType(0);
if(curType == DisplayManagerAw.DISPLAY_OUTPUT_TYPE_TV){
DispList.DispFormat format = null;
Slog.v(TAG,"Cvbs " + mCvbsIsConnected + ";Ypbpr " + mYpbprIsConnected);
if(mHdmiIsConnected){
format = DispList.HDMI_DEFAULT_FORMAT;
}else if(mYpbprIsConnected){
format = DispList.VGA_DEFAULT_FORMAT;
}
if(format != null){
switchDisplayOutput(format.mOutputType, format.mFormat);
}
}else{
mToast.setText(com.android.internal.R.string.cvbs_plug_out);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
}
private void onTvDacVGAPlugOut(Intent intent)
{
if (SHOW_TVPLUG_IN_CALL)
{
Slog.d(TAG,"onVgaPlugOut Starting!\n");
int curType = mDisplayManager.getDisplayOutputType(0);
if(curType != DisplayManagerAw.DISPLAY_OUTPUT_TYPE_VGA){
mToast.setText(com.android.internal.R.string.vga_plug_out);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
}
private void onTvDacYPBPRPlugOut(Intent intent)
{
if (SHOW_TVPLUG_IN_CALL)
{
Slog.d(TAG,"onypbprPlugOut Starting!\n");
mToast.setText(com.android.internal.R.string.ypbpr_plug_out);
mToast.setOnHideListener(null);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
}
private void switchDisplayOutput(int type, int format){
/* switch display output format */
Slog.d(TAG, "switch diplay to " + DispList.ItemCode2Name(new DispList.DispFormat(type, format)));
//mDisplayManager.setDisplayOutputType(0, type, format);
mDisplayManager.setDisplayParameter(0,type,format);
mDisplayManager.setDisplayMode(DisplayManagerAw.DISPLAY_MODE_SINGLE_FB_GPU);
/* record the display output format */
Settings.System.putString(mContext.getContentResolver(), Settings.System.DISPLY_OUTPUT_FORMAT,
DispList.ItemCode2Name(new DispList.DispFormat(type, format)));
/* switch audio output mode in the same time */
ArrayList<String> channel = new ArrayList<String>();
if(type == DisplayManagerAw.DISPLAY_OUTPUT_TYPE_HDMI){
channel.add(AudioManager.AUDIO_NAME_HDMI);
}else{
channel.add(AudioManager.AUDIO_NAME_CODEC);
}
AudioManager mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
mAudioManager.setAudioDeviceActive(channel,AudioManager.AUDIO_OUTPUT_ACTIVE);
}
private OnHideListener mHDMIPlugInToastOnHide = new OnHideListener(){
public void onHide(){
switchDisplayOutput(DispList.HDMI_DEFAULT_FORMAT.mOutputType, DispList.HDMI_DEFAULT_FORMAT.mFormat);
}
};
}
interface OnHideListener {
public void onHide();
}
private class HotPlugToast extends Toast{
public HotPlugToast(Context context){
super(context);
LayoutInflater inflate = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflate.inflate(com.android.internal.R.layout.transient_notification, null);
super.setGravity(Gravity.CENTER, 0, 0 );
super.setView(v);
super.setDuration(Toast.LENGTH_LONG);
}
public void setOnHideListener(OnHideListener listener){
mOnHideListener = listener;
}
public void onHide(){
Slog.d(TAG, "on Hide in HotPlugToast.\n");
if(mOnHideListener != null)
mOnHideListener.onHide();
}
private OnHideListener mOnHideListener = null;
}
/* add by Gary. end -----------------------------------}} */
private class StatusBarTVDHotPlug implements DisplayHotPlugPolicy
{
StatusBarTVDHotPlug()
{
}
public void onHdmiPlugChanged(Intent intent)
{
}
public void onTvDacPlugChanged(Intent intent)
{
}
}
}
| 28,158 | 0.558137 | 0.551529 | 695 | 39.502159 | 30.50552 | 143 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.546763 | false | false |
3
|
7e4b63c8bb2342096597568889fe85e27b4d27ca
| 27,298,812,183,779 |
1a1e82a1b246c403d6802e390f9fe3bc41b0debd
|
/src/main/java/IO/Athlete.java
|
49d79a8910ccc1c54f882998b1cf88eb697c5b65
|
[
"Apache-2.0"
] |
permissive
|
CristianGrigorita/java-IO
|
https://github.com/CristianGrigorita/java-IO
|
38629199a39c79545a0107d0e0c6cad7db39fb4e
|
556c7bbf6a994ad415732d7469eb0e6d5bc64413
|
refs/heads/main
| 2023-01-20T00:36:33.455000 | 2020-11-29T22:05:54 | 2020-11-29T22:05:54 | 316,982,828 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package IO;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import static java.lang.Integer.parseInt;
public class Athlete implements Comparable<Athlete>{
private static Logger logger = LogManager.getLogger(CSVParser.class);
public String name;
public int number;
public String countryCode;
public String skiTimeResult;
public String firstShootingRange;
public String secondShootingRange;
public String thirdShootingRange;
public String timeWithPenalties;
public Athlete(int number, String name, String countryCode,
String skiTimeResult, String firstShootingRange,
String secondShootingRange, String thirdShootingRange) {
this.name = name;
this.number = number;
this.countryCode = countryCode;
this.firstShootingRange = firstShootingRange;
this.secondShootingRange = secondShootingRange;
this.thirdShootingRange = thirdShootingRange;
this.skiTimeResult = skiTimeResult;
int penalties = calculatePenalties();
System.out.println(penalties);
addPenalties(penalties * 10);
}
public void addPenalties(int penalties){
int seconds = transformToSeconds(this.skiTimeResult);
System.out.println("normal seconds: " + seconds + " will add this many seconds as penalties: " + penalties);
seconds += penalties;
System.out.println("after penalties addition: " + seconds);
int sec = seconds % 60;
int min = (seconds / 60)%60;
String timeWithPenalties = min + ":" + sec;
setTimeWithPenalties(timeWithPenalties);
}
public void setTimeWithPenalties(String timeWithPenalties) {
this.timeWithPenalties = timeWithPenalties;
// System.out.println("time with penalties: " + this.timeWithPenalties);
}
public int transformToSeconds(String time){
String[] timeArray = time.split(":");
int hours = parseInt(timeArray[0]);
int seconds = parseInt(timeArray[1]);
seconds = hours * 60 + seconds;
return seconds;
}
public int calculatePenalties(){
ArrayList<String> shootingRanges = new ArrayList<>(3);
shootingRanges.add(this.firstShootingRange);
shootingRanges.add(this.secondShootingRange);
shootingRanges.add(this.thirdShootingRange);
int shootsMissed = 0;
for (String shoots: shootingRanges) {
shootsMissed += StringUtils.countMatches(shoots, "o");
}
System.out.println("Shoots missed: " + shootsMissed);
return shootsMissed;
}
public String getTimeWithPenalties() {
return timeWithPenalties;
}
public int getNumber() {
return number;
}
public String getSkiTimeResult() {
return skiTimeResult;
}
public String getName() {
return name;
}
@Override
public String toString() {
return "\n Athlete{" +
"number=" + number +
", name='" + name + '\'' +
", countryCode='" + countryCode + '\'' +
", skiTimeResult=" + skiTimeResult +
", timeWithPenalties=" + timeWithPenalties +
", firstShootingRange='" + firstShootingRange + '\'' +
", secondShootingRange='" + secondShootingRange + '\'' +
", thirdShootingRange='" + thirdShootingRange + '\'' +
'}';
}
@Override
public int compareTo(Athlete o) {
return this.name.compareTo(o.getName());
}
}
|
UTF-8
|
Java
| 3,679 |
java
|
Athlete.java
|
Java
|
[
{
"context": ", String thirdShootingRange) {\n this.name = name;\n this.number = number;\n this.count",
"end": 839,
"score": 0.566730797290802,
"start": 835,
"tag": "NAME",
"value": "name"
},
{
"context": " \"number=\" + number +\n \", name='\" + name + '\\'' +\n \", countryCode='\" + coun",
"end": 3146,
"score": 0.662338376045227,
"start": 3142,
"tag": "NAME",
"value": "name"
}
] | null |
[] |
package IO;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import static java.lang.Integer.parseInt;
public class Athlete implements Comparable<Athlete>{
private static Logger logger = LogManager.getLogger(CSVParser.class);
public String name;
public int number;
public String countryCode;
public String skiTimeResult;
public String firstShootingRange;
public String secondShootingRange;
public String thirdShootingRange;
public String timeWithPenalties;
public Athlete(int number, String name, String countryCode,
String skiTimeResult, String firstShootingRange,
String secondShootingRange, String thirdShootingRange) {
this.name = name;
this.number = number;
this.countryCode = countryCode;
this.firstShootingRange = firstShootingRange;
this.secondShootingRange = secondShootingRange;
this.thirdShootingRange = thirdShootingRange;
this.skiTimeResult = skiTimeResult;
int penalties = calculatePenalties();
System.out.println(penalties);
addPenalties(penalties * 10);
}
public void addPenalties(int penalties){
int seconds = transformToSeconds(this.skiTimeResult);
System.out.println("normal seconds: " + seconds + " will add this many seconds as penalties: " + penalties);
seconds += penalties;
System.out.println("after penalties addition: " + seconds);
int sec = seconds % 60;
int min = (seconds / 60)%60;
String timeWithPenalties = min + ":" + sec;
setTimeWithPenalties(timeWithPenalties);
}
public void setTimeWithPenalties(String timeWithPenalties) {
this.timeWithPenalties = timeWithPenalties;
// System.out.println("time with penalties: " + this.timeWithPenalties);
}
public int transformToSeconds(String time){
String[] timeArray = time.split(":");
int hours = parseInt(timeArray[0]);
int seconds = parseInt(timeArray[1]);
seconds = hours * 60 + seconds;
return seconds;
}
public int calculatePenalties(){
ArrayList<String> shootingRanges = new ArrayList<>(3);
shootingRanges.add(this.firstShootingRange);
shootingRanges.add(this.secondShootingRange);
shootingRanges.add(this.thirdShootingRange);
int shootsMissed = 0;
for (String shoots: shootingRanges) {
shootsMissed += StringUtils.countMatches(shoots, "o");
}
System.out.println("Shoots missed: " + shootsMissed);
return shootsMissed;
}
public String getTimeWithPenalties() {
return timeWithPenalties;
}
public int getNumber() {
return number;
}
public String getSkiTimeResult() {
return skiTimeResult;
}
public String getName() {
return name;
}
@Override
public String toString() {
return "\n Athlete{" +
"number=" + number +
", name='" + name + '\'' +
", countryCode='" + countryCode + '\'' +
", skiTimeResult=" + skiTimeResult +
", timeWithPenalties=" + timeWithPenalties +
", firstShootingRange='" + firstShootingRange + '\'' +
", secondShootingRange='" + secondShootingRange + '\'' +
", thirdShootingRange='" + thirdShootingRange + '\'' +
'}';
}
@Override
public int compareTo(Athlete o) {
return this.name.compareTo(o.getName());
}
}
| 3,679 | 0.631693 | 0.627073 | 114 | 31.271931 | 24.185789 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.596491 | false | false |
3
|
8b9662a46e0d23143f3920a50c4ac6316d59c0ce
| 32,298,154,129,390 |
feebb2379b3790adfd12d285bd2413944b1e2a08
|
/15_nueva_gestion_pedidos/src/service/GestorPedidos.java
|
812e61e29f09b0f09a6be9bc89b6cf327d6127b8
|
[] |
no_license
|
amartinsierra/ejercicios_modulo2_java_profesional
|
https://github.com/amartinsierra/ejercicios_modulo2_java_profesional
|
19790e19322e1d0d82aee8457eecdb7d9c3a8115
|
600c28315652ac83138fe3baec830566bd49635b
|
refs/heads/master
| 2022-11-22T23:02:22.997000 | 2020-07-23T12:01:17 | 2020-07-23T12:01:17 | 280,397,721 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package service;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import model.Pedido;
import util.MiFiltro;
import util.Utilidades;
public class GestorPedidos {
Path path;
String RUTA="pedidos.txt";
public GestorPedidos() {
path=Paths.get(RUTA);
if(!Files.exists(path)) {
try {
Files.createFile(path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private Stream<Pedido> streamPedido(){
try {
return Files.lines(path,StandardCharsets.UTF_8)
.map(s->Utilidades.stringToPedido(s));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return Stream.empty();
}
}
//almacena el pedido recibido
public void grabarPedido(Pedido pedido) {
try {
Files.writeString(path, Utilidades.pedidoToString(pedido)+System.lineSeparator(),
StandardCharsets.UTF_8,
StandardOpenOption.APPEND);
} catch (IOException e) {
e.printStackTrace();
}
}
//media de ventas pedidos de esa seccion
public double promedioSeccion(String seccion) {
return streamPedido()
.filter(p->p.getSeccion().equals(seccion))
.collect(Collectors.averagingDouble(p->p.getPrecioUnitario()*p.getUnidades()));
}
//ventas totales de el producto indicado
public double totalProducto(String producto) {
return streamPedido()
.filter(p->p.getProducto().equals(producto))
.collect(Collectors.summingDouble(p->p.getPrecioUnitario()*p.getUnidades()));
}
//devuelve el pedido con venta superior
public Pedido pedidoSuperior() {
return streamPedido()
.max((p1,p2)->
p1.getPrecioUnitario()*p1.getUnidades()<p2.getPrecioUnitario()*p2.getUnidades()?-1:1)
.orElse(null);
}
//devuelve lista de pedidos de una sección
public List<Pedido> pedidosSeccion(String seccion) {
MiFiltro mifiltro=new MiFiltro(seccion);
return streamPedido()
.filter(mifiltro)
.collect(Collectors.toList());
}
//devuelve el pedido con fecha más reciente
public Pedido pedidoMasReciente() {
return streamPedido()
.max((p1,p2)->p1.getFecha().compareTo(p2.getFecha()))
.orElse(null);
}
//devuelve lista de pedidos, posteriores a la fecha indicada
public List<Pedido> pedidosPosterioresFecha(Date fecha) {
return streamPedido()
.filter(p->p.getFecha().after(fecha))
.collect(Collectors.toList());
}
//lista de nombres de sección, no repetidas
public List<String> secciones() {
return streamPedido()
.map(p->p.getSeccion())
.distinct()
.collect(Collectors.toList());
}
}
|
ISO-8859-3
|
Java
| 2,943 |
java
|
GestorPedidos.java
|
Java
|
[] | null |
[] |
package service;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import model.Pedido;
import util.MiFiltro;
import util.Utilidades;
public class GestorPedidos {
Path path;
String RUTA="pedidos.txt";
public GestorPedidos() {
path=Paths.get(RUTA);
if(!Files.exists(path)) {
try {
Files.createFile(path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private Stream<Pedido> streamPedido(){
try {
return Files.lines(path,StandardCharsets.UTF_8)
.map(s->Utilidades.stringToPedido(s));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return Stream.empty();
}
}
//almacena el pedido recibido
public void grabarPedido(Pedido pedido) {
try {
Files.writeString(path, Utilidades.pedidoToString(pedido)+System.lineSeparator(),
StandardCharsets.UTF_8,
StandardOpenOption.APPEND);
} catch (IOException e) {
e.printStackTrace();
}
}
//media de ventas pedidos de esa seccion
public double promedioSeccion(String seccion) {
return streamPedido()
.filter(p->p.getSeccion().equals(seccion))
.collect(Collectors.averagingDouble(p->p.getPrecioUnitario()*p.getUnidades()));
}
//ventas totales de el producto indicado
public double totalProducto(String producto) {
return streamPedido()
.filter(p->p.getProducto().equals(producto))
.collect(Collectors.summingDouble(p->p.getPrecioUnitario()*p.getUnidades()));
}
//devuelve el pedido con venta superior
public Pedido pedidoSuperior() {
return streamPedido()
.max((p1,p2)->
p1.getPrecioUnitario()*p1.getUnidades()<p2.getPrecioUnitario()*p2.getUnidades()?-1:1)
.orElse(null);
}
//devuelve lista de pedidos de una sección
public List<Pedido> pedidosSeccion(String seccion) {
MiFiltro mifiltro=new MiFiltro(seccion);
return streamPedido()
.filter(mifiltro)
.collect(Collectors.toList());
}
//devuelve el pedido con fecha más reciente
public Pedido pedidoMasReciente() {
return streamPedido()
.max((p1,p2)->p1.getFecha().compareTo(p2.getFecha()))
.orElse(null);
}
//devuelve lista de pedidos, posteriores a la fecha indicada
public List<Pedido> pedidosPosterioresFecha(Date fecha) {
return streamPedido()
.filter(p->p.getFecha().after(fecha))
.collect(Collectors.toList());
}
//lista de nombres de sección, no repetidas
public List<String> secciones() {
return streamPedido()
.map(p->p.getSeccion())
.distinct()
.collect(Collectors.toList());
}
}
| 2,943 | 0.680612 | 0.67585 | 113 | 24.017698 | 20.169626 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.141593 | false | false |
3
|
8118dc29e9a4e2b59065797193b0d9b060deaef8
| 5,540,507,829,772 |
50058b2a9e5b36a426226125be05430b7a6a2654
|
/leetcode/editor/cn/[1010]总持续时间可被 60 整除的歌曲.java
|
982a7fbd3aa8c63e9650bf7e164897f0e18cceea
|
[] |
no_license
|
hihihiman/leetcode
|
https://github.com/hihihiman/leetcode
|
f9b4e5a5257ace187511fb03859b005976f10f26
|
e108340aa86c866e550ec7c07201d7cf2374d180
|
refs/heads/master
| 2021-04-03T21:26:27.575000 | 2020-07-23T01:35:02 | 2020-07-23T01:35:02 | 248,397,984 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
//在歌曲列表中,第 i 首歌曲的持续时间为 time[i] 秒。
//
// 返回其总持续时间(以秒为单位)可被 60 整除的歌曲对的数量。形式上,我们希望索引的数字 i 和 j 满足 i < j 且有 (time[i] + tim
//e[j]) % 60 == 0。
//
//
//
// 示例 1:
//
// 输入:[30,20,150,100,40]
//输出:3
//解释:这三对的总持续时间可被 60 整数:
//(time[0] = 30, time[2] = 150): 总持续时间 180
//(time[1] = 20, time[3] = 100): 总持续时间 120
//(time[1] = 20, time[4] = 40): 总持续时间 60
//
//
// 示例 2:
//
// 输入:[60,60,60]
//输出:3
//解释:所有三对的总持续时间都是 120,可以被 60 整数。
//
//
//
//
// 提示:
//
//
// 1 <= time.length <= 60000
// 1 <= time[i] <= 500
//
// Related Topics 数组
// 👍 95 👎 0
/* 思路
整数对60取模,可能有60种余数。故初始化一个长度为60的数组,统计各余数出现的次数。
遍历time数组,每个值对60取模,并统计每个余数值(0-59)出现的个数。因为余数部分需要找到合适的cp组合起来能被60整除。
余数为0的情况,只能同余数为0的情况组合(如60s、120s等等)。0的情况出现k次,则只能在k中任选两次进行两两组合。本题解单独写了个求组合数的方法,也可以用k * (k - 1) / 2表示。
余数为30的情况同上。
其余1与59组合,2与58组合,故使用双指针分别从1和59两头向中间遍历。1的情况出现m次,59的情况出现n次,则总共有m*n种组合。
作者:keen0126
链接:https://leetcode-cn.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/solution/java-2ms-ji-bai-10000-by-keen0126/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
*/
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
public int numPairsDivisibleBy60(int[] time) {
int count = 0;
int[] seconds = new int[60];
for(int t : time) {
seconds[t % 60] += 1;
}
count += combination(seconds[30], 2);
count += combination(seconds[0], 2);
int i = 1, j = 59;
while(i < j) {
count += seconds[i++] * seconds[j--];
}
return count;
}
// 求组合数
public int combination(int n, int k) {
long result = 1;
for(int i = 1; i <= k; i++) {
result = result * (n - i + 1) / i;
}
return (int)result;
}
}
//leetcode submit region end(Prohibit modification and deletion)
|
UTF-8
|
Java
| 2,644 |
java
|
[1010]总持续时间可被 60 整除的歌曲.java
|
Java
|
[
{
"context": "分别从1和59两头向中间遍历。1的情况出现m次,59的情况出现n次,则总共有m*n种组合。\n\n作者:keen0126\n链接:https://leetcode-cn.com/problems/pairs-of-song",
"end": 852,
"score": 0.9996898770332336,
"start": 844,
"tag": "USERNAME",
"value": "keen0126"
}
] | null |
[] |
//在歌曲列表中,第 i 首歌曲的持续时间为 time[i] 秒。
//
// 返回其总持续时间(以秒为单位)可被 60 整除的歌曲对的数量。形式上,我们希望索引的数字 i 和 j 满足 i < j 且有 (time[i] + tim
//e[j]) % 60 == 0。
//
//
//
// 示例 1:
//
// 输入:[30,20,150,100,40]
//输出:3
//解释:这三对的总持续时间可被 60 整数:
//(time[0] = 30, time[2] = 150): 总持续时间 180
//(time[1] = 20, time[3] = 100): 总持续时间 120
//(time[1] = 20, time[4] = 40): 总持续时间 60
//
//
// 示例 2:
//
// 输入:[60,60,60]
//输出:3
//解释:所有三对的总持续时间都是 120,可以被 60 整数。
//
//
//
//
// 提示:
//
//
// 1 <= time.length <= 60000
// 1 <= time[i] <= 500
//
// Related Topics 数组
// 👍 95 👎 0
/* 思路
整数对60取模,可能有60种余数。故初始化一个长度为60的数组,统计各余数出现的次数。
遍历time数组,每个值对60取模,并统计每个余数值(0-59)出现的个数。因为余数部分需要找到合适的cp组合起来能被60整除。
余数为0的情况,只能同余数为0的情况组合(如60s、120s等等)。0的情况出现k次,则只能在k中任选两次进行两两组合。本题解单独写了个求组合数的方法,也可以用k * (k - 1) / 2表示。
余数为30的情况同上。
其余1与59组合,2与58组合,故使用双指针分别从1和59两头向中间遍历。1的情况出现m次,59的情况出现n次,则总共有m*n种组合。
作者:keen0126
链接:https://leetcode-cn.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/solution/java-2ms-ji-bai-10000-by-keen0126/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
*/
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
public int numPairsDivisibleBy60(int[] time) {
int count = 0;
int[] seconds = new int[60];
for(int t : time) {
seconds[t % 60] += 1;
}
count += combination(seconds[30], 2);
count += combination(seconds[0], 2);
int i = 1, j = 59;
while(i < j) {
count += seconds[i++] * seconds[j--];
}
return count;
}
// 求组合数
public int combination(int n, int k) {
long result = 1;
for(int i = 1; i <= k; i++) {
result = result * (n - i + 1) / i;
}
return (int)result;
}
}
//leetcode submit region end(Prohibit modification and deletion)
| 2,644 | 0.588203 | 0.507167 | 76 | 22.868422 | 24.760612 | 131 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.342105 | false | false |
3
|
cf60d40dfc1e53d539c9529339942c60623ec552
| 5,540,507,831,215 |
9a42b642bf8ba732eb488c3c9dbf693733342693
|
/src/test/java/com/muso/stepDefinition/DashBoard_StepDefinition.java
|
7b1522bb7ee2091b06b936fcab1882ce606ac920
|
[] |
no_license
|
S0rc3r3r/test
|
https://github.com/S0rc3r3r/test
|
859e8fac365c233523a331839b5930c000e77ec8
|
a265d2a90493e4b421da09f1240b1d9bee2807aa
|
refs/heads/master
| 2021-01-02T22:19:27.945000 | 2018-04-10T13:47:29 | 2018-04-10T13:47:29 | 99,317,537 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.muso.stepDefinition;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringEscapeUtils;
import org.openqa.selenium.InvalidArgumentException;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.muso.enums.MenuType;
import com.muso.enums.Table;
import com.muso.enums.TypeType;
import com.muso.testers.CampaignTester;
import com.muso.testers.DashboardTester;
import com.muso.testers.DateRangeTester;
import com.muso.testers.MemberTester;
import com.muso.testers.ProductTester;
import com.muso.testers.ReportTester;
import com.muso.testers.TypeTester;
import cucumber.api.Delimiter;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class DashBoard_StepDefinition {
protected WebDriver driver = Hooks.driver;
private static final Logger LOGGER = LoggerFactory.getLogger(DashBoard_StepDefinition.class);
private DashboardTester dashboardTester = BaseStepDefinition.dashboardTester;
private CampaignTester campaignTester = BaseStepDefinition.campaignTester;
private ProductTester productTester = BaseStepDefinition.productTester;
private TypeTester typeTester = BaseStepDefinition.typeTester;
private ReportTester reportTester = BaseStepDefinition.reportTester;
private MemberTester memberTester = BaseStepDefinition.memberTester;
private DateRangeTester dateRangeTester = BaseStepDefinition.dateRangeTester;
@When("^I expand '(Report|Date Range|Campaign|Type|Members)' menu$")
public void I_expand_menu(String menuName) {
LOGGER.info("Expanding menu: {}", menuName);
switch ((MenuType.fromString(menuName))) {
case REPORT:
reportTester.expandReportMenu(true);
break;
case DATE_RANGE:
dateRangeTester.expandDateRangeMenu(true);
break;
case CAMPAIGN:
campaignTester.expandCampaignMenu(true);
break;
case TYPE:
typeTester.expandTypeMenu(true);
break;
case MEMBERS:
memberTester.expandMembersMenu(true);
break;
default:
throw new InvalidArgumentException("Unknown button label:" + menuName);
}
}
@Then("^I see (\\d+) available options in '(Report|Date Range|Members|Campaign|Product|Type)' menu filter:$")
public void I_should_see_available_options(int i, String menuName, List<String> options) {
List<String> availableOptions;
switch (MenuType.fromString(menuName)) {
case REPORT:
availableOptions = reportTester.getReportOptions();
assertEquals(menuName + " should have " + i + " available options but found: " + availableOptions.toString() + "\n", i, availableOptions.size());
for (String option : options) {
LOGGER.debug("Verifying that {} is a valid {} option", option, menuName);
assertTrue(option + " is not a valid Report option.", MenuType.REPORT.isOptionValid(option));
assertTrue(option + " is not displayed on UI", availableOptions.contains(option));
}
break;
case DATE_RANGE:
availableOptions = dateRangeTester.getDateRangeOptions();
assertEquals(menuName + " should have " + i + " available options but found: " + availableOptions.toString() + "\n", i, availableOptions.size());
for (String option : options) {
LOGGER.debug("Verifying that {} is a valid {} option", option, menuName);
assertTrue(option + " is not a valid Date Range option.", MenuType.DATE_RANGE.isOptionValid(option));
assertTrue(option + " is not displayed on UI", availableOptions.contains(option));
}
break;
case MEMBERS:
availableOptions = memberTester.getMembersOptions();
assertEquals(menuName + " should have " + i + " available options but found: " + availableOptions.toString() + "\n", i, availableOptions.size());
for (String option : options) {
LOGGER.debug("Verifying that {} is displayed under {} option", option, menuName);
assertTrue(option + " is not displayed on UI", availableOptions.contains(option));
}
break;
case TYPE:
availableOptions = typeTester.getTypeOptions();
assertEquals(menuName + " should have " + i + " available options but found: " + availableOptions.toString() + "\n", i, availableOptions.size());
for (String option : options) {
LOGGER.debug("Verifying that {} is displayed under {} option", option, menuName);
assertTrue(option + " is not displayed on UI", availableOptions.contains(option));
}
break;
default:
throw new InvalidArgumentException(" CASE NOT IMPLEMENTED");
}
}
@When("^No '(Campaign|Product|Type)' option is selected$")
public void no_option_is_selected(String menuName) {
switch (MenuType.fromString(menuName)) {
case CAMPAIGN:
campaignTester.clearCampaignSelection();
break;
case TYPE:
typeTester.clearTypeSelection();
break;
case PRODUCT:
productTester.clearProductSelection();
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
@Then("^'(Campaign|Product|Type)' menu filter is (enabled|disabled)$")
public void filter_is_enabled(String menuName, String status) {
dashboardTester.expandSidebar();
boolean expectedStatus = true;
if (status.equals("disabled"))
expectedStatus = false;
LOGGER.debug("Verifying if {} menu filter is {}", menuName, status);
switch (MenuType.fromString(menuName)) {
case PRODUCT:
if (expectedStatus) {
assertTrue("Product menu should be enabled", productTester.isFilterEnabled());
} else {
assertFalse("Product menu should be disabled", productTester.isFilterEnabled());
}
break;
case CAMPAIGN:
if (expectedStatus) {
assertTrue("Campaign menu should be enabled", campaignTester.isFilterEnabled());
} else {
assertFalse("Campaign menu should be disabled", campaignTester.isFilterEnabled());
}
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
@Then("^'(Campaign|Product|Type|Members)' menu filter is (visible|hidden)$")
public void filter_is_visible(String menuName, String status) {
boolean expectedStatus = true;
if (status.equals("hidden"))
expectedStatus = false;
switch (MenuType.fromString(menuName)) {
case MEMBERS:
if (expectedStatus) {
assertTrue("Members menu should be visible", memberTester.isFilterDisplayed());
} else {
assertFalse("Members menu should be hidden", memberTester.isFilterDisplayed());
}
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
@And("^'(.+)' options? from '(Report|Date Range|Campaign|Product|Type)' menu (?:is|are)(| not) selected$")
public void option_is_selected(@Delimiter("; ") List<String> optionNames, String menuName, String optionSelected) {
for (String optionName : optionNames) {
optionName = StringEscapeUtils.unescapeEcmaScript(optionName);
LOGGER.debug("Verifying selection state for option {} under menu {}", optionName, menuName);
boolean selectionState;
if (optionSelected.isEmpty()) {
selectionState = true;
} else {
selectionState = false;
}
Boolean isOptionSelected = null;
switch (MenuType.fromString(menuName)) {
case CAMPAIGN:
isOptionSelected = campaignTester.isCampaignOptionSelected(optionName, selectionState);
break;
case TYPE:
isOptionSelected = typeTester.isTypeOptionSelected(optionName, selectionState);
break;
case PRODUCT:
isOptionSelected = productTester.isPorductOptionSelected(optionName, selectionState);
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
if (selectionState) {
assertTrue(optionName + " is not selected.", isOptionSelected);
if (MenuType.fromString(menuName) == MenuType.CAMPAIGN || MenuType.fromString(menuName) == MenuType.PRODUCT) {
if (productTester.getNumberOfSelectedProducts() < 6)
assertTrue(optionName + " is selected but not displayed in header", campaignTester.isCampaignDisplayedInHeader(optionName));
}
} else {
assertFalse(optionName + " is selected.", !isOptionSelected);
if (MenuType.fromString(menuName) == MenuType.CAMPAIGN || MenuType.fromString(menuName) == MenuType.PRODUCT) {
if (productTester.getNumberOfSelectedProducts() < 6)
assertFalse(optionName + " is not selected but displayed in header", campaignTester.isCampaignDisplayedInHeader(optionName));
}
}
}
}
@Then("^All '(.+)' subcategories from '(Campaign|Type)' menu are disabled$")
public void all_subcategories_from_menu_are_disabled(ArrayList<String> categories, String menuName) {
switch (MenuType.fromString(menuName)) {
case CAMPAIGN:
for (String category : categories) {
assertTrue(category + " is not a selected option under Campaign filter.", campaignTester.isCampaignOptionSelected(category, true));
assertTrue("All campaigns from the selected category should be disabled", campaignTester.isCampaignCategoryElementsDisabled(category));
}
break;
case TYPE:
for (String category : categories) {
assertTrue(category + " is not a selected option under Type filter.", typeTester.isTypeOptionSelected(category, true));
assertTrue("All types from the selected category should be disabled", typeTester.isTypeCategoryElementsDisabled(category));
}
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
@When("^I search for '(.+)' '(Campaign|Product|Type)'(| and select the results)$")
public void i_search_for(String searchString, String menuName, String selectResultsString) {
boolean selectResults = (selectResultsString.isEmpty()) ? false : true;
switch (MenuType.fromString(menuName)) {
case CAMPAIGN:
if (selectResults) {
campaignTester.searchForCampaignAndSelect(searchString);
} else {
campaignTester.searchForCampaign(searchString);
}
break;
case TYPE:
if (selectResults) {
typeTester.searchForTypeAndSelect(searchString);
} else {
typeTester.searchForType(searchString);
}
break;
case PRODUCT:
if (selectResults) {
productTester.searchForProductAndSelect(searchString);
} else {
productTester.searchForProduct(searchString);
}
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
@When("^'(\\d+)' results? (?:are|is) displayed in '(Campaign|Product|Type)' filter$")
public void results_are_displayed(int results, String menuName) {
switch (MenuType.fromString(menuName)) {
case CAMPAIGN:
ArrayList<String> resultCampaigns = campaignTester.getCampaignOptions();
assertEquals("Expected " + results + " results but found " + resultCampaigns.size(), results, resultCampaigns.size());
break;
case PRODUCT:
ArrayList<String> resultProduct = productTester.getProductOptions();
assertEquals("Expected " + results + " results but found " + resultProduct.size() + ": " + resultProduct.toString(), results, resultProduct.size());
break;
case TYPE:
ArrayList<String> resultType = typeTester.getTypeOptions();
assertEquals("Expected " + results + " results but found " + resultType.size() + ": " + resultType.toString(), results, resultType.size());
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
@When("^I (select|remove) '(.+)' options? from '(Report|Date Range|Campaign|Product|Type|Members)' menu$")
public void i_select_option_from_menu(String action, @Delimiter("; ") List<String> optionNames, String menuName) {
for (String optionName : optionNames) {
switch (MenuType.fromString(menuName)) {
case REPORT:
assertTrue(optionName + " is not a valid option for " + menuName + " or not available for the current user", MenuType.REPORT.isOptionValid(optionName));
reportTester.setReport(optionName);
assertTrue(optionName + " was not selected", reportTester.isReportOptionSelected(optionName, true));
break;
case DATE_RANGE:
assertTrue(optionName + " is not a valid option for " + menuName + " or not available for the current user", MenuType.DATE_RANGE.isOptionValid(optionName));
dateRangeTester.setDateRange(optionName);
assertTrue(optionName + " was not selected", dateRangeTester.isDateRangeOptionSelected(optionName, true));
break;
case CAMPAIGN:
campaignTester.setCampaign(action, optionName);
if (action.equals("select")) {
assertTrue(optionName + " was not sleected.", campaignTester.isCampaignOptionSelected(optionName, true));
if (campaignTester.getNumberOfSelectedCampaigns() < 6)
assertTrue(optionName + " is selected but not displayed in header", campaignTester.isCampaignDisplayedInHeader(optionName));
} else {
assertTrue(optionName + " was not removed.", campaignTester.isCampaignOptionSelected(optionName, false));
if (campaignTester.getNumberOfSelectedCampaigns() < 6)
assertFalse(optionName + " is not selected but displayed in header", campaignTester.isCampaignDisplayedInHeader(optionName));
}
break;
case PRODUCT:
productTester.setProduct(action, optionName);
if (action.equals("select")) {
assertTrue(optionName + " was not sleected.", productTester.isPorductOptionSelected(optionName, true));
if (productTester.getNumberOfSelectedProducts() < 6)
assertTrue(optionName + "is selected but not displayed in header", campaignTester.isCampaignDisplayedInHeader(optionName));
} else {
assertTrue(optionName + " was not removed.", productTester.isPorductOptionSelected(optionName, false));
if (productTester.getNumberOfSelectedProducts() < 6)
assertFalse(optionName + "is not selected but displayed in header", campaignTester.isCampaignDisplayedInHeader(optionName));
}
break;
case TYPE:
assertTrue(optionName + " is not a valid option for " + menuName + " or not available for the current user", MenuType.TYPE.isOptionValid(optionName));
typeTester.setType(action, optionName);
if (action.equals("select")) {
assertTrue(optionName + " was not selected.", typeTester.isTypeOptionSelected(optionName, true));
} else {
assertTrue(optionName + " was not removed.", typeTester.isTypeOptionSelected(optionName, false));
}
break;
case MEMBERS:
if (action.equals("select")) {
memberTester.setMember(optionName);
assertTrue(optionName + " was not selected under Members menu filter", memberTester.isMemberOptionSelected(optionName));
} else {
throw new InvalidArgumentException(menuName + " does not supports REMOVE operations");
}
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
}
@When("^I count '(Total Removals|Last (?:12|6|2)?\\s?Months?|(?:Removals )?Last 4?\\s?Weeks?|Custom Range)' I get '(\\d+)'$")
public void i_count_header_info_i_get(String optionName, int infringements) {
int compareResult = -1;
int actualResult = -1;
switch (optionName) {
case "Total Removals":
actualResult = dashboardTester.getInfringementsTotalRemovals();
compareResult = Double.compare(infringements, actualResult);
assertTrue(optionName + " value should be " + infringements + " but was " + actualResult, compareResult == 0);
break;
case "Last Week":
case "Removals Last Week":
actualResult = dashboardTester.getInfringementsLastWeekRemovals();
compareResult = Double.compare(infringements, actualResult);
assertTrue(optionName + " value should be " + infringements + " but was " + actualResult, compareResult == 0);
break;
case "Custom Range":
case "Last 12 Months":
case "Last 6 Months":
case "Last 2 Months":
case "Last Month":
case "Last 4 Weeks":
actualResult = dashboardTester.getInfringementsCustomRemovals();
compareResult = Double.compare(infringements, actualResult);
assertTrue(optionName + " value should be " + infringements + " but was " + actualResult, compareResult == 0);
break;
default:
throw new InvalidArgumentException("Unknown option name " + optionName);
}
}
@When("^I count '(Removals By Type|Removals By Status)' - '(.+)' I get '([0-9]+.?[0-9]+)'$")
public void i_count_removals_i_get(String optionType, String optionName, double infringements) {
int compareResult = -1;
double actualResult = -1.0;
switch (optionType) {
case "Removals By Type":
assertTrue(optionName + " is not a valid option for TYPE filter", TypeType.isTypeValid(optionName));
actualResult = dashboardTester.getRemovalByTypeValue(TypeType.fromString(optionName));
compareResult = Double.compare(infringements, actualResult);
if (actualResult == -1.00)
assertTrue(optionName + " type has has no value or is not displayed in Removals By Type chart", false);
assertTrue(optionName + " value should be " + infringements + "% but was " + actualResult + "%", compareResult == 0);
break;
case "Removals By Status":
switch (optionName) {
case "Complete":
case "In Progress":
case "Aborted":
actualResult = dashboardTester.getRemovalByStatusValue(optionName);
compareResult = Double.compare(infringements, actualResult);
if (actualResult == -1.00)
assertTrue(optionName + " type has has no value or is not displayed in Removals By Status chart", false);
assertTrue(optionName + " value should be " + infringements + "% but was " + actualResult + "%", compareResult == 0);
break;
default:
throw new InvalidArgumentException(optionName + " is not a valid Status for Removals By Status");
}
break;
default:
throw new InvalidArgumentException("Unknown option Type name " + optionType);
}
}
@When("^I count '(All Time|Last (?:12|6|2)?\\s?Months?|Last 4?\\s?Weeks?|Custom Range)' for (campaign|product) '(.+)' I get '(\\d+)'$")
public void i_count_campaigns_or_products_i_get(String period, String optionType, String optionName, long infringements) {
switch (MenuType.fromString(optionType)) {
case CAMPAIGN:
Long actualInfringements = dashboardTester.getCampaignInfringements(optionName, period);
assertTrue("There should be " + infringements + " infringements for campaign " + optionName + " using " + period + " filter. But was " + actualInfringements, infringements == actualInfringements);
break;
case PRODUCT:
dashboardTester.getProductInfringements(optionName, period);
break;
default:
break;
}
}
@Then("^'(.+)' counter is(| not) displayed$")
public void counter_is_not_displayed(String counterName, String isDisplayed) {
if (isDisplayed.isEmpty()) {
assertTrue(counterName + " is not displayed", dashboardTester.isCounterDisplayed(counterName));
} else {
assertTrue(counterName + " is displayed", !dashboardTester.isCounterDisplayed(counterName));
}
}
@When("^I change the number of rows to be displayed for '(Campaigns|Removal Details)' table to (5|20|50|100)$")
public void i_change_the_number_of_rows_to_be_displayed_for_table(String tableName, int rowsToDisplay) {
switch (tableName) {
case "Removal Details":
dashboardTester.setRemovalDetailRowsToDisplay(rowsToDisplay);
break;
default:
throw new InvalidArgumentException(tableName + " was not found.");
}
}
@Then("^'(.+)' report is displayed and has all elements displayed correctly$")
public void report_view_is_displayed(String reportName) {
reportTester.checkReportIsDisplayedCorrectly(reportName);
}
@Then("^Only the results that match '(Date Range|Campaign|Product|Type|Members)' filter are displayed$")
public void only_results_that_match_filter_are_displayed_in_table(String menuName) {
boolean isFilgerApplied = false;
switch (MenuType.fromString(menuName)) {
case CAMPAIGN:
isFilgerApplied = campaignTester.isCampaignFilterApplied();
break;
case PRODUCT:
isFilgerApplied = productTester.isProductFilterApplied();
break;
case DATE_RANGE:
isFilgerApplied = dateRangeTester.isDateRangeFilterApplied();
break;
case TYPE:
isFilgerApplied = typeTester.isTypeFilterApplied();
break;
case MEMBERS:
isFilgerApplied = memberTester.isMembersFilterApplied();
break;
default:
throw new RuntimeException("NOT IMPLEMENTED");
}
assertTrue(menuName + " filter is not applied correctly.", isFilgerApplied);
}
@Then("^'(Removal Details|Campaigns)' results are displayed on (\\d+) pages?$")
public void results_are_displayed_in_pages(String tableName, int pagesToDisplay) {
final Table table = Table.fromString(tableName);
switch (table) {
case REMOVAL_DETAILS:
final int actualPages = dashboardTester.getTablePages(Table.fromString(tableName));
assertEquals("Results for table " + tableName + " should be displayed on " + pagesToDisplay + " pages\n", pagesToDisplay, actualPages);
break;
default:
throw new InvalidArgumentException(tableName + " table was not found.");
}
}
@And("^The number of results displayed in table '(Removal Details|Campaigns)' is (\\d+)$")
public void results_are_displayed_in_table(String tableName, int results) {
final Table table = Table.fromString(tableName);
switch (table) {
case REMOVAL_DETAILS:
final int actualResults = dashboardTester.getTableRows(Table.REMOVAL_DETAILS);
assertEquals("Results displayed on table " + tableName + " should be " + results + " \n", results, actualResults);
break;
default:
throw new InvalidArgumentException(tableName + " table was not found.");
}
}
}
|
UTF-8
|
Java
| 25,701 |
java
|
DashBoard_StepDefinition.java
|
Java
|
[] | null |
[] |
package com.muso.stepDefinition;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringEscapeUtils;
import org.openqa.selenium.InvalidArgumentException;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.muso.enums.MenuType;
import com.muso.enums.Table;
import com.muso.enums.TypeType;
import com.muso.testers.CampaignTester;
import com.muso.testers.DashboardTester;
import com.muso.testers.DateRangeTester;
import com.muso.testers.MemberTester;
import com.muso.testers.ProductTester;
import com.muso.testers.ReportTester;
import com.muso.testers.TypeTester;
import cucumber.api.Delimiter;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class DashBoard_StepDefinition {
protected WebDriver driver = Hooks.driver;
private static final Logger LOGGER = LoggerFactory.getLogger(DashBoard_StepDefinition.class);
private DashboardTester dashboardTester = BaseStepDefinition.dashboardTester;
private CampaignTester campaignTester = BaseStepDefinition.campaignTester;
private ProductTester productTester = BaseStepDefinition.productTester;
private TypeTester typeTester = BaseStepDefinition.typeTester;
private ReportTester reportTester = BaseStepDefinition.reportTester;
private MemberTester memberTester = BaseStepDefinition.memberTester;
private DateRangeTester dateRangeTester = BaseStepDefinition.dateRangeTester;
@When("^I expand '(Report|Date Range|Campaign|Type|Members)' menu$")
public void I_expand_menu(String menuName) {
LOGGER.info("Expanding menu: {}", menuName);
switch ((MenuType.fromString(menuName))) {
case REPORT:
reportTester.expandReportMenu(true);
break;
case DATE_RANGE:
dateRangeTester.expandDateRangeMenu(true);
break;
case CAMPAIGN:
campaignTester.expandCampaignMenu(true);
break;
case TYPE:
typeTester.expandTypeMenu(true);
break;
case MEMBERS:
memberTester.expandMembersMenu(true);
break;
default:
throw new InvalidArgumentException("Unknown button label:" + menuName);
}
}
@Then("^I see (\\d+) available options in '(Report|Date Range|Members|Campaign|Product|Type)' menu filter:$")
public void I_should_see_available_options(int i, String menuName, List<String> options) {
List<String> availableOptions;
switch (MenuType.fromString(menuName)) {
case REPORT:
availableOptions = reportTester.getReportOptions();
assertEquals(menuName + " should have " + i + " available options but found: " + availableOptions.toString() + "\n", i, availableOptions.size());
for (String option : options) {
LOGGER.debug("Verifying that {} is a valid {} option", option, menuName);
assertTrue(option + " is not a valid Report option.", MenuType.REPORT.isOptionValid(option));
assertTrue(option + " is not displayed on UI", availableOptions.contains(option));
}
break;
case DATE_RANGE:
availableOptions = dateRangeTester.getDateRangeOptions();
assertEquals(menuName + " should have " + i + " available options but found: " + availableOptions.toString() + "\n", i, availableOptions.size());
for (String option : options) {
LOGGER.debug("Verifying that {} is a valid {} option", option, menuName);
assertTrue(option + " is not a valid Date Range option.", MenuType.DATE_RANGE.isOptionValid(option));
assertTrue(option + " is not displayed on UI", availableOptions.contains(option));
}
break;
case MEMBERS:
availableOptions = memberTester.getMembersOptions();
assertEquals(menuName + " should have " + i + " available options but found: " + availableOptions.toString() + "\n", i, availableOptions.size());
for (String option : options) {
LOGGER.debug("Verifying that {} is displayed under {} option", option, menuName);
assertTrue(option + " is not displayed on UI", availableOptions.contains(option));
}
break;
case TYPE:
availableOptions = typeTester.getTypeOptions();
assertEquals(menuName + " should have " + i + " available options but found: " + availableOptions.toString() + "\n", i, availableOptions.size());
for (String option : options) {
LOGGER.debug("Verifying that {} is displayed under {} option", option, menuName);
assertTrue(option + " is not displayed on UI", availableOptions.contains(option));
}
break;
default:
throw new InvalidArgumentException(" CASE NOT IMPLEMENTED");
}
}
@When("^No '(Campaign|Product|Type)' option is selected$")
public void no_option_is_selected(String menuName) {
switch (MenuType.fromString(menuName)) {
case CAMPAIGN:
campaignTester.clearCampaignSelection();
break;
case TYPE:
typeTester.clearTypeSelection();
break;
case PRODUCT:
productTester.clearProductSelection();
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
@Then("^'(Campaign|Product|Type)' menu filter is (enabled|disabled)$")
public void filter_is_enabled(String menuName, String status) {
dashboardTester.expandSidebar();
boolean expectedStatus = true;
if (status.equals("disabled"))
expectedStatus = false;
LOGGER.debug("Verifying if {} menu filter is {}", menuName, status);
switch (MenuType.fromString(menuName)) {
case PRODUCT:
if (expectedStatus) {
assertTrue("Product menu should be enabled", productTester.isFilterEnabled());
} else {
assertFalse("Product menu should be disabled", productTester.isFilterEnabled());
}
break;
case CAMPAIGN:
if (expectedStatus) {
assertTrue("Campaign menu should be enabled", campaignTester.isFilterEnabled());
} else {
assertFalse("Campaign menu should be disabled", campaignTester.isFilterEnabled());
}
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
@Then("^'(Campaign|Product|Type|Members)' menu filter is (visible|hidden)$")
public void filter_is_visible(String menuName, String status) {
boolean expectedStatus = true;
if (status.equals("hidden"))
expectedStatus = false;
switch (MenuType.fromString(menuName)) {
case MEMBERS:
if (expectedStatus) {
assertTrue("Members menu should be visible", memberTester.isFilterDisplayed());
} else {
assertFalse("Members menu should be hidden", memberTester.isFilterDisplayed());
}
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
@And("^'(.+)' options? from '(Report|Date Range|Campaign|Product|Type)' menu (?:is|are)(| not) selected$")
public void option_is_selected(@Delimiter("; ") List<String> optionNames, String menuName, String optionSelected) {
for (String optionName : optionNames) {
optionName = StringEscapeUtils.unescapeEcmaScript(optionName);
LOGGER.debug("Verifying selection state for option {} under menu {}", optionName, menuName);
boolean selectionState;
if (optionSelected.isEmpty()) {
selectionState = true;
} else {
selectionState = false;
}
Boolean isOptionSelected = null;
switch (MenuType.fromString(menuName)) {
case CAMPAIGN:
isOptionSelected = campaignTester.isCampaignOptionSelected(optionName, selectionState);
break;
case TYPE:
isOptionSelected = typeTester.isTypeOptionSelected(optionName, selectionState);
break;
case PRODUCT:
isOptionSelected = productTester.isPorductOptionSelected(optionName, selectionState);
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
if (selectionState) {
assertTrue(optionName + " is not selected.", isOptionSelected);
if (MenuType.fromString(menuName) == MenuType.CAMPAIGN || MenuType.fromString(menuName) == MenuType.PRODUCT) {
if (productTester.getNumberOfSelectedProducts() < 6)
assertTrue(optionName + " is selected but not displayed in header", campaignTester.isCampaignDisplayedInHeader(optionName));
}
} else {
assertFalse(optionName + " is selected.", !isOptionSelected);
if (MenuType.fromString(menuName) == MenuType.CAMPAIGN || MenuType.fromString(menuName) == MenuType.PRODUCT) {
if (productTester.getNumberOfSelectedProducts() < 6)
assertFalse(optionName + " is not selected but displayed in header", campaignTester.isCampaignDisplayedInHeader(optionName));
}
}
}
}
@Then("^All '(.+)' subcategories from '(Campaign|Type)' menu are disabled$")
public void all_subcategories_from_menu_are_disabled(ArrayList<String> categories, String menuName) {
switch (MenuType.fromString(menuName)) {
case CAMPAIGN:
for (String category : categories) {
assertTrue(category + " is not a selected option under Campaign filter.", campaignTester.isCampaignOptionSelected(category, true));
assertTrue("All campaigns from the selected category should be disabled", campaignTester.isCampaignCategoryElementsDisabled(category));
}
break;
case TYPE:
for (String category : categories) {
assertTrue(category + " is not a selected option under Type filter.", typeTester.isTypeOptionSelected(category, true));
assertTrue("All types from the selected category should be disabled", typeTester.isTypeCategoryElementsDisabled(category));
}
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
@When("^I search for '(.+)' '(Campaign|Product|Type)'(| and select the results)$")
public void i_search_for(String searchString, String menuName, String selectResultsString) {
boolean selectResults = (selectResultsString.isEmpty()) ? false : true;
switch (MenuType.fromString(menuName)) {
case CAMPAIGN:
if (selectResults) {
campaignTester.searchForCampaignAndSelect(searchString);
} else {
campaignTester.searchForCampaign(searchString);
}
break;
case TYPE:
if (selectResults) {
typeTester.searchForTypeAndSelect(searchString);
} else {
typeTester.searchForType(searchString);
}
break;
case PRODUCT:
if (selectResults) {
productTester.searchForProductAndSelect(searchString);
} else {
productTester.searchForProduct(searchString);
}
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
@When("^'(\\d+)' results? (?:are|is) displayed in '(Campaign|Product|Type)' filter$")
public void results_are_displayed(int results, String menuName) {
switch (MenuType.fromString(menuName)) {
case CAMPAIGN:
ArrayList<String> resultCampaigns = campaignTester.getCampaignOptions();
assertEquals("Expected " + results + " results but found " + resultCampaigns.size(), results, resultCampaigns.size());
break;
case PRODUCT:
ArrayList<String> resultProduct = productTester.getProductOptions();
assertEquals("Expected " + results + " results but found " + resultProduct.size() + ": " + resultProduct.toString(), results, resultProduct.size());
break;
case TYPE:
ArrayList<String> resultType = typeTester.getTypeOptions();
assertEquals("Expected " + results + " results but found " + resultType.size() + ": " + resultType.toString(), results, resultType.size());
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
@When("^I (select|remove) '(.+)' options? from '(Report|Date Range|Campaign|Product|Type|Members)' menu$")
public void i_select_option_from_menu(String action, @Delimiter("; ") List<String> optionNames, String menuName) {
for (String optionName : optionNames) {
switch (MenuType.fromString(menuName)) {
case REPORT:
assertTrue(optionName + " is not a valid option for " + menuName + " or not available for the current user", MenuType.REPORT.isOptionValid(optionName));
reportTester.setReport(optionName);
assertTrue(optionName + " was not selected", reportTester.isReportOptionSelected(optionName, true));
break;
case DATE_RANGE:
assertTrue(optionName + " is not a valid option for " + menuName + " or not available for the current user", MenuType.DATE_RANGE.isOptionValid(optionName));
dateRangeTester.setDateRange(optionName);
assertTrue(optionName + " was not selected", dateRangeTester.isDateRangeOptionSelected(optionName, true));
break;
case CAMPAIGN:
campaignTester.setCampaign(action, optionName);
if (action.equals("select")) {
assertTrue(optionName + " was not sleected.", campaignTester.isCampaignOptionSelected(optionName, true));
if (campaignTester.getNumberOfSelectedCampaigns() < 6)
assertTrue(optionName + " is selected but not displayed in header", campaignTester.isCampaignDisplayedInHeader(optionName));
} else {
assertTrue(optionName + " was not removed.", campaignTester.isCampaignOptionSelected(optionName, false));
if (campaignTester.getNumberOfSelectedCampaigns() < 6)
assertFalse(optionName + " is not selected but displayed in header", campaignTester.isCampaignDisplayedInHeader(optionName));
}
break;
case PRODUCT:
productTester.setProduct(action, optionName);
if (action.equals("select")) {
assertTrue(optionName + " was not sleected.", productTester.isPorductOptionSelected(optionName, true));
if (productTester.getNumberOfSelectedProducts() < 6)
assertTrue(optionName + "is selected but not displayed in header", campaignTester.isCampaignDisplayedInHeader(optionName));
} else {
assertTrue(optionName + " was not removed.", productTester.isPorductOptionSelected(optionName, false));
if (productTester.getNumberOfSelectedProducts() < 6)
assertFalse(optionName + "is not selected but displayed in header", campaignTester.isCampaignDisplayedInHeader(optionName));
}
break;
case TYPE:
assertTrue(optionName + " is not a valid option for " + menuName + " or not available for the current user", MenuType.TYPE.isOptionValid(optionName));
typeTester.setType(action, optionName);
if (action.equals("select")) {
assertTrue(optionName + " was not selected.", typeTester.isTypeOptionSelected(optionName, true));
} else {
assertTrue(optionName + " was not removed.", typeTester.isTypeOptionSelected(optionName, false));
}
break;
case MEMBERS:
if (action.equals("select")) {
memberTester.setMember(optionName);
assertTrue(optionName + " was not selected under Members menu filter", memberTester.isMemberOptionSelected(optionName));
} else {
throw new InvalidArgumentException(menuName + " does not supports REMOVE operations");
}
break;
default:
throw new InvalidArgumentException(menuName + " is not implemented");
}
}
}
@When("^I count '(Total Removals|Last (?:12|6|2)?\\s?Months?|(?:Removals )?Last 4?\\s?Weeks?|Custom Range)' I get '(\\d+)'$")
public void i_count_header_info_i_get(String optionName, int infringements) {
int compareResult = -1;
int actualResult = -1;
switch (optionName) {
case "Total Removals":
actualResult = dashboardTester.getInfringementsTotalRemovals();
compareResult = Double.compare(infringements, actualResult);
assertTrue(optionName + " value should be " + infringements + " but was " + actualResult, compareResult == 0);
break;
case "Last Week":
case "Removals Last Week":
actualResult = dashboardTester.getInfringementsLastWeekRemovals();
compareResult = Double.compare(infringements, actualResult);
assertTrue(optionName + " value should be " + infringements + " but was " + actualResult, compareResult == 0);
break;
case "Custom Range":
case "Last 12 Months":
case "Last 6 Months":
case "Last 2 Months":
case "Last Month":
case "Last 4 Weeks":
actualResult = dashboardTester.getInfringementsCustomRemovals();
compareResult = Double.compare(infringements, actualResult);
assertTrue(optionName + " value should be " + infringements + " but was " + actualResult, compareResult == 0);
break;
default:
throw new InvalidArgumentException("Unknown option name " + optionName);
}
}
@When("^I count '(Removals By Type|Removals By Status)' - '(.+)' I get '([0-9]+.?[0-9]+)'$")
public void i_count_removals_i_get(String optionType, String optionName, double infringements) {
int compareResult = -1;
double actualResult = -1.0;
switch (optionType) {
case "Removals By Type":
assertTrue(optionName + " is not a valid option for TYPE filter", TypeType.isTypeValid(optionName));
actualResult = dashboardTester.getRemovalByTypeValue(TypeType.fromString(optionName));
compareResult = Double.compare(infringements, actualResult);
if (actualResult == -1.00)
assertTrue(optionName + " type has has no value or is not displayed in Removals By Type chart", false);
assertTrue(optionName + " value should be " + infringements + "% but was " + actualResult + "%", compareResult == 0);
break;
case "Removals By Status":
switch (optionName) {
case "Complete":
case "In Progress":
case "Aborted":
actualResult = dashboardTester.getRemovalByStatusValue(optionName);
compareResult = Double.compare(infringements, actualResult);
if (actualResult == -1.00)
assertTrue(optionName + " type has has no value or is not displayed in Removals By Status chart", false);
assertTrue(optionName + " value should be " + infringements + "% but was " + actualResult + "%", compareResult == 0);
break;
default:
throw new InvalidArgumentException(optionName + " is not a valid Status for Removals By Status");
}
break;
default:
throw new InvalidArgumentException("Unknown option Type name " + optionType);
}
}
@When("^I count '(All Time|Last (?:12|6|2)?\\s?Months?|Last 4?\\s?Weeks?|Custom Range)' for (campaign|product) '(.+)' I get '(\\d+)'$")
public void i_count_campaigns_or_products_i_get(String period, String optionType, String optionName, long infringements) {
switch (MenuType.fromString(optionType)) {
case CAMPAIGN:
Long actualInfringements = dashboardTester.getCampaignInfringements(optionName, period);
assertTrue("There should be " + infringements + " infringements for campaign " + optionName + " using " + period + " filter. But was " + actualInfringements, infringements == actualInfringements);
break;
case PRODUCT:
dashboardTester.getProductInfringements(optionName, period);
break;
default:
break;
}
}
@Then("^'(.+)' counter is(| not) displayed$")
public void counter_is_not_displayed(String counterName, String isDisplayed) {
if (isDisplayed.isEmpty()) {
assertTrue(counterName + " is not displayed", dashboardTester.isCounterDisplayed(counterName));
} else {
assertTrue(counterName + " is displayed", !dashboardTester.isCounterDisplayed(counterName));
}
}
@When("^I change the number of rows to be displayed for '(Campaigns|Removal Details)' table to (5|20|50|100)$")
public void i_change_the_number_of_rows_to_be_displayed_for_table(String tableName, int rowsToDisplay) {
switch (tableName) {
case "Removal Details":
dashboardTester.setRemovalDetailRowsToDisplay(rowsToDisplay);
break;
default:
throw new InvalidArgumentException(tableName + " was not found.");
}
}
@Then("^'(.+)' report is displayed and has all elements displayed correctly$")
public void report_view_is_displayed(String reportName) {
reportTester.checkReportIsDisplayedCorrectly(reportName);
}
@Then("^Only the results that match '(Date Range|Campaign|Product|Type|Members)' filter are displayed$")
public void only_results_that_match_filter_are_displayed_in_table(String menuName) {
boolean isFilgerApplied = false;
switch (MenuType.fromString(menuName)) {
case CAMPAIGN:
isFilgerApplied = campaignTester.isCampaignFilterApplied();
break;
case PRODUCT:
isFilgerApplied = productTester.isProductFilterApplied();
break;
case DATE_RANGE:
isFilgerApplied = dateRangeTester.isDateRangeFilterApplied();
break;
case TYPE:
isFilgerApplied = typeTester.isTypeFilterApplied();
break;
case MEMBERS:
isFilgerApplied = memberTester.isMembersFilterApplied();
break;
default:
throw new RuntimeException("NOT IMPLEMENTED");
}
assertTrue(menuName + " filter is not applied correctly.", isFilgerApplied);
}
@Then("^'(Removal Details|Campaigns)' results are displayed on (\\d+) pages?$")
public void results_are_displayed_in_pages(String tableName, int pagesToDisplay) {
final Table table = Table.fromString(tableName);
switch (table) {
case REMOVAL_DETAILS:
final int actualPages = dashboardTester.getTablePages(Table.fromString(tableName));
assertEquals("Results for table " + tableName + " should be displayed on " + pagesToDisplay + " pages\n", pagesToDisplay, actualPages);
break;
default:
throw new InvalidArgumentException(tableName + " table was not found.");
}
}
@And("^The number of results displayed in table '(Removal Details|Campaigns)' is (\\d+)$")
public void results_are_displayed_in_table(String tableName, int results) {
final Table table = Table.fromString(tableName);
switch (table) {
case REMOVAL_DETAILS:
final int actualResults = dashboardTester.getTableRows(Table.REMOVAL_DETAILS);
assertEquals("Results displayed on table " + tableName + " should be " + results + " \n", results, actualResults);
break;
default:
throw new InvalidArgumentException(tableName + " table was not found.");
}
}
}
| 25,701 | 0.607836 | 0.605813 | 558 | 44.059139 | 41.758415 | 208 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.761649 | false | false |
3
|
8161d072d3209d251468d3a1e2d17f8cfb3536fc
| 16,990,890,630,923 |
8b9378f75fa4b391b910c339fe4433a218725c9e
|
/BufferPoolLRUTest.java
|
1136e457a071aba53deeb8fed502805b2c63f937
|
[] |
no_license
|
vishalmns/HeapFileSort
|
https://github.com/vishalmns/HeapFileSort
|
40d33c23baf71b656172034af62a3b967124418e
|
83c144d61bee2726ddb21232b010ae629d6a6de1
|
refs/heads/master
| 2023-06-13T04:50:23.469000 | 2021-07-03T01:25:21 | 2021-07-03T01:25:21 | 380,840,444 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import student.TestCase;
import java.io.File;
import java.io.IOException;
/**
* Test the BufferPool
* @author mark peas,vishalms
* @version 1.0
*/
public class BufferPoolLRUTest extends TestCase {
/**
* Buffer pool object
*/
private BufferPoolLRU bufferPool;
/**
* generating data and initalised object for test
* @throws IOException throw error when unable generate data
*/
public void setUp() throws IOException {
ByteFileGenerator generator = new ByteFileGenerator();
generator.generate(2048);
File file = new File("p3_input_sample.txt");
bufferPool = new BufferPoolLRU(file, 1);
}
/**
* test to get the record bytes from the buffer pool
*/
public void testGetRecordBytes() {
byte[] recordBytes = bufferPool.getRecordBytes(0, 4);
assertNotNull(recordBytes);
}
/**
* test to set the record bytes to the buffer pool
*/
public void testSetRecordBytes() {
byte[] bytes = "10AA".getBytes();
bufferPool.setRecordBytes(bytes, 0);
byte[] recordBytes = bufferPool.getRecordBytes(0, 4);
assertNotNull(recordBytes);
}
}
|
UTF-8
|
Java
| 1,196 |
java
|
BufferPoolLRUTest.java
|
Java
|
[
{
"context": "OException;\n\n/**\n * Test the BufferPool\n * @author mark peas,vishalms\n * @version 1.0\n */\npublic class BufferP",
"end": 123,
"score": 0.9997115731239319,
"start": 114,
"tag": "NAME",
"value": "mark peas"
},
{
"context": "\n\n/**\n * Test the BufferPool\n * @author mark peas,vishalms\n * @version 1.0\n */\npublic class BufferPoolLRUTes",
"end": 132,
"score": 0.9993197917938232,
"start": 124,
"tag": "USERNAME",
"value": "vishalms"
}
] | null |
[] |
import student.TestCase;
import java.io.File;
import java.io.IOException;
/**
* Test the BufferPool
* @author <NAME>,vishalms
* @version 1.0
*/
public class BufferPoolLRUTest extends TestCase {
/**
* Buffer pool object
*/
private BufferPoolLRU bufferPool;
/**
* generating data and initalised object for test
* @throws IOException throw error when unable generate data
*/
public void setUp() throws IOException {
ByteFileGenerator generator = new ByteFileGenerator();
generator.generate(2048);
File file = new File("p3_input_sample.txt");
bufferPool = new BufferPoolLRU(file, 1);
}
/**
* test to get the record bytes from the buffer pool
*/
public void testGetRecordBytes() {
byte[] recordBytes = bufferPool.getRecordBytes(0, 4);
assertNotNull(recordBytes);
}
/**
* test to set the record bytes to the buffer pool
*/
public void testSetRecordBytes() {
byte[] bytes = "10AA".getBytes();
bufferPool.setRecordBytes(bytes, 0);
byte[] recordBytes = bufferPool.getRecordBytes(0, 4);
assertNotNull(recordBytes);
}
}
| 1,193 | 0.637124 | 0.624582 | 51 | 22.450981 | 21.539124 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.372549 | false | false |
3
|
c4a54dee0a4923833eb49d9d71cb07a3ecceeda0
| 8,495,445,331,046 |
ac0ce72e5336977a522c6c2ba3ae8f7d80a8ebd4
|
/modules/srm-server/src/main/java/org/dcache/srm/handler/SrmReleaseSpace.java
|
656b7384b051112730578b7c418d7169e666d470
|
[] |
no_license
|
Spawn89/dcache
|
https://github.com/Spawn89/dcache
|
e347b77641de45e1083b892bd8983ddf67d8e5e8
|
e7baf076dfa422a8341422f074e40a4a9ebaa061
|
refs/heads/master
| 2021-01-18T09:11:13.224000 | 2013-09-27T06:48:20 | 2013-10-07T04:59:02 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
//______________________________________________________________________________
//
// $Id$
// $Author$
//
// created 10/05 by Dmitry Litvintsev (litvinse@fnal.gov)
//
//______________________________________________________________________________
/*
* SrmCopy
*
* Created on 10/05
*/
package org.dcache.srm.handler;
import org.apache.axis.types.URI.MalformedURIException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.dcache.srm.AbstractStorageElement;
import org.dcache.srm.SRM;
import org.dcache.srm.SRMException;
import org.dcache.srm.SRMUser;
import org.dcache.srm.request.RequestCredential;
import org.dcache.srm.scheduler.Scheduler;
import org.dcache.srm.util.Configuration;
import org.dcache.srm.v2_2.SrmReleaseSpaceRequest;
import org.dcache.srm.v2_2.SrmReleaseSpaceResponse;
import org.dcache.srm.v2_2.TReturnStatus;
import org.dcache.srm.v2_2.TStatusCode;
/**
*
* @author litvinse
*/
public class SrmReleaseSpace {
private static Logger logger =
LoggerFactory.getLogger(SrmReleaseSpace.class);
private final static String SFN_STRING="?SFN=";
AbstractStorageElement storage;
SrmReleaseSpaceRequest request;
SrmReleaseSpaceResponse response;
SRMUser user;
Scheduler scheduler;
RequestCredential credential;
Configuration configuration;
public SrmReleaseSpace(SRMUser user,
RequestCredential credential,
SrmReleaseSpaceRequest request,
AbstractStorageElement storage,
SRM srm,
String client_host) {
if (request == null) {
throw new NullPointerException("request is null");
}
this.request = request;
this.user = user;
this.credential = credential;
if (storage == null) {
throw new NullPointerException("storage is null");
}
this.storage = storage;
this.scheduler = srm.getCopyRequestScheduler();
if (scheduler == null) {
throw new NullPointerException("scheduler is null");
}
this.configuration = srm.getConfiguration();
if (configuration == null) {
throw new NullPointerException("configuration is null");
}
}
public SrmReleaseSpaceResponse getResponse() {
if(response != null ) {
return response;
}
try {
response = releaseSpace();
} catch(MalformedURIException mue) {
logger.debug(" malformed uri : "+mue.getMessage());
response = getFailedResponse(" malformed uri : "+mue.getMessage(),
TStatusCode.SRM_INVALID_REQUEST);
} catch(SRMException srme) {
logger.error(srme.toString());
response = getFailedResponse(srme.toString());
}
return response;
}
private static SrmReleaseSpaceResponse getFailedResponse(String text) {
return getFailedResponse(text, TStatusCode.SRM_FAILURE);
}
private static SrmReleaseSpaceResponse getFailedResponse(String text, TStatusCode statusCode) {
SrmReleaseSpaceResponse response = new SrmReleaseSpaceResponse();
response.setReturnStatus(new TReturnStatus(statusCode, text));
return response;
}
public SrmReleaseSpaceResponse releaseSpace()
throws SRMException,MalformedURIException {
if(request==null) {
return getFailedResponse("srmReleaseSpace: null request passed to SrmReleaseSpace",
TStatusCode.SRM_INVALID_REQUEST);
}
String token = request.getSpaceToken();
SrmReleaseSpaceCallbacks callbacks = new SrmReleaseSpaceCallbacks();
storage.srmReleaseSpace(user,token,null, callbacks );
TReturnStatus status = callbacks.waitResult(60 * 1000);//one minute max
return new SrmReleaseSpaceResponse(status);
}
private class SrmReleaseSpaceCallbacks implements org.dcache.srm.SrmReleaseSpaceCallbacks {
private boolean completed;
private TReturnStatus status;
public SrmReleaseSpaceCallbacks() {
}
public synchronized TReturnStatus waitResult(long timeout)
{
//System.out.println("PutCallbacks waitResult() starting for CopyFileRequest "+fileId);
long start = System.currentTimeMillis();
long current = start;
while(true)
{
if(completed)
{
//System.out.println("PutCallbacks waitResult() completed with success="+success+
//" for CopyFileRequest "+fileId);
return status;
}
long wait = timeout - (current -start);
if(wait > 0)
{
try
{
this.wait(wait);
}
catch(InterruptedException ie){
}
}
else
{
return new TReturnStatus(TStatusCode.SRM_INTERNAL_ERROR, "release takes longer then "+timeout +" millis");
}
current = System.currentTimeMillis();
}
}
public synchronized void complete()
{
this.completed = true;
this.notifyAll();
}
@Override
public void ReleaseSpaceFailed(String reason){
status = new TReturnStatus(TStatusCode.SRM_FAILURE, reason);
complete();
}
@Override
public void SpaceReleased(String spaceReservationToken,long remainingSpaceSize){
status = new TReturnStatus(TStatusCode.SRM_SUCCESS, "Space released");
complete();
}
@Override
public void ReleaseSpaceFailed(Exception e){
status = new TReturnStatus(TStatusCode.SRM_FAILURE, e.toString());
complete();
}
}
@Override
public String toString(){
return "SrmReleaseSpace("+request.getSpaceToken()+")";
}
}
|
UTF-8
|
Java
| 6,166 |
java
|
SrmReleaseSpace.java
|
Java
|
[
{
"context": "____\n//\n// $Id$\n// $Author$\n//\n// created 10/05 by Dmitry Litvintsev (litvinse@fnal.gov)\n//\n//________________________",
"end": 144,
"score": 0.9998692274093628,
"start": 127,
"tag": "NAME",
"value": "Dmitry Litvintsev"
},
{
"context": "Author$\n//\n// created 10/05 by Dmitry Litvintsev (litvinse@fnal.gov)\n//\n//___________________________________________",
"end": 163,
"score": 0.9999284744262695,
"start": 146,
"tag": "EMAIL",
"value": "litvinse@fnal.gov"
},
{
"context": ".dcache.srm.v2_2.TStatusCode;\n\n\n/**\n *\n * @author litvinse\n */\n\npublic class SrmReleaseSpace {\n private s",
"end": 927,
"score": 0.9988184571266174,
"start": 919,
"tag": "USERNAME",
"value": "litvinse"
}
] | null |
[] |
//______________________________________________________________________________
//
// $Id$
// $Author$
//
// created 10/05 by <NAME> (<EMAIL>)
//
//______________________________________________________________________________
/*
* SrmCopy
*
* Created on 10/05
*/
package org.dcache.srm.handler;
import org.apache.axis.types.URI.MalformedURIException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.dcache.srm.AbstractStorageElement;
import org.dcache.srm.SRM;
import org.dcache.srm.SRMException;
import org.dcache.srm.SRMUser;
import org.dcache.srm.request.RequestCredential;
import org.dcache.srm.scheduler.Scheduler;
import org.dcache.srm.util.Configuration;
import org.dcache.srm.v2_2.SrmReleaseSpaceRequest;
import org.dcache.srm.v2_2.SrmReleaseSpaceResponse;
import org.dcache.srm.v2_2.TReturnStatus;
import org.dcache.srm.v2_2.TStatusCode;
/**
*
* @author litvinse
*/
public class SrmReleaseSpace {
private static Logger logger =
LoggerFactory.getLogger(SrmReleaseSpace.class);
private final static String SFN_STRING="?SFN=";
AbstractStorageElement storage;
SrmReleaseSpaceRequest request;
SrmReleaseSpaceResponse response;
SRMUser user;
Scheduler scheduler;
RequestCredential credential;
Configuration configuration;
public SrmReleaseSpace(SRMUser user,
RequestCredential credential,
SrmReleaseSpaceRequest request,
AbstractStorageElement storage,
SRM srm,
String client_host) {
if (request == null) {
throw new NullPointerException("request is null");
}
this.request = request;
this.user = user;
this.credential = credential;
if (storage == null) {
throw new NullPointerException("storage is null");
}
this.storage = storage;
this.scheduler = srm.getCopyRequestScheduler();
if (scheduler == null) {
throw new NullPointerException("scheduler is null");
}
this.configuration = srm.getConfiguration();
if (configuration == null) {
throw new NullPointerException("configuration is null");
}
}
public SrmReleaseSpaceResponse getResponse() {
if(response != null ) {
return response;
}
try {
response = releaseSpace();
} catch(MalformedURIException mue) {
logger.debug(" malformed uri : "+mue.getMessage());
response = getFailedResponse(" malformed uri : "+mue.getMessage(),
TStatusCode.SRM_INVALID_REQUEST);
} catch(SRMException srme) {
logger.error(srme.toString());
response = getFailedResponse(srme.toString());
}
return response;
}
private static SrmReleaseSpaceResponse getFailedResponse(String text) {
return getFailedResponse(text, TStatusCode.SRM_FAILURE);
}
private static SrmReleaseSpaceResponse getFailedResponse(String text, TStatusCode statusCode) {
SrmReleaseSpaceResponse response = new SrmReleaseSpaceResponse();
response.setReturnStatus(new TReturnStatus(statusCode, text));
return response;
}
public SrmReleaseSpaceResponse releaseSpace()
throws SRMException,MalformedURIException {
if(request==null) {
return getFailedResponse("srmReleaseSpace: null request passed to SrmReleaseSpace",
TStatusCode.SRM_INVALID_REQUEST);
}
String token = request.getSpaceToken();
SrmReleaseSpaceCallbacks callbacks = new SrmReleaseSpaceCallbacks();
storage.srmReleaseSpace(user,token,null, callbacks );
TReturnStatus status = callbacks.waitResult(60 * 1000);//one minute max
return new SrmReleaseSpaceResponse(status);
}
private class SrmReleaseSpaceCallbacks implements org.dcache.srm.SrmReleaseSpaceCallbacks {
private boolean completed;
private TReturnStatus status;
public SrmReleaseSpaceCallbacks() {
}
public synchronized TReturnStatus waitResult(long timeout)
{
//System.out.println("PutCallbacks waitResult() starting for CopyFileRequest "+fileId);
long start = System.currentTimeMillis();
long current = start;
while(true)
{
if(completed)
{
//System.out.println("PutCallbacks waitResult() completed with success="+success+
//" for CopyFileRequest "+fileId);
return status;
}
long wait = timeout - (current -start);
if(wait > 0)
{
try
{
this.wait(wait);
}
catch(InterruptedException ie){
}
}
else
{
return new TReturnStatus(TStatusCode.SRM_INTERNAL_ERROR, "release takes longer then "+timeout +" millis");
}
current = System.currentTimeMillis();
}
}
public synchronized void complete()
{
this.completed = true;
this.notifyAll();
}
@Override
public void ReleaseSpaceFailed(String reason){
status = new TReturnStatus(TStatusCode.SRM_FAILURE, reason);
complete();
}
@Override
public void SpaceReleased(String spaceReservationToken,long remainingSpaceSize){
status = new TReturnStatus(TStatusCode.SRM_SUCCESS, "Space released");
complete();
}
@Override
public void ReleaseSpaceFailed(Exception e){
status = new TReturnStatus(TStatusCode.SRM_FAILURE, e.toString());
complete();
}
}
@Override
public String toString(){
return "SrmReleaseSpace("+request.getSpaceToken()+")";
}
}
| 6,145 | 0.584982 | 0.580928 | 191 | 31.282722 | 26.363621 | 125 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.471204 | false | false |
3
|
d57535196aceaf34aa93fe0c4b1e963da0c44e3e
| 824,633,743,681 |
6f672fb72caedccb841ee23f53e32aceeaf1895e
|
/sound-cloud_source/src/com/soundcloud/android/offline/DownloadState$Status.java
|
e4f99383baf381cf9684cf3a93f8edf277f1a260
|
[] |
no_license
|
cha63506/CompSecurity
|
https://github.com/cha63506/CompSecurity
|
5c69743f660b9899146ed3cf21eceabe3d5f4280
|
eee7e74f4088b9c02dd711c061fc04fb1e4e2654
|
refs/heads/master
| 2018-03-23T04:15:18.480000 | 2015-12-19T01:29:58 | 2015-12-19T01:29:58 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: braces fieldsfirst space lnc
package com.soundcloud.android.offline;
// Referenced classes of package com.soundcloud.android.offline:
// DownloadState
private static final class _cls9 extends Enum
{
private static final ERROR $VALUES[];
public static final ERROR CANCELLED;
public static final ERROR CONNECTION_ERROR;
public static final ERROR ERROR;
public static final ERROR NOT_ENOUGH_SPACE;
public static final ERROR PROGRESS;
public static final ERROR SUCCESS;
public static final ERROR UNAVAILABLE;
public static _cls9 valueOf(String s)
{
return (_cls9)Enum.valueOf(com/soundcloud/android/offline/DownloadState$Status, s);
}
public static _cls9[] values()
{
return (_cls9[])$VALUES.clone();
}
static
{
PROGRESS = new <init>("PROGRESS", 0);
SUCCESS = new <init>("SUCCESS", 1);
CANCELLED = new <init>("CANCELLED", 2);
UNAVAILABLE = new <init>("UNAVAILABLE", 3);
NOT_ENOUGH_SPACE = new <init>("NOT_ENOUGH_SPACE", 4);
CONNECTION_ERROR = new <init>("CONNECTION_ERROR", 5);
ERROR = new <init>("ERROR", 6);
$VALUES = (new .VALUES[] {
PROGRESS, SUCCESS, CANCELLED, UNAVAILABLE, NOT_ENOUGH_SPACE, CONNECTION_ERROR, ERROR
});
}
private _cls9(String s, int i)
{
super(s, i);
}
}
|
UTF-8
|
Java
| 1,528 |
java
|
DownloadState$Status.java
|
Java
|
[
{
"context": "// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.\n// Jad home page: http://www.geocities.com/kpdus",
"end": 61,
"score": 0.9996511340141296,
"start": 45,
"tag": "NAME",
"value": "Pavel Kouznetsov"
}
] | null |
[] |
// Decompiled by Jad v1.5.8e. Copyright 2001 <NAME>.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: braces fieldsfirst space lnc
package com.soundcloud.android.offline;
// Referenced classes of package com.soundcloud.android.offline:
// DownloadState
private static final class _cls9 extends Enum
{
private static final ERROR $VALUES[];
public static final ERROR CANCELLED;
public static final ERROR CONNECTION_ERROR;
public static final ERROR ERROR;
public static final ERROR NOT_ENOUGH_SPACE;
public static final ERROR PROGRESS;
public static final ERROR SUCCESS;
public static final ERROR UNAVAILABLE;
public static _cls9 valueOf(String s)
{
return (_cls9)Enum.valueOf(com/soundcloud/android/offline/DownloadState$Status, s);
}
public static _cls9[] values()
{
return (_cls9[])$VALUES.clone();
}
static
{
PROGRESS = new <init>("PROGRESS", 0);
SUCCESS = new <init>("SUCCESS", 1);
CANCELLED = new <init>("CANCELLED", 2);
UNAVAILABLE = new <init>("UNAVAILABLE", 3);
NOT_ENOUGH_SPACE = new <init>("NOT_ENOUGH_SPACE", 4);
CONNECTION_ERROR = new <init>("CONNECTION_ERROR", 5);
ERROR = new <init>("ERROR", 6);
$VALUES = (new .VALUES[] {
PROGRESS, SUCCESS, CANCELLED, UNAVAILABLE, NOT_ENOUGH_SPACE, CONNECTION_ERROR, ERROR
});
}
private _cls9(String s, int i)
{
super(s, i);
}
}
| 1,518 | 0.638743 | 0.625654 | 51 | 28.960785 | 24.991732 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.705882 | false | false |
3
|
eff426cd9a1d82e886efb3046b052a51ab560211
| 14,388,140,498,241 |
0d2aed4ed2800b187f9871ed204c714788d69979
|
/ims-microtasks/src/main/java/org/jee8ng/ims/tasks/entity/Issue.java
|
a3b137e153befc2cdd2fb39720198026faf16d77
|
[] |
no_license
|
ramonavacarasu/Issue-Management-System
|
https://github.com/ramonavacarasu/Issue-Management-System
|
613d85b7f349bb102b52d2737673ac2e6455bcd0
|
d04d47f674324724438bf976e446e5e7405907ec
|
refs/heads/master
| 2023-01-20T03:40:44.456000 | 2020-11-16T06:43:52 | 2020-11-16T06:43:52 | 312,873,369 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.jee8ng.ims.tasks.entity;
public class Issue {
private Long id;
private String name;
private String priority;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
@Override
public String toString() {
return "Issue{" + "id=" + id + ", name=" + name + ", priority=" + priority + '}';
}
}
|
UTF-8
|
Java
| 677 |
java
|
Issue.java
|
Java
|
[] | null |
[] |
package org.jee8ng.ims.tasks.entity;
public class Issue {
private Long id;
private String name;
private String priority;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
@Override
public String toString() {
return "Issue{" + "id=" + id + ", name=" + name + ", priority=" + priority + '}';
}
}
| 677 | 0.555391 | 0.553914 | 37 | 17.297297 | 18.118029 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.351351 | false | false |
3
|
0b94c6cc65a41005de15eeccdff3afec0075f96f
| 14,388,140,494,055 |
7ee2d6fe2bcc2f5197039f19e8a4f0bf0f848208
|
/safety/safety-service/src/main/java/com/zte/alm/safety/service/impl/FireBrigadeService.java
|
ee699283487c64d981ff9f31e27e130c038af158
|
[] |
no_license
|
bellmit/project-1
|
https://github.com/bellmit/project-1
|
693e9a7dcad9e6275ca92d10aae71514bbd46829
|
bbc3aa15cbe715b8fe5f6e2644753e47eb1c1107
|
refs/heads/master
| 2022-01-03T07:43:40.862000 | 2018-03-19T09:35:49 | 2018-03-19T09:35:49 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.zte.alm.safety.service.impl;
import com.zte.alm.safety.common.service.BaseService;
import com.zte.alm.safety.repository.entity.SysFireBrigade;
import com.zte.alm.safety.repository.entity.SysUser;
import com.zte.alm.safety.repository.mapper.SysFireBrigadeMapper;
import com.zte.alm.safety.service.IFireBrigadeService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by 6418000384 on 2016/7/20.
*/
@Service
public class FireBrigadeService extends BaseService implements IFireBrigadeService {
@Resource
private SysFireBrigadeMapper sysFireBrigadeMapper;
@Override
public int add(SysFireBrigade sysFireBrigade){
return sysFireBrigadeMapper.insertSelective(sysFireBrigade);
}
@Override
public void deleteByPrimaryKey(Long id){
sysFireBrigadeMapper.deleteByPrimaryKey(id);
}
@Override
public List<Map> query(Map map,SysUser user) throws Exception{
Map queryMap = new HashMap();
if(!this.isMapKeyNull(map,"name"))
{
queryMap.put("name",this.getMapString(map,"name"));
}
if(!this.isMapKeyNull(map,"organization"))
{
queryMap.put("organization",this.getMapString(map,"organization"));
}
if(!this.isMapKeyNull(map,"address"))
{
queryMap.put("address",this.getMapString(map,"address"));
}
//获取符合条件的数据
List<Map> queryResult = sysFireBrigadeMapper.query(queryMap);
return queryResult;
}
@Override
public List<Map> queryAll() throws Exception{
//获取符合条件的数据
List<Map> queryResult = sysFireBrigadeMapper.queryAll();
return queryResult;
}
@Override
public int update(SysFireBrigade sysFireBrigade){
return sysFireBrigadeMapper.updateByPrimaryKey(sysFireBrigade);
}
@Override
public SysFireBrigade selectByPrimaryKey(Long id){
return sysFireBrigadeMapper.selectByPrimaryKey(id);
}
}
|
UTF-8
|
Java
| 2,118 |
java
|
FireBrigadeService.java
|
Java
|
[] | null |
[] |
package com.zte.alm.safety.service.impl;
import com.zte.alm.safety.common.service.BaseService;
import com.zte.alm.safety.repository.entity.SysFireBrigade;
import com.zte.alm.safety.repository.entity.SysUser;
import com.zte.alm.safety.repository.mapper.SysFireBrigadeMapper;
import com.zte.alm.safety.service.IFireBrigadeService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by 6418000384 on 2016/7/20.
*/
@Service
public class FireBrigadeService extends BaseService implements IFireBrigadeService {
@Resource
private SysFireBrigadeMapper sysFireBrigadeMapper;
@Override
public int add(SysFireBrigade sysFireBrigade){
return sysFireBrigadeMapper.insertSelective(sysFireBrigade);
}
@Override
public void deleteByPrimaryKey(Long id){
sysFireBrigadeMapper.deleteByPrimaryKey(id);
}
@Override
public List<Map> query(Map map,SysUser user) throws Exception{
Map queryMap = new HashMap();
if(!this.isMapKeyNull(map,"name"))
{
queryMap.put("name",this.getMapString(map,"name"));
}
if(!this.isMapKeyNull(map,"organization"))
{
queryMap.put("organization",this.getMapString(map,"organization"));
}
if(!this.isMapKeyNull(map,"address"))
{
queryMap.put("address",this.getMapString(map,"address"));
}
//获取符合条件的数据
List<Map> queryResult = sysFireBrigadeMapper.query(queryMap);
return queryResult;
}
@Override
public List<Map> queryAll() throws Exception{
//获取符合条件的数据
List<Map> queryResult = sysFireBrigadeMapper.queryAll();
return queryResult;
}
@Override
public int update(SysFireBrigade sysFireBrigade){
return sysFireBrigadeMapper.updateByPrimaryKey(sysFireBrigade);
}
@Override
public SysFireBrigade selectByPrimaryKey(Long id){
return sysFireBrigadeMapper.selectByPrimaryKey(id);
}
}
| 2,118 | 0.698847 | 0.690682 | 70 | 28.742857 | 25.188255 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.485714 | false | false |
3
|
99bf9d639cbdb42ae0cc119c4c20dfc50e84b4e6
| 1,340,029,832,467 |
961183d02b796d3f1ea7eb2d628337c93bb97a19
|
/src/waste1.java
|
63398991f3b031760d047b940599660057d7c4bb
|
[] |
no_license
|
anuj99singh/Quiz-Management-System
|
https://github.com/anuj99singh/Quiz-Management-System
|
04b46efea38c2699d1c4ca120f78b20718665e0e
|
3cdf1c0c2d7a11b124c27767a7698ab4b032a529
|
refs/heads/master
| 2023-05-12T16:36:17.999000 | 2021-06-03T09:43:49 | 2021-06-03T09:43:49 | 343,671,602 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class waste1
*/
@WebServlet("/waste1")
public class waste1 extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html");
PrintWriter out = response.getWriter();
int i=Integer.parseInt(request.getParameter("t0"));
if(i==1) {
RequestDispatcher r=request.getRequestDispatcher("quiz_s.html");
r.include(request, response);
}
else if(i==2) {
RequestDispatcher r=request.getRequestDispatcher("quiz update karan ");
r.include(request, response);
}
else if(i==3) {
RequestDispatcher r=request.getRequestDispatcher("quiz_view.jsp");
r.forward(request, response);
}
}
}
|
UTF-8
|
Java
| 1,170 |
java
|
waste1.java
|
Java
|
[] | null |
[] |
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class waste1
*/
@WebServlet("/waste1")
public class waste1 extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html");
PrintWriter out = response.getWriter();
int i=Integer.parseInt(request.getParameter("t0"));
if(i==1) {
RequestDispatcher r=request.getRequestDispatcher("quiz_s.html");
r.include(request, response);
}
else if(i==2) {
RequestDispatcher r=request.getRequestDispatcher("quiz update karan ");
r.include(request, response);
}
else if(i==3) {
RequestDispatcher r=request.getRequestDispatcher("quiz_view.jsp");
r.forward(request, response);
}
}
}
| 1,170 | 0.752137 | 0.745299 | 43 | 26.16279 | 25.655073 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.651163 | false | false |
3
|
e2fcf08f23dfdc7f1bac39f7e1635f8c64729461
| 2,448,131,423,722 |
7079d7733d0598e4a0d1fd5d29fff9682959b5f4
|
/src/dto/Cart.java
|
44cd92f45fab4d39f58a6ed30a8d8d4850c36c88
|
[] |
no_license
|
AmilaGalijasevic/MobileShop
|
https://github.com/AmilaGalijasevic/MobileShop
|
443d46442b640764e11454f80d181210b5b57118
|
f4ff4d921866edf41a46521972056a49a4fb181b
|
refs/heads/master
| 2021-01-19T05:30:26.568000 | 2016-06-13T07:15:26 | 2016-06-13T07:15:26 | 60,838,280 | 0 | 1 | null | false | 2016-06-13T07:15:27 | 2016-06-10T09:52:24 | 2016-06-10T10:07:09 | 2016-06-13T07:15:26 | 1,034 | 0 | 1 | 4 |
Java
| null | null |
package dto;
public class Cart {
private int cartId;
private int productId;
private int userId;
private String ProductName;
public Cart() {
super();
}
public Cart(int cartId, int productId, int userId, String productName) {
super();
this.cartId = cartId;
this.productId = productId;
this.userId = userId;
ProductName = productName;
}
public int getCartId() {
return cartId;
}
public void setCartId(int cartId) {
this.cartId = cartId;
}
public int getProductId() {
return productId;
}
public void setProductId(int productId) {
this.productId = productId;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getProductName() {
return ProductName;
}
public void setProductName(String productName) {
ProductName = productName;
}
}
|
UTF-8
|
Java
| 861 |
java
|
Cart.java
|
Java
|
[] | null |
[] |
package dto;
public class Cart {
private int cartId;
private int productId;
private int userId;
private String ProductName;
public Cart() {
super();
}
public Cart(int cartId, int productId, int userId, String productName) {
super();
this.cartId = cartId;
this.productId = productId;
this.userId = userId;
ProductName = productName;
}
public int getCartId() {
return cartId;
}
public void setCartId(int cartId) {
this.cartId = cartId;
}
public int getProductId() {
return productId;
}
public void setProductId(int productId) {
this.productId = productId;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getProductName() {
return ProductName;
}
public void setProductName(String productName) {
ProductName = productName;
}
}
| 861 | 0.695703 | 0.695703 | 57 | 14.105263 | 15.482513 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.298246 | false | false |
3
|
85abfd9d554801a854bff7b0a3ae13622cfca0c3
| 32,890,859,564,819 |
cda89bc584023d8112f8ec73302f9e7925fbcdb2
|
/src/constants/ConstantHandler.java
|
394ef710b21ad0c92515332644408bd4493b18fe
|
[] |
no_license
|
mohamedwahba/Gaith
|
https://github.com/mohamedwahba/Gaith
|
1e7ec9700bf1ca0ee7408bf55db8a8a1ff1dd097
|
9ab899ba0dcdcc899684932841b9f8eda825b6fd
|
refs/heads/master
| 2021-01-16T21:15:24.287000 | 2013-04-25T15:03:43 | 2013-04-25T15:03:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package constants;
import java.util.HashMap;
public class ConstantHandler {
// Indexing Wiki
public static final int INDEX_WIKI_LIMIT = 5;
public static final int WIKIPEDIA_SIZE = 4489;
public static final String WIKI_MAPPER_INIT = "WikiInit.txt";
public static final String WIKI_INDEX = "./index";
// Indexing Corpus
public static final int INDEX_CORPUS_LIMIT = 25;
public static final int CORPUS_SIZE = 134;
public static final String CORPUS_MAPPER_INIT = "CorpusInit.txt";
public static final String CORPUS_INDEX = "./corpusIndex";
// Query Handler
public static final HashMap<Integer, Double> NULL_HASH = new HashMap<Integer, Double>();
// Logger
public static enum LOG_TYPES {DEBUG,EVENT,WORNING,ERROR};
public static boolean LOG_DEBUG = true;
public static boolean LOG_EVENT = true;
public static boolean LOG_WORNING = true;
public static boolean LOG_ERROR = true;
/*
* Index
*/
public static final int KMEANS = 1;
public static final int DBSCAN = 2;
public static final int MITOSIS = 3;
public static final int SHC = 4;
/*
* Constants
*/
public static final int NUMBEROFDOCUMENTS = 0;
public static final int NUMBEROFCONCEPTS = 0;
public static final int NUMBEROFCENTROIDS = 0;
public static final int MAXITERATIONS = 0;
public static final double EPSLION = 1.0;
public static final int MINPOINTS = 5;
public static final double F = 0.0;
public static final double K = 0.0;
public static final double ESA_MAX_SCORE = 1.0;
}
|
UTF-8
|
Java
| 1,537 |
java
|
ConstantHandler.java
|
Java
|
[] | null |
[] |
package constants;
import java.util.HashMap;
public class ConstantHandler {
// Indexing Wiki
public static final int INDEX_WIKI_LIMIT = 5;
public static final int WIKIPEDIA_SIZE = 4489;
public static final String WIKI_MAPPER_INIT = "WikiInit.txt";
public static final String WIKI_INDEX = "./index";
// Indexing Corpus
public static final int INDEX_CORPUS_LIMIT = 25;
public static final int CORPUS_SIZE = 134;
public static final String CORPUS_MAPPER_INIT = "CorpusInit.txt";
public static final String CORPUS_INDEX = "./corpusIndex";
// Query Handler
public static final HashMap<Integer, Double> NULL_HASH = new HashMap<Integer, Double>();
// Logger
public static enum LOG_TYPES {DEBUG,EVENT,WORNING,ERROR};
public static boolean LOG_DEBUG = true;
public static boolean LOG_EVENT = true;
public static boolean LOG_WORNING = true;
public static boolean LOG_ERROR = true;
/*
* Index
*/
public static final int KMEANS = 1;
public static final int DBSCAN = 2;
public static final int MITOSIS = 3;
public static final int SHC = 4;
/*
* Constants
*/
public static final int NUMBEROFDOCUMENTS = 0;
public static final int NUMBEROFCONCEPTS = 0;
public static final int NUMBEROFCENTROIDS = 0;
public static final int MAXITERATIONS = 0;
public static final double EPSLION = 1.0;
public static final int MINPOINTS = 5;
public static final double F = 0.0;
public static final double K = 0.0;
public static final double ESA_MAX_SCORE = 1.0;
}
| 1,537 | 0.708523 | 0.690956 | 50 | 28.74 | 22.007099 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.54 | false | false |
3
|
bb5fc6aa35c44a0f03f3aabd58960e64b8fba853
| 26,766,236,208,194 |
52d2e552a3b6defd903734513a9c33395a671486
|
/app/src/main/java/post/com/boxes/MainActivity.java
|
4a9e15c8864084124128f20ca5b95e917bd33ae7
|
[] |
no_license
|
purplesunset871019/Boxes
|
https://github.com/purplesunset871019/Boxes
|
d0cc97a846decd1a431beea55175a9aea38ceb06
|
24fa2d62d84c5099193f1348c6b737818efead44
|
refs/heads/master
| 2020-04-04T22:43:09.834000 | 2018-11-06T07:50:29 | 2018-11-06T07:50:29 | 156,333,245 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package post.com.boxes;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
private EditText edlength;
private EditText edwidth;
private EditText edheight;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViews();
}
private void findViews() {
edlength = findViewById(R.id.ed_length);
edwidth = findViewById(R.id.ed_width);
edheight = findViewById(R.id.ed_height);
}
public void boxes(View view){
float length = Float.parseFloat(edlength.getText().toString());
float width = Float.parseFloat(edwidth.getText().toString());
float height = Float.parseFloat(edheight.getText().toString());
if(length<=23 && width<=14 && height<=13){
Intent intent = new Intent(this,Box3Activity.class);
startActivity(intent);
}
else if(length<=39.5 && width<=27.5 && height<=23){
Intent intent = new Intent(this,Box5Activity.class);
startActivity(intent);
}
}
}
|
UTF-8
|
Java
| 1,301 |
java
|
MainActivity.java
|
Java
|
[] | null |
[] |
package post.com.boxes;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
private EditText edlength;
private EditText edwidth;
private EditText edheight;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViews();
}
private void findViews() {
edlength = findViewById(R.id.ed_length);
edwidth = findViewById(R.id.ed_width);
edheight = findViewById(R.id.ed_height);
}
public void boxes(View view){
float length = Float.parseFloat(edlength.getText().toString());
float width = Float.parseFloat(edwidth.getText().toString());
float height = Float.parseFloat(edheight.getText().toString());
if(length<=23 && width<=14 && height<=13){
Intent intent = new Intent(this,Box3Activity.class);
startActivity(intent);
}
else if(length<=39.5 && width<=27.5 && height<=23){
Intent intent = new Intent(this,Box5Activity.class);
startActivity(intent);
}
}
}
| 1,301 | 0.656418 | 0.643351 | 42 | 29.976191 | 22.763262 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.571429 | false | false |
3
|
10a26b05284fabf2be54ed9c54e758d08512d958
| 35,631,048,713,661 |
05eb8f6b23ff2c584b7dff3d8036c46b4b2dd3c6
|
/src/com/Prac1.java
|
910eb6bef2425385ec2e2e61a583056f01774a99
|
[] |
no_license
|
yangsiyugithub/Test
|
https://github.com/yangsiyugithub/Test
|
24d69c37f0d6557b11eb0f691f780805918ebf52
|
80d63cdaf3f2b719e037e2bd41b202fe8e9f2cb4
|
refs/heads/master
| 2022-11-23T04:58:26.140000 | 2020-07-17T02:16:55 | 2020-07-17T02:16:55 | 280,080,743 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import util.DBUtil;
public class Prac1 {
public static void main(String[] args) throws Exception {
Connection conn =DBUtil.getConnection();
Statement stm=conn.createStatement();
String sql = "select * from userinfo";
ResultSet rs=stm.executeQuery(sql);
while(rs.next()){
int id=rs.getInt(1);
String username=rs.getString("username");
String password=rs.getString("password");
String note=rs.getString("note");
System.out.println("id:"+id+";"+"username:"+username+";"+"password:"+password+";"+"note:"+note);
}
DBUtil.close(conn, stm, rs);
}
}
|
UTF-8
|
Java
| 792 |
java
|
Prac1.java
|
Java
|
[
{
"context": "s.getInt(1);\r\n\t\t\t\t\t\tString username=rs.getString(\"username\");\r\n\t\t\t\t\t\tString password=rs.getString(\"password\"",
"end": 533,
"score": 0.7228361964225769,
"start": 525,
"tag": "USERNAME",
"value": "username"
},
{
"context": "\t\t\t\t\t\tSystem.out.println(\"id:\"+id+\";\"+\"username:\"+username+\";\"+\"password:\"+password+\";\"+\"note:\"+note);\t\r\n\t\t\t",
"end": 686,
"score": 0.9367243051528931,
"start": 678,
"tag": "USERNAME",
"value": "username"
},
{
"context": "\"id:\"+id+\";\"+\"username:\"+username+\";\"+\"password:\"+password+\";\"+\"note:\"+note);\t\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\tDBUtil.c",
"end": 711,
"score": 0.9793376922607422,
"start": 703,
"tag": "PASSWORD",
"value": "password"
}
] | null |
[] |
package com;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import util.DBUtil;
public class Prac1 {
public static void main(String[] args) throws Exception {
Connection conn =DBUtil.getConnection();
Statement stm=conn.createStatement();
String sql = "select * from userinfo";
ResultSet rs=stm.executeQuery(sql);
while(rs.next()){
int id=rs.getInt(1);
String username=rs.getString("username");
String password=rs.getString("password");
String note=rs.getString("note");
System.out.println("id:"+id+";"+"username:"+username+";"+"password:"+<PASSWORD>+";"+"note:"+note);
}
DBUtil.close(conn, stm, rs);
}
}
| 794 | 0.626263 | 0.623737 | 30 | 24.4 | 22.788301 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.466667 | false | false |
3
|
b3ecfa6f9af6178d679ff42722ece48e74e1c00e
| 36,172,214,602,343 |
c82e7fb693d36aac852e0db1c943a674ea2e3f52
|
/src/main/java/com/java/o2o/enums/ShopStateEnum.java
|
3cee5b0deb3a12a2d66cbf6048e5426d68646395
|
[] |
no_license
|
shiqianghua/CampusShops
|
https://github.com/shiqianghua/CampusShops
|
585106d24be31292f3dbd4ea7b9b188ade908356
|
a73c1166af2e370ca64b35b3d283d91f5df4fb2f
|
refs/heads/master
| 2022-12-21T19:54:07.991000 | 2019-08-09T08:53:07 | 2019-08-09T08:53:07 | 200,620,482 | 0 | 1 | null | false | 2022-12-16T05:01:06 | 2019-08-05T09:02:01 | 2019-08-09T12:05:47 | 2022-12-16T05:01:03 | 92,824 | 0 | 1 | 11 |
Java
| false | false |
package com.java.o2o.enums;
public enum ShopStateEnum {
// 每个枚举类类型都是该类对象
CHECK(0,"审核中"),OFFLINE(-1,"非法店铺"),SUCCESS(1,"操作成功"),NULL_SHOP(-1003,"shop的信息为空"),
PASS(2,"认证通过"),INNER_ERROR(-1001,"内部系统错误"),NULL_SHOPID(-1002,"ShopId为空");
private int state;
private String stateInfo;
private ShopStateEnum(int state, String stateInfo) {
this.state = state;
this.stateInfo = stateInfo;
}
//根据传入的state返回相应的enum值
public static ShopStateEnum stateOf(int state){
for(ShopStateEnum stateEnum:values()){
if(stateEnum.getState()==state){
return stateEnum;
}
}
return null;
}
public int getState() {
return state;
}
public String getStateInfo() {
return stateInfo;
}
}
|
UTF-8
|
Java
| 942 |
java
|
ShopStateEnum.java
|
Java
|
[] | null |
[] |
package com.java.o2o.enums;
public enum ShopStateEnum {
// 每个枚举类类型都是该类对象
CHECK(0,"审核中"),OFFLINE(-1,"非法店铺"),SUCCESS(1,"操作成功"),NULL_SHOP(-1003,"shop的信息为空"),
PASS(2,"认证通过"),INNER_ERROR(-1001,"内部系统错误"),NULL_SHOPID(-1002,"ShopId为空");
private int state;
private String stateInfo;
private ShopStateEnum(int state, String stateInfo) {
this.state = state;
this.stateInfo = stateInfo;
}
//根据传入的state返回相应的enum值
public static ShopStateEnum stateOf(int state){
for(ShopStateEnum stateEnum:values()){
if(stateEnum.getState()==state){
return stateEnum;
}
}
return null;
}
public int getState() {
return state;
}
public String getStateInfo() {
return stateInfo;
}
}
| 942 | 0.579952 | 0.559666 | 33 | 23.39394 | 21.612202 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.727273 | false | false |
3
|
55de1785c0c47ce41769d3fd022de71146346ec1
| 35,570,919,178,400 |
dcf1a4b97f1630be4553cfebd4e74abd5f5c80ce
|
/app/src/main/java/com/xiandong/fst/view/activity/MyWalletDetailsActivity.java
|
de3644d4b1e795d958cfbb7ae07ad468c5a66e5f
|
[] |
no_license
|
EGOSICK/NewFenShenTu
|
https://github.com/EGOSICK/NewFenShenTu
|
39d39c6f01121c4a26c88bcb6430589972e916dd
|
58693c40a4d06e054c22a797c1ca68aca3287cfa
|
refs/heads/master
| 2021-01-11T06:36:24.838000 | 2017-03-02T08:04:18 | 2017-03-02T08:04:18 | 81,193,359 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.xiandong.fst.view.activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.xiandong.fst.R;
import com.xiandong.fst.model.bean.MoneyRecordBean;
import com.xiandong.fst.presenter.MoneyRecordPresenterImpl;
import com.xiandong.fst.tools.adapter.MyWalletDetailsAdapter;
import com.xiandong.fst.view.MoneyRecordView;
import com.xiandong.fst.view.customview.emptyview.HHEmptyView;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
/**
* Created by dell on 2017/1/21.
*/
@ContentView(R.layout.activity_my_wallet_details)
public class MyWalletDetailsActivity extends AbsBaseActivity implements MoneyRecordView {
@ViewInject(R.id.myWalletDetailsLv)
private ListView myWalletDetailsLv;
@ViewInject(R.id.titleBackImg)
ImageView titleBackImg;
@ViewInject(R.id.titleTitleTv)
TextView titleTitleTv;
@ViewInject(R.id.hhEmptyView)
HHEmptyView hhEmptyView;
MoneyRecordPresenterImpl presenter;
private MyWalletDetailsAdapter adapter;
String act;
@Override
protected void initialize() {
hhEmptyView.bindView(myWalletDetailsLv);
hhEmptyView.setOnBtnClickListener(new HHEmptyView.OnBtnClickListener() {
@Override
public void onBtnClick() {
presenter.getMoneyRecord();
}
});
presenter = new MoneyRecordPresenterImpl(this);
presenter.getMoneyRecord();
adapter = new MyWalletDetailsAdapter(this);
act = getIntent().getStringExtra("act");
switch (act) {
case "2":
titleTitleTv.setText("佣金记录");
break;
case "3":
titleTitleTv.setText("提现记录");
break;
default:
titleTitleTv.setText("消费记录");
break;
}
myWalletDetailsLv.setAdapter(adapter);
}
@Event(type = View.OnClickListener.class, value = {R.id.titleBackImg})
private void onClickListener(View view) {
switch (view.getId()) {
case R.id.titleBackImg:
finish();
break;
}
}
@Override
public void moneyRecordSuccess(MoneyRecordBean recordBean) {
adapter.addData(act, recordBean);
hhEmptyView.success();
}
@Override
public void moneyRecordFails(String err) {
hhEmptyView.empty(err);
}
}
|
UTF-8
|
Java
| 2,614 |
java
|
MyWalletDetailsActivity.java
|
Java
|
[
{
"context": "ils.view.annotation.ViewInject;\n\n/**\n * Created by dell on 2017/1/21.\n */\n@ContentView(R.layout.activity_",
"end": 684,
"score": 0.9283685684204102,
"start": 680,
"tag": "USERNAME",
"value": "dell"
}
] | null |
[] |
package com.xiandong.fst.view.activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.xiandong.fst.R;
import com.xiandong.fst.model.bean.MoneyRecordBean;
import com.xiandong.fst.presenter.MoneyRecordPresenterImpl;
import com.xiandong.fst.tools.adapter.MyWalletDetailsAdapter;
import com.xiandong.fst.view.MoneyRecordView;
import com.xiandong.fst.view.customview.emptyview.HHEmptyView;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
/**
* Created by dell on 2017/1/21.
*/
@ContentView(R.layout.activity_my_wallet_details)
public class MyWalletDetailsActivity extends AbsBaseActivity implements MoneyRecordView {
@ViewInject(R.id.myWalletDetailsLv)
private ListView myWalletDetailsLv;
@ViewInject(R.id.titleBackImg)
ImageView titleBackImg;
@ViewInject(R.id.titleTitleTv)
TextView titleTitleTv;
@ViewInject(R.id.hhEmptyView)
HHEmptyView hhEmptyView;
MoneyRecordPresenterImpl presenter;
private MyWalletDetailsAdapter adapter;
String act;
@Override
protected void initialize() {
hhEmptyView.bindView(myWalletDetailsLv);
hhEmptyView.setOnBtnClickListener(new HHEmptyView.OnBtnClickListener() {
@Override
public void onBtnClick() {
presenter.getMoneyRecord();
}
});
presenter = new MoneyRecordPresenterImpl(this);
presenter.getMoneyRecord();
adapter = new MyWalletDetailsAdapter(this);
act = getIntent().getStringExtra("act");
switch (act) {
case "2":
titleTitleTv.setText("佣金记录");
break;
case "3":
titleTitleTv.setText("提现记录");
break;
default:
titleTitleTv.setText("消费记录");
break;
}
myWalletDetailsLv.setAdapter(adapter);
}
@Event(type = View.OnClickListener.class, value = {R.id.titleBackImg})
private void onClickListener(View view) {
switch (view.getId()) {
case R.id.titleBackImg:
finish();
break;
}
}
@Override
public void moneyRecordSuccess(MoneyRecordBean recordBean) {
adapter.addData(act, recordBean);
hhEmptyView.success();
}
@Override
public void moneyRecordFails(String err) {
hhEmptyView.empty(err);
}
}
| 2,614 | 0.667954 | 0.664479 | 86 | 29.11628 | 20.106356 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.511628 | false | false |
3
|
0eb52504ceb3d76fa28c4b65837f9445e0f4c960
| 37,795,712,226,359 |
082e26b011e30dc62a62fae95f375e4f87d9e99c
|
/docs/weixin_7.0.4_source/反编译源码/反混淆后/src/main/java/com/tencent/p177mm/protocal/protobuf/C15373py.java
|
25c8041d2462606dc8682640eea5a4653aad5b0d
|
[] |
no_license
|
xsren/AndroidReverseNotes
|
https://github.com/xsren/AndroidReverseNotes
|
9631a5aabc031006e795a112b7ac756a8edd4385
|
9202c276fe9f04a978e4e08b08e42645d97ca94b
|
refs/heads/master
| 2021-04-07T22:50:51.072000 | 2019-07-16T02:24:43 | 2019-07-16T02:24:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.tencent.p177mm.protocal.protobuf;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.p177mm.p205bt.C1331a;
import java.util.LinkedList;
import p690e.p691a.p692a.C6087a;
import p690e.p691a.p692a.C6092b;
import p690e.p691a.p692a.p693a.C6086a;
import p690e.p691a.p692a.p695b.p697b.C6091a;
import p690e.p691a.p692a.p698c.C6093a;
/* renamed from: com.tencent.mm.protocal.protobuf.py */
public final class C15373py extends bsr {
public String cBT;
public String pPZ;
public String pQe;
public long pSg;
public String vWF;
public String vWY;
/* renamed from: op */
public final int mo4669op(int i, Object... objArr) {
AppMethodBeat.m2504i(48812);
C6092b c6092b;
int ix;
if (i == 0) {
C6093a c6093a = (C6093a) objArr[0];
if (this.cBT == null) {
c6092b = new C6092b("Not all required fields were included: req_key");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else if (this.vWY == null) {
c6092b = new C6092b("Not all required fields were included: transfer_id");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else if (this.pQe == null) {
c6092b = new C6092b("Not all required fields were included: transaction_id");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else if (this.pPZ == null) {
c6092b = new C6092b("Not all required fields were included: receiver_openid");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else {
if (this.BaseRequest != null) {
c6093a.mo13479iy(1, this.BaseRequest.computeSize());
this.BaseRequest.writeFields(c6093a);
}
if (this.cBT != null) {
c6093a.mo13475e(2, this.cBT);
}
if (this.vWY != null) {
c6093a.mo13475e(3, this.vWY);
}
if (this.pQe != null) {
c6093a.mo13475e(4, this.pQe);
}
if (this.pPZ != null) {
c6093a.mo13475e(5, this.pPZ);
}
c6093a.mo13472ai(6, this.pSg);
if (this.vWF != null) {
c6093a.mo13475e(7, this.vWF);
}
AppMethodBeat.m2505o(48812);
return 0;
}
} else if (i == 1) {
if (this.BaseRequest != null) {
ix = C6087a.m9557ix(1, this.BaseRequest.computeSize()) + 0;
} else {
ix = 0;
}
if (this.cBT != null) {
ix += C6091a.m9575f(2, this.cBT);
}
if (this.vWY != null) {
ix += C6091a.m9575f(3, this.vWY);
}
if (this.pQe != null) {
ix += C6091a.m9575f(4, this.pQe);
}
if (this.pPZ != null) {
ix += C6091a.m9575f(5, this.pPZ);
}
ix += C6091a.m9578o(6, this.pSg);
if (this.vWF != null) {
ix += C6091a.m9575f(7, this.vWF);
}
AppMethodBeat.m2505o(48812);
return ix;
} else if (i == 2) {
C6086a c6086a = new C6086a((byte[]) objArr[0], unknownTagHandler);
for (ix = C1331a.getNextFieldNumber(c6086a); ix > 0; ix = C1331a.getNextFieldNumber(c6086a)) {
if (!super.populateBuilderWithField(c6086a, this, ix)) {
c6086a.ems();
}
}
if (this.cBT == null) {
c6092b = new C6092b("Not all required fields were included: req_key");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else if (this.vWY == null) {
c6092b = new C6092b("Not all required fields were included: transfer_id");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else if (this.pQe == null) {
c6092b = new C6092b("Not all required fields were included: transaction_id");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else if (this.pPZ == null) {
c6092b = new C6092b("Not all required fields were included: receiver_openid");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else {
AppMethodBeat.m2505o(48812);
return 0;
}
} else if (i == 3) {
C6086a c6086a2 = (C6086a) objArr[0];
C15373py c15373py = (C15373py) objArr[1];
int intValue = ((Integer) objArr[2]).intValue();
switch (intValue) {
case 1:
LinkedList Vh = c6086a2.mo13445Vh(intValue);
int size = Vh.size();
for (intValue = 0; intValue < size; intValue++) {
byte[] bArr = (byte[]) Vh.get(intValue);
C7267hl c7267hl = new C7267hl();
C6086a c6086a3 = new C6086a(bArr, unknownTagHandler);
for (boolean z = true; z; z = c7267hl.populateBuilderWithField(c6086a3, c7267hl, C1331a.getNextFieldNumber(c6086a3))) {
}
c15373py.BaseRequest = c7267hl;
}
AppMethodBeat.m2505o(48812);
return 0;
case 2:
c15373py.cBT = c6086a2.BTU.readString();
AppMethodBeat.m2505o(48812);
return 0;
case 3:
c15373py.vWY = c6086a2.BTU.readString();
AppMethodBeat.m2505o(48812);
return 0;
case 4:
c15373py.pQe = c6086a2.BTU.readString();
AppMethodBeat.m2505o(48812);
return 0;
case 5:
c15373py.pPZ = c6086a2.BTU.readString();
AppMethodBeat.m2505o(48812);
return 0;
case 6:
c15373py.pSg = c6086a2.BTU.mo13459ve();
AppMethodBeat.m2505o(48812);
return 0;
case 7:
c15373py.vWF = c6086a2.BTU.readString();
AppMethodBeat.m2505o(48812);
return 0;
default:
AppMethodBeat.m2505o(48812);
return -1;
}
} else {
AppMethodBeat.m2505o(48812);
return -1;
}
}
}
|
UTF-8
|
Java
| 6,810 |
java
|
C15373py.java
|
Java
|
[] | null |
[] |
package com.tencent.p177mm.protocal.protobuf;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.p177mm.p205bt.C1331a;
import java.util.LinkedList;
import p690e.p691a.p692a.C6087a;
import p690e.p691a.p692a.C6092b;
import p690e.p691a.p692a.p693a.C6086a;
import p690e.p691a.p692a.p695b.p697b.C6091a;
import p690e.p691a.p692a.p698c.C6093a;
/* renamed from: com.tencent.mm.protocal.protobuf.py */
public final class C15373py extends bsr {
public String cBT;
public String pPZ;
public String pQe;
public long pSg;
public String vWF;
public String vWY;
/* renamed from: op */
public final int mo4669op(int i, Object... objArr) {
AppMethodBeat.m2504i(48812);
C6092b c6092b;
int ix;
if (i == 0) {
C6093a c6093a = (C6093a) objArr[0];
if (this.cBT == null) {
c6092b = new C6092b("Not all required fields were included: req_key");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else if (this.vWY == null) {
c6092b = new C6092b("Not all required fields were included: transfer_id");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else if (this.pQe == null) {
c6092b = new C6092b("Not all required fields were included: transaction_id");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else if (this.pPZ == null) {
c6092b = new C6092b("Not all required fields were included: receiver_openid");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else {
if (this.BaseRequest != null) {
c6093a.mo13479iy(1, this.BaseRequest.computeSize());
this.BaseRequest.writeFields(c6093a);
}
if (this.cBT != null) {
c6093a.mo13475e(2, this.cBT);
}
if (this.vWY != null) {
c6093a.mo13475e(3, this.vWY);
}
if (this.pQe != null) {
c6093a.mo13475e(4, this.pQe);
}
if (this.pPZ != null) {
c6093a.mo13475e(5, this.pPZ);
}
c6093a.mo13472ai(6, this.pSg);
if (this.vWF != null) {
c6093a.mo13475e(7, this.vWF);
}
AppMethodBeat.m2505o(48812);
return 0;
}
} else if (i == 1) {
if (this.BaseRequest != null) {
ix = C6087a.m9557ix(1, this.BaseRequest.computeSize()) + 0;
} else {
ix = 0;
}
if (this.cBT != null) {
ix += C6091a.m9575f(2, this.cBT);
}
if (this.vWY != null) {
ix += C6091a.m9575f(3, this.vWY);
}
if (this.pQe != null) {
ix += C6091a.m9575f(4, this.pQe);
}
if (this.pPZ != null) {
ix += C6091a.m9575f(5, this.pPZ);
}
ix += C6091a.m9578o(6, this.pSg);
if (this.vWF != null) {
ix += C6091a.m9575f(7, this.vWF);
}
AppMethodBeat.m2505o(48812);
return ix;
} else if (i == 2) {
C6086a c6086a = new C6086a((byte[]) objArr[0], unknownTagHandler);
for (ix = C1331a.getNextFieldNumber(c6086a); ix > 0; ix = C1331a.getNextFieldNumber(c6086a)) {
if (!super.populateBuilderWithField(c6086a, this, ix)) {
c6086a.ems();
}
}
if (this.cBT == null) {
c6092b = new C6092b("Not all required fields were included: req_key");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else if (this.vWY == null) {
c6092b = new C6092b("Not all required fields were included: transfer_id");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else if (this.pQe == null) {
c6092b = new C6092b("Not all required fields were included: transaction_id");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else if (this.pPZ == null) {
c6092b = new C6092b("Not all required fields were included: receiver_openid");
AppMethodBeat.m2505o(48812);
throw c6092b;
} else {
AppMethodBeat.m2505o(48812);
return 0;
}
} else if (i == 3) {
C6086a c6086a2 = (C6086a) objArr[0];
C15373py c15373py = (C15373py) objArr[1];
int intValue = ((Integer) objArr[2]).intValue();
switch (intValue) {
case 1:
LinkedList Vh = c6086a2.mo13445Vh(intValue);
int size = Vh.size();
for (intValue = 0; intValue < size; intValue++) {
byte[] bArr = (byte[]) Vh.get(intValue);
C7267hl c7267hl = new C7267hl();
C6086a c6086a3 = new C6086a(bArr, unknownTagHandler);
for (boolean z = true; z; z = c7267hl.populateBuilderWithField(c6086a3, c7267hl, C1331a.getNextFieldNumber(c6086a3))) {
}
c15373py.BaseRequest = c7267hl;
}
AppMethodBeat.m2505o(48812);
return 0;
case 2:
c15373py.cBT = c6086a2.BTU.readString();
AppMethodBeat.m2505o(48812);
return 0;
case 3:
c15373py.vWY = c6086a2.BTU.readString();
AppMethodBeat.m2505o(48812);
return 0;
case 4:
c15373py.pQe = c6086a2.BTU.readString();
AppMethodBeat.m2505o(48812);
return 0;
case 5:
c15373py.pPZ = c6086a2.BTU.readString();
AppMethodBeat.m2505o(48812);
return 0;
case 6:
c15373py.pSg = c6086a2.BTU.mo13459ve();
AppMethodBeat.m2505o(48812);
return 0;
case 7:
c15373py.vWF = c6086a2.BTU.readString();
AppMethodBeat.m2505o(48812);
return 0;
default:
AppMethodBeat.m2505o(48812);
return -1;
}
} else {
AppMethodBeat.m2505o(48812);
return -1;
}
}
}
| 6,810 | 0.471953 | 0.359325 | 170 | 39.058823 | 21.917683 | 143 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.747059 | false | false |
3
|
feaeb82b8e0e6bd366dce4399eaaecbca0e9b63b
| 37,400,575,241,412 |
a69e8db802fddecfc0388e3797cbd9b5238af860
|
/源代码/client/src/listener/LaterListener.java
|
a578f70a412ad49041009e5ea01358e13953c091
|
[] |
no_license
|
sssssqqqqq/LAN_Messenger_java
|
https://github.com/sssssqqqqq/LAN_Messenger_java
|
b1bedf40fab332421b9bb392818eef6ede33c968
|
4d3be978250ee787815bcadf74fb52eb87bc6835
|
refs/heads/master
| 2021-12-04T08:18:35.560000 | 2015-02-14T08:48:57 | 2015-02-14T08:48:57 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package listener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.ObjectOutputStream;
import javax.swing.JOptionPane;
import frame.ChatRecordFrame;
import frame.LaterLoadFrame;
import frame.PasswordFrame;
import panel.LaterLoadPanel;
import pub.PackType;
import pub.QQPackage;
import tool.StaticTool;
public class LaterListener implements ActionListener {
LaterLoadPanel laterLoadPanel;
LaterLoadFrame laterLoadFrame;
private PasswordFrame passwordFrame;
public LaterListener(LaterLoadPanel laterLoadPanel,
LaterLoadFrame laterLoadFrame) {
this.laterLoadPanel = laterLoadPanel;
this.laterLoadFrame = laterLoadFrame;
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == laterLoadPanel.getButton()) {
passwordFrame = new PasswordFrame(this);
} else if (e.getSource() == laterLoadPanel.getButton1()) {
// 聊天记录
new ChatRecordFrame(laterLoadFrame);
} else if (e.getSource() == laterLoadPanel.getButton2()) {
// 发送消息
String inputMessage = laterLoadPanel.getTextArea2().getText();
int length = inputMessage.trim().length();
if (laterLoadPanel.getTextArea2().getText() == null
|| "".equals(laterLoadPanel.getTextArea2().getText())) {
JOptionPane.showMessageDialog(
laterLoadPanel.getLaterLoadFrame(), "不能发送空信息!");
return;
}
if (laterLoadPanel.getName().equals(
laterLoadPanel.getLaterLoadFrame().getTitle())) {
JOptionPane.showMessageDialog(
laterLoadPanel.getLaterLoadFrame(), "不能给自己发信息!");
return;
}
if (length > 200) {
JOptionPane.showMessageDialog(
laterLoadPanel.getLaterLoadFrame(), "信息长度不能超过200个字符!");
return;
}
try {
ObjectOutputStream objectOutputStream = laterLoadPanel
.getLaterLoadFrame().getObjectOutputStream();
QQPackage qqPackage = new QQPackage();
qqPackage
.setFrom(laterLoadPanel.getLaterLoadFrame().getTitle());
qqPackage.setTo(laterLoadPanel.getName());
if (laterLoadPanel.getName().equals("所有人")) {
qqPackage.setPackType(PackType.publicChat);
String message = "我 " + StaticTool.SystemTime()
+ " 对 所有人 说:" + "\n"
+ laterLoadPanel.getTextArea2().getText() + "\n";
laterLoadPanel.getTextArea1().append(message);
laterLoadPanel.writeLog(message, laterLoadPanel
.getLaterLoadFrame().getTitle().substring(0, 5));
} else {
qqPackage.setPackType(PackType.privateChat);
String message = "我 " + StaticTool.SystemTime() + " 对 "
+ laterLoadPanel.getName().substring(6) + " 说:"
+ "\n" + laterLoadPanel.getTextArea2().getText()
+ "\n";
laterLoadPanel.getTextArea1().append(message);
laterLoadPanel.writeLog(message, laterLoadPanel
.getLaterLoadFrame().getTitle().substring(0, 5));
}
qqPackage.setData(laterLoadPanel.getTextArea2().getText());
objectOutputStream.writeObject(qqPackage);
objectOutputStream.flush();
} catch (IOException e1) {
e1.printStackTrace();
}
laterLoadPanel.getTextArea2().setText("");
} else if (e.getSource() == laterLoadPanel.getButton3()) {
// 关闭
int i = JOptionPane.showConfirmDialog(
laterLoadPanel.getLaterLoadFrame(), "确定要退出QQ吗?");
if (i == 0) {
QQPackage qqPackage = new QQPackage();
qqPackage.setPackType(PackType.userDownLine);
qqPackage
.setFrom(laterLoadPanel.getLaterLoadFrame().getTitle());
try {
ObjectOutputStream objectOutputStream = laterLoadPanel
.getLaterLoadFrame().getObjectOutputStream();
objectOutputStream.writeObject(qqPackage);
objectOutputStream.flush();
System.exit(0);
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
public PasswordFrame getPasswordFrame() {
return passwordFrame;
}
public LaterLoadPanel getLaterLoadPanel() {
return laterLoadPanel;
}
public LaterLoadFrame getLaterLoadFrame() {
return laterLoadFrame;
}
}
|
GB18030
|
Java
| 4,071 |
java
|
LaterListener.java
|
Java
|
[] | null |
[] |
package listener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.ObjectOutputStream;
import javax.swing.JOptionPane;
import frame.ChatRecordFrame;
import frame.LaterLoadFrame;
import frame.PasswordFrame;
import panel.LaterLoadPanel;
import pub.PackType;
import pub.QQPackage;
import tool.StaticTool;
public class LaterListener implements ActionListener {
LaterLoadPanel laterLoadPanel;
LaterLoadFrame laterLoadFrame;
private PasswordFrame passwordFrame;
public LaterListener(LaterLoadPanel laterLoadPanel,
LaterLoadFrame laterLoadFrame) {
this.laterLoadPanel = laterLoadPanel;
this.laterLoadFrame = laterLoadFrame;
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == laterLoadPanel.getButton()) {
passwordFrame = new PasswordFrame(this);
} else if (e.getSource() == laterLoadPanel.getButton1()) {
// 聊天记录
new ChatRecordFrame(laterLoadFrame);
} else if (e.getSource() == laterLoadPanel.getButton2()) {
// 发送消息
String inputMessage = laterLoadPanel.getTextArea2().getText();
int length = inputMessage.trim().length();
if (laterLoadPanel.getTextArea2().getText() == null
|| "".equals(laterLoadPanel.getTextArea2().getText())) {
JOptionPane.showMessageDialog(
laterLoadPanel.getLaterLoadFrame(), "不能发送空信息!");
return;
}
if (laterLoadPanel.getName().equals(
laterLoadPanel.getLaterLoadFrame().getTitle())) {
JOptionPane.showMessageDialog(
laterLoadPanel.getLaterLoadFrame(), "不能给自己发信息!");
return;
}
if (length > 200) {
JOptionPane.showMessageDialog(
laterLoadPanel.getLaterLoadFrame(), "信息长度不能超过200个字符!");
return;
}
try {
ObjectOutputStream objectOutputStream = laterLoadPanel
.getLaterLoadFrame().getObjectOutputStream();
QQPackage qqPackage = new QQPackage();
qqPackage
.setFrom(laterLoadPanel.getLaterLoadFrame().getTitle());
qqPackage.setTo(laterLoadPanel.getName());
if (laterLoadPanel.getName().equals("所有人")) {
qqPackage.setPackType(PackType.publicChat);
String message = "我 " + StaticTool.SystemTime()
+ " 对 所有人 说:" + "\n"
+ laterLoadPanel.getTextArea2().getText() + "\n";
laterLoadPanel.getTextArea1().append(message);
laterLoadPanel.writeLog(message, laterLoadPanel
.getLaterLoadFrame().getTitle().substring(0, 5));
} else {
qqPackage.setPackType(PackType.privateChat);
String message = "我 " + StaticTool.SystemTime() + " 对 "
+ laterLoadPanel.getName().substring(6) + " 说:"
+ "\n" + laterLoadPanel.getTextArea2().getText()
+ "\n";
laterLoadPanel.getTextArea1().append(message);
laterLoadPanel.writeLog(message, laterLoadPanel
.getLaterLoadFrame().getTitle().substring(0, 5));
}
qqPackage.setData(laterLoadPanel.getTextArea2().getText());
objectOutputStream.writeObject(qqPackage);
objectOutputStream.flush();
} catch (IOException e1) {
e1.printStackTrace();
}
laterLoadPanel.getTextArea2().setText("");
} else if (e.getSource() == laterLoadPanel.getButton3()) {
// 关闭
int i = JOptionPane.showConfirmDialog(
laterLoadPanel.getLaterLoadFrame(), "确定要退出QQ吗?");
if (i == 0) {
QQPackage qqPackage = new QQPackage();
qqPackage.setPackType(PackType.userDownLine);
qqPackage
.setFrom(laterLoadPanel.getLaterLoadFrame().getTitle());
try {
ObjectOutputStream objectOutputStream = laterLoadPanel
.getLaterLoadFrame().getObjectOutputStream();
objectOutputStream.writeObject(qqPackage);
objectOutputStream.flush();
System.exit(0);
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
public PasswordFrame getPasswordFrame() {
return passwordFrame;
}
public LaterLoadPanel getLaterLoadPanel() {
return laterLoadPanel;
}
public LaterLoadFrame getLaterLoadFrame() {
return laterLoadFrame;
}
}
| 4,071 | 0.708154 | 0.700833 | 131 | 29.236641 | 21.261309 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.274809 | false | false |
3
|
740b0ea84d58771134e012b0bcd6520eb287f1f8
| 18,459,769,473,479 |
1761da56e2f475176a995eb27245c341266b73e8
|
/cj.netos.inform/src/cj/netos/inform/Informer.java
|
337eafc0ba74ce8396330baae0356579cadede75
|
[] |
no_license
|
carocean/cj.netos.fsbank
|
https://github.com/carocean/cj.netos.fsbank
|
178c51e695554beb6c47dc41bed01802947300e2
|
db418012570fe2fc34377d4a507cfdb60725ea3f
|
refs/heads/master
| 2022-01-09T04:45:11.694000 | 2019-06-29T02:15:38 | 2019-06-29T02:15:38 | 182,208,079 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package cj.netos.inform;
import java.util.Map;
import cj.studio.ecm.net.Circuit;
import cj.studio.ecm.net.CircuitException;
import cj.studio.ecm.net.Frame;
public interface Informer {
static String KEY_SERVICE_NAME = "$.netos.informer";
/**
* 执行通知。<br>
* 即可向远程网关的stub方法通知,也可向任意的http服务通知<br>
* 如果欲取回响应,则:
*
* <pre>
*
* MemoryOutputChannel oc = new MemoryOutputChannel();
* Circuit circuit = new Circuit(oc, "http/1.1 200 ok");
* informer.inform(frame, circuit);
* byte[] b = oc.readFully();
* System.out.println(new String(b));
* </pre>
*
* @param frame
* @param circuit
* @throws CircuitException
*/
void inform(Frame frame, Circuit circuit) throws CircuitException;
/**
* 创建侦。默认指令为:get
*
* @param informAddress
* @return
* @throws CircuitException
*/
Frame createFrame(String informAddress) throws CircuitException;
/**
* 创建侦。默认指令为:post
*
* @param informAddress
* @param content 请求内容。
*
* <pre>
* 如果远程服务是stub服务方法的内容参数,例如参数名为info,内容必须用以下格式写:
* {
* "info":{}
* }
* 将之转换为bytes即可
* </pre>
*
* @return
* @throws CircuitException
*/
Frame createFrame(String informAddress, byte[] content) throws CircuitException;
/**
* 创建侦
*
* @param command 请求命令
* @param informAddress 通知地址
* @param content 请求内容。
*
* <pre>
* 如果远程服务是stub服务方法的内容参数,例如参数名为info,内容必须用以下格式写:
* {
* "info":{}
* }
* 将之转换为bytes即可
* </pre>
*
* @return
* @throws CircuitException
*/
Frame createFrame(String command, String informAddress, byte[] content) throws CircuitException;
/**
* 创建侦,默认指令为:post<br>
* 专门为兼容调用stub服务而设,建议只要传内容均用此格式,尽量远程接收目标对内容解析的统一
* @param uri
* @param contentMap 请求内容
*
* @return
* @throws CircuitException
*/
Frame createFrame(String uri, Map<String, Object> contentMap) throws CircuitException;
}
|
UTF-8
|
Java
| 2,392 |
java
|
Informer.java
|
Java
|
[] | null |
[] |
package cj.netos.inform;
import java.util.Map;
import cj.studio.ecm.net.Circuit;
import cj.studio.ecm.net.CircuitException;
import cj.studio.ecm.net.Frame;
public interface Informer {
static String KEY_SERVICE_NAME = "$.netos.informer";
/**
* 执行通知。<br>
* 即可向远程网关的stub方法通知,也可向任意的http服务通知<br>
* 如果欲取回响应,则:
*
* <pre>
*
* MemoryOutputChannel oc = new MemoryOutputChannel();
* Circuit circuit = new Circuit(oc, "http/1.1 200 ok");
* informer.inform(frame, circuit);
* byte[] b = oc.readFully();
* System.out.println(new String(b));
* </pre>
*
* @param frame
* @param circuit
* @throws CircuitException
*/
void inform(Frame frame, Circuit circuit) throws CircuitException;
/**
* 创建侦。默认指令为:get
*
* @param informAddress
* @return
* @throws CircuitException
*/
Frame createFrame(String informAddress) throws CircuitException;
/**
* 创建侦。默认指令为:post
*
* @param informAddress
* @param content 请求内容。
*
* <pre>
* 如果远程服务是stub服务方法的内容参数,例如参数名为info,内容必须用以下格式写:
* {
* "info":{}
* }
* 将之转换为bytes即可
* </pre>
*
* @return
* @throws CircuitException
*/
Frame createFrame(String informAddress, byte[] content) throws CircuitException;
/**
* 创建侦
*
* @param command 请求命令
* @param informAddress 通知地址
* @param content 请求内容。
*
* <pre>
* 如果远程服务是stub服务方法的内容参数,例如参数名为info,内容必须用以下格式写:
* {
* "info":{}
* }
* 将之转换为bytes即可
* </pre>
*
* @return
* @throws CircuitException
*/
Frame createFrame(String command, String informAddress, byte[] content) throws CircuitException;
/**
* 创建侦,默认指令为:post<br>
* 专门为兼容调用stub服务而设,建议只要传内容均用此格式,尽量远程接收目标对内容解析的统一
* @param uri
* @param contentMap 请求内容
*
* @return
* @throws CircuitException
*/
Frame createFrame(String uri, Map<String, Object> contentMap) throws CircuitException;
}
| 2,392 | 0.621553 | 0.618999 | 91 | 20.516483 | 20.526779 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.131868 | false | false |
3
|
4e459eefc4790a1e897cbdfd95a5bfcb9049ef9d
| 20,529,943,714,010 |
735e5841bdc1c7fbabcadcb4ad4ee7efdd0fd869
|
/app/src/main/java/com/aquasafe/volley/BasicRequest.java
|
6e0f1cec0e9582aae8f51ec8ef02b3f3e5d0993a
|
[] |
no_license
|
flowness/android
|
https://github.com/flowness/android
|
7cd4594ff88f0079214ed16e6ad9402675fded32
|
f0d95ff14c2bab94284eb653586acf2f6941172c
|
refs/heads/master
| 2020-03-17T07:58:53.346000 | 2018-06-11T16:01:23 | 2018-06-11T16:01:23 | 133,242,650 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.aquasafe.volley;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.HttpHeaderParser;
import com.android.volley.toolbox.Volley;
import com.google.gson.Gson;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings("unchecked")
public class BasicRequest implements com.android.volley.Response.ErrorListener{
Request mRequest;
ResponseListener mResponseListener;
String mUrl;
String mPostBody;
int mRequestType = Request.Method.GET;
static RequestQueue mRequestQueue;
int timeout = 10000;
int retries = 3;
public BasicRequest()
{
//default constructor
}
public BasicRequest(int requestType, String url, String postBody, ResponseListener listener) {
mResponseListener = listener;
mUrl = url;
mPostBody = postBody;
mRequestType = requestType;
}
void initRequest()
{
mRequest = new Request(mRequestType, mUrl, this) {
@Override
protected com.android.volley.Response parseNetworkResponse(NetworkResponse response) {
String responseString = handleResponse(response);
// Timber.e("Response success * " + responseString);
BasicRequest.this.deliverResponse(Response.STATUS_SUCCESS, "", responseString, response.statusCode, response.headers);
return com.android.volley.Response.success(responseString, HttpHeaderParser.parseCacheHeaders(response));
}
@Override
protected void deliverResponse(Object response) {
}
@Override
public int compareTo(@NonNull Object o) {
return 0;
}
@Override
public byte[] getBody() throws AuthFailureError {
return BasicRequest.this.getBody();
}
@Override
public String getBodyContentType() {
return BasicRequest.this.getBodyContentType();
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
return BasicRequest.this.getHeaders();
}
};
}
@Override
public void onErrorResponse(VolleyError error) {
// Timber.e("Response error * " + error.getMessage());
deliverResponse(Response.STATUS_ERROR, error.getMessage(), "", -1, null);
}
public Map<String, String> getHeaders()
{
HashMap<String, String> headers = new HashMap<>();
return headers;
}
public byte[] getBody()
{
if(mPostBody != null)
{
// Timber.e("POST BODY = " + mPostBody);
return mPostBody.getBytes();
}
// else Timber.e("POST BODY is null");
return null;
}
public String getBodyContentType() {
return "application/json; charset=utf-8";
}
public JSONObject getJSONBody()
{
return new JSONObject();
}
public String handleResponse(NetworkResponse response)
{
if(response != null)
{
return new String(response.data);
}
return null;
}
void deliverResponse(final int status, final String message, final String data, final int resultCode, final Map<String, String> headers)
{
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
if(mResponseListener != null)
{
Response response = new Response();
response.status = status;
response.message = message;
response.data = data;
response.resultCode = resultCode;
response.headers = headers;
mResponseListener.onResponse(response);
}
}
});
}
public void setResponseListener(ResponseListener listener)
{
mResponseListener = listener;
}
public void execute(Context context)
{
// Timber.e("request url = " + mUrl);
initRequest();
getRequestQueue(context);
mRequest.setRetryPolicy(new DefaultRetryPolicy(
timeout,
retries,
0));
mRequestQueue.add(mRequest);
// mRequestQueue.start();
}
public RequestQueue getRequestQueue(Context context)
{
if(mRequestQueue == null)
{
mRequestQueue = Volley.newRequestQueue(context);
}
return mRequestQueue;
}
public interface ResponseListener
{
void onResponse(Response response);
}
public static class Response
{
public static final int STATUS_ERROR = 0;
public static final int STATUS_SUCCESS = 1;
public int status;
public String data = "";
public String message = "";
public int resultCode = 0;
public Map<String, String> headers = new HashMap<>();
public <T> T getData(Class<T> tClass)
{
return new Gson().fromJson(data, tClass);
}
public boolean isSuccess()
{
return status == STATUS_SUCCESS;
}
@Override
public String toString() {
return data;
}
public String getHeader(String key)
{
if(key != null && headers != null && headers.containsKey(key))
{
return headers.get(key);
}
return null;
}
}
}
|
UTF-8
|
Java
| 5,957 |
java
|
BasicRequest.java
|
Java
|
[] | null |
[] |
package com.aquasafe.volley;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.HttpHeaderParser;
import com.android.volley.toolbox.Volley;
import com.google.gson.Gson;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings("unchecked")
public class BasicRequest implements com.android.volley.Response.ErrorListener{
Request mRequest;
ResponseListener mResponseListener;
String mUrl;
String mPostBody;
int mRequestType = Request.Method.GET;
static RequestQueue mRequestQueue;
int timeout = 10000;
int retries = 3;
public BasicRequest()
{
//default constructor
}
public BasicRequest(int requestType, String url, String postBody, ResponseListener listener) {
mResponseListener = listener;
mUrl = url;
mPostBody = postBody;
mRequestType = requestType;
}
void initRequest()
{
mRequest = new Request(mRequestType, mUrl, this) {
@Override
protected com.android.volley.Response parseNetworkResponse(NetworkResponse response) {
String responseString = handleResponse(response);
// Timber.e("Response success * " + responseString);
BasicRequest.this.deliverResponse(Response.STATUS_SUCCESS, "", responseString, response.statusCode, response.headers);
return com.android.volley.Response.success(responseString, HttpHeaderParser.parseCacheHeaders(response));
}
@Override
protected void deliverResponse(Object response) {
}
@Override
public int compareTo(@NonNull Object o) {
return 0;
}
@Override
public byte[] getBody() throws AuthFailureError {
return BasicRequest.this.getBody();
}
@Override
public String getBodyContentType() {
return BasicRequest.this.getBodyContentType();
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
return BasicRequest.this.getHeaders();
}
};
}
@Override
public void onErrorResponse(VolleyError error) {
// Timber.e("Response error * " + error.getMessage());
deliverResponse(Response.STATUS_ERROR, error.getMessage(), "", -1, null);
}
public Map<String, String> getHeaders()
{
HashMap<String, String> headers = new HashMap<>();
return headers;
}
public byte[] getBody()
{
if(mPostBody != null)
{
// Timber.e("POST BODY = " + mPostBody);
return mPostBody.getBytes();
}
// else Timber.e("POST BODY is null");
return null;
}
public String getBodyContentType() {
return "application/json; charset=utf-8";
}
public JSONObject getJSONBody()
{
return new JSONObject();
}
public String handleResponse(NetworkResponse response)
{
if(response != null)
{
return new String(response.data);
}
return null;
}
void deliverResponse(final int status, final String message, final String data, final int resultCode, final Map<String, String> headers)
{
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
if(mResponseListener != null)
{
Response response = new Response();
response.status = status;
response.message = message;
response.data = data;
response.resultCode = resultCode;
response.headers = headers;
mResponseListener.onResponse(response);
}
}
});
}
public void setResponseListener(ResponseListener listener)
{
mResponseListener = listener;
}
public void execute(Context context)
{
// Timber.e("request url = " + mUrl);
initRequest();
getRequestQueue(context);
mRequest.setRetryPolicy(new DefaultRetryPolicy(
timeout,
retries,
0));
mRequestQueue.add(mRequest);
// mRequestQueue.start();
}
public RequestQueue getRequestQueue(Context context)
{
if(mRequestQueue == null)
{
mRequestQueue = Volley.newRequestQueue(context);
}
return mRequestQueue;
}
public interface ResponseListener
{
void onResponse(Response response);
}
public static class Response
{
public static final int STATUS_ERROR = 0;
public static final int STATUS_SUCCESS = 1;
public int status;
public String data = "";
public String message = "";
public int resultCode = 0;
public Map<String, String> headers = new HashMap<>();
public <T> T getData(Class<T> tClass)
{
return new Gson().fromJson(data, tClass);
}
public boolean isSuccess()
{
return status == STATUS_SUCCESS;
}
@Override
public String toString() {
return data;
}
public String getHeader(String key)
{
if(key != null && headers != null && headers.containsKey(key))
{
return headers.get(key);
}
return null;
}
}
}
| 5,957 | 0.587544 | 0.585362 | 224 | 25.59375 | 25.031946 | 140 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.477679 | false | false |
3
|
4387fcb196b373cabfc108f3bc0c182d5633faea
| 8,839,042,739,029 |
eea985d0cb0d416e192d9a4679720d94dc6fac52
|
/L15_31OCT19/src/Subsequence_void.java
|
a58aa246a8f575e6348af1caa67f2cd013033a37
|
[] |
no_license
|
kaushalsharma1998/Algo
|
https://github.com/kaushalsharma1998/Algo
|
bdbe650c2a9aa531fe54e97acab87c7dde0342cb
|
364b9e5cefcf4ba5f063feb95c5148e25783056f
|
refs/heads/master
| 2021-05-17T16:06:25.217000 | 2020-05-21T13:53:03 | 2020-05-21T13:53:03 | 250,861,838 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Subsequence_void {
public static void SubsequenceVoid(String str, String ans)
{
if(str.length()==0)
{
System.out.println(ans);
return;
}
char ch= str.charAt(0);
String req=str.substring(1);
SubsequenceVoid(req, ans+ch);
SubsequenceVoid(req, ans);
}
public static void main(String[] args) {
// TODO Auto-generated meth od stub
SubsequenceVoid("abc","");
}
}
|
UTF-8
|
Java
| 438 |
java
|
Subsequence_void.java
|
Java
|
[] | null |
[] |
public class Subsequence_void {
public static void SubsequenceVoid(String str, String ans)
{
if(str.length()==0)
{
System.out.println(ans);
return;
}
char ch= str.charAt(0);
String req=str.substring(1);
SubsequenceVoid(req, ans+ch);
SubsequenceVoid(req, ans);
}
public static void main(String[] args) {
// TODO Auto-generated meth od stub
SubsequenceVoid("abc","");
}
}
| 438 | 0.614155 | 0.607306 | 26 | 14.807693 | 16.476135 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.461538 | false | false |
3
|
c08664962fbac3219c21281d85320d35c1fcaba1
| 10,617,159,211,394 |
611d0be90cdb5d2d1435c1e2ed20e51c67c8ad12
|
/app/src/main/java/morandoso/android/com/emergencia.java
|
11c6afc538e407b4371b4b463231d70411410a98
|
[] |
no_license
|
gumechler/MorandoSo
|
https://github.com/gumechler/MorandoSo
|
ae426584a7be9432c82f71dea7d9b2695bc4da3a
|
8469bf9234db13053f6f7340a15444bff1de9b65
|
refs/heads/master
| 2020-04-08T05:48:36.565000 | 2018-11-20T00:41:10 | 2018-11-20T00:41:10 | 158,308,694 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package morandoso.android.com;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class emergencia extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_emergencia);
getSupportActionBar().hide();
}
public void ligarSamu(View view){
String numero = "192";
Uri uri = Uri.parse("tel:" + numero);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
if (ActivityCompat.checkSelfPermission(emergencia.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(emergencia.this, new String[]{Manifest.permission.CALL_PHONE}, 1);
return;
}
startActivity(intent);
}
public void ligarBombeiro(View view){
String numero = "193";
Uri uri = Uri.parse("tel:" + numero);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
if (ActivityCompat.checkSelfPermission(emergencia.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(emergencia.this, new String[]{Manifest.permission.CALL_PHONE}, 1);
return;
}
startActivity(intent);
}
public void ligarDisqDenuncia(View view){
String numero = "181";
Uri uri = Uri.parse("tel:" + numero);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
if (ActivityCompat.checkSelfPermission(emergencia.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(emergencia.this, new String[]{Manifest.permission.CALL_PHONE}, 1);
return;
}
startActivity(intent);
}
public void ligarPolicia(View view){
String numero = "190";
Uri uri = Uri.parse("tel:" + numero);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
if (ActivityCompat.checkSelfPermission(emergencia.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(emergencia.this, new String[]{Manifest.permission.CALL_PHONE}, 1);
return;
}
startActivity(intent);
}
public void ligarDefCivil(View view){
String numero = "199";
Uri uri = Uri.parse("tel:" + numero);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
if (ActivityCompat.checkSelfPermission(emergencia.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(emergencia.this, new String[]{Manifest.permission.CALL_PHONE}, 1);
return;
}
startActivity(intent);
}
public void ligarDelegMulher(View view){
String numero = "180";
Uri uri = Uri.parse("tel:" + numero);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
if (ActivityCompat.checkSelfPermission(emergencia.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(emergencia.this, new String[]{Manifest.permission.CALL_PHONE}, 1);
return;
}
startActivity(intent);
}
}
|
UTF-8
|
Java
| 3,556 |
java
|
emergencia.java
|
Java
|
[] | null |
[] |
package morandoso.android.com;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class emergencia extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_emergencia);
getSupportActionBar().hide();
}
public void ligarSamu(View view){
String numero = "192";
Uri uri = Uri.parse("tel:" + numero);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
if (ActivityCompat.checkSelfPermission(emergencia.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(emergencia.this, new String[]{Manifest.permission.CALL_PHONE}, 1);
return;
}
startActivity(intent);
}
public void ligarBombeiro(View view){
String numero = "193";
Uri uri = Uri.parse("tel:" + numero);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
if (ActivityCompat.checkSelfPermission(emergencia.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(emergencia.this, new String[]{Manifest.permission.CALL_PHONE}, 1);
return;
}
startActivity(intent);
}
public void ligarDisqDenuncia(View view){
String numero = "181";
Uri uri = Uri.parse("tel:" + numero);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
if (ActivityCompat.checkSelfPermission(emergencia.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(emergencia.this, new String[]{Manifest.permission.CALL_PHONE}, 1);
return;
}
startActivity(intent);
}
public void ligarPolicia(View view){
String numero = "190";
Uri uri = Uri.parse("tel:" + numero);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
if (ActivityCompat.checkSelfPermission(emergencia.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(emergencia.this, new String[]{Manifest.permission.CALL_PHONE}, 1);
return;
}
startActivity(intent);
}
public void ligarDefCivil(View view){
String numero = "199";
Uri uri = Uri.parse("tel:" + numero);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
if (ActivityCompat.checkSelfPermission(emergencia.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(emergencia.this, new String[]{Manifest.permission.CALL_PHONE}, 1);
return;
}
startActivity(intent);
}
public void ligarDelegMulher(View view){
String numero = "180";
Uri uri = Uri.parse("tel:" + numero);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
if (ActivityCompat.checkSelfPermission(emergencia.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(emergencia.this, new String[]{Manifest.permission.CALL_PHONE}, 1);
return;
}
startActivity(intent);
}
}
| 3,556 | 0.671541 | 0.664229 | 94 | 36.829788 | 37.933773 | 134 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.765957 | false | false |
3
|
69907b9dfc5b1ffbb24400138d93592e0bb10b1f
| 4,363,686,812,248 |
5d77abfba31d2f0a5cb2f92f937904859785e7ff
|
/Java/java_examples Hyd/jspproj/jspShop-1.1a.tar/jspShop/rae/src/com/submersion/jspshop/rae/PropertyType.java
|
326de99fd021c129ceedd81be90ca2cfa4c4eeda
|
[] |
no_license
|
thinkpavan/artefacts
|
https://github.com/thinkpavan/artefacts
|
d93a1c0be0b6158cb0976aae9af9c6a016ebfdae
|
04bcf95450243dfe2f4fa8f09d96274034428e4d
|
refs/heads/master
| 2020-04-01T20:24:34.142000 | 2016-07-07T16:27:47 | 2016-07-07T16:27:47 | 62,716,135 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.submersion.jspshop.rae;
import javax.rmi.*;
import java.rmi.RemoteException;
import javax.ejb.*;
import javax.naming.*;
import java.util.*;
import com.submersion.jspshop.ejb.*;
/** Access to all the types for one property.
*
* @author Darryl Bleau (darrylbleau@submersion.com)
* @see com.submersion.jspshop.rae.PropertyTypes
* @see com.submersion.jspshop.rae.Property
* @version $Revision$
* @created: August 29, 2001
* @changed: $Date$
* @changedBy: $Author$
*/
public class PropertyType extends RAEInstance
{
/* ================================================
CLASS AND OBJECT ATTRIBUTES
================================================ */
private Long propertyID;
private Long typeID;
private com.submersion.jspshop.ejb.PropertyType propertyType = null;
private PropertyTypeHome propertyTypeHome;
private TypeValueHome typeValueHome;
private ValueHome valueHome;
/* ================================================
CONSTRUCTORS
================================================ */
public PropertyType(Long id)
{
super(id);
this.right = 15;
}
public PropertyType(Long id, com.submersion.jspshop.ejb.PropertyType propertyType)
{
super(id);
this.propertyType = propertyType;
initialise();
this.right = 15;
}
/* ================================================
PUBLIC INTERFACE
================================================ */
/* --PropertyID---------------- */
public Long getPropertyID()
{
if (propertyType == null)
initialise(); //run initialisation because we haven't yet
return propertyID;
}
/* --Types--------------------- */
public Long getTypeID()
{
if (propertyType == null)
initialise(); //run initialisation because we haven't yet
return typeID;
}
public void setTypeID(Long typeID)
{
if (propertyType == null)
initialise(); // run initialisation because we haven't yet
this.typeID = changeTypeID(typeID);
}
/* --Delete---------------- */
public void delete() throws RemoveException
{
if (propertyType == null)
initialise(); // run initialisation because we haven't yet
deletePropertyType(getID());
}
/* ================================================
PRIVATE METHODS
================================================ */
private Long changeTypeID(Long typeID)
{
try
{
propertyType.setTypeID(typeID);
}
catch (RemoteException e)
{
System.err.println("jspShop: Error connecting to container in deletePropertyTypes method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
return typeID;
}
private void deletePropertyType(Long propertyTypeID) throws RemoveException
{
try
{
// delete all referenced values to this propertyType
deleteObjectValues(propertyType.getPropertyID(), propertyType.getTypeID());
// remove the propertyType from the database
propertyTypeHome.remove(getID());
}
catch (RemoteException e)
{
System.err.println("jspShop: Error connecting to container in deletePropertyTypes method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
}
private void deleteObjectValues(Long propertyID, Long typeID) throws RemoveException
{
try
{
// get iterator of all TypeValues that use typeID
Iterator iterator = typeValueHome.findByPropertyIDTypeID(propertyID, typeID).iterator();
//iterate through each one
while (iterator.hasNext())
{
// remove the buggers
typeValueHome.remove(((TypeValue)iterator.next()).getTypeValueID());
}
}
catch (RemoteException e)
{
System.err.println("jspShop: Error connecting to container in deleteObjectValues method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
catch (FinderException e)
{
System.err.println("jspShop: Error using finder query in deleteObjectValues method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
}
protected void initialise()
{
try
{
// retrieve the initial context from the container
InitialContext context = new InitialContext();
// get a reference to the PropertyType entity bean
java.lang.Object homeRef = context.lookup("java:comp/env/ejb/PropertyType");
// get an instance of the PropertyTypeHome interface
propertyTypeHome = (PropertyTypeHome)PortableRemoteObject.narrow(homeRef, PropertyTypeHome.class);
// get a reference to the TypeValue entity bean
homeRef = context.lookup("java:comp/env/ejb/TypeValue");
// get an instance of the TypeValueHome interface
typeValueHome = (TypeValueHome)PortableRemoteObject.narrow(homeRef, TypeValueHome.class);
// get a reference to the Value entity bean
homeRef = context.lookup("java:comp/env/ejb/Value");
// get an instance of the ValueHome interface
valueHome = (ValueHome)PortableRemoteObject.narrow(homeRef, ValueHome.class);
// get a reference to the Type entity bean
homeRef = context.lookup("java:comp/env/ejb/Type");
// get an instance of the TypeHome interface
TypeHome typeHome = (TypeHome)PortableRemoteObject.narrow(homeRef, TypeHome.class);
if (propertyType == null)
{
// get an instance of the current propertyType using it's ID from constructor
propertyType = propertyTypeHome.findByPrimaryKey(getID());
}
// set values on this object
this.typeID = propertyType.getTypeID();
this.propertyID = propertyType.getPropertyID();
// get the name from the corresponding Type entity bean
this.name = typeHome.findByPrimaryKey(typeID).getName();
}
catch (NamingException e)
{
System.err.println("jspShop: Error looking up Home interfaces in initialise method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
catch (RemoteException e)
{
System.err.println("jspShop: Error connecting to container in initialise method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
catch (FinderException e)
{
System.err.println("jspShop: Error using finder query in initialise method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
}
}
|
UTF-8
|
Java
| 7,356 |
java
|
PropertyType.java
|
Java
|
[
{
"context": " to all the types for one property.\n * \n * @author Darryl Bleau (darrylbleau@submersion.com)\n * @see com.submersi",
"end": 264,
"score": 0.9998970627784729,
"start": 252,
"tag": "NAME",
"value": "Darryl Bleau"
},
{
"context": "es for one property.\n * \n * @author Darryl Bleau (darrylbleau@submersion.com)\n * @see com.submersion.jspshop.rae.PropertyTypes",
"end": 292,
"score": 0.9999378323554993,
"start": 266,
"tag": "EMAIL",
"value": "darrylbleau@submersion.com"
}
] | null |
[] |
package com.submersion.jspshop.rae;
import javax.rmi.*;
import java.rmi.RemoteException;
import javax.ejb.*;
import javax.naming.*;
import java.util.*;
import com.submersion.jspshop.ejb.*;
/** Access to all the types for one property.
*
* @author <NAME> (<EMAIL>)
* @see com.submersion.jspshop.rae.PropertyTypes
* @see com.submersion.jspshop.rae.Property
* @version $Revision$
* @created: August 29, 2001
* @changed: $Date$
* @changedBy: $Author$
*/
public class PropertyType extends RAEInstance
{
/* ================================================
CLASS AND OBJECT ATTRIBUTES
================================================ */
private Long propertyID;
private Long typeID;
private com.submersion.jspshop.ejb.PropertyType propertyType = null;
private PropertyTypeHome propertyTypeHome;
private TypeValueHome typeValueHome;
private ValueHome valueHome;
/* ================================================
CONSTRUCTORS
================================================ */
public PropertyType(Long id)
{
super(id);
this.right = 15;
}
public PropertyType(Long id, com.submersion.jspshop.ejb.PropertyType propertyType)
{
super(id);
this.propertyType = propertyType;
initialise();
this.right = 15;
}
/* ================================================
PUBLIC INTERFACE
================================================ */
/* --PropertyID---------------- */
public Long getPropertyID()
{
if (propertyType == null)
initialise(); //run initialisation because we haven't yet
return propertyID;
}
/* --Types--------------------- */
public Long getTypeID()
{
if (propertyType == null)
initialise(); //run initialisation because we haven't yet
return typeID;
}
public void setTypeID(Long typeID)
{
if (propertyType == null)
initialise(); // run initialisation because we haven't yet
this.typeID = changeTypeID(typeID);
}
/* --Delete---------------- */
public void delete() throws RemoveException
{
if (propertyType == null)
initialise(); // run initialisation because we haven't yet
deletePropertyType(getID());
}
/* ================================================
PRIVATE METHODS
================================================ */
private Long changeTypeID(Long typeID)
{
try
{
propertyType.setTypeID(typeID);
}
catch (RemoteException e)
{
System.err.println("jspShop: Error connecting to container in deletePropertyTypes method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
return typeID;
}
private void deletePropertyType(Long propertyTypeID) throws RemoveException
{
try
{
// delete all referenced values to this propertyType
deleteObjectValues(propertyType.getPropertyID(), propertyType.getTypeID());
// remove the propertyType from the database
propertyTypeHome.remove(getID());
}
catch (RemoteException e)
{
System.err.println("jspShop: Error connecting to container in deletePropertyTypes method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
}
private void deleteObjectValues(Long propertyID, Long typeID) throws RemoveException
{
try
{
// get iterator of all TypeValues that use typeID
Iterator iterator = typeValueHome.findByPropertyIDTypeID(propertyID, typeID).iterator();
//iterate through each one
while (iterator.hasNext())
{
// remove the buggers
typeValueHome.remove(((TypeValue)iterator.next()).getTypeValueID());
}
}
catch (RemoteException e)
{
System.err.println("jspShop: Error connecting to container in deleteObjectValues method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
catch (FinderException e)
{
System.err.println("jspShop: Error using finder query in deleteObjectValues method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
}
protected void initialise()
{
try
{
// retrieve the initial context from the container
InitialContext context = new InitialContext();
// get a reference to the PropertyType entity bean
java.lang.Object homeRef = context.lookup("java:comp/env/ejb/PropertyType");
// get an instance of the PropertyTypeHome interface
propertyTypeHome = (PropertyTypeHome)PortableRemoteObject.narrow(homeRef, PropertyTypeHome.class);
// get a reference to the TypeValue entity bean
homeRef = context.lookup("java:comp/env/ejb/TypeValue");
// get an instance of the TypeValueHome interface
typeValueHome = (TypeValueHome)PortableRemoteObject.narrow(homeRef, TypeValueHome.class);
// get a reference to the Value entity bean
homeRef = context.lookup("java:comp/env/ejb/Value");
// get an instance of the ValueHome interface
valueHome = (ValueHome)PortableRemoteObject.narrow(homeRef, ValueHome.class);
// get a reference to the Type entity bean
homeRef = context.lookup("java:comp/env/ejb/Type");
// get an instance of the TypeHome interface
TypeHome typeHome = (TypeHome)PortableRemoteObject.narrow(homeRef, TypeHome.class);
if (propertyType == null)
{
// get an instance of the current propertyType using it's ID from constructor
propertyType = propertyTypeHome.findByPrimaryKey(getID());
}
// set values on this object
this.typeID = propertyType.getTypeID();
this.propertyID = propertyType.getPropertyID();
// get the name from the corresponding Type entity bean
this.name = typeHome.findByPrimaryKey(typeID).getName();
}
catch (NamingException e)
{
System.err.println("jspShop: Error looking up Home interfaces in initialise method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
catch (RemoteException e)
{
System.err.println("jspShop: Error connecting to container in initialise method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
catch (FinderException e)
{
System.err.println("jspShop: Error using finder query in initialise method in com.submersion.jspshop.rae.PropertyType. " + e.getMessage());
e.printStackTrace();
}
}
}
| 7,331 | 0.567836 | 0.566476 | 210 | 34.028572 | 34.07148 | 165 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.566667 | false | false |
3
|
a9d8bd781705f9a2a90df1f3e838534fac7aa19d
| 2,594,160,287,696 |
2d30a1b600d1f38a659f23af8a76a7a414f0bc08
|
/Server/src/ChatApplication.java
|
d9c29c04a370de59bf0477e7ed775c9a670605b6
|
[] |
no_license
|
Moya1004/Chat-Application-For-Android-Using-Socket-Programming
|
https://github.com/Moya1004/Chat-Application-For-Android-Using-Socket-Programming
|
3c80c27b7766d9cad6cf93ab7f31c278af21b659
|
51947baf07c086eb026cdf24400848a09df5ee16
|
refs/heads/master
| 2020-03-31T13:58:52.883000 | 2018-10-09T16:29:34 | 2018-10-09T16:29:34 | 152,275,125 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* 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.
*/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
/**
*
* @author Moya
*/
public class ChatApplication {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic
try
{
//System.out.println(java.lang.System.getProperty("java.library.path"));
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection conn = DriverManager.getConnection(
"jdbc:jtds:sqlserver://localhost:57004;databaseName=ASOSDB;integratedSecurity=true");
System.out.println("connected");
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery("select * from [User]");
while (rs.next()) {
String lastName = rs.getString("UserName");
System.out.println(lastName + "\n");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
|
UTF-8
|
Java
| 1,276 |
java
|
ChatApplication.java
|
Java
|
[
{
"context": "Set;\nimport java.sql.Statement;\n\n/**\n *\n * @author Moya\n */\npublic class ChatApplication {\n\n /**\n ",
"end": 322,
"score": 0.5334290266036987,
"start": 318,
"tag": "NAME",
"value": "Moya"
}
] | null |
[] |
/*
* 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.
*/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
/**
*
* @author Moya
*/
public class ChatApplication {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic
try
{
//System.out.println(java.lang.System.getProperty("java.library.path"));
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection conn = DriverManager.getConnection(
"jdbc:jtds:sqlserver://localhost:57004;databaseName=ASOSDB;integratedSecurity=true");
System.out.println("connected");
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery("select * from [User]");
while (rs.next()) {
String lastName = rs.getString("UserName");
System.out.println(lastName + "\n");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
| 1,276 | 0.603448 | 0.59953 | 45 | 27.355556 | 25.875906 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false |
3
|
7d966f73db7df7201b4c6a515765149f6dd6e1b9
| 27,960,237,151,005 |
843d4c28aaba3c79ae45cdee0247a943af25105d
|
/1.JavaSyntax/src/pl/codegym/task/task07/task0703/Solution.java
|
72df642b1aee6e26ae95e696f5687222dfc2fb93
|
[] |
no_license
|
splacik992/CodeGym
|
https://github.com/splacik992/CodeGym
|
5699064b5219efc1021aefaef11f53a300527f75
|
d7484f2d0ef1902512403b6ce806b158ad69ea85
|
refs/heads/master
| 2021-06-12T16:11:32.937000 | 2020-06-02T12:44:22 | 2020-06-02T12:44:22 | 254,355,828 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package pl.codegym.task.task07.task0703;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
/*
Samotne tablice oddziałują na siebie
*/
public class Solution {
public static void main(String[] args) throws Exception {
Scanner scan = new Scanner(System.in);
String[] listaStringow = new String[10];
int[] liczby = new int[10];
for(int i=0;i<listaStringow.length;i++){
listaStringow[i] = scan.nextLine();
liczby[i] = listaStringow[i].length();
}
for(int j=0;j<liczby.length;j++){
System.out.println(liczby[j]);
}
}
}
|
UTF-8
|
Java
| 661 |
java
|
Solution.java
|
Java
|
[] | null |
[] |
package pl.codegym.task.task07.task0703;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
/*
Samotne tablice oddziałują na siebie
*/
public class Solution {
public static void main(String[] args) throws Exception {
Scanner scan = new Scanner(System.in);
String[] listaStringow = new String[10];
int[] liczby = new int[10];
for(int i=0;i<listaStringow.length;i++){
listaStringow[i] = scan.nextLine();
liczby[i] = listaStringow[i].length();
}
for(int j=0;j<liczby.length;j++){
System.out.println(liczby[j]);
}
}
}
| 661 | 0.620637 | 0.602428 | 26 | 24.384615 | 20.195347 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.538462 | false | false |
3
|
ce64be46184bbc7a59271c4be9bb175242f0b92b
| 5,523,327,993,655 |
e355816127511f12ab70da51a1cfa44d873f13a7
|
/ManyFacedProject/src/main/java/com/revature/data/CharacterDAO.java
|
7ec2a981b8a9efcd2c785bb048dc4f431627304a
|
[] |
no_license
|
evanmolinelli/GameOfThronesModule
|
https://github.com/evanmolinelli/GameOfThronesModule
|
96d41a6228406d99cb41575f09b8dc7d06de21c6
|
a5b46080e34672aa6b6b88fd0c496f82445c754c
|
refs/heads/master
| 2021-06-30T14:36:51.395000 | 2017-09-16T02:43:40 | 2017-09-16T02:43:40 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.revature.data;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.revature.beans.Character;
import com.revature.beans.House;
import com.revature.beans.Location;
public class CharacterDAO {
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void create(Character character) {
//opens a session, beings transaction
sessionFactory.getCurrentSession().save(character);
}
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void update(Character character) {
sessionFactory.getCurrentSession().saveOrUpdate(character);
}
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void delete(Character character) {
sessionFactory.getCurrentSession().delete(character);
}
@SuppressWarnings("unchecked")
@Transactional
public List<Character> findAll() {
return sessionFactory.getCurrentSession()
.createCriteria(Character.class).list();
}
@SuppressWarnings("unchecked")
@Transactional
public Character findOne(int id) {
return (Character) sessionFactory.getCurrentSession().createCriteria(Character.class)
.add(Restrictions.eq("id", id)).uniqueResult();
}
@SuppressWarnings("unchecked")
@Transactional
public Set<Character> findAllCharactersInHouse(int id) {
ArrayList<Character> list = (ArrayList<Character>) sessionFactory.getCurrentSession()
.createCriteria(Character.class)
.add(Restrictions.eq("house.id", id))
.list();
Set<Character> s = new LinkedHashSet<Character>(list);
return s;
}
}
|
UTF-8
|
Java
| 2,237 |
java
|
CharacterDAO.java
|
Java
|
[] | null |
[] |
package com.revature.data;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.revature.beans.Character;
import com.revature.beans.House;
import com.revature.beans.Location;
public class CharacterDAO {
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void create(Character character) {
//opens a session, beings transaction
sessionFactory.getCurrentSession().save(character);
}
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void update(Character character) {
sessionFactory.getCurrentSession().saveOrUpdate(character);
}
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void delete(Character character) {
sessionFactory.getCurrentSession().delete(character);
}
@SuppressWarnings("unchecked")
@Transactional
public List<Character> findAll() {
return sessionFactory.getCurrentSession()
.createCriteria(Character.class).list();
}
@SuppressWarnings("unchecked")
@Transactional
public Character findOne(int id) {
return (Character) sessionFactory.getCurrentSession().createCriteria(Character.class)
.add(Restrictions.eq("id", id)).uniqueResult();
}
@SuppressWarnings("unchecked")
@Transactional
public Set<Character> findAllCharactersInHouse(int id) {
ArrayList<Character> list = (ArrayList<Character>) sessionFactory.getCurrentSession()
.createCriteria(Character.class)
.add(Restrictions.eq("house.id", id))
.list();
Set<Character> s = new LinkedHashSet<Character>(list);
return s;
}
}
| 2,237 | 0.792579 | 0.792579 | 68 | 31.897058 | 29.893015 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.441176 | false | false |
3
|
4d84725963c1812ac404f5ccbbb27d7145f7fafd
| 5,523,327,991,335 |
28f1bd2053f48abad4ee0dc51ccb5d28730937c0
|
/疯狂Java讲义(第3版)光盘内容/project_codes/editor/src/org/crazyit/editor/Main.java
|
4ec5fbca53ae2797561b9c6167a1b3fae2d4ab9b
|
[
"Apache-2.0"
] |
permissive
|
JamesKing9/-Java-3-
|
https://github.com/JamesKing9/-Java-3-
|
ce029cd2d78b50aaf4bdf39f120b83fd9ff1cf94
|
3fa0aae7bc5dd95a119322c431431f116fda9ec8
|
refs/heads/master
| 2020-12-02T10:03:32.508000 | 2017-07-09T13:05:31 | 2017-07-09T13:05:31 | 96,684,655 | 2 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.crazyit.editor;
import org.crazyit.editor.tree.TreeCreator;
import org.crazyit.editor.tree.TreeCreatorImpl;
/**
* 程序入口类
*
* @author yangenxiong yangenxiong2009@gmail.com
* @version 1.0
* <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
* <br>Copyright (C), 2009-2010, yangenxiong
* <br>This program is protected by copyright laws.
*/
public class Main {
public static void main(String[] args) {
TreeCreator treeCreator = new TreeCreatorImpl();
//创建EditorFrame,暂时不用设置可见
EditorFrame editorFrame = new EditorFrame("ide", treeCreator);
//将editorFrame对象作为SpaceFrame的构造参数
SpaceFrame spaceFrame = new SpaceFrame(editorFrame);
//让SpaceFrame可见
spaceFrame.setVisible(true);
}
}
|
GB18030
|
Java
| 785 |
java
|
Main.java
|
Java
|
[
{
"context": "tree.TreeCreatorImpl;\n\n/**\n * 程序入口类\n * \n * @author yangenxiong yangenxiong2009@gmail.com\n * @version 1.0",
"end": 154,
"score": 0.958807647228241,
"start": 150,
"tag": "USERNAME",
"value": "yang"
},
{
"context": "TreeCreatorImpl;\n\n/**\n * 程序入口类\n * \n * @author yangenxiong yangenxiong2009@gmail.com\n * @version 1.0\n * <br",
"end": 161,
"score": 0.9152939319610596,
"start": 154,
"tag": "NAME",
"value": "enxiong"
},
{
"context": "atorImpl;\n\n/**\n * 程序入口类\n * \n * @author yangenxiong yangenxiong2009@gmail.com\n * @version 1.0\n * <br/>网站: <a href=\"http://www.",
"end": 187,
"score": 0.9999274611473083,
"start": 162,
"tag": "EMAIL",
"value": "yangenxiong2009@gmail.com"
},
{
"context": "疯狂Java联盟</a>\n * <br>Copyright (C), 2009-2010, yangenxiong\n * <br>This program is protected by copyrigh",
"end": 302,
"score": 0.6059866547584534,
"start": 300,
"tag": "USERNAME",
"value": "en"
}
] | null |
[] |
package org.crazyit.editor;
import org.crazyit.editor.tree.TreeCreator;
import org.crazyit.editor.tree.TreeCreatorImpl;
/**
* 程序入口类
*
* @author yangenxiong <EMAIL>
* @version 1.0
* <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
* <br>Copyright (C), 2009-2010, yangenxiong
* <br>This program is protected by copyright laws.
*/
public class Main {
public static void main(String[] args) {
TreeCreator treeCreator = new TreeCreatorImpl();
//创建EditorFrame,暂时不用设置可见
EditorFrame editorFrame = new EditorFrame("ide", treeCreator);
//将editorFrame对象作为SpaceFrame的构造参数
SpaceFrame spaceFrame = new SpaceFrame(editorFrame);
//让SpaceFrame可见
spaceFrame.setVisible(true);
}
}
| 767 | 0.738462 | 0.718881 | 26 | 26.5 | 21.135551 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false |
3
|
a767ec81b07bca367bb85a264f87ead731d554b9
| 33,423,435,542,646 |
fa91450deb625cda070e82d5c31770be5ca1dec6
|
/Diff-Raw-Data/8/8_5f912f4926d0febbd657058d1e0120b2431e952a/Pack/8_5f912f4926d0febbd657058d1e0120b2431e952a_Pack_s.java
|
864b02d9123a935ab526904001dbb71c77733bf5
|
[] |
no_license
|
zhongxingyu/Seer
|
https://github.com/zhongxingyu/Seer
|
48e7e5197624d7afa94d23f849f8ea2075bcaec0
|
c11a3109fdfca9be337e509ecb2c085b60076213
|
refs/heads/master
| 2023-07-06T12:48:55.516000 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | false | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | 2023-06-21T00:53:27 | 2023-06-22T07:55:57 | 2,849,868 | 2 | 2 | 0 | null | false | false |
/*
* (C) Copyright 2006-2010 Nuxeo SAS (http://nuxeo.com/) and contributors.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
*
* This library 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.
*
* Contributors:
* bstefanescu
*/
package org.nuxeo.runtime.jboss.deployer;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
*
*/
public class Pack {
public static void main(String[] args) throws Exception {
File wd = new File(".");
File file = new File(wd, "META-INF/application.xml");
if (!file.isFile()) {
System.err.println("You should run this tool from a preprocessed nuxeo.ear folder");
}
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
FileInputStream in = new FileInputStream(file);
Document doc = docBuilder.parse(in);
Element root = doc.getDocumentElement();
NodeList list = root.getElementsByTagName("module");
ArrayList<String> paths = new ArrayList<String>();
for (int i = 0; i < list.getLength(); i++) {
Element el = (Element) list.item(i);
Node n = el.getFirstChild();
while (n != null) {
if (n.getNodeType() == Node.ELEMENT_NODE) {
Element mtype = ((Element) n);
String type = n.getNodeName().toLowerCase();
String path = null;
if ("web".equals(type)) {
path = ((Element) (mtype.getElementsByTagName("web-uri").item(0))).getTextContent().trim();
} else {
path = mtype.getTextContent().trim();
}
paths.add(path);
}
n = n.getNextSibling();
}
}
File ejbs = new File(wd, "tmp-ejbs");
ejbs.mkdirs();
for (String path : paths) {
System.out.println("Move EAR module " + path + " to "
+ ejbs.getName());
File f = new File(wd, path);
f.renameTo(new File(ejbs, f.getName()));
}
File lib = new File(wd, "lib");
File[] files = new File(wd, "bundles").listFiles();
if (files != null) {
for (File f : files) {
System.out.println("Move POJO bundle " + f.getName()
+ " to lib");
f.renameTo(new File(lib, f.getName()));
}
}
File bundles = new File(wd, "bundles");
files = ejbs.listFiles();
if (files != null) {
for (File f : files) {
System.out.println("Move back EAR module " + f.getName()
+ " to bundles");
f.renameTo(new File(bundles, f.getName()));
}
}
}
}
|
UTF-8
|
Java
| 3,630 |
java
|
8_5f912f4926d0febbd657058d1e0120b2431e952a_Pack_s.java
|
Java
|
[
{
"context": "se for more details.\n *\n * Contributors:\n * bstefanescu\n */\n package org.nuxeo.runtime.jboss.deployer;\n ",
"end": 656,
"score": 0.9995203614234924,
"start": 645,
"tag": "USERNAME",
"value": "bstefanescu"
},
{
"context": ".dom.NodeList;\n \n /**\n * @author <a href=\"mailto:bs@nuxeo.com\">Bogdan Stefanescu</a>\n * \n */\n public class Pa",
"end": 1050,
"score": 0.9999150633811951,
"start": 1038,
"tag": "EMAIL",
"value": "bs@nuxeo.com"
},
{
"context": "\n \n /**\n * @author <a href=\"mailto:bs@nuxeo.com\">Bogdan Stefanescu</a>\n * \n */\n public class Pack {\n \n public ",
"end": 1069,
"score": 0.9998637437820435,
"start": 1052,
"tag": "NAME",
"value": "Bogdan Stefanescu"
}
] | null |
[] |
/*
* (C) Copyright 2006-2010 Nuxeo SAS (http://nuxeo.com/) and contributors.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
*
* This library 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.
*
* Contributors:
* bstefanescu
*/
package org.nuxeo.runtime.jboss.deployer;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* @author <a href="mailto:<EMAIL>"><NAME></a>
*
*/
public class Pack {
public static void main(String[] args) throws Exception {
File wd = new File(".");
File file = new File(wd, "META-INF/application.xml");
if (!file.isFile()) {
System.err.println("You should run this tool from a preprocessed nuxeo.ear folder");
}
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
FileInputStream in = new FileInputStream(file);
Document doc = docBuilder.parse(in);
Element root = doc.getDocumentElement();
NodeList list = root.getElementsByTagName("module");
ArrayList<String> paths = new ArrayList<String>();
for (int i = 0; i < list.getLength(); i++) {
Element el = (Element) list.item(i);
Node n = el.getFirstChild();
while (n != null) {
if (n.getNodeType() == Node.ELEMENT_NODE) {
Element mtype = ((Element) n);
String type = n.getNodeName().toLowerCase();
String path = null;
if ("web".equals(type)) {
path = ((Element) (mtype.getElementsByTagName("web-uri").item(0))).getTextContent().trim();
} else {
path = mtype.getTextContent().trim();
}
paths.add(path);
}
n = n.getNextSibling();
}
}
File ejbs = new File(wd, "tmp-ejbs");
ejbs.mkdirs();
for (String path : paths) {
System.out.println("Move EAR module " + path + " to "
+ ejbs.getName());
File f = new File(wd, path);
f.renameTo(new File(ejbs, f.getName()));
}
File lib = new File(wd, "lib");
File[] files = new File(wd, "bundles").listFiles();
if (files != null) {
for (File f : files) {
System.out.println("Move POJO bundle " + f.getName()
+ " to lib");
f.renameTo(new File(lib, f.getName()));
}
}
File bundles = new File(wd, "bundles");
files = ejbs.listFiles();
if (files != null) {
for (File f : files) {
System.out.println("Move back EAR module " + f.getName()
+ " to bundles");
f.renameTo(new File(bundles, f.getName()));
}
}
}
}
| 3,614 | 0.548485 | 0.544077 | 97 | 36.412373 | 25.508339 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.56701 | false | false |
3
|
db7b0ddd8f26257f625c374c86618e68e06c5b98
| 9,869,834,852,372 |
931e158220b2ea6e703b824dbc7c0474d3c99c53
|
/src/main/java/Main.java
|
3fa6acec77796182808c8bc258af3b650689fff1
|
[
"Apache-2.0"
] |
permissive
|
stepan-tarasenko/recognizing_1
|
https://github.com/stepan-tarasenko/recognizing_1
|
09adc2119531ec87b4ad72a963d68b855cfdf529
|
d413ba45820b44c397e6db208d31c5ce5260ef9a
|
refs/heads/master
| 2023-01-08T21:48:35.109000 | 2020-11-08T20:59:05 | 2020-11-08T20:59:05 | 298,761,096 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.io.IOException;
import java.net.URISyntaxException;
public class Main {
public static void main(String[] args) throws IOException, URISyntaxException {
new TextPredictor().main();
}
}
|
UTF-8
|
Java
| 213 |
java
|
Main.java
|
Java
|
[] | null |
[] |
import java.io.IOException;
import java.net.URISyntaxException;
public class Main {
public static void main(String[] args) throws IOException, URISyntaxException {
new TextPredictor().main();
}
}
| 213 | 0.723005 | 0.723005 | 8 | 25.625 | 25.499693 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false |
3
|
a19b235b5a7f8a5d15f082c17fa6185acc84aa36
| 20,452,634,313,065 |
45b657df6ad5f1fd61478f97aa7ad9c3473d8688
|
/Project 1/src/InsertBehavior.java
|
d397eb4ab5652f6203239cb02d4fad2cd2cb5511
|
[] |
no_license
|
lemtzas/Java3D-Project-1
|
https://github.com/lemtzas/Java3D-Project-1
|
08f5f10b1ebd5d44edaf2eada708dec97512bcd5
|
c61a2d1267ef18a92f0c11360dc5211e431e6f5b
|
refs/heads/master
| 2020-05-18T02:21:48.499000 | 2013-05-06T06:31:10 | 2013-05-06T06:31:10 | 9,880,714 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import com.sun.j3d.utils.geometry.Sphere;
import javax.media.j3d.*;
import javax.vecmath.Vector3d;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.Enumeration;
import java.util.Observable;
import java.util.Observer;
/**
* A Behavior meant to work in concert with CamGrabBehavior and FlyCam.
*
* This behavior's job is to manage the selection and insertion of objects around the "cursor" position.
*/
public class InsertBehavior extends Behavior {
/**What events are we listening to?**/
private WakeupOr wakeupEvents;
/**The transform to the cursor's space**/
private TransformGroup curTransform;
/**Where we add things**/
private BranchGroup scene;
/**The object to insert into the world when requested**/
private Node curObject = new Sphere();
/**scratch space variable**/
Transform3D t3d = new Transform3D();
/**scratch space variable**/
Transform3D t3d2 = new Transform3D();
/**scratch space variable**/
Vector3d v3d = new Vector3d();
/**scratch space variable**/
Vector3d v3d2 = new Vector3d();
/**
* Sets up the Insert Behavior
* @param scene where should we insert new elements?
* @param curTransform Where is the cursor?
*/
public InsertBehavior(BranchGroup scene, TransformGroup curTransform) {
this.scene = scene;
this.curTransform = curTransform;
WakeupCriterion[] eventsNormal = {
new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED),
new WakeupOnAWTEvent(KeyEvent.KEY_RELEASED),
new WakeupOnAWTEvent(KeyEvent.KEY_TYPED)};
wakeupEvents = new WakeupOr(eventsNormal);
}
@Override
public void initialize() {
wakeupOn(wakeupEvents);
}
@Override
public void processStimulus(Enumeration criteria) {
WakeupCriterion wakeup;
AWTEvent[] events;
wakeup = (WakeupCriterion)criteria.nextElement();
//this should be the only type of event
if (wakeup instanceof WakeupOnAWTEvent) {
events = ((WakeupOnAWTEvent)wakeup).getAWTEvent();
for(AWTEvent e : events) {
if(e instanceof KeyEvent) {
KeyEvent ke = (KeyEvent)e;
if(ke.getID() == KeyEvent.KEY_TYPED) {
switch(ke.getKeyChar()) {
case '1' : //insert
insertObject();
break;
case '2' : //place
placeObject();
break;
case '3' : //remove
removeObject();
break;
default:
//eh?
}
}
} else {
//eh?
}
}
}
wakeupOn(wakeupEvents);
}
/**Remove the objects currently selected**/
private void removeObject() {
System.out.println("remove object");
//copy over appropriate children
for(int i = curTransform.numChildren()-1; i >= 0 ; i--){
Node child = curTransform.getChild(i);
if(child instanceof BranchGroup) {
curTransform.removeChild(i);
}
}
}
/**Place the currently selected objects into the world**/
private void placeObject() {
System.out.println("place objects");
//copy the current transform
Transform3D t3d = new Transform3D();
curTransform.getTransform(t3d);
TransformGroup tg = new TransformGroup(t3d);
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
tg.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
tg.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
BranchGroup bg = new BranchGroup();
bg.addChild(tg);
//copy over appropriate children
for(int i = curTransform.numChildren()-1; i >= 0 ; i--){
Node child = curTransform.getChild(i);
if(child instanceof BranchGroup) {
curTransform.removeChild(i);
tg.addChild(child);
}
}
//tg.addChild(curObject.cloneTree());
scene.addChild(bg);
}
/**Insert a new object at the cursor. Starts "selected"**/
private void insertObject() {
System.out.println("insert object");
//add branch group (for detach) and a transform (for manipulation) with the new object at the root
BranchGroup bg = new BranchGroup();
bg.setCapability(BranchGroup.ENABLE_PICK_REPORTING);
bg.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
TransformGroup tg = new TransformGroup();
bg.addChild(tg);
bg.setCapability(BranchGroup.ALLOW_DETACH);
tg.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
tg.addChild(curObject.cloneTree());
curTransform.addChild(bg);
}
/**Select an object from the world.
* @param node The object to select. Should already be removed from previous parent.
* @param local The transform to the selected object before it was removed.
*/
public void selectObject(Node node, Transform3D local) {
//node.getLocalToVworld(this.t3d);
local.get(v3d); //get object translation
curTransform.getTransform(t3d2);
t3d2.get(v3d2); //get translation from cur position
v3d.sub(v3d2); //calculate offset
BranchGroup bg;
if(node instanceof BranchGroup) {
bg = (BranchGroup)node;
} else {
//encapsulate the node in a detachable BranchGroup
bg = new BranchGroup();
bg.setCapability(BranchGroup.ENABLE_PICK_REPORTING);
bg.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
bg.setCapability(BranchGroup.ALLOW_DETACH);
TransformGroup tg = new TransformGroup();
bg.addChild(node);
}
// bg.setCapability(BranchGroup.ALLOW_DETACH);
// tg.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
// tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
// tg.addChild(curObject.cloneTree());
curTransform.addChild(bg);
}
/**Sets the object to insert**/
public void setObject(Node node) {
this.curObject = node;
}
}
|
UTF-8
|
Java
| 6,551 |
java
|
InsertBehavior.java
|
Java
|
[] | null |
[] |
import com.sun.j3d.utils.geometry.Sphere;
import javax.media.j3d.*;
import javax.vecmath.Vector3d;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.Enumeration;
import java.util.Observable;
import java.util.Observer;
/**
* A Behavior meant to work in concert with CamGrabBehavior and FlyCam.
*
* This behavior's job is to manage the selection and insertion of objects around the "cursor" position.
*/
public class InsertBehavior extends Behavior {
/**What events are we listening to?**/
private WakeupOr wakeupEvents;
/**The transform to the cursor's space**/
private TransformGroup curTransform;
/**Where we add things**/
private BranchGroup scene;
/**The object to insert into the world when requested**/
private Node curObject = new Sphere();
/**scratch space variable**/
Transform3D t3d = new Transform3D();
/**scratch space variable**/
Transform3D t3d2 = new Transform3D();
/**scratch space variable**/
Vector3d v3d = new Vector3d();
/**scratch space variable**/
Vector3d v3d2 = new Vector3d();
/**
* Sets up the Insert Behavior
* @param scene where should we insert new elements?
* @param curTransform Where is the cursor?
*/
public InsertBehavior(BranchGroup scene, TransformGroup curTransform) {
this.scene = scene;
this.curTransform = curTransform;
WakeupCriterion[] eventsNormal = {
new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED),
new WakeupOnAWTEvent(KeyEvent.KEY_RELEASED),
new WakeupOnAWTEvent(KeyEvent.KEY_TYPED)};
wakeupEvents = new WakeupOr(eventsNormal);
}
@Override
public void initialize() {
wakeupOn(wakeupEvents);
}
@Override
public void processStimulus(Enumeration criteria) {
WakeupCriterion wakeup;
AWTEvent[] events;
wakeup = (WakeupCriterion)criteria.nextElement();
//this should be the only type of event
if (wakeup instanceof WakeupOnAWTEvent) {
events = ((WakeupOnAWTEvent)wakeup).getAWTEvent();
for(AWTEvent e : events) {
if(e instanceof KeyEvent) {
KeyEvent ke = (KeyEvent)e;
if(ke.getID() == KeyEvent.KEY_TYPED) {
switch(ke.getKeyChar()) {
case '1' : //insert
insertObject();
break;
case '2' : //place
placeObject();
break;
case '3' : //remove
removeObject();
break;
default:
//eh?
}
}
} else {
//eh?
}
}
}
wakeupOn(wakeupEvents);
}
/**Remove the objects currently selected**/
private void removeObject() {
System.out.println("remove object");
//copy over appropriate children
for(int i = curTransform.numChildren()-1; i >= 0 ; i--){
Node child = curTransform.getChild(i);
if(child instanceof BranchGroup) {
curTransform.removeChild(i);
}
}
}
/**Place the currently selected objects into the world**/
private void placeObject() {
System.out.println("place objects");
//copy the current transform
Transform3D t3d = new Transform3D();
curTransform.getTransform(t3d);
TransformGroup tg = new TransformGroup(t3d);
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
tg.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
tg.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
BranchGroup bg = new BranchGroup();
bg.addChild(tg);
//copy over appropriate children
for(int i = curTransform.numChildren()-1; i >= 0 ; i--){
Node child = curTransform.getChild(i);
if(child instanceof BranchGroup) {
curTransform.removeChild(i);
tg.addChild(child);
}
}
//tg.addChild(curObject.cloneTree());
scene.addChild(bg);
}
/**Insert a new object at the cursor. Starts "selected"**/
private void insertObject() {
System.out.println("insert object");
//add branch group (for detach) and a transform (for manipulation) with the new object at the root
BranchGroup bg = new BranchGroup();
bg.setCapability(BranchGroup.ENABLE_PICK_REPORTING);
bg.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
TransformGroup tg = new TransformGroup();
bg.addChild(tg);
bg.setCapability(BranchGroup.ALLOW_DETACH);
tg.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
tg.addChild(curObject.cloneTree());
curTransform.addChild(bg);
}
/**Select an object from the world.
* @param node The object to select. Should already be removed from previous parent.
* @param local The transform to the selected object before it was removed.
*/
public void selectObject(Node node, Transform3D local) {
//node.getLocalToVworld(this.t3d);
local.get(v3d); //get object translation
curTransform.getTransform(t3d2);
t3d2.get(v3d2); //get translation from cur position
v3d.sub(v3d2); //calculate offset
BranchGroup bg;
if(node instanceof BranchGroup) {
bg = (BranchGroup)node;
} else {
//encapsulate the node in a detachable BranchGroup
bg = new BranchGroup();
bg.setCapability(BranchGroup.ENABLE_PICK_REPORTING);
bg.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
bg.setCapability(BranchGroup.ALLOW_DETACH);
TransformGroup tg = new TransformGroup();
bg.addChild(node);
}
// bg.setCapability(BranchGroup.ALLOW_DETACH);
// tg.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
// tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
// tg.addChild(curObject.cloneTree());
curTransform.addChild(bg);
}
/**Sets the object to insert**/
public void setObject(Node node) {
this.curObject = node;
}
}
| 6,551 | 0.589834 | 0.583575 | 192 | 33.119793 | 22.699146 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.458333 | false | false |
3
|
450bb105fc5d256f806fe882ab0298dda7793ede
| 17,471,927,004,478 |
a645f2f1a0d307aceea7c635a67083d7aa6b12f7
|
/src/main/java/com/dondog/dbapp/scConController.java
|
710a2f3aa9f283e35dd08270af131e2e7eec99f0
|
[] |
no_license
|
iyeeun96/DonDog
|
https://github.com/iyeeun96/DonDog
|
61ea0667bccd738a4632885c2c1bbdc7c9f40e2e
|
8d31479ee69fb8b8d51bbb385edd012971fe456e
|
refs/heads/master
| 2023-03-12T00:55:14.077000 | 2021-02-25T04:49:14 | 2021-02-25T04:49:14 | 342,125,937 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.dondog.dbapp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;
import com.dondog.dbapp.service.btConService;
import com.dondog.dbapp.service.scConService;
import lombok.extern.java.Log;
@Controller
@Log
public class scConController {
private static final Logger logger = LoggerFactory.getLogger(scConController.class);
//서비스 객체 변수
@Autowired
private scConService scServ;
//ModelAndView 객체
private ModelAndView mv3;
@GetMapping("scContents")
public ModelAndView scContents() {
log.info("scContents()");
mv3 = scServ.sclist();
return mv3;
}
}
|
UTF-8
|
Java
| 863 |
java
|
scConController.java
|
Java
|
[] | null |
[] |
package com.dondog.dbapp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;
import com.dondog.dbapp.service.btConService;
import com.dondog.dbapp.service.scConService;
import lombok.extern.java.Log;
@Controller
@Log
public class scConController {
private static final Logger logger = LoggerFactory.getLogger(scConController.class);
//서비스 객체 변수
@Autowired
private scConService scServ;
//ModelAndView 객체
private ModelAndView mv3;
@GetMapping("scContents")
public ModelAndView scContents() {
log.info("scContents()");
mv3 = scServ.sclist();
return mv3;
}
}
| 863 | 0.76213 | 0.756213 | 38 | 21.236841 | 21.051859 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.657895 | false | false |
3
|
af27f45d1df757db0d9e7e171c8e7519a8a80a05
| 2,233,383,021,472 |
f35293d4c088025efb85be977b63551254eb1ef2
|
/LeetCode/Mix Questions - Various Topics/Missing Number.java
|
9792a10e7d5c73e4b155828d48d88d19f81d19d7
|
[] |
no_license
|
Om4AI/Hackerrank_Solutions
|
https://github.com/Om4AI/Hackerrank_Solutions
|
97ca5c90e274ff3b2ebba04038178e643788c153
|
e100e166e93809f302f2d760311af4af2040f715
|
refs/heads/main
| 2023-03-23T07:36:12.675000 | 2023-03-01T16:55:03 | 2023-03-01T16:55:03 | 304,216,020 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
class Solution {
public int missingNumber(int[] nums) {
int p = 0;
Arrays.sort(nums);
for (int i=0; i<nums.length; i++){
if (nums[i]!=p){
break;
}else p+=1;
}
return p;
}
}
|
UTF-8
|
Java
| 261 |
java
|
Missing Number.java
|
Java
|
[] | null |
[] |
class Solution {
public int missingNumber(int[] nums) {
int p = 0;
Arrays.sort(nums);
for (int i=0; i<nums.length; i++){
if (nums[i]!=p){
break;
}else p+=1;
}
return p;
}
}
| 261 | 0.409962 | 0.398467 | 12 | 20.75 | 12.28227 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.583333 | false | false |
3
|
006a1ade76ab909a94bab864eb38824836657abf
| 22,411,139,351,196 |
0af5c5c2413acc68d472aebcf1c84bf5b033283b
|
/src/test/java/com/usa/pollasoftwareweb/entidad/PartidoTest.java
|
4cc7a05a55442ec57a0ddf1a3af80e6d38788514
|
[] |
no_license
|
sergiorom92/softwarePolla
|
https://github.com/sergiorom92/softwarePolla
|
7ab92d7513ef4d85553215bd625b86f24fb596d6
|
fd6714332b91ee36f013f85a2b214ab1bd45b1da
|
refs/heads/master
| 2021-08-18T21:51:25.124000 | 2017-11-24T01:42:08 | 2017-11-24T01:42:08 | 109,597,847 | 0 | 1 | null | false | 2017-11-19T18:37:07 | 2017-11-05T16:52:01 | 2017-11-06T04:07:21 | 2017-11-19T18:37:07 | 107 | 0 | 1 | 1 |
SQLPL
| false | null |
/*
* 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 com.usa.pollasoftwareweb.entidad;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author Juan
*/
public class PartidoTest {
public PartidoTest() {
}
@Before
public void setUp() {
}
@Test
public void testGetIdPartido() {
System.out.println("getIdPartido");
Partido instance = new Partido();
Integer expResult = null;
Integer result = instance.getIdPartido();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetIdPartido() {
System.out.println("setIdPartido");
Integer idPartido = null;
Partido instance = new Partido();
instance.setIdPartido(idPartido);
fail("The test case is a prototype.");
}
@Test
public void testGetHora() {
System.out.println("getHora");
Partido instance = new Partido();
Date expResult = null;
Date result = instance.getHora();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetHora() {
System.out.println("setHora");
Date hora = null;
Partido instance = new Partido();
instance.setHora(hora);
fail("The test case is a prototype.");
}
@Test
public void testGetMarcadorLocalFinal() {
System.out.println("getMarcadorLocalFinal");
Partido instance = new Partido();
BigInteger expResult = null;
BigInteger result = instance.getMarcadorLocalFinal();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetMarcadorLocalFinal() {
System.out.println("setMarcadorLocalFinal");
BigInteger marcadorLocalFinal = null;
Partido instance = new Partido();
instance.setMarcadorLocalFinal(marcadorLocalFinal);
fail("The test case is a prototype.");
}
@Test
public void testGetMarcadorVisitanteFinal() {
System.out.println("getMarcadorVisitanteFinal");
Partido instance = new Partido();
BigInteger expResult = null;
BigInteger result = instance.getMarcadorVisitanteFinal();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetMarcadorVisitanteFinal() {
System.out.println("setMarcadorVisitanteFinal");
BigInteger marcadorVisitanteFinal = null;
Partido instance = new Partido();
instance.setMarcadorVisitanteFinal(marcadorVisitanteFinal);
fail("The test case is a prototype.");
}
@Test
public void testGetApuestaList() {
System.out.println("getApuestaList");
Partido instance = new Partido();
List<Apuesta> expResult = null;
List<Apuesta> result = instance.getApuestaList();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetApuestaList() {
System.out.println("setApuestaList");
List<Apuesta> apuestaList = null;
Partido instance = new Partido();
instance.setApuestaList(apuestaList);
fail("The test case is a prototype.");
}
@Test
public void testGetIdEquipoLocal() {
System.out.println("getIdEquipoLocal");
Partido instance = new Partido();
Equipo expResult = null;
Equipo result = instance.getIdEquipoLocal();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetIdEquipoLocal() {
System.out.println("setIdEquipoLocal");
Equipo idEquipoLocal = null;
Partido instance = new Partido();
instance.setIdEquipoLocal(idEquipoLocal);
fail("The test case is a prototype.");
}
@Test
public void testGetIdEquipoVisitante() {
System.out.println("getIdEquipoVisitante");
Partido instance = new Partido();
Equipo expResult = null;
Equipo result = instance.getIdEquipoVisitante();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetIdEquipoVisitante() {
System.out.println("setIdEquipoVisitante");
Equipo idEquipoVisitante = null;
Partido instance = new Partido();
instance.setIdEquipoVisitante(idEquipoVisitante);
fail("The test case is a prototype.");
}
@Test
public void testHashCode() {
System.out.println("hashCode");
Partido instance = new Partido();
int expResult = 0;
int result = instance.hashCode();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testEquals() {
System.out.println("equals");
Object object = null;
Partido instance = new Partido();
boolean expResult = false;
boolean result = instance.equals(object);
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testToString() {
System.out.println("toString");
Partido instance = new Partido();
String expResult = "";
String result = instance.toString();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
}
|
UTF-8
|
Java
| 5,744 |
java
|
PartidoTest.java
|
Java
|
[
{
"context": "port static org.junit.Assert.*;\n\n/**\n *\n * @author Juan\n */\npublic class PartidoTest {\n \n public Pa",
"end": 408,
"score": 0.9988245368003845,
"start": 404,
"tag": "NAME",
"value": "Juan"
}
] | null |
[] |
/*
* 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 com.usa.pollasoftwareweb.entidad;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author Juan
*/
public class PartidoTest {
public PartidoTest() {
}
@Before
public void setUp() {
}
@Test
public void testGetIdPartido() {
System.out.println("getIdPartido");
Partido instance = new Partido();
Integer expResult = null;
Integer result = instance.getIdPartido();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetIdPartido() {
System.out.println("setIdPartido");
Integer idPartido = null;
Partido instance = new Partido();
instance.setIdPartido(idPartido);
fail("The test case is a prototype.");
}
@Test
public void testGetHora() {
System.out.println("getHora");
Partido instance = new Partido();
Date expResult = null;
Date result = instance.getHora();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetHora() {
System.out.println("setHora");
Date hora = null;
Partido instance = new Partido();
instance.setHora(hora);
fail("The test case is a prototype.");
}
@Test
public void testGetMarcadorLocalFinal() {
System.out.println("getMarcadorLocalFinal");
Partido instance = new Partido();
BigInteger expResult = null;
BigInteger result = instance.getMarcadorLocalFinal();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetMarcadorLocalFinal() {
System.out.println("setMarcadorLocalFinal");
BigInteger marcadorLocalFinal = null;
Partido instance = new Partido();
instance.setMarcadorLocalFinal(marcadorLocalFinal);
fail("The test case is a prototype.");
}
@Test
public void testGetMarcadorVisitanteFinal() {
System.out.println("getMarcadorVisitanteFinal");
Partido instance = new Partido();
BigInteger expResult = null;
BigInteger result = instance.getMarcadorVisitanteFinal();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetMarcadorVisitanteFinal() {
System.out.println("setMarcadorVisitanteFinal");
BigInteger marcadorVisitanteFinal = null;
Partido instance = new Partido();
instance.setMarcadorVisitanteFinal(marcadorVisitanteFinal);
fail("The test case is a prototype.");
}
@Test
public void testGetApuestaList() {
System.out.println("getApuestaList");
Partido instance = new Partido();
List<Apuesta> expResult = null;
List<Apuesta> result = instance.getApuestaList();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetApuestaList() {
System.out.println("setApuestaList");
List<Apuesta> apuestaList = null;
Partido instance = new Partido();
instance.setApuestaList(apuestaList);
fail("The test case is a prototype.");
}
@Test
public void testGetIdEquipoLocal() {
System.out.println("getIdEquipoLocal");
Partido instance = new Partido();
Equipo expResult = null;
Equipo result = instance.getIdEquipoLocal();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetIdEquipoLocal() {
System.out.println("setIdEquipoLocal");
Equipo idEquipoLocal = null;
Partido instance = new Partido();
instance.setIdEquipoLocal(idEquipoLocal);
fail("The test case is a prototype.");
}
@Test
public void testGetIdEquipoVisitante() {
System.out.println("getIdEquipoVisitante");
Partido instance = new Partido();
Equipo expResult = null;
Equipo result = instance.getIdEquipoVisitante();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testSetIdEquipoVisitante() {
System.out.println("setIdEquipoVisitante");
Equipo idEquipoVisitante = null;
Partido instance = new Partido();
instance.setIdEquipoVisitante(idEquipoVisitante);
fail("The test case is a prototype.");
}
@Test
public void testHashCode() {
System.out.println("hashCode");
Partido instance = new Partido();
int expResult = 0;
int result = instance.hashCode();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testEquals() {
System.out.println("equals");
Object object = null;
Partido instance = new Partido();
boolean expResult = false;
boolean result = instance.equals(object);
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
@Test
public void testToString() {
System.out.println("toString");
Partido instance = new Partido();
String expResult = "";
String result = instance.toString();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
}
| 5,744 | 0.62796 | 0.627786 | 192 | 28.916666 | 19.275776 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.604167 | false | false |
3
|
5b533537efab203115fa9f72e5c5fb8eb287d2b4
| 22,411,139,352,883 |
3947da54355e7a8c0517fa37420a3bafcde51efc
|
/sandbox-apis/vi/src/main/java/org/jclouds/vi/compute/config/ViComputeServiceContextModule.java
|
cdca7e4d8bf24bbea11359fbd760a88761965bae
|
[
"Apache-2.0"
] |
permissive
|
mikem2005/jclouds
|
https://github.com/mikem2005/jclouds
|
20ef81863c08319306908def3bd02a446dce91c9
|
dafa2dc00ca5bebe7a0623225b384b7a68e19ced
|
refs/heads/master
| 2021-01-15T22:24:32.613000 | 2011-02-19T18:47:11 | 2011-02-19T18:47:11 | 1,382,852 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.vi.compute.config;
import static com.google.common.base.Predicates.notNull;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.transform;
import static org.jclouds.vi.reference.ViConstants.PROPERTY_VI_XML_NAMESPACE;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.rmi.RemoteException;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import javax.ws.rs.core.HttpHeaders;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.jclouds.Constants;
import org.jclouds.compute.ComputeServiceAdapter;
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.domain.Location;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.io.Payloads;
import org.jclouds.location.Provider;
import org.jclouds.location.suppliers.OnlyLocationOrFirstZone;
import org.jclouds.rest.HttpClient;
import org.jclouds.vi.Image;
import org.jclouds.vi.compute.functions.DatacenterToLocation;
import org.jclouds.vi.compute.functions.ViImageToImage;
import org.jclouds.vi.compute.functions.VirtualMachineToHardware;
import org.jclouds.vi.compute.functions.VirtualMachineToNodeMetadata;
import org.jclouds.vi.compute.strategy.ViComputeServiceAdapter;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.TypeLiteral;
import com.vmware.vim25.mo.Datacenter;
import com.vmware.vim25.mo.ServiceInstance;
import com.vmware.vim25.mo.VirtualMachine;
import com.vmware.vim25.ws.WSClient;
/**
*
* @author Adrian Cole
*/
public class ViComputeServiceContextModule
extends
ComputeServiceAdapterContextModule<ServiceInstance, ServiceInstance, VirtualMachine, VirtualMachine, Image, Datacenter> {
public ViComputeServiceContextModule() {
super(ServiceInstance.class, ServiceInstance.class);
}
@Override
protected void configure() {
super.configure();
bind(new TypeLiteral<ComputeServiceAdapter<VirtualMachine, VirtualMachine, Image, Datacenter>>() {
}).to(ViComputeServiceAdapter.class);
bind(new TypeLiteral<Supplier<Location>>() {
}).to(OnlyLocationOrFirstZone.class);
bind(new TypeLiteral<Function<VirtualMachine, NodeMetadata>>() {
}).to(VirtualMachineToNodeMetadata.class);
bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
}).to(ViImageToImage.class);
bind(new TypeLiteral<Function<VirtualMachine, Hardware>>() {
}).to(VirtualMachineToHardware.class);
bind(new TypeLiteral<Function<Datacenter, Location>>() {
}).to(DatacenterToLocation.class);
}
@Provides
@Singleton
protected ServiceInstance createConnection(JcloudsWSClient client,
@Named(Constants.PROPERTY_IDENTITY) String identity,
@Named(Constants.PROPERTY_CREDENTIAL) String credential,
@Named(Constants.PROPERTY_TRUST_ALL_CERTS) boolean ignoreCertificate) throws RemoteException,
MalformedURLException {
// uncomment this to use jclouds http commands
// return new ServiceInstance(client, identity, credential, ignoreCertificate);
return new ServiceInstance(new WSClient(client.getBaseUrl().toString(), ignoreCertificate), identity, credential,
ignoreCertificate + "");
}
@Singleton
public static class JcloudsWSClient extends WSClient {
private final HttpClient client;
@Inject
public JcloudsWSClient(HttpClient client, @Provider URI baseUrl,
@Named(PROPERTY_VI_XML_NAMESPACE) String vimNameSpace,
@Named(Constants.PROPERTY_TRUST_ALL_CERTS) boolean ignoreCert) throws MalformedURLException {
super(baseUrl.toASCIIString(), ignoreCert);
this.setVimNameSpace(vimNameSpace);
this.client = client;
}
@Override
public InputStream post(String soapMsg) throws IOException {
Builder<String, String> headers = ImmutableMultimap.<String, String> builder();
headers.put("SOAPAction", "urn:vim25/4.0");
if (getCookie() != null)
headers.put(HttpHeaders.COOKIE, getCookie());
HttpRequest request;
try {
request = HttpRequest.builder().endpoint(getBaseUrl().toURI()).method("POST").headers(headers.build())
.payload(Payloads.newStringPayload(soapMsg)).build();
} catch (URISyntaxException e) {
Throwables.propagate(e);
return null;// unreachable as the above line will throw the exception.
}
HttpResponse response = client.invoke(request);
if (getCookie() != null && response.getFirstHeaderOrNull(HttpHeaders.SET_COOKIE) != null) {
setCookie(response.getFirstHeaderOrNull(HttpHeaders.SET_COOKIE));
}
return response.getPayload().getInput();
}
}
@Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
// String domainDir = injector.getInstance(Key.get(String.class,
// Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR)));
// String domainDir = "";
// String hardwareId = searchForHardwareIdInDomainDir(domainDir);
// String image = searchForImageIdInDomainDir(domainDir);
return template.hardwareId("vm-1221").imageId("winNetEnterprise64Guest");
}
private String searchForImageIdInDomainDir(String domainDir) {
// TODO
return "1";
}
@SuppressWarnings("unchecked")
private String searchForHardwareIdInDomainDir(String domainDir, final ParseSax.Factory factory,
final javax.inject.Provider<UUIDHandler> provider) {
// TODO: remove commons-io dependency
return Iterables.<String> getLast(filter(transform(FileUtils.listFiles(new File(domainDir),
new WildcardFileFilter("*.xml"), null), new Function<File, String>() {
@Override
public String apply(File input) {
try {
return factory.create(provider.get()).parse(new FileInputStream(input));
} catch (FileNotFoundException e) {
// log error.
return null;
}
}
}), notNull()));
}
public static class UUIDHandler extends ParseSax.HandlerWithResult<String> {
private StringBuilder currentText = new StringBuilder();
private boolean inDomain;
private String uuid;
public String getResult() {
return uuid;
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
if (qName.equals("domain")) {
inDomain = true;
}
}
@Override
public void endElement(String uri, String localName, String qName) {
if (qName.equalsIgnoreCase("uuid") && inDomain) {
this.uuid = currentText.toString();
} else if (qName.equalsIgnoreCase("domain")) {
inDomain = false;
}
currentText = new StringBuilder();
}
public void characters(char ch[], int start, int length) {
currentText.append(ch, start, length);
}
}
/*
* Map<String, URI> regions = newLinkedHashMap(); for (String region :
* Splitter.on(',').split(regionString)) { regions.put( region,
* URI.create(injector.getInstance(Key.get(String.class, Names.named(Constants.PROPERTY_ENDPOINT
* + "." + region))))); } return regions;
*/
}
|
UTF-8
|
Java
| 9,105 |
java
|
ViComputeServiceContextModule.java
|
Java
|
[
{
"context": "*\n *\n * Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>\n *\n * ==========================================",
"end": 75,
"score": 0.9999278783798218,
"start": 52,
"tag": "EMAIL",
"value": "info@cloudconscious.com"
},
{
"context": " com.vmware.vim25.ws.WSClient;\n\n/**\n * \n * @author Adrian Cole\n */\npublic class ViComputeServiceContextModule\n ",
"end": 3185,
"score": 0.9998635053634644,
"start": 3174,
"tag": "NAME",
"value": "Adrian Cole"
}
] | null |
[] |
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <<EMAIL>>
*
* ====================================================================
* 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.jclouds.vi.compute.config;
import static com.google.common.base.Predicates.notNull;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.transform;
import static org.jclouds.vi.reference.ViConstants.PROPERTY_VI_XML_NAMESPACE;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.rmi.RemoteException;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import javax.ws.rs.core.HttpHeaders;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.jclouds.Constants;
import org.jclouds.compute.ComputeServiceAdapter;
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.domain.Location;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.io.Payloads;
import org.jclouds.location.Provider;
import org.jclouds.location.suppliers.OnlyLocationOrFirstZone;
import org.jclouds.rest.HttpClient;
import org.jclouds.vi.Image;
import org.jclouds.vi.compute.functions.DatacenterToLocation;
import org.jclouds.vi.compute.functions.ViImageToImage;
import org.jclouds.vi.compute.functions.VirtualMachineToHardware;
import org.jclouds.vi.compute.functions.VirtualMachineToNodeMetadata;
import org.jclouds.vi.compute.strategy.ViComputeServiceAdapter;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.TypeLiteral;
import com.vmware.vim25.mo.Datacenter;
import com.vmware.vim25.mo.ServiceInstance;
import com.vmware.vim25.mo.VirtualMachine;
import com.vmware.vim25.ws.WSClient;
/**
*
* @author <NAME>
*/
public class ViComputeServiceContextModule
extends
ComputeServiceAdapterContextModule<ServiceInstance, ServiceInstance, VirtualMachine, VirtualMachine, Image, Datacenter> {
public ViComputeServiceContextModule() {
super(ServiceInstance.class, ServiceInstance.class);
}
@Override
protected void configure() {
super.configure();
bind(new TypeLiteral<ComputeServiceAdapter<VirtualMachine, VirtualMachine, Image, Datacenter>>() {
}).to(ViComputeServiceAdapter.class);
bind(new TypeLiteral<Supplier<Location>>() {
}).to(OnlyLocationOrFirstZone.class);
bind(new TypeLiteral<Function<VirtualMachine, NodeMetadata>>() {
}).to(VirtualMachineToNodeMetadata.class);
bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
}).to(ViImageToImage.class);
bind(new TypeLiteral<Function<VirtualMachine, Hardware>>() {
}).to(VirtualMachineToHardware.class);
bind(new TypeLiteral<Function<Datacenter, Location>>() {
}).to(DatacenterToLocation.class);
}
@Provides
@Singleton
protected ServiceInstance createConnection(JcloudsWSClient client,
@Named(Constants.PROPERTY_IDENTITY) String identity,
@Named(Constants.PROPERTY_CREDENTIAL) String credential,
@Named(Constants.PROPERTY_TRUST_ALL_CERTS) boolean ignoreCertificate) throws RemoteException,
MalformedURLException {
// uncomment this to use jclouds http commands
// return new ServiceInstance(client, identity, credential, ignoreCertificate);
return new ServiceInstance(new WSClient(client.getBaseUrl().toString(), ignoreCertificate), identity, credential,
ignoreCertificate + "");
}
@Singleton
public static class JcloudsWSClient extends WSClient {
private final HttpClient client;
@Inject
public JcloudsWSClient(HttpClient client, @Provider URI baseUrl,
@Named(PROPERTY_VI_XML_NAMESPACE) String vimNameSpace,
@Named(Constants.PROPERTY_TRUST_ALL_CERTS) boolean ignoreCert) throws MalformedURLException {
super(baseUrl.toASCIIString(), ignoreCert);
this.setVimNameSpace(vimNameSpace);
this.client = client;
}
@Override
public InputStream post(String soapMsg) throws IOException {
Builder<String, String> headers = ImmutableMultimap.<String, String> builder();
headers.put("SOAPAction", "urn:vim25/4.0");
if (getCookie() != null)
headers.put(HttpHeaders.COOKIE, getCookie());
HttpRequest request;
try {
request = HttpRequest.builder().endpoint(getBaseUrl().toURI()).method("POST").headers(headers.build())
.payload(Payloads.newStringPayload(soapMsg)).build();
} catch (URISyntaxException e) {
Throwables.propagate(e);
return null;// unreachable as the above line will throw the exception.
}
HttpResponse response = client.invoke(request);
if (getCookie() != null && response.getFirstHeaderOrNull(HttpHeaders.SET_COOKIE) != null) {
setCookie(response.getFirstHeaderOrNull(HttpHeaders.SET_COOKIE));
}
return response.getPayload().getInput();
}
}
@Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
// String domainDir = injector.getInstance(Key.get(String.class,
// Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR)));
// String domainDir = "";
// String hardwareId = searchForHardwareIdInDomainDir(domainDir);
// String image = searchForImageIdInDomainDir(domainDir);
return template.hardwareId("vm-1221").imageId("winNetEnterprise64Guest");
}
private String searchForImageIdInDomainDir(String domainDir) {
// TODO
return "1";
}
@SuppressWarnings("unchecked")
private String searchForHardwareIdInDomainDir(String domainDir, final ParseSax.Factory factory,
final javax.inject.Provider<UUIDHandler> provider) {
// TODO: remove commons-io dependency
return Iterables.<String> getLast(filter(transform(FileUtils.listFiles(new File(domainDir),
new WildcardFileFilter("*.xml"), null), new Function<File, String>() {
@Override
public String apply(File input) {
try {
return factory.create(provider.get()).parse(new FileInputStream(input));
} catch (FileNotFoundException e) {
// log error.
return null;
}
}
}), notNull()));
}
public static class UUIDHandler extends ParseSax.HandlerWithResult<String> {
private StringBuilder currentText = new StringBuilder();
private boolean inDomain;
private String uuid;
public String getResult() {
return uuid;
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
if (qName.equals("domain")) {
inDomain = true;
}
}
@Override
public void endElement(String uri, String localName, String qName) {
if (qName.equalsIgnoreCase("uuid") && inDomain) {
this.uuid = currentText.toString();
} else if (qName.equalsIgnoreCase("domain")) {
inDomain = false;
}
currentText = new StringBuilder();
}
public void characters(char ch[], int start, int length) {
currentText.append(ch, start, length);
}
}
/*
* Map<String, URI> regions = newLinkedHashMap(); for (String region :
* Splitter.on(',').split(regionString)) { regions.put( region,
* URI.create(injector.getInstance(Key.get(String.class, Names.named(Constants.PROPERTY_ENDPOINT
* + "." + region))))); } return regions;
*/
}
| 9,084 | 0.700384 | 0.697419 | 239 | 37.100418 | 29.587513 | 130 | false | false | 0 | 0 | 0 | 0 | 69 | 0.015157 | 0.669456 | false | false |
3
|
aadae62ea610d7f457b5580187f57a7fa25055e0
| 26,989,574,517,152 |
5d711a0d89f66cff111959cff7fc27348c42fa52
|
/src/main/java/common/Persons.java
|
f4eb197fd92b13ed676170225d68a260b228de74
|
[] |
no_license
|
yueh-github/extra_api
|
https://github.com/yueh-github/extra_api
|
265204cd94c098b06074aa7752dcef02a0de94b9
|
955bf797163cec3bbbdf210333561acbb1408293
|
refs/heads/master
| 2021-01-15T08:18:36.538000 | 2017-08-10T06:47:04 | 2017-08-10T06:47:04 | 99,563,151 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package common;
import lombok.Builder;
import lombok.Data;
/**
* Created by yuehao on 2017/8/7.
*/
@Data
public class Persons {
private String name;
private Integer age;
private String remark;
}
|
UTF-8
|
Java
| 213 |
java
|
Persons.java
|
Java
|
[
{
"context": "ok.Builder;\nimport lombok.Data;\n\n/**\n * Created by yuehao on 2017/8/7.\n */\n@Data\npublic class Persons {\n ",
"end": 85,
"score": 0.9992130398750305,
"start": 79,
"tag": "USERNAME",
"value": "yuehao"
}
] | null |
[] |
package common;
import lombok.Builder;
import lombok.Data;
/**
* Created by yuehao on 2017/8/7.
*/
@Data
public class Persons {
private String name;
private Integer age;
private String remark;
}
| 213 | 0.685446 | 0.657277 | 16 | 12.3125 | 11.427591 | 33 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false |
3
|
1384366a87b55da3c9eed29d49c8aad005009041
| 33,131,377,761,430 |
e4763d6f76c59e31a73121db83c3ba222606f6af
|
/base-springjpa/src/main/java/com/infosky/framework/exception/MyExceptionHandler.java
|
79e53f28056b6703804f34136a939e3d8134016d
|
[] |
no_license
|
zql3315/test1
|
https://github.com/zql3315/test1
|
5828e10e0cdd2c1a0666f7dbfa70bd88a0fec000
|
2b12c0a1ba03dca0cb5e8270f4401854a97a343c
|
refs/heads/master
| 2021-01-21T17:59:59.254000 | 2017-09-30T09:42:26 | 2017-09-30T09:42:26 | 92,006,280 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.infosky.framework.exception;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
import com.infosky.common.util.CommonUtil;
/**
* 添加类/接口功能描述
*
* @author n004881
*/
public class MyExceptionHandler implements HandlerExceptionResolver {
private static final Logger LOG = LoggerFactory.getLogger(MyExceptionHandler.class);
@Override
public ModelAndView resolveException(HttpServletRequest httpservletrequest, HttpServletResponse response, Object obj, Exception exception) {
Map<String, Object> model = new HashMap<String, Object>();
model.put("result", false);
PrintWriter out = null;
model.put("exception", exception);
LOG.error("url:"+httpservletrequest.getRequestURI(), exception);
try {
if (CommonUtil.useAjax(httpservletrequest)) {
response.setCharacterEncoding("UTF-8");
if (exception instanceof MaxUploadSizeExceededException) {
model.put("msg", "文件过大");
} else {
model.put("msg", exception.getLocalizedMessage());
}
response.setContentType(MediaType.APPLICATION_JSON_VALUE); // 设置ContentType
response.setCharacterEncoding("UTF-8"); // 避免乱码
response.setHeader("Cache-Control", "no-cache, must-revalidate");
out = response.getWriter();
out.write(JSONObject.fromObject(model).toString());
return null;
} else if (exception instanceof MaxUploadSizeExceededException) {
if (exception instanceof MaxUploadSizeExceededException) {
model.put("msg", "文件过大");
} else {
model.put("msg", exception.getLocalizedMessage());
}
return null;
} else if (exception instanceof java.lang.Exception) {
return new ModelAndView("common/error", model);
} else if (exception instanceof java.lang.Throwable) {
return new ModelAndView("common/err", model);
} else {
return new ModelAndView("error", model);
}
} catch (Exception e) {
LOG.error(e.getLocalizedMessage());
} finally {
if (out != null) {
out.flush();
out.close();
}
}
return null;
}
}
|
UTF-8
|
Java
| 2,998 |
java
|
MyExceptionHandler.java
|
Java
|
[
{
"context": "CommonUtil;\r\n\r\n/**\r\n * 添加类/接口功能描述\r\n * \r\n * @author n004881\r\n */\r\npublic class MyExceptionHandler implements ",
"end": 644,
"score": 0.9992715120315552,
"start": 637,
"tag": "USERNAME",
"value": "n004881"
}
] | null |
[] |
package com.infosky.framework.exception;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
import com.infosky.common.util.CommonUtil;
/**
* 添加类/接口功能描述
*
* @author n004881
*/
public class MyExceptionHandler implements HandlerExceptionResolver {
private static final Logger LOG = LoggerFactory.getLogger(MyExceptionHandler.class);
@Override
public ModelAndView resolveException(HttpServletRequest httpservletrequest, HttpServletResponse response, Object obj, Exception exception) {
Map<String, Object> model = new HashMap<String, Object>();
model.put("result", false);
PrintWriter out = null;
model.put("exception", exception);
LOG.error("url:"+httpservletrequest.getRequestURI(), exception);
try {
if (CommonUtil.useAjax(httpservletrequest)) {
response.setCharacterEncoding("UTF-8");
if (exception instanceof MaxUploadSizeExceededException) {
model.put("msg", "文件过大");
} else {
model.put("msg", exception.getLocalizedMessage());
}
response.setContentType(MediaType.APPLICATION_JSON_VALUE); // 设置ContentType
response.setCharacterEncoding("UTF-8"); // 避免乱码
response.setHeader("Cache-Control", "no-cache, must-revalidate");
out = response.getWriter();
out.write(JSONObject.fromObject(model).toString());
return null;
} else if (exception instanceof MaxUploadSizeExceededException) {
if (exception instanceof MaxUploadSizeExceededException) {
model.put("msg", "文件过大");
} else {
model.put("msg", exception.getLocalizedMessage());
}
return null;
} else if (exception instanceof java.lang.Exception) {
return new ModelAndView("common/error", model);
} else if (exception instanceof java.lang.Throwable) {
return new ModelAndView("common/err", model);
} else {
return new ModelAndView("error", model);
}
} catch (Exception e) {
LOG.error(e.getLocalizedMessage());
} finally {
if (out != null) {
out.flush();
out.close();
}
}
return null;
}
}
| 2,998 | 0.60603 | 0.602642 | 76 | 36.842106 | 28.596582 | 144 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.736842 | false | false |
3
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.