blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 410 | content_id stringlengths 40 40 | detected_licenses listlengths 0 51 | license_type stringclasses 2
values | repo_name stringlengths 5 132 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 80 | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 132
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 9.45M | extension stringclasses 28
values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 352 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
13070b34221cd7edbce9d40cac404259cb778b01 | 4abd603f82fdfa5f5503c212605f35979b77c406 | /html/Programs/hw4-diff/b03611033-191-0/Diff.java | af8d6b5bb52b1ec7bf47324da517ece6121fe7f5 | [] | no_license | dn070017/1042-PDSA | b23070f51946c8ac708d3ab9f447ab8185bd2a34 | 5e7d7b1b2c9d751a93de9725316aa3b8f59652e6 | refs/heads/master | 2020-03-20T12:13:43.229042 | 2018-06-15T01:00:48 | 2018-06-15T01:00:48 | 137,424,305 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,539 | java |
import java.util.Iterator;
import java.util.NoSuchElementException;
public class Deque<Item> implements Iterable<Item> {
private int N;
private Node first, last;
private Node oldlast, oldfirst;
private class Node {
Item item;
Node next;
}
public Deque() { // construct an empty deque
first = null;
last = null;
N = 0;
}
public boolean isEmpty() { // is the deque empty?
return first == null;
}
public int size() { // return the number of items on the deque
return N;
}
public void addLast(Item item) { // add the item to the end
if (item == null) {
throw new NullPointerException();
} else {
oldlast = last;
last = new Node();
last.item = item;
last.next = null;
if (isEmpty()) {
first = last;
} else {
oldlast.next = last;
}
N++;
}
}
public void addFirst(Item item) { // add the item to the front
if (item == null) {
throw new NullPointerException();
} else {
oldfirst = first;
if (isEmpty()) {
first = new Node();
first.item = item;
last = first;
} else {
first = new Node();
first.item = item;
first.next = oldfirst;
}
N++;
}
}
public Item removeFirst() { // remove and return the item from the front
if (isEmpty()) {
throw new NoSuchElementException();
} else {
Item item;
item = first.item;
first = first.next;
N--;
return item;
}
}
public Item removeLast() { // remove and return the item from the end
if (isEmpty()) {
throw new NoSuchElementException();
} else {
Item item;
item = last.item;
last = oldlast;
N--;
return item;
}
}
public Iterator<Item> iterator() { // return an iterator over items in order from front to end
return (Iterator<Item>) new ListIterator();
}
private class ListIterator implements Iterable<Item> {
private Node current = first;
public boolean hasNext() {
return current != null;
}
public void remove() {
throw new UnsupportedOperationException();
}
public Item Next() {
Item item = current.item;
if (hasNext()) {
current = current.next;
return item;
} else {
throw new NoSuchElementException();
}
}
@Override
public Iterator<Item> iterator() {
.
}
}
public static void main(String[] args) throws Exception { // unit testing
Deque deque=new Deque();
deque.addFirst(""yyy"");
deque.addLast(""fff"");
deque.addLast(""sss"");
String f =null;
//deque.addFirst(f);
StdOut.println(deque.size());
StdOut.println(deque.removeFirst());
}
}
| [
"dn070017@gmail.com"
] | dn070017@gmail.com |
6123909e734c62e87b36a0e89d812e71fa137c00 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/7/7_6cd5ccf894503fb47b18bb45cfd2724a3395139d/RosterBean/7_6cd5ccf894503fb47b18bb45cfd2724a3395139d_RosterBean_s.java | 9c50c9df5602cbbf773960d78e477f154a37759f | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 14,177 | java | /**********************************************************************************
* $URL$
* $Id$
***********************************************************************************
*
* Copyright (c) 2005, 2006 The Regents of the University of California and The Regents of the University of Michigan
*
* Licensed under the Educational Community License, Version 1.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.opensource.org/licenses/ecl1.php
*
* 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.sakaiproject.tool.section.jsf.backingbean;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
import java.text.DateFormat;
import javax.faces.application.Application;
import javax.faces.component.UIColumn;
import javax.faces.component.html.HtmlDataTable;
import javax.faces.component.html.HtmlOutputText;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.custom.sortheader.HtmlCommandSortHeader;
import org.sakaiproject.section.api.coursemanagement.CourseSection;
import org.sakaiproject.section.api.coursemanagement.EnrollmentRecord;
import org.sakaiproject.section.api.coursemanagement.ParticipationRecord;
import org.sakaiproject.section.api.coursemanagement.SectionEnrollments;
import org.sakaiproject.section.api.SectionManager;
import org.sakaiproject.tool.section.decorator.EnrollmentDecorator;
import org.sakaiproject.tool.section.jsf.JsfUtil;
import org.sakaiproject.jsf.spreadsheet.SpreadsheetDataFileWriterCsv;
import org.sakaiproject.jsf.spreadsheet.SpreadsheetUtil;
/**
* Controls the roster page.
*
* @author <a href="mailto:jholtzman@berkeley.edu">Josh Holtzman</a>
*
*/
public class RosterBean extends CourseDependentBean implements Serializable {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(RosterBean.class);
private static final String CAT_COLUMN_PREFIX = "cat";
private String searchText;
private int firstRow;
private int enrollmentsSize;
private boolean externallyManaged;
private List<SelectItem> filterItems;
private List<EnrollmentDecorator> enrollments;
private List<String> categories;
private List<EnrollmentRecord> siteStudents;
public void init() {
// Determine whether this course is externally managed
externallyManaged = getSectionManager().isExternallyManaged(getCourse().getUuid());
// Get the section categories
categories = getSectionManager().getSectionCategories(getSiteContext());
// Get the default search text
if(StringUtils.trimToNull(searchText) == null) {
searchText = JsfUtil.getLocalizedMessage("roster_search_text");
}
// Get the site enrollments
//List<EnrollmentRecord> siteStudents;
if(searchText.equals(JsfUtil.getLocalizedMessage("roster_search_text"))) {
siteStudents = getSectionManager().getSiteEnrollments(getSiteContext());
} else {
siteStudents = getSectionManager().findSiteEnrollments(getSiteContext(), searchText);
}
// Get the section enrollments
Set<String> studentUids = new HashSet<String>();
for(Iterator iter = siteStudents.iterator(); iter.hasNext();) {
ParticipationRecord record = (ParticipationRecord)iter.next();
studentUids.add(record.getUser().getUserUid());
}
SectionEnrollments sectionEnrollments = getSectionManager().getSectionEnrollmentsForStudents(getSiteContext(), studentUids);
// Construct the list of filter items
filterItems = new ArrayList<SelectItem>();
filterItems.add(new SelectItem("", JsfUtil.getLocalizedMessage("filter_all_sections")));
filterItems.add(new SelectItem("MY", JsfUtil.getLocalizedMessage("filter_my_category_sections", new String[] {""})));
for(Iterator<String> iter = categories.iterator(); iter.hasNext();) {
String cat = iter.next();
filterItems.add(new SelectItem(cat, JsfUtil.getLocalizedMessage("filter_my_category_sections",
new String[] {getCategoryName(cat)})));
}
// If this is a TA, and we're filtering, get the TA's participation records
List<CourseSection> assignedSections = null;
if(StringUtils.trimToNull(getFilter()) != null) {
assignedSections = findAssignedSections();
}
// Construct the decorated enrollments for the UI
decorateEnrollments(siteStudents, sectionEnrollments, assignedSections);
}
private void decorateEnrollments(List<EnrollmentRecord> siteStudents, SectionEnrollments sectionEnrollments, List<CourseSection> assignedSections) {
List<EnrollmentDecorator> unpagedEnrollments = new ArrayList<EnrollmentDecorator>();
for(Iterator<EnrollmentRecord> studentIter = siteStudents.iterator(); studentIter.hasNext();) {
EnrollmentRecord enrollment = studentIter.next();
// Build a map of categories to sections in which the student is enrolled
Map<String, CourseSection> map = new HashMap<String, CourseSection>();
for(Iterator catIter = categories.iterator(); catIter.hasNext();) {
String cat = (String)catIter.next();
CourseSection section = sectionEnrollments.getSection(enrollment.getUser().getUserUid(), cat);
map.put(cat, section);
}
// Check to see whether this enrollment should be filtered out
boolean includeStudent = false;
if(StringUtils.trimToNull(getFilter()) == null) {
includeStudent = true;
} else {
for(Iterator<Entry<String, CourseSection>> entryIter = map.entrySet().iterator(); entryIter.hasNext();) {
Entry<String, CourseSection> entry = entryIter.next();
CourseSection section = entry.getValue();
// Some map entries won't have a section at all, since the student isn't in any section of that category
if(section == null) {
continue;
}
if("MY".equals(getFilter()) && assignedSections.contains(section)) {
includeStudent = true;
break;
} else if(section.getCategory().equals(getFilter()) && assignedSections.contains(section)) {
includeStudent = true;
break;
}
}
}
if(includeStudent) {
EnrollmentDecorator decorator = new EnrollmentDecorator(enrollment, map);
unpagedEnrollments.add(decorator);
}
}
// Sort the list
Collections.sort(unpagedEnrollments, getComparator());
// Filter the list of enrollments
enrollments = new ArrayList<EnrollmentDecorator>();
int lastRow;
int maxDisplayedRows = getPrefs().getRosterMaxDisplayedRows();
if(maxDisplayedRows < 1 || firstRow + maxDisplayedRows > unpagedEnrollments.size()) {
lastRow = unpagedEnrollments.size();
} else {
lastRow = firstRow + maxDisplayedRows;
}
enrollments.addAll(unpagedEnrollments.subList(firstRow, lastRow));
enrollmentsSize = unpagedEnrollments.size();
}
private List<CourseSection> findAssignedSections() {
List<CourseSection> assignedSections = new ArrayList<CourseSection>();
for(Iterator<CourseSection> secIter = getSectionManager().getSections(getSiteContext()).iterator(); secIter.hasNext();) {
CourseSection section = secIter.next();
List<ParticipationRecord> tas = getSectionManager().getSectionTeachingAssistants(section.getUuid());
for(Iterator<ParticipationRecord> taIter = tas.iterator(); taIter.hasNext();) {
ParticipationRecord ta = taIter.next();
if(ta.getUser().getUserUid().equals(getUserUid())) {
assignedSections.add(section);
break;
}
}
}
return assignedSections;
}
private Comparator<EnrollmentDecorator> getComparator() {
String sortColumn = getPrefs().getRosterSortColumn();
boolean sortAscending = getPrefs().isRosterSortAscending();
if(sortColumn.equals("studentName")) {
return EnrollmentDecorator.getNameComparator(sortAscending);
} else if(sortColumn.equals("displayId")) {
return EnrollmentDecorator.getDisplayIdComparator(sortAscending);
} else {
return EnrollmentDecorator.getCategoryComparator(sortColumn, sortAscending);
}
}
public HtmlDataTable getRosterDataTable() {
return null;
}
public void setRosterDataTable(HtmlDataTable rosterDataTable) {
Set usedCategories = getUsedCategories();
if (rosterDataTable.findComponent(CAT_COLUMN_PREFIX + "0") == null) {
Application app = FacesContext.getCurrentInstance().getApplication();
// Add columns for each category. Be sure to create unique IDs
// for all child components.
int colpos = 0;
for (Iterator iter = usedCategories.iterator(); iter.hasNext(); colpos++) {
String category = (String)iter.next();
String categoryName = getCategoryName(category);
UIColumn col = new UIColumn();
col.setId(CAT_COLUMN_PREFIX + colpos);
HtmlCommandSortHeader sortHeader = new HtmlCommandSortHeader();
sortHeader.setId(CAT_COLUMN_PREFIX + "sorthdr_" + colpos);
sortHeader.setRendererType("org.apache.myfaces.SortHeader");
sortHeader.setArrow(true);
sortHeader.setColumnName(category);
//sortHeader.setActionListener(app.createMethodBinding("#{rosterBean.sort}", new Class[] {ActionEvent.class}));
HtmlOutputText headerText = new HtmlOutputText();
headerText.setId(CAT_COLUMN_PREFIX + "hdr_" + colpos);
headerText.setValue(categoryName);
sortHeader.getChildren().add(headerText);
col.setHeader(sortHeader);
HtmlOutputText contents = new HtmlOutputText();
contents.setId(CAT_COLUMN_PREFIX + "cell_" + colpos);
contents.setValueBinding("value",
app.createValueBinding("#{enrollment.categoryToSectionMap['" + category + "'].title}"));
col.getChildren().add(contents);
rosterDataTable.getChildren().add(col);
}
}
}
public void search(ActionEvent event) {
// firstRow = 0;
}
public void clearSearch(ActionEvent event) {
firstRow = 0;
searchText = null;
}
public List getEnrollments() {
return enrollments;
}
public int getEnrollmentsSize() {
return enrollmentsSize;
}
public boolean isExternallyManaged() {
return externallyManaged;
}
public String getSearchText() {
return searchText;
}
public void setSearchText(String searchText) {
if (StringUtils.trimToNull(searchText) == null) {
searchText = JsfUtil.getLocalizedMessage("roster_search_text");
}
if (!StringUtils.equals(searchText, this.searchText)) {
if (log.isDebugEnabled()) log.debug("setSearchString " + searchText);
this.searchText = searchText;
setFirstRow(0); // clear the paging when we update the search
}
}
public int getFirstRow() {
return firstRow;
}
public void setFirstRow(int firstRow) {
this.firstRow = firstRow;
}
public String getFilter() {
return getPrefs().getRosterFilter();
}
public void setFilter(String filter) {
getPrefs().setRosterFilter(filter);
}
public List getFilterItems() {
return filterItems;
}
public void export(ActionEvent event){
List<List<Object>> spreadsheetData = new ArrayList<List<Object>>();
// Get the section enrollments
Set<String> studentUids = new HashSet<String>();
for(Iterator iter = siteStudents.iterator(); iter.hasNext();) {
ParticipationRecord record = (ParticipationRecord)iter.next();
studentUids.add(record.getUser().getUserUid());
}
SectionEnrollments sectionEnrollments = getSectionManager().getSectionEnrollmentsForStudents(getSiteContext(), studentUids);
// Add the header row
List<Object> header = new ArrayList<Object>();
header.add(JsfUtil.getLocalizedMessage("roster_table_header_name"));
header.add(JsfUtil.getLocalizedMessage("roster_table_header_id"));
for (Iterator iter = getUsedCategories().iterator(); iter.hasNext();){
String category = (String)iter.next();
String categoryName = getCategoryName(category);
header.add(categoryName);
}
spreadsheetData.add(header);
for(Iterator<EnrollmentDecorator> enrollmentIter = enrollments.iterator(); enrollmentIter.hasNext();) {
EnrollmentDecorator enrollment = enrollmentIter.next();
List<Object> row = new ArrayList<Object>();
row.add(enrollment.getUser().getSortName());
row.add(enrollment.getUser().getDisplayId());
for (Iterator iter = getUsedCategories().iterator(); iter.hasNext();){
String category = (String)iter.next();
CourseSection section = sectionEnrollments.getSection(enrollment.getUser().getUserUid(), category);
try{
row.add(section.getTitle());
}catch(NullPointerException npe){
if(log.isDebugEnabled())log.debug("section type has no enrollments");
row.add("");
}
}
spreadsheetData.add(row);
}
String spreadsheetName = getDownloadFileName(getCourse().getTitle());
SpreadsheetUtil.downloadSpreadsheetData(spreadsheetData, spreadsheetName, new SpreadsheetDataFileWriterCsv());
}
protected String getDownloadFileName(String rawString) {
String dateString = DateFormat.getDateInstance(DateFormat.SHORT).format(new Date());
return rawString.replaceAll("\\W","_")+ "_"+dateString;
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
73ab7cbfa7e94df13f309b118a47b0942e4a87fe | 5c279bca77599a64f2f81555af60cfcc686c6405 | /src/java/com/plan/backend/entities/Venta.java | 890610e9fbda9ce5d426693d878df1c71bb78507 | [] | no_license | katheholmes/Plan | 1d681c2dfe212d7e9fd7a992f519341f51e91e0a | e0416b7560d4a20e7099537c2ffc667676fcf381 | refs/heads/master | 2021-01-12T08:55:23.292811 | 2016-12-17T16:59:13 | 2016-12-17T16:59:13 | 76,722,073 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,004 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.plan.backend.entities;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Kathe
*/
@Entity
@Table(name = "Ventas")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Venta.findAll", query = "SELECT v FROM Venta v")
, @NamedQuery(name = "Venta.findById", query = "SELECT v FROM Venta v WHERE v.id = :id")
, @NamedQuery(name = "Venta.findByFecha", query = "SELECT v FROM Venta v WHERE v.fecha = :fecha")})
public class Venta implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "id")
private Integer id;
@Column(name = "fecha", insertable = false)
private Integer fecha;
@JoinColumn(name = "idUsuario", referencedColumnName = "id")
@ManyToOne
private Usuario idUsuario;
@JoinColumn(name = "idVehiculo", referencedColumnName = "codigo")
@ManyToOne
private Vehiculo idVehiculo;
public Venta() {
}
public Venta(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getFecha() {
return fecha;
}
public void setFecha(Integer fecha) {
this.fecha = fecha;
}
public Usuario getIdUsuario() {
return idUsuario;
}
public void setIdUsuario(Usuario idUsuario) {
this.idUsuario = idUsuario;
}
public Vehiculo getIdVehiculo() {
return idVehiculo;
}
public void setIdVehiculo(Vehiculo idVehiculo) {
this.idVehiculo = idVehiculo;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
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 Venta)) {
return false;
}
Venta other = (Venta) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.plan.backend.entities.Venta[ id=" + id + " ]";
}
}
| [
"Kathe@kathe"
] | Kathe@kathe |
f1b52bb869476a121af9a36ea4164d505da419be | 4cd6be645296fe738745a4be1a7f08a1a303b5a4 | /RNAMovies/RNAFolding/src/de/unibi/bibiserv/rnamovies/Individual.java | 4f6086cbe817f5e276f39cced536a31fb8424f19 | [] | no_license | darshik/RNA-Folding | bfc718a85e2fa6420f1e46bad14ab9261f34a384 | 95c7f7701cc3b8edd8345427e01a4c8aa49dbdbc | refs/heads/master | 2021-01-10T12:49:14.554615 | 2016-04-02T19:41:04 | 2016-04-02T19:41:04 | 55,312,024 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,386 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package de.unibi.bibiserv.rnamovies;
import java.util.Random;
public class Individual {
public static double BindRate = 0.5;
static int defaultGeneLength = 64;
static int defaultGeneLength2 = 500;
public String sequence = "";
public String structure = "";
private byte[] genes = new byte[defaultGeneLength];
// Cache
private int fitness = 0;
private double fitness2 = 0.0;
// Create a random individual
public String generateIndividual2(int length, String structure ) {
Random ran = new Random(5);
boolean bindflag = false;
String Bind = ".";
int indexofbind = 0;
for(int i=0;i<length;i++)
{
structure += '.';
}
for(int i=0;i<length-1;i++)
{
if(structure.charAt(i) != '.')
{
continue;
}
if(Math.random()<BindRate)
{
Bind = "(";
// System.out.println("length-i -1: " + (length-i-1) );
int temp = length-i-1;
if(temp >=1)
{
indexofbind = i + ran.nextInt(temp) + 1;
}
else
{
throw new IllegalArgumentException("*************");
}
if(structure.charAt(indexofbind) == '.')
{
char[] seq= structure.toCharArray();
seq[indexofbind] = ')';
structure = String.valueOf(seq);
bindflag=true;
}
else
{
for(int j = indexofbind;j<length;j++)
{
if(structure.charAt(j) == '.')
{
char[] seq= structure.toCharArray();
seq[j] = ')';
structure = String.valueOf(seq);
bindflag=true;
break;
}
}
}
if(bindflag)
{
char[] seq= structure.toCharArray();
seq[i] = '(';
structure = String.valueOf(seq);
bindflag = false;
}
}
// else
// {
// char[] seq= structure.toCharArray();
// seq[i] = '.';
// structure = String.valueOf(seq);
// }
}
return structure;
}
/* Getters and setters */
// Use this if you want to create individuals with different gene lengths
public static void setDefaultGeneLength(int length) {
defaultGeneLength = length;
}
public char getGene(int index) {
return structure.charAt(index);
}
public void setGene(int index, byte value) {
genes[index] = value;
fitness = 0;
}
/* Public methods */
// public int size() {
// return genes.length;
// }
public int size2() {
return structure.length();
}
public int getFitness() {
fitness = FitnessCalc.getFitness(this);
return fitness;
}
@Override
public String toString() {
return structure;
}
} | [
"darshik.shirodaria@gmail.com"
] | darshik.shirodaria@gmail.com |
5913c30eec992d4957dbb428efec71452ca10f83 | 45e710356e1fdf98b7fbcacc2586f3d384c3d554 | /src/Main.java | 39130232110cddf3774e410a1d63dbdc63524af7 | [] | no_license | ianworthington1/Webscraper | 1fdff7dff933a69208ce1f1341d167ce48a75c73 | 8f8981ac6a47817febf347771b87977ee5ec5985 | refs/heads/master | 2020-03-30T09:26:27.885143 | 2018-10-01T11:09:00 | 2018-10-01T11:09:00 | 151,075,429 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 183 | java |
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Running...");
System.out.println(Login.Login());
}
} | [
"Ian.Worthington@sqs.com"
] | Ian.Worthington@sqs.com |
91665a897e485b965bd935cf2063519750014e8d | 3be72ba5686df090860c6ac37dd1956e9d01fca7 | /src/GUI/SuperMarketPanel.java | 6d20dcdfb8e17ac2427e290b43c751ff760c5d4a | [] | no_license | nirfinz/Supermarket-management | 22647866028b5b321c9ee5c68b70e02d375f8619 | 624ef963221bf79395bbb249e463b8b1c9b53780 | refs/heads/master | 2020-03-19T09:37:07.496122 | 2018-06-07T09:46:36 | 2018-06-07T09:46:36 | 136,304,222 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,097 | java | package GUI;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.SpringLayout;
import javax.swing.border.LineBorder;
import AllClasses.*;
@SuppressWarnings("serial")
public class SuperMarketPanel extends JPanel {
public final static int MAX_BUTTONS = 6;
public final static int TABEL_WIDTH = 250;
public final static int TABEL_HEIGHT = 120;
public final static int TEXT_WIDTH=250;
public final static int TEXT_HEIGHT = 100;
private MyTableModel tableModel;
private JTable tblProducts;
private JScrollPane scrollerProduct;
private JTextArea text;
private SuperMarket market;
private SpringLayout mainPanelLayout;
private JButton addButton;
private JButton remove;
private JButton sortByName;
private JButton sortByBarcode;
private JButton sortByDate;
private JButton expDate;
public SuperMarketPanel (SuperMarket market){
this.market=market;
mainPanelLayout = new SpringLayout();
setLayout(mainPanelLayout);
setPreferredSize(new Dimension(520,300));
JPanel tablePanel = createTablePanle();
JPanel boxLayout = createBoxLayoutPanel();
JPanel textArea = createTextArea();
textArea.setBorder(new LineBorder(Color.RED));
tblProducts.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent mouse) {
int row = tblProducts.getSelectedRow();
String barcode =(String) tblProducts.getValueAt(row, 0);
Product p = market.getProductByBarcode(barcode);
text.setText(p.toString());
remove.setEnabled(true);
}
});
add(textArea);
add(tablePanel);
add(boxLayout);
mainPanelLayout.putConstraint(SpringLayout.WEST, tablePanel, 10, SpringLayout.WEST, this);
mainPanelLayout.putConstraint(SpringLayout.NORTH, tablePanel, 10, SpringLayout.NORTH, this);
mainPanelLayout.putConstraint(SpringLayout.NORTH, textArea, 10, SpringLayout.SOUTH, tablePanel);
mainPanelLayout.putConstraint(SpringLayout.WEST, textArea, 10, SpringLayout.WEST, this);
mainPanelLayout.putConstraint(SpringLayout.WEST, boxLayout, 10, SpringLayout.EAST, tablePanel);
mainPanelLayout.putConstraint(SpringLayout.NORTH, boxLayout, 40, SpringLayout.NORTH, this);
}
public JPanel createTextArea() {
JPanel textAreaPanel = new JPanel();
text = new JTextArea();
text.setPreferredSize(new Dimension(TEXT_WIDTH,TEXT_HEIGHT));
text.setEditable(false);
text.setBackground(Color.WHITE);
text.setLineWrap(true);
text.setWrapStyleWord(true);
textAreaPanel.add(text);
return textAreaPanel;
}
public JPanel createBoxLayoutPanel() {
JPanel boxLayout = new JPanel();
boxLayout.setPreferredSize(new Dimension(200, 200));
boxLayout.setLayout(new GridLayout(MAX_BUTTONS, 1, 0, 5));
this.addButton = new JButton("Add");
boxLayout.add(addButton);
this.remove = new JButton("Remove");
boxLayout.add(remove);
this.sortByName = new JButton("Name Sort");
boxLayout.add(sortByName);
this.sortByBarcode = new JButton("Barcode Sort");
boxLayout.add(sortByBarcode);
this.sortByDate = new JButton("Date Sort");
boxLayout.add(sortByDate);
this.expDate = new JButton("Check Exp Date");
boxLayout.add(expDate);
remove.setEnabled(false);
eventButtons();
return boxLayout;
}
private void addProduct() {
new AddProductDialog(market, this);
}
public void eventButtons() {
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addProduct();
}
});
remove.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent delete) {
int row = tblProducts.getSelectedRow();
if(row != -1){
String barcode = (String)tblProducts.getValueAt(row, 0);
market.removeProduct(barcode);
tblProducts.clearSelection();
text.setText(" ");
tableModel.fireTableDataChanged();
}
remove.setEnabled(false);
}
});
sortByName.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
market.sortProductsByName();
tableModel.fireTableDataChanged();
}
});
sortByBarcode.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
market.sortProductsByBarcode();
tableModel.fireTableDataChanged();
}
});
sortByDate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
market.sortProductsByExpDate();
tableModel.fireTableDataChanged();
}
});
expDate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new ShowExpDate(market);
}
});
}
public JPanel createTablePanle() {
JPanel pnlMain = new JPanel();
// tableModel = new DefaultTableModel();
// tblProducts = new JTable(tableModel);
// tblProducts.setPreferredScrollableViewportSize(new Dimension(TABEL_WIDTH,TABEL_HEIGHT));
//
// tableModel.setColumnIdentifiers(new Object[] {"Barcode","Name","Exp Date"});
//
// scrollerProduct = new JScrollPane(tblProducts);
// scrollerProduct.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
//
// for(int i = 0 ;i<market.getProdCount();i++){
// Product p = market.getProductVector().elementAt(i);
// tableModel.addRow(new Object[] {p.getBarcode(),p.getName(),(p.getExpDate() != null )? p.getExpDate():"None",p});
// }
//
// pnlMain.add(scrollerProduct);
tableModel = new MyTableModel(market);
tblProducts = new JTable(tableModel);
tblProducts.setPreferredScrollableViewportSize(new Dimension(TABEL_WIDTH,TABEL_HEIGHT));
scrollerProduct = new JScrollPane(tblProducts);
scrollerProduct.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
tableModel.fireTableDataChanged();
pnlMain.add(scrollerProduct);
return pnlMain;
}
}
| [
"nirfinz2@gmail.com"
] | nirfinz2@gmail.com |
6fc340eab2cba11d4aed6bfe78f2cc0d3f8b9773 | e18ec6e8310a7c45a90fd188bcf9a3d242f18776 | /src/org/free/en/ji/_000/word/list/operation/_100W/_alpha/e/Every_enI.java | 66fb5b60d977d901a21a07c41c89325585c079b1 | [] | no_license | peter-me1/org_free_root | f5a24a4651c011a5ee822cdc0dd02f66b255ebdb | 4cbaeadc2b5cc8c94e8cb937e10cad94b4ca0c5a | refs/heads/master | 2021-01-10T06:15:13.766827 | 2015-11-15T19:25:28 | 2015-11-15T19:25:28 | 46,078,901 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 97 | java | package org.free.en.ji._000.word.list.operation._100W._alpha.e;
public interface Every_enI {
}
| [
"peter.me@mail.de"
] | peter.me@mail.de |
789ddb7895404b4eb1a39bc57f8ea3d8005def3d | 7f96edd98dde86d86e945673ac838897e48eed7b | /src/Array/SecondLargestInArray.java | ac5e3fbae8bf02246d4abdfe950aa44b24aec08e | [] | no_license | AvianshKumar/DataStructure | 956dec221935164e876a58c1c9b0f914d4c798f2 | 05024c3a95b32bb97800bb565d07c88b16026730 | refs/heads/master | 2023-04-08T21:47:46.310995 | 2021-04-22T15:53:41 | 2021-04-22T15:53:41 | 360,574,169 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,032 | java | package Array;
public class SecondLargestInArray {
public static void main(String[] args)
{
int arr[] = { 12, 35, 1, 10, 34, 1 };
int n = arr.length;
print2largest(arr, n);
}
static int print2largest(int arr[], int n) {
// code here
int maax=Integer.MIN_VALUE;
int secondMax = Integer.MIN_VALUE;
if(arr.length<2){
return -1;
}
// if(arr[0]>arr[1]){
// maax = arr[0];
// secondMax = arr[1];
// }else{
// secondMax = arr[0];
// maax = arr[1];
// }
//maax = arr[0];
for(int i=0;i<arr.length;i++){
if(arr[i]>maax){
secondMax = maax;
maax = arr[i];
}else if(arr[i]>secondMax && arr[i]!=maax)
{
secondMax = arr[i];
}
}
if(secondMax == Integer.MIN_VALUE){
return -1;
}else{
return secondMax;
}
}
}
| [
"kumaravi256@gmail.com"
] | kumaravi256@gmail.com |
d678d96ffcdcc8aeaac42a3afe614e197736ab3d | 8ac011a48f037e769af08750a5b6171d56a2cd92 | /src/main/java/com/algaworks/brewer/repository/Estilos.java | a8220eb46ca8e8d56f75366b730829cbc743bd60 | [] | no_license | npi-fabio-franca/brewer | fc3c793080557b9c4a9f51d21f7d50dc77365f4f | 14f4b5ac9bd3e299b2d01e665032bdd327bc8416 | refs/heads/master | 2023-03-25T03:09:59.257647 | 2021-03-24T10:34:46 | 2021-03-24T10:34:46 | 344,767,579 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 365 | java | package com.algaworks.brewer.repository;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.algaworks.brewer.model.Estilo;
@Repository
public interface Estilos extends JpaRepository<Estilo, Long>{
public Optional<Estilo> findByNomeIgnoreCase(String nome);
}
| [
"fabio.franca@npisistemas.com.br"
] | fabio.franca@npisistemas.com.br |
cc5e1f8e80a96d50a746f3aaa9a127f400304ce0 | 15bd89ba16e29afa189636d8041d2efa636e829f | /src/realisticNameGenerator.java | 2029564a28c519415a2fc208d35c428100250a9e | [] | no_license | ZacNeu/AirlineSeating | c8b5acaed524ac2e2101af97eba75508e9298723 | 1c256bbb8d4fabd2f5bcf63c4e0b2ecafaedede1 | refs/heads/master | 2022-12-21T10:01:52.191075 | 2020-08-31T21:19:51 | 2020-08-31T21:19:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,701 | java | /**
* A class to provide a passenger manifest using realistic
* first and last names, using popular (ie) frequent first
* and last names in the US. The class comprises three String
* arrays with common masculine and feminine first names. In
* a tribute to my COMP 170 SP 20 students -- the first class
* to go online due to COVID-19, in March 2020 -- I am using
* their last names in array lastnames[].
*
* The class comprises a method that returns a randomly generated
* name, with a 50-50 probability for a male or female person.
*
* To use this class, instantiate it first, then access its
* .realisticName() method.
*
*/
import java.util.Random;
public class RealisticNameGenerator {
private static final String[] lastNames = {
"Johnson",
"Williams",
"Brown",
"Jones",
"Garcia",
"Miller",
"Davis",
"Rodriguez",
"Martinez",
"Hernandez",
"Lopez",
"Gonzalez",
"Wilson",
"Anderson",
"Thomas",
"Taylor",
"Moore",
"Jackson",
"Martin",
"Lee",
"Irakliotis"};
private static final String[] firstNamesMale = {
"James",
"John",
"Robert",
"Michael",
"William",
"David",
"Richard",
"Charles",
"Joseph",
"Thomas",
"Christopher",
"Daniel",
"Paul",
"Mark",
"Donald",
"George",
"Kenneth",
"Steven",
"Edward",
"Brian",
"Leo"
};
private static final String[] firstNameFemale = {
"Mary",
"Patricia",
"Linda",
"Barbara",
"Elizabeth",
"Jennifer",
"Maria",
"Susan",
"Margaret",
"Dorothy",
"Lisa",
"Nancy",
"Karen",
"Betty",
"Helen",
"Sandra",
"Donna",
"Carol",
"Ruth",
"Sharon",
"Michelle",
};
/**
* Method realisticName is the principal method of this class. Users
* may access this class' main service only through this method. It
* returns a String[2] array, where the first element is a <b>realistic</b>
* first name and the second element is a realistic last name. The
* gender for the first name is determined by a coin toss.
* @return realisticName Contains first and last name
*/
public String[] realisticName () {
/**
* Sizes of the name arrays. These are necessary and parameters
* for Random.nextInt().
*/
int lastNamesCount = lastNames.length;
int maleFirstNamesCount = firstNamesMale.length;
int femaleFirstNamesCount = firstNameFemale.length;
/**
* A local variable to be used as a coin flip to determine
* if the output will be a masculine or feminine first name.
*/
int gender;
/**
* Local array with two elements for first and last name,
* respectively. This is the item returned by this method.
*/
String[] name = new String[2];
/** Instantiate random number class */
Random rand = new Random();
/** Flip a coid; 0 is female; 1 is male */
gender = rand.nextInt(2);
/** Select a last name at random */
name[1] = lastNames[rand.nextInt(lastNamesCount)]; // last names common to both genders
/**
* Select a first name at random, from the male or female
* array, based on the value of the gender "coin flip"
*/
if (gender == 0) { // female first name
name[0] = firstNameFemale[rand.nextInt(femaleFirstNamesCount)];
} else { // male first name
name[0] = firstNamesMale[rand.nextInt(maleFirstNamesCount)];
}
/* question for class: how to bias towards female or male first names? */
return name;
}
/* Method main() below is for local testing only */
public static void main(String[] args) {
final int N = 20;
RealisticNameGenerator realNames = new RealisticNameGenerator();
String[] realName = new String[2];
for (int i = 0; i<N; i++) {
realName = realNames.realisticName();
System.out.println(realName[0] + " " + realName[1]);
}
}
}
| [
"lgreco@gmail.com"
] | lgreco@gmail.com |
c60133607a1aeb51b85c907a9cd86db0ba7931aa | 74a04e09d1e854ef8c085e93cdebd9f6cb735d7b | /src/main/java/domain/Request.java | 0bc4ed394404205b4fcbeea8c89339563e04f913 | [] | no_license | brapercob/DP2-18-19 | 5bbf2dd0dfb5282efab34a61dceff8df06af5929 | cd6624595f8276904fd944c4825868fd0821508a | refs/heads/master | 2020-04-24T20:04:09.987995 | 2019-03-07T22:13:17 | 2019-03-07T22:13:17 | 172,232,465 | 0 | 0 | null | 2019-03-07T22:13:18 | 2019-02-23T15:51:21 | Java | UTF-8 | Java | false | false | 1,228 | java | package domain;
import java.util.Collection;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
@Entity
@Access(AccessType.PROPERTY)
public class Request extends DomainEntity{
public Collection<Member> members;
public Collection<Procesion> procesions;
public Integer status;
public Integer row;
public Integer column;
public String reason;
public Integer getStatus() {
return this.status;
}
public void setStatus(final Integer status) {
this.status = status;
}
public Integer getRow() {
return this.row;
}
public void setRow(final Integer row) {
this.row = row;
}
public Integer getColumn() {
return this.column;
}
public void setColumn(final Integer column) {
this.column = column;
}
public String getReason() {
return this.reason;
}
public void setReason(final String reason) {
this.reason = reason;
}
@ManyToOne
public Collection<Member> getMembers() {
return this.members;
}
@ManyToOne
public Collection<Procesion> getProcesions() {
return this.procesions;
}
public void setProcesions(final Collection<Procesion> procesions) {
this.procesions = procesions;
}
}
| [
"raulgarciadelapoza@gmail.com"
] | raulgarciadelapoza@gmail.com |
ab057035a4696a8f9ccc3be0699306de21a82756 | 1c48c5c9723e8a9a6954ea2addc7c1211736ba33 | /library/src/main/java/im/r_c/android/fusioncache/DiskLruCache.java | 1ffc263843a893aabf684e88bbbc3a24fe763dc6 | [
"MIT"
] | permissive | kpioneer123/fusion-cache | 6c806712aaed49838baaae7cd9588862876808b4 | dbac25de2089b0669397c566422163e495451f4c | refs/heads/master | 2021-01-17T06:42:59.666188 | 2016-08-11T03:04:32 | 2016-08-11T03:04:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 34,085 | java | /*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.r_c.android.fusioncache;
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.reflect.Array;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* *****************************************************************************
* Taken from the JB source code, can be found in:
* libcore/luni/src/main/java/libcore/io/DiskLruCache.java
* or direct link:
* https://android.googlesource.com/platform/libcore/+/android-4.1.1_r1/luni/src/main/java/libcore/io/DiskLruCache.java
* *****************************************************************************
* <p>
* A cache that uses a bounded amount of space on a filesystem. Each cache
* entry has a string key and a fixed number of values. Values are byte
* sequences, accessible as streams or files. Each value must be between {@code
* 0} and {@code Integer.MAX_VALUE} bytes in length.
* <p>
* <p>The cache stores its data in a directory on the filesystem. This
* directory must be exclusive to the cache; the cache may delete or overwrite
* files from its directory. It is an error for multiple processes to use the
* same cache directory at the same time.
* <p>
* <p>This cache limits the number of bytes that it will store on the
* filesystem. When the number of stored bytes exceeds the limit, the cache will
* remove entries in the background until the limit is satisfied. The limit is
* not strict: the cache may temporarily exceed it while waiting for files to be
* deleted. The limit does not include filesystem overhead or the cache
* journal so space-sensitive applications should set a conservative limit.
* <p>
* <p>Clients call {@link #edit} to create or update the values of an entry. An
* entry may have only one editor at one time; if a value is not available to be
* edited then {@link #edit} will return null.
* <ul>
* <li>When an entry is being <strong>created</strong> it is necessary to
* supply a full set of values; the empty value should be used as a
* placeholder if necessary.
* <li>When an entry is being <strong>edited</strong>, it is not necessary
* to supply data for every value; values default to their previous
* value.
* </ul>
* Every {@link #edit} call must be matched by a call to {@link Editor#commit}
* or {@link Editor#abort}. Committing is atomic: a read observes the full set
* of values as they were before or after the commit, but never a mix of values.
* <p>
* <p>Clients call {@link #get} to read a snapshot of an entry. The read will
* observe the value at the time that {@link #get} was called. Updates and
* removals after the call do not impact ongoing reads.
* <p>
* <p>This class is tolerant of some I/O errors. If files are missing from the
* filesystem, the corresponding entries will be dropped from the cache. If
* an error occurs while writing a cache value, the edit will fail silently.
* Callers should handle other problems by catching {@code IOException} and
* responding appropriately.
*/
public final class DiskLruCache implements Closeable {
static final String JOURNAL_FILE = "journal";
static final String JOURNAL_FILE_TMP = "journal.tmp";
static final String MAGIC = "libcore.io.DiskLruCache";
static final String VERSION_1 = "1";
static final long ANY_SEQUENCE_NUMBER = -1;
private static final String CLEAN = "CLEAN";
private static final String DIRTY = "DIRTY";
private static final String REMOVE = "REMOVE";
private static final String READ = "READ";
private static final Charset UTF_8 = Charset.forName("UTF-8");
private static final int IO_BUFFER_SIZE = 8 * 1024;
/*
* This cache uses a journal file named "journal". A typical journal file
* looks like this:
* libcore.io.DiskLruCache
* 1
* 100
* 2
*
* CLEAN 3400330d1dfc7f3f7f4b8d4d803dfcf6 832 21054
* DIRTY 335c4c6028171cfddfbaae1a9c313c52
* CLEAN 335c4c6028171cfddfbaae1a9c313c52 3934 2342
* REMOVE 335c4c6028171cfddfbaae1a9c313c52
* DIRTY 1ab96a171faeeee38496d8b330771a7a
* CLEAN 1ab96a171faeeee38496d8b330771a7a 1600 234
* READ 335c4c6028171cfddfbaae1a9c313c52
* READ 3400330d1dfc7f3f7f4b8d4d803dfcf6
*
* The first five lines of the journal form its header. They are the
* constant string "libcore.io.DiskLruCache", the disk cache's version,
* the application's version, the value count, and a blank line.
*
* Each of the subsequent lines in the file is a record of the state of a
* cache entry. Each line contains space-separated values: a state, a key,
* and optional state-specific values.
* o DIRTY lines track that an entry is actively being created or updated.
* Every successful DIRTY action should be followed by a CLEAN or REMOVE
* action. DIRTY lines without a matching CLEAN or REMOVE indicate that
* temporary files may need to be deleted.
* o CLEAN lines track a cache entry that has been successfully published
* and may be read. A publish line is followed by the lengths of each of
* its values.
* o READ lines track accesses for LRU.
* o REMOVE lines track entries that have been deleted.
*
* The journal file is appended to as cache operations occur. The journal may
* occasionally be compacted by dropping redundant lines. A temporary file named
* "journal.tmp" will be used during compaction; that file should be deleted if
* it exists when the cache is opened.
*/
private final File directory;
private final File journalFile;
private final File journalFileTmp;
private final int appVersion;
private final long maxSize;
private final int valueCount;
private long size = 0;
private Writer journalWriter;
private final LinkedHashMap<String, Entry> lruEntries
= new LinkedHashMap<String, Entry>(0, 0.75f, true);
private int redundantOpCount;
/**
* To differentiate between old and current snapshots, each entry is given
* a sequence number each time an edit is committed. A snapshot is stale if
* its sequence number is not equal to its entry's sequence number.
*/
private long nextSequenceNumber = 0;
/* From java.util.Arrays */
@SuppressWarnings("unchecked")
private static <T> T[] copyOfRange(T[] original, int start, int end) {
final int originalLength = original.length; // For exception priority compatibility.
if (start > end) {
throw new IllegalArgumentException();
}
if (start < 0 || start > originalLength) {
throw new ArrayIndexOutOfBoundsException();
}
final int resultLength = end - start;
final int copyLength = Math.min(resultLength, originalLength - start);
final T[] result = (T[]) Array
.newInstance(original.getClass().getComponentType(), resultLength);
System.arraycopy(original, start, result, 0, copyLength);
return result;
}
/**
* Returns the remainder of 'reader' as a string, closing it when done.
*/
public static String readFully(Reader reader) throws IOException {
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[1024];
int count;
while ((count = reader.read(buffer)) != -1) {
writer.write(buffer, 0, count);
}
return writer.toString();
} finally {
reader.close();
}
}
/**
* Returns the ASCII characters up to but not including the next "\r\n", or
* "\n".
*
* @throws java.io.EOFException if the stream is exhausted before the next newline
* character.
*/
public static String readAsciiLine(InputStream in) throws IOException {
// TODO: support UTF-8 here instead
StringBuilder result = new StringBuilder(80);
while (true) {
int c = in.read();
if (c == -1) {
throw new EOFException();
} else if (c == '\n') {
break;
}
result.append((char) c);
}
int length = result.length();
if (length > 0 && result.charAt(length - 1) == '\r') {
result.setLength(length - 1);
}
return result.toString();
}
/**
* Closes 'closeable', ignoring any checked exceptions. Does nothing if 'closeable' is null.
*/
public static void closeQuietly(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (RuntimeException rethrown) {
throw rethrown;
} catch (Exception ignored) {
}
}
}
/**
* Recursively delete everything in {@code dir}.
*/
// TODO: this should specify paths as Strings rather than as Files
public static void deleteContents(File dir) throws IOException {
File[] files = dir.listFiles();
if (files == null) {
throw new IllegalArgumentException("not a directory: " + dir);
}
for (File file : files) {
if (file.isDirectory()) {
deleteContents(file);
}
if (!file.delete()) {
throw new IOException("failed to delete file: " + file);
}
}
}
/**
* This cache uses a single background thread to evict entries.
*/
private final ExecutorService executorService = new ThreadPoolExecutor(0, 1,
60L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
private final Callable<Void> cleanupCallable = new Callable<Void>() {
@Override
public Void call() throws Exception {
synchronized (DiskLruCache.this) {
if (journalWriter == null) {
return null; // closed
}
trimToSize();
if (journalRebuildRequired()) {
rebuildJournal();
redundantOpCount = 0;
}
}
return null;
}
};
private DiskLruCache(File directory, int appVersion, int valueCount, long maxSize) {
this.directory = directory;
this.appVersion = appVersion;
this.journalFile = new File(directory, JOURNAL_FILE);
this.journalFileTmp = new File(directory, JOURNAL_FILE_TMP);
this.valueCount = valueCount;
this.maxSize = maxSize;
}
/**
* Opens the cache in {@code directory}, creating a cache if none exists
* there.
*
* @param directory a writable directory
* @param appVersion
* @param valueCount the number of values per cache entry. Must be positive.
* @param maxSize the maximum number of bytes this cache should use to store
* @throws java.io.IOException if reading or writing the cache directory fails
*/
public static DiskLruCache open(File directory, int appVersion, int valueCount, long maxSize)
throws IOException {
if (maxSize <= 0) {
throw new IllegalArgumentException("maxSize <= 0");
}
if (valueCount <= 0) {
throw new IllegalArgumentException("valueCount <= 0");
}
// prefer to pick up where we left off
DiskLruCache cache = new DiskLruCache(directory, appVersion, valueCount, maxSize);
if (cache.journalFile.exists()) {
try {
cache.readJournal();
cache.processJournal();
cache.journalWriter = new BufferedWriter(new FileWriter(cache.journalFile, true),
IO_BUFFER_SIZE);
return cache;
} catch (IOException journalIsCorrupt) {
// System.logW("DiskLruCache " + directory + " is corrupt: "
// + journalIsCorrupt.getMessage() + ", removing");
cache.delete();
}
}
// create a new empty cache
directory.mkdirs();
cache = new DiskLruCache(directory, appVersion, valueCount, maxSize);
cache.rebuildJournal();
return cache;
}
private void readJournal() throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(journalFile), IO_BUFFER_SIZE);
try {
String magic = readAsciiLine(in);
String version = readAsciiLine(in);
String appVersionString = readAsciiLine(in);
String valueCountString = readAsciiLine(in);
String blank = readAsciiLine(in);
if (!MAGIC.equals(magic)
|| !VERSION_1.equals(version)
|| !Integer.toString(appVersion).equals(appVersionString)
|| !Integer.toString(valueCount).equals(valueCountString)
|| !"".equals(blank)) {
throw new IOException("unexpected journal header: ["
+ magic + ", " + version + ", " + valueCountString + ", " + blank + "]");
}
while (true) {
try {
readJournalLine(readAsciiLine(in));
} catch (EOFException endOfJournal) {
break;
}
}
} finally {
closeQuietly(in);
}
}
private void readJournalLine(String line) throws IOException {
String[] parts = line.split(" ");
if (parts.length < 2) {
throw new IOException("unexpected journal line: " + line);
}
String key = parts[1];
if (parts[0].equals(REMOVE) && parts.length == 2) {
lruEntries.remove(key);
return;
}
Entry entry = lruEntries.get(key);
if (entry == null) {
entry = new Entry(key);
lruEntries.put(key, entry);
}
if (parts[0].equals(CLEAN) && parts.length == 2 + valueCount) {
entry.readable = true;
entry.currentEditor = null;
entry.setLengths(copyOfRange(parts, 2, parts.length));
} else if (parts[0].equals(DIRTY) && parts.length == 2) {
entry.currentEditor = new Editor(entry);
} else if (parts[0].equals(READ) && parts.length == 2) {
// this work was already done by calling lruEntries.get()
} else {
throw new IOException("unexpected journal line: " + line);
}
}
/**
* Computes the initial size and collects garbage as a part of opening the
* cache. Dirty entries are assumed to be inconsistent and will be deleted.
*/
private void processJournal() throws IOException {
deleteIfExists(journalFileTmp);
for (Iterator<Entry> i = lruEntries.values().iterator(); i.hasNext(); ) {
Entry entry = i.next();
if (entry.currentEditor == null) {
for (int t = 0; t < valueCount; t++) {
size += entry.lengths[t];
}
} else {
entry.currentEditor = null;
for (int t = 0; t < valueCount; t++) {
deleteIfExists(entry.getCleanFile(t));
deleteIfExists(entry.getDirtyFile(t));
}
i.remove();
}
}
}
/**
* Creates a new journal that omits redundant information. This replaces the
* current journal if it exists.
*/
private synchronized void rebuildJournal() throws IOException {
if (journalWriter != null) {
journalWriter.close();
}
Writer writer = new BufferedWriter(new FileWriter(journalFileTmp), IO_BUFFER_SIZE);
writer.write(MAGIC);
writer.write("\n");
writer.write(VERSION_1);
writer.write("\n");
writer.write(Integer.toString(appVersion));
writer.write("\n");
writer.write(Integer.toString(valueCount));
writer.write("\n");
writer.write("\n");
for (Entry entry : lruEntries.values()) {
if (entry.currentEditor != null) {
writer.write(DIRTY + ' ' + entry.key + '\n');
} else {
writer.write(CLEAN + ' ' + entry.key + entry.getLengths() + '\n');
}
}
writer.close();
journalFileTmp.renameTo(journalFile);
journalWriter = new BufferedWriter(new FileWriter(journalFile, true), IO_BUFFER_SIZE);
}
private static void deleteIfExists(File file) throws IOException {
// try {
// Libcore.os.remove(file.getPath());
// } catch (ErrnoException errnoException) {
// if (errnoException.errno != OsConstants.ENOENT) {
// throw errnoException.rethrowAsIOException();
// }
// }
if (file.exists() && !file.delete()) {
throw new IOException();
}
}
/**
* Returns a snapshot of the entry named {@code key}, or null if it doesn't
* exist is not currently readable. If a value is returned, it is moved to
* the head of the LRU queue.
*/
public synchronized Snapshot get(String key) throws IOException {
checkNotClosed();
validateKey(key);
Entry entry = lruEntries.get(key);
if (entry == null) {
return null;
}
if (!entry.readable) {
return null;
}
/*
* Open all streams eagerly to guarantee that we see a single published
* snapshot. If we opened streams lazily then the streams could come
* from different edits.
*/
InputStream[] ins = new InputStream[valueCount];
try {
for (int i = 0; i < valueCount; i++) {
ins[i] = new FileInputStream(entry.getCleanFile(i));
}
} catch (FileNotFoundException e) {
// a file must have been deleted manually!
return null;
}
redundantOpCount++;
journalWriter.append(READ + ' ' + key + '\n');
if (journalRebuildRequired()) {
executorService.submit(cleanupCallable);
}
return new Snapshot(key, entry.sequenceNumber, ins);
}
/**
* Returns an editor for the entry named {@code key}, or null if another
* edit is in progress.
*/
public Editor edit(String key) throws IOException {
return edit(key, ANY_SEQUENCE_NUMBER);
}
private synchronized Editor edit(String key, long expectedSequenceNumber) throws IOException {
checkNotClosed();
validateKey(key);
Entry entry = lruEntries.get(key);
if (expectedSequenceNumber != ANY_SEQUENCE_NUMBER
&& (entry == null || entry.sequenceNumber != expectedSequenceNumber)) {
return null; // snapshot is stale
}
if (entry == null) {
entry = new Entry(key);
lruEntries.put(key, entry);
} else if (entry.currentEditor != null) {
return null; // another edit is in progress
}
Editor editor = new Editor(entry);
entry.currentEditor = editor;
// flush the journal before creating files to prevent file leaks
journalWriter.write(DIRTY + ' ' + key + '\n');
journalWriter.flush();
return editor;
}
/**
* Returns the directory where this cache stores its data.
*/
public File getDirectory() {
return directory;
}
/**
* Returns the maximum number of bytes that this cache should use to store
* its data.
*/
public long maxSize() {
return maxSize;
}
/**
* Returns the number of bytes currently being used to store the values in
* this cache. This may be greater than the max size if a background
* deletion is pending.
*/
public synchronized long size() {
return size;
}
private synchronized void completeEdit(Editor editor, boolean success) throws IOException {
Entry entry = editor.entry;
if (entry.currentEditor != editor) {
throw new IllegalStateException();
}
// if this edit is creating the entry for the first time, every index must have a value
if (success && !entry.readable) {
for (int i = 0; i < valueCount; i++) {
if (!entry.getDirtyFile(i).exists()) {
editor.abort();
throw new IllegalStateException("edit didn't create file " + i);
}
}
}
for (int i = 0; i < valueCount; i++) {
File dirty = entry.getDirtyFile(i);
if (success) {
if (dirty.exists()) {
File clean = entry.getCleanFile(i);
dirty.renameTo(clean);
long oldLength = entry.lengths[i];
long newLength = clean.length();
entry.lengths[i] = newLength;
size = size - oldLength + newLength;
}
} else {
deleteIfExists(dirty);
}
}
redundantOpCount++;
entry.currentEditor = null;
if (entry.readable | success) {
entry.readable = true;
journalWriter.write(CLEAN + ' ' + entry.key + entry.getLengths() + '\n');
if (success) {
entry.sequenceNumber = nextSequenceNumber++;
}
} else {
lruEntries.remove(entry.key);
journalWriter.write(REMOVE + ' ' + entry.key + '\n');
}
if (size > maxSize || journalRebuildRequired()) {
executorService.submit(cleanupCallable);
}
}
/**
* We only rebuild the journal when it will halve the size of the journal
* and eliminate at least 2000 ops.
*/
private boolean journalRebuildRequired() {
final int REDUNDANT_OP_COMPACT_THRESHOLD = 2000;
return redundantOpCount >= REDUNDANT_OP_COMPACT_THRESHOLD
&& redundantOpCount >= lruEntries.size();
}
/**
* Drops the entry for {@code key} if it exists and can be removed. Entries
* actively being edited cannot be removed.
*
* @return true if an entry was removed.
*/
public synchronized boolean remove(String key) throws IOException {
checkNotClosed();
validateKey(key);
Entry entry = lruEntries.get(key);
if (entry == null || entry.currentEditor != null) {
return false;
}
for (int i = 0; i < valueCount; i++) {
File file = entry.getCleanFile(i);
if (!file.delete()) {
throw new IOException("failed to delete " + file);
}
size -= entry.lengths[i];
entry.lengths[i] = 0;
}
redundantOpCount++;
journalWriter.append(REMOVE + ' ' + key + '\n');
lruEntries.remove(key);
if (journalRebuildRequired()) {
executorService.submit(cleanupCallable);
}
return true;
}
/**
* Returns true if this cache has been closed.
*/
public boolean isClosed() {
return journalWriter == null;
}
private void checkNotClosed() {
if (journalWriter == null) {
throw new IllegalStateException("cache is closed");
}
}
/**
* Force buffered operations to the filesystem.
*/
public synchronized void flush() throws IOException {
checkNotClosed();
trimToSize();
journalWriter.flush();
}
/**
* Closes this cache. Stored values will remain on the filesystem.
*/
public synchronized void close() throws IOException {
if (journalWriter == null) {
return; // already closed
}
for (Entry entry : new ArrayList<Entry>(lruEntries.values())) {
if (entry.currentEditor != null) {
entry.currentEditor.abort();
}
}
trimToSize();
journalWriter.close();
journalWriter = null;
}
private void trimToSize() throws IOException {
while (size > maxSize) {
// Map.Entry<String, Entry> toEvict = lruEntries.eldest();
final Map.Entry<String, Entry> toEvict = lruEntries.entrySet().iterator().next();
remove(toEvict.getKey());
}
}
/**
* Closes the cache and deletes all of its stored values. This will delete
* all files in the cache directory including files that weren't created by
* the cache.
*/
public void delete() throws IOException {
close();
deleteContents(directory);
}
private void validateKey(String key) {
if (key.contains(" ") || key.contains("\n") || key.contains("\r")) {
throw new IllegalArgumentException(
"keys must not contain spaces or newlines: \"" + key + "\"");
}
}
private static String inputStreamToString(InputStream in) throws IOException {
return readFully(new InputStreamReader(in, UTF_8));
}
/**
* A snapshot of the values for an entry.
*/
public final class Snapshot implements Closeable {
private final String key;
private final long sequenceNumber;
private final InputStream[] ins;
private Snapshot(String key, long sequenceNumber, InputStream[] ins) {
this.key = key;
this.sequenceNumber = sequenceNumber;
this.ins = ins;
}
/**
* Returns an editor for this snapshot's entry, or null if either the
* entry has changed since this snapshot was created or if another edit
* is in progress.
*/
public Editor edit() throws IOException {
return DiskLruCache.this.edit(key, sequenceNumber);
}
/**
* Returns the unbuffered stream with the value for {@code index}.
*/
public InputStream getInputStream(int index) {
return ins[index];
}
/**
* Returns the string value for {@code index}.
*/
public String getString(int index) throws IOException {
return inputStreamToString(getInputStream(index));
}
@Override
public void close() {
for (InputStream in : ins) {
closeQuietly(in);
}
}
}
/**
* Edits the values for an entry.
*/
public final class Editor {
private final Entry entry;
private boolean hasErrors;
private Editor(Entry entry) {
this.entry = entry;
}
/**
* Returns an unbuffered input stream to read the last committed value,
* or null if no value has been committed.
*/
public InputStream newInputStream(int index) throws IOException {
synchronized (DiskLruCache.this) {
if (entry.currentEditor != this) {
throw new IllegalStateException();
}
if (!entry.readable) {
return null;
}
return new FileInputStream(entry.getCleanFile(index));
}
}
/**
* Returns the last committed value as a string, or null if no value
* has been committed.
*/
public String getString(int index) throws IOException {
InputStream in = newInputStream(index);
return in != null ? inputStreamToString(in) : null;
}
/**
* Returns a new unbuffered output stream to write the value at
* {@code index}. If the underlying output stream encounters errors
* when writing to the filesystem, this edit will be aborted when
* {@link #commit} is called. The returned output stream does not throw
* IOExceptions.
*/
public OutputStream newOutputStream(int index) throws IOException {
synchronized (DiskLruCache.this) {
if (entry.currentEditor != this) {
throw new IllegalStateException();
}
return new FaultHidingOutputStream(new FileOutputStream(entry.getDirtyFile(index)));
}
}
/**
* Sets the value at {@code index} to {@code value}.
*/
public void set(int index, String value) throws IOException {
Writer writer = null;
try {
writer = new OutputStreamWriter(newOutputStream(index), UTF_8);
writer.write(value);
} finally {
closeQuietly(writer);
}
}
/**
* Commits this edit so it is visible to readers. This releases the
* edit lock so another edit may be started on the same key.
*/
public void commit() throws IOException {
if (hasErrors) {
completeEdit(this, false);
remove(entry.key); // the previous entry is stale
} else {
completeEdit(this, true);
}
}
/**
* Aborts this edit. This releases the edit lock so another edit may be
* started on the same key.
*/
public void abort() throws IOException {
completeEdit(this, false);
}
private class FaultHidingOutputStream extends FilterOutputStream {
private FaultHidingOutputStream(OutputStream out) {
super(out);
}
@Override
public void write(int oneByte) {
try {
out.write(oneByte);
} catch (IOException e) {
hasErrors = true;
}
}
@Override
public void write(byte[] buffer, int offset, int length) {
try {
out.write(buffer, offset, length);
} catch (IOException e) {
hasErrors = true;
}
}
@Override
public void close() {
try {
out.close();
} catch (IOException e) {
hasErrors = true;
}
}
@Override
public void flush() {
try {
out.flush();
} catch (IOException e) {
hasErrors = true;
}
}
}
}
private final class Entry {
private final String key;
/**
* Lengths of this entry's files.
*/
private final long[] lengths;
/**
* True if this entry has ever been published
*/
private boolean readable;
/**
* The ongoing edit or null if this entry is not being edited.
*/
private Editor currentEditor;
/**
* The sequence number of the most recently committed edit to this entry.
*/
private long sequenceNumber;
private Entry(String key) {
this.key = key;
this.lengths = new long[valueCount];
}
public String getLengths() throws IOException {
StringBuilder result = new StringBuilder();
for (long size : lengths) {
result.append(' ').append(size);
}
return result.toString();
}
/**
* Set lengths using decimal numbers like "10123".
*/
private void setLengths(String[] strings) throws IOException {
if (strings.length != valueCount) {
throw invalidLengths(strings);
}
try {
for (int i = 0; i < strings.length; i++) {
lengths[i] = Long.parseLong(strings[i]);
}
} catch (NumberFormatException e) {
throw invalidLengths(strings);
}
}
private IOException invalidLengths(String[] strings) throws IOException {
throw new IOException("unexpected journal line: " + Arrays.toString(strings));
}
public File getCleanFile(int i) {
return new File(directory, key + "." + i);
}
public File getDirtyFile(int i) {
return new File(directory, key + "." + i + ".tmp");
}
}
}
| [
"richardchienthebest@gmail.com"
] | richardchienthebest@gmail.com |
f656c180f6f99419d5ca6eb735fb7ecd5fa4cc37 | ffbf37d68c94123b9105e676eed4341e7eb55896 | /app/src/main/java/com/omg/ireader/ui/adapter/view/DownloadHolder.java | e5a941d43ac7d6ec1d043b6aad4d286d8fa5e6f0 | [
"MIT"
] | permissive | stateInstance/FengQiReader | a8868be2209576bc0547ed6cc3bd300f605139a1 | 7fbab189fa147d6349ad6467aeb86a0e45500ff6 | refs/heads/master | 2021-08-16T17:33:01.986862 | 2017-11-20T05:53:18 | 2017-11-20T05:53:24 | 111,366,384 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,005 | java | package com.omg.ireader.ui.adapter.view;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.omg.ireader.R;
import com.omg.ireader.model.bean.DownloadTaskBean;
import com.omg.ireader.ui.base.adapter.ViewHolderImpl;
import com.omg.ireader.utils.FileUtils;
import com.omg.ireader.utils.StringUtils;
/**
* . on 17-5-12.
*/
public class DownloadHolder extends ViewHolderImpl<DownloadTaskBean> {
private TextView mTvTitle;
private TextView mTvMsg;
private TextView mTvTip;
private ProgressBar mPbShow;
private RelativeLayout mRlToggle;
private ImageView mIvStatus;
private TextView mTvStatus;
@Override
public void initView() {
mTvTitle = findById(R.id.download_tv_title);
mTvMsg = findById(R.id.download_tv_msg);
mTvTip = findById(R.id.download_tv_tip);
mPbShow = findById(R.id.download_pb_show);
mRlToggle = findById(R.id.download_rl_toggle);
mIvStatus = findById(R.id.download_iv_status);
mTvStatus = findById(R.id.download_tv_status);
}
@Override
public void onBind(DownloadTaskBean value, int pos) {
if (!mTvTitle.getText().equals(value.getTaskName())){
mTvTitle.setText(value.getTaskName());
}
switch (value.getStatus()){
case DownloadTaskBean.STATUS_LOADING:
changeBtnStyle(R.string.nb_download_pause,
R.color.nb_download_pause,R.drawable.ic_download_pause);
//进度状态
setProgressMax(value);
mPbShow.setProgress(value.getCurrentChapter());
setTip(R.string.nb_download_loading);
mTvMsg.setText(StringUtils.getString(R.string.nb_download_progress,
value.getCurrentChapter(),value.getBookChapters().size()));
break;
case DownloadTaskBean.STATUS_PAUSE:
//按钮状态
changeBtnStyle(R.string.nb_download_start,
R.color.nb_download_loading,R.drawable.ic_download_loading);
//进度状态
setProgressMax(value);
setTip(R.string.nb_download_pausing);
mPbShow.setProgress(value.getCurrentChapter());
mTvMsg.setText(StringUtils.getString(R.string.nb_download_progress,
value.getCurrentChapter(),value.getBookChapters().size()));
break;
case DownloadTaskBean.STATUS_WAIT:
//按钮状态
changeBtnStyle(R.string.nb_download_wait,
R.color.nb_download_wait,R.drawable.ic_download_wait);
//进度状态
setProgressMax(value);
setTip(R.string.nb_download_waiting);
mPbShow.setProgress(value.getCurrentChapter());
mTvMsg.setText(StringUtils.getString(R.string.nb_download_progress,
value.getCurrentChapter(),value.getBookChapters().size()));
break;
case DownloadTaskBean.STATUS_ERROR:
//按钮状态
changeBtnStyle(R.string.nb_download_error,
R.color.nb_download_error,R.drawable.ic_download_error);
setTip(R.string.nb_download_source_error);
mPbShow.setVisibility(View.INVISIBLE);
mTvMsg.setVisibility(View.GONE);
break;
case DownloadTaskBean.STATUS_FINISH:
//按钮状态
changeBtnStyle(R.string.nb_download_finish,
R.color.nb_download_finish,R.drawable.ic_download_complete);
setTip(R.string.nb_download_complete);
mPbShow.setVisibility(View.INVISIBLE);
//设置文件大小
mTvMsg.setText(FileUtils.getFileSize(value.getSize()));
break;
}
}
private void changeBtnStyle(int strRes,int colorRes,int drawableRes){
//按钮状态
if (!mTvStatus.getText().equals(
StringUtils.getString(strRes))){
mTvStatus.setText(StringUtils.getString(strRes));
mTvStatus.setTextColor(getContext().getResources().getColor(colorRes));
mIvStatus.setImageResource(drawableRes);
}
}
private void setProgressMax(DownloadTaskBean value){
if (mPbShow.getMax() != value.getBookChapters().size()){
mPbShow.setVisibility(View.VISIBLE);
mPbShow.setMax(value.getBookChapters().size());
}
}
//提示
private void setTip(int strRes){
if (!mTvTip.getText().equals(StringUtils.getString(strRes))){
mTvTip.setText(StringUtils.getString(strRes));
}
}
@Override
protected int getItemLayoutId() {
return R.layout.item_download;
}
}
| [
"454360996@qq.com"
] | 454360996@qq.com |
d95fd61edb3d4837d923ec0bddcf2c2bf0a888b4 | 8b3455215e01310c2077920e39753c7da6c5f381 | /UWServer/src/com/micropakito/persist/entity/usuariossesion/UsuariosesionJpaController.java | ac2a0af7a272bacfcd0a9a7f3d334d62e6950964 | [] | no_license | Micropakito/urgwars | c6ab6d22ca2e13fc5a018223e4b1f24b0bf511be | 17f5a6f5df20ff1e598f7e08b88e92d73cb7e948 | refs/heads/master | 2021-01-20T02:46:57.386147 | 2012-10-18T10:32:02 | 2012-10-18T10:32:02 | 32,143,279 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,826 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.micropakito.persist.entity.usuariossesion;
import com.micropakito.persist.entity.usuariossesion.exceptions.NonexistentEntityException;
import com.micropakito.persist.entity.usuariossesion.exceptions.PreexistingEntityException;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import javax.persistence.EntityNotFoundException;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
/**
*
* @author PascuaS
*/
public class UsuariosesionJpaController {
public UsuariosesionJpaController() {
emf = Persistence.createEntityManagerFactory("UWServerPU");
}
private EntityManagerFactory emf = null;
public EntityManager getEntityManager() {
return emf.createEntityManager();
}
public void create(Usuariosesion usuariosesion) throws PreexistingEntityException, Exception {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
em.persist(usuariosesion);
em.getTransaction().commit();
} catch (Exception ex) {
if (findUsuariosesion(usuariosesion.getIdUsuarioSesion()) != null) {
throw new PreexistingEntityException("Usuariosesion " + usuariosesion + " already exists.", ex);
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void edit(Usuariosesion usuariosesion) throws NonexistentEntityException, Exception {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
usuariosesion = em.merge(usuariosesion);
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = usuariosesion.getIdUsuarioSesion();
if (findUsuariosesion(id) == null) {
throw new NonexistentEntityException("The usuariosesion with id " + id + " no longer exists.");
}
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void destroy(Integer id) throws NonexistentEntityException {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
Usuariosesion usuariosesion;
try {
usuariosesion = em.getReference(Usuariosesion.class, id);
usuariosesion.getIdUsuarioSesion();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The usuariosesion with id " + id + " no longer exists.", enfe);
}
em.remove(usuariosesion);
em.getTransaction().commit();
} finally {
if (em != null) {
em.close();
}
}
}
public List<Usuariosesion> findUsuariosesionEntities() {
return findUsuariosesionEntities(true, -1, -1);
}
public List<Usuariosesion> findUsuariosesionEntities(int maxResults, int firstResult) {
return findUsuariosesionEntities(false, maxResults, firstResult);
}
private List<Usuariosesion> findUsuariosesionEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(Usuariosesion.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
public Usuariosesion findUsuariosesion(Integer id) {
EntityManager em = getEntityManager();
try {
return em.find(Usuariosesion.class, id);
} finally {
em.close();
}
}
public int getUsuariosesionCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<Usuariosesion> rt = cq.from(Usuariosesion.class);
cq.select(em.getCriteriaBuilder().count(rt));
Query q = em.createQuery(cq);
return ((Long) q.getSingleResult()).intValue();
} finally {
em.close();
}
}
}
| [
"micropakito@4cc3cb17-523a-1e42-7a16-127342d069f7"
] | micropakito@4cc3cb17-523a-1e42-7a16-127342d069f7 |
0c36aa8cec4105db168c04282ed10b22e2ce4584 | 6b17b0dc6ad57078e09a0d5def9e842690262456 | /src/main/java/com/example/sbbs/SbbsApplication.java | 194931c9e2ddaa103830a4cb980612bd6a170c9f | [] | no_license | liukunyin/sbbs | 0b8e6cef9e49a3b66bbdbb3e01f5601c967dc244 | 96eca498a352916cf13693cc7fc40ed9e9889246 | refs/heads/master | 2021-04-10T01:51:16.167613 | 2020-03-21T04:00:11 | 2020-03-21T04:03:00 | 248,901,372 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 305 | java | package com.example.sbbs;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SbbsApplication {
public static void main(String[] args) {
SpringApplication.run(SbbsApplication.class, args);
}
}
| [
"2500693004@qq.com"
] | 2500693004@qq.com |
7aa1f5aa6849ea8e5c8d72576e6c3c645abff6da | d4c79a845e2532b9bfcd7f5c8ae484ca179ed463 | /src/main/java/com/template/java_9/multi_resolution_image_api/Main.java | 1cf416922289951f59f7ca2a89100cb64b3dbaee | [
"Apache-2.0"
] | permissive | marcosrachid/java-updates-from-8-to-date | 69ddb5f35f9fdf8cad8937473c403ae5a8b0f7d9 | b8e12801138e0b650ca97e1d3b685bfbb21e4e08 | refs/heads/main | 2023-01-21T11:02:28.028024 | 2020-12-07T03:21:54 | 2020-12-07T03:21:54 | 319,066,805 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,162 | java | package com.template.java_9.multi_resolution_image_api;
import java.awt.Image;
import java.awt.image.BaseMultiResolutionImage;
import java.awt.image.MultiResolutionImage;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
public class Main {
public static void main(String[] args) {
try {
List<String> imgUrls = List.of("http://www.tutorialspoint.com/java9/images/logo.png",
"http://www.tutorialspoint.com/java9/images/mini_logo.png",
"http://www.tutorialspoint.com/java9/images/large_logo.png");
List<Image> images = new ArrayList<>();
for (String url : imgUrls) {
images.add(ImageIO.read(new URL(url)));
}
// read all images into one multiresolution image
MultiResolutionImage multiResolutionImage =
new BaseMultiResolutionImage(images.toArray(new Image[0]));
// get all variants of images
List<Image> variants = multiResolutionImage.getResolutionVariants();
System.out.println("Total number of images: " + variants.size());
for (Image img : variants) {
System.out.println(img);
}
// get a resolution-specific image variant for each indicated size
Image variant1 = multiResolutionImage.getResolutionVariant(156, 45);
System.out.printf("\nImage for destination[%d,%d]: [%d,%d]",
156, 45, variant1.getWidth(null), variant1.getHeight(null));
Image variant2 = multiResolutionImage.getResolutionVariant(311, 89);
System.out.printf("\nImage for destination[%d,%d]: [%d,%d]", 311, 89,
variant2.getWidth(null), variant2.getHeight(null));
Image variant3 = multiResolutionImage.getResolutionVariant(622, 178);
System.out.printf("\nImage for destination[%d,%d]: [%d,%d]", 622, 178,
variant3.getWidth(null), variant3.getHeight(null));
Image variant4 = multiResolutionImage.getResolutionVariant(300, 300);
System.out.printf("\nImage for destination[%d,%d]: [%d,%d]", 300, 300,
variant4.getWidth(null), variant4.getHeight(null));
} catch (Exception e) {
e.printStackTrace();
}
}
}
| [
"marcosrachid@gmail.com"
] | marcosrachid@gmail.com |
2b028955d799193b288cdd248b50ff666d2ed070 | d2d061eef5882ad4b4ce79b253136f8bcaf34d53 | /src/Test.java | c38fdebf760486d77f4cc54db94bd8d7bf379955 | [] | no_license | 826647235/Graduation | e2320f470cf79a9ac2f097a88b02bb6a056749ce | 70ba34b26f7637288c9f0f8f4c2bc7729d448752 | refs/heads/master | 2020-05-17T00:44:19.855577 | 2019-05-23T10:16:31 | 2019-05-23T10:16:31 | 183,404,630 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 817 | java | import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStreamWriter;
@WebServlet(name = "Test")
public class Test extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream());
out.write("Service is already running");
out.flush();
out.close();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}
| [
"826647235@q.com"
] | 826647235@q.com |
1508f78e515b925748fa105efc7b4a116ce52629 | a568b6d8e5fad02a6ee19c65ba25be7aaff3e828 | /dicomweb-common-service/src/main/java/org/alvearie/imaging/ingestion/service/s3/S3Service.java | 45268d5000b7cc2e18f1fcd9b280f10c1faab29a | [
"Apache-2.0"
] | permissive | draiberg/imaging-ingestion | 1ea1219c668ae77ab442ec8837f11c9148b6d498 | 94c1ae930c26518691ddc23a81bc035f9cba851d | refs/heads/main | 2023-08-19T05:59:55.665809 | 2021-10-22T16:21:06 | 2021-10-22T16:21:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,483 | java | /*
* (C) Copyright IBM Corp. 2021
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.alvearie.imaging.ingestion.service.s3;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import org.jboss.logging.Logger;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.core.sync.ResponseTransformer;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
import software.amazon.awssdk.services.s3.model.PutObjectResponse;
@ApplicationScoped
public class S3Service extends PersistenceService {
private static final Logger LOG = Logger.getLogger(S3Service.class);
@Inject
S3Client s3;
@Override
public ByteArrayOutputStream getObject(String objectKey) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GetObjectRequest request = GetObjectRequest.builder().bucket(config.getBucketName()).key(objectKey).build();
s3.getObject(request, ResponseTransformer.toOutputStream(baos));
return baos;
}
@Override
public void putObject(StoreContext ctx) throws NoSuchAlgorithmException, IOException {
File file = new File(ctx.getFilePath());
String sha256 = super.getContentChecksum(MessageDigest.getInstance("SHA-256"), file);
String key = sha256 + ".dcm";
ctx.setObjectName(key);
LOG.infof("Put %s to object store", key);
PutObjectRequest request = PutObjectRequest.builder().bucket(config.getBucketName()).key(key)
.contentType("application/octet-stream").build();
PutObjectResponse response = s3.putObject(request, Paths.get(ctx.getFilePath()));
if (response == null) {
throw new IOException("Error storing to object store");
}
LOG.infof("%s stored in object store", key);
}
@PostConstruct
void init() throws URISyntaxException {
AwsCredentials credentials = AwsBasicCredentials.create(config.getAwsAcessKeyID(),
config.getAwsSecretAccessKey());
AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(credentials);
String hostPort = config.getBucketHost() + ":" + config.getBucketPort();
if (!hostPort.startsWith("http://") && !hostPort.startsWith("https://")) {
if ("443".equals(config.getBucketPort())) {
hostPort = "https://" + hostPort;
} else if ("80".equals(config.getBucketPort())) {
hostPort = "http://" + hostPort;
} else {
hostPort = "https://" + hostPort;
}
}
s3 = S3Client.builder().credentialsProvider(credentialsProvider).endpointOverride(new URI(hostPort))
.region(Region.of(config.getBucketRegion())).build();
}
}
| [
"jjacob@us.ibm.com"
] | jjacob@us.ibm.com |
d35c8837bf2f48793beadd1aacabd7caca5566f9 | e4b6315f4adcbe85b45156b1a6636c6377a633cd | /java11/src/main/java/java.xml/com/sun/org/apache/xml/internal/utils/XMLStringDefault.java | 7933d669624bfb350d7e55e98afed20433b2e9bc | [] | no_license | sunxiongkun/jdk-source | 48f0664d50f8c63e6f92eb1bb643e3ed452f99ee | 068e4867e17e5a965703d2edf561781b4f7b22a2 | refs/heads/master | 2020-04-15T01:56:30.872418 | 2019-01-07T02:33:58 | 2019-01-07T02:33:58 | 164,297,232 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 31,452 | java | /*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.utils;
import java.util.Locale;
/**
* The default implementation of the XMLString interface,
* which is just a simple wrapper of a String object.
*/
public class XMLStringDefault implements XMLString
{
private String m_str;
/**
* Create a XMLStringDefault object from a String
*/
public XMLStringDefault(String str)
{
m_str = str;
}
/**
* Directly call the
* characters method on the passed ContentHandler for the
* string-value. Multiple calls to the
* ContentHandler's characters methods may well occur for a single call to
* this method.
*
* @param ch A non-null reference to a ContentHandler.
*
* @throws org.xml.sax.SAXException
*/
public void dispatchCharactersEvents(org.xml.sax.ContentHandler ch)
throws org.xml.sax.SAXException
{
}
/**
* Directly call the
* comment method on the passed LexicalHandler for the
* string-value.
*
* @param lh A non-null reference to a LexicalHandler.
*
* @throws org.xml.sax.SAXException
*/
public void dispatchAsComment(org.xml.sax.ext.LexicalHandler lh)
throws org.xml.sax.SAXException
{
}
/**
* Conditionally trim all leading and trailing whitespace in the specified String.
* All strings of white space are
* replaced by a single space character (#x20), except spaces after punctuation which
* receive double spaces if doublePunctuationSpaces is true.
* This function may be useful to a formatter, but to get first class
* results, the formatter should probably do it's own white space handling
* based on the semantics of the formatting object.
*
* @param trimHead Trim leading whitespace?
* @param trimTail Trim trailing whitespace?
* @param doublePunctuationSpaces Use double spaces for punctuation?
* @return The trimmed string.
*/
public XMLString fixWhiteSpace(boolean trimHead,
boolean trimTail,
boolean doublePunctuationSpaces)
{
return new XMLStringDefault(m_str.trim());
}
/**
* Returns the length of this string.
*
* @return the length of the sequence of characters represented by this
* object.
*/
public int length()
{
return m_str.length();
}
/**
* Returns the character at the specified index. An index ranges
* from <code>0</code> to <code>length() - 1</code>. The first character
* of the sequence is at index <code>0</code>, the next at index
* <code>1</code>, and so on, as for array indexing.
*
* @param index the index of the character.
* @return the character at the specified index of this string.
* The first character is at index <code>0</code>.
* @exception IndexOutOfBoundsException if the <code>index</code>
* argument is negative or not less than the length of this
* string.
*/
public char charAt(int index)
{
return m_str.charAt(index);
}
/**
* Copies characters from this string into the destination character
* array.
*
* @param srcBegin index of the first character in the string
* to copy.
* @param srcEnd index after the last character in the string
* to copy.
* @param dst the destination array.
* @param dstBegin the start offset in the destination array.
* @exception IndexOutOfBoundsException If any of the following
* is true:
* <ul><li><code>srcBegin</code> is negative.
* <li><code>srcBegin</code> is greater than <code>srcEnd</code>
* <li><code>srcEnd</code> is greater than the length of this
* string
* <li><code>dstBegin</code> is negative
* <li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than
* <code>dst.length</code></ul>
* @exception NullPointerException if <code>dst</code> is <code>null</code>
*/
public void getChars(int srcBegin, int srcEnd, char dst[],
int dstBegin)
{
int destIndex = dstBegin;
for (int i = srcBegin; i < srcEnd; i++)
{
dst[destIndex++] = m_str.charAt(i);
}
}
/**
* Compares this string to the specified <code>String</code>.
* The result is <code>true</code> if and only if the argument is not
* <code>null</code> and is a <code>String</code> object that represents
* the same sequence of characters as this object.
*
* @param obj2 the object to compare this <code>String</code> against.
* @return <code>true</code> if the <code>String</code>s are equal;
* <code>false</code> otherwise.
* @see java.lang.String#compareTo(java.lang.String)
* @see java.lang.String#equalsIgnoreCase(java.lang.String)
*/
public boolean equals(String obj2) {
return m_str.equals(obj2);
}
/**
* Compares this string to the specified object.
* The result is <code>true</code> if and only if the argument is not
* <code>null</code> and is a <code>String</code> object that represents
* the same sequence of characters as this object.
*
* @param anObject the object to compare this <code>String</code>
* against.
* @return <code>true</code> if the <code>String </code>are equal;
* <code>false</code> otherwise.
* @see java.lang.String#compareTo(java.lang.String)
* @see java.lang.String#equalsIgnoreCase(java.lang.String)
*/
public boolean equals(XMLString anObject)
{
return m_str.equals(anObject.toString());
}
/**
* Compares this string to the specified object.
* The result is <code>true</code> if and only if the argument is not
* <code>null</code> and is a <code>String</code> object that represents
* the same sequence of characters as this object.
*
* @param anObject the object to compare this <code>String</code>
* against.
* @return <code>true</code> if the <code>String </code>are equal;
* <code>false</code> otherwise.
* @see java.lang.String#compareTo(java.lang.String)
* @see java.lang.String#equalsIgnoreCase(java.lang.String)
*/
public boolean equals(Object anObject)
{
return m_str.equals(anObject);
}
/**
* Compares this <code>String</code> to another <code>String</code>,
* ignoring case considerations. Two strings are considered equal
* ignoring case if they are of the same length, and corresponding
* characters in the two strings are equal ignoring case.
*
* @param anotherString the <code>String</code> to compare this
* <code>String</code> against.
* @return <code>true</code> if the argument is not <code>null</code>
* and the <code>String</code>s are equal,
* ignoring case; <code>false</code> otherwise.
* @see #equals(Object)
* @see java.lang.Character#toLowerCase(char)
* @see java.lang.Character#toUpperCase(char)
*/
public boolean equalsIgnoreCase(String anotherString)
{
return m_str.equalsIgnoreCase(anotherString);
}
/**
* Compares two strings lexicographically.
*
* @param anotherString the <code>String</code> to be compared.
* @return the value <code>0</code> if the argument string is equal to
* this string; a value less than <code>0</code> if this string
* is lexicographically less than the string argument; and a
* value greater than <code>0</code> if this string is
* lexicographically greater than the string argument.
* @exception java.lang.NullPointerException if <code>anotherString</code>
* is <code>null</code>.
*/
public int compareTo(XMLString anotherString)
{
return m_str.compareTo(anotherString.toString());
}
/**
* Compares two strings lexicographically, ignoring case considerations.
* This method returns an integer whose sign is that of
* <code>this.toUpperCase().toLowerCase().compareTo(
* str.toUpperCase().toLowerCase())</code>.
* <p>
* Note that this method does <em>not</em> take locale into account,
* and will result in an unsatisfactory ordering for certain locales.
* The java.text package provides <em>collators</em> to allow
* locale-sensitive ordering.
*
* @param str the <code>String</code> to be compared.
* @return a negative integer, zero, or a positive integer as the
* the specified String is greater than, equal to, or less
* than this String, ignoring case considerations.
* @see java.text.Collator#compare(String, String)
* @since 1.2
*/
public int compareToIgnoreCase(XMLString str)
{
return m_str.compareToIgnoreCase(str.toString());
}
/**
* Tests if this string starts with the specified prefix beginning
* a specified index.
*
* @param prefix the prefix.
* @param toffset where to begin looking in the string.
* @return <code>true</code> if the character sequence represented by the
* argument is a prefix of the substring of this object starting
* at index <code>toffset</code>; <code>false</code> otherwise.
* The result is <code>false</code> if <code>toffset</code> is
* negative or greater than the length of this
* <code>String</code> object; otherwise the result is the same
* as the result of the expression
* <pre>
* this.subString(toffset).startsWith(prefix)
* </pre>
* @exception java.lang.NullPointerException if <code>prefix</code> is
* <code>null</code>.
*/
public boolean startsWith(String prefix, int toffset)
{
return m_str.startsWith(prefix, toffset);
}
/**
* Tests if this string starts with the specified prefix beginning
* a specified index.
*
* @param prefix the prefix.
* @param toffset where to begin looking in the string.
* @return <code>true</code> if the character sequence represented by the
* argument is a prefix of the substring of this object starting
* at index <code>toffset</code>; <code>false</code> otherwise.
* The result is <code>false</code> if <code>toffset</code> is
* negative or greater than the length of this
* <code>String</code> object; otherwise the result is the same
* as the result of the expression
* <pre>
* this.subString(toffset).startsWith(prefix)
* </pre>
* @exception java.lang.NullPointerException if <code>prefix</code> is
* <code>null</code>.
*/
public boolean startsWith(XMLString prefix, int toffset)
{
return m_str.startsWith(prefix.toString(), toffset);
}
/**
* Tests if this string starts with the specified prefix.
*
* @param prefix the prefix.
* @return <code>true</code> if the character sequence represented by the
* argument is a prefix of the character sequence represented by
* this string; <code>false</code> otherwise.
* Note also that <code>true</code> will be returned if the
* argument is an empty string or is equal to this
* <code>String</code> object as determined by the
* {@link #equals(Object)} method.
* @exception java.lang.NullPointerException if <code>prefix</code> is
* <code>null</code>.
* @since JDK1. 0
*/
public boolean startsWith(String prefix)
{
return m_str.startsWith(prefix);
}
/**
* Tests if this string starts with the specified prefix.
*
* @param prefix the prefix.
* @return <code>true</code> if the character sequence represented by the
* argument is a prefix of the character sequence represented by
* this string; <code>false</code> otherwise.
* Note also that <code>true</code> will be returned if the
* argument is an empty string or is equal to this
* <code>String</code> object as determined by the
* {@link #equals(Object)} method.
* @exception java.lang.NullPointerException if <code>prefix</code> is
* <code>null</code>.
* @since JDK1. 0
*/
public boolean startsWith(XMLString prefix)
{
return m_str.startsWith(prefix.toString());
}
/**
* Tests if this string ends with the specified suffix.
*
* @param suffix the suffix.
* @return <code>true</code> if the character sequence represented by the
* argument is a suffix of the character sequence represented by
* this object; <code>false</code> otherwise. Note that the
* result will be <code>true</code> if the argument is the
* empty string or is equal to this <code>String</code> object
* as determined by the {@link #equals(Object)} method.
* @exception java.lang.NullPointerException if <code>suffix</code> is
* <code>null</code>.
*/
public boolean endsWith(String suffix)
{
return m_str.endsWith(suffix);
}
/**
* Returns a hashcode for this string. The hashcode for a
* <code>String</code> object is computed as
* <blockquote><pre>
* s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
* </pre></blockquote>
* using <code>int</code> arithmetic, where <code>s[i]</code> is the
* <i>i</i>th character of the string, <code>n</code> is the length of
* the string, and <code>^</code> indicates exponentiation.
* (The hash value of the empty string is zero.)
*
* @return a hash code value for this object.
*/
public int hashCode()
{
return m_str.hashCode();
}
/**
* Returns the index within this string of the first occurrence of the
* specified character. If a character with value <code>ch</code> occurs
* in the character sequence represented by this <code>String</code>
* object, then the index of the first such occurrence is returned --
* that is, the smallest value <i>k</i> such that:
* <blockquote><pre>
* this.charAt(<i>k</i>) == ch
* </pre></blockquote>
* is <code>true</code>. If no such character occurs in this string,
* then <code>-1</code> is returned.
*
* @param ch a character.
* @return the index of the first occurrence of the character in the
* character sequence represented by this object, or
* <code>-1</code> if the character does not occur.
*/
public int indexOf(int ch)
{
return m_str.indexOf(ch);
}
/**
* Returns the index within this string of the first occurrence of the
* specified character, starting the search at the specified index.
* <p>
* If a character with value <code>ch</code> occurs in the character
* sequence represented by this <code>String</code> object at an index
* no smaller than <code>fromIndex</code>, then the index of the first
* such occurrence is returned--that is, the smallest value <i>k</i>
* such that:
* <blockquote><pre>
* (this.charAt(<i>k</i>) == ch) && (<i>k</i> >= fromIndex)
* </pre></blockquote>
* is true. If no such character occurs in this string at or after
* position <code>fromIndex</code>, then <code>-1</code> is returned.
* <p>
* There is no restriction on the value of <code>fromIndex</code>. If it
* is negative, it has the same effect as if it were zero: this entire
* string may be searched. If it is greater than the length of this
* string, it has the same effect as if it were equal to the length of
* this string: <code>-1</code> is returned.
*
* @param ch a character.
* @param fromIndex the index to start the search from.
* @return the index of the first occurrence of the character in the
* character sequence represented by this object that is greater
* than or equal to <code>fromIndex</code>, or <code>-1</code>
* if the character does not occur.
*/
public int indexOf(int ch, int fromIndex)
{
return m_str.indexOf(ch, fromIndex);
}
/**
* Returns the index within this string of the last occurrence of the
* specified character. That is, the index returned is the largest
* value <i>k</i> such that:
* <blockquote><pre>
* this.charAt(<i>k</i>) == ch
* </pre></blockquote>
* is true.
* The String is searched backwards starting at the last character.
*
* @param ch a character.
* @return the index of the last occurrence of the character in the
* character sequence represented by this object, or
* <code>-1</code> if the character does not occur.
*/
public int lastIndexOf(int ch)
{
return m_str.lastIndexOf(ch);
}
/**
* Returns the index within this string of the last occurrence of the
* specified character, searching backward starting at the specified
* index. That is, the index returned is the largest value <i>k</i>
* such that:
* <blockquote><pre>
* this.charAt(k) == ch) && (k <= fromIndex)
* </pre></blockquote>
* is true.
*
* @param ch a character.
* @param fromIndex the index to start the search from. There is no
* restriction on the value of <code>fromIndex</code>. If it is
* greater than or equal to the length of this string, it has
* the same effect as if it were equal to one less than the
* length of this string: this entire string may be searched.
* If it is negative, it has the same effect as if it were -1:
* -1 is returned.
* @return the index of the last occurrence of the character in the
* character sequence represented by this object that is less
* than or equal to <code>fromIndex</code>, or <code>-1</code>
* if the character does not occur before that point.
*/
public int lastIndexOf(int ch, int fromIndex)
{
return m_str.lastIndexOf(ch, fromIndex);
}
/**
* Returns the index within this string of the first occurrence of the
* specified substring. The integer returned is the smallest value
* <i>k</i> such that:
* <blockquote><pre>
* this.startsWith(str, <i>k</i>)
* </pre></blockquote>
* is <code>true</code>.
*
* @param str any string.
* @return if the string argument occurs as a substring within this
* object, then the index of the first character of the first
* such substring is returned; if it does not occur as a
* substring, <code>-1</code> is returned.
* @exception java.lang.NullPointerException if <code>str</code> is
* <code>null</code>.
*/
public int indexOf(String str)
{
return m_str.indexOf(str);
}
/**
* Returns the index within this string of the first occurrence of the
* specified substring. The integer returned is the smallest value
* <i>k</i> such that:
* <blockquote><pre>
* this.startsWith(str, <i>k</i>)
* </pre></blockquote>
* is <code>true</code>.
*
* @param str any string.
* @return if the string argument occurs as a substring within this
* object, then the index of the first character of the first
* such substring is returned; if it does not occur as a
* substring, <code>-1</code> is returned.
* @exception java.lang.NullPointerException if <code>str</code> is
* <code>null</code>.
*/
public int indexOf(XMLString str)
{
return m_str.indexOf(str.toString());
}
/**
* Returns the index within this string of the first occurrence of the
* specified substring, starting at the specified index. The integer
* returned is the smallest value <i>k</i> such that:
* <blockquote><pre>
* this.startsWith(str, <i>k</i>) && (<i>k</i> >= fromIndex)
* </pre></blockquote>
* is <code>true</code>.
* <p>
* There is no restriction on the value of <code>fromIndex</code>. If
* it is negative, it has the same effect as if it were zero: this entire
* string may be searched. If it is greater than the length of this
* string, it has the same effect as if it were equal to the length of
* this string: <code>-1</code> is returned.
*
* @param str the substring to search for.
* @param fromIndex the index to start the search from.
* @return If the string argument occurs as a substring within this
* object at a starting index no smaller than
* <code>fromIndex</code>, then the index of the first character
* of the first such substring is returned. If it does not occur
* as a substring starting at <code>fromIndex</code> or beyond,
* <code>-1</code> is returned.
* @exception java.lang.NullPointerException if <code>str</code> is
* <code>null</code>
*/
public int indexOf(String str, int fromIndex)
{
return m_str.indexOf(str, fromIndex);
}
/**
* Returns the index within this string of the rightmost occurrence
* of the specified substring. The rightmost empty string "" is
* considered to occur at the index value <code>this.length()</code>.
* The returned index is the largest value <i>k</i> such that
* <blockquote><pre>
* this.startsWith(str, k)
* </pre></blockquote>
* is true.
*
* @param str the substring to search for.
* @return if the string argument occurs one or more times as a substring
* within this object, then the index of the first character of
* the last such substring is returned. If it does not occur as
* a substring, <code>-1</code> is returned.
* @exception java.lang.NullPointerException if <code>str</code> is
* <code>null</code>.
*/
public int lastIndexOf(String str)
{
return m_str.lastIndexOf(str);
}
/**
* Returns the index within this string of the last occurrence of
* the specified substring.
*
* @param str the substring to search for.
* @param fromIndex the index to start the search from. There is no
* restriction on the value of fromIndex. If it is greater than
* the length of this string, it has the same effect as if it
* were equal to the length of this string: this entire string
* may be searched. If it is negative, it has the same effect
* as if it were -1: -1 is returned.
* @return If the string argument occurs one or more times as a substring
* within this object at a starting index no greater than
* <code>fromIndex</code>, then the index of the first character of
* the last such substring is returned. If it does not occur as a
* substring starting at <code>fromIndex</code> or earlier,
* <code>-1</code> is returned.
* @exception java.lang.NullPointerException if <code>str</code> is
* <code>null</code>.
*/
public int lastIndexOf(String str, int fromIndex)
{
return m_str.lastIndexOf(str, fromIndex);
}
/**
* Returns a new string that is a substring of this string. The
* substring begins with the character at the specified index and
* extends to the end of this string. <p>
* Examples:
* <blockquote><pre>
* "unhappy".substring(2) returns "happy"
* "Harbison".substring(3) returns "bison"
* "emptiness".substring(9) returns "" (an empty string)
* </pre></blockquote>
*
* @param beginIndex the beginning index, inclusive.
* @return the specified substring.
* @exception IndexOutOfBoundsException if
* <code>beginIndex</code> is negative or larger than the
* length of this <code>String</code> object.
*/
public XMLString substring(int beginIndex)
{
return new XMLStringDefault(m_str.substring(beginIndex));
}
/**
* Returns a new string that is a substring of this string. The
* substring begins at the specified <code>beginIndex</code> and
* extends to the character at index <code>endIndex - 1</code>.
* Thus the length of the substring is <code>endIndex-beginIndex</code>.
*
* @param beginIndex the beginning index, inclusive.
* @param endIndex the ending index, exclusive.
* @return the specified substring.
* @exception IndexOutOfBoundsException if the
* <code>beginIndex</code> is negative, or
* <code>endIndex</code> is larger than the length of
* this <code>String</code> object, or
* <code>beginIndex</code> is larger than
* <code>endIndex</code>.
*/
public XMLString substring(int beginIndex, int endIndex)
{
return new XMLStringDefault(m_str.substring(beginIndex, endIndex));
}
/**
* Concatenates the specified string to the end of this string.
*
* @param str the <code>String</code> that is concatenated to the end
* of this <code>String</code>.
* @return a string that represents the concatenation of this object's
* characters followed by the string argument's characters.
* @exception java.lang.NullPointerException if <code>str</code> is
* <code>null</code>.
*/
public XMLString concat(String str)
{
return new XMLStringDefault(m_str.concat(str));
}
/**
* Converts all of the characters in this <code>String</code> to lower
* case using the rules of the given <code>Locale</code>.
*
* @param locale use the case transformation rules for this locale
* @return the String, converted to lowercase.
* @see java.lang.Character#toLowerCase(char)
* @see java.lang.String#toUpperCase(Locale)
*/
public XMLString toLowerCase(Locale locale)
{
return new XMLStringDefault(m_str.toLowerCase(locale));
}
/**
* Converts all of the characters in this <code>String</code> to lower
* case using the rules of the default locale, which is returned
* by <code>Locale.getDefault</code>.
* <p>
*
* @return the string, converted to lowercase.
* @see java.lang.Character#toLowerCase(char)
* @see java.lang.String#toLowerCase(Locale)
*/
public XMLString toLowerCase()
{
return new XMLStringDefault(m_str.toLowerCase());
}
/**
* Converts all of the characters in this <code>String</code> to upper
* case using the rules of the given locale.
* @param locale use the case transformation rules for this locale
* @return the String, converted to uppercase.
* @see java.lang.Character#toUpperCase(char)
* @see java.lang.String#toLowerCase(Locale)
*/
public XMLString toUpperCase(Locale locale)
{
return new XMLStringDefault(m_str.toUpperCase(locale));
}
/**
* Converts all of the characters in this <code>String</code> to upper
* case using the rules of the default locale, which is returned
* by <code>Locale.getDefault</code>.
*
* <p>
* If no character in this string has a different uppercase version,
* based on calling the <code>toUpperCase</code> method defined by
* <code>Character</code>, then the original string is returned.
* <p>
* Otherwise, this method creates a new <code>String</code> object
* representing a character sequence identical in length to the
* character sequence represented by this <code>String</code> object and
* with every character equal to the result of applying the method
* <code>Character.toUpperCase</code> to the corresponding character of
* this <code>String</code> object. <p>
* Examples:
* <blockquote><pre>
* "Fahrvergnügen".toUpperCase() returns "FAHRVERGNÜGEN"
* "Visit Ljubinje!".toUpperCase() returns "VISIT LJUBINJE!"
* </pre></blockquote>
*
* @return the string, converted to uppercase.
* @see java.lang.Character#toUpperCase(char)
* @see java.lang.String#toUpperCase(Locale)
*/
public XMLString toUpperCase()
{
return new XMLStringDefault(m_str.toUpperCase());
}
/**
* Removes white space from both ends of this string.
* <p>
* If this <code>String</code> object represents an empty character
* sequence, or the first and last characters of character sequence
* represented by this <code>String</code> object both have codes
* greater than <code>'\u0020'</code> (the space character), then a
* reference to this <code>String</code> object is returned.
* <p>
* Otherwise, if there is no character with a code greater than
* <code>'\u0020'</code> in the string, then a new
* <code>String</code> object representing an empty string is created
* and returned.
* <p>
* Otherwise, let <i>k</i> be the index of the first character in the
* string whose code is greater than <code>'\u0020'</code>, and let
* <i>m</i> be the index of the last character in the string whose code
* is greater than <code>'\u0020'</code>. A new <code>String</code>
* object is created, representing the substring of this string that
* begins with the character at index <i>k</i> and ends with the
* character at index <i>m</i>-that is, the result of
* <code>this.substring(<i>k</i>, <i>m</i>+1)</code>.
* <p>
* This method may be used to trim
* {@link Character#isSpace(char) whitespace} from the beginning and end
* of a string; in fact, it trims all ASCII control characters as well.
*
* @return this string, with white space removed from the front and end.
*/
public XMLString trim()
{
return new XMLStringDefault(m_str.trim());
}
/**
* This object (which is already a string!) is itself returned.
*
* @return the string itself.
*/
public String toString()
{
return m_str;
}
/**
* Tell if this object contains a java String object.
*
* @return true if this XMLString can return a string without creating one.
*/
public boolean hasString()
{
return true;
}
/**
* Convert a string to a double -- Allowed input is in fixed
* notation ddd.fff.
*
* @return A double value representation of the string, or return Double.NaN
* if the string can not be converted.
*/
public double toDouble()
{
try {
return Double.valueOf(m_str).doubleValue();
}
catch (NumberFormatException nfe)
{
return Double.NaN;
}
}
}
| [
"sunxiongkun2018@163.com"
] | sunxiongkun2018@163.com |
cb928aff5d14b69ede121d2dba98d27ef9780397 | 43f42e2480e1a82d9a8ab6da91cdf482f798bb29 | /api/action/SystemApiAction.java | 40f46a038eca4295df91a20c143284cd275c8bd9 | [] | no_license | jreyson/shopping | 1cbf9c8d843c04c456d6e1b1a42d33ab93d34893 | 85e81a6fa72a16c453ca36bbb4c1f73a28296f38 | refs/heads/master | 2020-03-22T21:30:39.071407 | 2018-07-12T09:39:09 | 2018-07-12T09:39:09 | 140,692,217 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,033 | java | package com.shopping.api.action;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.shopping.api.domain.CenterListApi;
import com.shopping.api.tools.ApiUtils;
import com.shopping.core.mv.JModelAndView;
import com.shopping.core.tools.CommUtil;
import com.shopping.foundation.domain.User;
import com.shopping.foundation.service.IAccessoryService;
import com.shopping.foundation.service.ICommonService;
import com.shopping.foundation.service.ISysConfigService;
import com.shopping.foundation.service.IUserConfigService;
import com.shopping.foundation.service.IUserService;
@Controller
public class SystemApiAction {
@Autowired
private ISysConfigService configService;
@Autowired
IUserService userService;
@Autowired
ICommonService commonService;
@Autowired
private IAccessoryService accessoryService;
@Autowired
private IUserConfigService userConfigService;
@RequestMapping({ "/center_list.htm" })
public ModelAndView center_list(HttpServletRequest request,
HttpServletResponse response, String user_id) throws IOException {
ModelAndView mv = new JModelAndView("center_list.html",
this.configService.getSysConfig(),
this.userConfigService.getUserConfig(), 1, request, response);
User user = this.userService.getObjById(CommUtil.null2Long(user_id));
mv.addObject("user", user);
return mv;
}
@RequestMapping({ "/app_down.htm" })
public ModelAndView app_down(HttpServletRequest request,
HttpServletResponse response, String user_id) throws IOException {
ModelAndView mv = new JModelAndView("app_down.html",
this.configService.getSysConfig(),
this.userConfigService.getUserConfig(), 1, request, response);
return mv;
}
}
| [
"zhaozhenteng@live.com"
] | zhaozhenteng@live.com |
4525177d2cdac2e8031fbf2e9db41e8045e86a21 | 8d5546b55cb72c92b57215d2446394751ecd93e9 | /micro-ecommerce-master/assurance-bulletin/src/main/java/org/cat/europe/bulletin/Repository/ActeRepository.java | 874a7e0694d2f955b89687cb3634cb48d50fb3b8 | [
"Apache-2.0"
] | permissive | Khaled-V/Vermeg | 4eb808607d04dddf327b06d72381f83fe0c7e46e | 0f0260b5b461fca1a7ef043a6c2a25b304926ae0 | refs/heads/master | 2020-12-03T03:38:54.185160 | 2017-06-29T14:19:15 | 2017-06-29T14:19:15 | 95,756,214 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 752 | java | package org.cat.europe.bulletin.Repository;
import java.util.Collection;
import javax.transaction.Transactional;
import org.cat.europe.bulletin.domain.ActeMedicale;
import org.cat.europe.bulletin.domain.BulletinDeSoin;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
@Transactional
public interface ActeRepository extends CrudRepository<ActeMedicale, Long>{
/*
* @Query(value="select * from ArticleMedicale as a where a.acte_id= ?1",nativeQuery=true)
Collection<ArticleMedicale> findByActe(Long id);
*/
@Query(value="select * from BulletinDeSoin as b where b.bulletin_id=?1",nativeQuery=true)
Collection<BulletinDeSoin> findByBul(Long id);
}
| [
"Student@TUN401.vermeg.com"
] | Student@TUN401.vermeg.com |
ee084f2e9404a7b84ac5f7a973cbce5de75b4432 | 4f3c9cb6087abfbccf28e63f654f8158b989ae14 | /app/src/main/java/com/example/movie_db_example/Detailaview.java | f3b51ccd3faf552c2d16f891740f0f2673232693 | [] | no_license | srohit95/movie_db_example | 8fd03950cb2c59e6f1a9b41dd356c4cc1d73adc8 | 3948523f3769a809ff6b30f840121b64f96bdb07 | refs/heads/master | 2022-12-31T10:25:01.952850 | 2020-10-26T14:07:22 | 2020-10-26T14:07:22 | 303,635,065 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,776 | java | package com.example.movie_db_example;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class Detailaview extends AppCompatActivity {
TextView title,popular, adult,totalvote, voteavg,releasedate, language,overview;
ImageView image;
Button save,delete;
database db;
String movieid="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detailaview);
overview=findViewById(R.id.overview);
title=findViewById(R.id.title);
popular=findViewById(R.id.popular);
adult=findViewById(R.id.adult);
totalvote=findViewById(R.id.totalvote );
voteavg=findViewById(R.id.voteavg);
releasedate=findViewById(R.id.releasedate);
language=findViewById(R.id.language);
image=findViewById(R.id.image);
save=findViewById(R.id.save);
delete=findViewById(R.id.delete);
db=new database(this);
setTitle("Movie Overview");
try {
final JSONObject jsonObject=new JSONObject(getIntent().getStringExtra("jdata"));
title.setText(jsonObject.getString("original_title"));
popular.setText(jsonObject.getString("popularity"));
releasedate.setText(jsonObject.getString("release_date"));
totalvote.setText(jsonObject.getString("vote_count"));
voteavg.setText(jsonObject.getString("vote_average"));
language.setText(jsonObject.getString("original_language"));
overview.setText(jsonObject.getString("overview"));
movieid=jsonObject.getString("id");
if(jsonObject.getBoolean("adult")){
adult.setText("A");
}else{
adult.setText("U");
}
Glide.with(Detailaview.this)
.load("https://image.tmdb.org/t/p/w500"+jsonObject.getString("backdrop_path"))
.into(image);
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (db.tbl_insert(jsonObject.toString(),movieid)) {
Toast.makeText(Detailaview.this, "Saved", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(Detailaview.this, "Not Saved", Toast.LENGTH_SHORT).show();
}
}
});
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (db.tbl_delete(movieid.trim())) {
Toast.makeText(Detailaview.this, "Deleted", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(Detailaview.this, "Not Deleted", Toast.LENGTH_SHORT).show();
}
}
});
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home){
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
} | [
"srohit8695@gmail.com"
] | srohit8695@gmail.com |
1d2f7eb7d1d97d82534bf74d0e425472057a8162 | ee1e9d20baaf467f5d2e39f43d21a4c4e062417c | /app/src/main/java/fm/player/mediaplayer/player/Mpg123Decoder.java | f8d1c091adc64eb8a7723dc438bd333ce115a82e | [] | no_license | MobS930/Media | ea6fca10e84fedf2e8f21e1bd02f286d4f6833b9 | 217aba490faef2f712c051b57a11b35768773fee | refs/heads/master | 2020-07-01T06:24:01.415421 | 2019-08-07T05:09:05 | 2019-08-07T05:09:05 | 201,073,900 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,206 | java | package fm.player.mediaplayer.player;
import java.nio.ByteBuffer;
public class Mpg123Decoder {
private static final String TAG = "Mpg123Decoder";
public ByteBuffer buffer; //will be used in each native function to differentiate between instances
private native ByteBuffer init(boolean disableFilters); //must be called before using each instance of this class
public native long openFile(ByteBuffer handle, int format);
public native void navFeedSamples(byte[] rawsamples, int rawbytesRead, ByteBuffer handle);
public native int navOutputSamples(byte[] samples, ByteBuffer handle);
public native int getNumChannels(ByteBuffer handle);
public native int getRate(ByteBuffer handle);
public native int getEncoding(ByteBuffer handle);
public native void closeFile(ByteBuffer handle);
public native void flush(ByteBuffer handle);
public native void setFileEnd(ByteBuffer handle);
public Mpg123Decoder(int format, boolean disableFilters) {
buffer = init(disableFilters);
openFile(buffer, format);
}
public Mpg123Decoder(int format) {
buffer = init(false);
openFile(buffer, format);
}
}
| [
"software.pro.830@gmail.com"
] | software.pro.830@gmail.com |
7755fe90f4a207605b4320ae02c09bc84f72f584 | 4fe3466c2f27863bfb0d5109f27f1c63a403ecef | /Task_4_2/src/main/java/GsonWorker.java | 1118a8bc9ca581ce3164ac2edeec5f012125de7e | [] | no_license | hardworkar/19214morozovOOP | fd1f11af9cbfe7952312095e3cb3e65c8a759bf5 | ae1d681639e30e40ba358026c05b5cb5b5ad90d7 | refs/heads/master | 2023-04-26T08:35:39.846847 | 2021-05-20T06:28:27 | 2021-05-20T06:28:27 | 294,608,239 | 0 | 0 | null | 2021-05-20T06:28:28 | 2020-09-11T06:03:00 | Java | UTF-8 | Java | false | false | 2,969 | java | import com.google.gson.*;
import org.jetbrains.annotations.NotNull;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Type;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class GsonWorker {
/* достает из существующего? json-а */
protected MyNotebook deserialize(@NotNull Path file) throws IOException {
String fileContent = new String(Files.readAllBytes(file));
Gson gson = new GsonBuilder()
.registerTypeAdapter(MyNotebook.class, new MyNotebookDeserializer())
.setPrettyPrinting()
.create();
return gson.fromJson(fileContent, MyNotebook.class);
}
/* складывает в json */
protected void serialize(@NotNull MyNotebook notebook, @NotNull String file){
try (Writer writer = new FileWriter(file)) {
Gson gson = new GsonBuilder()
.registerTypeAdapter(MyNotebook.class, new MyNotebookDeserializer()).setPrettyPrinting()
.create();
gson.toJson(notebook, writer);
} catch (IOException e) {
e.printStackTrace();
}
}
}
class MyNotebookDeserializer implements JsonDeserializer<MyNotebook>{
/* очень вкусно, очень классно, никому не советую
* так как у меня блокнот использует абстрактные классы, стандартный deserializer из gson-а поднимает лапки и говорит, что не может в такое (ну и в интерфейсы тоже)
* https://github.com/google/gson/issues/411 :)))
* поэтому приходится изворачиваться и делать свой кастомный :/ */
@Override
public MyNotebook deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = json.getAsJsonObject();
MyNotebook result = new MyNotebook();
result.setName(jsonObject.get("name").getAsString());
var records = jsonObject.get("records").getAsJsonArray();
for(var record : records){
String title = record.getAsJsonObject().get("title").getAsString();
String text = record.getAsJsonObject().get("text").getAsString();
SimpleDateFormat formatter = new SimpleDateFormat("MMM dd, yyyy, HH:mm:ss aa", Locale.US);
try {
Date createdDate = formatter.parse(record.getAsJsonObject().get("createdAt").getAsString());
result.records.add(new NotebookRecord(title, text, createdDate));
} catch (ParseException e) {
e.printStackTrace();
}
}
return result;
}
}
| [
"arsmoroz@ya.ru"
] | arsmoroz@ya.ru |
daf8f92d2bc42efda7a515cdd83a6b8a86c86ea0 | 999e9b143b37be4292de1ee9930f6e29fee2a294 | /app/src/test/java/com/geostar/demo/ExampleUnitTest.java | 19932ccc227dc009383a30f2cce15ba4e46974dd | [
"Apache-2.0"
] | permissive | linjian99666/CountDownList | b0388e5b409e3ceb87eec7701b0dcf4704a97261 | d8b2aecba1e7d339a96def63f1a59cd40d8a8ead | refs/heads/master | 2020-08-23T23:08:38.668486 | 2019-10-22T06:33:46 | 2019-10-22T06:33:46 | 216,720,662 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 377 | java | package com.geostar.demo;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
} | [
"13827259612@163.com"
] | 13827259612@163.com |
d0d0f40471cf4d65a869e7aee179620529d7636f | 0af8b92686a58eb0b64e319b22411432aca7a8f3 | /single-large-project/src/main/java/org/gradle/test/performancenull_280/Productionnull_27939.java | 6a34a170a5f9eccef39acbf22e4722740207ed7d | [] | no_license | gradle/performance-comparisons | b0d38db37c326e0ce271abebdb3c91769b860799 | e53dc7182fafcf9fedf07920cbbea8b40ee4eef4 | refs/heads/master | 2023-08-14T19:24:39.164276 | 2022-11-24T05:18:33 | 2022-11-24T05:18:33 | 80,121,268 | 17 | 15 | null | 2022-09-30T08:04:35 | 2017-01-26T14:25:33 | null | UTF-8 | Java | false | false | 588 | java | package org.gradle.test.performancenull_280;
public class Productionnull_27939 {
private final String property;
public Productionnull_27939(String param) {
this.property = param;
}
public String getProperty() {
return property;
}
private String prop0;
public String getProp0() {
return prop0;
}
public void setProp0(String value) {
prop0 = value;
}
private String prop1;
public String getProp1() {
return prop1;
}
public void setProp1(String value) {
prop1 = value;
}
}
| [
"cedric.champeau@gmail.com"
] | cedric.champeau@gmail.com |
a06a441ca8b8d96f75cd7fabb35f2a0a0027659e | cfec1fd7f6d6ceebd37260f340f9c1facbeeb16f | /src/uk/co/senab/photoview/ImageDetailFragment.java | 2f5a3e6808a7ed875bb7103d889acda5e8aeb426 | [] | no_license | caocf/Tjxl | adc21e67c86c438d592af26a9e30d22c2e565485 | 371b51d7ffe3909d003353139863bbc4ff771803 | refs/heads/master | 2021-01-18T12:21:29.000804 | 2015-07-28T07:26:16 | 2015-07-28T07:26:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,147 | java | package uk.co.senab.photoview;
import uk.co.senab.photoview.PhotoViewAttacher;
import uk.co.senab.photoview.PhotoViewAttacher.OnPhotoTapListener;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.eims.tjxl_andorid.R;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.assist.SimpleImageLoadingListener;
/**
* 单张图片显示Fragment
*/
public class ImageDetailFragment extends Fragment {
private String mImageUrl;
private ImageView mImageView;
private ProgressBar progressBar;
private PhotoViewAttacher mAttacher;
public static ImageDetailFragment newInstance(String imageUrl) {
final ImageDetailFragment f = new ImageDetailFragment();
final Bundle args = new Bundle();
args.putString("url", imageUrl);
f.setArguments(args);
return f;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mImageUrl = getArguments() != null ? getArguments().getString("url")
: null;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.image_detail_fragment,
container, false);
mImageView = (ImageView) v.findViewById(R.id.image);
mAttacher = new PhotoViewAttacher(mImageView);
mAttacher.setOnPhotoTapListener(new OnPhotoTapListener() {
@Override
public void onPhotoTap(View arg0, float arg1, float arg2) {
getActivity().finish();
}
});
progressBar = (ProgressBar) v.findViewById(R.id.loading);
return v;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ImageLoader.getInstance().displayImage(mImageUrl, mImageView,
new SimpleImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
progressBar.setVisibility(View.VISIBLE);
}
@Override
public void onLoadingFailed(String imageUri, View view,
FailReason failReason) {
String message = null;
switch (failReason.getType()) {
case IO_ERROR:
message = "下载错误";
break;
case DECODING_ERROR:
message = "图片无法显示";
break;
case NETWORK_DENIED:
message = "网络有问题,无法下载";
break;
case OUT_OF_MEMORY:
message = "图片太大无法显示";
break;
case UNKNOWN:
message = "未知的错误";
break;
}
Toast.makeText(getActivity(), message,
Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.GONE);
}
@Override
public void onLoadingComplete(String imageUri, View view,
Bitmap loadedImage) {
progressBar.setVisibility(View.GONE);
mAttacher.update();
}
});
}
}
| [
"293575570@qq.com"
] | 293575570@qq.com |
8071d3fcec37f06914b04ba54b4832021a26e406 | 90e632e182676d52742aacb4cda3eaec57b26ad1 | /src/com/bestfunforever/activity/facebook/ILikeFacebook.java | 5c98749fcd82f8319df5b6dd84993a86bea2d2ea | [] | no_license | tgioihan/CustomView | d6790755ac8462bf9c977f61bcf5f176efe152a0 | 5329d9da7984fa579243bced16481955b48af842 | refs/heads/master | 2020-12-24T16:59:10.075958 | 2014-07-22T03:42:49 | 2014-07-22T03:42:49 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 219 | java | package com.bestfunforever.activity.facebook;
import com.facebook.Session;
import com.facebook.SessionState;
public interface ILikeFacebook {
public void onLikeFacebookSuccess();
public void onLikeFacebookFail();
}
| [
"tgioihan@gmail.com"
] | tgioihan@gmail.com |
43002765c7da449a1a43c92c95914045881437fa | 4635a589961045fb5dc6b036eaf7bdce12a5cde5 | /IngReqSocialMediaMed/src/controlador/CtrListaPropuestaPDI.java | 333b77e372e65b5076fb7fcdc61f844bb2bc9539 | [] | no_license | juliarobles/coderz-socialmediamed | 32ccaf4f12fbce600ccd9a0b43c85520875b883a | bd618beb9f140cfc78f4b6b510fce7c7346e3d09 | refs/heads/master | 2020-09-13T13:21:18.246599 | 2020-01-24T00:47:09 | 2020-01-24T00:47:09 | 222,795,099 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 2,558 | java | package controlador;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import modelo.Propuesta;
import modelo.Tupla;
import vista.GestionPropuestas;
import vista.GestionPropuestasPDI;
public class CtrListaPropuestaPDI implements ListSelectionListener {
private JPanel panel;
private JList<Tupla> lista;
private JLabel titulo;
private JLabel descripcion;
private JLabel fechaini;
private JLabel fechafin;
private JLabel ong;
private GestionPropuestasPDI vista;
public CtrListaPropuestaPDI(JPanel panel, JList<Tupla> lista, JLabel titulo, JLabel descripcion, JLabel fechaini,
JLabel fechafin, JLabel ong, GestionPropuestasPDI vista) {
this.panel = panel;
this.lista = lista;
this.titulo = titulo;
this.descripcion = descripcion;
this.fechaini = fechaini;
this.fechafin = fechafin;
this.ong = ong;
this.vista = vista;
}
//Importante para controlar el tamaño de los campos que escribimos
@Override
public void valueChanged(ListSelectionEvent e) {
if(!lista.isSelectionEmpty()) {
Propuesta p = new Propuesta(Integer.parseInt(lista.getSelectedValue().elemento1));
titulo.setText("<html>" + p.getTitulo() + "<html>");
descripcion.setText("<html>" + p.getDescripcion()+ "<html>");
fechaini.setText(p.getFechainicial());
fechafin.setText(p.getFechafinal());
ong.setText(p.getOng().getNombre());
vista.ambito.setText(p.getAmbito().toString());
vista.zonaaccion.setText(p.getZonaaccion().toString());
vista.tipooferta.setText(p.getTipooferta().toString());
String proy = (p.getProyecto() == null) ? "No incluido en ningún proyecto" : p.getProyecto().getNombre();
vista.proyecto.setText(proy);
vista.setPropuesta(p);
if(p.getAsignatura() == null) {
vista.tipo.setText("Investigación");
} else {
vista.tipo.setText("Aprendizaje - " + p.getAsignatura().getNombre());
}
for(Component c : panel.getComponents()) {
c.setVisible(true);
}
} else {
titulo.setText("");
descripcion.setText("");
fechaini.setText("");
fechafin.setText("");
ong.setText("");
vista.setPropuesta(null);
vista.ambito.setText("");
vista.zonaaccion.setText("");
vista.tipooferta.setText("");
vista.proyecto.setText("");
vista.tipo.setText("");
for(Component c : panel.getComponents()) {
c.setVisible(false);
}
}
}
}
| [
"juliarobles@uma.es"
] | juliarobles@uma.es |
0e610df6b6877435c219027e341c3e48c567a565 | 696ce7d6d916dd36912d5660e4921af7d793d80c | /Succorfish/CombatDiver/app/src/main/java/com/succorfish/combatdiver/helper/Constant.java | 8401e2100b7d07e67c7dcbb616f2c79d9f5791cc | [] | no_license | VinayTShetty/GeoFence_Project_End | c669ff89cc355e1772353317c8d6e7bac9ac3361 | 7e178f207c9183bcd42ec24e339bf414a6df9e71 | refs/heads/main | 2023-06-04T13:54:32.836943 | 2021-06-26T02:27:59 | 2021-06-26T02:27:59 | 380,394,802 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 245 | java | package com.succorfish.combatdiver.helper;
/**
* Created by Jaydeep on 19-01-2018.
*/
public class Constant {
public static String DIRECTORY_FOLDER_NAME = "/CombatDiver";
public static String DIRECTORY_APP_DOCUMENT = "/Document";
}
| [
"vinay@succorfish.com"
] | vinay@succorfish.com |
aaf6260d66288f19f00cfd8583cbe9ca0954cc3b | 2d8daca2f394423e00b772fe3563d5d47b365826 | /learn-modules/learn-tmc/learn-sync/learn-sync-service/src/main/java/me/own/learn/sync/bo/RequestBo.java | 211c48b8987fe54f89ce55b6dce7067e1f9da7de | [] | no_license | xudongye/learn | 07601d1f57cf52ff63a70d83f30670e38fc9cb77 | dd88d68cf45014f68210c24982b994d21dd850cc | refs/heads/master | 2022-07-12T23:47:06.073893 | 2020-04-17T09:23:38 | 2020-04-17T09:23:45 | 181,639,796 | 0 | 0 | null | 2022-06-25T07:28:37 | 2019-04-16T07:41:27 | Java | UTF-8 | Java | false | false | 1,784 | java | package me.own.learn.sync.bo;
/**
* @author yexudong
* @date 2019/4/17 16:03
*/
public class RequestBo {
private Object businessRequest;
private String partnerCode;
private String version;
private String requestType;
private String signature;
private Long timestamp;
public Object getBusinessRequest() {
return businessRequest;
}
public void setBusinessRequest(Object businessRequest) {
this.businessRequest = businessRequest;
}
public String getPartnerCode() {
return partnerCode;
}
public void setPartnerCode(String partnerCode) {
this.partnerCode = partnerCode;
}
public String getRequestType() {
return requestType;
}
public void setRequestType(String requestType) {
this.requestType = requestType;
}
public String getSignature() {
return signature;
}
public void setSignature(String signature) {
this.signature = signature;
}
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
@Override
public String toString() {
return '{' +
"\"businessRequest\":{" + businessRequest + '}' +
"\"header\":{" +
"\"partnerCode\":\"" + partnerCode + "\"" +
",\"version\":\"" + version + "\"" +
",\"requestType\":\"" + requestType + "\"" +
",\"signature\":\"" + signature + "\"" +
",\"timestamp\":" + timestamp + '}'
+ '}';
}
}
| [
"simonye@aliyun.com"
] | simonye@aliyun.com |
34e4e042c91ece286fb1089c4aebd09096bf1222 | 18e6da955719cff29d33ac4c0c5587d8f7b1188e | /apg-core/src/main/java/it/giunti/apg/shared/model/LogDeletion.java | 1e2de13d8f2cebd826372111c54ab8a196555a99 | [] | no_license | pynolo/backup-apg-project | 5dde8def09a330298e981a0146b3f7e00295801f | 36c427a6ea2242db433129dd1a17a4e7ed09438b | refs/heads/master | 2023-01-23T19:56:18.519181 | 2020-12-02T11:05:17 | 2020-12-02T11:05:17 | 317,835,636 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,882 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package it.giunti.apg.shared.model;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
*
* @author paolo
*/
@Entity
@Table(name = "log_deletion")
public class LogDeletion extends BaseEntity {
private static final long serialVersionUID = 5781543734777809510L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id", nullable = false)
private Integer id;
@Basic(optional = false)
@Column(name = "entity_name", nullable = false, length = 64)
private String entityName;
@Basic(optional = false)
@Column(name="entity_id", nullable = false)
private Integer entityId;
@Basic(optional = false)
@Column(name="entity_uid", nullable = false, length = 16)
private String entityUid;
@Basic(optional = false)
@Column(name = "log_datetime", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date logDatetime;
@Column(name = "id_utente", length = 32, nullable = false)
private String idUtente;
public LogDeletion() {
}
public LogDeletion(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getEntityName() {
return entityName;
}
public void setEntityName(String entityName) {
this.entityName = entityName;
}
public Integer getEntityId() {
return entityId;
}
public void setEntityId(Integer entityId) {
this.entityId = entityId;
}
public String getEntityUid() {
return entityUid;
}
public void setEntityUid(String entityUid) {
this.entityUid = entityUid;
}
public String getIdUtente() {
return idUtente;
}
public void setIdUtente(String idUtente) {
this.idUtente = idUtente;
}
public Date getLogDatetime() {
return logDatetime;
}
public void setLogDatetime(Date logDatetime) {
this.logDatetime = logDatetime;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
if (!(object instanceof LogDeletion)) {
return false;
}
LogDeletion other = (LogDeletion) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "LogWs[id=" + id + "]";
}
}
| [
"p.tacconi@giunti.it"
] | p.tacconi@giunti.it |
f99891f0d61ac2b67baa7ea85e9d53bf64e3c891 | 02e4f82f23954cac1b152065dfa91f4e689f3e4b | /core/src/main/java/io/onedev/server/rest/github/RepositoryResource.java | 73976df0fa5861b91b3d0894501e9073aa5af7ae | [
"MIT"
] | permissive | desktoptips/onedev | f51e3cfd8eca0c5ccbeb865f40d21d7a6c49dfb6 | 8dff13e1f20756f7d1a283923a38057490bd7ff0 | refs/heads/master | 2020-04-16T01:37:48.106728 | 2019-01-10T08:45:10 | 2019-01-10T08:45:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,910 | java | package io.onedev.server.rest.github;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.shiro.authz.UnauthorizedException;
import io.onedev.server.manager.ProjectManager;
import io.onedev.server.model.Project;
import io.onedev.server.rest.RestConstants;
import io.onedev.server.security.SecurityUtils;
@Path("/repos/projects")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.WILDCARD)
@Singleton
public class RepositoryResource {
private final ProjectManager projectManager;
@Inject
public RepositoryResource(ProjectManager projectManager) {
this.projectManager = projectManager;
}
@Path("/{name}")
@GET
public Response get(@PathParam("name") String name) {
Project project = projectManager.find(name);
if (!SecurityUtils.canReadCode(project.getFacade())) {
throw new UnauthorizedException("Unauthorized access to project " + project.getName());
} else {
Map<String, Object> entity = new HashMap<>();
Map<String, String> permissionsMap = new HashMap<>();
entity.put("name", project.getName());
permissionsMap.put("admin", String.valueOf(SecurityUtils.canAdministrate(project.getFacade())));
permissionsMap.put("push", String.valueOf(SecurityUtils.canWriteCode(project.getFacade())));
permissionsMap.put("pull", "true");
entity.put("permissions", permissionsMap);
Map<String, String> ownerMap = new HashMap<>();
ownerMap.put("login", "projects");
ownerMap.put("id", "1000000");
entity.put("owner", ownerMap);
return Response.ok(entity, RestConstants.JSON_UTF8).build();
}
}
}
| [
"robin@pmease.com"
] | robin@pmease.com |
21fef1613d855f7518119b9049cf3597bf1cafda | b01906a2f8f380fc4578f93a7847489ef980713b | /app/src/main/java/com/example/hp/project/Sports.java | a50534fbafa6ff748eb115d8c857248e696ff3c4 | [] | no_license | sagy2018/Scheme | 7819773aff80752bc2e2bc23d7587d14de3647cf | e159efff94330f1a60a5da3b0bafcfc2494b1194 | refs/heads/master | 2021-05-16T14:15:07.587462 | 2018-01-19T14:22:07 | 2018-01-19T14:22:07 | 118,134,371 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,390 | java | package com.example.hp.project;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class Sports extends AppCompatActivity {
TextView t1;
TextView t2;
TextView t3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sports);
t1=(TextView) findViewById(R.id.textView10);
t1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i1=new Intent(Sports.this,Khel.class);
startActivity(i1);
}
});
t2=(TextView)findViewById(R.id.textView16);
t2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i2=new Intent(Sports.this,Spoamdis.class);
startActivity(i2);
}
});
t3=(TextView)findViewById(R.id.textView24);
t3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i3=new Intent(Sports.this,Gandhi.class);
startActivity(i3);
}
});
}
}
| [
"adsagyapp@gmail.com"
] | adsagyapp@gmail.com |
c0cba52e2a664bc8baed2976f0d3932f750b7db8 | b61296555d47ab1c0b258d0c5326a38c8c18a4f2 | /src-gen/com/facebook/buck/distributed/thrift/StampedeId.java | f6f08d779fe88db8deadda591a3d554d94b75195 | [
"Apache-2.0"
] | permissive | lyft/buck | 0abe826d62ac1d046aba4518b9c6c2a69358462a | 5543d7236fb4ba932a692a67926c404f33676ac2 | refs/heads/master | 2023-08-20T12:09:30.454709 | 2019-08-15T15:28:18 | 2019-08-15T16:36:13 | 110,744,548 | 1 | 1 | Apache-2.0 | 2020-10-28T16:27:03 | 2017-11-14T21:04:49 | Java | UTF-8 | Java | false | true | 11,709 | java | /**
* Autogenerated by Thrift Compiler (0.12.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package com.facebook.buck.distributed.thrift;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)")
public class StampedeId implements org.apache.thrift.TBase<StampedeId, StampedeId._Fields>, java.io.Serializable, Cloneable, Comparable<StampedeId> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("StampedeId");
private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new StampedeIdStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new StampedeIdTupleSchemeFactory();
public @org.apache.thrift.annotation.Nullable java.lang.String id; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
ID((short)1, "id");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
static {
for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
@org.apache.thrift.annotation.Nullable
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // ID
return ID;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
@org.apache.thrift.annotation.Nullable
public static _Fields findByName(java.lang.String name) {
return byName.get(name);
}
private final short _thriftId;
private final java.lang.String _fieldName;
_Fields(short thriftId, java.lang.String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public java.lang.String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final _Fields optionals[] = {_Fields.ID};
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(StampedeId.class, metaDataMap);
}
public StampedeId() {
}
/**
* Performs a deep copy on <i>other</i>.
*/
public StampedeId(StampedeId other) {
if (other.isSetId()) {
this.id = other.id;
}
}
public StampedeId deepCopy() {
return new StampedeId(this);
}
@Override
public void clear() {
this.id = null;
}
@org.apache.thrift.annotation.Nullable
public java.lang.String getId() {
return this.id;
}
public StampedeId setId(@org.apache.thrift.annotation.Nullable java.lang.String id) {
this.id = id;
return this;
}
public void unsetId() {
this.id = null;
}
/** Returns true if field id is set (has been assigned a value) and false otherwise */
public boolean isSetId() {
return this.id != null;
}
public void setIdIsSet(boolean value) {
if (!value) {
this.id = null;
}
}
public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
switch (field) {
case ID:
if (value == null) {
unsetId();
} else {
setId((java.lang.String)value);
}
break;
}
}
@org.apache.thrift.annotation.Nullable
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case ID:
return getId();
}
throw new java.lang.IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new java.lang.IllegalArgumentException();
}
switch (field) {
case ID:
return isSetId();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that == null)
return false;
if (that instanceof StampedeId)
return this.equals((StampedeId)that);
return false;
}
public boolean equals(StampedeId that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_id = true && this.isSetId();
boolean that_present_id = true && that.isSetId();
if (this_present_id || that_present_id) {
if (!(this_present_id && that_present_id))
return false;
if (!this.id.equals(that.id))
return false;
}
return true;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = hashCode * 8191 + ((isSetId()) ? 131071 : 524287);
if (isSetId())
hashCode = hashCode * 8191 + id.hashCode();
return hashCode;
}
@Override
public int compareTo(StampedeId other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = java.lang.Boolean.valueOf(isSetId()).compareTo(other.isSetId());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetId()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
@org.apache.thrift.annotation.Nullable
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
scheme(iprot).read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
scheme(oprot).write(oprot, this);
}
@Override
public java.lang.String toString() {
java.lang.StringBuilder sb = new java.lang.StringBuilder("StampedeId(");
boolean first = true;
if (isSetId()) {
sb.append("id:");
if (this.id == null) {
sb.append("null");
} else {
sb.append(this.id);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class StampedeIdStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public StampedeIdStandardScheme getScheme() {
return new StampedeIdStandardScheme();
}
}
private static class StampedeIdStandardScheme extends org.apache.thrift.scheme.StandardScheme<StampedeId> {
public void read(org.apache.thrift.protocol.TProtocol iprot, StampedeId struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // ID
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.id = iprot.readString();
struct.setIdIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, StampedeId struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.id != null) {
if (struct.isSetId()) {
oprot.writeFieldBegin(ID_FIELD_DESC);
oprot.writeString(struct.id);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class StampedeIdTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public StampedeIdTupleScheme getScheme() {
return new StampedeIdTupleScheme();
}
}
private static class StampedeIdTupleScheme extends org.apache.thrift.scheme.TupleScheme<StampedeId> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, StampedeId struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetId()) {
optionals.set(0);
}
oprot.writeBitSet(optionals, 1);
if (struct.isSetId()) {
oprot.writeString(struct.id);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, StampedeId struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(1);
if (incoming.get(0)) {
struct.id = iprot.readString();
struct.setIdIsSet(true);
}
}
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
1184a8e523c1b0f6bd77ece3377e1336beb2de40 | 44bc6514eb20e966bcd8d8177e6981d2dc645d71 | /itrip-biz/src/main/java/cn/itrip/service/itripHotelOrder/ItripHotelOrderServiceImpl.java | ca3a8499298029dbd92c72dadea53f562f89eb08 | [] | no_license | j338group/itrip-project | 3b70c1a99f6b5b0a7db388dd1aa7f723a74ad439 | 7c7b66f9a23d7d16f54d9bc490953743f664194a | refs/heads/master | 2021-06-22T11:15:54.469248 | 2019-11-15T08:32:27 | 2019-11-15T08:32:27 | 214,998,252 | 1 | 0 | null | 2021-06-04T02:18:08 | 2019-10-14T09:10:54 | Java | UTF-8 | Java | false | false | 6,293 | java | package cn.itrip.service.itripHotelOrder;
import cn.itrip.beans.pojo.*;
import cn.itrip.common.BigDecimalUtil;
import cn.itrip.mapper.itripHotelOrder.ItripHotelOrderMapper;
import cn.itrip.common.EmptyUtils;
import cn.itrip.common.Page;
import cn.itrip.mapper.itripHotelRoom.ItripHotelRoomMapper;
import cn.itrip.mapper.itripHotelTempStore.ItripHotelTempStoreMapper;
import cn.itrip.mapper.itripOrderLinkUser.ItripOrderLinkUserMapper;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.itrip.common.Constants;
@Service
public class ItripHotelOrderServiceImpl implements ItripHotelOrderService {
@Resource
private ItripHotelOrderMapper itripHotelOrderMapper;
@Resource
private ItripOrderLinkUserMapper itripOrderLinkUserMapper;
@Resource
private ItripHotelRoomMapper itripHotelRoomMapper;
@Resource
private ItripHotelTempStoreMapper itripHotelTempStoreMapper;
public ItripHotelOrder getItripHotelOrderById(Long id)throws Exception{
return itripHotelOrderMapper.getItripHotelOrderById(id);
}
public List<ItripHotelOrder> getItripHotelOrderListByMap(Map<String,Object> param)throws Exception{
return itripHotelOrderMapper.getItripHotelOrderListByMap(param);
}
public Integer getItripHotelOrderCountByMap(Map<String,Object> param)throws Exception{
return itripHotelOrderMapper.getItripHotelOrderCountByMap(param);
}
public Integer itriptxAddItripHotelOrder(ItripHotelOrder itripHotelOrder)throws Exception{
itripHotelOrder.setCreationDate(new Date());
return itripHotelOrderMapper.insertItripHotelOrder(itripHotelOrder);
}
public Integer itriptxModifyItripHotelOrder(ItripHotelOrder itripHotelOrder)throws Exception{
itripHotelOrder.setModifyDate(new Date());
return itripHotelOrderMapper.updateItripHotelOrder(itripHotelOrder);
}
public Integer itriptxDeleteItripHotelOrderById(Long id)throws Exception{
return itripHotelOrderMapper.deleteItripHotelOrderById(id);
}
public Page<ItripHotelOrder> queryItripHotelOrderPageByMap(Map<String,Object> param,Integer pageNo,Integer pageSize)throws Exception{
Integer total = itripHotelOrderMapper.getItripHotelOrderCountByMap(param);
pageNo = EmptyUtils.isEmpty(pageNo) ? Constants.DEFAULT_PAGE_NO : pageNo;
pageSize = EmptyUtils.isEmpty(pageSize) ? Constants.DEFAULT_PAGE_SIZE : pageSize;
Page page = new Page(pageNo, pageSize, total);
param.put("beginPos", page.getBeginPos());
param.put("pageSize", page.getPageSize());
List<ItripHotelOrder> itripHotelOrderList = itripHotelOrderMapper.getItripHotelOrderListByMap(param);
page.setRows(itripHotelOrderList);
return page;
}
@Override
public BigDecimal getPayAmount(Integer count, int bookingDays, Double roomPrice) throws Exception {
return BigDecimalUtil.OperationASMD(count * bookingDays, roomPrice, BigDecimalUtil.BigDecimalOprations.multiply, 2, BigDecimal.ROUND_DOWN);
}
@Override
public Long itriptxAddItripHotelOrder(ItripHotelOrder order, List<ItripUserLinkUser> linkUser) throws Exception {
Long orderId = order.getId();
if (orderId == null) {
//插入订单记录
order.setCreationDate(new Date());
itripHotelOrderMapper.insertItripHotelOrder(order);
orderId=order.getId();
}else{
//删除联系人
itripOrderLinkUserMapper.deleteItripOrderLinkUserByOrderId(orderId);
//修改订单
itripHotelOrderMapper.updateItripHotelOrder(order);
}
//插入订单联系人
for (ItripUserLinkUser user : linkUser) {
ItripOrderLinkUser orderUser = new ItripOrderLinkUser();
orderUser.setOrderId(orderId);
orderUser.setLinkUserId(user.getId());
orderUser.setLinkUserName(user.getLinkUserName());
orderUser.setCreationDate(new Date());
orderUser.setCreatedBy(order.getUserId());
itripOrderLinkUserMapper.insertItripOrderLinkUser(orderUser);
}
return orderId;
}
/**
* 验证支付类型是否支持(线上、线下)
* @param hotelOrder
* @param payType
* @return
* @throws Exception
*/
@Override
public Boolean getSupportPayType(ItripHotelOrder hotelOrder, Integer payType) throws Exception {
ItripHotelRoom hotelRoom = itripHotelRoomMapper.getItripHotelRoomById(hotelOrder.getRoomId());
Integer oldPayType = hotelRoom.getPayType();
// 11 01 10
// 01,10 01 10
return (oldPayType&payType)!=0;
}
/**
* 修改订单状态并刷新库存
* @param hotelOrder
* @param payType
* @throws Exception
*/
@Override
public void itriptxModifyItripHotelOrderAndTempRoomStore(ItripHotelOrder hotelOrder, Integer payType) throws Exception {
//减库存
Map<String, Object> param = new HashMap<>();
param.put("count", hotelOrder.getCount());
param.put("roomId", hotelOrder.getRoomId());
param.put("checkInDate", hotelOrder.getCheckInDate());
param.put("checkOutDate", hotelOrder.getCheckOutDate());
itripHotelTempStoreMapper.updateTempStore(param);
//修改订单状态
hotelOrder.setPayType(payType);
hotelOrder.setOrderStatus(2);
itripHotelOrderMapper.updateItripHotelOrder(hotelOrder);
}
@Scheduled(cron = "0 0/10 * * * ?")
public void updateOrderStatusTimeOutPay(){
//扫描订单表,(未支付的)查看订单生成时间跟当前时间的差,是否大于2小时
//如果大于2小时,修改订单状态
//1分钟 效率低
//2小时 12:00 2:00 误差大
System.out.println("定时修改超时未支付的订单。。。");
try {
itripHotelOrderMapper.updateOrderStatus();
} catch (Exception e) {
e.printStackTrace();
}
}
}
| [
"test@test.com"
] | test@test.com |
6e10628a46562071dbbed1dc6ec8092c90716bd9 | 335fbd8ae7cfed5cd4991a94dd79def87fad9ae7 | /src/com/trendy/ow/portal/payment/business/PayReceiver.java | 703d38bc77f8674862442b1a3e25a5774c54df6a | [] | no_license | climbtop/EC_PAYMENT | 320c4c5ba66ac9e0a1137c2a112763b6c3559107 | ed0d449b554346d898edaa5b4ac9d7fe69ca10c9 | refs/heads/master | 2021-08-30T14:03:30.792180 | 2017-12-18T07:54:09 | 2017-12-18T07:54:09 | 114,611,666 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 546 | java | package com.trendy.ow.portal.payment.business;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.trendy.fw.tools.exception.PortalServletException;
public abstract class PayReceiver extends PayBaseProcessor {
public abstract void processNotify(HttpServletRequest request, HttpServletResponse response)
throws PortalServletException;
public abstract void processCallback(HttpServletRequest request, HttpServletResponse response)
throws PortalServletException;
}
| [
"XYSM@DESKTOP-U45JULJ"
] | XYSM@DESKTOP-U45JULJ |
b483b0ac09abcd31542b878dba959488c71081e0 | 05aa3d18688d3c7fb0991765acfc698ed97a2387 | /app/src/main/java/com/powerproject/login/RegisterActivity.java | fdc83ea6c46fe656c8d6952ee564a1277d6fafd8 | [] | no_license | hamidfadhilah/Power-Project-Beta | 965bc2dc386a6785f6d340b3509245be2de38803 | 6f88c97288e9fa04a2fa9f246b36bed5b7decdfb | refs/heads/master | 2020-04-02T17:16:08.936946 | 2018-10-25T10:17:46 | 2018-10-25T10:17:46 | 154,650,443 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,546 | java | package com.powerproject.login;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.Volley;
import org.json.JSONException;
import org.json.JSONObject;
import static android.R.attr.checked;
public class RegisterActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
final EditText etQuestion = (EditText) findViewById(R.id.etQuestion);
final EditText etAnswer = (EditText) findViewById(R.id.etAnswer);
final EditText etName = (EditText) findViewById(R.id.etName);
final EditText etUsername = (EditText) findViewById(R.id.etUsername);
final EditText etPassword = (EditText) findViewById(R.id.etPassword);
final EditText etPassword1 = (EditText) findViewById(R.id.etREPassword);
final Button bRegister = (Button) findViewById(R.id.bRegister);
final CheckBox bCek = (CheckBox) findViewById(R.id.bCek);
bCek.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(bCek.isChecked()) {
bRegister.setEnabled(true);
}else
bRegister.setEnabled(false);
}
});
bRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
final ProgressDialog progressDialog = new ProgressDialog(RegisterActivity.this);
progressDialog.setMessage("Registering");
progressDialog.show();
final String name = etName.getText().toString();
final String username = etUsername.getText().toString();
final String password = etPassword.getText().toString();
final String password1 = etPassword1.getText().toString();
final String question = etQuestion.getText().toString();
final String answer = etAnswer.getText().toString();
Response.Listener<String> responseListener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
if (name.isEmpty() || username.isEmpty() || password.isEmpty() || password1.isEmpty() || question.isEmpty() || answer.isEmpty()) {
Toast.makeText(RegisterActivity.this, "Harus diisi jangan kosong ",Toast.LENGTH_SHORT).show();
}else if(password.equals(password1) && password.length()==6 && password1.length()==6 && bCek.isChecked()){
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
progressDialog.dismiss();
if (success) {
Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
Toast.makeText(RegisterActivity.this, "Register Success", Toast.LENGTH_SHORT).show();
RegisterActivity.this.startActivity(intent);
finish();
} else {
Toast.makeText(RegisterActivity.this, "Register Failed", Toast.LENGTH_SHORT).show();
}
}else {
Toast.makeText(RegisterActivity.this, "Password Harus Sama dan 6 karakter ",Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
RegisterRequest registerRequest = new RegisterRequest(name, username, password, question, answer, responseListener);
RequestQueue queue = Volley.newRequestQueue(RegisterActivity.this);
queue.add(registerRequest);
}
});
}
} | [
"41520484+hamidfadhilah@users.noreply.github.com"
] | 41520484+hamidfadhilah@users.noreply.github.com |
c112498abcaaaf5e7c02f34c413fa1fd8736b984 | f302bc239b4788dd112a7f67e12075d496353523 | /src/main/java/vinyarion/fukkit/rpg/forging/rings/FRingForgingEffectCombination.java | 5b1837268cc38716e9d5116f0ebb644c17d0b5d0 | [] | no_license | VinyarionHyarmendacil/Fukkit | e2021b35e91749ef505bf390e5159f649f260c27 | 8d880bc47e96a3e4f63b4d29c0f41805b471dbb1 | refs/heads/master | 2020-05-17T10:49:48.597021 | 2020-05-04T07:27:03 | 2020-05-04T07:27:03 | 183,667,226 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,420 | java | package vinyarion.fukkit.rpg.forging.rings;
import lotr.common.inventory.LOTRContainerAnvil;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import vinyarion.fukkit.main.attrib.FAttributes;
import vinyarion.fukkit.main.attrib.FRingAttribEffect;
import vinyarion.fukkit.main.game.FItem;
import vinyarion.fukkit.main.recipes.FAnvilRecipe;
import vinyarion.fukkit.main.recipes.Permenant;
import vinyarion.fukkit.main.util.Colors;
public class FRingForgingEffectCombination extends FAnvilRecipe implements Permenant {
public FRingForgingEffectCombination(String name, boolean pub) {
super(name, pub);
}
public boolean matches(ItemStack left, ItemStack top, ItemStack bottom) {
return left != null && FRingForging.rings.getOrDefault(left.getItem(), FItem.DUMMY).equals(left) && left.stackSize == 1 && FAttributes.forgingGrade.isOn(left) &&
top != null && FRingForging.gems.getOrDefault(top.getItem(), FItem.DUMMY).equals(top) && top.stackSize == 1 &&
FRingForging.ringSmithHammer.equals(bottom);
}
public ItemStack getResult(ItemStack left, ItemStack top, ItemStack bottom) {
Grade grade = getRingGrade(left);
ForgingAttribute fa = ForgingAttribute.of(top);
int slots = grade.index+1;
int occupied = 0;
for(FRingAttribEffect rae : FAttributes.ringPotions) if(rae.isOn(left)) occupied+=(rae.potion==fa.data.effect.id?slots:1);
if(occupied >= slots) return null;
ItemStack result = left.copy();
int diff = slots - occupied - 1;
String say = Colors.GRAY + Colors.ITALIC + (diff == 0 ? "No" : String.valueOf(diff)) + " open effect slot" + (diff == 1 ? "" : "s");
FAttributes.forgingGrade.setOwnedLineAlternates(result, say, "0");
FRingAttribEffect rae = FRingForging.ringEffects.get(top.getItem());
String amp = rae.potion == Potion.invisibility.id ? "1" : "0";
rae.addTo(result, amp, String.valueOf(fa.data.tiertimes[grade.index]));
return result;
}
public ItemStack clickResult(LOTRContainerAnvil anvil, ItemStack result) {
Slot[] slots = FAnvilRecipe.getLeftTopBottom(anvil);
slots[0].decrStackSize(1);
slots[1].decrStackSize(1);
slots[2].getStack().attemptDamageItem(5, FRingForging.rr);
anvil.playAnvilSound();
return result;
}
private Grade getRingGrade(ItemStack ring) {
return FAttributes.forgingGrade.isOn(ring) ? FAttributes.forgingGrade.update(null, ring) : Grade.NORMAL;
}
}
| [
"kennethrsdael@gmail.com"
] | kennethrsdael@gmail.com |
cf12602c9979a6944f676ce03aff4384ba9708ed | a1269e00c07c0bfa493a9cc318ed2fee8df60faa | /StrictMath/src/hendricks/lab821/Main.java | 3506d0cc992973a8f4d8ff849bab4fe55082ed56 | [] | no_license | connormcdermid/javaBackup | 6f920336714e086fed37fb6bec9e6db0d3125e12 | 1524d025a46e16dcd6a31ea8ada2d4a68ee042a7 | refs/heads/master | 2020-04-14T12:43:34.637091 | 2019-06-13T12:22:25 | 2019-06-13T12:22:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,440 | java | package hendricks.lab821;
import java.util.Arrays;
import java.util.Random;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
Random rand = new Random();
int[] rarray = new int[25];
for (int i = 0; i < rarray.length; i++) {
rarray[i] = rand.nextInt();
}
ArrayList<Integer> odds = new ArrayList<>();
ArrayList<Integer> evens = new ArrayList<>();
for (int obj: rarray) {
if (obj % 2 != 0) {
odds.add(obj);
} else {
evens.add(obj);
}
}
for (Integer obj: evens) {
System.out.print(obj);
System.out.print(",");
}
System.out.println();
for (Integer obj: odds) {
System.out.print(obj);
System.out.print(",");
}
//Palindromes
int[] threeDigits = new int[10];
for (int i = 0; i < 10; i++) {
threeDigits[i] = rand.nextInt(899) + 100;
}
for (int obj: threeDigits) {
if (palindromeFinder(obj)) {
System.out.println(obj + " is a palindrome.");
} else {
System.out.println(obj + " is not a palindrome.");
}
}
//Part 3
//Uses the same array as before
Arrays.sort(rarray);
int sum = 0;
for (int obj : rarray) {
sum += obj;
}
int mean = sum / 25;
int median = rarray[12];
int max = rarray[25];
int min = rarray[0];
int range = max - min;
int variance = 0;
for (int obj: rarray) {
variance = (obj - mean) * (obj - mean);
}
double standardDev = Math.sqrt(variance);
System.out.println("Mean: " + mean);
System.out.println("Median: " + median);
System.out.println("Maximum: " + max);
System.out.println("Minimum: " + min);
System.out.println("Range: " + range);
System.out.println("Variance: " + variance);
System.out.println("Standard Deviation: " + standardDev);
}
public static boolean palindromeFinder(int num) {
char[] cnum = Integer.toString(num).toCharArray();
int rnum = Integer.parseInt(Character.toString(cnum[2]) + Character.toString(cnum[1]) + Character.toString(cnum[0]));
return num == rnum;
}
}
| [
"cam-o-man@live.com"
] | cam-o-man@live.com |
ce267d12e3b8cbde70b60b4f1da07b7a0bbb86d3 | 3c2d0279eaac473abc2758af4c6105ab8984fd8e | /lib_zxing/src/main/java/com/example/sweet_xue/two_dimension_code/MainActivity.java | 9d1bd290dd554c0d00c129d2c7f4898c7034398d | [] | no_license | sulancheng/myapptools | e53905a55e5972caad4420d31f4fbe7bdeab96e8 | 4b6766823e12ca0a2be899ec81bb009068a4af51 | refs/heads/master | 2021-01-20T08:13:21.038625 | 2019-04-12T08:39:23 | 2019-04-12T08:39:23 | 90,111,617 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,900 | java | package com.example.sweet_xue.two_dimension_code;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.ChecksumException;
import com.google.zxing.EncodeHintType;
import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.QRCodeReader;
import com.google.zxing.qrcode.QRCodeWriter;
import java.util.Hashtable;
public class MainActivity extends Activity implements View.OnClickListener, View.OnLongClickListener {
private EditText edt_wenan;
private Button btn_create,btn_saomiao,btn_select;
private ImageView imageView;
private String url = "http://www.weibo.com/";
private int QR_WIDTH = 170;
private int QR_HEIGHT = 170;
private Bitmap bitmap;
private static final int CHOOCE_PIC = 0;
private static final int PHOTO_PIC = 1;
private String imagePath = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
private void initView() {
edt_wenan = (EditText) findViewById(R.id.edt_wenan);
btn_create = (Button) findViewById(R.id.btn_create);
imageView = (ImageView) findViewById(R.id.imageview);
btn_saomiao = (Button) findViewById(R.id.btn_saomiao);
btn_select = (Button) findViewById(R.id.btn_select);
btn_create.setOnClickListener(this);
btn_saomiao.setOnClickListener(this);
btn_select.setOnClickListener(this);
imageView.setOnLongClickListener(this);
edt_wenan.setText(url);
}
/**
* 生成二维码
* @param url
*/
private void createQRImage(String url){
//判断url的合法性
if (url == null || "".equals(url) || url.length() < 1){
return;
}
Hashtable<EncodeHintType,String> hints = new Hashtable<EncodeHintType, String>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
try {
BitMatrix bitMatrix = new QRCodeWriter().encode(url, BarcodeFormat.QR_CODE,QR_WIDTH,QR_HEIGHT,hints);
int[] pixels = new int[QR_WIDTH * QR_HEIGHT];
for (int y = 0;y< QR_HEIGHT;y++){
for (int x = 0;x<QR_WIDTH;x++){
if (bitMatrix.get(x,y)){
pixels[y*QR_WIDTH + x] = 0xff000000;
}else {
pixels[y*QR_WIDTH + x] = 0xffffffff;
}
}
}
bitmap = Bitmap.createBitmap(QR_WIDTH, QR_HEIGHT, Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels,0,QR_WIDTH,0,0,QR_WIDTH,QR_HEIGHT);
imageView.setImageBitmap(bitmap);
} catch (WriterException e) {
e.printStackTrace();
}
}
/**
* 解析图片中的二维码
* @param bitmapPath
* @return
*/
private Result paresQRciseBitmap(String bitmapPath){
Hashtable<EncodeHintType,String> hints = new Hashtable<EncodeHintType, String>();
hints.put(EncodeHintType.CHARACTER_SET,"utf-8");
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeFile(bitmapPath,options);
options.inSampleSize = options.outHeight / 400;
if (options.inSampleSize <=0){
options.inSampleSize = 1;
}
options.inJustDecodeBounds = false;
bitmap = BitmapFactory.decodeFile(bitmapPath,options);
RGBLuminanceSource rgbLuminanceSource = new RGBLuminanceSource(bitmap);
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(rgbLuminanceSource));
QRCodeReader reader = new QRCodeReader();
Result result = null;
try {
result = reader.decode(binaryBitmap);
} catch (NotFoundException e) {
e.printStackTrace();
} catch (ChecksumException e) {
e.printStackTrace();
} catch (FormatException e) {
e.printStackTrace();
}
return result;
}
@Override
public void onClick(View v) {
int i = v.getId();
if (i == R.id.btn_create) {
createQRImage(url);
} else if (i == R.id.btn_saomiao) {
Intent intent2 = new Intent(MainActivity.this, MipcaActivityCapture.class);
startActivityForResult(intent2, PHOTO_PIC);
} else if (i == R.id.btn_select) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
intent.setType("image/*");
Intent intent1 = Intent.createChooser(intent, "选择一张二维码图片");
startActivityForResult(intent1, CHOOCE_PIC);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
imagePath = null;
if (resultCode == RESULT_OK){
switch (requestCode){
case PHOTO_PIC:
String result = data.getExtras().getString("result");
Intent intent = new Intent(MainActivity.this,MoWebActivity.class);
intent.putExtra("url_", result);
startActivity(intent);
break;
case CHOOCE_PIC:
String[] proj = new String[]{MediaStore.Images.Media.DATA};
Cursor cursor = MainActivity.this.getContentResolver().query(data.getData(), proj, null, null, null);
if (cursor.moveToFirst()){
int columIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
imagePath = cursor.getString(columIndex);
}
cursor.close();
Result result1 = paresQRciseBitmap(imagePath);
Intent intent1 = new Intent(MainActivity.this,MoWebActivity.class);
intent1.putExtra("url_",result1.toString());
startActivity(intent1);
break;
}
}
}
@Override
public boolean onLongClick(View v) {
//此处可弄一个类似微信的长按二维码的dialog
Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
System.out.println("====bitmap==onLong="+bitmap);
RGBLuminanceSource rgbLuminanceSource = new RGBLuminanceSource(bitmap);
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(rgbLuminanceSource));
QRCodeReader reader = new QRCodeReader();
Result result = null;
try {
result = reader.decode(binaryBitmap);
Intent intent2 = new Intent(MainActivity.this,MoWebActivity.class);
intent2.putExtra("url_",result.toString());
startActivity(intent2);
} catch (NotFoundException e) {
e.printStackTrace();
} catch (ChecksumException e) {
e.printStackTrace();
} catch (FormatException e) {
e.printStackTrace();
}
return true;
}
}
| [
"suchengkuaile@126.com"
] | suchengkuaile@126.com |
84c68ad0b0da6b9bbde699452ba32f97aa82c6c1 | af544e478f4e5b6a721591cd6c6f75b873c8cc88 | /FDP/T3_A8_PinedoBerumenClaraRuby/src/Ejercicio05_Cad_Sin_Espacios.java | 321ebd8f16889e851224592046d7705a5f6d4046 | [] | no_license | RubyBerumen/1roISC | 68054885371a59a9e90d62d78a136c2d8f36c09d | 9078b383f889912d8ba982eb5c39df995e3dfe2f | refs/heads/main | 2023-02-02T14:09:46.987092 | 2020-12-21T16:00:40 | 2020-12-21T16:00:40 | 323,373,475 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 488 | java | import java.util.Scanner;
public class Ejercicio05_Cad_Sin_Espacios {
public static void main(String[] args) {
Scanner entrada = new Scanner(System.in);
System.out.println("==Programa que recibe una cadena de caracteres y la muestra "
+ "sin ningún espacio en blanco==");
System.out.println();
System.out.println("Ingrese una cadena de caracteres: ");
String cadena = entrada.nextLine();
System.out.println(cadena.replace(" ", ""));
}
}
| [
"clararubipb15@gmail.com"
] | clararubipb15@gmail.com |
5c0248a6291a5215c6725c1f21af07ca4d6f3d48 | a069c606abe248371d373f3974557505b2c439f0 | /src/main/java/br/com/project/report/util/DateUtils.java | 659f33d00f73d80cb4ff544583ff9114264efcbe | [] | no_license | sirAndre1337/ProjetoJsf | e99ccdf84dfa6c436a8c2d7e30e046a972e90a14 | 774ce51c1e51ed9dc54e229992363d7bc7442228 | refs/heads/master | 2023-07-29T09:35:30.728161 | 2021-09-14T01:28:31 | 2021-09-14T01:28:31 | 406,023,921 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 417 | java | package br.com.project.report.util;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class DateUtils implements Serializable{
private static final long serialVersionUID = 1L;
public static String getDateAtualReportName() {
DateFormat df = new SimpleDateFormat("ddMMyyyy");
return df.format(Calendar.getInstance().getTime());
}
}
| [
"andrelluis17@hotmail.com"
] | andrelluis17@hotmail.com |
08ed701b517abbb2f3cb8f14c9d666f10256b07c | 310059f7a578936a2c1428cb744697422fbd3207 | /cache2k-core/src/test/java/org/cache2k/test/core/CacheNameTest.java | 5e53304ec9cc77d9df2f747537aa5958f54d28f3 | [
"Apache-2.0"
] | permissive | alfonsomunozpomer/cache2k | 74cf34012f6afdacdeeed550b190bc8aba2d9ad3 | b54a9d2df7d4b072663fe4dc561355c8a4f7f326 | refs/heads/master | 2022-11-26T20:13:16.915023 | 2020-08-08T22:36:31 | 2020-08-08T22:36:31 | 286,234,358 | 1 | 0 | Apache-2.0 | 2020-08-09T12:38:28 | 2020-08-09T12:38:27 | null | UTF-8 | Java | false | false | 2,036 | java | package org.cache2k.test.core;
/*
* #%L
* cache2k implementation
* %%
* Copyright (C) 2000 - 2020 headissue GmbH, Munich
* %%
* 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.
* #L%
*/
import org.cache2k.Cache;
import org.cache2k.Cache2kBuilder;
import org.cache2k.CacheManager;
import org.cache2k.testing.category.FastTests;
import static org.junit.Assert.*;
import static org.hamcrest.Matchers.*;
import org.junit.Test;
import org.junit.experimental.categories.Category;
/**
* @author Jens Wilke
*/
@Category(FastTests.class)
public class CacheNameTest {
/**
* Needed by JSR107 TCK tests, e.g.: org.jsr107.tck.CacheManagerTest@6fc6f14e
*/
@Test
public void atCharacter() {
Cache2kBuilder.forUnknownTypes().name("CacheNameTest@").build().close();
}
/**
* Needed by JSR107 annotations that create a cache name with
* {@code org.example.KeyClass,org.example.ValueClass}
*/
@Test
public void commaCharacter() {
Cache2kBuilder.forUnknownTypes().name("CacheNameTest,").build().close();
}
/**
* Needed by JSR107 TCK
*/
@Test
public void spaceCharacter() {
Cache2kBuilder.forUnknownTypes().name("CacheNameTest space").build().close();
}
@Test
public void managerNameInToString() {
final String _MANAGER_NAME = "managerNameInToString123";
CacheManager cm = CacheManager.getInstance(_MANAGER_NAME);
Cache c = Cache2kBuilder.forUnknownTypes().manager(cm).build();
assertThat(c.toString(), containsString(_MANAGER_NAME));
cm.close();
}
}
| [
"jw_github@headissue.com"
] | jw_github@headissue.com |
03f8a1d4c4761b748612a1327b6aced9a04d5972 | d8921242987175e5aa4f51e87bf05f68c1eb60f4 | /product-catalog/src/main/java/org/digitalinnovation/experts/productcatalog/repository/ProductRepository.java | 85588ef4132139465c70b4c942085314eee60c39 | [] | no_license | caio-lima1991/microsservicos-api | acc55fa93295d78c9f9f505cd418add0263f3dc6 | a3eaf91e87ac917ac219d1cc0c9ed26bb31c74a7 | refs/heads/master | 2023-07-22T03:13:18.296302 | 2021-09-06T01:06:43 | 2021-09-06T01:06:43 | 403,446,424 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 273 | java | package org.digitalinnovation.experts.productcatalog.repository;
import org.digitalinnovation.experts.productcatalog.model.Product;
import org.springframework.data.repository.CrudRepository;
public interface ProductRepository extends CrudRepository<Product, Integer> {
}
| [
"caio.lima1991@icloud.com"
] | caio.lima1991@icloud.com |
04218e8bd78bef30014228bfe1a14f657b5b8db4 | 44e7a56b893024c275593f13b150c3b18a80d5c8 | /RMI_Client/src/rmi_serverint/RMI_ServerInt.java | fdd79eb326436d50850d35d029e35167456c6fff | [] | no_license | marcinkozikowski/Java_RMI_GetDataFromServer | 8f87831306a580b9231cd4d2a1d166e1ae01541d | 8468f1659c89b81f0f7d902257bdcd04c4c7dcb1 | refs/heads/master | 2021-04-12T03:04:10.106612 | 2018-03-18T13:11:19 | 2018-03-18T13:11:19 | 125,726,135 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 654 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package rmi_serverint;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.ArrayList;
/**
*
* @author Dell
*/
public interface RMI_ServerInt extends Remote {
public int getResault(int a,int b,String operation) throws RemoteException;
public Person getPerson(int index) throws RemoteException;
public ArrayList<Person> getAllPeople() throws RemoteException;
public ArrayList<Person> getByPersonName(String name) throws RemoteException;
}
| [
"marcinkozikowski@wp.pl"
] | marcinkozikowski@wp.pl |
8619e46518457872953c7bc1ce783a09f46f44ae | f279161b64f857ae4effc50fe0738d2ac3124fd8 | /src/java/org/m4us/handlers/MovieSelectHandler.java | 13fb7255c3561a45e26b85cd6751e9a95293865c | [] | no_license | movies4us/movies4us | 64dbecd819e9d978ba1c4a2762c5d554936967de | 19306971ada880c336360c4d607903fae04e702c | refs/heads/master | 2020-05-26T21:06:19.312716 | 2012-04-26T18:30:03 | 2012-04-26T18:30:03 | 3,557,203 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,150 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.m4us.handlers;
import java.util.ArrayList;
import org.m4us.controller.FlowContext;
import org.m4us.movielens.utils.dto.MoviesTableObject;
import org.recommend.utils.qo.RejectMovie;
/**
*
* @author Aveek
*/
public class MovieSelectHandler implements IHandler{
@Override
public void handleRequest(FlowContext flowCtx)
{
Integer groupId = Integer.parseInt((String)flowCtx.get("groupId"));
Integer movieId = Integer.parseInt((String)flowCtx.get("movieId"));
ArrayList movieList=(ArrayList)flowCtx.get("RecommendationList");
for(int i=0;i<movieList.size();i++)
{
MoviesTableObject obj = (MoviesTableObject)movieList.get(i);
if(obj.getMovieId().equals(movieId))
break;
else
{
RejectMovie rm=new RejectMovie(groupId, obj.getMovieId());
rm.updateRejects();
}
}
}
}
| [
"Aveek@Aveek-Laptop.mshome.net"
] | Aveek@Aveek-Laptop.mshome.net |
5f396c7e14485875b9968355410d1e2c1e9eaf14 | 05d0a9553358fbf159e566c403626de2718e17c9 | /hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/NodeLabelTestBase.java | 28b9497fa36cece5fdbc93cc6360bd0b433fbee6 | [
"CC-BY-2.5",
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"EPL-1.0",
"Classpath-exception-2.0",
"GCC-exception-3.1",
"BSD-3-Clause",
"CC-PDDC",
"GPL-2.0-only",
"CDDL-1.0",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"GPL-1.0-or-later",
"LicenseRef-scancode-jdom"... | permissive | hopshadoop/hops | d8baaf20bc418af460e582974839a3a9a72f173a | ed0d4de3dadbde5afa12899e703954aa67db7b3b | refs/heads/master | 2023-08-31T20:36:31.212647 | 2023-08-28T15:31:37 | 2023-08-28T15:31:37 | 32,975,439 | 295 | 85 | Apache-2.0 | 2023-09-05T09:19:57 | 2015-03-27T08:31:42 | Java | UTF-8 | Java | false | false | 5,714 | java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.yarn.nodelabels;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.api.records.NodeLabel;
import org.junit.Assert;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
public class NodeLabelTestBase {
public static void assertMapEquals(Map<NodeId, Set<String>> expected,
ImmutableMap<NodeId, Set<String>> actual) {
Assert.assertEquals(expected.size(), actual.size());
for (NodeId k : expected.keySet()) {
Assert.assertTrue(actual.containsKey(k));
assertCollectionEquals(expected.get(k), actual.get(k));
}
}
public static void assertLabelInfoMapEquals(
Map<NodeId, Set<NodeLabel>> expected,
ImmutableMap<NodeId, Set<NodeLabel>> actual) {
Assert.assertEquals(expected.size(), actual.size());
for (NodeId k : expected.keySet()) {
Assert.assertTrue(actual.containsKey(k));
assertNLCollectionEquals(expected.get(k), actual.get(k));
}
}
public static void assertLabelsToNodesEquals(
Map<String, Set<NodeId>> expected,
ImmutableMap<String, Set<NodeId>> actual) {
Assert.assertEquals(expected.size(), actual.size());
for (String k : expected.keySet()) {
Assert.assertTrue(actual.containsKey(k));
Set<NodeId> expectedS1 = new HashSet<>(expected.get(k));
Set<NodeId> actualS2 = new HashSet<>(actual.get(k));
Assert.assertEquals(expectedS1, actualS2);
Assert.assertTrue(expectedS1.containsAll(actualS2));
}
}
public static ImmutableMap<String, Set<NodeId>> transposeNodeToLabels(
Map<NodeId, Set<String>> mapNodeToLabels) {
Map<String, Set<NodeId>> mapLabelsToNodes = new HashMap<>();
for(Entry<NodeId, Set<String>> entry : mapNodeToLabels.entrySet()) {
NodeId node = entry.getKey();
Set<String> setLabels = entry.getValue();
for(String label : setLabels) {
Set<NodeId> setNode = mapLabelsToNodes.get(label);
if (setNode == null) {
setNode = new HashSet<>();
}
setNode.add(NodeId.newInstance(node.getHost(), node.getPort()));
mapLabelsToNodes.put(label, setNode);
}
}
return ImmutableMap.copyOf(mapLabelsToNodes);
}
public static void assertMapContains(Map<NodeId, Set<String>> expected,
ImmutableMap<NodeId, Set<String>> actual) {
for (NodeId k : actual.keySet()) {
Assert.assertTrue(expected.containsKey(k));
assertCollectionEquals(expected.get(k), actual.get(k));
}
}
public static void assertCollectionEquals(Collection<String> expected,
Collection<String> actual) {
if (expected == null) {
Assert.assertNull(actual);
} else {
Assert.assertNotNull(actual);
}
Set<String> expectedSet = new HashSet<>(expected);
Set<String> actualSet = new HashSet<>(actual);
Assert.assertEquals(expectedSet, actualSet);
Assert.assertTrue(expectedSet.containsAll(actualSet));
}
public static void assertNLCollectionEquals(Collection<NodeLabel> expected,
Collection<NodeLabel> actual) {
if (expected == null) {
Assert.assertNull(actual);
} else {
Assert.assertNotNull(actual);
}
Set<NodeLabel> expectedSet = new HashSet<>(expected);
Set<NodeLabel> actualSet = new HashSet<>(actual);
Assert.assertEquals(expectedSet, actualSet);
Assert.assertTrue(expectedSet.containsAll(actualSet));
}
@SuppressWarnings("unchecked")
public static <E> Set<E> toSet(E... elements) {
Set<E> set = Sets.newHashSet(elements);
return set;
}
public static Set<NodeLabel> toNodeLabelSet(String... nodeLabelsStr) {
if (null == nodeLabelsStr) {
return null;
}
Set<NodeLabel> labels = new HashSet<>();
for (String label : nodeLabelsStr) {
labels.add(NodeLabel.newInstance(label));
}
return labels;
}
public NodeId toNodeId(String str) {
if (str.contains(":")) {
int idx = str.indexOf(':');
NodeId id =
NodeId.newInstance(str.substring(0, idx),
Integer.parseInt(str.substring(idx + 1)));
return id;
} else {
return NodeId.newInstance(str, CommonNodeLabelsManager.WILDCARD_PORT);
}
}
public static void assertLabelsInfoToNodesEquals(
Map<NodeLabel, Set<NodeId>> expected,
ImmutableMap<NodeLabel, Set<NodeId>> actual) {
Assert.assertEquals(expected.size(), actual.size());
for (NodeLabel k : expected.keySet()) {
Assert.assertTrue(actual.containsKey(k));
Set<NodeId> expectedS1 = new HashSet<>(expected.get(k));
Set<NodeId> actualS2 = new HashSet<>(actual.get(k));
Assert.assertEquals(expectedS1, actualS2);
Assert.assertTrue(expectedS1.containsAll(actualS2));
}
}
}
| [
"gautier.berthou@gmail.com"
] | gautier.berthou@gmail.com |
1fe7fda308e7b5cd359d3625e1b8a2de29a750c8 | a1d72a07b5df38a868b28bbd7c1afa263702459c | /src/main/java/com/example/model/Fridge.java | 8a345cb94efba5fd72c59b3db36bd398d122395d | [] | no_license | wxn0738xx/Recipe-Finder | b95cab24e3b8543f4bdf5027517b301add881617 | 7518cb34450fad7cb7c185f3a7cf98e0e88e01aa | refs/heads/master | 2020-05-07T17:54:18.629200 | 2019-04-15T12:00:50 | 2019-04-15T12:00:50 | 180,746,120 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 583 | java | package com.example.model;
import java.util.Date;
public class Fridge {
private String item;
private int amount;
private Unit unit;
private Date useBy;
public String getItem() {
return item;
}
public void setItem(String item) {
this.item = item;
}
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
public Unit getUnit() {
return unit;
}
public void setUnit(Unit unit) {
this.unit = unit;
}
public Date getUseBy() {
return useBy;
}
public void setUseBy(Date useBy) {
this.useBy = useBy;
}
}
| [
"xiaonanw2@student.unimelb.edu.au"
] | xiaonanw2@student.unimelb.edu.au |
8d0fa7434feb919ab023694ca8da5280d2b33659 | 1a041bf9671b9a7ffaf37a0f4aab77c8573a0a8e | /jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysPositionController.java | cccd034b886a3f7a762eed7cb0d5fad49329407a | [
"Apache-2.0",
"MIT"
] | permissive | Liannala/jeecg-boot | dd70d7d03c9e1433bb8eeebe94efe0e1bfa692a9 | 8c143f35f8003cbb0a9a364303ba8606b70a5d68 | refs/heads/master | 2022-03-12T00:11:55.369602 | 2022-02-18T03:28:23 | 2022-02-18T03:28:23 | 186,774,331 | 1 | 0 | MIT | 2019-05-15T07:38:09 | 2019-05-15T07:38:09 | null | UTF-8 | Java | false | false | 10,791 | java | package org.jeecg.modules.system.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.ImportExcelUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.quartz.service.IQuartzJobService;
import org.jeecg.modules.system.entity.SysPosition;
import org.jeecg.modules.system.service.ISysPositionService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @Description: 职务表
* @Author: jeecg-boot
* @Date: 2019-09-19
* @Version: V1.0
*/
@Slf4j
@Api(tags = "职务表")
@RestController
@RequestMapping("/sys/position")
public class SysPositionController {
@Autowired
private ISysPositionService sysPositionService;
/**
* 分页列表查询
*
* @param sysPosition
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "职务表-分页列表查询")
@ApiOperation(value = "职务表-分页列表查询", notes = "职务表-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<SysPosition>> queryPageList(SysPosition sysPosition,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Result<IPage<SysPosition>> result = new Result<IPage<SysPosition>>();
QueryWrapper<SysPosition> queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, req.getParameterMap());
Page<SysPosition> page = new Page<SysPosition>(pageNo, pageSize);
IPage<SysPosition> pageList = sysPositionService.page(page, queryWrapper);
result.setSuccess(true);
result.setResult(pageList);
return result;
}
/**
* 添加
*
* @param sysPosition
* @return
*/
@AutoLog(value = "职务表-添加")
@ApiOperation(value = "职务表-添加", notes = "职务表-添加")
@PostMapping(value = "/add")
public Result<SysPosition> add(@RequestBody SysPosition sysPosition) {
Result<SysPosition> result = new Result<SysPosition>();
try {
sysPositionService.save(sysPosition);
result.success("添加成功!");
} catch (Exception e) {
log.error(e.getMessage(), e);
result.error500("操作失败");
}
return result;
}
/**
* 编辑
*
* @param sysPosition
* @return
*/
@AutoLog(value = "职务表-编辑")
@ApiOperation(value = "职务表-编辑", notes = "职务表-编辑")
@RequestMapping(value = "/edit", method ={RequestMethod.PUT, RequestMethod.POST})
public Result<SysPosition> edit(@RequestBody SysPosition sysPosition) {
Result<SysPosition> result = new Result<SysPosition>();
SysPosition sysPositionEntity = sysPositionService.getById(sysPosition.getId());
if (sysPositionEntity == null) {
result.error500("未找到对应实体");
} else {
boolean ok = sysPositionService.updateById(sysPosition);
//TODO 返回false说明什么?
if (ok) {
result.success("修改成功!");
}
}
return result;
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "职务表-通过id删除")
@ApiOperation(value = "职务表-通过id删除", notes = "职务表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
try {
sysPositionService.removeById(id);
} catch (Exception e) {
log.error("删除失败", e.getMessage());
return Result.error("删除失败!");
}
return Result.ok("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "职务表-批量删除")
@ApiOperation(value = "职务表-批量删除", notes = "职务表-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<SysPosition> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
Result<SysPosition> result = new Result<SysPosition>();
if (ids == null || "".equals(ids.trim())) {
result.error500("参数不识别!");
} else {
this.sysPositionService.removeByIds(Arrays.asList(ids.split(",")));
result.success("删除成功!");
}
return result;
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "职务表-通过id查询")
@ApiOperation(value = "职务表-通过id查询", notes = "职务表-通过id查询")
@GetMapping(value = "/queryById")
public Result<SysPosition> queryById(@RequestParam(name = "id", required = true) String id) {
Result<SysPosition> result = new Result<SysPosition>();
SysPosition sysPosition = sysPositionService.getById(id);
if (sysPosition == null) {
result.error500("未找到对应实体");
} else {
result.setResult(sysPosition);
result.setSuccess(true);
}
return result;
}
/**
* 导出excel
*
* @param request
* @param response
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
// Step.1 组装查询条件
QueryWrapper<SysPosition> queryWrapper = null;
try {
String paramsStr = request.getParameter("paramsStr");
if (oConvertUtils.isNotEmpty(paramsStr)) {
String deString = URLDecoder.decode(paramsStr, "UTF-8");
SysPosition sysPosition = JSON.parseObject(deString, SysPosition.class);
queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, request.getParameterMap());
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<SysPosition> pageList = sysPositionService.list(queryWrapper);
//导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "职务表列表");
mv.addObject(NormalExcelConstants.CLASS, SysPosition.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("职务表列表数据", "导出人:Jeecg", "导出信息"));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response)throws IOException {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
// 错误信息
List<String> errorMessage = new ArrayList<>();
int successLines = 0, errorLines = 0;
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<Object> listSysPositions = ExcelImportUtil.importExcel(file.getInputStream(), SysPosition.class, params);
List<String> list = ImportExcelUtil.importDateSave(listSysPositions, ISysPositionService.class, errorMessage,CommonConstant.SQL_INDEX_UNIQ_CODE);
errorLines+=list.size();
successLines+=(listSysPositions.size()-errorLines);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("文件导入失败:" + e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return ImportExcelUtil.imporReturnRes(errorLines,successLines,errorMessage);
}
/**
* 通过code查询
*
* @param code
* @return
*/
@AutoLog(value = "职务表-通过code查询")
@ApiOperation(value = "职务表-通过code查询", notes = "职务表-通过code查询")
@GetMapping(value = "/queryByCode")
public Result<SysPosition> queryByCode(@RequestParam(name = "code", required = true) String code) {
Result<SysPosition> result = new Result<SysPosition>();
QueryWrapper<SysPosition> queryWrapper = new QueryWrapper<SysPosition>();
queryWrapper.eq("code",code);
SysPosition sysPosition = sysPositionService.getOne(queryWrapper);
if (sysPosition == null) {
result.error500("未找到对应实体");
} else {
result.setResult(sysPosition);
result.setSuccess(true);
}
return result;
}
}
| [
"zhangdaiscott@163.com"
] | zhangdaiscott@163.com |
3e051fd92bf95ae8f8f099d5a381e02c3a52f2a4 | 3d5d1ac859df481d2b45607fd376af1b4072d114 | /RFP/src/test/java/com/incubator/springmvc/utils/UtilityTest.java | f84949536b4fdbea38810109f808b5417b06b604 | [] | no_license | grace191/crowd-funding | e8f5d54560ea34d921dd486db710aa63d7673bc3 | ecf0c64fb99981178625a6d1cbd17b642f226d6f | refs/heads/master | 2016-09-13T19:47:06.836562 | 2016-06-02T00:11:25 | 2016-06-02T00:11:25 | 58,279,335 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,769 | java | package com.incubator.springmvc.utils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.SystemUtils;
import org.junit.Test;
import com.amazonaws.services.s3.model.GetObjectMetadataRequest;
import com.amazonaws.services.s3.model.GetObjectRequest;
import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.services.s3.transfer.Copy;
public class UtilityTest {
// @Test
// public void createS3Folder(){
// String path = "test"+DeclareConstant.SUFFIX + "des" + DeclareConstant.SUFFIX ;
//// String path1 = "test1"+DeclareConstant.SUFFIX + DeclareConstant.TEMP;
// UtilitiesS3.createFolder(DeclareConstant.BUCKET, path, UtilitiesS3.getS3Client());
//// UtilitiesS3.createFolder(DeclareConstant.BUCKET, path1, UtilitiesS3.getS3Client());
// // System.out.println(SystemUtils.IS_OS_WINDOWS_2012);
// }
//
// @Test
// public void uploadFile(){
// String fileName = "test"+DeclareConstant.SUFFIX + DeclareConstant.TEMP +DeclareConstant.SUFFIX +"img_1.jpg";
//
// System.out.println(fileName);
// UtilitiesS3.uploadFile(fileName, new File("C:\\Users\\tians\\Desktop\\images\\img_1.jpg"));
//
//
//
//// GetObjectMetadataRequest request2 =
//// new GetObjectMetadataRequest(Utilities.getS3Client(), fileName);
////
//// ObjectMetadata metadata = s3client.getObjectMetadata(request2);
////
//// System.out.println("Encryption algorithm used: " +
//// metadata.getSSEAlgorithm());
// }
// @Test
// public void Copy(){
// String sourceKey = "test"+DeclareConstant.SUFFIX + DeclareConstant.TEMP +DeclareConstant.SUFFIX;
// String destinationKey ="test"+DeclareConstant.SUFFIX + "des" +DeclareConstant.SUFFIX;
// UtilitiesS3.copyObjects(sourceKey, destinationKey);
// }
// @Test
// public void getBytes(){
// String fileName = "ceb546a2-e4ef-467a-a607-f81dcef39a01/f9f13873-df48-47c3-ac66-ca598abb41cc/attachments" +"/img_3.jpg";
// S3Object s3Object =UtilitiesS3.getS3Client()
// .getObject(new GetObjectRequest(DeclareConstant.BUCKET, fileName));
// InputStream inputStream = s3Object.getObjectContent();
// byte[] bytes = {};
// try {
// bytes = IOUtils.toByteArray(inputStream);
// System.out.println("bytes "+bytes.length);
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// @Test
// public void listFile(){
// System.out.println(UtilitiesS3.listFileNames("ceb546a2-e4ef-467a-a607-f81dcef39a01/temp/images/"));
// }
// @Test
// public void deleteFile(){
// UtilitiesS3.deleteFile("ceb546a2-e4ef-467a-a607-f81dcef39a01/temp/images/");
// }
}
| [
"yli191@hawk.iit.edu"
] | yli191@hawk.iit.edu |
4f0ada35d8ea99f0b6e3355eddd4e9867b940f19 | 89a050d1b41f9cb6ad233f9383499298f0313623 | /Sinapsi Web Service/src/com/sinapsi/webservice/web/AvailableTriggerServlet.java | 5f8b1dff4492d56eafabf3c8bf25330d91e9206e | [
"MIT"
] | permissive | AyoubOuarrak/Sinapsi | 0258d41e91b41654a56a04b475d30e47369d38d8 | ada75cc19c32824a133ca464e346a77e82d796b3 | refs/heads/master | 2021-01-18T00:49:10.618873 | 2015-05-21T01:47:27 | 2015-05-21T01:47:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,580 | java | package com.sinapsi.webservice.web;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.bgp.decryption.Decrypt;
import com.bgp.encryption.Encrypt;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.sinapsi.model.MacroComponent;
import com.sinapsi.webservice.db.EngineDBManager;
import com.sinapsi.webservice.db.KeysDBManager;
import com.sinapsi.webservice.db.UserDBManager;
import com.sinapsi.webservice.utility.BodyReader;
/**
* Servlet implementation class AvailableTriggerServlet
*/
@WebServlet("/available_triggers")
public class AvailableTriggerServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/json");
PrintWriter out = response.getWriter();
EngineDBManager engineManager = (EngineDBManager) getServletContext().getAttribute("engines_db");
KeysDBManager keysManager = (KeysDBManager) getServletContext().getAttribute("keys_db");
UserDBManager userManager = (UserDBManager) getServletContext().getAttribute("users_db");
Gson gson = new Gson();
int idDevice = Integer.parseInt(request.getParameter("device"));
try {
String email = userManager.getUserEmail(idDevice);
// create the encrypter
Encrypt encrypter = new Encrypt(keysManager.getClientPublicKey(email));
// get the available triggers from the db
List<MacroComponent> triggers = engineManager.getAvailableTrigger(idDevice);
// send the encrypted data
out.print(encrypter.encrypt(gson.toJson(triggers)));
out.flush();
} catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/json");
PrintWriter out = response.getWriter();
EngineDBManager engineManager = (EngineDBManager) getServletContext().getAttribute("engines_db");
KeysDBManager keysManager = (KeysDBManager) getServletContext().getAttribute("keys_db");
UserDBManager userManager = (UserDBManager) getServletContext().getAttribute("users_db");
Gson gson = new Gson();
int idDevice = Integer.parseInt(request.getParameter("device"));
// if the db fails to add the available triggers, then set success to false, and vice-versa
boolean success = false;
// read the encrypted jsoned body
String encryptedJsonBody = BodyReader.read(request);
try {
String email = userManager.getUserEmail(idDevice);
// create the decrypter
Decrypt decrypter = new Decrypt(keysManager.getPrivateKey(email), keysManager.getClientSessionKey(email));
// decrypt the jsoned body
String jsonBody = decrypter.decrypt(encryptedJsonBody);
// extract the list of triggers from the jsoned triggers
List<MacroComponent> triggers = gson.fromJson(jsonBody,new TypeToken<List<MacroComponent>>() {}.getType());
// add the list of trigger in the db
engineManager.addAvailableTriggers(idDevice, triggers);
success = true;
} catch (Exception e) {
// the db fails to add triggers
success = false;
e.printStackTrace();
}
try {
String email = userManager.getUserEmail(idDevice);
// return a crypted response to the client
Encrypt encrypter = new Encrypt(keysManager.getClientPublicKey(email));
if (success)
out.print(encrypter.encrypt(gson.toJson("success!")));
else
out.print(encrypter.encrypt(gson.toJson("Fail!")));
out.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
}
| [
"andreyvondorcon@gmail.com"
] | andreyvondorcon@gmail.com |
553e31f6c382b604ca3dbdb5b3c3b278e8ac99cd | 1cc2814c47e636ab20bf7ebcf2a5955dc3893413 | /src/main/java/com/mycompany/crmwebapijavas2s/CrmApplication.java | b5a86adbdf750b84d53d8b8b7753a368acaf7f97 | [] | no_license | guilhermeblima/CrmWebApiJavaS2S | b7e0a262db946e717884f51f152aa239c2047c48 | 1888e34bbb5a66818ab01ec014901b5e319489b4 | refs/heads/master | 2020-03-26T10:21:29.764101 | 2017-05-17T17:56:42 | 2017-05-17T17:56:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,472 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.crmwebapijavas2s;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLEncoder;
import net.minidev.json.JSONObject;
import net.minidev.json.JSONValue;
public class CrmApplication {
//This was registered in Azure AD as a WEB APP / API APPLICATION
//Azure Application Client ID
private final static String CLIENT_ID = "00000000-0000-0000-0000-000000000000";
private final static String CLIENT_SECRET = "secret";
//CRM URL
private final static String RESOURCE = "https://org.crm.dynamics.com";
//Azure Directory OAUTH 2.0 AUTHORIZATION ENDPOINT
private final static String AUTHORITY = "https://login.windows.net/00000000-0000-0000-0000-000000000000/oauth2/token";
public static void main(String args[]) throws Exception {
//No prompt for credentials
String token = GetToken();
System.out.println("Access Token - " + token);
String userId = WhoAmI(token);
System.out.println("UserId - " + userId);
String fullname = FindFullname(token, userId);
System.out.println("Fullname: " + fullname);
String accountId = CreateAccount(token, "Java Test");
System.out.println("Created: " + accountId);
accountId = UpdateAccount(token, accountId);
System.out.println("Updated: " + accountId);
accountId = DeleteAccount(token, accountId);
System.out.println("Deleted: " + accountId);
}
private static String DeleteAccount(String token, String accountId) throws MalformedURLException, IOException {
HttpURLConnection connection = null;
URL url = new URL(RESOURCE + "/api/data/v8.2/accounts(" + accountId + ")");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("DELETE");
connection.setRequestProperty("OData-MaxVersion", "4.0");
connection.setRequestProperty("OData-Version", "4.0");
connection.addRequestProperty("Authorization", "Bearer " + token);
connection.setRequestProperty(
"Content-Type", "application/x-www-form-urlencoded");
connection.connect();
int responseCode = connection.getResponseCode();
return accountId;
}
private static String UpdateAccount(String token, String accountId) throws MalformedURLException, IOException, URISyntaxException {
JSONObject account = new JSONObject();
account.put("websiteurl", "http://www.microsoft.com");
HttpURLConnection connection = null;
URL url = new URL(RESOURCE + "/api/data/v8.2/accounts(" + accountId + ")");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("X-HTTP-Method-Override", "PATCH");
connection.setRequestMethod("POST");
connection.setRequestProperty("OData-MaxVersion", "4.0");
connection.setRequestProperty("OData-Version", "4.0");
connection.setRequestProperty("Accept", "application/json");
connection.addRequestProperty("Authorization", "Bearer " + token);
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type", "application/json");
connection.setDoOutput(true);
connection.connect();
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
out.write(account.toJSONString());
out.flush();
out.close();
int responseCode = connection.getResponseCode();
return accountId;
}
private static String CreateAccount(String token, String name) throws MalformedURLException, IOException {
JSONObject account = new JSONObject();
account.put("name", name);
//account.put("primarycontactid@odata.bind", "/contacts(A33605D9-A6A0-E611-80EA-C4346BACDA3C)");
HttpURLConnection connection = null;
URL url = new URL(RESOURCE + "/api/data/v8.2/accounts");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("OData-MaxVersion", "4.0");
connection.setRequestProperty("OData-Version", "4.0");
connection.setRequestProperty("Accept", "application/json");
connection.addRequestProperty("Authorization", "Bearer " + token);
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type", "application/json");
connection.setDoOutput(true);
connection.connect();
BufferedWriter out
= new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
out.write(account.toJSONString());
out.close();
int responseCode = connection.getResponseCode();
String headerId = connection.getHeaderField("OData-EntityId");
String accountId = headerId.split("[\\(\\)]")[1];
return accountId;
}
private static String FindFullname(String token, String userId) throws MalformedURLException, IOException {
HttpURLConnection connection = null;
URL url = new URL(RESOURCE + "/api/data/v8.2/systemusers(" + userId + ")?$select=fullname");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("OData-MaxVersion", "4.0");
connection.setRequestProperty("OData-Version", "4.0");
connection.setRequestProperty("Accept", "application/json");
connection.addRequestProperty("Authorization", "Bearer " + token);
int responseCode = connection.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
Object jResponse;
jResponse = JSONValue.parse(response.toString());
JSONObject jObject = (JSONObject) jResponse;
String fullname = jObject.get("fullname").toString();
return fullname;
}
private static String WhoAmI(String token) throws MalformedURLException, IOException {
HttpURLConnection connection = null;
URL url = new URL(RESOURCE + "/api/data/v8.2/WhoAmI");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("OData-MaxVersion", "4.0");
connection.setRequestProperty("OData-Version", "4.0");
connection.setRequestProperty("Accept", "application/json");
connection.addRequestProperty("Authorization", "Bearer " + token);
int responseCode = connection.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
Object jResponse;
jResponse = JSONValue.parse(response.toString());
JSONObject jObject = (JSONObject) jResponse;
String userId = jObject.get("UserId").toString();
return userId;
}
private static String GetToken() throws MalformedURLException, IOException {
String body = "resource=" + URLEncoder.encode(RESOURCE)
+ "&client_id=" + URLEncoder.encode(CLIENT_ID)
+ "&client_secret=" + URLEncoder.encode(CLIENT_SECRET)
+ "&grant_type=client_credentials";
HttpURLConnection connection = null;
URL url = new URL(AUTHORITY);
connection = (HttpURLConnection) url.openConnection();
// connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.connect();
BufferedWriter out
= new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
out.write(body);
out.close();
int responseCode = connection.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
Object jResponse;
jResponse = JSONValue.parse(response.toString());
JSONObject jObject = (JSONObject) jResponse;
String access_token = jObject.get("access_token").toString();
return access_token;
}
}
| [
"jason.lattimer@gmail.com"
] | jason.lattimer@gmail.com |
eb83e751919ccc6dee5865283cf3c9cfcdde1474 | e4f3b4d82eb7b1c1f1b631eedae7ca6589adb53e | /player/src/main/java/com/cpp/mscs/cricscore/repositories/MatchRepo.java | c99283f62eebe04bf1cab0d8ca9da4605b5bb3a8 | [] | no_license | jayavardhanpatil/cricscore_backend_springboot | 66140d9c82d221ce8d1af906e4f8aecb5b62d585 | 0bb8eeb40a0f49d3b2fb5f0b4e5ea07880c42343 | refs/heads/main | 2023-04-10T00:42:48.527870 | 2021-04-18T02:50:14 | 2021-04-18T02:50:14 | 357,829,707 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,182 | java | package com.cpp.mscs.cricscore.repositories;
import com.cpp.mscs.cricscore.models.City;
import com.cpp.mscs.cricscore.models.Match;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.Map;
/**
* Created by IntelliJ IDEA.
* User: jayavardhanpatil
* Date: 3/28/21
* Time: 18:18
*/
@Repository
public interface MatchRepo extends JpaRepository<Match, Long> {
@Modifying(clearAutomatically = true)
@Query("update Match m set m.result =:result, m.winningTeamId =:wonTeamId, m.totalScore =:target " +
"where m.matchId =:matchId")
void updateResult(@Param(value = "result") String result,
@Param(value = "wonTeamId") int wonTeamId,
@Param(value = "target") int target,
@Param(value = "matchId") long matchId);
@Query("Select m.matchVenuecityId from Match m where m.matchId =:matchId")
Long getCity(@Param("matchId") Long matchId);
}
| [
"jayawardhan.patil@gmail.com"
] | jayawardhan.patil@gmail.com |
2ce919fc9e769cdc21ebf8dfa486bb4ad4866c58 | 16795af3931e58f8a2e5db52c0cc67f8a92ff8fa | /src/main/java/guru/springframework/spring5webapp/controller/BookController.java | b8e928b7dc9637de17b49b0d04956e923196603d | [] | no_license | sambit04126/spring5webapp | b0b0789aaf307d982620770acac4df98fb98e0ef | 1c946dd16e90fd418c46aaee0f5566da93b105dc | refs/heads/master | 2020-04-27T21:47:43.121868 | 2019-03-16T14:23:52 | 2019-03-16T14:23:52 | 174,712,165 | 0 | 0 | null | 2019-03-09T15:35:23 | 2019-03-09T15:35:23 | null | UTF-8 | Java | false | false | 643 | java | package guru.springframework.spring5webapp.controller;
import guru.springframework.spring5webapp.repositories.BookRepository;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class BookController {
private BookRepository bookRepository;
public BookController(BookRepository bookRepository) {
this.bookRepository = bookRepository;
}
@RequestMapping("/books")
public String getBooks(Model model){
model.addAttribute("books",bookRepository.findAll());
return "books";
}
}
| [
"sambit04126@gmail.com"
] | sambit04126@gmail.com |
2d8e88647ae03a4f49a5d940b4009dc6e85760e3 | 3229383f3580ef38cd4c15e58d92402bce4c643e | /app/src/main/java/com/example/ilhacisneclube/fragments/RankingFragment.java | 1d9ae7dd0146f2f00a7503c0710ef59c1ca3ac6b | [] | no_license | gussouzauni/native-android-java | 5ab04826e8fc69b0c47ab428c37f95364d98d604 | 488c53c137a35bae8c7d33dc8929f4c9f29273af | refs/heads/master | 2022-07-03T10:23:36.525592 | 2020-05-13T18:15:40 | 2020-05-13T18:15:40 | 191,859,246 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,543 | java | package com.example.ilhacisneclube.fragments;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import com.example.ilhacisneclube.R;
import com.example.ilhacisneclube.activity.ExibirRankingTime;
import com.example.ilhacisneclube.adaptador.AdapterRanking;
import com.example.ilhacisneclube.model.Campeonato;
import com.example.ilhacisneclube.recycleritemclick.RecyclerItemClickListener;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.List;
import static com.example.ilhacisneclube.activity.CadastroCampeonato.usuarioLogado;
public class RankingFragment extends Fragment {
private ArrayList<Campeonato> vitorias = new ArrayList<>();
private RecyclerView recyclerViewRanking;
private AdapterRanking adapterRanking;
private List<String> idsRanking = new ArrayList<>();
DatabaseReference databaseReference;
FirebaseDatabase mFirebasedatabase;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.ranking_fragment, container, false);
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
//Firebase
mFirebasedatabase = FirebaseDatabase.getInstance();
databaseReference = mFirebasedatabase.getReference();
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
inicializarComponentes();
recuperarDados();
acessarCadastroPontos();
}
private void inicializarComponentes() {
//RecyclerView
recyclerViewRanking = getView().findViewById(R.id.recycler_ranking);
recyclerViewRanking.setLayoutManager(new GridLayoutManager(getContext(), 2));
//Adapter
adapterRanking = new AdapterRanking(vitorias);
recyclerViewRanking.setAdapter(adapterRanking);
Toolbar toolbar = getActivity().findViewById(R.id.toolbar_ranking_fragment);
toolbar.setTitle("Ranking");
}
private void recuperarDados() { //Recuperar dados do firebase para exibir na lista pontuação
databaseReference.child("Campeonato").child(usuarioLogado()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for(DataSnapshot data : dataSnapshot.getChildren()) {
Campeonato ranking1 = data.getValue(Campeonato.class);
vitorias.add(ranking1);
idsRanking.add(data.getKey());
}
adapterRanking.notifyDataSetChanged();
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
private void acessarCadastroPontos() { //Acessa o fragmento de pontos de cada campeonato
recyclerViewRanking.addOnItemTouchListener(new RecyclerItemClickListener(getActivity(), recyclerViewRanking, new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
String idPosicao = idsRanking.get(position);
Log.v("idposicao", idPosicao);
Intent intent = new Intent(getContext(), ExibirRankingTime.class);
intent.putExtra("rankingSelecionado", idPosicao);
startActivity(intent);
}
@Override
public void onLongItemClick(View view, int position) {
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
}));
}
}
| [
"gustavo10ssouza@gmail.com"
] | gustavo10ssouza@gmail.com |
f1d677eb0bc7caa5439d493aa77f901349a42093 | 5f5f331a66764d45400552e36a7993455c64c611 | /src/wsPanFinder/OBJEstablishmentService.java | 9e0d4f0303c535fe321ca52b4a765cb89e8a1c5d | [] | no_license | mrwass/tech-summit-hackathon-panfinder | 2f4d9199b843849de46338f91271277e5c97b4b4 | b81ac05ce2072a51caae645c56fcf5a28ea82e29 | refs/heads/master | 2020-04-04T13:37:08.327732 | 2013-06-06T20:48:07 | 2013-06-06T20:48:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,265 | java | package wsPanFinder;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>
* Java class for OBJ_EstablishmentService complex type.
*
* <p>
* The following schema fragment specifies the expected content contained within
* this class.
*
* <pre>
* <complexType name="OBJ_EstablishmentService">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="serviceCode_FK" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="establishment_FK" type="{http://www.w3.org/2001/XMLSchema}int"/>
* <element name="selected" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "OBJ_EstablishmentService", propOrder = { "serviceCodeFK",
"establishmentFK", "selected" })
public class OBJEstablishmentService {
@XmlElement(name = "serviceCode_FK")
protected String serviceCodeFK;
@XmlElement(name = "establishment_FK")
protected int establishmentFK;
protected boolean selected;
/**
* Gets the value of the serviceCodeFK property.
*
* @return possible object is {@link String }
*
*/
public String getServiceCodeFK() {
return serviceCodeFK;
}
/**
* Sets the value of the serviceCodeFK property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setServiceCodeFK(String value) {
this.serviceCodeFK = value;
}
/**
* Gets the value of the establishmentFK property.
*
*/
public int getEstablishmentFK() {
return establishmentFK;
}
/**
* Sets the value of the establishmentFK property.
*
*/
public void setEstablishmentFK(int value) {
this.establishmentFK = value;
}
/**
* Gets the value of the selected property.
*
*/
public boolean isSelected() {
return selected;
}
/**
* Sets the value of the selected property.
*
*/
public void setSelected(boolean value) {
this.selected = value;
}
}
| [
"wsantiago@insolpr.com"
] | wsantiago@insolpr.com |
2495f716bbc5195cf2f6772a908fe60c0026a2ae | a30b6a9e9934cdfd2aaa4bd0970dfdaa05f53d12 | /Values Input/Minutes.java | 7160a25b627a4cf5f6ceccd7218665a126df9fad | [] | no_license | azeenali/Example | 7d5e5dfd3a9975680da91cc006fbf82d00b9c14d | d1d06b0abc19183c8fcb388e6a7804fc43e8f152 | refs/heads/master | 2020-10-02T05:03:55.973055 | 2019-12-12T22:42:01 | 2019-12-12T22:42:01 | 227,708,393 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 476 | java | import java.util.Scanner ;
public class Minutes
{
public static void main ( String [] args )
{
Scanner scan = new Scanner (System.in);
System.out.print (" Input the number of minutes : ");
double minutes = scan.nextDouble();
double years ;
double days ;
years = minutes / ( 60 * 24 * 365 ) ;
days = ( minutes / 60 / 24 ) % 365 ;
System.out.println ( minutes + " minutes is approximately " + years + " years and " +days + " days " );
}
} | [
"azeenali@hotmail.com"
] | azeenali@hotmail.com |
80818c196843e54662161c1a7f4713ba669836b9 | 43ab26a1d1c3b34b1e35a5d6ab348ad7c1f49af7 | /src/main/java/org/smart4j/framework/ConfigConstant.java | 0156b631996281295484feb7618bd8ca97dc55d0 | [] | no_license | liukunlong1093/template_web | ba95db359d3fab115ff3031f293bfe97af22abc8 | a2be29075825120d34268137242d076662133443 | refs/heads/master | 2021-09-11T15:30:53.344103 | 2018-04-09T09:27:56 | 2018-04-09T09:27:56 | 119,965,288 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 832 | java | package org.smart4j.framework;
/**
* 提供相关配置项常量
*
* @author liukl
* @date 2018/2/1
*/
public interface ConfigConstant {
/** MySQL驱动*/
String CONFIG_FILE="smart.properties";
/** MySQL驱动*/
String JDBC_DRIVER="smart.framework.jdbc.driver";
/** MySQL连接地址*/
String JDBC_URL="smart.framework.jdbc.url";
/** MySQL用户名*/
String JDBC_USERNAME="smart.framework.jdbc.username";
/** MySQL密码*/
String JDBC_PASSWORD="smart.framework.jdbc.password";
/** 项目的基础包名*/
String APP_BASE_PACKAGE="smart.framework.app.base_package";
/** JSP的基础路径*/
String APP_JSP_PATH="smart.framework.jsp_ptah";
/** 静态资源文件的基础路径,比如JS,CSS,图片等*/
String APP_ASSET_PATH="smart.framework.asset_path";
}
| [
"liukunlong1093@163.com"
] | liukunlong1093@163.com |
dd5e0c681e90d0a3b82cb058348cea7951b7242d | 5c1d9a18f16649de8c773f6bc07e8f8f9fc29d6c | /app/src/main/java/com/example/android/justjava/MainActivity.java | 6e919c647cc9ec26df301427efd626a895c95d4a | [] | no_license | VedranLeskovec/JustJava | 81992022b0608a0667857a09160ea39e0badf7c3 | 5b5dedabaf50d8255689ac922d93e3b721c0d8b7 | refs/heads/master | 2021-01-25T07:07:17.078886 | 2017-02-02T08:31:52 | 2017-02-02T08:31:52 | 80,707,599 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,039 | java | package com.example.android.justjava;
import android.content.Context;
import android.content.Intent;
import android.icu.text.NumberFormat;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import static android.R.attr.id;
/**
* This app displays an order form to order coffee.
*/
public class MainActivity extends AppCompatActivity {
int quantity=0;
int price=8;
boolean whipped=false;
boolean chocolate=false;
CheckBox whippedCream;
CheckBox chckCoko;
String name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
whippedCream= (CheckBox) findViewById(R.id.chck_whipped);
chckCoko= (CheckBox) findViewById(R.id.chck_choko);
}
/**
* This method is called when the order button is clicked.
*/
public void submitOrder(View view) {
int priceToDisplay=calculatePrice();
EditText editText= (EditText) findViewById(R.id.nameOfCustomer);
name= editText.getText().toString();
String poruka=getString(R.string.order_summary_name,name);
poruka+="\n"+getString(R.string.add_cream)+" "+whipped;
poruka+="\n"+getString(R.string.add_chocolate)+" "+chocolate;
poruka+="\n"+getString(R.string.quantity)+": "+quantity;
poruka+="\n"+getString(R.string.total)+": "+priceToDisplay+" "+getString(R.string.currency);
poruka+="\n"+getString(R.string.thank_you);
sendEmail(poruka, name);
//displayMessage(createOrderSummary(priceToDisplay,name));
}
public void sendEmail(String poruka, String name){
Intent intent= new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:"));
intent.putExtra(Intent.EXTRA_TEXT,poruka);
intent.putExtra(Intent.EXTRA_SUBJECT,"JustJava order for "+name);
if(intent.resolveActivity(getPackageManager())!=null){
startActivity(intent);
}
}
public int calculatePrice(){
int cijena=quantity*price;
if(whipped) cijena +=2*quantity;
if(chocolate) cijena +=3*quantity;
return cijena;
}
public void increment(View view){
if(quantity<100){
quantity++;
}else{
Context context= getApplicationContext();
CharSequence text="You cannot have more than 100 cups of coffee";
int duration= Toast.LENGTH_SHORT;
Toast toast= Toast.makeText(context,text,duration);
toast.show();
}
displayQuantity(quantity);
}
public void decrement(View view){
if(quantity>1){
quantity--;
}else{
Context context= getApplicationContext();
CharSequence text="You cannot have less than 1 cups of coffee";
int duration= Toast.LENGTH_SHORT;
Toast toast= Toast.makeText(context,text,duration);
toast.show();
}
displayQuantity(quantity);
}
public void hasWhipped(View view){
if(whippedCream.isChecked()) whipped=true;
else whipped=false;
}
public void hasChoko(View view){
if(chckCoko.isChecked()) chocolate=true;
else chocolate=false;
}
/**
* This method displays the given quantity value on the screen.
*/
private void displayQuantity(int number) {
TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view);
quantityTextView.setText("" + number);
}
/**
* This method displays the given text on the screen.
*/
/*private void displayMessage(String message){
TextView orderSummaryTextView=(TextView) findViewById(R.id.order_summary_text_view);
orderSummaryTextView.setText(message);
}*/
} | [
"vedran.leskovec@gmail.com"
] | vedran.leskovec@gmail.com |
682bc1e7e738a4076b010cc8e78596c440a55b23 | c961ac8c4aa6bd9bd27cff9de70a7cb5038d5104 | /src/test/java/ar/edu/ejempoci/web/rest/WithUnauthenticatedMockUser.java | c2f75f63a1a573b0eaa32333a70566d2d4bb096b | [] | no_license | fabiancontigliani/ejemploic | 1006ecfa710f66e16993d6a0c932ef88c25638f3 | 2c88e11a637a06954631a7e2e2145f08f1f3e630 | refs/heads/master | 2022-12-26T02:22:13.905463 | 2020-09-25T04:34:17 | 2020-09-25T04:34:17 | 298,399,474 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 987 | java | package ar.edu.ejempoci.web.rest;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.test.context.support.WithSecurityContext;
import org.springframework.security.test.context.support.WithSecurityContextFactory;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@WithSecurityContext(factory = WithUnauthenticatedMockUser.Factory.class)
public @interface WithUnauthenticatedMockUser {
class Factory implements WithSecurityContextFactory<WithUnauthenticatedMockUser> {
@Override
public SecurityContext createSecurityContext(WithUnauthenticatedMockUser annotation) {
return SecurityContextHolder.createEmptyContext();
}
}
}
| [
"fabian.contigliani@um.edu.ar"
] | fabian.contigliani@um.edu.ar |
1e78b36708f0dbd7c1528563ef37726ba2fdaa02 | 4fab44e9f3205863c0c4e888c9de1801919dc605 | /AL-Game/src/com/aionemu/gameserver/model/templates/housing/HousePart.java | c080019fcc7e4eb56ad53ea594cfe277cd895309 | [] | no_license | YggDrazil/AionLight9 | fce24670dcc222adb888f4a5d2177f8f069fd37a | 81f470775c8a0581034ed8c10d5462f85bef289a | refs/heads/master | 2021-01-11T00:33:15.835333 | 2016-07-29T19:20:11 | 2016-07-29T19:20:11 | 70,515,345 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,265 | java | /**
* This file is part of Aion-Lightning <aion-lightning.org>.
*
* Aion-Lightning is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Aion-Lightning is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License
* along with Aion-Lightning.
* If not, see <http://www.gnu.org/licenses/>.
*/
package com.aionemu.gameserver.model.templates.housing;
import com.aionemu.gameserver.model.templates.item.ItemQuality;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author Rolandas
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "house_part")
public class HousePart {
@XmlAttribute(name = "building_tags", required = true)
private List<String> buildingTags;
@XmlAttribute(required = true)
protected PartType type;
@XmlAttribute(required = true)
protected ItemQuality quality;
@XmlAttribute
protected String name;
@XmlAttribute(required = true)
protected int id;
@XmlTransient
protected Set<String> tagsSet = new HashSet<String>(1);
void afterUnmarshal(Unmarshaller u, Object parent) {
if (buildingTags == null) {
return;
}
for (String tag : buildingTags) {
tagsSet.add(tag);
}
buildingTags.clear();
buildingTags = null;
}
public PartType getType() {
return type;
}
public ItemQuality getQuality() {
return quality;
}
public String getName() {
return name;
}
public int getId() {
return id;
}
public Set<String> getTags() {
return tagsSet;
}
public boolean isForBuilding(Building building) {
return tagsSet.contains(building.getPartsMatchTag());
}
}
| [
"michelgorter@outlook.com"
] | michelgorter@outlook.com |
3440a7e6f1834e77898490353a7ae7b2d9980d61 | 8194355b473231b877b0ba262d0074459fc220bc | /Java_Programming/Question 복사본/src/chess/BoardTest.java | a1006f00054f164ce34ce8e5aca55602e53b6e01 | [] | no_license | daegeonkim/Study_Java | 47629f87417ef615b184b6bd7a70621daa03729a | 2c1ce917f8a217b98a7143de051f8a5fa6db1a64 | refs/heads/master | 2020-05-21T13:45:56.520132 | 2016-10-28T08:05:36 | 2016-10-28T08:05:36 | 60,679,611 | 3 | 1 | null | 2016-06-09T15:53:17 | 2016-06-08T07:56:52 | Java | UTF-8 | Java | false | false | 733 | java | package chess;
import pieces.Pawn;
import junit.framework.TestCase;
public class BoardTest extends TestCase{
final String firstPawnColor = "White";
final String secondPawnColor = "Black";
private Board board;
public void setUp(){
board = new Board();
}
public void testCreate(){
Board board2 = new Board();
Pawn firstPawn = new Pawn(firstPawnColor);
Pawn secondPawn = new Pawn(secondPawnColor);
Pawn thirdPawn = new Pawn();
board.enroll(firstPawn);
assertEquals(1, board.getNumberofPawns());
board.enroll(secondPawn);
assertEquals(2, board.getNumberofPawns());
board.enroll(thirdPawn);
assertEquals(3, board.getNumberofPawns());
new Integer("7");
//board.enroll(Integer);
}
} | [
"daegeonkim@icloud.com"
] | daegeonkim@icloud.com |
6aac60ed14dc5e384e5d60411efa6787b3cedaff | ad0659aa0d9232704732c4d42acb7001af74b4f4 | /src/skodb2/menu/Meny.java | 7bda06a63bd5a63f0d14a4ac8f4843766c8a025b | [] | no_license | ViktorKodet/Skodb2 | 6e6d8fb7eb18e1f24c338c06ac1a3eb815a5fea0 | 9e3cf9ac6a3a42767b6525f4818048ac1bcd4fd4 | refs/heads/master | 2023-03-07T15:42:52.894796 | 2021-02-23T14:03:01 | 2021-02-23T14:03:01 | 341,471,559 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 4,404 | java | package skodb2.menu;
import skodb2.db.Beställning;
import skodb2.db.Kund;
import skodb2.db.Repository;
import skodb2.db.Sko;
import java.sql.PreparedStatement;
import java.util.List;
import java.util.Scanner;
public class Meny {
Scanner scan = new Scanner(System.in);
Kund k;
Meny(){
loginMenu();
}
public void loginMenu(){
List<Kund> kundList = Repository.getAllCustomers();
String användarnamn;
String lösenord;
while(true){
boolean found = false;
System.out.println("Skriv in användarnamn:");
användarnamn = scan.nextLine();
System.out.println("Skriv in lösenord:");
lösenord = scan.nextLine();
for(Kund kund : kundList){
if (kund.getAnvändarnamn().equals(användarnamn) && kund.getLösenord().equals(lösenord)){
k = kund;
found = true;
mainMenu();
break;
}
}
if (!found) {
System.out.println("Användarnamn eller lösenord är fel, försök igen");
}
}
}
public void mainMenu(){
System.out.println("Välkommen " + k.getNamn());
String input;
Boolean inloggad = true;
while(inloggad){
System.out.println("Mata in en siffra i consolen för att välja alternativ:" +
"\n 1: Sko-menyn" +
"\n 2: Se din beställning" +
"\n 3: Slutför beställning" +
"\n 0: Logga ut");
input = scan.nextLine();
switch(input) {
case "1": shoeMenu();
break;
case "2": Repository.getActiveOrder(k).printAllShoes();
break;
case "3": Repository.finalizeOrder(Repository.getActiveOrderId(k));
break;
case "0": inloggad = false;
break;
default:
System.out.println("Felaktig inmatning, försök igen.");
break;
}
}
}
public void shoeMenu(){
List<Sko> skoList = Repository.getAllActiveShoes();
for(Sko sko : skoList){
System.out.println(sko.toStringForCustomer());
}
String input;
while(true) {
System.out.println("Mata in en siffra i consolen för att välja alternativ:" +
"\n 1: Beställ en sko" +
"\n 2: Betygsätt en sko" +
"\n 0: Tillbaka till huvudmenyn");
input = scan.nextLine();
switch (input) {
case "1": shoeOrderMenu();
break;
case "2": shoeRatingMenu();
break;
case "0": return;
default:
System.out.println("Felaktig inmatning, försök igen.");
break;
}
}
}
public void shoeOrderMenu(){
System.out.println("Mata in skons namn:");
String name = scan.nextLine();
System.out.println("Mata in skons färg:");
String color = scan.nextLine();
System.out.println("Mata in skons storlek:");
int size = scan.nextInt();
try{
Repository.addToCart(k.getId(), Repository.getActiveOrderId(k), Repository.getShoeId(name, color, size));
System.out.println("Sko tillagd.");
}catch (Exception e){
e.printStackTrace();
}
}
public void shoeRatingMenu(){
System.out.println("Mata in skons namn:");
String name = scan.nextLine();
System.out.println("Mata in skons färg:");
String color = scan.nextLine();
System.out.println("Mata in skons storlek:");
int size = scan.nextInt();
System.out.println("Mata in ditt betyg (1-10):");
int betyg = scan.nextInt();
System.out.println("Mata in din kommentar:");
String kommentar = scan.nextLine();
try{
Repository.rateShoe(Repository.getShoeId(name, color, size), k.getId(), betyg, kommentar);
}catch (Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) {
new Meny();
}
}
| [
"viktor.kodet@gmail.com"
] | viktor.kodet@gmail.com |
176ee8da19f95c78df74c42bd003000caed86213 | 3a877d99134c003b6ac267c2371c1461ecbeebd7 | /src/main/java/com/perez/jaroslav/compiler/components/statement/SelectionStatement.java | 3d873d85715d746151ea9ae39e1a99e9e8364809 | [] | no_license | jaros1024/C2AsmCompiler | d1cbf268716b94bcc92873ffc6d3811a19307914 | 8ba8fbf1d90c871560927303a3caed57e3c98439 | refs/heads/master | 2020-03-19T16:47:15.720432 | 2018-06-20T23:44:54 | 2018-06-20T23:44:54 | 136,730,047 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 316 | java | package com.perez.jaroslav.compiler.components.statement;
import com.perez.jaroslav.compiler.util.RandomString;
public abstract class SelectionStatement {
public String label = new RandomString(8).nextString();
public abstract String addJumpAfterExpression();
public abstract String addAfterLabel();
}
| [
"michal.sienczak@gmail.com"
] | michal.sienczak@gmail.com |
6bfc6ea7c07e2b7537f582f3213c68189ecf3bb2 | 2df74bb7b5ab5e55049223fa01937ef6f2d53697 | /Lab_old/src/IDAO/IUserDAO.java | 102906e7bf22c8f9b31781c3659ff27a40c6486a | [] | no_license | civinx/course-java-lab | ea7ca8d14ef8b1d326cfe20287630d26a66e4d29 | 3fb518841995d115f3e0b92ffc6e604e4dbdc7f4 | refs/heads/master | 2020-03-18T18:01:38.070264 | 2018-06-21T19:08:14 | 2018-06-21T19:08:14 | 135,067,039 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 448 | java | package IDAO;
import model.User;
import java.util.List;
public interface IUserDAO {
void add(User user) throws Exception;
void delete(String userName) throws Exception;
void delete(int userId) throws Exception;
void update(User user) throws Exception;
User query(String name) throws Exception;
User query(int userId) throws Exception;
List queryList(String userNick, int userType, int userState) throws Exception;
}
| [
"31501293@stu.zucc.edu.cn"
] | 31501293@stu.zucc.edu.cn |
d61582e8bb4ecc6cf10ae55c35d7f95a02f4146b | 81190399ea2048a65d17a9ed08ac3dc945b98580 | /src/main/java/com/jkinfo/taotao/service/impl/TestServiceImpl.java | 35d317c04fb1ac6a2696312bccb24a32ebc550b5 | [] | no_license | leochn/jkinfo-taotao | bb945bad31c81786a8a86ce1028ca07f0b6cfebb | 0c7bda35bd225113fc495ed1c2d02dc6d595492f | refs/heads/master | 2021-01-22T08:28:59.714969 | 2017-02-15T08:40:39 | 2017-02-15T08:40:39 | 81,904,824 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 409 | java | package com.jkinfo.taotao.service.impl;
import org.springframework.stereotype.Service;
import com.jkinfo.taotao.pojo.Test;
import com.jkinfo.taotao.service.TestService;
@Service
public class TestServiceImpl extends BaseServiceImpl<Test> implements TestService {
public Integer saveTest(Test item) {
item.setId(null);// 强制设置id为null,从数据库中自增长
return super.save(item);
}
}
| [
"appchn@163.com"
] | appchn@163.com |
71379627024ed0d1d8cfb61a2671f1ea832394b9 | 091bd426b780dd6b16f3d49b647b58ecd8c5ca0a | /Design-Patterns/src/builder/CorreiaChata.java | b13a9134592c1363d230ee639946d9a8ea3a98d2 | [] | no_license | jphrmartins/Design-Patterns | 0dbbbbb67141fbbbf4eeabf6856b0719a379511a | bc17709dfc962f56144c5e2f32041cc6433c1dee | refs/heads/master | 2020-03-15T23:51:19.628203 | 2018-05-07T21:03:09 | 2018-05-07T21:03:09 | 132,402,131 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 185 | java | package builder;
public class CorreiaChata implements Correia{
@Override
public double getTamanho() {
return 70;
}
@Override
public double getExpessura() {
return 10;
}
}
| [
"jphmartins@gmail.com"
] | jphmartins@gmail.com |
3c672682bbcbdd3f0cd73fa03cce3dc3943315a8 | 98c4c37cc9c5b7b0b60f1209380975edc878a8dc | /src/interfaces/Extension.java | 7e4ac3bd412c186b916caff0951e141a5e0b8403 | [] | no_license | jjjava/Samurai1.7 | 88e7705a23d5617fdac5047c4f14c1d72ac81e9b | f27ed50139bea209a2a8d5e05a7ed0caad756ab8 | refs/heads/master | 2016-09-10T22:08:32.527589 | 2014-11-19T16:43:40 | 2014-11-19T16:43:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,508 | java |
/*
* Extension.java
*
* Created on 26/01/2012, 23:25:37
*/
package interfaces;
import core.Core_Extension;
import java.awt.Toolkit;
import javax.swing.JOptionPane;
/**
*
* @author Hudson
*/
public class Extension extends javax.swing.JFrame {
private Core_Extension core;
public Extension() {
this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/res/srch_24.png")));
initComponents();
core = new Core_Extension(this);
this.setResizable(false);
this.setLocationRelativeTo(null);
this.setVisible(true);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
tf_ext = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
ta_desc = new javax.swing.JTextArea();
bt_ok = new javax.swing.JButton();
bt_canel = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Samurai Search Server 2011");
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Extensões de arquivos"));
jLabel1.setText("Nova extensão:");
tf_ext.setToolTipText("Digite a extensão sem o \".\"");
jLabel2.setText("Descrição:");
ta_desc.setColumns(20);
ta_desc.setRows(5);
ta_desc.setToolTipText("Limite de 512 caracteres.");
jScrollPane1.setViewportView(ta_desc);
bt_ok.setText("OK");
bt_ok.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_okActionPerformed(evt);
}
});
bt_canel.setText("Cancelar");
bt_canel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_canelActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
.addComponent(tf_ext, javax.swing.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(bt_ok, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(bt_canel)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tf_ext, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bt_ok)
.addComponent(bt_canel))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void bt_okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_okActionPerformed
if (tf_ext.getText().length() <= 0) {
JOptionPane.showMessageDialog(null,
"O campo \"Nova extensão\" está vazio.","Extensões",JOptionPane.ERROR_MESSAGE);
} else {
core.setExtension(tf_ext.getText(), ta_desc.getText());
}
}//GEN-LAST:event_bt_okActionPerformed
private void bt_canelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_canelActionPerformed
this.dispose();
}//GEN-LAST:event_bt_canelActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton bt_canel;
private javax.swing.JButton bt_ok;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea ta_desc;
private javax.swing.JTextField tf_ext;
// End of variables declaration//GEN-END:variables
}
| [
"hudson.sales@SPW9712NTW7P.sondait.com.br"
] | hudson.sales@SPW9712NTW7P.sondait.com.br |
ae780de27571ee4e5f5064689f2355db88c1a75a | 40665051fadf3fb75e5a8f655362126c1a2a3af6 | /eiswind-jackrabbit-orient/cf67f6fd3cb9b02a3b7350efcd62ece93fff5696/342/OrientPersistenceManager.java | 2d4451b0711636cae987f10e7c45a27e0d7a9c32 | [] | no_license | fermadeiral/StyleErrors | 6f44379207e8490ba618365c54bdfef554fc4fde | d1a6149d9526eb757cf053bc971dbd92b2bfcdf1 | refs/heads/master | 2020-07-15T12:55:10.564494 | 2019-10-24T02:30:45 | 2019-10-24T02:30:45 | 205,546,543 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 23,964 | java | /*
* (c) 2013 by Thomas Kratz
*/
package de.eiswind.jackrabbit.persistence.orient;
import com.orientechnologies.common.exception.OException;
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentPool;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.db.record.ODatabaseRecord;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.index.OIndex;
import com.orientechnologies.orient.core.index.OIndexManagerProxy;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OProperty;
import com.orientechnologies.orient.core.metadata.schema.OSchema;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.query.OQuery;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import org.apache.jackrabbit.core.fs.FileSystem;
import org.apache.jackrabbit.core.fs.FileSystemException;
import org.apache.jackrabbit.core.id.NodeId;
import org.apache.jackrabbit.core.id.PropertyId;
import org.apache.jackrabbit.core.persistence.PMContext;
import org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager;
import org.apache.jackrabbit.core.persistence.util.BLOBStore;
import org.apache.jackrabbit.core.persistence.util.BundleBinding;
import org.apache.jackrabbit.core.persistence.util.ErrorHandling;
import org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore;
import org.apache.jackrabbit.core.persistence.util.NodePropBundle;
import org.apache.jackrabbit.core.state.ChangeLog;
import org.apache.jackrabbit.core.state.ItemStateException;
import org.apache.jackrabbit.core.state.NoSuchItemStateException;
import org.apache.jackrabbit.core.state.NodeReferences;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.jcr.PropertyType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
* (C) 2013 by Thomas Kratz
* this is experimental code. if you reuse it, you do so at your own risk
* if you modify and/or or republish it, you must publish the original authors name with your source code.
*/
/**
* This is a generic persistence manager that stores the {@link NodePropBundle}s
* in an orient db datastore.
* <p>
*/
public class OrientPersistenceManager extends AbstractBundlePersistenceManager {
private static final int MIN_BLOB_SIZE = 0x1000;
/**
* the default logger.
*/
private static final Logger LOG = LoggerFactory.getLogger(OrientPersistenceManager.class);
private static final int POOL_MAX_SIZE = 50;
private static final int SB_CAPACITY = 35;
private static final int THIRTEEN = 13;
private static final int EIGHTEEN = 18;
private static final int TWENTYTHREE = 23;
private static final int EIGHT = 8;
/**
* flag indicating if this manager was initialized.
*/
private boolean initialized;
/**
* prefix for orient classnames.
*/
private String objectPrefix;
private String url;
private String user = "admin";
private String pass = "admin";
private boolean createDB = true;
private FileSystem itemFs;
private ODatabaseDocumentPool pool;
/**
* gets the db url.
*
* @return the url
*/
public final String getUrl() {
return url;
}
/**
* sets the db url.
*
* @param myUrl the url
*/
public final void setUrl(final String myUrl) {
this.url = myUrl;
}
/**
* gets the object prefix.
*
* @return the prefix
*/
public final String getSchemaObjectPrefix() {
return objectPrefix;
}
/**
* sets the object prefix.
*
* @param objectPrefix1 the prefix
*/
public final void setSchemaObjectPrefix(final String objectPrefix1) {
this.objectPrefix = objectPrefix1;
}
/**
* gets the user.
*
* @return the user
*/
public final String getUser() {
return user;
}
/**
* sets the user.
*
* @param user1 the user
*/
public final void setUser(final String user1) {
this.user = user1;
}
/**
* gets the password.
*
* @return the password
*/
public final String getPass() {
return pass;
}
/**
* sets the password.
*
* @param pass1 the password
*/
public final void setPass(final String pass1) {
this.pass = pass1;
}
/**
* the minimum size of a property until it gets written to the blob store.
*/
private int minBlobSize = MIN_BLOB_SIZE;
/**
* the bundle binding.
*/
private BundleBinding binding;
/**
* flag for error handling.
*/
private ErrorHandling errorHandling = new ErrorHandling();
/**
* the name of this persistence manager.
*/
private String name = super.toString();
private String bundleClassName;
private String refsClassName;
/**
* file system where BLOB data is stored.
*/
private OrientPersistenceManager.CloseableBLOBStore blobStore;
private int blobFSBlockSize;
private Map<NodeId, BundleMapper> documentMap = new HashMap<NodeId, BundleMapper>();
/**
* Sets the error handling behaviour of this manager. See {@link ErrorHandling}
* for details about the flags.
*
* @param myErrorHandling the error handling
*/
public final void setErrorHandling(final String myErrorHandling) {
this.errorHandling = new ErrorHandling(myErrorHandling);
}
/**
* Returns the error handling configuration of this manager.
*
* @return the error handling configuration of this manager
*/
public final String getErrorHandling() {
return errorHandling.toString();
}
/**
* {@inheritDoc}
*/
@Override
protected final BLOBStore getBlobStore() {
return blobStore;
}
/**
* should blob store be used.
*
* @return the if blob store is used
*/
public final boolean useLocalFsBlobStore() {
return blobFSBlockSize == 0;
}
private BinaryFileSystemHelper fileSystem;
/**
* {@inheritDoc}
*/
public final void init(final PMContext context) throws Exception {
if (initialized) {
throw new IllegalStateException("already initialized");
}
this.fileSystem = new BinaryFileSystemHelper(context.getFileSystem());
OGlobalConfiguration.STORAGE_KEEP_OPEN.setValue(false);
ODatabaseDocumentTx db;
db = new ODatabaseDocumentTx(url);
if (!db.exists()) {
db.create();
}
pool = new ODatabaseDocumentPool(url, "admin", "admin");
pool.setup(1, POOL_MAX_SIZE);
super.init(context);
// load namespaces
binding = new BundleBinding(errorHandling, blobStore, getNsIndex(), getNameIndex(), context.getDataStore());
binding.setMinBlobSize(minBlobSize);
this.name = context.getHomeDir().getName();
runWithDatabase(database -> {
OSchema schema = database.getMetadata().getSchema();
bundleClassName = getSchemaObjectPrefix() + name + "Bundle";
refsClassName = getSchemaObjectPrefix() + name + "Refs";
OClass bundleClass = schema.getClass(bundleClassName);
OClass vertexClass = schema.getClass("V");
if (bundleClass == null) {
bundleClass = schema.createClass(bundleClassName, vertexClass);
OProperty id = bundleClass.createProperty("uuid", OType.STRING);
id.createIndex(OClass.INDEX_TYPE.UNIQUE);
schema.save();
}
OClass refsClass = schema.getClass(refsClassName);
if (refsClass == null) {
refsClass = schema.createClass(refsClassName, vertexClass);
OProperty id = refsClass.createProperty("targetuuid", OType.STRING);
id.createIndex(OClass.INDEX_TYPE.UNIQUE);
schema.save();
}
return null;
});
initialized = true;
}
/**
* {@inheritDoc}
*/
@Override
public final synchronized void store(final ChangeLog changeLog) throws ItemStateException {
documentMap.clear();
runWithDatabase(db -> {
try {
super.store(changeLog);
} catch (ItemStateException e) {
LOG.error("jackrabbit", e);
}
return null;
});
documentMap.clear();
}
/**
* runs in an orient transaction.
*
* @param function the lamba.
* @return the result
*/
private Object runWithDatabase(final Function<ODatabaseRecord, Object> function) {
ODatabaseDocumentTx closeDB = null;
ODatabaseRecord database;
if (!ODatabaseRecordThreadLocal.INSTANCE.isDefined()) {
closeDB = pool.acquire(url, user, pass);
database = closeDB;
} else {
database = ODatabaseRecordThreadLocal.INSTANCE.get();
if (database.isClosed()) {
database.open(user, pass);
}
}
Object result = null;
try {
database.getTransaction().begin();
result = function.apply(database);
database.getTransaction().commit();
} catch (OException x) {
database.getTransaction().rollback();
LOG.error("DB error", x);
throw x;
} finally {
if (closeDB != null) {
closeDB.close();
}
}
return result;
}
/**
* {@inheritDoc}
*/
public final synchronized void close() throws Exception {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
try {
pool.close();
super.close();
} finally {
initialized = false;
}
}
/**
* {@inheritDoc}
*/
protected final NodePropBundle loadBundle(final NodeId id) throws ItemStateException {
try {
return (NodePropBundle) runWithDatabase(database -> {
String uuid = id.toString();
ODocument doc = loadBundleDoc(uuid);
if (doc == null) {
return null;
}
BundleMapper mapper = new BundleMapper(doc, database, bundleClassName, fileSystem);
NodePropBundle bundle = mapper.read();
return bundle;
});
} catch (Exception e) {
String msg = "failed to read bundle: " + id + ": " + e;
LOG.error(msg);
throw new ItemStateException(msg, e);
}
}
/**
* Creates the file path for the given node id that is
* suitable for storing node states in a filesystem.
*
* @param pbuf buffer to append to or <code>null</code>
* @param id the id of the node
* @return the buffer with the appended data.
*/
@Override
protected final StringBuffer buildNodeFilePath(final StringBuffer pbuf, final NodeId id) {
StringBuffer buf;
if (pbuf == null) {
buf = new StringBuffer();
} else {
buf = pbuf;
}
buildNodeFolderPath(buf, id);
buf.append('.');
buf.append(NODEFILENAME);
return buf;
}
/**
* Creates the file path for the given references id that is
* suitable for storing reference states in a filesystem.
*
* @param pbuf buffer to append to or <code>null</code>
* @param id the id of the node
* @return the buffer with the appended data.
*/
@Override
protected final StringBuffer buildNodeReferencesFilePath(final StringBuffer pbuf, final NodeId id) {
StringBuffer buf;
if (pbuf == null) {
buf = new StringBuffer();
} else {
buf = pbuf;
}
buildNodeFolderPath(buf, id);
buf.append('.');
buf.append(NODEREFSFILENAME);
return buf;
}
/**
* {@inheritDoc}
*/
@Override
protected final synchronized void storeBundle(final NodePropBundle bundle) throws ItemStateException {
runWithDatabase(database -> {
try {
ODocument vertex = null;
if (bundle.isNew()) {
vertex = new ODocument(bundleClassName);
} else {
vertex = loadBundleDoc(bundle.getId().toString());
}
if (vertex == null) {
throw new IllegalStateException("FATAL: Tried to update non existing bundle" +
bundle.getId().toString());
}
BundleMapper mapper = new BundleMapper(vertex, database, bundleClassName, fileSystem);
mapper.writePhase1(bundle);
vertex.save();
NodeId id = bundle.getId();
// store this for phase2
documentMap.put(id, mapper);
} catch (Exception e) {
String msg = "failed to write bundle: " + bundle.getId();
OrientPersistenceManager.LOG.error(msg, e);
}
return null;
});
}
/**
* {@inheritDoc}
*/
protected final synchronized void destroyBundle(final NodePropBundle bundle) throws ItemStateException {
runWithDatabase(database -> {
try {
String uuid = bundle.getId().toString();
ODocument result = loadBundleDoc(uuid);
if (result == null) {
throw new NullPointerException(uuid + " is missing");
}
cascadeDeleteToBlobs(result);
result.delete();
} catch (Exception e) {
String msg = "failed to delete bundle: " + bundle.getId();
OrientPersistenceManager.LOG.error(msg, e);
}
return null;
});
}
/**
* deletes referenced blobs.
*
* @param result the document
*/
private void cascadeDeleteToBlobs(final ODocument result) {
List<ODocument> propertyDocs = result.field("properties", OType.EMBEDDEDLIST);
if (propertyDocs != null) {
for (ODocument pDoc : propertyDocs) {
List<ODocument> valDocs = pDoc.field("properties", OType.EMBEDDEDLIST);
if (valDocs != null) {
for (ODocument vDoc : valDocs) {
int type = vDoc.field("type", OType.INTEGER);
if (PropertyType.BINARY == type) {
Boolean embedded = vDoc.field("embedded", OType.BOOLEAN);
if (!embedded) {
fileSystem.delete(vDoc.field("value", OType.STRING));
}
}
}
}
}
}
}
/**
* load a bundle doc.
*
* @param uuid the id
* @return the document
*/
private ODocument loadBundleDoc(final String uuid) {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
return (ODocument) runWithDatabase(database -> {
OIndexManagerProxy indexManager = database.getMetadata().getIndexManager();
OIndex<OIdentifiable> index = (OIndex<OIdentifiable>) indexManager.getIndex(bundleClassName + ".uuid");
OIdentifiable id = index.get(uuid);
ODocument doc = null;
if (id != null) {
doc = id.getRecord();
}
return doc;
});
}
/**
* loads references.
*
* @param targetuuid the id
* @return the refs doc
*/
private ODocument loadRefsDoc(final String targetuuid) {
return (ODocument) runWithDatabase(database -> {
OQuery<ODocument> query =
new OSQLSynchQuery<>("select from " + refsClassName + " WHERE targetuuid = '" + targetuuid + "'");
List<ODocument> result = database.query(query);
if (result.size() == 0) {
return null;
}
// result must be unique since we have the index
return result.get(0);
});
}
/**
* {@inheritDoc}
*/
public final synchronized NodeReferences loadReferencesTo(final NodeId targetId) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
NodeReferences result = (NodeReferences) runWithDatabase(database -> {
ODocument refsDoc = loadRefsDoc(targetId.toString());
if (refsDoc == null) {
return null;
}
NodeReferences refs = new NodeReferences(targetId);
List<ODocument> refDocs = refsDoc.field("refs", OType.EMBEDDEDLIST);
for (ODocument rDoc : refDocs) {
String value = rDoc.field("ref", OType.STRING);
refs.addReference(PropertyId.valueOf(value));
}
return refs;
});
if (result == null) {
throw new NoSuchItemStateException(targetId.toString());
}
return result;
}
/**
* {@inheritDoc}
*/
public final synchronized void store(final NodeReferences refs) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
runWithDatabase(database -> {
ODocument refsDoc = loadRefsDoc(refs.getTargetId().toString());
if (refsDoc == null) {
refsDoc = new ODocument(refsClassName);
refsDoc.field("targetuuid", refs.getTargetId().toString(), OType.STRING);
}
List<ODocument> refDocs = new ArrayList<ODocument>();
for (PropertyId propId : refs.getReferences()) {
ODocument refDoc = database.newInstance();
refDoc.field("ref", propId.toString(), OType.STRING);
refDocs.add(refDoc);
}
refsDoc.field("refs", refDocs, OType.EMBEDDEDLIST);
refsDoc.save();
return null;
});
}
/**
* {@inheritDoc}
*/
public final synchronized void destroy(final NodeReferences refs) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
runWithDatabase(database -> {
ODocument doc = loadRefsDoc(refs.getTargetId().toString());
if (doc != null) {
doc.delete();
}
return null;
});
}
/**
* {@inheritDoc}
*/
public final synchronized boolean existsReferencesTo(final NodeId targetId) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
return (Boolean) runWithDatabase(database -> {
ODocument doc = loadRefsDoc(targetId.toString());
return doc != null;
});
}
/**
* {@inheritDoc}
*/
public final String toString() {
return name;
}
/**
* should the db be created?
*
* @param pcreateDB wether the db should be created.
*/
public final void setCreateDB(final boolean pcreateDB) {
this.createDB = pcreateDB;
}
/**
* {@inheritDoc}
*/
public final List<NodeId> getAllNodeIds(final NodeId bigger, final int maxCount) throws ItemStateException {
ArrayList<NodeId> list = new ArrayList<NodeId>();
try {
getListRecursive(list, "", bigger, maxCount);
return list;
} catch (FileSystemException e) {
String msg = "failed to read node list: " + bigger + ": " + e;
LOG.error(msg);
throw new ItemStateException(msg, e);
}
}
/**
* {@inheritDoc}
*/
protected final NodeId getIdFromFileName(final String fileName) {
StringBuffer buff = new StringBuffer(SB_CAPACITY);
if (!fileName.endsWith("." + NODEFILENAME)) {
return null;
}
for (int i = 0; i < fileName.length(); i++) {
char c = fileName.charAt(i);
if (c == '.') {
break;
}
if (c != '/') {
buff.append(c);
int len = buff.length();
if (len == EIGHT || len == THIRTEEN || len == EIGHTEEN || len == TWENTYTHREE) {
buff.append('-');
}
}
}
return new NodeId(buff.toString());
}
/**
* gets a list from the filesystem.
*
* @param list the list
* @param path the path
* @param bigger for recusrion
* @param maxCount up to max?
* @throws FileSystemException on fs errors
*/
private void getListRecursive(final ArrayList<NodeId> list, final String path,
final NodeId bigger, final int maxCount) throws FileSystemException {
if (maxCount > 0 && list.size() >= maxCount) {
return;
}
String[] files = itemFs.listFiles(path);
Arrays.sort(files);
for (int i = 0; i < files.length; i++) {
String f = files[i];
NodeId n = getIdFromFileName(path + FileSystem.SEPARATOR + f);
if (n == null) {
continue;
}
if (bigger != null && bigger.toString().compareTo(n.toString()) >= 0) {
continue;
}
list.add(n);
if (maxCount > 0 && list.size() >= maxCount) {
return;
}
}
String[] dirs = itemFs.listFolders(path);
Arrays.sort(dirs);
for (int i = 0; i < dirs.length; i++) {
getListRecursive(list, path + FileSystem.SEPARATOR + dirs[i], bigger, maxCount);
}
}
/**
* Helper interface for closeable stores.
*/
protected interface CloseableBLOBStore extends BLOBStore {
/**
* close this store.
*/
void close();
}
/**
* own implementation of the filesystem blob store that uses a different
* blob-id scheme.
*/
private class FSBlobStore extends FileSystemBLOBStore implements OrientPersistenceManager.CloseableBLOBStore {
private FileSystem fs;
/**
* init te blobstore.
*
* @param pfs the underlying filesystem.
*/
public FSBlobStore(final FileSystem pfs) {
super(pfs);
this.fs = pfs;
}
/**
* create an id.
*
* @param id the id
* @param index the index.
* @return the blob path,
*/
public String createId(final PropertyId id, final int index) {
return buildBlobFilePath(null, id, index).toString();
}
/**
* {@inheritDoc}
*/
public final void close() {
try {
fs.close();
fs = null;
} catch (Exception e) {
LOG.warn("close blob stors", e);
}
}
}
}
| [
"fer.madeiral@gmail.com"
] | fer.madeiral@gmail.com |
a7c54d1e2ca513914fb99d8c7943022d1445c0d2 | 2ef7ec5e47bda778ee89991e355b683eef8961d4 | /src/main/java/com/aimprosoft/departments/controller/ListEmployeeOfDepartmentController.java | 2a4e96a5b1a8eefe703b769c2d9387c512064087 | [] | no_license | Maksik-Masya/departments | fde3502ed9d2db42d8f76c8def3cfa01b271ee07 | b43caa5949d22581cd9a5c27df52bbc9686a7eb3 | refs/heads/master | 2021-01-01T05:25:56.964922 | 2016-04-22T09:06:25 | 2016-04-22T09:06:25 | 56,794,340 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,965 | java | package com.aimprosoft.departments.controller;
/**
* Created on 06.04.16.
*/
import com.aimprosoft.departments.model.Department;
import org.hibernate.HibernateException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import com.aimprosoft.departments.service.DepartmentService;
import com.aimprosoft.departments.service.EmployeeService;
import com.aimprosoft.departments.utils.StringFieldConverter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@Component(value = "/listEmployee")
public class ListEmployeeOfDepartmentController implements InternalController {
@Autowired
private DepartmentService departmentService;
@Autowired
private EmployeeService employeeService;
@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Integer id_department = StringFieldConverter.convertStringToInteger(request.getParameter("departmentId"));
try {
Department department = departmentService.getDepartmentById(id_department);
String department_name = department.getName();
//List employeeList = department.getEmployees();
List employeeList = employeeService.getEmployeeByDepartmentId(department);
request.setAttribute("id_department", id_department);
request.setAttribute("employees", employeeList);
request.setAttribute("department_name", department_name);
request.setAttribute("departmentId", id_department);
request.getRequestDispatcher("jsp/listEmployee.jsp").forward(request, response);
} catch (HibernateException e) {
response.sendRedirect("/error");
}
}
}
| [
"maksimborodenko@mail.ru"
] | maksimborodenko@mail.ru |
283afe7af7bf4dbae3bbf0c4703c9c0044facd59 | c354bf62c6e936d9753a6f0c5149a3649459461f | /01-cloud-demo/order-service/src/main/java/com/web/order/web/OrderController.java | 74f988e4b7496e4505e48ee478f9b2f3aa6f7d53 | [] | no_license | Eascaty/SpringCloud- | d5e83914504788d7871654cd23716b8df814ab8a | 7806399bdc91689cbd42ec0a2f725d0cce54173b | refs/heads/main | 2023-08-25T08:38:20.105991 | 2021-10-20T06:36:48 | 2021-10-20T06:36:48 | 402,252,264 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 748 | java | package com.web.order.web;
import com.web.order.pojo.Order;
import com.web.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("order")
public class OrderController {
@Autowired
private OrderService orderService;
@GetMapping("{orderId}")
public Order queryOrderByUserId(@PathVariable("orderId") Long orderId) {
// 根据id查询订单并返回
return orderService.queryOrderById(orderId);
}
}
| [
"63639459+Eascaty@users.noreply.github.com"
] | 63639459+Eascaty@users.noreply.github.com |
bcc2502c5a9ee206fb76f57a6bf3c8f2ccd26f8e | d1e2c6b87e6d3d62a40d5c4bac6bd92c2e041392 | /tree/src/binarytree/ExpressionTree.java | 683851a7ffda90dc8b9abde4073410f0473b6d75 | [] | no_license | kamaleshpati/dspractice | 8b2dd4ad28587dfeadca8ed787384a62b4d71622 | 26df813c31d3d6fed7d73c9b58631dad2e00c26b | refs/heads/master | 2021-07-20T12:30:42.653254 | 2021-05-01T15:28:02 | 2021-05-01T15:28:02 | 248,203,666 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,262 | java | package binarytree;
import java.util.Stack;
public class ExpressionTree {
static boolean isOperator(char c) {
if (c == '+' || c == '-'
|| c == '*' || c == '/'
|| c == '^') {
return true;
}
return false;
}
static void inorder(Tree t) {
if (t != null) {
inorder(t.left);
System.out.print(t.value + " ");
inorder(t.right);
}
}
static Tree constructTree(char postfix[]) {
Stack<Tree> st = new Stack();
Tree t, t1, t2;
for (int i = 0; i < postfix.length; i++) {
if (!isOperator(postfix[i])) {
t = new Tree(postfix[i]);
st.push(t);
} else
{
t = new Tree(postfix[i]);
t1 = st.pop();
t2 = st.pop();
t.right = t1;
t.left = t2;
st.push(t);
}
}
t = st.peek();
st.pop();
return t;
}
public static void main(String args[]) {
String postfix = "ab+ef*g*-";
char[] charArray = postfix.toCharArray();
Tree root = constructTree(charArray);
inorder(root);
}
}
| [
"k97pati@gmail.com"
] | k97pati@gmail.com |
9b0359fb0a315a0a77f57a85cc8af51d022ba168 | b14bb46647bbc24ba697c81919e5a6b0f27eadc0 | /Java-DS/src/main/java/com/akshay/stack/ImplementStackUsingTwoQueue.java | 2298b151bcd654e0f762f05c7a128ee558fc5942 | [] | no_license | luciferMF/java | 3a5e04e242917c5ed5d9d9d5bb3fbdb7e10c9395 | fbb4f651827d62991a8ffc5a6956391d105abc85 | refs/heads/master | 2023-04-23T05:48:16.838705 | 2021-05-03T15:26:10 | 2021-05-03T15:26:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 804 | java | package com.akshay.stack;
import java.util.LinkedList;
import java.util.Queue;
public class ImplementStackUsingTwoQueue {
static Queue<Integer> queue = new LinkedList<Integer>();
private static Integer pop() {
if (queue.isEmpty()) {
System.out.println("Stack is Empty");
return null;
}
int x = queue.poll();
System.out.println(x);
return x;
}
//While push just add new element in queue. It should
private static void push(int value) {
int size = queue.size();
queue.add(value);
for (int i = 0; i < size; i++) {
int x = queue.poll();
queue.add(x);
}
}
public static void main(String[] args) {
push(4);
push(8);
push(9);
push(12);
push(14);
push(16);
push(19);
pop();
pop();
pop();
pop();
pop();
pop();
pop();
}
}
| [
"akshay243601@gmail.com"
] | akshay243601@gmail.com |
3694678ed817369bcc3508ddb989fb51fc2f8b97 | 954db3d02548bb0cf5272167849795bd3fd41575 | /src/main/java/org/casadocodigo/loja/models/Preco.java | 2b0b1e1e31ff10e4b26daedb733ec88b711194f2 | [] | no_license | jorgecmb/casadocodigo | cc5c549be3367a09e94b1962fccae309029fdb0f | 3168b50fa20cb36f74afb24b211a9f7df9ae2908 | refs/heads/master | 2021-01-19T04:22:24.739243 | 2016-08-06T11:11:47 | 2016-08-06T11:11:47 | 62,679,400 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 519 | java | package org.casadocodigo.loja.models;
import java.math.BigDecimal;
import javax.persistence.Embeddable;
@Embeddable
public class Preco {
private BigDecimal valor;
private TipoPreco tipo;
public BigDecimal getValor() {
return valor;
}
public void setValor(BigDecimal valor) {
this.valor = valor;
}
public TipoPreco getTipo() {
return tipo;
}
public void setTipo(TipoPreco tipo) {
this.tipo = tipo;
}
@Override
public String toString() {
return this.tipo.name() + " - " + this.valor;
}
}
| [
"jorgecmb@Mac-mini-de-Jorge-Neto.local"
] | jorgecmb@Mac-mini-de-Jorge-Neto.local |
a00e3170502321e5c7cee5714fa6f2ad465bb3aa | 6fd7b6dee9fb14f2cac2386e56fec30219853977 | /src/main/java/org/doneta/util/url/UrlUtils.java | 7305a4e733d8e98cc5ff9e13e7a896b8546003d5 | [
"Apache-2.0"
] | permissive | Hypnusds/dnwa | 55fe6d8bc3de799d09e9cfe1ba66dd0a6f59a23e | e118092ef092f32757caaebc024a3e46b5242dcd | refs/heads/master | 2020-12-30T10:37:00.840260 | 2011-02-25T01:26:15 | 2011-02-25T01:26:15 | 1,409,153 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 631 | java | package org.doneta.util.url;
import java.net.URI;
import java.net.URISyntaxException;
/**
* UrlUtils URL处理的工具类
* @author Hypnusds
*/
public class UrlUtils {
/**
* 相对路径转换绝对路径 <br>
* 注意:请补全/
* @param realPath 当前页面的URL 如:http://www.google.com/
* @param relatedPath 相对路径
* @return 绝对路径
* @throws URISyntaxException URL 异常
*/
public static String relatedToAbs(String realPath, String relatedPath) throws URISyntaxException {
URI base = new URI(realPath);
URI abs = base.resolve(relatedPath);
return abs.toASCIIString();
}
}
| [
"Hypnusds@Gmail.com"
] | Hypnusds@Gmail.com |
c3dfa562dd4c8180375f967dec8b78d84e7bd44e | ca9371238f2f8fbec5f277b86c28472f0238b2fe | /src/mx/com/kubo/rest/model/LoginMembership.java | ce9fbeb18ac4bbbf1e803d554e6cc31380e27984 | [] | no_license | ocg1/kubo.portal | 64cb245c8736a1f8ec4010613e14a458a0d94881 | ab022457d55a72df73455124d65b625b002c8ac2 | refs/heads/master | 2021-05-15T17:23:48.952576 | 2017-05-08T17:18:09 | 2017-05-08T17:18:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,160 | java | package mx.com.kubo.rest.model;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class LoginMembership
{
private String area;
private String prospectus_id;
private String full_name;
private String last_login_attempt;
private String password_ENABLED;
public LoginMembership(){}
public String getProspectus_id() {
return prospectus_id;
}
public void setProspectus_id(String prospectus_id) {
this.prospectus_id = prospectus_id;
}
public String getFull_name() {
return full_name;
}
public void setFull_name(String full_name) {
this.full_name = full_name;
}
public String getLast_login_attempt() {
return last_login_attempt;
}
public void setLast_login_attempt(String last_login_attempt) {
this.last_login_attempt = last_login_attempt;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getPassword_ENABLED() {
return password_ENABLED;
}
public void setPassword_ENABLED(String password_ENABLED) {
this.password_ENABLED = password_ENABLED;
}
}
| [
"damian.tapia.nava@gmail.com"
] | damian.tapia.nava@gmail.com |
f8840d6660ab6c2166d85e658429c6c96e200e86 | e8df0acb9c027d43b106ab4e1e5568afd0fa7db1 | /src/test/java/com/slowed/reddity/ReddityApplicationTests.java | c8e1203a76f3dca9342bb1e7fb9f413c35a66bf5 | [] | no_license | root-marco/reddity-server | ef56d1908496bbf7c2c953f2adbd12a6d496602d | 11d72767fa1f163bc896cd2c454b429b4e449e88 | refs/heads/master | 2023-08-05T22:38:02.608871 | 2021-09-09T14:52:20 | 2021-09-09T14:52:20 | 399,202,289 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 211 | java | package com.slowed.reddity;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ReddityApplicationTests {
@Test
void contextLoads() {
}
}
| [
"rootslowed@gmail.com"
] | rootslowed@gmail.com |
e40993aaf1ecb67d80ae527954206589295c32ec | dbafd7a23b7c61a938c8d663cf1ecad9299b379a | /src/main/java/com/backend/ppinfo/exception/error/GeneralExceptionMessage.java | 782a99fa8fd303278fe423d4959df6d2a367adff | [] | no_license | breno-cn/ppinfo | 22cd3f8d4db06a7f0731da6963551ec8dcb338db | e803988d19754058a52a5a917fd2f3a7b909a274 | refs/heads/master | 2023-08-24T07:08:34.955129 | 2021-11-01T23:54:16 | 2021-11-01T23:54:16 | 413,616,370 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 230 | java | package com.backend.ppinfo.exception.error;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class GeneralExceptionMessage {
private ErrorCode errorCode;
private String message;
}
| [
"breno.cn@hotmail.com"
] | breno.cn@hotmail.com |
0fb66fd679d1544afcbbfe544fe6fbd1a204495d | 04b5d81e44476390446d9e9dba65005bdbbf5629 | /springboot/springboot_quick3/src/main/java/app/SpringbootQuick3Application.java | 90cda537b4c5f2b0307da9227740ec14a48508a6 | [] | no_license | biasbug/study | d04ba9f8db690865f92c67f806d8bfa983a29330 | c90f943758b7ead1b943f38d463500c32930988d | refs/heads/master | 2022-06-29T20:26:33.345680 | 2020-04-07T05:20:35 | 2020-04-07T05:20:35 | 251,166,933 | 0 | 0 | null | 2022-06-21T03:07:04 | 2020-03-30T00:53:51 | Java | UTF-8 | Java | false | false | 468 | java | package app;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan({"controller"})
public class SpringbootQuick3Application {
public static void main(String[] args) {
SpringApplication.run(SpringbootQuick3Application.class, args);
}
}
| [
"xuhongda_code@163.com"
] | xuhongda_code@163.com |
8b1b056f8d0d1e4bfee3fc9b1fb47ff888d1f17b | e362b5819a322b8f32e376625391da92d30e536a | /src/com/zelic/tabfragment/Fragment02.java | 4d02af5dadaa28eb17dc1d4d0db18b9fb077ff61 | [] | no_license | zelic91/tabfragment | 4312079f833fe99d533347265abe9cfc8ffa88bf | cddb971f8deabda6bfe5439b6f43d433d8699c28 | refs/heads/master | 2020-04-21T21:33:15.882776 | 2013-07-09T14:21:01 | 2013-07-09T14:21:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 465 | java | package com.zelic.tabfragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Fragment02 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
return inflater.inflate(R.layout.fragment_tab02, container, false);
}
}
| [
"zelic91@gmail.com"
] | zelic91@gmail.com |
0bd947c495694507cdb707d0dc9585577caf9540 | 8060804e892d0e1f1e57308ab3f7f25e2a617277 | /version14/blueJk/src/main/java/cn/blue/common/other/ExportEnum.java | 4006599fa24a3ff437f73b4ef7bf301c04ab147f | [] | no_license | huachengzhou/jkblue | fd97df354314cae511f73105451fb71c9ec37546 | 673d15d2aa25767931353fb7ae6c85bcb6106f24 | refs/heads/master | 2021-09-08T00:29:14.742207 | 2018-03-04T10:08:19 | 2018-03-04T10:08:19 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 248 | java | package cn.blue.common.other;
public enum ExportEnum {
EXPORT_ENUM_Start("1"), EXPORT_ENUM_END("0");
private String var;
ExportEnum(String var) {
this.var = var;
}
public String getVar() {
return var;
}
}
| [
"noatnu@163.com"
] | noatnu@163.com |
5aee90d6ba647823ceacb6f7963cfe0346cee70e | 164aee9acdadc303699136486458c5c43367c71e | /Yeremeiev_Rodion_Kyiv_HT3/src/main/java/pageobject/pages/AllInOnePersonalComputersPage.java | 654aaa2492e0aa92782331ebde39ffab271d7bfd | [] | no_license | RodionYeremeiev/AQA-TA-Home-Tasks | 3818b7bd08a7c14906b1df44f6d56ee0aa881d97 | a263bc0dd37a5dc7d043f07dc20c34e9ee8fad72 | refs/heads/main | 2023-05-17T08:06:44.173998 | 2021-06-14T11:01:32 | 2021-06-14T11:01:32 | 371,435,815 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 219 | java | package pageobject.pages;
import org.openqa.selenium.WebDriver;
public class AllInOnePersonalComputersPage extends BasePage{
public AllInOnePersonalComputersPage(WebDriver driver) {
super(driver);
}
}
| [
"rodion.ieremeiev@gmail.com"
] | rodion.ieremeiev@gmail.com |
99982b8a9f11216ceb0cbcf67436d59dd1dfffc2 | 0f1bda97bb4e3ffc28c0ff2841fe490977b73650 | /src/main/java/com/tailors/trynewmenu/infrastructure/resourcemanagement/s3/S3FileUploader.java | c7875884329feac1da3809545bade4a419ec8518 | [] | no_license | kyowonkim/Trynewmenu | b2a79e615c0d11610114cea862819c427a598106 | 9d8bf4a857c62574d595ab2129c9675d608297ba | refs/heads/master | 2020-07-27T09:44:33.410200 | 2019-06-25T02:18:22 | 2019-06-25T02:18:22 | 209,049,289 | 1 | 0 | null | 2019-09-17T12:34:33 | 2019-09-17T12:34:33 | null | UTF-8 | Java | false | false | 2,522 | java | package com.tailors.trynewmenu.infrastructure.resourcemanagement.s3;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.PutObjectRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Optional;
@Slf4j
@RequiredArgsConstructor
@Component
public class S3FileUploader {
private final AmazonS3 s3Client;
@Value("${cloud.aws.s3.bucket}")
private String bucket;
public String upload(MultipartFile multipartFile, String dirName) throws IOException {
File uploadFile = convert(multipartFile)
.orElseThrow(() -> new IllegalArgumentException("MultipartFile -> File로 전환이 실패했습니다."));
return upload(uploadFile, dirName);
}
private String upload(File uploadFile, String dirName) {
String fileName = dirName + "/" + uploadFile.getName();
String uploadImageUrl = putS3(uploadFile, fileName);
removeNewFile(uploadFile);
return uploadImageUrl;
}
private String putS3(File uploadFile, String fileName) {
s3Client.putObject(new PutObjectRequest(bucket, fileName, uploadFile).withCannedAcl(CannedAccessControlList.PublicRead));
return s3Client.getUrl(bucket, fileName).toString();
}
private void removeNewFile(File targetFile) {
if (targetFile.delete()) {
log.info("파일이 삭제되었습니다.");
} else {
log.info("파일이 삭제되지 못했습니다.");
}
}
private Optional<File> convert(MultipartFile file) throws IOException {
if (file == null) {
throw new IllegalArgumentException("File argument must not be null");
}
File convertFile = new File(file.getOriginalFilename());
if(convertFile.createNewFile()) {
try (FileOutputStream fos = new FileOutputStream(convertFile)) {
fos.write(file.getBytes());
}
return Optional.of(convertFile);
}
return Optional.empty();
}
}
| [
"syubsyubboy@gmail.com"
] | syubsyubboy@gmail.com |
d580a77e73b7532688c7ae31fb25f0f966decca4 | be73270af6be0a811bca4f1710dc6a038e4a8fd2 | /crash-reproduction-moho/results/MATH-51b-6-19-NSGA_II-LineCoverage:ExceptionType:StackTraceSimilarity/org/apache/commons/math/analysis/solvers/BaseSecantSolver_ESTest.java | 3b9fe7ab56b46df8a4ffd546fc585bfe143e74b2 | [] | no_license | STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application | cf118b23ecb87a8bf59643e42f7556b521d1f754 | 3bb39683f9c343b8ec94890a00b8f260d158dfe3 | refs/heads/master | 2022-07-29T14:44:00.774547 | 2020-08-10T15:14:49 | 2020-08-10T15:14:49 | 285,804,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,055 | java | /*
* This file was automatically generated by EvoSuite
* Tue Jan 21 22:02:47 UTC 2020
*/
package org.apache.commons.math.analysis.solvers;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.evosuite.runtime.EvoAssertions.*;
import org.apache.commons.math.analysis.SinFunction;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.analysis.solvers.PegasusSolver;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;
@RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true)
public class BaseSecantSolver_ESTest extends BaseSecantSolver_ESTest_scaffolding {
@Test(timeout = 4000)
public void test0() throws Throwable {
PegasusSolver pegasusSolver0 = new PegasusSolver(0.0, 0.0, 0.0);
SinFunction sinFunction0 = new SinFunction();
// Undeclared exception!
pegasusSolver0.solve(4, (UnivariateRealFunction) sinFunction0, (-1245.11383374), 540.459599, 1996.4512);
}
}
| [
"pouria.derakhshanfar@gmail.com"
] | pouria.derakhshanfar@gmail.com |
e0970610036cfa9f478c916c2cb8c0cb0c7ad612 | c9613eddf139b64111878b60f467c451f78b92b7 | /carRent/src/aplpication/Program.java | 82bc831ee2e46c30a5ea8d0e2821933e7998dd91 | [] | no_license | luizleandrini/carRent | 0b5e2d1b399c78c49ccc502625cff8f0f2f08331 | 591ca9f9eb9f86bfa85c38aed556c86eafc1d82a | refs/heads/main | 2020-12-29T07:45:27.610644 | 2020-11-27T13:20:34 | 2020-11-27T13:20:34 | 238,516,063 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 1,532 | java | package aplpication;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
import model.entities.CarRental;
import model.entities.Vehicle;
import model.services.BrazilTaxService;
import model.services.RentalService;
public class Program {
public static void main(String[] args) throws ParseException {
Scanner sc = new Scanner(System.in);
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyy HH:ss");
System.out.println("Entre com os dados da locação: ");
System.out.print("Modelo do Carro: ");
String carModel = sc.nextLine();
System.out.print("Pickup (dd/MM/yyyy hh:ss): ");
Date start = sdf.parse(sc.nextLine());
System.out.print("Return (dd/MM/yyyy hh:ss): ");
Date finish = sdf.parse(sc.nextLine());
CarRental cr = new CarRental(start, finish, new Vehicle(carModel));
System.out.print("Entre com o preço por hora: ");
double pricePerHour = sc.nextDouble();
System.out.print("Preço por dia: ");
double pricePerDay = sc.nextDouble();
RentalService rentalService = new RentalService(pricePerDay, pricePerHour, new BrazilTaxService());
rentalService.processInvoice(cr);
System.out.println("Invoice");
System.out.println("Basic Payment: " + String.format("%.2f", cr.getInvoice().getBasicPayment()));
System.out.println("Tax: " + String.format("%.2f", cr.getInvoice().getTax()));
System.out.println("Total Payment: " + String.format("%.2f", cr.getInvoice().getTotalPayment()));
sc.close();
}
}
| [
"guilhermeleandrini@hotmail.com"
] | guilhermeleandrini@hotmail.com |
3934cdd6f957de09f4ecaac951400655cc4212d9 | e58a8e0fb0cfc7b9a05f43e38f1d01a4d8d8cf1f | /WidgetWarren/src/com/puttysoftware/widgetwarren/objects/FadingWall.java | 5a04484975789b811869298bb987a0424f8e6c27 | [
"Unlicense"
] | permissive | retropipes/older-java-games | 777574e222f30a1dffe7936ed08c8bfeb23a21ba | 786b0c165d800c49ab9977a34ec17286797c4589 | refs/heads/master | 2023-04-12T14:28:25.525259 | 2021-05-15T13:03:54 | 2021-05-15T13:03:54 | 235,693,016 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,740 | java | /* WidgetWarren: A Maze-Solving Game
Copyright (C) 2008-2014 Eric Ahnell
Any questions should be directed to the author via email at: products@puttysoftware.com
*/
package com.puttysoftware.widgetwarren.objects;
import com.puttysoftware.widgetwarren.Application;
import com.puttysoftware.widgetwarren.WidgetWarren;
import com.puttysoftware.widgetwarren.generic.GenericWall;
import com.puttysoftware.widgetwarren.maze.MazeConstants;
public class FadingWall extends GenericWall {
// Fields
private static final int SCAN_LIMIT = 3;
// Constructors
public FadingWall() {
super();
this.activateTimer(1);
}
@Override
public void timerExpiredAction(final int dirX, final int dirY) {
// Disappear if the player is close to us
boolean scanResult = false;
final Application app = WidgetWarren.getApplication();
final int pz = app.getGameManager().getPlayerManager()
.getPlayerLocationZ();
final int pl = MazeConstants.LAYER_OBJECT;
final String targetName = new Player().getName();
scanResult = app.getMazeManager().getMaze().radialScan(dirX, dirY, pz,
pl, FadingWall.SCAN_LIMIT, targetName);
if (scanResult) {
app.getGameManager().morph(new Empty(), dirX, dirY, pz);
}
this.activateTimer(1);
}
@Override
public String getName() {
return "Fading Wall";
}
@Override
public String getGameName() {
return "Wall";
}
@Override
public String getPluralName() {
return "Fading Walls";
}
@Override
public String getDescription() {
return "Fading Walls disappear when you get close to them.";
}
}
| [
"eric.ahnell@puttysoftware.com"
] | eric.ahnell@puttysoftware.com |
1ae9648f4d076a68cdb22b87b6e1fcd3b3cc8ea0 | 0f1f95e348b389844b916c143bb587aa1c13e476 | /bboss-core-entity/src-asm/bboss/org/objectweb/asm/commons/SerialVersionUIDAdder.java | bdb0d771886ab93ba6527842c4a3850a2cde85c0 | [
"Apache-2.0"
] | permissive | bbossgroups/bboss | 78f18f641b18ea6dd388a1f2b28e06c4950b07c3 | 586199b68a8275aa59b76af10f408fec03dc93de | refs/heads/master | 2023-08-31T14:48:12.040505 | 2023-08-29T13:05:46 | 2023-08-29T13:05:46 | 2,780,369 | 269 | 151 | null | 2016-04-04T13:25:20 | 2011-11-15T14:01:02 | Java | UTF-8 | Java | false | false | 20,482 | java | /***
* ASM: a very small and fast Java bytecode manipulation framework
* Copyright (c) 2000-2011 INRIA, France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
package bboss.org.objectweb.asm.commons;
import java.io.ByteArrayOutputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import bboss.org.objectweb.asm.ClassVisitor;
import bboss.org.objectweb.asm.FieldVisitor;
import bboss.org.objectweb.asm.MethodVisitor;
import bboss.org.objectweb.asm.Opcodes;
/**
* A {@link ClassVisitor} that adds a serial version unique identifier to a
* class if missing. Here is typical usage of this class:
*
* <pre>
* ClassWriter cw = new ClassWriter(...);
* ClassVisitor sv = new SerialVersionUIDAdder(cw);
* ClassVisitor ca = new MyClassAdapter(sv);
* new ClassReader(orginalClass).accept(ca, false);
* </pre>
*
* The SVUID algorithm can be found <a href=
* "http://java.sun.com/j2se/1.4.2/docs/guide/serialization/spec/class.html"
* >http://java.sun.com/j2se/1.4.2/docs/guide/serialization/spec/class.html</a>:
*
* <pre>
* The serialVersionUID is computed using the signature of a stream of bytes
* that reflect the class definition. The National Institute of Standards and
* Technology (NIST) Secure Hash Algorithm (SHA-1) is used to compute a
* signature for the stream. The first two 32-bit quantities are used to form a
* 64-bit hash. A java.lang.DataOutputStream is used to convert primitive data
* types to a sequence of bytes. The values input to the stream are defined by
* the Java Virtual Machine (VM) specification for classes.
*
* The sequence of items in the stream is as follows:
*
* 1. The class name written using UTF encoding.
* 2. The class modifiers written as a 32-bit integer.
* 3. The name of each interface sorted by name written using UTF encoding.
* 4. For each field of the class sorted by field name (except private static
* and private transient fields):
* 1. The name of the field in UTF encoding.
* 2. The modifiers of the field written as a 32-bit integer.
* 3. The descriptor of the field in UTF encoding
* 5. If a class initializer exists, write out the following:
* 1. The name of the method, <clinit>, in UTF encoding.
* 2. The modifier of the method, java.lang.reflect.Modifier.STATIC,
* written as a 32-bit integer.
* 3. The descriptor of the method, ()V, in UTF encoding.
* 6. For each non-private constructor sorted by method name and signature:
* 1. The name of the method, <init>, in UTF encoding.
* 2. The modifiers of the method written as a 32-bit integer.
* 3. The descriptor of the method in UTF encoding.
* 7. For each non-private method sorted by method name and signature:
* 1. The name of the method in UTF encoding.
* 2. The modifiers of the method written as a 32-bit integer.
* 3. The descriptor of the method in UTF encoding.
* 8. The SHA-1 algorithm is executed on the stream of bytes produced by
* DataOutputStream and produces five 32-bit values sha[0..4].
*
* 9. The hash value is assembled from the first and second 32-bit values of
* the SHA-1 message digest. If the result of the message digest, the five
* 32-bit words H0 H1 H2 H3 H4, is in an array of five int values named
* sha, the hash value would be computed as follows:
*
* long hash = ((sha[0] >>> 24) & 0xFF) |
* ((sha[0] >>> 16) & 0xFF) << 8 |
* ((sha[0] >>> 8) & 0xFF) << 16 |
* ((sha[0] >>> 0) & 0xFF) << 24 |
* ((sha[1] >>> 24) & 0xFF) << 32 |
* ((sha[1] >>> 16) & 0xFF) << 40 |
* ((sha[1] >>> 8) & 0xFF) << 48 |
* ((sha[1] >>> 0) & 0xFF) << 56;
* </pre>
*
* @author Rajendra Inamdar, Vishal Vishnoi
*/
public class SerialVersionUIDAdder extends ClassVisitor {
/**
* Flag that indicates if we need to compute SVUID.
*/
private boolean computeSVUID;
/**
* Set to true if the class already has SVUID.
*/
private boolean hasSVUID;
/**
* Classes access flags.
*/
private int access;
/**
* Internal name of the class
*/
private String name;
/**
* Interfaces implemented by the class.
*/
private String[] interfaces;
/**
* Collection of fields. (except private static and private transient
* fields)
*/
private Collection<Item> svuidFields;
/**
* Set to true if the class has static initializer.
*/
private boolean hasStaticInitializer;
/**
* Collection of non-private constructors.
*/
private Collection<Item> svuidConstructors;
/**
* Collection of non-private methods.
*/
private Collection<Item> svuidMethods;
/**
* Creates a new {@link SerialVersionUIDAdder}. <i>Subclasses must not use
* this constructor</i>. Instead, they must use the
* {@link #SerialVersionUIDAdder(int, ClassVisitor)} version.
*
* @param cv
* a {@link ClassVisitor} to which this visitor will delegate
* calls.
* @throws IllegalStateException
* If a subclass calls this constructor.
*/
public SerialVersionUIDAdder(final ClassVisitor cv) {
this(Opcodes.ASM5, cv);
if (getClass() != SerialVersionUIDAdder.class) {
throw new IllegalStateException();
}
}
/**
* Creates a new {@link SerialVersionUIDAdder}.
*
* @param api
* the ASM API version implemented by this visitor. Must be one
* of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
* @param cv
* a {@link ClassVisitor} to which this visitor will delegate
* calls.
*/
protected SerialVersionUIDAdder(final int api, final ClassVisitor cv) {
super(api, cv);
svuidFields = new ArrayList<Item>();
svuidConstructors = new ArrayList<Item>();
svuidMethods = new ArrayList<Item>();
}
// ------------------------------------------------------------------------
// Overridden methods
// ------------------------------------------------------------------------
/*
* Visit class header and get class name, access , and interfaces
* information (step 1,2, and 3) for SVUID computation.
*/
@Override
public void visit(final int version, final int access, final String name,
final String signature, final String superName,
final String[] interfaces) {
computeSVUID = (access & Opcodes.ACC_INTERFACE) == 0;
if (computeSVUID) {
this.name = name;
this.access = access;
this.interfaces = new String[interfaces.length];
System.arraycopy(interfaces, 0, this.interfaces, 0,
interfaces.length);
}
super.visit(version, access, name, signature, superName, interfaces);
}
/*
* Visit the methods and get constructor and method information (step 5 and
* 7). Also determine if there is a class initializer (step 6).
*/
@Override
public MethodVisitor visitMethod(final int access, final String name,
final String desc, final String signature, final String[] exceptions) {
if (computeSVUID) {
if ("<clinit>".equals(name)) {
hasStaticInitializer = true;
}
/*
* Remembers non private constructors and methods for SVUID
* computation For constructor and method modifiers, only the
* ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
* ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT and ACC_STRICT flags
* are used.
*/
int mods = access
& (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE
| Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC
| Opcodes.ACC_FINAL | Opcodes.ACC_SYNCHRONIZED
| Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_STRICT);
// all non private methods
if ((access & Opcodes.ACC_PRIVATE) == 0) {
if ("<init>".equals(name)) {
svuidConstructors.add(new Item(name, mods, desc));
} else if (!"<clinit>".equals(name)) {
svuidMethods.add(new Item(name, mods, desc));
}
}
}
return super.visitMethod(access, name, desc, signature, exceptions);
}
/*
* Gets class field information for step 4 of the algorithm. Also determines
* if the class already has a SVUID.
*/
@Override
public FieldVisitor visitField(final int access, final String name,
final String desc, final String signature, final Object value) {
if (computeSVUID) {
if ("serialVersionUID".equals(name)) {
// since the class already has SVUID, we won't be computing it.
computeSVUID = false;
hasSVUID = true;
}
/*
* Remember field for SVUID computation For field modifiers, only
* the ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC,
* ACC_FINAL, ACC_VOLATILE, and ACC_TRANSIENT flags are used when
* computing serialVersionUID values.
*/
if ((access & Opcodes.ACC_PRIVATE) == 0
|| (access & (Opcodes.ACC_STATIC | Opcodes.ACC_TRANSIENT)) == 0) {
int mods = access
& (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE
| Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC
| Opcodes.ACC_FINAL | Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT);
svuidFields.add(new Item(name, mods, desc));
}
}
return super.visitField(access, name, desc, signature, value);
}
/**
* Handle a bizarre special case. Nested classes (static classes declared
* inside another class) that are protected have their access bit set to
* public in their class files to deal with some odd reflection situation.
* Our SVUID computation must do as the JVM does and ignore access bits in
* the class file in favor of the access bits InnerClass attribute.
*/
@Override
public void visitInnerClass(final String aname, final String outerName,
final String innerName, final int attr_access) {
if ((name != null) && name.equals(aname)) {
this.access = attr_access;
}
super.visitInnerClass(aname, outerName, innerName, attr_access);
}
/*
* Add the SVUID if class doesn't have one
*/
@Override
public void visitEnd() {
// compute SVUID and add it to the class
if (computeSVUID && !hasSVUID) {
try {
addSVUID(computeSVUID());
} catch (Throwable e) {
throw new RuntimeException("Error while computing SVUID for "
+ name, e);
}
}
super.visitEnd();
}
// ------------------------------------------------------------------------
// Utility methods
// ------------------------------------------------------------------------
/**
* Returns true if the class already has a SVUID field. The result of this
* method is only valid when visitEnd is or has been called.
*
* @return true if the class already has a SVUID field.
*/
public boolean hasSVUID() {
return hasSVUID;
}
protected void addSVUID(long svuid) {
FieldVisitor fv = super.visitField(Opcodes.ACC_FINAL
+ Opcodes.ACC_STATIC, "serialVersionUID", "J", null, new Long(
svuid));
if (fv != null) {
fv.visitEnd();
}
}
/**
* Computes and returns the value of SVUID.
*
* @return Returns the serial version UID
* @throws IOException
* if an I/O error occurs
*/
protected long computeSVUID() throws IOException {
ByteArrayOutputStream bos;
DataOutputStream dos = null;
long svuid = 0;
try {
bos = new ByteArrayOutputStream();
dos = new DataOutputStream(bos);
/*
* 1. The class name written using UTF encoding.
*/
dos.writeUTF(name.replace('/', '.'));
/*
* 2. The class modifiers written as a 32-bit integer.
*/
dos.writeInt(access
& (Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL
| Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT));
/*
* 3. The name of each interface sorted by name written using UTF
* encoding.
*/
Arrays.sort(interfaces);
for (int i = 0; i < interfaces.length; i++) {
dos.writeUTF(interfaces[i].replace('/', '.'));
}
/*
* 4. For each field of the class sorted by field name (except
* private static and private transient fields):
*
* 1. The name of the field in UTF encoding. 2. The modifiers of the
* field written as a 32-bit integer. 3. The descriptor of the field
* in UTF encoding
*
* Note that field signatures are not dot separated. Method and
* constructor signatures are dot separated. Go figure...
*/
writeItems(svuidFields, dos, false);
/*
* 5. If a class initializer exists, write out the following: 1. The
* name of the method, <clinit>, in UTF encoding. 2. The modifier of
* the method, java.lang.reflect.Modifier.STATIC, written as a
* 32-bit integer. 3. The descriptor of the method, ()V, in UTF
* encoding.
*/
if (hasStaticInitializer) {
dos.writeUTF("<clinit>");
dos.writeInt(Opcodes.ACC_STATIC);
dos.writeUTF("()V");
} // if..
/*
* 6. For each non-private constructor sorted by method name and
* signature: 1. The name of the method, <init>, in UTF encoding. 2.
* The modifiers of the method written as a 32-bit integer. 3. The
* descriptor of the method in UTF encoding.
*/
writeItems(svuidConstructors, dos, true);
/*
* 7. For each non-private method sorted by method name and
* signature: 1. The name of the method in UTF encoding. 2. The
* modifiers of the method written as a 32-bit integer. 3. The
* descriptor of the method in UTF encoding.
*/
writeItems(svuidMethods, dos, true);
dos.flush();
/*
* 8. The SHA-1 algorithm is executed on the stream of bytes
* produced by DataOutputStream and produces five 32-bit values
* sha[0..4].
*/
byte[] hashBytes = computeSHAdigest(bos.toByteArray());
/*
* 9. The hash value is assembled from the first and second 32-bit
* values of the SHA-1 message digest. If the result of the message
* digest, the five 32-bit words H0 H1 H2 H3 H4, is in an array of
* five int values named sha, the hash value would be computed as
* follows:
*
* long hash = ((sha[0] >>> 24) & 0xFF) | ((sha[0] >>> 16) & 0xFF)
* << 8 | ((sha[0] >>> 8) & 0xFF) << 16 | ((sha[0] >>> 0) & 0xFF) <<
* 24 | ((sha[1] >>> 24) & 0xFF) << 32 | ((sha[1] >>> 16) & 0xFF) <<
* 40 | ((sha[1] >>> 8) & 0xFF) << 48 | ((sha[1] >>> 0) & 0xFF) <<
* 56;
*/
for (int i = Math.min(hashBytes.length, 8) - 1; i >= 0; i--) {
svuid = (svuid << 8) | (hashBytes[i] & 0xFF);
}
} finally {
// close the stream (if open)
if (dos != null) {
dos.close();
}
}
return svuid;
}
/**
* Returns the SHA-1 message digest of the given value.
*
* @param value
* the value whose SHA message digest must be computed.
* @return the SHA-1 message digest of the given value.
*/
protected byte[] computeSHAdigest(final byte[] value) {
try {
return MessageDigest.getInstance("SHA").digest(value);
} catch (Exception e) {
throw new UnsupportedOperationException(e.toString());
}
}
/**
* Sorts the items in the collection and writes it to the data output stream
*
* @param itemCollection
* collection of items
* @param dos
* a <code>DataOutputStream</code> value
* @param dotted
* a <code>boolean</code> value
* @exception IOException
* if an error occurs
*/
private static void writeItems(final Collection<Item> itemCollection,
final DataOutput dos, final boolean dotted) throws IOException {
int size = itemCollection.size();
Item[] items = itemCollection.toArray(new Item[size]);
Arrays.sort(items);
for (int i = 0; i < size; i++) {
dos.writeUTF(items[i].name);
dos.writeInt(items[i].access);
dos.writeUTF(dotted ? items[i].desc.replace('/', '.')
: items[i].desc);
}
}
// ------------------------------------------------------------------------
// Inner classes
// ------------------------------------------------------------------------
private static class Item implements Comparable<Item> {
final String name;
final int access;
final String desc;
Item(final String name, final int access, final String desc) {
this.name = name;
this.access = access;
this.desc = desc;
}
public int compareTo(final Item other) {
int retVal = name.compareTo(other.name);
if (retVal == 0) {
retVal = desc.compareTo(other.desc);
}
return retVal;
}
@Override
public boolean equals(final Object o) {
if (o instanceof Item) {
return compareTo((Item) o) == 0;
}
return false;
}
@Override
public int hashCode() {
return (name + desc).hashCode();
}
}
}
| [
"yin-bp@163.com"
] | yin-bp@163.com |
d1d804094c734e6c5ae4751762f2dd57f60344d8 | 447520f40e82a060368a0802a391697bc00be96f | /apks/playstore_apps/com_advantage_RaiffeisenBank/source/org/apache/commons/codec/StringDecoder.java | 12dc62da98c0fa87a22eae75b470d80a518b8a52 | [
"Apache-2.0"
] | permissive | iantal/AndroidPermissions | 7f3343a9c29d82dbcd4ecd98b3a50ddf8d179465 | d623b732734243590b5f004d167e542e2e2ae249 | refs/heads/master | 2023-07-19T01:29:26.689186 | 2019-09-30T19:01:42 | 2019-09-30T19:01:42 | 107,239,248 | 0 | 0 | Apache-2.0 | 2023-07-16T07:41:38 | 2017-10-17T08:22:57 | null | UTF-8 | Java | false | false | 178 | java | package org.apache.commons.codec;
public abstract interface StringDecoder
extends Decoder
{
public abstract String decode(String paramString)
throws DecoderException;
}
| [
"antal.micky@yahoo.com"
] | antal.micky@yahoo.com |
271167840cb7ba84a7b40920e484920c84b1b6f1 | 10c9b0f6c05b1432a6053f074bdb13820f8ab545 | /src/main/java/com/sdajava/Horda/controller/LoginController.java | cad19d72177585feed526327047349e06f331bcb | [] | no_license | LukkeM/HordaRozrabiakow | 1ee3feee44ca8d1e5d9273287d54e358b034c2b8 | 8f2ef0bf48267d3db528c4e1dd1cc767df0238cd | refs/heads/master | 2021-01-11T14:00:55.487733 | 2017-06-25T07:23:42 | 2017-06-25T07:23:42 | 94,909,642 | 0 | 0 | null | 2017-06-20T15:57:14 | 2017-06-20T15:57:14 | null | UTF-8 | Java | false | false | 637 | java | package com.sdajava.Horda.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.Map;
@Controller
public class LoginController {
private static final Logger logger = LoggerFactory.getLogger(LoginController.class);
@PostMapping("/login")
public String publicPage(Map<String, Object> model) {
logger.info("Odwiedzono publiczny endpoint");
model.put("text", "A PUBLIC PAGE!");
return "page";
}
}
| [
"arczir@gmail.com"
] | arczir@gmail.com |
9663b9edc55c2e3cff602e30c66618b3a703cf21 | 734e624cae5323e979d46746e58534edae1fb066 | /src/com/sdnu/dao/DictDao.java | 1d04196d7204844a05721cc51bc4c603455fd599 | [] | no_license | hahasdnu1029/CRM | 7c3e453cda218d9a58feb994d29646353bea5db8 | 4cd0b0a2652753fe98a31580b8c1403396f06554 | refs/heads/master | 2020-03-27T08:33:53.337706 | 2018-08-27T08:23:29 | 2018-08-27T08:23:29 | 146,267,903 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 290 | java | package com.sdnu.dao;
import java.util.List;
import com.sdnu.domain.Dictionary;
public interface DictDao {
/**
* 根据字典表类型查找信息
* @param dict_type_code 字典类型码
* @return 信息的list集合
*/
List<Dictionary> findByCode(String dict_type_code);
}
| [
"1176946782@qq.com"
] | 1176946782@qq.com |
b8b1d0ec529e908b2c4f92d08cdfd99a4ffd8393 | d84fb60595312136aeb1069baad585da325c218d | /HuaShanApp/app/src/main/java/com/karazam/huashanapp/my/security/checkpaymentpassword/retrofit/CheckPaymentpsDataSource.java | 6ddfb8475e571d4419ca4ce09018d7d63103709d | [] | no_license | awplying12/huashanApp | d6a72b248c94a65e882385edf92231552214340c | 86bd908ec2f82fc030a9d83238144a943461c842 | refs/heads/master | 2021-01-11T00:21:10.870110 | 2017-02-10T11:27:06 | 2017-02-10T11:27:06 | 70,544,770 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 720 | java | package com.karazam.huashanapp.my.security.checkpaymentpassword.retrofit;
import com.karazam.huashanapp.HuaShanApplication;
import com.karazam.huashanapp.main.retorfitMain.BaseDataSource;
import com.karazam.huashanapp.main.retorfitMain.BaseReturn;
import rx.Observable;
/**
* Created by Administrator on 2017/2/10.
*/
public class CheckPaymentpsDataSource extends BaseDataSource {
CheckPaymentpsApi service = retrofit1.create(CheckPaymentpsApi.class);
public Observable<BaseReturn> checkPaymentps(){
CheckPaymentpsPost post = new CheckPaymentpsPost();
post.setUserId(HuaShanApplication.uuid);
return service.checkPaymentps(post,HuaShanApplication.token,"XMLHttpRequest");
}
}
| [
"awplying14@163.com"
] | awplying14@163.com |
111f7c0ed95c76acccd46cc42c96ba7b42d1d779 | 98ff864d86197c69c8eba65704b643c0cb15cb79 | /src/main/java/ru/puredelight/handlers/Config.java | 5ab10bc5cf0a1eb43dc59fbed50c29304abc2389 | [] | no_license | azamat1554/LSB_Steganography | 06bd3023f60c66e1211c5a3a70b3b959866d89f7 | 8008142bb69c59bfa75b164c49513901e064307e | refs/heads/master | 2020-12-24T18:41:53.054845 | 2017-07-23T10:20:17 | 2017-07-23T10:20:17 | 86,154,288 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 551 | java | package ru.puredelight.handlers;
/**
* В этом классе находятся конфигурационные параметры
*/
public class Config {
/**
* Секретная метка, которая довавляется в изображение, чтобы указать на секретное содержимое в файле
*/
public static final byte[] SECRET_TAG = "secret".getBytes();
/**
* Длина заголовка в байтах
*/
public static final int HEADER_LENGTH = 10;
}
| [
"azaforgit@gmail.com"
] | azaforgit@gmail.com |
5474ca6b04dd7ceafd208ddf80a61bb25998f668 | f18218a61ced4025217c20a605ada8a55e765e67 | /State/src/structure/state/concrete/HasCard.java | 9f122db721a6792a28bf5b907ece44e9fdd0eb9c | [] | no_license | Diecaal/DesignPatterns | 4bafbd6bca9d6f2ed43dcb88b0c32e794427f8b7 | 2e122485ce10b4512b439c54e154bf4d101cb724 | refs/heads/master | 2023-05-14T12:51:45.420071 | 2021-06-01T19:23:00 | 2021-06-01T19:23:00 | 364,739,490 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,087 | java | package structure.state.concrete;
import structure.context.ATMMachine;
import structure.state.ATMState;
public class HasCard implements ATMState {
ATMMachine atmMachine;
public HasCard(ATMMachine atmMachine) {
this.atmMachine = atmMachine;
}
@Override
public void insertCard() {
System.out.println("Can not enter more than one card at a time");
}
@Override
public void ejectCard() {
System.out.println("Card ejected");
atmMachine.setAtmCurrentState( atmMachine.getNoCardState() );
}
@Override
public void insertPin(int pinEntered) {
System.out.println("PIN entered...");
if(pinEntered == 1234) {
System.out.println("Correct PIN");
atmMachine.setCorrectPinEntered( true );
atmMachine.setAtmCurrentState( atmMachine.getHasPin() );
} else {
System.out.println("Wrong PIN");
atmMachine.setCorrectPinEntered( false );
System.out.println("Card will be ejected");
atmMachine.setAtmCurrentState( atmMachine.getNoCardState() );
}
}
@Override
public void requestCash(int cashToWithdraw) {
System.out.println("Enter PIN first");
}
}
| [
"diecaal@gmail.com"
] | diecaal@gmail.com |
622d901a39274f92a4ee1a63531eadefd17f81b1 | 3bbb5090ec51516f29316e380cfc07c25fb29b5e | /core/src/test/java/org/elasticsearch/script/StoredScriptSourceTests.java | a99c897ec3445da72042fbd652893079e672f5e4 | [
"Apache-2.0"
] | permissive | strapdata/elassandra5-rc | 66bb349b62ea4c6ef38ff5cca1ce8cd99877c40b | 0a1d0066331e5347186f30aac1233f793f4fac24 | refs/heads/v5.5.0-strapdata | 2022-12-12T22:51:01.546176 | 2018-08-03T16:05:37 | 2018-08-08T14:25:20 | 96,863,176 | 0 | 0 | Apache-2.0 | 2022-12-08T00:37:34 | 2017-07-11T07:18:48 | Java | UTF-8 | Java | false | false | 2,579 | java | /*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.script;
import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.AbstractSerializingTestCase;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class StoredScriptSourceTests extends AbstractSerializingTestCase<StoredScriptSource> {
@Override
protected StoredScriptSource createTestInstance() {
String lang = randomAlphaOfLengthBetween(1, 20);
XContentType xContentType = randomFrom(XContentType.JSON, XContentType.YAML);
try {
XContentBuilder template = XContentBuilder.builder(xContentType.xContent());
template.startObject();
template.startObject("query");
template.startObject("match");
template.field("title", "{{query_string}}");
template.endObject();
template.endObject();
template.endObject();
Map<String, String> options = new HashMap<>();
if (randomBoolean()) {
options.put(Script.CONTENT_TYPE_OPTION, xContentType.mediaType());
}
return StoredScriptSource.parse(lang, template.bytes(), xContentType);
} catch (IOException e) {
throw new AssertionError("Failed to create test instance", e);
}
}
@Override
protected StoredScriptSource doParseInstance(XContentParser parser) throws IOException {
return StoredScriptSource.fromXContent(parser);
}
@Override
protected Reader<StoredScriptSource> instanceReader() {
return StoredScriptSource::new;
}
}
| [
"colings86@users.noreply.github.com"
] | colings86@users.noreply.github.com |
db76262a4f98d19b95c9faeb98ebedbdc9e8f963 | 34da1d10d10a025430b14ddaca138fae1c4f0e1e | /src/if1/pkg10119013/latihan55/handphone/Handphone.java | 90be1784c6cba30e7e40cd95fc9f23f666441b02 | [] | no_license | fi-yona/IF1-10119013-Latihan55-Handphone | c653bfd3b97ec65fe4f1b8e5f16d8d61496ab8e7 | acea8fa8531b70e5a406d44d25476e7b4bde713c | refs/heads/master | 2023-01-09T05:02:14.834264 | 2020-11-14T16:25:05 | 2020-11-14T16:25:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 812 | java | /*
* NAMA : Fiona Avila Putri
* NIM : 10119013
* KELAS : IF1 2019/2020 (PBO1)
*/
package if1.pkg10119013.latihan55.handphone;
/**
*
* @author Fiona Avila
*/
public class Handphone {
protected String manufacture;
protected String operatingSystem;
protected String model;
protected int harga;
public Handphone(String man, String os, String model, int harga){
this.manufacture = man;
this.operatingSystem = os;
this.model = model;
this.harga = harga;
}
public void displayProduct(){
System.out.println("Manufaktur : " + this.manufacture);
System.out.println("OS : " + this.operatingSystem);
System.out.println("Model : " + this.model);
System.out.println("Harga : Rp " + this.harga);
}
}
| [
"fionaavila15@gmail.com"
] | fionaavila15@gmail.com |
103119393cf5cd53abe8e58a40398cc7a314c91c | 1e7872ceb921ad715c0089dba6425d320db6b1ea | /BalancedParen2107.java | cce11f5bbdb9e19bd914c417e908f605c8d4d648 | [] | no_license | randeep01/javapractice | 9f28774a5532ce974e2a54fc85a8de92080a36a9 | cefaf0e00d910083618c49f53049c6b55f5fbd29 | refs/heads/master | 2023-01-29T07:57:52.832249 | 2020-12-11T23:39:39 | 2020-12-11T23:39:39 | 253,450,534 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 966 | java | import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
public class BalancedParen2107{
public static void main(String args[])
{
new BalancedParen2107().bal("((a+b))(d+f))");
}
public void bal(String str){
HashSet<String> hs = new HashSet<>();
Queue<String> q = new LinkedList<>();
hs.add(str);
q.add(str);
while(q.isEmpty()!=true)
{
String val = q.poll();
if(isBalanced(val)){
// printit
System.out.println(val);
break;
}
else{
for(int i =0;i<val.length();i++)
{
String temp = val.substring(0,i)+val.substring(i+1);
if(!hs.contains(temp)){
hs.add(temp);
q.add(temp);
}
}
}
}
}
public boolean isBalanced(String str)
{
int bal = 0;
for(int i =0;i<str.length();i++)
{
char c = str.charAt(i);
if(c == ')')
{
bal--;
if(bal<0){
return false;
}
}
else if(c=='(')
{
bal++;
}
}
return bal == 0;
}
}
| [
"randeepsaggu@gmail.com"
] | randeepsaggu@gmail.com |
1eb569e97546b66812d7376ac5d6bf6ccf77d269 | e06e0b7041b9cbac208d086b3d39f528c50cd8ef | /mqtt/src/main/java/com/pi/mqtt/ob/EventManager.java | 28714e8d54fdbebd84661aa7290341274488439d | [] | no_license | xxl6097/raspberry | b5680bd78cfa0b87d91ffcc2a24eeafb54fa2c80 | cd05344ae2d642823f7df99886448052e8f68848 | refs/heads/master | 2020-03-15T23:29:04.582729 | 2019-10-21T07:00:30 | 2019-10-21T07:00:30 | 132,394,301 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,284 | java | package com.pi.mqtt.ob;
import com.pi.mqtt.bean.MQBean;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
/**
* Created by uuxia-mac on 2017/12/30.
*/
public class EventManager {
private static Set<INotify> obs = new HashSet<INotify>();
private INotify dataInterceptor;
private static EventManager instance;
public static EventManager getInstance() {
if (instance == null) {
synchronized (EventManager.class) {
if (null == instance) {
instance = new EventManager();
}
}
}
return instance;
}
public synchronized void registerObserver(INotify o) {
if (o != null) {
if (!obs.contains(o)) {
obs.add(o);
}
}
}
public synchronized void unregisterObserver(INotify o) {
if (obs.contains(o)) {
obs.remove(o);
}
}
public synchronized void clear() {
obs.clear();
}
public synchronized void post(MQBean obj) {
if (obj == null)
return;
Iterator<INotify> it = obs.iterator();
while (it.hasNext()) {
INotify mgr = it.next();
mgr.onNotify(obj);
}
}
}
| [
"szhittech"
] | szhittech |
ed3119328432cfdfecf7db6749d61e6fb998e5b1 | d2d2b04534a32e79161b35e664f018e7d43a2f1b | /src/pl/grzegorz2047/survivalgames/commands/EditModeArg.java | 3ff048681bb9158cb8547bbe348c3ba9779d677d | [
"Apache-2.0"
] | permissive | grzegorz2047/SurvivalGames-Bukkit | 92422a404b62a6127b68c2edac077025059578ef | 47d2aaf7e266f2267358739b90988690676e0261 | refs/heads/master | 2021-01-11T05:20:40.050520 | 2016-10-25T10:41:32 | 2016-10-25T10:41:32 | 71,886,803 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,564 | java | package pl.grzegorz2047.survivalgames.commands;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import pl.grzegorz2047.survivalgames.MsgManager;
import pl.grzegorz2047.survivalgames.SurvivalGames;
/**
* Created by Grzegorz2047. 01.09.2015.
*/
public class EditModeArg extends Arg {
private SurvivalGames sg;
public EditModeArg(SurvivalGames sg) {
this.sg = sg;
}
@Override
protected void execute(CommandSender sender, String args[]) {
if(!(sender instanceof Player)){
return;
}
Player p = (Player) sender;
if(args.length >= 2){
boolean editMode = Boolean.parseBoolean(args[1]);
sg.getGameManager().getChestManager().setEditMode(editMode);
if(editMode){
p.sendMessage(MsgManager.msg(ChatColor.GREEN + "Wlaczono tryb edycji skrzynek!"));
p.sendMessage(MsgManager.msg("Aby zapisac wspolrzedne skrzynki kliknij na nia lewym klawiszem!"));
p.sendMessage(MsgManager.msg("Kiedy skonczysz wylacz tryb edycji i zapisz wspolrzedne skrzynek poprzez /sg editmode false"));
}else{
sg.getGameManager().getChestManager().saveChestsLocToFile();
sg.getGameManager().getChestManager().saveDoubleChestsLocToFile();
p.sendMessage(MsgManager.msg("zapisano skrzynki!"));
}
}else{
p.sendMessage(MsgManager.msg("Poprawne uzycie: /sg editmode true/false"));
}
}
}
| [
"grzegorz2047@gmail.com"
] | grzegorz2047@gmail.com |
cbc505d0ae434025521523bfc63bc95be9950c83 | 74b47b895b2f739612371f871c7f940502e7165b | /aws-java-sdk-appsync/src/main/java/com/amazonaws/services/appsync/model/transform/RelationalDatabaseDataSourceConfigJsonUnmarshaller.java | ca026ea16c5ab4900cdf1bbdd79da3449cde5bfb | [
"Apache-2.0"
] | permissive | baganda07/aws-sdk-java | fe1958ed679cd95b4c48f971393bf03eb5512799 | f19bdb30177106b5d6394223a40a382b87adf742 | refs/heads/master | 2022-11-09T21:55:43.857201 | 2022-10-24T21:08:19 | 2022-10-24T21:08:19 | 221,028,223 | 0 | 0 | Apache-2.0 | 2019-11-11T16:57:12 | 2019-11-11T16:57:11 | null | UTF-8 | Java | false | false | 3,301 | java | /*
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.amazonaws.services.appsync.model.transform;
import java.math.*;
import javax.annotation.Generated;
import com.amazonaws.services.appsync.model.*;
import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
import com.amazonaws.transform.*;
import com.fasterxml.jackson.core.JsonToken;
import static com.fasterxml.jackson.core.JsonToken.*;
/**
* RelationalDatabaseDataSourceConfig JSON Unmarshaller
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class RelationalDatabaseDataSourceConfigJsonUnmarshaller implements Unmarshaller<RelationalDatabaseDataSourceConfig, JsonUnmarshallerContext> {
public RelationalDatabaseDataSourceConfig unmarshall(JsonUnmarshallerContext context) throws Exception {
RelationalDatabaseDataSourceConfig relationalDatabaseDataSourceConfig = new RelationalDatabaseDataSourceConfig();
int originalDepth = context.getCurrentDepth();
String currentParentElement = context.getCurrentParentElement();
int targetDepth = originalDepth + 1;
JsonToken token = context.getCurrentToken();
if (token == null)
token = context.nextToken();
if (token == VALUE_NULL) {
return null;
}
while (true) {
if (token == null)
break;
if (token == FIELD_NAME || token == START_OBJECT) {
if (context.testExpression("relationalDatabaseSourceType", targetDepth)) {
context.nextToken();
relationalDatabaseDataSourceConfig.setRelationalDatabaseSourceType(context.getUnmarshaller(String.class).unmarshall(context));
}
if (context.testExpression("rdsHttpEndpointConfig", targetDepth)) {
context.nextToken();
relationalDatabaseDataSourceConfig.setRdsHttpEndpointConfig(RdsHttpEndpointConfigJsonUnmarshaller.getInstance().unmarshall(context));
}
} else if (token == END_ARRAY || token == END_OBJECT) {
if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) {
if (context.getCurrentDepth() <= originalDepth)
break;
}
}
token = context.nextToken();
}
return relationalDatabaseDataSourceConfig;
}
private static RelationalDatabaseDataSourceConfigJsonUnmarshaller instance;
public static RelationalDatabaseDataSourceConfigJsonUnmarshaller getInstance() {
if (instance == null)
instance = new RelationalDatabaseDataSourceConfigJsonUnmarshaller();
return instance;
}
}
| [
""
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.