blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 410 | content_id stringlengths 40 40 | detected_licenses listlengths 0 51 | license_type stringclasses 2 values | repo_name stringlengths 5 132 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 80 | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 689M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22 values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 131 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 3 9.45M | extension stringclasses 32 values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 313 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8835daa13c862a23ae96dc4145d240954e2320e6 | 0b241e6d0a5be93e9d1a6c87b0c26d5cc8b90393 | /src/main/java/ch/uzh/torrentdbmanager/DataBaseAdapter.java | cdab2ff7da75ae93ec3f83ff8e13e9e93eed7762 | [] | no_license | andrilareida/torrentDBManager | 04406e24acfab2351479a0523d0516c8804e385d | 1d6dc9e6330b0f1ae9569e6b670b72928a3c1880 | refs/heads/master | 2021-01-09T20:33:26.623229 | 2016-08-09T09:42:51 | 2016-08-09T09:42:51 | 65,281,636 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,152 | 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 ch.uzh.torrentdbmanager;
import java.io.Closeable;
import java.io.IOException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.IIOException;
/**
*
* @author lareida
*/
public class DataBaseAdapter implements Closeable {
public static final String TORRENTS ="TORRENTS";
public static final String INFO_HASH = "INFO_HASH";
public static final String TORRENT_TITLE = "TORRENT_TITLE";
public static final String TORRENT_COMMENT = "TORRENT_COMMENT";
public static final String TORRENT_SIZE = "TORRENT_SIZE";
public static final String SIZE_UNIT = "SIZE_UNIT";
public static final String LANGUAGE = "LANGUAGE";
public static final String QUALITY = "QUALITY";
public static final String SUBTITLES = "SUBTITLES";
public static final String GENRES = "GENRES";
public static final String PUBLISH_DATE = "PUBLISH_DATE";
public static final String TIME_ADDED = "TIME_ADDED";
public static final String MAGNET_URI = "MAGNET_URI";
public static final String TORRENT_LINK = "TORRENT_LINK";
public static final String IMDB_LINK = "IMDB_LINK";
public static final String IMDB_ID = "IMDB_ID";
public static final String IMDB_RATING = "IMDB_RATING";
public static final String IMDB_VOTES = "IMDB_VOTES";
public static final String TV_MAZE_LINK = "TV_MAZE_LINK";
public static final String createTableSQL = "CREATE TABLE IF NOT EXISTS "+TORRENTS+" ( " +
INFO_HASH +" BINARY(20) NOT NULL, " +
TORRENT_TITLE + " VARCHAR(255) NOT NULL, " +
TORRENT_COMMENT + " TEXT, " +
TORRENT_SIZE + " REAL, " +
SIZE_UNIT + " VARCHAR(4), " +
LANGUAGE + " VARCHAR(20), " +
QUALITY + " VARCHAR(20), " +
SUBTITLES + " VARCHAR(256), " +
GENRES + " VARCHAR(256), " +
PUBLISH_DATE + " TIMESTAMP NOT NULL, " +
TIME_ADDED + " TIMESTAMP NOT NULL, " +
MAGNET_URI + " VARCHAR(512), " +
TORRENT_LINK + " VARCHAR(255), " +
IMDB_LINK + " VARCHAR(255), " +
IMDB_ID + " VARCHAR(20), " +
IMDB_RATING + " REAL, " +
IMDB_VOTES + " INTEGER " +
TV_MAZE_LINK + " VARCHAR(255), " +
"PRIMARY KEY ( " + INFO_HASH + "))";
public static final String sqlStatement = "INSERT OR IGNORE INTO " + TORRENTS + " ( " +
INFO_HASH + ", " +
TORRENT_TITLE + ", " +
TORRENT_COMMENT + "," +
TORRENT_SIZE + "," +
SIZE_UNIT + "," +
LANGUAGE + "," +
QUALITY + "," +
SUBTITLES + "," +
GENRES + "," +
PUBLISH_DATE + ", " +
TIME_ADDED + ", " +
MAGNET_URI + ", " +
TORRENT_LINK + ", " +
IMDB_LINK + "," +
IMDB_ID + "," +
IMDB_RATING + "," +
IMDB_VOTES + " ) " +
"VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
private Connection connection;
public DataBaseAdapter(String file) throws ClassNotFoundException{
Class.forName("org.sqlite.JDBC");
try {
connection = DriverManager.getConnection("jdbc:sqlite:"+file);
Statement statement = connection.createStatement();
statement.setQueryTimeout(30);
statement.executeUpdate(createTableSQL);
} catch (SQLException ex) {
Logger.getLogger(DataBaseAdapter.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void storeTorrent(TorrentDAO t){
try {
PreparedStatement stmt = connection.prepareStatement(sqlStatement);
stmt.setString(1, t.getInfoHash());
stmt.setString(2, t.getTitle());
stmt.setString(3, t.getComment());
stmt.setDouble(4, t.getSize());
stmt.setString(5, t.getUnit());
stmt.setString(6, t.getLanguage());
stmt.setString(7, t.getQuality());
stmt.setString(8, t.getSubtitles());
stmt.setString(9, t.getGenres());
stmt.setDate(10, new Date(t.getPublishDate()));
stmt.setDate(11, new Date(t.getDateAdded()));
stmt.setString(12, t.getMagnetUri());
stmt.setString(13, t.getLink());
stmt.setString(14, t.getiMDBLlink());
stmt.setString(15, t.getiMDBiD());
stmt.setDouble(16, t.getiMDBrating());
stmt.setInt(17, t.getiMDBvotes());
stmt.execute();
} catch (SQLException ex) {
Logger.getLogger(DataBaseAdapter.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
}
}
public boolean exists(String torrent){
String query = "SELECT " + INFO_HASH + " FROM " + TORRENTS + " WHERE " + INFO_HASH + "=?";
boolean result = false;
try {
PreparedStatement pst = connection.prepareStatement(query);
pst.setString(1, torrent);
ResultSet rs = pst.executeQuery();
result = rs.next();
rs.close();
} catch (SQLException ex) {
Logger.getLogger(DataBaseAdapter.class.getName()).log(Level.SEVERE, null, ex);
}
return result;
}
@Override
public void close() throws IOException {
try {
connection.close();
} catch (SQLException ex) {
throw new IIOException("Failed to close JDBC connection", ex);
}
}
}
| [
"lareida@ifi.uzh.ch"
] | lareida@ifi.uzh.ch |
bfe01b90038ee0b108a61fe095d9be71129f4ad9 | 2ff042829ae507a6e6a88fd115bf82cffa2fa711 | /juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/Publish3to2.java | e37d45a33882f03b2efef1efc1b342999af6bf80 | [
"OFL-1.1",
"LicenseRef-scancode-proprietary-license",
"Apache-2.0",
"CDDL-1.0",
"MIT",
"CPL-1.0",
"MPL-1.1",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | apache/juddi | d2d3bce3880031572156c46c8fe403404dee6568 | 71a9028c839db876a52cc49b643360450748a390 | refs/heads/master | 2023-09-03T12:43:37.071448 | 2023-01-20T23:22:43 | 2023-01-20T23:22:43 | 17,049,428 | 24 | 35 | Apache-2.0 | 2023-02-16T21:19:00 | 2014-02-21T08:00:09 | Java | UTF-8 | Java | false | false | 9,965 | java | /*
* Copyright 2014 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.juddi.v3.client.transport.wrapper;
import java.rmi.RemoteException;
import java.util.List;
import java.util.Map;
import javax.xml.ws.Binding;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.Holder;
import javax.xml.ws.soap.SOAPFaultException;
import org.apache.juddi.v3.client.UDDIServiceV2;
import org.apache.juddi.v3.client.mapping.MapUDDIv2Tov3;
import org.apache.juddi.v3.client.mapping.MapUDDIv3Tov2;
import org.uddi.api_v2.AssertionStatusReport;
import org.uddi.api_v2.PublisherAssertions;
import org.uddi.api_v2.SetPublisherAssertions;
import org.uddi.api_v3.AddPublisherAssertions;
import org.uddi.api_v3.AssertionStatusItem;
import org.uddi.api_v3.BindingDetail;
import org.uddi.api_v3.BusinessDetail;
import org.uddi.api_v3.CompletionStatus;
import org.uddi.api_v3.DeleteBinding;
import org.uddi.api_v3.DeleteBusiness;
import org.uddi.api_v3.DeletePublisherAssertions;
import org.uddi.api_v3.DeleteService;
import org.uddi.api_v3.DeleteTModel;
import org.uddi.api_v3.GetRegisteredInfo;
import org.uddi.api_v3.PublisherAssertion;
import org.uddi.api_v3.RegisteredInfo;
import org.uddi.api_v3.SaveBinding;
import org.uddi.api_v3.SaveBusiness;
import org.uddi.api_v3.SaveService;
import org.uddi.api_v3.SaveTModel;
import org.uddi.api_v3.ServiceDetail;
import org.uddi.api_v3.TModelDetail;
import org.uddi.v2_service.DispositionReport;
import org.uddi.v2_service.Publish;
import org.uddi.v3_service.DispositionReportFaultMessage;
import org.uddi.v3_service.UDDIPublicationPortType;
/**
* This class provides a wrapper to enable UDDIv3 clients to talk to UDDIv2
* servers via JAXWS Transport. It handles all translations for Publish
* service methods.
*
* @author <a href="alexoree@apache.org">Alex O'Ree</a>
* @since 3.2
*/
public class Publish3to2 implements UDDIPublicationPortType, BindingProvider {
Publish publishService = null;
public Publish3to2() {
UDDIServiceV2 service = new UDDIServiceV2();
publishService = service.getPublish();
}
public Publish getUDDIv2PublishWebServiceClient(){
return publishService;
}
@Override
public void addPublisherAssertions(AddPublisherAssertions body) throws DispositionReportFaultMessage, RemoteException {
try {
publishService.addPublisherAssertions(MapUDDIv3Tov2.MapAddPublisherAssertions(body));
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public void deleteBinding(DeleteBinding body) throws DispositionReportFaultMessage, RemoteException {
try {
publishService.deleteBinding(MapUDDIv3Tov2.MapDeleteBinding(body));
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public void deleteBusiness(DeleteBusiness body) throws DispositionReportFaultMessage, RemoteException {
try {
publishService.deleteBusiness(MapUDDIv3Tov2.MapDeleteBusiness(body));
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public void deletePublisherAssertions(DeletePublisherAssertions body) throws DispositionReportFaultMessage, RemoteException {
try {
publishService.deletePublisherAssertions(MapUDDIv3Tov2.MapDeletePublisherAssertions(body));
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public void deleteService(DeleteService body) throws DispositionReportFaultMessage, RemoteException {
try {
publishService.deleteService(MapUDDIv3Tov2.MapDeleteService(body));
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public void deleteTModel(DeleteTModel body) throws DispositionReportFaultMessage, RemoteException {
try {
publishService.deleteTModel(MapUDDIv3Tov2.MapDeleteTModel(body));
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public List<AssertionStatusItem> getAssertionStatusReport(String authInfo, CompletionStatus completionStatus) throws DispositionReportFaultMessage, RemoteException {
try {
AssertionStatusReport assertionStatusReport = publishService.getAssertionStatusReport(MapUDDIv3Tov2.MapGetAssertionStatusReport(authInfo, completionStatus));
return MapUDDIv2Tov3.MapAssertionStatusItems(assertionStatusReport);
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public List<PublisherAssertion> getPublisherAssertions(String authInfo) throws DispositionReportFaultMessage, RemoteException {
try {
return MapUDDIv2Tov3.MapListPublisherAssertion(publishService.getPublisherAssertions(MapUDDIv3Tov2.MapGetPublisherAssertions(authInfo)));
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public RegisteredInfo getRegisteredInfo(GetRegisteredInfo body) throws DispositionReportFaultMessage, RemoteException {
try {
return MapUDDIv2Tov3.MapListRegisteredInfo(publishService.getRegisteredInfo(MapUDDIv3Tov2.MapGetRegisteredInfo(body)));
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public BindingDetail saveBinding(SaveBinding body) throws DispositionReportFaultMessage, RemoteException {
try {
return MapUDDIv2Tov3.MapBindingDetail(publishService.saveBinding(MapUDDIv3Tov2.MapSaveBinding(body)));
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public BusinessDetail saveBusiness(SaveBusiness body) throws DispositionReportFaultMessage, RemoteException {
try {
return MapUDDIv2Tov3.MapBusinessDetail(publishService.saveBusiness(MapUDDIv3Tov2.MapSaveBusiness(body)));
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public ServiceDetail saveService(SaveService body) throws DispositionReportFaultMessage, RemoteException {
try {
return MapUDDIv2Tov3.MapServiceDetail(publishService.saveService(MapUDDIv3Tov2.MapSaveService(body)));
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public TModelDetail saveTModel(SaveTModel body) throws DispositionReportFaultMessage, RemoteException {
try {
return MapUDDIv2Tov3.MapTModelDetail(publishService.saveTModel(MapUDDIv3Tov2.MapSaveTModel(body)));
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public void setPublisherAssertions(String authInfo, Holder<List<PublisherAssertion>> publisherAssertion) throws DispositionReportFaultMessage, RemoteException {
try {
SetPublisherAssertions req = MapUDDIv3Tov2.MapSetPublisherAssertions(publisherAssertion.value);
req.setAuthInfo(authInfo);
PublisherAssertions setPublisherAssertions = publishService.setPublisherAssertions(req);
publisherAssertion.value = MapUDDIv2Tov3.MapListPublisherAssertion(setPublisherAssertions);
} catch (DispositionReport ex) {
throw MapUDDIv2Tov3.MapException(ex);
} catch (SOAPFaultException ex) {
throw MapUDDIv2Tov3.MapException(ex);
}
}
@Override
public Map<String, Object> getRequestContext() {
return ((BindingProvider) publishService).getRequestContext();
}
@Override
public Map<String, Object> getResponseContext() {
return ((BindingProvider) publishService).getResponseContext();
}
@Override
public Binding getBinding() {
return ((BindingProvider) publishService).getBinding();
}
@Override
public EndpointReference getEndpointReference() {
return ((BindingProvider) publishService).getEndpointReference();
}
@Override
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
return ((BindingProvider) publishService).getEndpointReference(clazz);
}
}
| [
"alexoree@unknown"
] | alexoree@unknown |
4e0070cd7385500a9fcbbc2e130224c752da0587 | b514d08b9a98ffada93f204d5bef17bcbacdb6ac | /src/main/java/net/anasa/util/data/DataConform.java | b10b6464568b266c352793569d985e8e5666f3a4 | [] | no_license | cm3175/anasa-util | 194dce9d88495b23b68095ee558c9a7437135e84 | e493942d847f2a76d7c55d8a029204fee2200253 | refs/heads/master | 2021-01-24T21:25:24.686915 | 2014-09-23T23:47:24 | 2014-09-23T23:47:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,011 | java | package net.anasa.util.data;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
public abstract class DataConform
{
public static <T, O> List<O> conform(T[] data, IConformHandler<T, O> handler) throws FormatException
{
return conform(Arrays.asList(data), handler);
}
public static <T, O> List<O> conform(Iterable<T> data, IConformHandler<T, O> handler) throws FormatException
{
List<O> list = new ArrayList<>(data instanceof Collection ? ((Collection<T>)data).size() : 10);
for(T item : data)
{
list.add(handler.getFrom(item));
}
return list;
}
public interface IConformHandler<T, O>
{
public O getFrom(T data) throws FormatException;
}
public static class FormatException extends Exception
{
public FormatException(String message)
{
super(message);
}
public FormatException(Throwable e)
{
super(e);
}
public FormatException(String message, Throwable e)
{
super(message, e);
}
}
}
| [
"ryanvandersmith@hotmail.com"
] | ryanvandersmith@hotmail.com |
fe4b6cd2cc3edd539831a285d06cd6f9cb4a56b0 | 1ef0dae251b57d13362d34139e82d515dde2c5a8 | /src/com/mom/basicOOP/Animal.java | 3fb9e98774b028aa1443116d265f04dcd02008d5 | [] | no_license | jren2019/MyJavaSE | a4a9770f5e0721eadc497eafb65be6196bd0bca9 | f09877cb97681428f80cf7396560010deeb91ac2 | refs/heads/master | 2022-12-18T22:12:32.694363 | 2020-09-24T19:01:44 | 2020-09-24T19:01:44 | 285,451,320 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 279 | java | package com.mom.basicOOP;
public class Animal {
String Name;
public String Action(){
return "Animal is crying";
};
@Override
public String toString() {
return "Animal{" +
"Name='" + Name + '\'' +
'}';
}
}
| [
"junren@sushlabs.com"
] | junren@sushlabs.com |
4db6bc876acdecad6a18f8f68e6815545043b8be | 481b73028edc4e3fb2cc1f9491bfacfed2082f6e | /app/src/main/java/com/example/dasolee/registeration/ImageListAdapter.java | 86e7abba2cca8df3f415e0e7879dbaa8aaf2cd3e | [] | no_license | DLEKTHF/Alibi_RequestList | 643cbfed2c63425df8f2c147a633812870cc74f4 | acd61a6fa94f3cdaa784473be814c018daaebcc4 | refs/heads/master | 2020-03-17T05:26:47.685950 | 2018-05-28T14:00:27 | 2018-05-28T14:00:27 | 133,316,926 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,759 | java | package com.example.dasolee.registeration;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
public class ImageListAdapter extends BaseAdapter {
private ArrayList<Image> imageViewItemList = new ArrayList<Image>() ;
public ImageListAdapter() {
}
// Adapter에 사용되는 데이터의 개수를 리턴. : 필수 구현
@Override
public int getCount() {
return imageViewItemList.size() ;
}
// position에 위치한 데이터를 화면에 출력하는데 사용될 View를 리턴. : 필수 구현
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int pos = position;
final Context context = parent.getContext();
// "listview_item" Layout을 inflate하여 convertView 참조 획득.
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.image, parent, false);
}
// 화면에 표시될 View(Layout이 inflate된)으로부터 위젯에 대한 참조 획득
ImageView iconImageView = (ImageView) convertView.findViewById(R.id.imageView1) ;
TextView titleTextView = (TextView) convertView.findViewById(R.id.textView1) ;
TextView descTextView = (TextView) convertView.findViewById(R.id.textView2) ;
// Data Set(listViewItemList)에서 position에 위치한 데이터 참조 획득
Image image = imageViewItemList.get(position);
// 아이템 내 각 위젯에 데이터 반영
iconImageView.setImageDrawable(image.getIcon());
titleTextView.setText(image.getTitle());
descTextView.setText(image.getDesc());
return convertView;
}
// 지정한 위치(position)에 있는 데이터와 관계된 아이템(row)의 ID를 리턴. : 필수 구현
@Override
public long getItemId(int position) {
return position ;
}
// 지정한 위치(position)에 있는 데이터 리턴 : 필수 구현
@Override
public Object getItem(int position) {
return imageViewItemList.get(position) ;
}
// 아이템 데이터 추가를 위한 함수. 개발자가 원하는대로 작성 가능.
public void addItem(Drawable icon, String title, String desc) {
Image item = new Image();
item.setIcon(icon);
item.setTitle(title);
item.setDesc(desc);
imageViewItemList.add(item);
}
}
| [
"dleekthf@naver.com"
] | dleekthf@naver.com |
1524d5d408cfd5b8d44359d5870dd3f6abfc07cd | 32d0cf330c24a20124d394c94c364e2cffebf74b | /ermp-view-service/src/main/java/com/aker/ermp/queryside/ErmpViewServiceMain.java | 062ea87d17d2b61452025ba4f9781e46d79567d6 | [] | no_license | aker/eventuate-examples-ermp | b166ac989915557ba5831a809416858f9930a740 | 4845aae1477f4770d91e4fcdf8347b62682ef36b | refs/heads/master | 2021-01-01T18:35:42.522745 | 2017-09-05T01:42:12 | 2017-09-05T01:42:12 | 98,370,233 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 847 | java | package com.aker.ermp.queryside;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import com.aker.ermp.commonswagger.CommonSwaggerConfiguration;
import com.aker.ermp.queryside.web.ErmpViewWebConfiguration;
import io.eventuate.javaclient.driver.EventuateDriverConfiguration;
@Configuration
@Import({ErmpViewWebConfiguration.class, EventuateDriverConfiguration.class, CommonSwaggerConfiguration.class})
@EnableAutoConfiguration
@ComponentScan
public class ErmpViewServiceMain {
public static void main(String[] args) {
SpringApplication.run(ErmpViewServiceMain.class, args);
}
} | [
"kzjmail@gmail.com"
] | kzjmail@gmail.com |
c1f41b938d06b9bb47e58b9d634ca09dbd3018e6 | 3e0d77eedc400f6925ee8c75bf32f30486f70b50 | /CoreJava/src/com/techchefs/javaapps/learning/annotations/ForAnnotations.java | 67e0cf38c3727a46b1352f4b311208c00c4440f0 | [] | no_license | sanghante/ELF-06June19-TechChefs-SantoshG | 1c1349a1e4dcea33923dda73cdc7e7dbc54f48e6 | a13c01aa22e057dad1e39546a50af1be6ab78786 | refs/heads/master | 2023-01-10T05:58:52.183306 | 2019-08-14T13:26:12 | 2019-08-14T13:26:12 | 192,526,998 | 0 | 0 | null | 2023-01-04T07:13:13 | 2019-06-18T11:30:13 | Rich Text Format | UTF-8 | Java | false | false | 185 | java | package com.techchefs.javaapps.learning.annotations;
@FunctionalInterface
public interface ForAnnotations {
void eat();
default void hide() {
System.out.println("Hide");
}
}
| [
"santhosh.ghante@yahoo.com"
] | santhosh.ghante@yahoo.com |
6ec60abbead0d4e56b0b15fdc41acd299a0f8c53 | 4c14666a520f4e5b7405c18d1e17a4856504722a | /app/src/main/java/com/haoyu/app/activity/AppSurveyHomeActivity.java | 0252ec131e2bed38605be6cfe716fc1d72afc62e | [] | no_license | theboundaryforever/lingnan_teach-1 | a3cf5b618b5f139c66ab837f3db85e41f29a1888 | 0e6ebd78ce9e26ee5439fb3be74faefb893f6201 | refs/heads/master | 2021-07-06T10:58:53.170609 | 2017-09-30T03:03:33 | 2017-09-30T03:03:33 | 103,899,125 | 0 | 0 | null | 2017-09-18T06:07:35 | 2017-09-18T06:07:35 | null | UTF-8 | Java | false | false | 6,649 | java | package com.haoyu.app.activity;
import android.content.Intent;
import android.text.Html;
import android.text.Spanned;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.haoyu.app.base.BaseActivity;
import com.haoyu.app.entity.AppActivityViewEntity;
import com.haoyu.app.entity.CourseSurveyEntity;
import com.haoyu.app.entity.TimePeriod;
import com.haoyu.app.lingnan.teacher.R;
import com.haoyu.app.utils.Constants;
import com.haoyu.app.utils.TimeUtil;
import com.haoyu.app.view.AppToolBar;
import org.sufficientlysecure.htmltextview.HtmlHttpImageGetter;
import butterknife.BindView;
/**
* 创建日期:2016/12/24 on 10:44
* 描述:
* 作者:马飞奔 Administrator
*/
public class AppSurveyHomeActivity extends BaseActivity {
private AppSurveyHomeActivity context = this;
@BindView(R.id.toolBar)
AppToolBar toolBar;
@BindView(R.id.time_layout)
View time_layout;
@BindView(R.id.survey_time)
TextView survey_time;
@BindView(R.id.welcome)
TextView welcome;
@BindView(R.id.tv_survey_title)
TextView tv_survey_title;
@BindView(R.id.tv_description)
TextView tv_description;
@BindView(R.id.rl_take_part_in)
RelativeLayout rl_take_part_in;
private String relationId;
private String type;
private String activityId;
private String surveyId;
private String surveyTitle;
@BindView(R.id.surveyIco)
ImageView surveyIco;
@BindView(R.id.survey_content)
LinearLayout survey_content;
@BindView(R.id.stopTips)
TextView stopTips;
@BindView(R.id.tv_bottomtips)
TextView tv_bottomtips;
private String state;
private boolean running, isStop;
private TimePeriod timePeriod;
private AppActivityViewEntity.SurveyUserMobileEntity mSurveyUser;
private int REQUEST_CODE = 1;
@Override
public int setLayoutResID() {
return R.layout.activity_survey_home;
}
@Override
public void initView() {
running = getIntent().getBooleanExtra("running", false);
timePeriod = (TimePeriod) getIntent().getSerializableExtra("timePeriod");
mSurveyUser = (AppActivityViewEntity.SurveyUserMobileEntity) getIntent().getSerializableExtra("surveyUser");
type = getIntent().getStringExtra("type");
relationId = getIntent().getStringExtra("relationId");
activityId = getIntent().getStringExtra("activityId");
String activityTitle = getIntent().getStringExtra("activityTitle");
if (activityTitle != null && activityTitle.trim().length() > 0)
toolBar.setTitle_text(Html.fromHtml(activityTitle).toString());
else
toolBar.setTitle_text("问卷调查");
}
public void initData() {
updateUI(timePeriod);
if (mSurveyUser != null) {
state = mSurveyUser.getState();
updateUI(mSurveyUser.getmSurvey());
}
}
private void updateUI(TimePeriod timePeriod) {
if (running) {
if (timePeriod != null && timePeriod.getMinutes() > 0) { //活动在时间范围内
survey_time.setText("离问卷调研结束还剩:" + TimeUtil.computeTimeDiff(timePeriod.getMinutes()));
} else {
if (timePeriod != null && timePeriod.getState() != null)
survey_time.setText("问卷调研" + timePeriod.getState());
else
survey_time.setText("问卷调研进行中");
}
showSurvey();
} else {
isStop = true;
stopSurvey();
}
}
private void updateUI(CourseSurveyEntity surveyEntity) {
surveyId = surveyEntity.getId();
surveyTitle = surveyEntity.getTitle();
tv_survey_title.setText(surveyTitle);
toolBar.setTitle_text(surveyTitle);
String description = surveyEntity.getDescription();
Spanned spanned = Html.fromHtml(description, new HtmlHttpImageGetter(tv_description, Constants.REFERER, true), null);
tv_description.setText(spanned);
}
private void showSurvey() {
surveyIco.setImageResource(R.drawable.course_survey_home_ig);
time_layout.setVisibility(View.VISIBLE);
welcome.setVisibility(View.VISIBLE);
survey_content.setVisibility(View.VISIBLE);
tv_bottomtips.setText("开始问卷调查");
}
private void stopSurvey() {
surveyIco.setImageResource(R.drawable.course_survey_home_stop_icon);
time_layout.setVisibility(View.GONE);
welcome.setVisibility(View.GONE);
stopTips.setVisibility(View.VISIBLE);
toolBar.setTitle_text("调研问卷");
tv_bottomtips.setText("查看问卷");
}
@Override
public void setListener() {
toolBar.setOnLeftClickListener(new AppToolBar.OnLeftClickListener() {
@Override
public void onLeftClick(View view) {
finish();
}
});
rl_take_part_in.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isStop) {
Intent intent = new Intent(context, AppSurveyResultActivity.class);
intent.putExtra("type", type);
intent.putExtra("relationId", relationId);
intent.putExtra("activityId", activityId);
intent.putExtra("surveyId", surveyId);
intent.putExtra("surveyTitle", surveyTitle);
startActivity(intent);
finish();
} else {
Intent intent = new Intent(context, AppPageSurveyActivity.class);
if (running) {
intent.putExtra("canSubmit", true);
}
intent.putExtra("type", type);
intent.putExtra("relationId", relationId);
intent.putExtra("activityId", activityId);
intent.putExtra("surveyTitle", surveyTitle);
intent.putExtra("surveyId", surveyId);
intent.putExtra("state", state);
startActivityForResult(intent, REQUEST_CODE);
}
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null) {
setResult(RESULT_OK, data);
finish();
}
}
}
| [
"xiaoma920406@126.c0m"
] | xiaoma920406@126.c0m |
9e154b6daf3eca13b254cb5e4802b9a8146faec2 | eb8ff90411d0907e957a04519ab621a9a0da8739 | /app/src/main/java/com/androidmarket/easypdfconverter/util/FeedbackUtils.java | c0b053af097cc15cd02bcb781122fe025940e606 | [] | no_license | Amit2569/PDF-Converter | 09c01238295693c2f83551a37cf5ee920b777068 | 105574bc8b1cbe0881ef5d9f33a50f9c297a21d2 | refs/heads/master | 2023-09-03T22:50:54.169200 | 2021-10-23T04:21:31 | 2021-10-23T04:21:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,383 | java | package com.androidmarket.easypdfconverter.util;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.preference.PreferenceManager;
import static com.androidmarket.easypdfconverter.Constants.LAUNCH_COUNT;
import androidmarket.R;
public class FeedbackUtils {
private final Activity mContext;
private final SharedPreferences mSharedPreferences;
public FeedbackUtils(Activity context) {
this.mContext = context;
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
}
/**
* Share application's playstore link
*/
public void shareApplication() {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, mContext.getResources().getString(R.string.rate_us_text));
openMailIntent(intent);
}
public void openMailIntent(Intent intent) {
try {
mContext.startActivity(Intent.createChooser(intent, mContext.getString(R.string.share_chooser)));
} catch (android.content.ActivityNotFoundException ex) {
StringUtils.getInstance().showSnackbar(mContext, R.string.snackbar_no_share_app);
}
}
/**
* Open application in play store, so that user can rate
*/
public void rateUs() {
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(mContext.getString(R.string.rate_title))
.setMessage(mContext.getString(R.string.rate_dialog_text))
.setNegativeButton(mContext.getString(R.string.rate_negative),
(dialogInterface, i) -> {
mSharedPreferences.edit().putInt(LAUNCH_COUNT, 0).apply();
dialogInterface.cancel();
})
.setPositiveButton(mContext.getString(R.string.rate_positive),
(dialogInterface, i) -> {
try {
mContext.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=" +
mContext.getApplicationContext().getPackageName())));
} catch (Exception e) {
openWebPage("https://play.google.com/store/apps/details?id=swati4star.createpdf");
}
mSharedPreferences.edit().putInt(LAUNCH_COUNT, -1).apply();
dialogInterface.dismiss();
})
.setNeutralButton(mContext.getString(R.string.rate_us_never), (dialogInterface, i) -> {
mSharedPreferences.edit().putInt(LAUNCH_COUNT, -1).apply();
dialogInterface.cancel();
});
builder.create().show();
}
/**
* Opens given web page in browser
* @param url - web page to open up
*/
public void openWebPage(String url) {
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
if (intent.resolveActivity(mContext.getPackageManager()) != null)
mContext.startActivity(intent);
}
}
| [
"sumit2607"
] | sumit2607 |
17dbe240b5ef7b0a28a03564bf0d9dcc8e1d6ce5 | f95d61ad4fe76137f22cf9cda67159db91606d5d | /src/main/java/edu/umn/cs/csci3081w/project/model/BusDeploymentStrategyNight.java | 15884cef80da008355cb771d9c3ca2837b9d0a8b | [] | no_license | wang8038/BusSimulatorSystem | c0cb90ebd2affe5d0df5d69a5922cf31a59dcb10 | d32aafd589d00ba48e4bcf2053ad039b47a44202 | refs/heads/main | 2023-03-23T03:00:42.237185 | 2021-03-18T03:25:22 | 2021-03-18T03:25:22 | 348,928,091 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 563 | java | package edu.umn.cs.csci3081w.project.model;
public class BusDeploymentStrategyNight implements BusDeploymentStrategy {
/**
* Returns small busses.
*
* @param name parameter for the name of the bus
* @param outbound parameter for outbound route
* @param inbound parameter for inbound route
* @param speed parameter for bus speed
* @return the next bus according to the strategy
*/
public Bus getNextBus(String name, Route outbound, Route inbound, double speed) {
return new SmallBus(name, outbound, inbound, speed);
}
}
| [
"wang8038@umn.edu"
] | wang8038@umn.edu |
bd90dffa478435a8bdca39c3d1a16bcbcbc44c6c | aa9dd5e54ab06932f6dc80323e19523b00d743f7 | /src/main/java/com/curso/resources/exception/StandardError.java | 043bc22ad8c3782b883e17f41345c091d25278b8 | [] | no_license | ivanleite/springboot | fd0adf39c8de7241e45af622d61dee557450d0d2 | 6a40ccbc9c180bf301b596423d2ee25572c8f8d8 | refs/heads/master | 2020-05-09T15:51:03.660239 | 2019-04-18T18:54:34 | 2019-04-18T18:54:34 | 181,247,862 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 769 | java | package com.curso.resources.exception;
import java.io.Serializable;
public class StandardError implements Serializable {
private static final long serialVersionUID = 1L;
private Integer status;
private String msg;
private Long timeStamp;
public StandardError(Integer status, String msg, Long timeStamp) {
super();
this.status = status;
this.msg = msg;
this.timeStamp = timeStamp;
}
public Integer getStatus() {
return status;
}
public String getMsg() {
return msg;
}
public Long getTimeStamp() {
return timeStamp;
}
public void setStatus(Integer status) {
this.status = status;
}
public void setMsg(String msg) {
this.msg = msg;
}
public void setTimeStamp(Long timeStamp) {
this.timeStamp = timeStamp;
}
}
| [
"imouraleite@gmail.com"
] | imouraleite@gmail.com |
c677f03d0a22f9f8aa6b4b48cc95c1b1dc6720a9 | 29fd0c041a74dcf3c99eed67df3efe5f3f080377 | /soa-be/src/main/java/ru/itmo/soa/soabe/entity/data/validator/CarValidator.java | 87dce420b17128a6e72397ad88206fce933c71fb | [] | no_license | DeltaZN/soa-lab-1 | f88d71f357e332b57a10da3c08a89e458705cb54 | 9aeb039fa62c4ba8a0c562f9baaed5612abc49c6 | refs/heads/master | 2023-07-27T05:13:57.452019 | 2021-09-14T17:27:52 | 2021-09-14T17:27:52 | 396,015,179 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 824 | java | package ru.itmo.soa.soabe.entity.data.validator;
import ru.itmo.soa.soabe.entity.data.CarData;
import ru.itmo.soa.soabe.entity.data.HumanData;
import javax.xml.bind.ValidationException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
public class CarValidator implements Validator<CarData> {
public List<String> validate(CarData car) throws ValidationException, IllegalAccessException {
List<String> errorList = new ArrayList<>();
if (car == null) {
return errorList;
}
for (Field f : CarData.class.getDeclaredFields()) {
f.setAccessible(true);
if (f.get(car) == null) {
errorList.add(String.format("Car %s isn't specified", f.getName()));
}
}
return errorList;
}
}
| [
"gsavin@devexperts.com"
] | gsavin@devexperts.com |
13f2f54a81f059f034fd2eadbdaf428fc9bdb3b4 | 8d7fac0cf75516c7994bc27603567951586e84f4 | /misc/PaintRobotPath.java | db825d6ccafb6c0258c953c0948aa94d21bfa8e3 | [] | no_license | evgmik/robocode_bots.frame-lib | 6aea6c22e16590aba7105816dfeb872ef65a7730 | 3eeb60c9b00317af1a88783e3181ddaaa94d4fec | refs/heads/master | 2021-01-19T08:34:23.764615 | 2017-12-04T02:57:48 | 2017-12-04T02:57:48 | 41,282,990 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,240 | java | package eem.frame.misc;
// borrowed from wompi.misc.painter
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.GeneralPath;
import java.util.HashMap;
public class PaintRobotPath
{
static HashMap<String, PathHelper> pathMap = new HashMap<String, PathHelper>();
static long lastTime;
public static void onPaint(Graphics2D g,String botName, long time, double xRobot,double yRobot, Color pathColor)
{
if (lastTime > time) pathMap.clear(); // new battle reset
lastTime = time;
PathHelper myPath = pathMap.get(botName);
if (myPath == null)
{
myPath = new PathHelper();
myPath.rName = botName;
myPath.rPath = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 2000);
myPath.rPath.moveTo (xRobot, yRobot);
myPath.rColor = pathColor;
pathMap.put(botName, myPath);
}
if (time - myPath.rTime >= 5) // thin out the path
{
myPath.rPath.lineTo(xRobot,yRobot);
myPath.rTime = time;
}
for (PathHelper helper : pathMap.values())
{
if ((time - helper.rTime) >= 30) continue; // dead robots fade away after 30 turns
g.setColor(helper.rColor);
g.draw(helper.rPath);
}
}
}
class PathHelper
{
GeneralPath rPath;
String rName;
Color rColor;
long rTime;
}
| [
"evgmik@gmail.com"
] | evgmik@gmail.com |
79a00ac5fed8e1914b1a28bd88694210681b0d0b | 2ad3736c11cb11c2aa82819990734e0c3f1159af | /backend/src/main/java/com/pomhotel/booking/ui/api/v1/exceptions/ApiManagerException.java | e507589192ee1cdfd1d1496d036e625cc85013f5 | [] | no_license | leguim-repo/pom-hotel-mike | 7744b47c6aeddce2db074d6c5c7c5a79976bfceb | c9ab52bcb74f6515d91cfc54e5f069eb92d37239 | refs/heads/master | 2023-03-31T04:54:22.703638 | 2021-01-30T21:37:15 | 2021-01-30T21:37:15 | 302,645,084 | 0 | 0 | null | 2021-01-30T21:37:16 | 2020-10-09T13:11:56 | JavaScript | UTF-8 | Java | false | false | 1,123 | java | package com.pomhotel.booking.ui.api.v1.exceptions;
import com.pomhotel.booking.ui.api.v1.dto.BookingApiDTO;
import java.io.Serializable;
public class ApiManagerException extends RuntimeException implements Serializable {
private ApiManagerException(Exception e, String errorMessage) {
super(errorMessage, e);
}
public static ApiManagerException RoomNotFoundById(Exception e, String id) {
return new ApiManagerException(e, "RoomNotFoundById. Room id = " + id + " NOT FOUND");
}
public static ApiManagerException BookingApiException(Exception e, BookingApiDTO dto) {
return new ApiManagerException(e, "BookingApiDTO Malformed dto = " + dto.toString());
}
public static ApiManagerException NotFoundGetAllReservedDatesByRoomIdApi(Exception e, String id) {
return new ApiManagerException(e, "NotFoundGetAllReservedDatesByRoomIdApi id = " + id + " NOT FOUND");
}
public static ApiManagerException BookRoomNowException(Exception e, BookingApiDTO dto) {
return new ApiManagerException(e, "BookRoomNow Malformed dto = " + dto.toString());
}
}
| [
"60325499+leguim-repo@users.noreply.github.com"
] | 60325499+leguim-repo@users.noreply.github.com |
0ec2a5442dfbed2ca6cb1288fef743bf6534c90a | 901f25b16295f1f4bddd49c190a3c0a7da4d2ac7 | /src/com/example/carousels/MainRecyclerAdapter.java | 19a4b6302a40a7705451fdd61939515e1ac73fdc | [] | no_license | joShinichi/carousels | e4bf48dd1b6f8f063f84982156583397406d5bf5 | 6bc8c1e77bee65f43f36ba79a592cccb393bdf66 | refs/heads/master | 2021-01-18T07:30:54.071494 | 2014-12-05T08:37:42 | 2014-12-05T08:37:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,247 | java | package com.example.carousels;
import java.util.List;
import com.example.carousels.R;
import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.OnScrollListener;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class MainRecyclerAdapter extends RecyclerView.Adapter<MainRecyclerAdapter.ViewHolder> {
public static final String LOGTAG ="carousels";
private List<List<Item>> mRows;
Context mContext;
public MainRecyclerAdapter(List<List<Item>> objects,Context context) {
mContext = context;
mRows = objects;
}
static class ViewHolder extends RecyclerView.ViewHolder{
public RecyclerView mRecyclerViewRow;
public ViewHolder(View itemView) {
super(itemView);
mRecyclerViewRow =(RecyclerView)itemView.findViewById(R.id.recyclerView_row);
}
}
@Override
public int getItemCount() {
return mRows.size();
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
List<Item> RowItems = mRows.get(position);
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext,LinearLayoutManager.HORIZONTAL,false);
holder.mRecyclerViewRow.setLayoutManager(layoutManager);
holder.mRecyclerViewRow.setHasFixedSize(true);
RowRecyclerAdapter rowsRecyclerAdapter = new RowRecyclerAdapter(mContext,RowItems);
holder.mRecyclerViewRow.setAdapter(rowsRecyclerAdapter);
final RecyclerView finalRecyclerView = holder.mRecyclerViewRow;
finalRecyclerView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged (RecyclerView recyclerView, int newState){
switch(newState){
case RecyclerView.SCROLL_STATE_IDLE:
float targetBottomPosition1 = finalRecyclerView.getX();
float targetBottomPosition2 = finalRecyclerView.getX() + finalRecyclerView.getWidth();
Log.i(LOGTAG,"targetBottomPosition1 = " + targetBottomPosition1);
Log.i(LOGTAG,"targetBottomPosition2 = " + targetBottomPosition2);
View v1 = finalRecyclerView.findChildViewUnder(targetBottomPosition1,0);
View v2 = finalRecyclerView.findChildViewUnder(targetBottomPosition2,0);
float x1 = targetBottomPosition1;
if(v1!=null){
x1 =v1.getX();
}
float x2 = targetBottomPosition2;
if(v2!=null){
x2 =v2.getX();
}
Log.i(LOGTAG,"x1 = " + x1);
Log.i(LOGTAG,"x2 = " + x2);
float dx1 = Math.abs(finalRecyclerView.getX()-x1 );
float dx2 = Math.abs(finalRecyclerView.getX()+ finalRecyclerView.getWidth()-x2);
Log.i(LOGTAG,"dx1 = " + dx1);
Log.i(LOGTAG,"dx2 = " + dx2);
float visiblePortionOfItem1 = 0;
float visiblePortionOfItem2 = 0;
if(x1<0 && v1 != null){
visiblePortionOfItem1 = v1.getWidth() - dx1;
}
if(v2 != null){
visiblePortionOfItem2 = v2.getWidth() - dx2;
}
Log.i(LOGTAG,"visiblePortionOfItem1 = " + visiblePortionOfItem1);
Log.i(LOGTAG,"visiblePortionOfItem2 = " + visiblePortionOfItem2);
int position = 0;
if(visiblePortionOfItem1>=visiblePortionOfItem2){
position = finalRecyclerView.getChildPosition(finalRecyclerView.findChildViewUnder(targetBottomPosition1,0));
}else{
position = finalRecyclerView.getChildPosition(finalRecyclerView.findChildViewUnder(targetBottomPosition2,0));
}
finalRecyclerView.scrollToPosition(position);
break;
case RecyclerView.SCROLL_STATE_DRAGGING:
break;
case RecyclerView.SCROLL_STATE_SETTLING:
break;
}
}
@Override
public void onScrolled (RecyclerView recyclerView, int dx, int dy){
// Log.i(LOGTAG,"X = " + dx + " and Y = " + dy);
}
});
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int arg1) {
LayoutInflater inflater =
(LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View convertView = inflater.inflate(R.layout.row, parent, false);
return new ViewHolder(convertView);
}
}
| [
"meworking93@gmail.com"
] | meworking93@gmail.com |
45ded8729aa944ef7a05382182a34bf5ba919c3a | eaf010bf171a9fa5d0759608984ee07f9b1c379f | /is-migration-client/src/main/java/migration/service/v530/RegistryDataManager.java | 17fad24d4a10f92503c0941f837fcf64ce74315f | [] | no_license | tgtshanika/apim-2.1.0-2.5.0-migration | 7b55cd8fadabaffd788097d6db95ffacba5f4b9e | dea5b9df96390d0fdab82ab9d4e3a33dbe89c423 | refs/heads/master | 2020-03-26T21:34:28.319103 | 2018-08-20T09:23:56 | 2018-08-20T09:23:56 | 145,395,839 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 17,997 | java | /*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. 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 migration.service.v530;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.base.IdentityException;
import org.wso2.carbon.identity.core.util.IdentityIOStreamUtils;
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
import org.wso2.carbon.identity.recovery.model.ChallengeQuestion;
import org.wso2.carbon.identity.recovery.util.Utils;
import org.wso2.carbon.is.migration.internal.ISMigrationServiceDataHolder;
import org.wso2.carbon.registry.api.Collection;
import org.wso2.carbon.registry.api.Registry;
import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.api.Resource;
import org.wso2.carbon.registry.core.ResourceImpl;
import org.wso2.carbon.user.api.Tenant;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Paths;
import java.util.*;
import static org.wso2.carbon.base.MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
import static org.wso2.carbon.context.RegistryType.SYSTEM_CONFIGURATION;
import static org.wso2.carbon.identity.recovery.IdentityRecoveryConstants.Questions.*;
import static org.wso2.carbon.registry.core.RegistryConstants.PATH_SEPARATOR;
import static org.wso2.carbon.registry.core.RegistryConstants.TAG_MEDIA_TYPE;
public class RegistryDataManager {
private static RegistryDataManager instance = new RegistryDataManager();
private static final Log log = LogFactory.getLog(RegistryDataManager.class);
private static final String SCOPE_RESOURCE_PATH = "/oidc";
private static final String EMAIL_TEMPLATE_OLD_REG_LOCATION = "/identity/config/emailTemplate";
private static final String EMAIL_TEMPLATE_NEW_REG_LOCATION_ROOT = "/identity/email/";
private static final Set<String> TEMPLATE_NAMES = new HashSet<String>() {{
add("accountConfirmation");
add("accountDisable");
add("accountEnable");
add("accountIdRecovery");
add("accountUnLock");
add("askPassword");
add("otp");
add("passwordReset");
add("temporaryPassword");
}};
private static final Map<String, String> PLACEHOLDERS_MAP = new HashMap<String, String>() {{
put("\\{first-name\\}", "{{user.claim.givenname}}");
put("\\{user-name\\}", "{{user-name}}");
put("\\{confirmation-code\\}", "{{confirmation-code}}");
put("\\{userstore-domain\\}", "{{userstore-domain}}");
put("\\{url:user-name\\}", "{{url:user-name}}");
put("\\{tenant-domain\\}", "{{tenant-domain}}");
put("\\{temporary-password\\}", "{{temporary-password}}");
}};
/*
Constants related challenge question migration.
*/
private static final String OLD_CHALLENGE_QUESTIONS_PATH =
"/repository/components/org.wso2.carbon.identity.mgt/questionCollection";
private static final String NEW_CHALLENGE_QUESTIONS_PATH = "/identity/questionCollection";
private static final String OLD_QUESTION_SET_PROPERTY = "questionSetId";
private static final String OLD_QUESTION_PROPERTY = "question";
private static final String DEFAULT_LOCALE = "en_US";
private static final String TEMPLATE_NAME = "migratedQuestion%d";
private RegistryDataManager() {
}
public static RegistryDataManager getInstance() {
return instance;
}
public void migrateEmailTemplates(boolean migrateActiveTenantsOnly) throws Exception {
//migrating super tenant configurations
try {
migrateTenantEmailTemplates();
log.info("Email templates migrated for tenant : " + SUPER_TENANT_DOMAIN_NAME);
} catch (Exception e) {
log.error("Error while migrating email templates for tenant : " + SUPER_TENANT_DOMAIN_NAME, e);
}
//migrating tenant configurations
Tenant[] tenants = ISMigrationServiceDataHolder
.getRealmService().getTenantManager().getAllTenants();
for (Tenant tenant : tenants) {
if (migrateActiveTenantsOnly && !tenant.isActive()) {
log.info("Tenant " + tenant.getDomain() + " is inactive. Skipping Email Templates migration!!!!");
continue;
}
try {
startTenantFlow(tenant);
IdentityTenantUtil.getTenantRegistryLoader().loadTenantRegistry(tenant.getId());
migrateTenantEmailTemplates();
log.info("Email templates migrated for tenant : " + tenant.getDomain());
} catch (Exception e) {
log.error("Error while migrating email templates for tenant : " + tenant.getDomain(), e);
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
}
}
private void migrateTenantEmailTemplates() throws IdentityException {
Registry registry = PrivilegedCarbonContext.getThreadLocalCarbonContext().getRegistry(SYSTEM_CONFIGURATION);
try {
if (registry.resourceExists(EMAIL_TEMPLATE_OLD_REG_LOCATION)) {
Properties properties = registry.get(EMAIL_TEMPLATE_OLD_REG_LOCATION).getProperties();
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
if (!TEMPLATE_NAMES.contains(entry.getKey())) {
log.info("Skipping probable invalid template :" + entry.getKey());
continue;
}
String[] templateParts = ((List<String>) entry.getValue()).get(0).split("\\|");
if (templateParts.length != 3) {
log.warn("Skipping invalid template data. Expected 3 sections, but contains " +
templateParts.length);
}
String newResourcePath =
EMAIL_TEMPLATE_NEW_REG_LOCATION_ROOT + entry.getKey().toString().toLowerCase() +
"/en_us";
String newContent = String.format("[\"%s\",\"%s\",\"%s\"]",
updateContent(templateParts[0]),
updateContent(templateParts[1]),
updateContent(templateParts[2]));
Resource resource;
if (registry.resourceExists(newResourcePath)) {
resource = registry.get(newResourcePath);
} else {
resource = registry.newResource();
resource.addProperty("display", (String) entry.getKey());
resource.addProperty("type", (String) entry.getKey());
resource.addProperty("emailContentType", "text/plain");
resource.addProperty("locale", "en_US");
}
resource.setContent(newContent);
resource.setMediaType("tag");
registry.put(newResourcePath, resource);
}
}
} catch (RegistryException e) {
throw IdentityException.error("Error while migration registry data", e);
}
}
private String updateContent(String s) {
//update the placeholders
for (Map.Entry<String, String> entry : PLACEHOLDERS_MAP.entrySet()) {
s = s.replaceAll(entry.getKey(), entry.getValue());
}
//update the new line
s = s.replaceAll("\n", "\\\\n");
return s;
}
public void migrateChallengeQuestions(boolean migrateActiveTenantsOnly) throws Exception {
//migrating super tenant configurations
try {
migrateChallengeQuestionsForTenant();
log.info("Challenge Questions migrated for tenant : " + SUPER_TENANT_DOMAIN_NAME);
} catch (Exception e) {
log.error("Error while migrating challenge questions for tenant : " + SUPER_TENANT_DOMAIN_NAME, e);
}
//migrating tenant configurations
Tenant[] tenants = ISMigrationServiceDataHolder.getRealmService().getTenantManager().getAllTenants();
for (Tenant tenant : tenants) {
if (migrateActiveTenantsOnly && !tenant.isActive()) {
log.info("Tenant " + tenant.getDomain() + " is inactive. Skipping challenge question migration!!!!");
continue;
}
try {
startTenantFlow(tenant);
IdentityTenantUtil.getTenantRegistryLoader().loadTenantRegistry(tenant.getId());
migrateChallengeQuestionsForTenant();
log.info("Challenge Questions migrated for tenant : " + tenant.getDomain());
} catch (Exception e) {
log.error("Error while migrating challenge questions for tenant : " + tenant.getDomain(), e);
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
}
}
private void migrateChallengeQuestionsForTenant() throws Exception {
// read the old questions
Registry registry = PrivilegedCarbonContext.getThreadLocalCarbonContext().getRegistry(SYSTEM_CONFIGURATION);
try {
if (registry.resourceExists(OLD_CHALLENGE_QUESTIONS_PATH)) {
Collection questionCollection = (Collection) registry.get(OLD_CHALLENGE_QUESTIONS_PATH);
Map<String, Integer> countMap = new HashMap<>();
for (String challengeQuestionPath : questionCollection.getChildren()) {
// old challenge question.
Resource oldQuestion = registry.get(challengeQuestionPath);
String questionSetId = oldQuestion.getProperty(OLD_QUESTION_SET_PROPERTY);
String question = oldQuestion.getProperty(OLD_QUESTION_PROPERTY);
// find the correct question number for migrated questions
int questionCount = countMap.containsKey(questionSetId) ? countMap.get(questionSetId) : 1;
countMap.put(questionSetId, questionCount + 1);
String questionId = String.format(TEMPLATE_NAME, questionCount);
ChallengeQuestion challengeQuestion =
new ChallengeQuestion(questionSetId, questionId, question, DEFAULT_LOCALE);
// Create a registry resource for the new Challenge Question.
Resource resource = createRegistryResource(challengeQuestion);
registry.put(getQuestionPath(challengeQuestion), resource);
}
}
} catch (RegistryException e) {
throw IdentityException.error("Error while migration challenge question registry data", e);
}
}
private Resource createRegistryResource(ChallengeQuestion question) throws RegistryException,
UnsupportedEncodingException {
Resource resource = new ResourceImpl();
resource.setContent(question.getQuestion().getBytes("UTF-8"));
resource.addProperty(CHALLENGE_QUESTION_SET_ID, question.getQuestionSetId());
resource.addProperty(CHALLENGE_QUESTION_ID, question.getQuestionId());
resource.addProperty(CHALLENGE_QUESTION_LOCALE, question.getLocale());
resource.setMediaType(TAG_MEDIA_TYPE);
return resource;
}
/**
* Get the relative path to the parent directory of the challenge question resource.
*
* @param challengeQuestion challenge question to which the path is calculated
* @return Path to the parent of challenge question relative to the root of the registry.
*/
private String getQuestionPath(ChallengeQuestion challengeQuestion) {
// challenge set uri
String questionSetIdUri = challengeQuestion.getQuestionSetId();
String questionId = challengeQuestion.getQuestionId();
String questionSetId = Utils.getChallengeSetDirFromUri(questionSetIdUri);
String locale = challengeQuestion.getLocale().toLowerCase();
return NEW_CHALLENGE_QUESTIONS_PATH + PATH_SEPARATOR + questionSetId + PATH_SEPARATOR + questionId +
PATH_SEPARATOR + locale;
}
private void startTenantFlow(Tenant tenant) {
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
carbonContext.setTenantId(tenant.getId());
carbonContext.setTenantDomain(tenant.getDomain());
}
public void copyOIDCScopeData(boolean migrateActiveTenantsOnly) throws Exception {
// since copying oidc-config file for super tenant is handled by the OAuth component we only need to handle
// this in migrated tenants.
Tenant[] tenants = ISMigrationServiceDataHolder.getRealmService().getTenantManager().getAllTenants();
for (Tenant tenant : tenants) {
if (migrateActiveTenantsOnly && !tenant.isActive()) {
log.info("Tenant " + tenant.getDomain() + " is inactive. Skipping copying OIDC Scopes Data !!!!");
continue;
}
try {
startTenantFlow(tenant);
IdentityTenantUtil.getTenantRegistryLoader().loadTenantRegistry(tenant.getId());
initiateOIDCScopes();
log.info("OIDC Scope data migrated for tenant : " + tenant.getDomain());
} catch (RegistryException | FileNotFoundException e) {
log.error("Error while migrating OIDC Scope data for tenant: " + tenant.getDomain(), e);
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
}
}
private void initiateOIDCScopes() throws RegistryException, FileNotFoundException, IdentityException {
Map<String, String> scopes = loadScopeConfigFile();
Registry registry = PrivilegedCarbonContext.getThreadLocalCarbonContext().getRegistry(SYSTEM_CONFIGURATION);
if(!registry.resourceExists(SCOPE_RESOURCE_PATH)) {
Resource resource = registry.newResource();
for (Map.Entry<String, String> entry : scopes.entrySet()) {
resource.setProperty(entry.getKey(), entry.getValue());
}
registry.put("/oidc", resource);
}
}
private static Map<String, String> loadScopeConfigFile() throws FileNotFoundException, IdentityException {
Map<String, String> scopes = new HashMap<>();
String carbonHome = System.getProperty("carbon.home");
String confXml = Paths.get(carbonHome,
new String[]{"repository", "conf", "identity", "oidc-scope-config.xml"}).toString();
File configfile = new File(confXml);
if(!configfile.exists()) {
String errMsg = "OIDC scope-claim Configuration File is not present at: " + confXml;
throw new FileNotFoundException(errMsg);
}
XMLStreamReader parser = null;
FileInputStream stream = null;
try {
stream = new FileInputStream(configfile);
parser = XMLInputFactory.newInstance().createXMLStreamReader(stream);
StAXOMBuilder builder = new StAXOMBuilder(parser);
OMElement documentElement = builder.getDocumentElement();
Iterator iterator = documentElement.getChildElements();
while(iterator.hasNext()) {
OMElement omElement = (OMElement)iterator.next();
String configType = omElement.getAttributeValue(new QName("id"));
scopes.put(configType, loadClaimConfig(omElement));
}
} catch (XMLStreamException ex) {
throw IdentityException.error("Error while loading scope config.", ex);
} finally {
try {
if(parser != null) {
parser.close();
}
if(stream != null) {
IdentityIOStreamUtils.closeInputStream(stream);
}
} catch (XMLStreamException ex) {
log.error("Error while closing XML stream", ex);
}
}
return scopes;
}
private static String loadClaimConfig(OMElement configElement) {
StringBuilder claimConfig = new StringBuilder();
Iterator it = configElement.getChildElements();
while(it.hasNext()) {
OMElement element = (OMElement)it.next();
if("Claim".equals(element.getLocalName())) {
String commaSeparatedClaimNames = element.getText();
if(StringUtils.isNotBlank(commaSeparatedClaimNames)) {
claimConfig.append(commaSeparatedClaimNames.trim());
}
}
}
return claimConfig.toString();
}
}
| [
"tgtshanika@gmail.com"
] | tgtshanika@gmail.com |
7c04fea6c2a58419a0d655eb5079367db4d618a7 | a52b1d91a5a2984591df9b2f03b1014c263ee8ab | /net/minecraft/client/resources/IResourceManagerReloadListener.java | 38fbc396ab06ae34b257802640fa456947fd2a40 | [] | no_license | MelonsYum/leap-client | 5c200d0b39e0ca1f2071f9264f913f9e6977d4b4 | c6611d4b9600311e1eb10f87a949419e34749373 | refs/heads/main | 2023-08-04T17:40:13.797831 | 2021-09-17T00:18:38 | 2021-09-17T00:18:38 | 411,085,054 | 3 | 3 | null | 2021-09-28T00:33:06 | 2021-09-28T00:33:05 | null | UTF-8 | Java | false | false | 373 | java | package net.minecraft.client.resources;
public interface IResourceManagerReloadListener {
void onResourceManagerReload(IResourceManager paramIResourceManager);
}
/* Location: C:\Users\wyatt\Downloads\Leap-Client.jar!\net\minecraft\client\resources\IResourceManagerReloadListener.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/ | [
"90357372+danny-125@users.noreply.github.com"
] | 90357372+danny-125@users.noreply.github.com |
188bc2e256e48dc39fb332aef6eddea1b76f534c | 2ec31b9fe2939097dc039abb68dcbb70d50efa19 | /easy-security-core/src/main/java/easy/security/core/social/wx/config/WxAutoConfig.java | 14a776a083891ae352659e744ffa42b633933b83 | [] | no_license | leo-1994/easy-security | fcd12c819ba96d58c469e2bf061f44e68c9c4192 | 74f3637caa1a43fbd847e7138567ec8acbbdd18f | refs/heads/master | 2022-07-20T18:43:43.233060 | 2019-09-16T07:33:56 | 2019-09-16T07:33:56 | 207,815,062 | 0 | 0 | null | 2022-06-17T02:29:03 | 2019-09-11T13:07:32 | Java | UTF-8 | Java | false | false | 1,567 | java | package easy.security.core.social.wx.config;
import easy.security.core.social.EasyConnectView;
import easy.security.core.social.support.SocialAutoConfigurerAdapter;
import easy.security.core.properties.EasySecurityProperties;
import easy.security.core.properties.WxProperties;
import easy.security.core.social.wx.connect.WxConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.social.connect.ConnectionFactory;
import org.springframework.web.servlet.View;
/**
* 微信登录配置
*
* @author chao.li@quvideo.com
* @date 2019/9/7 17:36
*/
@ConditionalOnProperty(prefix = "security.social.wx", name = "app-id")
@Configuration
public class WxAutoConfig extends SocialAutoConfigurerAdapter {
@Autowired
private EasySecurityProperties easySecurityProperties;
@Override
protected ConnectionFactory<?> createConnectionFactory() {
WxProperties wxConfig = easySecurityProperties.getSocial().getWx();
return new WxConnectionFactory(wxConfig.getProviderId(), wxConfig.getAppId(), wxConfig.getAppSecret());
}
@Bean({"connect/wxConnected", "connect/wxConnect"})
@ConditionalOnMissingBean(name = "wxConnectedView")
public View wxConnectedView() {
return new EasyConnectView();
}
}
| [
"leo_1994@qq.com"
] | leo_1994@qq.com |
78b6aef7cf20aeeb22905caaaedb95456f3f0cfb | 5459de262625a279425a08e76008f162309eb158 | /src/main/java/net/peelo/kahvi/compiler/parser/ParserException.java | 94170f8f6c9683d684611a671c828fe7b7aeabc5 | [
"BSD-3-Clause"
] | permissive | peelonet/kahvi | 32f372ddaec7dfdc1d4d522ba3fb013047644f00 | e6e4dc1c5ba31a99122c720a6fe47280687758b3 | refs/heads/master | 2021-01-25T07:19:13.158432 | 2014-06-29T17:42:57 | 2014-06-29T17:42:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 754 | java | package net.peelo.kahvi.compiler.parser;
import net.peelo.kahvi.compiler.util.SourceLocatable;
import net.peelo.kahvi.compiler.util.SourcePosition;
public final class ParserException extends RuntimeException
implements SourceLocatable
{
private final SourcePosition position;
ParserException(SourcePosition position, String message)
{
super(message);
this.position = position;
}
@Override
public SourcePosition getSourcePosition()
{
return this.position;
}
@Override
public String getMessage()
{
if (this.position == null)
{
return super.getMessage();
} else {
return this.position + ": " + super.getMessage();
}
}
}
| [
"da.cappu@gmail.com"
] | da.cappu@gmail.com |
699909b18f255ff23cadf4cdad1aeb1724fb90dc | 6fe0a7519f7a69030239f877b1c05eef46311652 | /src/test/java/com/test/jacoco/test/HelloWorldTest.java | 1cefcaf8a26dd367b595781b8dc81ecdca500942 | [] | no_license | charlyne/testjacoco | 3a87453b18398d2eea3bd98450af23830c109f27 | cb479f6b94838ea447e4a6e9a9bf69e74d1426a1 | refs/heads/master | 2021-07-08T13:23:49.148296 | 2020-02-11T09:32:45 | 2020-02-11T09:32:45 | 192,898,283 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 518 | java | package com.test.jacoco.test;
/**
* Created by zc on 2017/5/2.
*/
import junit.framework.Assert;
import org.junit.Test;
import com.test.jacoco.HelloWorld;
public class HelloWorldTest {
@Test
public void testMethod1() {
HelloWorld hw = new HelloWorld();
String ss = hw.testMethod1();
Assert.assertNotNull(ss);
}
@Test
public void testMethod2() {
HelloWorld hw = new HelloWorld();
int ss = hw.addMethod(1, 1);
Assert.assertEquals(ss, 2);
}
}
| [
"nanbiandehe@sina.com"
] | nanbiandehe@sina.com |
ccc42dcc0dcdfad91c4cfbf8b5b3c3872dc14755 | 8929dd0dd0596bf44a266a0312ab4f1544706d07 | /apps/poverenik/src/main/java/com/project/poverenik/model/zalba_cutanje/ObjectFactory.java | e52775473b6d5e1f580a00dbdeed42aa24f4d087 | [] | no_license | miloradradovic/XML_TIM7 | 008c71296c5505266326eb583d48e96462d60b22 | 9af9cfe9f9284c811d8b7be54c394cae339502a0 | refs/heads/main | 2023-02-28T01:39:06.383126 | 2021-02-06T21:18:59 | 2021-02-06T21:18:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,150 | java |
package com.project.poverenik.model.zalba_cutanje;
import javax.xml.bind.annotation.XmlRegistry;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.project.poverenik.model.zalba_cutanje package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*/
@XmlRegistry
public class ObjectFactory {
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.project.poverenik.model.zalba_cutanje
*/
public ObjectFactory() {
}
public Tzalba createTzalba() {
return new Tzalba();
}
/**
* Create an instance of {@link ZalbaCutanje }
*/
public ZalbaCutanje createZalbaCutanje() {
return new ZalbaCutanje();
}
}
| [
"romana_1998@hotmail.com"
] | romana_1998@hotmail.com |
874a5d142db5583668d696e152f55d284daafe48 | 14fc3039f76cfd34b3ed264b5fc4d1076aabd7c7 | /我学习的代码/cloud-config/src/test/java/com/ye/cloudconfig/CloudConfigApplicationTests.java | a6f8473f44fc13a4490c32eb92a182057a70e861 | [] | no_license | xiehai1983/often_user_shell | 6800f43d43f982cad49d80c54ecc2fa94f669d2c | eac6df77b2e10f09d7bdd93028fa6524423045e3 | refs/heads/master | 2023-07-07T14:24:50.254146 | 2021-08-10T16:38:32 | 2021-08-10T16:38:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 224 | java | package com.ye.cloudconfig;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class CloudConfigApplicationTests {
@Test
void contextLoads() {
}
}
| [
"1039288191@qq.com"
] | 1039288191@qq.com |
2622b8be5d1530179412a680e5edb355cccb8ffa | b7f3edb5b7c62174bed808079c3b21fb9ea51d52 | /components/module_installer/android/java/src/org/chromium/components/module_installer/builder/ModuleDescriptor.java | 74f0c3ccc6cacf07587015499c724b06960821e8 | [
"BSD-3-Clause"
] | permissive | otcshare/chromium-src | 26a7372773b53b236784c51677c566dc0ad839e4 | 64bee65c921db7e78e25d08f1e98da2668b57be5 | refs/heads/webml | 2023-03-21T03:20:15.377034 | 2020-11-16T01:40:14 | 2020-11-16T01:40:14 | 209,262,645 | 18 | 21 | BSD-3-Clause | 2023-03-23T06:20:07 | 2019-09-18T08:52:07 | null | UTF-8 | Java | false | false | 695 | java | // Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.components.module_installer.builder;
/**
* Provides information about a dynamic feature module.
*/
public interface ModuleDescriptor {
/**
* Returns the list of native library names this module requires at runtime.
*/
String[] getLibraries();
/**
* Returns the list of PAK resources files this module contains.
*/
String[] getPaks();
/**
* Returns whether to auto-load native libraries / resources on getImpl().
*/
boolean getLoadNativeOnGetImpl();
}
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
ab8741276c5c331a9520ead06d7875d211acd7ff | b54981b406108d6cf270e9aaae7b7e7bd7077a3b | /src/com/RedBus/Generic/BasePage.java | a14304c9d459ac04c863b36296d5b7a10dd4c936 | [] | no_license | SRIKANTN/Redbus | bc57ce7190311c97b3bf89f1c411219fb14175a1 | aa0d0f30c6086e39b6f2b94fc9aeecca7e898c10 | refs/heads/master | 2020-04-11T12:10:32.687577 | 2018-12-14T10:56:57 | 2018-12-14T10:56:57 | 161,772,029 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,220 | java | package com.RedBus.Generic;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.Reporter;
public class BasePage
{
public WebDriver driver;
public BasePage(WebDriver driver)
{
this.driver=driver;
}
public void verifyTitle(String etitle)
{
WebDriverWait wait= new WebDriverWait(driver, 20);
try
{
wait.until(ExpectedConditions.titleIs(etitle));
Reporter.log("Title is matiching"+etitle,true);
}
catch (Exception e)
{
Reporter.log("Title is not matching: Actual title is "+driver.getTitle(),true);
Assert.fail();
}
}
public void verifyElement(WebElement element)
{
WebDriverWait wait= new WebDriverWait(driver,20);
try
{
wait.until(ExpectedConditions.visibilityOf(element));
Reporter.log("Element is present",true);
}
catch (Exception e)
{
Reporter.log("element is not present",true);
Assert.fail();
}
}
}
| [
"qsp-exp@DESKTOP-EGJMG0E"
] | qsp-exp@DESKTOP-EGJMG0E |
856e40e9d5d3953e83d7acd5dc949ea3135de8b1 | b5ca09864e138e42182d810d4adaaa7771d64cd7 | /src/main/java/org/hyeji/jdbc/raw/ArticleDao.java | 0b48e734c6049b60f0b3d5d23f3069041a96f0e7 | [] | no_license | hyeji8755/hyeji_jdbc | 75aa8e1c6f1ebdb9bf60073ef208222235fb4298 | 63dd6382d2833c5af24a16ff4024a4f876707231 | refs/heads/master | 2020-04-30T19:49:34.709318 | 2019-03-22T09:31:22 | 2019-03-22T09:31:22 | 177,049,652 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 507 | java | package org.hyeji.jdbc.raw;
import java.util.List;
/**
* Data Access Object. 데이터베이스에 접속해서 데이터를 조작하는 인터페이스.
*
* @author hyeji
*/
public interface ArticleDao {
/**
* 목록
*/
List<Article> listArticles();
/**
* 조회
*/
Article getArticle(String articleId);
/**
* 등록
*/
void addArticle(Article article);
/**
* 수정
*/
void updateArticle(Article article);
/**
* 삭제
*/
void deleteArticle(String articleId);
} | [
"hyeji8755@hanmail.net"
] | hyeji8755@hanmail.net |
16783025257753bb117e63cea407c412676f6909 | 26b7f30c6640b8017a06786e4a2414ad8a4d71dd | /src/number_of_direct_superinterfaces/i46239.java | 847938375cb95af789827d1b274764a00b94baab | [] | no_license | vincentclee/jvm-limits | b72a2f2dcc18caa458f1e77924221d585f23316b | 2fd1c26d1f7984ea8163bc103ad14b6d72282281 | refs/heads/master | 2020-05-18T11:18:41.711400 | 2014-09-14T04:25:18 | 2014-09-14T04:25:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 69 | java | package number_of_direct_superinterfaces;
public interface i46239 {} | [
"vincentlee.dolbydigital@yahoo.com"
] | vincentlee.dolbydigital@yahoo.com |
21baf27014a5e1e8562856a0b95ac9e29cc0fde1 | 0d14e8a0fa92b1dafcef14ded3ed0b6ecbc8f4f1 | /src/main/java/org/bookmanagement/entity/BookEntity.java | e90c37c84dd964a5e79a33f9c0816cd178c0b219 | [] | no_license | venkatesh31/book-management | 929da2b678874ecd041d3f022cd01983c42590c7 | 2e758f3bbc6ec935b804afda5bec24ffd49c94e2 | refs/heads/main | 2023-01-31T04:00:19.733105 | 2020-12-11T11:31:12 | 2020-12-11T11:31:12 | 320,554,489 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,153 | java | package org.bookmanagement.entity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
@Entity
@Table(name = "book")
public class BookEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
@GenericGenerator(name = "native", strategy = "native")
@Column(name = "book_id", nullable = false)
private Integer bookId;
@Column(name = "name", nullable = false)
private String name;
@Column(name = "description", nullable = false)
private String description;
@Column(name = "category_id", nullable = false)
private Integer categoryId;
@Column(name = "author", nullable = false)
private String author;
@Column(name = "image_url", nullable = false)
private String imageUrl;
@Column(name = "publisher", nullable = false)
private String publisher;
@Column(name = "price", nullable = false)
private Integer price;
public Integer getBookId() {
return bookId;
}
public void setBookId(Integer bookId) {
this.bookId = bookId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getCategoryId() {
return categoryId;
}
public void setCategoryId(Integer categoryId) {
this.categoryId = categoryId;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getPublisher() {
return publisher;
}
public void setPublisher(String publisher) {
this.publisher = publisher;
}
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
} | [
"venkatesh@eventova.com"
] | venkatesh@eventova.com |
2b3cd809952886eabc354603fee96732f8173eaa | 9117ec8f618997d9575f8a6a21b888c6627a310a | /src/main/java/com/study/tiantian/proxy/dynamicproxy/ProxyFactory.java | 698288b5b518b67d8ea3806bd91821b643279fd8 | [] | no_license | kele6413430/design-pattern | 9f5c11d9d0c64eaf1b89c7cac96eb0a73f4e9af5 | 14a4fea8943bc00ce8f66b7c675f5a0a9531472a | refs/heads/master | 2023-03-26T11:39:48.321142 | 2021-03-16T11:39:40 | 2021-03-16T11:39:40 | 348,323,234 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 852 | java | package com.study.tiantian.proxy.dynamicproxy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
/**
* <p></p>
*
* @author yuantiantian
* @date 2020/12/22 4:09 下午
*/
public class ProxyFactory<T> {
private T target;
public ProxyFactory(T target) {
this.target = target;
}
public T getProxyInstance() {
return (T) Proxy.newProxyInstance(target.getClass().getClassLoader(),
target.getClass().getInterfaces(),
new InvocationHandler() {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
System.out.println("jdk proxy is started");
return method.invoke(target, args);
}
});
}
}
| [
"yuantiantian@meituan.com"
] | yuantiantian@meituan.com |
183c8cb31686dfdd1cba4dc61ce29f533095a1aa | cceb114da9e9235a500744d8ae8d4c0d47662d7e | /lib/src/main/java/com/linkhand/bxgj/lib/pagegridview/DividerGridItemDecoration.java | 540f612c27679c853c12be9e7781e885194078a0 | [] | no_license | jiaochenyu/baixingguanjia | 9c0f78381fe4c9f5e47b8a4fd0816c50f832ee30 | def2c9923d7276d3bc7acebf15bc39b0461d6d2c | refs/heads/master | 2021-06-23T22:54:57.726367 | 2017-08-29T05:53:24 | 2017-08-29T05:53:24 | 101,723,796 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,386 | java | package com.linkhand.bxgj.lib.pagegridview;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.LayoutManager;
import android.support.v7.widget.RecyclerView.State;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
/**
*
* @author zhy
*
*/
public class DividerGridItemDecoration extends RecyclerView.ItemDecoration
{
private static final int[] ATTRS = new int[] { android.R.attr.listDivider };
private Drawable mDivider;
public DividerGridItemDecoration(Context context)
{
final TypedArray a = context.obtainStyledAttributes(ATTRS);
mDivider = a.getDrawable(0);
a.recycle();
}
@Override
public void onDraw(Canvas c, RecyclerView parent, State state)
{
drawHorizontal(c, parent);
drawVertical(c, parent);
}
private int getSpanCount(RecyclerView parent)
{
// 列数
int spanCount = -1;
LayoutManager layoutManager = parent.getLayoutManager();
if (layoutManager instanceof GridLayoutManager)
{
spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
} else if (layoutManager instanceof StaggeredGridLayoutManager)
{
spanCount = ((StaggeredGridLayoutManager) layoutManager)
.getSpanCount();
}
return spanCount;
}
public void drawHorizontal(Canvas c, RecyclerView parent)
{
int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++)
{
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
.getLayoutParams();
final int left = child.getLeft() - params.leftMargin;
final int right = child.getRight() + params.rightMargin
+ mDivider.getIntrinsicWidth();
final int top = child.getBottom() + params.bottomMargin;
final int bottom = top + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
public void drawVertical(Canvas c, RecyclerView parent)
{
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++)
{
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
.getLayoutParams();
final int top = child.getTop() - params.topMargin;
final int bottom = child.getBottom() + params.bottomMargin;
final int left = child.getRight() + params.rightMargin;
final int right = left + mDivider.getIntrinsicWidth();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
private boolean isLastColum(RecyclerView parent, int pos, int spanCount,
int childCount)
{
LayoutManager layoutManager = parent.getLayoutManager();
if (layoutManager instanceof GridLayoutManager)
{
if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
{
return true;
}
} else if (layoutManager instanceof StaggeredGridLayoutManager)
{
int orientation = ((StaggeredGridLayoutManager) layoutManager)
.getOrientation();
if (orientation == StaggeredGridLayoutManager.VERTICAL)
{
if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
{
return true;
}
} else
{
childCount = childCount - childCount % spanCount;
if (pos >= childCount)// 如果是最后一列,则不需要绘制右边
return true;
}
}
return false;
}
private boolean isLastRaw(RecyclerView parent, int pos, int spanCount,
int childCount)
{
LayoutManager layoutManager = parent.getLayoutManager();
if (layoutManager instanceof GridLayoutManager)
{
childCount = childCount - childCount % spanCount;
if (pos >= childCount)// 如果是最后一行,则不需要绘制底部
return true;
} else if (layoutManager instanceof StaggeredGridLayoutManager)
{
int orientation = ((StaggeredGridLayoutManager) layoutManager)
.getOrientation();
// StaggeredGridLayoutManager 且纵向滚动
if (orientation == StaggeredGridLayoutManager.VERTICAL)
{
childCount = childCount - childCount % spanCount;
// 如果是最后一行,则不需要绘制底部
if (pos >= childCount)
return true;
} else
// StaggeredGridLayoutManager 且横向滚动
{
// 如果是最后一行,则不需要绘制底部
if ((pos + 1) % spanCount == 0)
{
return true;
}
}
}
return false;
}
@Override
public void getItemOffsets(Rect outRect, int itemPosition,
RecyclerView parent)
{
int spanCount = getSpanCount(parent);
int childCount = parent.getAdapter().getItemCount();
if (isLastRaw(parent, itemPosition, spanCount, childCount))// 如果是最后一行,则不需要绘制底部
{
outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
} else if (isLastColum(parent, itemPosition, spanCount, childCount))// 如果是最后一列,则不需要绘制右边
{
outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
} else
{
outRect.set(0, 0, mDivider.getIntrinsicWidth(),
mDivider.getIntrinsicHeight());
}
}
}
| [
"175687482@4@qq.com"
] | 175687482@4@qq.com |
e4cafbc943ab9d2d5c0523de5a9e040b3c4232e5 | 12e4d0aaa7e921f8f1c0a9e45dcac5ec726638a3 | /src/java/com/foohyfooh/publicholidays/Database.java | 960c96179f6410fec88cd2215962143042b242c7 | [] | no_license | kroikie/longweekend | 0e006f477d2a62e213357adcb67904bb8ca5049f | 5d68eee0d6aaeeba65a4a2b2579052d5bb930a63 | refs/heads/master | 2021-01-06T20:43:20.652136 | 2014-07-21T02:44:03 | 2014-07-21T02:44:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,844 | java | package com.foohyfooh.publicholidays;
import com.foohyfooh.publicholidays.entity.DateEntry;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspWriter;
import org.json.JSONArray;
import org.json.JSONObject;
public class Database {
public static final int LONG_WEEKEND_BEFORE = 0;
public static final int LONG_WEEKEND_AFTER = 1;
private final EntityManager entityManger;
private final List<DateEntry> holidays;
private final int nextId;
public Database() {
EntityManagerFactory factory = Persistence.createEntityManagerFactory("holidays");
entityManger = factory.createEntityManager();
Query query = entityManger.createNamedQuery("DateEntry.findAll", DateEntry.class);
holidays = query.getResultList();
nextId = holidays.get(holidays.size() - 1).getId() + 1;
//Modifing the list to add the hoidays that are on the same day each year
List<DateEntry> nextYearHolidays = new ArrayList<>(),
yearAfterNextHolidays = new ArrayList<>();
for(DateEntry d: holidays){
if(d.getAlwaysOnSameDay() == DateEntry.ALWAYS_ON_SAME_DAY){
DateEntry nextYearVersion = d.nextYear();
nextYearHolidays.add(nextYearVersion);
yearAfterNextHolidays.add(nextYearVersion.nextYear());
}
}
holidays.addAll(nextYearHolidays);
holidays.addAll(yearAfterNextHolidays);
Collections.sort(holidays);
}
public List<DateEntry> getHolidays() {
return holidays;
}
public void add(HttpServletRequest request) {
String name = request.getParameter("name"),
desc = request.getParameter("desc"),
date = request.getParameter("date"),
same_day = request.getParameter("same_day");
if(name == null || desc== null || same_day == null) return;
DateEntry toAdd = new DateEntry(nextId, name, desc, date, Integer.parseInt(same_day));
persist(toAdd);
}
public void update(HttpServletRequest request) {
String id = request.getParameter("id"),
name = request.getParameter("name"),
desc = request.getParameter("desc"),
date = request.getParameter("date"),
same_day = request.getParameter("same_day");
if(id == null || name == null || desc== null || same_day == null) return;
DateEntry update = new DateEntry(Integer.parseInt(id),
name ,desc, date,
Integer.parseInt(same_day));
persist(update);
}
public void print(JspWriter out) {
try {
for (DateEntry d : holidays) {
if(d.getId() != -1)
out.print(d + "<br/>");
}
} catch (IOException e) {
Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, e);
}
}
public List findLongWeekend(HttpServletRequest request) {
List<List<DateEntry>> allLongWeekends = new ArrayList<>();
String startDate = request.getParameter("startDate");
String endDate = request.getParameter("endDate");
getUserDates(request);
//Set up a list of possible long weekend candidates
List<DateEntry> toTraverse = new ArrayList<>();
for(DateEntry d: holidays){
if(startDate.compareTo(d.getHolidayDate()) <= 0
&& endDate.compareTo(d.getHolidayDate()) >= 0 ){
//Get the first possible day in a long weekend
toTraverse.add(getStartDate(d));
}
}
for(DateEntry current: toTraverse){
List<DateEntry> longweekend = new ArrayList<>();
while (isHoliday(current) || isWeekend(current) || isMondayAfterHoliday(current)) {
ArrayList<Object> collision = isHolidayColliding(current);
if ((Boolean) collision.get(0)) {
longweekend.add((DateEntry) collision.get(1));//Add the first colliding date
longweekend.add((DateEntry) collision.get(2));//Add the second colliding date
DateEntry next = (DateEntry) collision.get(2);
current = next.nextDate();//Get the nextId date to modify
current.setHolidayName("Honorary Date");
current.setHolidayDesc("Honorary Date");
longweekend.add(current);
current = current.nextDate();
continue;
}
for (DateEntry d : holidays) {
if (d.getHolidayDate().equals(current.getHolidayDate())) {
current = d;
break;
}
}
longweekend.add(current);
current = current.nextDate();
}
allLongWeekends.add(longweekend);
}
removeIntersecting(allLongWeekends);
String s = request.getParameter("selector");
int selector = s != null ? Integer.parseInt(s) : LONG_WEEKEND_AFTER;
switch(selector){
case LONG_WEEKEND_BEFORE:
return allLongWeekends.get(allLongWeekends.size()-1);
case LONG_WEEKEND_AFTER:
return allLongWeekends.get(0);
default:
return allLongWeekends.get(0);
}
}
//Priavte Methods
private void persist(DateEntry d) {
entityManger.getTransaction().begin();
entityManger.persist(d);
entityManger.getTransaction().commit();
entityManger.close();
}
private boolean isHoliday(DateEntry d) {
return holidays.contains(d);
}
private boolean isWeekend(DateEntry d) {
GregorianCalendar date = d.toGregorianCalendar();
if (date.get(GregorianCalendar.DAY_OF_WEEK) == GregorianCalendar.SATURDAY) {
d.setHolidayName("Saturday");
d.setHolidayDesc("Saturday");
return true;
} else if (date.get(GregorianCalendar.DAY_OF_WEEK) == GregorianCalendar.SUNDAY) {
d.setHolidayName("Sunday");
d.setHolidayDesc("Sunday");
return true;
}
return false;
}
private boolean isMondayAfterHoliday(DateEntry d) {
DateEntry previous = d.previousDate();
if (!isHoliday(previous)) {
return false;
}
GregorianCalendar previousDay = previous.toGregorianCalendar();
GregorianCalendar day = d.toGregorianCalendar();
if (previousDay.get(GregorianCalendar.DAY_OF_WEEK) == GregorianCalendar.SUNDAY
&& day.get(GregorianCalendar.DAY_OF_WEEK) == GregorianCalendar.MONDAY) {
d.setHolidayName("Honorary Date");
d.setHolidayDesc("Honorary Date");
return true;
}
return false;
}
private ArrayList<Object> isHolidayColliding(DateEntry d) {
/*Info on data returned by this method
* The first return value is a Boolean to know if the holidays collided
* The second return value is the first date the same day
* The third is the second date that had the same day
* It returns true if the date passed in is colliding
*/
//Reducing the amount of holidays to check for collision
ArrayList<DateEntry> holidaySet = new ArrayList<>();
for(DateEntry c: holidays){
if(d.compareTo(d) >= 0){
holidaySet.add(c);
}
}
ArrayList<Object> collision = new ArrayList<>();
DateEntry current, next;
for (int outerCounter = 0; outerCounter < holidaySet.size(); outerCounter++) {
current = holidaySet.get(outerCounter);
for (int innerCounter = 1; innerCounter < holidaySet.size(); innerCounter++) {
next = holidaySet.get(innerCounter);
//If the date is the samebut different names you get the nextId day
if (current.getHolidayDate().equals(next.getHolidayDate())
&& !current.getHolidayName().equals(next.getHolidayName())) {
if (d.getHolidayDate().equals(current.getHolidayDate())) {
collision.add(true);
collision.add(current);
collision.add(next);
return collision;//The date passed is a collision
}
}
}
}
collision.add(false);
return collision;
}
private DateEntry getStartDate(DateEntry d){
GregorianCalendar date = d.toGregorianCalendar();
if(date.get(GregorianCalendar.DAY_OF_WEEK) == GregorianCalendar.SUNDAY)
return d.previousDate();//Set the date to the saturday
else if(date.get(GregorianCalendar.DAY_OF_WEEK) == GregorianCalendar.MONDAY)
return d.previousDate().previousDate();//Set the date to the saturday
return d;//Tuesday-Saturday
}
public void removeIntersecting(List<List<DateEntry>> list) {
//Assumes that the first contains all the elements
for(int i = 1; i < list.size(); i++){
List<DateEntry> list1 = list.get(i-1), list2 = list.get(i);
if(listIntersect(list1, list2)){
list.remove(i);
i = 1;
}
}
}
public boolean listIntersect(List<DateEntry> list1, List<DateEntry> list2) {
for(DateEntry d: list2){
if(list1.contains(d)){
return true;
}
}
return false;
}
private void getUserDates(HttpServletRequest request){
String userDatesJSON = request.getParameter("userDates");
if(userDatesJSON == null || userDatesJSON.isEmpty())
return;
JSONArray userDates = new JSONArray(userDatesJSON);
for(int i = 0;i < userDates.length(); i++){
JSONObject jsonObject = userDates.getJSONObject(i);
DateEntry add = new DateEntry(jsonObject.getString("date"));
add.setHolidayName(jsonObject.getString("name"));
add.setHolidayDesc(jsonObject.getString("desc"));
holidays.add(add);
}
Collections.sort(holidays);
}
}
| [
"foohyfooh@gmail.com"
] | foohyfooh@gmail.com |
eaa86d6072bbe94cd2a349de5d900d8600486686 | 124cc94b84bf212af86afc66894a9abe5d61233f | /src/main/java/com/lzp/mysql/source/pbsSource/repository/TaskConfigRepository.java | 40d8679b44ad404ad03bb1db952bf3d710804a81 | [] | no_license | zapowpow/datacopy | 9b6972564ccc0299363742003699a7e353ac165c | 637905671b4fc1140531b18a179d758e3733ab36 | refs/heads/master | 2020-03-22T19:12:32.669975 | 2019-03-06T07:34:21 | 2019-03-06T07:34:21 | 140,513,095 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 380 | java | package com.lzp.mysql.source.pbsSource.repository;
import com.lzp.mysql.source.pbsSource.entity.TaskConfig;
import org.springframework.stereotype.Repository;
/**
* @Author: lizhipeng
* @Company: 上海博般数据技术有限公司
* @Date: 2018/12/26 10:48
* @Description:
*/
@Repository
public interface TaskConfigRepository extends PbsBaseRepository<TaskConfig,Long>{
}
| [
"799425065@qq.com"
] | 799425065@qq.com |
2c781770cb97b177b43639d489b9b6b17cf86a7c | d050db79b90a94657e9678fc5ba60af798cfda37 | /src/test/java/org/tutske/lib/stomp/StompTest.java | 7a7b2e095d0289096b8a86d45c6d121865d3b197 | [] | no_license | tutske/org.tutske.libs.stomp | 027c255ab12bff743644955f5ccae044ae167575 | 8dde49f32b0d67b876ae1de2536798a53aa26b09 | refs/heads/master | 2023-03-01T13:08:01.445155 | 2021-02-07T13:14:39 | 2021-02-07T13:14:39 | 91,728,641 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,808 | java | package org.tutske.lib.stomp;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.tutske.lib.stomp.Stomp.*;
import org.junit.jupiter.api.Test;
import java.util.Map;
public class StompTest {
@Test
public void it_should_create_stomp_messages_with_well_known_commands () {
assertThat (connect ().command (), is ("CONNECT"));
assertThat (disconnect ().command (), is ("DISCONNECT"));
assertThat (send ().command (), is ("SEND"));
assertThat (receipt ().command (), is ("RECEIPT"));
assertThat (message ().command (), is ("MESSAGE"));
assertThat (error ().command (), is ("ERROR"));
assertThat (ack ().command (), is ("ACK"));
assertThat (nack ().command (), is ("NACK"));
}
@Test
public void it_should_create_stomp_messages_with_header_maps_for_well_known_commands () {
Map<String, Object> headers = headers ("header", "value");
assertThat (connect (headers).headers (), hasKey ("header"));
assertThat (disconnect (headers).headers (), hasKey ("header"));
assertThat (send (headers).headers (), hasKey ("header"));
assertThat (receipt (headers).headers (), hasKey ("header"));
assertThat (message (headers).headers (), hasKey ("header"));
assertThat (error (headers).headers (), hasKey ("header"));
assertThat (ack (headers).headers (), hasKey ("header"));
assertThat (nack (headers).headers (), hasKey ("header"));
}
@Test
public void it_should_create_stomp_messages_with_well_known_commands_and_content () {
String body = "This is some content for the body of stomp messages";
byte [] bytes = body.getBytes ();
assertThat (send (bytes).getBody (), is (body));
assertThat (receipt (bytes).getBody (), is (body));
assertThat (message (bytes).getBody (), is (body));
assertThat (error (bytes).getBody (), is (body));
}
@Test
public void it_should_create_stomp_messages_with_headers_and_body_of_well_known_commands_verify_header () {
Map<String, Object> headers = headers ("header", "value");
String body = "This is some content for the body of stomp messages";
byte [] bytes = body.getBytes ();
assertThat (send (headers, bytes).headers (), hasKey ("header"));
assertThat (receipt (headers, bytes).headers (), hasKey ("header"));
assertThat (message (headers, bytes).headers (), hasKey ("header"));
assertThat (error (headers, bytes).headers (), hasKey ("header"));
}
@Test
public void it_should_create_stomp_messages_with_headers_and_body_of_well_known_commands_verify_body () {
Map<String, Object> headers = headers ("header", "value");
String body = "This is some content for the body of stomp messages";
byte [] bytes = body.getBytes ();
assertThat (send (headers, bytes).getBody (), is (body));
assertThat (receipt (headers, bytes).getBody (), is (body));
assertThat (message (headers, bytes).getBody (), is (body));
assertThat (error (headers, bytes).getBody (), is (body));
}
@Test
public void it_should_have_shortcuts_for_nack_frame_creation_with_headers () {
assertThat (nack ("header", "value").header ("header"), is ("value"));
assertThat (ack ("header", "value").header ("header"), is ("value"));
assertThat (connect ("header", "value").header ("header"), is ("value"));
assertThat (disconnect ("header", "value").header ("header"), is ("value"));
}
@Test
public void it_should_have_a_short_cut_for_creating_error_frames_from_a_string () {
StompFrame frame = error ("The description of the error");
assertThat (frame.getBody (), is ("The description of the error"));
}
@Test
public void it_should_complain_about_odd_number_of_header_arguments () {
assertThrows (RuntimeException.class, () -> {
headers ("header", "value", "only-header");
});
}
}
| [
"groot.sarchy@gmail.com"
] | groot.sarchy@gmail.com |
3c3a3cf642cbff6e2aa659be17940d49cedc1bfb | 79a7f3f0215c80a5743e6b146b55e43120f57f1f | /app/src/main/java/com/example/ggupt/htn2019/SplashScreen.java | 678ddcdf172693da822a399601ab31f7ea154a9f | [] | no_license | ManethKulatunge/HTN2019 | 29614272741b334b7e2666e9f68751952ed4af04 | 2c859f186b6fd5fc3471891e59ee159fd58604f3 | refs/heads/master | 2020-07-25T18:27:45.290996 | 2019-09-15T09:02:07 | 2019-09-15T09:02:07 | 208,386,419 | 0 | 0 | null | 2019-09-14T04:03:13 | 2019-09-14T04:03:12 | null | UTF-8 | Java | false | false | 525 | java | package com.example.ggupt.htn2019;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class SplashScreen extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
Intent intent = new Intent(getApplicationContext(),
MainActivity.class);
startActivity(intent);
finish();
}
}
| [
"35315739+ggupta24@users.noreply.github.com"
] | 35315739+ggupta24@users.noreply.github.com |
92695999220c4c2587d770b11b4edeb204d4a5fa | 65129bab6aff85c969c9de38d28b9e931714bca4 | /JavaWeb/book/src/com/github/test/BookServiceTest.java | 5c6833adc5897e2972927261c734d539ebcda6db | [] | no_license | bixie979/JAVA-Web | fe0412005358528e03daadb98fd9bae36bd361de | b6e8a537217f510b198902e4a8d8531b34af9bd7 | refs/heads/main | 2023-01-19T09:32:08.145815 | 2020-11-29T07:58:02 | 2020-11-29T07:58:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,272 | java | package com.github.test;
import com.github.pojo.Book;
import com.github.pojo.Page;
import com.github.service.BookService;
import com.github.service.impl.BookServiceImpl;
import org.junit.Test;
import java.math.BigDecimal;
public class BookServiceTest {
private BookService bookService = new BookServiceImpl();
@Test
public void addBook() {
bookService.addBook(new Book(null,"国哥在手,天下我有!", "1125", new BigDecimal(1000000), 100000000, 0, null));
}
@Test
public void deleteBookById() {
bookService.deleteBookById(22);
}
@Test
public void updateBook() {
bookService.updateBook(new Book(22,"社会我国哥,人狠话不多!", "1125", new BigDecimal(999999), 10, 111110, null));
}
@Test
public void queryBookById() {
System.out.println(bookService.queryBookById(22));
}
@Test
public void queryBooks() {
for (Book queryBook : bookService.queryBooks()) {
System.out.println(queryBook);
}
}
@Test
public void page(){
System.out.println(bookService.page(1, Page.PAGE_SIZE ));
}
@Test
public void pageByPrice(){
System.out.println(bookService.pageByPrice(1, Page.PAGE_SIZE,10,50 ));
}
} | [
"48648114+name365@users.noreply.github.com"
] | 48648114+name365@users.noreply.github.com |
aab8afc0c3fd4a8097b7dcd1a07683e9c9a90737 | 5715327d4561aa3d0ec81591c49060d907cf7056 | /src/main/java/com/project/cinderella/controller/payment/PaymentController.java | c481aacb987bfed282122f640576e2020139026b | [] | no_license | youming99/CinderellaProject | 8af8acc5e7bb752649cfca4802173173dee10415 | 4dbfcd9320a218963ca5d9f1b8e88a085853f70f | refs/heads/master | 2023-02-22T04:00:36.537234 | 2021-01-26T00:46:32 | 2021-01-26T00:46:32 | 331,511,979 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 8,049 | java | package com.project.cinderella.controller.payment;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.project.cinderella.common.MessageData;
import com.project.cinderella.exception.CartException;
import com.project.cinderella.exception.LoginRequiredException;
import com.project.cinderella.model.domain.Cart;
import com.project.cinderella.model.domain.Member;
import com.project.cinderella.model.domain.OrderSummary;
import com.project.cinderella.model.domain.Receiver;
import com.project.cinderella.model.member.service.MemberService;
import com.project.cinderella.model.payment.service.PaymentService;
import com.project.cinderella.model.product.service.TopCategoryService;
@Controller
public class PaymentController {
private static final Logger logger = LoggerFactory.getLogger(PaymentController.class);
@Autowired
private PaymentService paymentService;
@Autowired
private TopCategoryService topCategoryService;
@Autowired
private MemberService memberService;
// 장바구니에 상품 담기 요청
@RequestMapping(value = "/shop/cart/regist", method = RequestMethod.POST)
@ResponseBody
public MessageData registCart(Cart cart, HttpSession session) {
if (session.getAttribute("member") == null) {
throw new LoginRequiredException("로그인이 필요한 서비스입니다.");
}
Member member = (Member) session.getAttribute("member");
logger.debug("product_id " + cart.getProduct_id());
logger.debug("quantity " + cart.getQuantity());
cart.setMember_id(member.getMember_id());
paymentService.insert(cart);
// MessageConverter 에 의해 VO는 JSON형태로 응답되어질 수 있다!!
MessageData messageData = new MessageData();
messageData.setResultCode(1);
messageData.setMsg("장바구니에 상품이 담겼습니다");
messageData.setUrl("/cinderella/shop/cart/list");
return messageData;
}
// 장바구니 목록 요청
@RequestMapping(value = "/shop/cart/list", method = RequestMethod.GET)
public ModelAndView getCartList(HttpServletRequest request, HttpSession session) {
if (session.getAttribute("member") == null) {
throw new LoginRequiredException("로그인이 필요한 서비스입니다.");
}
Member member = (Member) session.getAttribute("member");
List topList = topCategoryService.selectAll();
List cartList = paymentService.selectCartList(member.getMember_id());
ModelAndView mav = new ModelAndView();
mav.addObject("topList", topList);
mav.addObject("cartList", cartList);
mav.setViewName("shop/cart/cart_list");
return mav;
}
// 장바구니 삭제 요청
@RequestMapping(value = "/shop/cart/del", method = RequestMethod.GET)
public String delCart(HttpSession session) {
// 장바구니를 삭제하기 위해서는, 로그인한 회원만 가능..
if (session.getAttribute("member") == null) {
throw new LoginRequiredException("로그인이 필요한 서비스입니다");
}
paymentService.delete((Member) session.getAttribute("member"));
return "redirect:/shop/cart/list";
}
// 장바구니 목록 수정
@RequestMapping(value = "/shop/cart/edit", method = RequestMethod.POST)
public ModelAndView editCart(@RequestParam("cart_id") int[] cartArray, @RequestParam("quantity") int[] qArray) {
// 넘겨받은 파라미터 출력하기!! cart_id, quantity
logger.debug("cartArray length " + cartArray.length);
List cartList = new ArrayList();
for (int i = 0; i < cartArray.length; i++) {
Cart cart = new Cart();
cart.setCart_id(cartArray[i]);
cart.setQuantity(qArray[i]);
cartList.add(cart);
}
paymentService.update(cartList);
// 수정되었다는 메시지를 보고싶다면.. message.jsp로 응답하자
MessageData messageData = new MessageData();
messageData.setResultCode(1);
messageData.setMsg("장바구니가 수정되었습니다");
messageData.setUrl("/cinderella/shop/cart/list");
ModelAndView mav = new ModelAndView();
mav.addObject("messageData", messageData);
mav.setViewName("shop/error/message");
return mav;
}
// 체크아웃 페이지 요청
@GetMapping("/shop/payment/form")
public ModelAndView payForm(HttpServletRequest request, HttpSession session) {
ModelAndView mav = new ModelAndView();
List topList = topCategoryService.selectAll();
mav.addObject("topList", topList); // ModelAndView에서의 Model만 사용..
// 결제수단 가져오기
List paymethodList = paymentService.selectPaymethodList();
mav.addObject("paymethodList", paymethodList);
// 장바구니 정보도 가져오기
Member member = (Member) session.getAttribute("member");
List cartList = paymentService.selectCartList(member.getMember_id());
mav.addObject("cartList", cartList);
mav.setViewName("shop/payment/checkout");
return mav;
}
// 결제요청 처리
@RequestMapping(value = "/shop/payment/regist", method = RequestMethod.POST, produces = "text/html;charset=utf8")
@ResponseBody
public String pay(HttpSession session, OrderSummary orderSummary, Receiver receiver) {
logger.debug("d"+orderSummary.getOrder_summary_id());
logger.debug("d"+orderSummary.getTotal_pay());
logger.debug("d"+orderSummary.getTotal_price());
logger.debug("d"+orderSummary.getPaymethod_id());
Member member = (Member) session.getAttribute("member");
orderSummary.setMember_id(member.getMember_id()); // 회원 pk
paymentService.registOrder(orderSummary, receiver);
memberService.updateBuyCount(member, member.getMember_id());
paymentService.delete((Member) session.getAttribute("member"));
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"result\":1,");
sb.append("\"msg\":\"결제 성공\"");
sb.append("}");
return sb.toString();
}
//주문목록 확인 - 관리자
@RequestMapping(value = "/admin/product/order_list", method = RequestMethod.GET)
public ModelAndView getOrderList() {
ModelAndView mav = new ModelAndView("admin/product/order_list");
List orderList = paymentService.selectOrderList();
List memberList = memberService.selectAll();
List orderstateList = paymentService.selectOrderStateList();
mav.addObject("orderList", orderList);
mav.addObject("memberList", memberList);
mav.addObject("orderstateList", orderstateList);
return mav;
}
// 장바구니와 관련된 예외처리 핸들러
@ExceptionHandler(CartException.class)
@ResponseBody
public MessageData handleException(CartException e) {
logger.debug("핸들러 동작함 " + e.getMessage());
MessageData messageData = new MessageData();
messageData.setResultCode(0);
messageData.setMsg(e.getMessage());
messageData.setUrl("/cinderella/shop/member/signin");
return messageData;
}
} | [
"noreply@github.com"
] | youming99.noreply@github.com |
46e62e4ab86b6c6b691ab652505607419bd99ab7 | 033c711bf981ef17e042849cfa4072da354f7ccc | /src/main/java/com/wenwen/swordtooffer/sword21_30/s26_CopyComplexLinkNode.java | 2557285f9749baae1ecee452a0cd25ef48bab7f0 | [] | no_license | chengyiqingqing/sword_offer | d4fd6db0a14218050a0f7b624a359ed37fa04f5c | d611877d6ff778482ce2030e6eb12397b95d3278 | refs/heads/master | 2020-03-06T18:38:28.430202 | 2018-03-27T15:54:07 | 2018-03-27T15:54:07 | 127,011,114 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,069 | java | package com.wenwen.swordtooffer.sword21_30;
/**
* Created by Administrator on 2018/3/18.
*/
public class s26_CopyComplexLinkNode {
public static void main(String[] args){
}
/**
* 复制这个复制链表。其实无所谓复杂,就是建立一个临时结点存一下当前的值;
* 然后依次往下就可以了。
* @param root
* @return
*/
public static Node copyComplexLinkNode(Node root){
if (root!=null){
return null;
}
//复制头结点;
Node head=new Node(root.data,root.next,root.random);
Node temp=head;
while (root.next!=null){
temp.next=new Node(root.next.data,root.next.next,root.next.random);
root=root.next;
temp=temp.next;
}
return head;
}
static class Node{
int data;
Node next;
Node random;
public Node(int data,Node next,Node random){
this.data=data;
this.next=next;
this.random=random;
}
}
}
| [
"17839221829@163.com"
] | 17839221829@163.com |
501c3e3d74a0a7504ee32de854fc77d389d12918 | 264afda77f43de8bcd25c6a4bbee9359c05c5d28 | /leetcode/src/main/java/com/tsshare/leetcode/l_0526/Solution1.java | e4fe8eb21c05a1a9252ae53bae22b8b5f2d9c8c6 | [] | no_license | chenzhenfei/leetcode | ef63c84a20136cd7ca03d82091f1dc9837b279ca | 18cf0c3efaade29f682d9674983ac1cd5cd35e70 | refs/heads/master | 2022-10-12T13:55:41.336151 | 2020-06-08T16:58:45 | 2020-06-08T16:58:45 | 267,320,484 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,282 | java | package com.tsshare.leetcode.l_0526;
/**
* @author chenzhenfei
* @title: Solution1
* @projectName leetcode
* @description: TODO
* @date 2020/5/260:20
*/
public class Solution1 {
public static int countSquares(int[][] matrix) {
int m = matrix.length;
int n = matrix[0].length;
int[][] dp = new int[m][n];
int ans = 0;
// 预处理每一行和每一列
for (int i = 0; i < m; i++) {
ans += dp[i][0] = matrix[i][0];
}
for (int j = 0; j < n; j++) {
ans += dp[0][j] = matrix[0][j];
}
// 上述过程(0, 0)判断了两次, 如果matrix[0][0] == 1,说明ans多算了一个
if (matrix[0][0] == 1) {
ans--;
}
for (int i = 1; i < m; i++) {
for (int j = 1; j < n; j++) {
if (matrix[i][j] == 1) {
dp[i][j] = Math.min(Math.min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1;
ans += dp[i][j];
}
}
}
return ans;
}
public static void main(String[] args) {
int[][] matrix = new int[][]{
{0,1,1,1 },{1,1,1,1},{0,1,1,1}};
int i = countSquares(matrix);
System.out.println(i);
}
}
| [
"916927902@qq.com"
] | 916927902@qq.com |
a141816e5c6fe4f8fba72256efccd5adaf390d9a | bf9fbaa33771b1503701d70b7ced2b835db122b3 | /src/main/java/com/educandoweb/course/services/exceptions/DatabaseException.java | f4dfc36ea42cebcd0f4965918a2571b8cc13389e | [] | no_license | genivalc/Projeto-Web-services-com-Spring-Boot-e-JPA-Hibernate | 70dabc9544ff7907079b44ffde6e3fc42d694577 | 804893bc94a99edb2f6f626aedd00ca0acfecee6 | refs/heads/master | 2022-04-20T05:24:24.175890 | 2020-04-02T23:32:17 | 2020-04-02T23:32:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 230 | java | package com.educandoweb.course.services.exceptions;
public class DatabaseException extends RuntimeException {
private static final long serialVersionUID = 1L;
public DatabaseException(String msg) {
super(msg);
}
} | [
"genivalcandeiadon.neto@gmail.com"
] | genivalcandeiadon.neto@gmail.com |
535ea31fb303119d9aa405d82af11ae043429f85 | f4905ebd6269fdb366b7a0c896beb9f4646a42ab | /src/main/java/br/univille/agrotech/model/Funcionario.java | b97fdd8d1c1207a52af843fc1c7e231687cb04c6 | [] | no_license | edufgar/AgroTech | 4513185d7389f8c11ba826c34fecff70f84820ad | 7794420ca691d9ae9c41befc3e0ab5753f7b4a39 | refs/heads/master | 2023-01-09T11:54:15.326769 | 2020-11-06T01:29:09 | 2020-11-06T01:29:09 | 275,040,992 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,034 | java | package br.univille.agrotech.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Funcionario {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long codFunc;
@Column(nullable = false,length = 1000)
private String nome;
private String telefone;
private String email;
public long getCodFunc() {
return codFunc;
}
public void setCodFunc(long codFunc) {
this.codFunc = codFunc;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
} | [
"eduardo.fontana1099@univillebr.onmicrosoft.com"
] | eduardo.fontana1099@univillebr.onmicrosoft.com |
414e5748ef06c6c66806a7198a5db862898ac505 | b4492de8a827f512e7c7852ffb291d5861f387a3 | /src/main/java/zero/Solution2.java | f510cb09adc78f5cb2d37c5df40ea226d9a3ae1d | [] | no_license | Vaisman/leetcode | 1d7cd9450fc4ce3bdfa4f6aaa77e13a67f115960 | 51ad1dafb35ce0e4b8f67945dcbdb8589a9f69af | refs/heads/master | 2021-04-27T07:41:43.039424 | 2019-05-03T08:56:13 | 2019-05-03T08:56:13 | 122,637,972 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,131 | java | package zero;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class Solution2 {
public int longestPalindrome(String s) {
int[] mem = new int[256];
for (char c : s.toCharArray()) {
mem[c]++;
}
int evenCounter = 0;
int oddCounter = 0;
for (int i : mem) {
if ((i % 2) == 0) {
evenCounter += i;
} else if ((i % 2) > 0) {
evenCounter += (i - 1);
oddCounter = 1;
} else oddCounter = 1;
}
return evenCounter + oddCounter;
}
public int longestPalindromeEff(String s) {
int[] map = new int[128];
int res = 0;
for (char c : s.toCharArray()) {
if (map[c]++ % 2 == 1) res += 2;
}
return s.length() > res ? 1 + res : res;
}
@Test
public void test1() {
assertEquals(0, longestPalindrome(""));
assertEquals(7, longestPalindrome("abccccdd"));
assertEquals(3, longestPalindrome("ccc"));
}
@Test
public void test2() {
assertEquals(0, longestPalindromeEff(""));
assertEquals(7, longestPalindromeEff("abccccdd"));
assertEquals(3, longestPalindromeEff("ccc"));
}
}
| [
"vasili.svirski@gmail.com"
] | vasili.svirski@gmail.com |
d39221000c1b316a64fa1dd57002e43da119325a | cd0e68a4cede7620bc2a44246e6f48275b556a1b | /RetrofitTest/app/src/main/java/com/example/localuser/retrofittest/Utils/PictureUtils.java | bce908698b807f7974a5d047ade718a06396e889 | [] | no_license | zhouyudonghit/MyPractisePro | bbf1663011d97103a048738671d6f6c3669800da | 2fbfafd7d1e7cf6dc2da647d0babdcc518871da7 | refs/heads/master | 2021-12-23T10:22:18.659649 | 2021-10-10T15:19:19 | 2021-10-10T15:19:19 | 131,786,721 | 0 | 1 | null | 2018-09-16T11:14:35 | 2018-05-02T02:20:41 | Java | UTF-8 | Java | false | false | 7,465 | java | package com.example.localuser.retrofittest.Utils;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.RectF;
import android.os.Environment;
import android.view.View;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* 性能优化——Android图片压缩与优化的几种方式
* https://blog.csdn.net/u013928412/article/details/80358597
* 5、JNI调用JPEG库
* Android的图片引擎使用的是阉割版的skia引擎,去掉了图片压缩中的哈夫曼算法——一种耗CPU但是能在保持图片清晰度的情况下很大程度降低图片的磁盘空间大小的算法,这就是为什么ios拍出的1M的照片比Android5M的还要清晰的原因。
* 6、还有一些技巧,比如在缩放压缩的时候,
* Bitmap.createBitmap(bitmap.getWidth() / radio, bitmap.getHeight() / radio, Bitmap.Config.ARGB_8888),如果不需要图片的透明度,可以将ARGB_8888改成RGB_565,这样之前每个像素占用4个字节,现在只需要2个字节,节省了一半的大小。
*
*关于 Android 中 Bitmap 的 ARGB_8888、ALPHA_8、ARGB_4444、RGB_565 的理解
*https://blog.csdn.net/tianjf0514/article/details/71698926
*Bitmap.Config 有四种枚举类型
* ARGB_8888:ARGB 四个通道的值都是 8 位,加起来 32 位,也就是 4 个字节。每个像素点占用 4 个字节的大小。
* ARGB_4444:ARGB 四个通道的值都是 4 位,加起来 16 位,也就是 2 个字节。每个像素点占用 2 个字节的大小。
* RGB_565:RGB 三个通道分别是 5 位、6 位、5 位,没有 A 通道,加起来 16 位,也就是 2 个字节。每个像素点占用 2 个字节的大小。
* ALPHA_8:只有 A 通道,占 8 位,1 个字节。每个像素点占用 1 个字节的大小。
*那到底用哪个呢?
* 很明显 ARGB_8888 的图片是质量最高的,但也是占用内存最大的。
*
* 如果想要节省内存,可以使用 ARGB_4444 或者 RGB_565。它们相比 ARGB_8888 内存占用都小了一半。
* ARGB_4444 图片的失真是比较严重的。
* RGB_565 图片的失真虽然很小,但是没有透明度。
*
* ALPHA_8 只有透明度,没有颜色值。对于在图片上设置遮盖的效果的是有很有用。
*
* 总结一下!
* ARGB_4444 图片失真严重,基本不用!
* ALPHA_8 使用场景比较特殊!
* 如果不设置透明度,RGB_565是个不错选择!
* 既要设置透明度,对图片质量要求又高的化,那就用 ARGB_8888 !
*/
public class PictureUtils {
/**
* 质量压缩
*质量压缩并不会改变图片在内存中的大小,仅仅会减小图片所占用的磁盘空间的大小,因为质量压缩不会改变图片的分辨率,而图片在内存中的大小是根据
* width*height*一个像素的所占用的字节数
* 计算的,宽高没变,在内存中占用的大小自然不会变,质量压缩的原理是通过改变图片的位深和透明度来减小图片占用的磁盘空间大小,所以不适合作为缩略图,可以用于想保持图片质量的同时减小图片所占用的磁盘空间大小。另外,
* 由于png是无损压缩,所以设置quality无效
* @param format 图片格式 jpeg,png,webp
* @param quality 图片的质量,0-100,数值越小质量越差
*/
public static void compressByQuality(Bitmap.CompressFormat format, int quality) {
File sdFile = Environment.getExternalStorageDirectory();
File originFile = new File(sdFile, "originImg.jpg");
Bitmap originBitmap = BitmapFactory.decodeFile(originFile.getAbsolutePath());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
originBitmap.compress(format, quality, bos);
try {
FileOutputStream fos = new FileOutputStream(new File(sdFile, "resultImg.jpg"));
fos.write(bos.toByteArray());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 采样率压缩
*采样率压缩是通过设置BitmapFactory.Options.inSampleSize,来减小图片的分辨率,进而减小图片所占用的磁盘空间和内存大小。
*
* 设置的inSampleSize会导致压缩的图片的宽高都为1/inSampleSize,整体大小变为原始图片的inSampleSize平方分之一,当然,这些有些注意点:
*
* 1、inSampleSize小于等于1会按照1处理
*
* 2、inSampleSize只能设置为2的平方,不是2的平方则最终会减小到最近的2的平方数,如设置7会按4进行压缩,设置15会按8进行压缩。
* @param inSampleSize 可以根据需求计算出合理的inSampleSize
*/
public static void compressByInSampleSize(int inSampleSize) {
File sdFile = Environment.getExternalStorageDirectory();
File originFile = new File(sdFile, "originImg.jpg");
BitmapFactory.Options options = new BitmapFactory.Options();
//设置此参数是仅仅读取图片的宽高到options中,不会将整张图片读到内存中,防止oom
options.inJustDecodeBounds = true;
Bitmap emptyBitmap = BitmapFactory.decodeFile(originFile.getAbsolutePath(), options);
options.inJustDecodeBounds = false;
options.inSampleSize = inSampleSize;
Bitmap resultBitmap = BitmapFactory.decodeFile(originFile.getAbsolutePath(), options);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
resultBitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
try {
FileOutputStream fos = new FileOutputStream(new File(sdFile, "resultImg.jpg"));
fos.write(bos.toByteArray());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void compress(View v) {
File sdFile = Environment.getExternalStorageDirectory();
File originFile = new File(sdFile, "originImg.jpg");
Bitmap bitmap = BitmapFactory.decodeFile(originFile.getAbsolutePath());
//设置缩放比
int radio = 8;
Bitmap result = Bitmap.createBitmap(bitmap.getWidth() / radio, bitmap.getHeight() / radio, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(result);
RectF rectF = new RectF(0, 0, bitmap.getWidth() / radio, bitmap.getHeight() / radio);
//将原图画在缩放之后的矩形上
canvas.drawBitmap(bitmap, null, rectF, null);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
result.compress(Bitmap.CompressFormat.JPEG, 100, bos);
try {
FileOutputStream fos = new FileOutputStream(new File(sdFile, "sizeCompress.jpg"));
fos.write(bos.toByteArray());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
| [
"18103518@suning.com"
] | 18103518@suning.com |
85a013c1e188487b8f156d64919b44992b5f852a | 6daebc577748eca9a19b3acd1c64f04c16060d01 | /app/src/main/java/com/shmily/tjz/swap/Adapter/FriendsAdapter.java | b815fade989972064483358b0309128dedfbe557 | [
"Apache-2.0"
] | permissive | Shmilyz/Swap | 07af35217ed555776903695990596b298e5a1916 | 8d785f5aa5b399c642391930b5ff19b1ecf66823 | refs/heads/master | 2021-01-20T09:02:15.751797 | 2017-06-28T07:08:04 | 2017-06-28T07:08:04 | 90,213,728 | 3 | 2 | null | null | null | null | UTF-8 | Java | false | false | 9,047 | java | package com.shmily.tjz.swap.Adapter;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.like.LikeButton;
import com.like.OnLikeListener;
import com.shmily.tjz.swap.FriendShoesActivity;
import com.shmily.tjz.swap.Gson.Friends;
import com.shmily.tjz.swap.LitePal.DiscussLite;
import com.shmily.tjz.swap.R;
import com.shmily.tjz.swap.ShoesActivity;
import com.shmily.tjz.swap.Utils.Xutils;
import com.yarolegovich.discretescrollview.transform.Pivot;
import org.litepal.crud.DataSupport;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.hdodenhof.circleimageview.CircleImageView;
/**
* Created by Shmily_Z on 2017/6/7.
*/
public class FriendsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
public static final int FRIENDS_LOVE =1;
public static final int FRIENDS_DISCUSS =2;
public static final int FRIENDS_RELEASE =3;
private Context mContext;
private List<Friends> mShoesList=new ArrayList<>();
String username;
private String loveurl="http://www.shmilyz.com/ForAndroidHttp/love.action";
private Xutils xutils;
public class LoveHolder extends RecyclerView.ViewHolder {
TextView friends_love_username,friends_love_shoesname,friends_love_date;
ImageView friends_love_image;
LinearLayout friends_love_item;
public LoveHolder(View view) {
super(view);
friends_love_username= (TextView) view.findViewById(R.id.friends_love_username);
friends_love_shoesname= (TextView) view.findViewById(R.id.friends_love_shoesname);
friends_love_date= (TextView) view.findViewById(R.id.friends_love_date);
friends_love_image= (ImageView) view.findViewById(R.id.friends_love_image);
friends_love_item= (LinearLayout) view.findViewById(R.id.friends_love_item);
}
}
public class DiscussHolder extends RecyclerView.ViewHolder {
TextView firends_discuss_username,firends_discuss_discuss,firends_discuss_date;
ImageView friends_discuss_headview;
LinearLayout friends_discuss_item;
public DiscussHolder(View view) {
super(view);
firends_discuss_username= (TextView) view.findViewById(R.id.firends_discuss_username);
firends_discuss_discuss= (TextView) view.findViewById(R.id.firends_discuss_discuss);
firends_discuss_date= (TextView) view.findViewById(R.id.firends_discuss_date);
friends_discuss_headview= (ImageView) view.findViewById(R.id.friends_discuss_headview);
friends_discuss_item= (LinearLayout) view.findViewById(R.id.friends_discuss_item);
}
}
public class ReleaseHolder extends RecyclerView.ViewHolder {
TextView friends_release_username,friends_release_name,friends_release_date;
ImageView friends_release_headview;
LinearLayout friends_release_item;
public ReleaseHolder(View view) {
super(view);
friends_release_username= (TextView) view.findViewById(R.id.friends_release_username);
friends_release_name= (TextView) view.findViewById(R.id.friends_release_name);
friends_release_date= (TextView) view.findViewById(R.id.friends_release_date);
friends_release_headview= (ImageView) view.findViewById(R.id.friends_release_headview);
friends_release_item= (LinearLayout) view.findViewById(R.id.friends_release_item);
}
}
public FriendsAdapter(List<Friends> shoesList) {
mShoesList = shoesList;
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
if (holder instanceof LoveHolder){
((LoveHolder)holder).friends_love_username.setText(mShoesList.get(position).getUsername());
((LoveHolder)holder).friends_love_shoesname.setText(mShoesList.get(position).getShoesname());
((LoveHolder)holder).friends_love_date.setText(mShoesList.get(position).getUserdate());
String url=mShoesList.get(position).getShoesurl();
Log.i("pictureurl",url);
Glide.with(mContext).load(url).into(((LoveHolder)holder).friends_love_image);
((LoveHolder)holder).friends_love_item.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position = holder.getAdapterPosition();
Friends friend = mShoesList.get(position);
Intent intent = new Intent(mContext, FriendShoesActivity.class);
intent.putExtra(FriendShoesActivity.SHOES_ID, String.valueOf(friend.getShoesid()));
intent.putExtra(FriendShoesActivity.SHOES_IMAGE_URL, friend.getShoesurl());
mContext.startActivity(intent);
}
});
}
else if (holder instanceof DiscussHolder){
((DiscussHolder)holder).firends_discuss_username.setText(mShoesList.get(position).getUsername());
((DiscussHolder)holder).firends_discuss_discuss.setText(mShoesList.get(position).getDiscuss());
((DiscussHolder)holder).firends_discuss_date.setText(mShoesList.get(position).getUserdate());
String url=mShoesList.get(position).getShoesurl();
Glide.with(mContext).load(url).into(((DiscussHolder)holder).friends_discuss_headview);
((DiscussHolder)holder).friends_discuss_item.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position = holder.getAdapterPosition();
Friends friend = mShoesList.get(position);
Intent intent = new Intent(mContext, FriendShoesActivity.class);
intent.putExtra(FriendShoesActivity.SHOES_ID, String.valueOf(friend.getShoesid()));
intent.putExtra(FriendShoesActivity.SHOES_IMAGE_URL, friend.getShoesurl());
mContext.startActivity(intent);
}
});
}
else if (holder instanceof ReleaseHolder){
((ReleaseHolder)holder).friends_release_username.setText(mShoesList.get(position).getUsername());
((ReleaseHolder)holder).friends_release_name.setText(mShoesList.get(position).getShoesname());
((ReleaseHolder)holder).friends_release_date.setText(mShoesList.get(position).getUserdate());
String url=mShoesList.get(position).getShoesurl();
Glide.with(mContext).load(url).into(((ReleaseHolder)holder).friends_release_headview);
((ReleaseHolder)holder).friends_release_item.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position = holder.getAdapterPosition();
Friends friend = mShoesList.get(position);
Intent intent = new Intent(mContext, FriendShoesActivity.class);
intent.putExtra(FriendShoesActivity.SHOES_ID, String.valueOf(friend.getShoesid()));
intent.putExtra(FriendShoesActivity.SHOES_IMAGE_URL, friend.getShoesurl());
mContext.startActivity(intent);
}
});
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view=null;
if (mContext == null) {
mContext = parent.getContext();
}
if (viewType==FRIENDS_LOVE){
view = LayoutInflater.from(mContext).inflate(R.layout.friends_love_item, parent, false);
LoveHolder loveholder = new LoveHolder(view);
return new LoveHolder(view);
}
else if (viewType==FRIENDS_DISCUSS){
view = LayoutInflater.from(mContext).inflate(R.layout.friends_discuss_item, parent, false);
DiscussHolder discussholder = new DiscussHolder(view);
return new DiscussHolder(view);
}
else if (viewType==FRIENDS_RELEASE){
view = LayoutInflater.from(mContext).inflate(R.layout.friends_release_item, parent, false);
ReleaseHolder releaseholder = new ReleaseHolder(view);
return new ReleaseHolder(view);
}
return null;
}
@Override
public int getItemViewType(int position) {
return mShoesList.get(position).getType();
}
@Override
public int getItemCount() {
return mShoesList.size();
}
}
| [
"zunzunzun8@163.com"
] | zunzunzun8@163.com |
55abd93d3242906438d934f93437ad418e62099b | 6b0dcff85194eddf0706e867162526b972b441eb | /extension/binding/fabric3-binding-rs-jersey/src/main/java/org/fabric3/binding/rs/runtime/RsContainer.java | 6951f505292dc65f8d28c47ab075844feb5076e3 | [] | no_license | jbaeck/fabric3-core | 802ae3889169d7cc5c2f3e2704cfe3338931ec76 | 55aaa7b2228c9bf2c2630cc196938d48a71274ff | refs/heads/master | 2021-01-18T15:27:25.959653 | 2012-11-04T00:36:36 | 2012-11-04T00:36:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,332 | java | /*
* Fabric3
* Copyright (c) 2009-2012 Metaform Systems
*
* Fabric3 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, with the
* following exception:
*
* Linking this software statically or dynamically with other
* modules is making a combined work based on this software.
* Thus, the terms and conditions of the GNU General Public
* License cover the whole combination.
*
* As a special exception, the copyright holders of this software
* give you permission to link this software with independent
* modules to produce an executable, regardless of the license
* terms of these independent modules, and to copy and distribute
* the resulting executable under terms of your choice, provided
* that you also meet, for each linked independent module, the
* terms and conditions of the license of that module. An
* independent module is a module which is not derived from or
* based on this software. If you modify this software, you may
* extend this exception to your version of the software, but
* you are not obligated to do so. If you do not wish to do so,
* delete this exception statement from your version.
*
* Fabric3 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 Fabric3.
* If not, see <http://www.gnu.org/licenses/>.
*/
package org.fabric3.binding.rs.runtime;
import java.io.IOException;
import java.util.Enumeration;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.fabric3.spi.invocation.CallFrame;
import org.fabric3.spi.invocation.WorkContext;
import org.fabric3.spi.invocation.WorkContextTunnel;
/**
* Manages resources defined in a deployable contribution.
*/
public final class RsContainer extends HttpServlet {
private static final long serialVersionUID = 1954697059021782141L;
private ClassLoader classLoader;
private Fabric3ProviderFactory providerFactory;
private RsServlet servlet;
private ServletConfig servletConfig;
private boolean reload = false;
private ReentrantReadWriteLock reloadRWLock = new ReentrantReadWriteLock();
private Lock reloadLock = reloadRWLock.readLock();
private Lock serviceLock = reloadRWLock.writeLock();
public RsContainer(ClassLoader classLoader) {
this.classLoader = classLoader;
this.providerFactory = new Fabric3ProviderFactory();
reload = true;
}
public void addResource(Class<?> resource, Object instance) {
providerFactory.addResource(resource, instance);
reload = true;
}
@Override
public void init(ServletConfig config) {
servletConfig = new ServletConfigWrapper(config);
}
public void reload() throws ServletException {
try {
reloadLock.lock();
// Set the class loader to the runtime one so Jersey loads the
// ResourceConfig properly
ClassLoader old = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(classLoader);
servlet = new RsServlet(this.providerFactory);
servlet.init(servletConfig);
} catch (ServletException se) {
se.printStackTrace();
throw se;
} catch (Throwable t) {
ServletException se = new ServletException(t);
se.printStackTrace();
throw se;
} finally {
Thread.currentThread().setContextClassLoader(old);
}
reload = false;
} finally {
reloadLock.unlock();
}
}
@Override
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
try {
serviceLock.lock();
if (reload) {
reload();
}
ClassLoader old = Thread.currentThread().getContextClassLoader();
WorkContext oldContext = null;
try {
Thread.currentThread().setContextClassLoader(classLoader);
WorkContext workContext = new WorkContext();
workContext.setHeader("fabric3.httpRequest", req);
workContext.setHeader("fabric3.httpResponse", res);
CallFrame frame = new CallFrame();
workContext.addCallFrame(frame);
oldContext = WorkContextTunnel.setThreadWorkContext(workContext);
servlet.service(req, res);
} catch (ServletException se) {
se.printStackTrace();
throw se;
} catch (IOException ie) {
ie.printStackTrace();
throw ie;
} catch (Throwable t) {
t.printStackTrace();
throw new ServletException(t);
} finally {
Thread.currentThread().setContextClassLoader(old);
WorkContextTunnel.setThreadWorkContext(oldContext);
}
} finally {
serviceLock.unlock();
}
}
/**
* Wrapper class to add the Jersey resource class as a web app init parameter
*/
public class ServletConfigWrapper implements ServletConfig {
private ServletConfig servletConfig;
public ServletConfigWrapper(ServletConfig servletConfig) {
this.servletConfig = servletConfig;
}
public String getInitParameter(String name) {
if ("javax.ws.rs.Application".equals(name)) {
return Fabric3ResourceConfig.class.getName();
}
return servletConfig.getInitParameter(name);
}
public Enumeration<String> getInitParameterNames() {
final Enumeration<String> e = servletConfig.getInitParameterNames();
return new Enumeration<String>() {
boolean finished = false;
public boolean hasMoreElements() {
return e.hasMoreElements() || !finished;
}
public String nextElement() {
if (e.hasMoreElements()) {
return e.nextElement();
}
if (!finished) {
finished = true;
return "javax.ws.rs.Application";
}
return null;
}
};
}
public ServletContext getServletContext() {
return servletConfig.getServletContext();
}
public String getServletName() {
return servletConfig.getServletName();
}
}
}
| [
"jim.marino@gmail.com"
] | jim.marino@gmail.com |
2f5c0764074c1067c8bdeb01503799fc36c400b6 | f84c5804aab8354736cdd9cc9d816d9f41ea0adf | /src/CassTor.java | d82888405e221df03b88e30d797d488bee3cf0f4 | [
"MIT"
] | permissive | lyubent/CassTor | f87ffd2209ec3bdddbaea89796def5f0cdef9162 | 3f58ff64a4518a18b30631bd878bb9da9f3ae90b | refs/heads/master | 2021-01-01T06:51:00.434416 | 2013-04-27T17:56:31 | 2013-04-27T17:56:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,147 | java |
import com.github.lyuben.bridge.SchemaManager;
import com.github.lyuben.util.AuthenticationHandler;
/**
* @author lyubentodorov
* @licence - MIT
* Available at http://lyuben.herokuapp.com/casstor/
* Source at https://github.com/lyubent/CassTor/
*/
public class CassTor {
public static void main(String[] args) {
try {
//Build schema, run only once on seed node.
//com.github.lyuben.bridge.SchemaManager.buildSchema(com.github.lyuben.bridge.Astyanax.getKeyspaceContext());System.exit(0);
//run tests
//new com.github.lyuben.test.TestSuite().runTests();System.exit(0);
if(com.github.lyuben.util.FileUtil.isFirstRun()) {
com.github.lyuben.modelview.FrameController.displayFirstRunFrames();
} else {
com.github.lyuben.modelview.FrameController.displayMainFrames();
}
} catch (Exception ex) {
java.util.logging.Logger.getLogger(CassTor.class.getName()).log(
java.util.logging.Level.SEVERE, "Error in main thread.", ex);
}
}
} | [
"ltodorov@dundee.ac.uk"
] | ltodorov@dundee.ac.uk |
b0066c891437563726ab94fc53684fe97ade3695 | 4bead044e0dff4910c96ed931317b4a72f6043c6 | /calendarselectdemo/src/main/java/com/example/drcbse/calendarselectdemo/calendar/bizs/calendars/SolarTerm.java | 9a16dad38e8740a428de08327925eafee7746ee0 | [] | no_license | linhou/ListDemo | 3cdfd8068c5775d6167b8e9f5b5d1234c84918aa | c625db8b86baf97d3671d581b7af4f318136b02d | refs/heads/master | 2020-06-19T02:01:50.037518 | 2017-11-01T08:09:54 | 2017-11-01T08:09:54 | 74,927,162 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 33,279 | java | package com.example.drcbse.calendarselectdemo.calendar.bizs.calendars;
import com.example.drcbse.calendarselectdemo.calendar.utils.DataUtils;
/**
* 农历二十四节气算法
* 该算法目前仅对外提供一个接口方法获取某年的节气数据{@link #buildSolarTerm(int)}
*
* Algorithm of lunar solar term.
* This algorithm provide a public method to get the all solar term of year.{@link #buildSolarTerm(int)}
*
* @author AigeStudio 2015-06-16
*/
final class SolarTerm {
private static final double[] E10 = {1.75347045673, 0.00000000000, 0.0000000000, 0.03341656456, 4.66925680417, 6283.0758499914, 0.00034894275, 4.62610241759, 12566.1516999828, 0.00003417571, 2.82886579606, 3.5231183490, 0.00003497056, 2.74411800971, 5753.3848848968, 0.00003135896, 3.62767041758, 77713.7714681205, 0.00002676218, 4.41808351397, 7860.4193924392, 0.00002342687, 6.13516237631, 3930.2096962196, 0.00001273166, 2.03709655772, 529.6909650946, 0.00001324292, 0.74246356352, 11506.7697697936, 0.00000901855, 2.04505443513, 26.2983197998, 0.00001199167, 1.10962944315, 1577.3435424478, 0.00000857223, 3.50849156957, 398.1490034082, 0.00000779786, 1.17882652114, 5223.6939198022, 0.00000990250, 5.23268129594, 5884.9268465832, 0.00000753141, 2.53339053818, 5507.5532386674, 0.00000505264, 4.58292563052, 18849.2275499742, 0.00000492379, 4.20506639861, 775.5226113240, 0.00000356655, 2.91954116867, 0.0673103028, 0.00000284125, 1.89869034186, 796.2980068164, 0.00000242810, 0.34481140906, 5486.7778431750, 0.00000317087, 5.84901952218, 11790.6290886588, 0.00000271039, 0.31488607649, 10977.0788046990, 0.00000206160, 4.80646606059, 2544.3144198834, 0.00000205385, 1.86947813692, 5573.1428014331, 0.00000202261, 2.45767795458, 6069.7767545534, 0.00000126184, 1.08302630210, 20.7753954924, 0.00000155516, 0.83306073807, 213.2990954380, 0.00000115132, 0.64544911683, 0.9803210682, 0.00000102851, 0.63599846727, 4694.0029547076, 0.00000101724, 4.26679821365, 7.1135470008, 0.00000099206, 6.20992940258, 2146.1654164752, 0.00000132212, 3.41118275555, 2942.4634232916, 0.00000097607, 0.68101272270, 155.4203994342, 0.00000085128, 1.29870743025, 6275.9623029906, 0.00000074651, 1.75508916159, 5088.6288397668, 0.00000101895, 0.97569221824, 15720.8387848784, 0.00000084711, 3.67080093025, 71430.6956181291, 0.00000073547, 4.67926565481, 801.8209311238, 0.00000073874, 3.50319443167, 3154.6870848956, 0.00000078756, 3.03698313141, 12036.4607348882, 0.00000079637, 1.80791330700, 17260.1546546904, 0.00000085803, 5.98322631256, 161000.6857376741, 0.00000056963, 2.78430398043, 6286.5989683404, 0.00000061148, 1.81839811024, 7084.8967811152, 0.00000069627, 0.83297596966, 9437.7629348870, 0.00000056116, 4.38694880779, 14143.4952424306, 0.00000062449, 3.97763880587, 8827.3902698748, 0.00000051145, 0.28306864501, 5856.4776591154, 0.00000055577, 3.47006009062, 6279.5527316424, 0.00000041036, 5.36817351402, 8429.2412664666, 0.00000051605, 1.33282746983, 1748.0164130670, 0.00000051992, 0.18914945834, 12139.5535091068, 0.00000049000, 0.48735065033, 1194.4470102246, 0.00000039200, 6.16832995016, 10447.3878396044, 0.00000035566, 1.77597314691, 6812.7668150860, 0.00000036770, 6.04133859347, 10213.2855462110, 0.00000036596, 2.56955238628, 1059.3819301892, 0.00000033291, 0.59309499459, 17789.8456197850, 0.00000035954, 1.70876111898, 2352.8661537718};
private static final double[] E11 = {6283.31966747491, 0.00000000000, 0.0000000000, 0.00206058863, 2.67823455584, 6283.0758499914, 0.00004303430, 2.63512650414, 12566.1516999828, 0.00000425264, 1.59046980729, 3.5231183490, 0.00000108977, 2.96618001993, 1577.3435424478, 0.00000093478, 2.59212835365, 18849.2275499742, 0.00000119261, 5.79557487799, 26.2983197998, 0.00000072122, 1.13846158196, 529.6909650946, 0.00000067768, 1.87472304791, 398.1490034082, 0.00000067327, 4.40918235168, 5507.5532386674, 0.00000059027, 2.88797038460, 5223.6939198022, 0.00000055976, 2.17471680261, 155.4203994342, 0.00000045407, 0.39803079805, 796.2980068164, 0.00000036369, 0.46624739835, 775.5226113240, 0.00000028958, 2.64707383882, 7.1135470008, 0.00000019097, 1.84628332577, 5486.7778431750, 0.00000020844, 5.34138275149, 0.9803210682, 0.00000018508, 4.96855124577, 213.2990954380, 0.00000016233, 0.03216483047, 2544.3144198834, 0.00000017293, 2.99116864949, 6275.9623029906};
private static final double[] E12 = {0.00052918870, 0.00000000000, 0.0000000000, 0.00008719837, 1.07209665242, 6283.0758499914, 0.00000309125, 0.86728818832, 12566.1516999828, 0.00000027339, 0.05297871691, 3.5231183490, 0.00000016334, 5.18826691036, 26.2983197998, 0.00000015752, 3.68457889430, 155.4203994342, 0.00000009541, 0.75742297675, 18849.2275499742, 0.00000008937, 2.05705419118, 77713.7714681205, 0.00000006952, 0.82673305410, 775.5226113240, 0.00000005064, 4.66284525271, 1577.3435424478};
private static final double[] E13 = {0.00000289226, 5.84384198723, 6283.0758499914, 0.00000034955, 0.00000000000, 0.0000000000, 0.00000016819, 5.48766912348, 12566.1516999828};
private static final double[] E14 = {0.00000114084, 3.14159265359, 0.0000000000, 0.00000007717, 4.13446589358, 6283.0758499914, 0.00000000765, 3.83803776214, 12566.1516999828};
private static final double[] E15 = {0.00000000878, 3.14159265359, 0.0000000000};
private static final double[] E20 = {0.00000279620, 3.19870156017, 84334.6615813083, 0.00000101643, 5.42248619256, 5507.5532386674, 0.00000080445, 3.88013204458, 5223.6939198022, 0.00000043806, 3.70444689758, 2352.8661537718, 0.00000031933, 4.00026369781, 1577.3435424478, 0.00000022724, 3.98473831560, 1047.7473117547, 0.00000016392, 3.56456119782, 5856.4776591154, 0.00000018141, 4.98367470263, 6283.0758499914, 0.00000014443, 3.70275614914, 9437.7629348870, 0.00000014304, 3.41117857525, 10213.2855462110};
private static final double[] E21 = {0.00000009030, 3.89729061890, 5507.5532386674, 0.00000006177, 1.73038850355, 5223.6939198022};
private static final double[] E30 = {1.00013988799, 0.00000000000, 0.0000000000, 0.01670699626, 3.09846350771, 6283.0758499914, 0.00013956023, 3.05524609620, 12566.1516999828, 0.00003083720, 5.19846674381, 77713.7714681205, 0.00001628461, 1.17387749012, 5753.3848848968, 0.00001575568, 2.84685245825, 7860.4193924392, 0.00000924799, 5.45292234084, 11506.7697697936, 0.00000542444, 4.56409149777, 3930.2096962196};
private static final double[] E31 = {0.00103018608, 1.10748969588, 6283.0758499914, 0.00001721238, 1.06442301418, 12566.1516999828, 0.00000702215, 3.14159265359, 0.0000000000};
private static final double[] E32 = {0.00004359385, 5.78455133738, 6283.0758499914};
private static final double[] E33 = {0.00000144595, 4.27319435148, 6283.0758499914};
private static final double[] M10 = {22639.5858800, 2.3555545723, 8328.6914247251, 1.5231275E-04, 2.5041111E-07, -1.1863391E-09, 4586.4383203, 8.0413790709, 7214.0628654588, -2.1850087E-04, -1.8646419E-07, 8.7760973E-10, 2369.9139357, 10.3969336431, 15542.7542901840, -6.6188121E-05, 6.3946925E-08, -3.0872935E-10, 769.0257187, 4.7111091445, 16657.3828494503, 3.0462550E-04, 5.0082223E-07, -2.3726782E-09, -666.4175399, -0.0431256817, 628.3019552485, -2.6638815E-06, 6.1639211E-10, -5.4439728E-11, -411.5957339, 3.2558104895, 16866.9323152810, -1.2804259E-04, -9.8998954E-09, 4.0433461E-11, 211.6555524, 5.6858244986, -1114.6285592663, -3.7081362E-04, -4.3687530E-07, 2.0639488E-09, 205.4359530, 8.0845047526, 6585.7609102104, -2.1583699E-04, -1.8708058E-07, 9.3204945E-10, 191.9561973, 12.7524882154, 23871.4457149091, 8.6124629E-05, 3.1435804E-07, -1.4950684E-09, 164.7286185, 10.4400593249, 14914.4523349355, -6.3524240E-05, 6.3330532E-08, -2.5428962E-10, -147.3213842, -2.3986802540, -7700.3894694766, -1.5497663E-04, -2.4979472E-07, 1.1318993E-09, -124.9881185, 5.1984668216, 7771.3771450920, -3.3094061E-05, 3.1973462E-08, -1.5436468E-10, -109.3803637, 2.3124288905, 8956.9933799736, 1.4964887E-04, 2.5102751E-07, -1.2407788E-09, 55.1770578, 7.1411231536, -1324.1780250970, 6.1854469E-05, 7.3846820E-08, -3.4916281E-10, -45.0996092, 5.6113650618, 25195.6237400061, 2.4270161E-05, 2.4051122E-07, -1.1459056E-09, 39.5333010, -0.9002559173, -8538.2408905558, 2.8035534E-04, 2.6031101E-07, -1.2267725E-09, 38.4298346, 18.4383127140, 22756.8171556428, -2.8468899E-04, -1.2251727E-07, 5.6888037E-10, 36.1238141, 7.0666637168, 24986.0742741754, 4.5693825E-04, 7.5123334E-07, -3.5590172E-09, 30.7725751, 16.0827581417, 14428.1257309177, -4.3700174E-04, -3.7292838E-07, 1.7552195E-09, -28.3971008, 7.9982533891, 7842.3648207073, -2.2116475E-04, -1.8584780E-07, 8.2317000E-10, -24.3582283, 10.3538079614, 16171.0562454324, -6.8852003E-05, 6.4563317E-08, -3.6316908E-10, -18.5847068, 2.8429122493, -557.3142796331, -1.8540681E-04, -2.1843765E-07, 1.0319744E-09, 17.9544674, 5.1553411398, 8399.6791003405, -3.5757942E-05, 3.2589854E-08, -2.0880440E-10, 14.5302779, 12.7956138971, 23243.1437596606, 8.8788511E-05, 3.1374165E-07, -1.4406287E-09, 14.3796974, 15.1080427876, 32200.1371396342, 2.3843738E-04, 5.6476915E-07, -2.6814075E-09, 14.2514576, -24.0810366320, -2.3011998397, 1.5231275E-04, 2.5041111E-07, -1.1863391E-09, 13.8990596, 20.7938672862, 31085.5085803679, -1.3237624E-04, 1.2789385E-07, -6.1745870E-10, 13.1940636, 3.3302699264, -9443.3199839914, -5.2312637E-04, -6.8728642E-07, 3.2502879E-09, -9.6790568, -4.7542348263, -16029.0808942018, -3.0728938E-04, -5.0020584E-07, 2.3182384E-09, -9.3658635, 11.2971895604, 24080.9951807398, -3.4654346E-04, -1.9636409E-07, 9.1804319E-10, 8.6055318, 5.7289501804, -1742.9305145148, -3.6814974E-04, -4.3749170E-07, 2.1183885E-09, -8.4530982, 7.5540213938, 16100.0685698171, 1.1921869E-04, 2.8238458E-07, -1.3407038E-09, 8.0501724, 10.4831850066, 14286.1503796870, -6.0860358E-05, 6.2714140E-08, -1.9984990E-10, -7.6301553, 4.6679834628, 17285.6848046987, 3.0196162E-04, 5.0143862E-07, -2.4271179E-09, -7.4474952, -0.0862513635, 1256.6039104970, -5.3277630E-06, 1.2327842E-09, -1.0887946E-10, 7.3712011, 8.1276304344, 5957.4589549619, -2.1317311E-04, -1.8769697E-07, 9.8648918E-10, 7.0629900, 0.9591375719, 33.7570471374, -3.0829302E-05, -3.6967043E-08, 1.7385419E-10, -6.3831491, 9.4966777258, 7004.5133996281, 2.1416722E-04, 3.2425793E-07, -1.5355019E-09, -5.7416071, 13.6527441326, 32409.6866054649, -1.9423071E-04, 5.4047029E-08, -2.6829589E-10, 4.3740095, 18.4814383957, 22128.5152003943, -2.8202511E-04, -1.2313366E-07, 6.2332010E-10, -3.9976134, 7.9669196340, 33524.3151647312, 1.7658291E-04, 4.9092233E-07, -2.3322447E-09, -3.2096876, 13.2398458924, 14985.4400105508, -2.5159493E-04, -1.5449073E-07, 7.2324505E-10, -2.9145404, 12.7093625336, 24499.7476701576, 8.3460748E-05, 3.1497443E-07, -1.5495082E-09, 2.7318890, 16.1258838235, 13799.8237756692, -4.3433786E-04, -3.7354477E-07, 1.8096592E-09, -2.5679459, -2.4418059357, -7072.0875142282, -1.5764051E-04, -2.4917833E-07, 1.0774596E-09, -2.5211990, 7.9551277074, 8470.6667759558, -2.2382863E-04, -1.8523141E-07, 7.6873027E-10, 2.4888871, 5.6426988169, -486.3266040178, -3.7347750E-04, -4.3625891E-07, 2.0095091E-09, 2.1460741, 7.1842488353, -1952.4799803455, 6.4518350E-05, 7.3230428E-08, -2.9472308E-10, 1.9777270, 23.1494218585, 39414.2000050930, 1.9936508E-05, 3.7830496E-07, -1.8037978E-09, 1.9336825, 9.4222182890, 33314.7656989005, 6.0925100E-04, 1.0016445E-06, -4.7453563E-09, 1.8707647, 20.8369929680, 30457.2066251194, -1.2971236E-04, 1.2727746E-07, -5.6301898E-10, -1.7529659, 0.4873576771, -8886.0057043583, -3.3771956E-04, -4.6884877E-07, 2.2183135E-09, -1.4371624, 7.0979974718, -695.8760698485, 5.9190587E-05, 7.4463212E-08, -4.0360254E-10, -1.3725701, 1.4552986550, -209.5494658307, 4.3266809E-04, 5.1072212E-07, -2.4131116E-09, 1.2618162, 7.5108957121, 16728.3705250656, 1.1655481E-04, 2.8300097E-07, -1.3951435E-09};
private static final double[] M11 = {1.6768000, -0.0431256817, 628.3019552485, -2.6638815E-06, 6.1639211E-10, -5.4439728E-11, 0.5164200, 11.2260974062, 6585.7609102104, -2.1583699E-04, -1.8708058E-07, 9.3204945E-10, 0.4138300, 13.5816519784, 14914.4523349355, -6.3524240E-05, 6.3330532E-08, -2.5428962E-10, 0.3711500, 5.5402729076, 7700.3894694766, 1.5497663E-04, 2.4979472E-07, -1.1318993E-09, 0.2756000, 2.3124288905, 8956.9933799736, 1.4964887E-04, 2.5102751E-07, -1.2407788E-09, 0.2459863, -25.6198212459, -2.3011998397, 1.5231275E-04, 2.5041111E-07, -1.1863391E-09, 0.0711800, 7.9982533891, 7842.3648207073, -2.2116475E-04, -1.8584780E-07, 8.2317000E-10, 0.0612800, 10.3538079614, 16171.0562454324, -6.8852003E-05, 6.4563317E-08, -3.6316908E-10};
private static final double[] M12 = {0.0048700, -0.0431256817, 628.3019552485, -2.6638815E-06, 6.1639211E-10, -5.4439728E-11, 0.0022800, -27.1705318325, -2.3011998397, 1.5231275E-04, 2.5041111E-07, -1.1863391E-09, 0.0015000, 11.2260974062, 6585.7609102104, -2.1583699E-04, -1.8708058E-07, 9.3204945E-10};
private static final double[] M20 = {18461.2400600, 1.6279052448, 8433.4661576405, -6.4021295E-05, -4.9499477E-09, 2.0216731E-11, 1010.1671484, 3.9834598170, 16762.1575823656, 8.8291456E-05, 2.4546117E-07, -1.1661223E-09, 999.6936555, 0.7276493275, -104.7747329154, 2.1633405E-04, 2.5536106E-07, -1.2065558E-09, 623.6524746, 8.7690283983, 7109.2881325435, -2.1668263E-06, 6.8896872E-08, -3.2894608E-10, 199.4837596, 9.6692843156, 15647.5290230993, -2.8252217E-04, -1.9141414E-07, 8.9782646E-10, 166.5741153, 6.4134738261, -1219.4032921817, -1.5447958E-04, -1.8151424E-07, 8.5739300E-10, 117.2606951, 12.0248388879, 23976.2204478244, -1.3020942E-04, 5.8996977E-08, -2.8851262E-10, 61.9119504, 6.3390143893, 25090.8490070907, 2.4060421E-04, 4.9587228E-07, -2.3524614E-09, 33.3572027, 11.1245829706, 15437.9795572686, 1.5014592E-04, 3.1930799E-07, -1.5152852E-09, 31.7596709, 3.0832038997, 8223.9166918098, 3.6864680E-04, 5.0577218E-07, -2.3928949E-09, 29.5766003, 8.8121540801, 6480.9861772950, 4.9705523E-07, 6.8280480E-08, -2.7450635E-10, 15.5662654, 4.0579192538, -9548.0947169068, -3.0679233E-04, -4.3192536E-07, 2.0437321E-09, 15.1215543, 14.3803934601, 32304.9118725496, 2.2103334E-05, 3.0940809E-07, -1.4748517E-09, -12.0941511, 8.7259027166, 7737.5900877920, -4.8307078E-06, 6.9513264E-08, -3.8338581E-10, 8.8681426, 9.7124099974, 15019.2270678508, -2.7985829E-04, -1.9203053E-07, 9.5226618E-10, 8.0450400, 0.6687636586, 8399.7091105030, -3.3191993E-05, 3.2017096E-08, -1.5363746E-10, 7.9585542, 12.0679645696, 23347.9184925760, -1.2754553E-04, 5.8380585E-08, -2.3407289E-10, 7.4345550, 6.4565995078, -1847.7052474301, -1.5181570E-04, -1.8213063E-07, 9.1183272E-10, -6.7314363, -4.0265854988, -16133.8556271171, -9.0955337E-05, -2.4484477E-07, 1.1116826E-09, 6.5795750, 16.8104074692, 14323.3509980023, -2.2066770E-04, -1.1756732E-07, 5.4866364E-10, -6.4600721, 1.5847795630, 9061.7681128890, -6.6685176E-05, -4.3335556E-09, -3.4222998E-11, -6.2964773, 4.8837157343, 25300.3984729215, -1.9206388E-04, -1.4849843E-08, 6.0650192E-11, -5.6323538, -0.7707750092, 733.0766881638, -2.1899793E-04, -2.5474467E-07, 1.1521161E-09, -5.3683961, 6.8263720663, 16204.8433027325, -9.7115356E-05, 2.7023515E-08, -1.3414795E-10, -5.3112784, 3.9403341353, 17390.4595376141, 8.5627574E-05, 2.4607756E-07, -1.2205621E-09, -5.0759179, 0.6845236457, 523.5272223331, 2.1367016E-04, 2.5597745E-07, -1.2609955E-09, -4.8396143, -1.6710309265, -7805.1642023920, 6.1357413E-05, 5.5663398E-09, -7.4656459E-11, -4.8057401, 3.5705615768, -662.0890125485, 3.0927234E-05, 3.6923410E-08, -1.7458141E-10, 3.9840545, 8.6945689615, 33419.5404318159, 3.9291696E-04, 7.4628340E-07, -3.5388005E-09, 3.6744619, 19.1659620415, 22652.0424227274, -6.8354947E-05, 1.3284380E-07, -6.3767543E-10, 2.9984815, 20.0662179587, 31190.2833132833, -3.4871029E-04, -1.2746721E-07, 5.8909710E-10, 2.7986413, -2.5281611620, -16971.7070481963, 3.4437664E-04, 2.6526096E-07, -1.2469893E-09, 2.4138774, 17.7106633865, 22861.5918885581, -5.0102304E-04, -3.7787833E-07, 1.7754362E-09, 2.1863132, 5.5132179088, -9757.6441827375, 1.2587576E-04, 7.8796768E-08, -3.6937954E-10, 2.1461692, 13.4801375428, 23766.6709819937, 3.0245868E-04, 5.6971910E-07, -2.7016242E-09, 1.7659832, 11.1677086523, 14809.6776020201, 1.5280981E-04, 3.1869159E-07, -1.4608454E-09, -1.6244212, 7.3137297434, 7318.8375983742, -4.3483492E-04, -4.4182525E-07, 2.0841655E-09, 1.5813036, 5.4387584720, 16552.6081165349, 5.2095955E-04, 7.5618329E-07, -3.5792340E-09, 1.5197528, 16.7359480324, 40633.6032972747, 1.7441609E-04, 5.5981921E-07, -2.6611908E-09, 1.5156341, 1.7023646816, -17876.7861416319, -4.5910508E-04, -6.8233647E-07, 3.2300712E-09, 1.5102092, 5.4977296450, 8399.6847301375, -3.3094061E-05, 3.1973462E-08, -1.5436468E-10, -1.3178223, 9.6261586339, 16275.8309783478, -2.8518605E-04, -1.9079775E-07, 8.4338673E-10, -1.2642739, 11.9817132061, 24604.5224030729, -1.3287330E-04, 5.9613369E-08, -3.4295235E-10, 1.1918723, 22.4217725310, 39518.9747380084, -1.9639754E-04, 1.2294390E-07, -5.9724197E-10, 1.1346110, 14.4235191419, 31676.6099173011, 2.4767216E-05, 3.0879170E-07, -1.4204120E-09, 1.0857810, 8.8552797618, 5852.6842220465, 3.1609367E-06, 6.7664088E-08, -2.2006663E-10, -1.0193852, 7.2392703065, 33629.0898976466, -3.9751134E-05, 2.3556127E-07, -1.1256889E-09, -0.8227141, 11.0814572888, 16066.2815125171, 1.4748204E-04, 3.1992438E-07, -1.5697249E-09, 0.8042238, 3.5274358950, -33.7870573000, 2.8263353E-05, 3.7539802E-08, -2.2902113E-10, 0.8025939, 6.7832463846, 16833.1452579809, -9.9779237E-05, 2.7639907E-08, -1.8858767E-10, -0.7931866, -6.3821400710, -24462.5470518423, -2.4326809E-04, -4.9525589E-07, 2.2980217E-09, -0.7910153, 6.3703481443, -591.1013369332, -1.5714346E-04, -1.8089785E-07, 8.0295327E-10, -0.6674056, 9.1819266386, 24533.5347274576, 5.5197395E-05, 2.7743463E-07, -1.3204870E-09, 0.6502226, 4.1010449356, -10176.3966721553, -3.0412845E-04, -4.3254175E-07, 2.0981718E-09, -0.6388131, 6.2958887075, 25719.1509623392, 2.3794032E-04, 4.9648867E-07, -2.4069012E-09};
private static final double[] M21 = {0.0743000, 11.9537467337, 6480.9861772950, 4.9705523E-07, 6.8280480E-08, -2.7450635E-10, 0.0304300, 8.7259027166, 7737.5900877920, -4.8307078E-06, 6.9513264E-08, -3.8338581E-10, 0.0222900, 12.8540026510, 15019.2270678508, -2.7985829E-04, -1.9203053E-07, 9.5226618E-10, 0.0199900, 15.2095572232, 23347.9184925760, -1.2754553E-04, 5.8380585E-08, -2.3407289E-10, 0.0186900, 9.5981921614, -1847.7052474301, -1.5181570E-04, -1.8213063E-07, 9.1183272E-10, 0.0169600, 7.1681781524, 16133.8556271171, 9.0955337E-05, 2.4484477E-07, -1.1116826E-09, 0.0162300, 1.5847795630, 9061.7681128890, -6.6685176E-05, -4.3335556E-09, -3.4222998E-11, 0.0141900, -0.7707750092, 733.0766881638, -2.1899793E-04, -2.5474467E-07, 1.1521161E-09};
private static final double[] M30 = {385000.5290396, 1.5707963268, 0.0000000000, 0.0000000E+00, 0.0000000E+00, 0.0000000E+00, -20905.3551378, 3.9263508990, 8328.6914247251, 1.5231275E-04, 2.5041111E-07, -1.1863391E-09, -3699.1109330, 9.6121753977, 7214.0628654588, -2.1850087E-04, -1.8646419E-07, 8.7760973E-10, -2955.9675626, 11.9677299699, 15542.7542901840, -6.6188121E-05, 6.3946925E-08, -3.0872935E-10, -569.9251264, 6.2819054713, 16657.3828494503, 3.0462550E-04, 5.0082223E-07, -2.3726782E-09, 246.1584797, 7.2566208254, -1114.6285592663, -3.7081362E-04, -4.3687530E-07, 2.0639488E-09, -204.5861179, 12.0108556517, 14914.4523349355, -6.3524240E-05, 6.3330532E-08, -2.5428962E-10, -170.7330791, 14.3232845422, 23871.4457149091, 8.6124629E-05, 3.1435804E-07, -1.4950684E-09, -152.1378118, 9.6553010794, 6585.7609102104, -2.1583699E-04, -1.8708058E-07, 9.3204945E-10, -129.6202242, -0.8278839272, -7700.3894694766, -1.5497663E-04, -2.4979472E-07, 1.1318993E-09, 108.7427014, 6.7692631483, 7771.3771450920, -3.3094061E-05, 3.1973462E-08, -1.5436468E-10, 104.7552944, 3.8832252173, 8956.9933799736, 1.4964887E-04, 2.5102751E-07, -1.2407788E-09, 79.6605685, 0.6705404095, -8538.2408905558, 2.8035534E-04, 2.6031101E-07, -1.2267725E-09, 48.8883284, 1.5276706450, 628.3019552485, -2.6638815E-06, 6.1639211E-10, -5.4439728E-11, -34.7825237, 20.0091090408, 22756.8171556428, -2.8468899E-04, -1.2251727E-07, 5.6888037E-10, 30.8238599, 11.9246042882, 16171.0562454324, -6.8852003E-05, 6.4563317E-08, -3.6316908E-10, 24.2084985, 9.5690497159, 7842.3648207073, -2.2116475E-04, -1.8584780E-07, 8.2317000E-10, -23.2104305, 8.6374600436, 24986.0742741754, 4.5693825E-04, 7.5123334E-07, -3.5590172E-09, -21.6363439, 17.6535544685, 14428.1257309177, -4.3700174E-04, -3.7292838E-07, 1.7552195E-09, -16.6747239, 6.7261374666, 8399.6791003405, -3.5757942E-05, 3.2589854E-08, -2.0880440E-10, 14.4026890, 4.9010662531, -9443.3199839914, -5.2312637E-04, -6.8728642E-07, 3.2502879E-09, -12.8314035, 14.3664102239, 23243.1437596606, 8.8788511E-05, 3.1374165E-07, -1.4406287E-09, -11.6499478, 22.3646636130, 31085.5085803679, -1.3237624E-04, 1.2789385E-07, -6.1745870E-10, -10.4447578, 16.6788391144, 32200.1371396342, 2.3843738E-04, 5.6476915E-07, -2.6814075E-09, 10.3211071, 8.7119194804, -1324.1780250970, 6.1854469E-05, 7.3846820E-08, -3.4916281E-10, 10.0562033, 7.2997465071, -1742.9305145148, -3.6814974E-04, -4.3749170E-07, 2.1183885E-09, -9.8844667, 12.0539813334, 14286.1503796870, -6.0860358E-05, 6.2714140E-08, -1.9984990E-10, 8.7515625, 6.3563649081, -9652.8694498221, -9.0458282E-05, -1.7656429E-07, 8.3717626E-10, -8.3791067, 4.4137085761, -557.3142796331, -1.8540681E-04, -2.1843765E-07, 1.0319744E-09, -7.0026961, -3.1834384995, -16029.0808942018, -3.0728938E-04, -5.0020584E-07, 2.3182384E-09, 6.3220032, 9.1248177206, 16100.0685698171, 1.1921869E-04, 2.8238458E-07, -1.3407038E-09, 5.7508579, 6.2387797896, 17285.6848046987, 3.0196162E-04, 5.0143862E-07, -2.4271179E-09, -4.9501349, 9.6984267611, 5957.4589549619, -2.1317311E-04, -1.8769697E-07, 9.8648918E-10, -4.4211770, 3.0260949818, -209.5494658307, 4.3266809E-04, 5.1072212E-07, -2.4131116E-09, 4.1311145, 11.0674740526, 7004.5133996281, 2.1416722E-04, 3.2425793E-07, -1.5355019E-09, -3.9579827, 20.0522347225, 22128.5152003943, -2.8202511E-04, -1.2313366E-07, 6.2332010E-10, 3.2582371, 14.8106422192, 14985.4400105508, -2.5159493E-04, -1.5449073E-07, 7.2324505E-10, -3.1483020, 4.8266068163, 16866.9323152810, -1.2804259E-04, -9.8998954E-09, 4.0433461E-11, 2.6164092, 14.2801588604, 24499.7476701576, 8.3460748E-05, 3.1497443E-07, -1.5495082E-09, 2.3536310, 9.5259240342, 8470.6667759558, -2.2382863E-04, -1.8523141E-07, 7.6873027E-10, -2.1171283, -0.8710096090, -7072.0875142282, -1.5764051E-04, -2.4917833E-07, 1.0774596E-09, -1.8970368, 17.6966801503, 13799.8237756692, -4.3433786E-04, -3.7354477E-07, 1.8096592E-09, -1.7385258, 2.0581540038, -8886.0057043583, -3.3771956E-04, -4.6884877E-07, 2.2183135E-09, -1.5713944, 22.4077892948, 30457.2066251194, -1.2971236E-04, 1.2727746E-07, -5.6301898E-10, -1.4225541, 24.7202181853, 39414.2000050930, 1.9936508E-05, 3.7830496E-07, -1.8037978E-09, -1.4189284, 17.1661967915, 23314.1314352759, -9.9282182E-05, 9.5920387E-08, -4.6309403E-10, 1.1655364, 3.8400995356, 9585.2953352221, 1.4698499E-04, 2.5164390E-07, -1.2952185E-09, -1.1169371, 10.9930146158, 33314.7656989005, 6.0925100E-04, 1.0016445E-06, -4.7453563E-09, 1.0656723, 1.4845449633, 1256.6039104970, -5.3277630E-06, 1.2327842E-09, -1.0887946E-10, 1.0586190, 11.9220903668, 8364.7398411275, -2.1850087E-04, -1.8646419E-07, 8.7760973E-10, -0.9333176, 9.0816920389, 16728.3705250656, 1.1655481E-04, 2.8300097E-07, -1.3951435E-09, 0.8624328, 12.4550876470, 6656.7485858257, -4.0390768E-04, -4.0490184E-07, 1.9095841E-09, 0.8512404, 4.3705828944, 70.9876756153, -1.8807069E-04, -2.1782126E-07, 9.7753467E-10, -0.8488018, 16.7219647962, 31571.8351843857, 2.4110126E-04, 5.6415276E-07, -2.6269678E-09, -0.7956264, 3.5134526588, -9095.5551701890, 9.4948529E-05, 4.1873358E-08, -1.9479814E-10};
private static final double[] M31 = {0.5139500, 12.0108556517, 14914.4523349355, -6.3524240E-05, 6.3330532E-08, -2.5428962E-10, 0.3824500, 9.6553010794, 6585.7609102104, -2.1583699E-04, -1.8708058E-07, 9.3204945E-10, 0.3265400, 3.9694765808, 7700.3894694766, 1.5497663E-04, 2.4979472E-07, -1.1318993E-09, 0.2639600, 0.7416325637, 8956.9933799736, 1.4964887E-04, 2.5102751E-07, -1.2407788E-09, 0.1230200, -1.6139220085, 628.3019552485, -2.6638815E-06, 6.1639211E-10, -5.4439728E-11, 0.0775400, 8.7830116346, 16171.0562454324, -6.8852003E-05, 6.4563317E-08, -3.6316908E-10, 0.0606800, 6.4274570623, 7842.3648207073, -2.2116475E-04, -1.8584780E-07, 8.2317000E-10, 0.0497000, 12.0539813334, 14286.1503796870, -6.0860358E-05, 6.2714140E-08, -1.9984990E-10};
private static final double[] M1n = {3.81034392032, 8.39968473021E+03, -3.31919929753E-05, 3.20170955005E-08, -1.53637455544E-10};
private static final double[] nutB = {2.1824391966, -33.757045954, 0.0000362262, 3.7340E-08, -2.8793E-10, -171996, -1742, 92025, 89, 3.5069406862, 1256.663930738, 0.0000105845, 6.9813E-10, -2.2815E-10, -13187, -16, 5736, -31, 1.3375032491, 16799.418221925, -0.0000511866, 6.4626E-08, -5.3543E-10, -2274, -2, 977, -5, 4.3648783932, -67.514091907, 0.0000724525, 7.4681E-08, -5.7586E-10, 2062, 2, -895, 5, 0.0431251803, -628.301955171, 0.0000026820, 6.5935E-10, 5.5705E-11, -1426, 34, 54, -1, 2.3555557435, 8328.691425719, 0.0001545547, 2.5033E-07, -1.1863E-09, 712, 1, -7, 0, 3.4638155059, 1884.965885909, 0.0000079025, 3.8785E-11, -2.8386E-10, -517, 12, 224, -6, 5.4382493597, 16833.175267879, -0.0000874129, 2.7285E-08, -2.4750E-10, -386, -4, 200, 0, 3.6930589926, 25128.109647645, 0.0001033681, 3.1496E-07, -1.7218E-09, -301, 0, 129, -1, 3.5500658664, 628.361975567, 0.0000132664, 1.3575E-09, -1.7245E-10, 217, -5, -95, 3};
private static final double[] GXC_e = {0.016708634, -0.000042037, -0.0000001267};
private static final double rad = 180 * 3600 / Math.PI;
private static final double RAD = 180 / Math.PI;
private static final double J2000 = 2451545;
private static final double[] preceB = {0, 50287.92262, 111.24406, 0.07699, -0.23479, -0.00178, 0.00018, 0.00001};
private static final double[] GXC_p = {102.93735 / RAD, 1.71946 / RAD, 0.00046 / RAD};
private static final double[] GXC_l = {280.4664567 / RAD, 36000.76982779 / RAD, 0.0003032028 / RAD, 1 / 49931000 / RAD, -1 / 153000000 / RAD};
private static final double GXC_k = 20.49552 / rad;
private static final double[] dts = {-4000, 108371.7, -13036.80, 392.000, 0.0000, -500, 17201.0, -627.82, 16.170, -0.3413, -150, 12200.6, -346.41, 5.403, -0.1593, 150, 9113.8, -328.13, -1.647, 0.0377, 500, 5707.5, -391.41, 0.915, 0.3145, 900, 2203.4, -283.45, 13.034, -0.1778, 1300, 490.1, -57.35, 2.085, -0.0072, 1600, 120.0, -9.81, -1.532, 0.1403, 1700, 10.2, -0.91, 0.510, -0.0370, 1800, 13.4, -0.72, 0.202, -0.0193, 1830, 7.8, -1.81, 0.416, -0.0247, 1860, 8.3, -0.13, -0.406, 0.0292, 1880, -5.4, 0.32, -0.183, 0.0173, 1900, -2.3, 2.06, 0.169, -0.0135, 1920, 21.2, 1.69, -0.304, 0.0167, 1940, 24.2, 1.22, -0.064, 0.0031, 1960, 33.2, 0.51, 0.231, -0.0109, 1980, 51.0, 1.29, -0.026, 0.0032, 2000, 64.7, -1.66, 5.224, -0.2905, 2150, 279.4, 732.95, 429.579, 0.0158, 6000};
private double enNT = 0;
private double mnNT = 0;
private double D = 1;
private class ZD {
double Lon;
double Obl;
}
/**
* 生成某年农历二十四节气数组数据
* Create solar term by year.
*
* @param year 某年
* @return ...
*/
String[][] buildSolarTerm(int year) {
String[] tmp = new String[24];
double jd = 365.2422 * (year - 2000), q;
int j;
for (int i = 0; i < tmp.length; i++) {
j = i - 5;
q = angleCal(jd + j * 15.2, j * 15, 0);
q = q + J2000 + (double) 8 / 24;
setFromJD(q, true);
tmp[i] = String.valueOf((int) D);
}
return DataUtils.arraysConvert(tmp, 12, 2);
}
private void setFromJD(double jd, boolean UTC) {
if (UTC)
jd -= this.deltaT2(jd - J2000);
jd += 0.5;
double A = int2(jd);
double D;
if (A > 2299161) {
D = int2((A - 1867216.25) / 36524.25);
A += 1 + D - int2(D / 4);
}
A += 1524;
double y = int2((A - 122.1) / 365.25);
D = A - int2(365.25 * y);
double m = int2(D / 30.6001);
this.D = D - int2(m * 30.6001);
y -= 4716;
m--;
if (m > 12)
m -= 12;
if (m <= 2)
//noinspection UnusedAssignment
y++;
}
private double int2(double v) {
v = Math.floor(v);
if (v < 0)
return v + 1;
return v;
}
private double deltaT2(double jd) {
return this.deltaT(jd / 365.2425 + 2000) / 86400.0;
}
private double deltaT(double y) {
int i;
for (i = 0; i < 100; i += 5)
if (y < dts[i + 5] || i == 95)
break;
double t1 = (y - dts[i]) / (dts[i + 5] - dts[i]) * 10;
double t2 = t1 * t1;
double t3 = t2 * t1;
return dts[i + 1] + dts[i + 2] * t1 + dts[i + 3] * t2 + dts[i + 4] * t3;
}
private double angleCal(double t1, double jiao, int lx) {
double t2 = t1, t = 0, v;
if (lx == 0)
t2 += 360;
else
t2 += 25;
jiao *= Math.PI / 180;
double v1 = jiaoCai(lx, t1, jiao);
double v2 = jiaoCai(lx, t2, jiao);
if (v1 < v2)
v2 -= 2 * Math.PI;
double k = 1, k2;
for (int i = 0; i < 10; i++) {
k2 = (v2 - v1) / (t2 - t1);
if (Math.abs(k2) > 1e-15)
k = k2;
t = t1 - v1 / k;
v = jiaoCai(lx, t, jiao);
if (v > 1)
v -= 2 * Math.PI;
if (Math.abs(v) < 1e-8)
break;
t1 = t2;
v1 = v2;
t2 = t;
v2 = v;
}
return t;
}
private double jiaoCai(int lx, double t, double jiao) {
double[] sun = earCal(t);
sun[0] += Math.PI;
sun[1] = -sun[1];
addGxc(t, sun);
if (lx == 0) {
ZD d = nutation(t);
sun[0] += d.Lon;
return rad2mrad(jiao - sun[0]);
}
double[] moon = moonCal(t);
return rad2mrad(jiao - (moon[0] - sun[0]));
}
private double[] moonCal(double jd) {
mnNT = jd / 36525;
double t1 = mnNT, t2 = t1 * t1, t3 = t2 * t1, t4 = t3 * t1;
double[] llr = new double[3];
llr[0] = (mnn(M10) + mnn(M11) * t1 + mnn(M12) * t2) / rad;
llr[1] = (mnn(M20) + mnn(M21) * t1) / rad;
llr[2] = (mnn(M30) + mnn(M31) * t1) * 0.999999949827;
llr[0] = llr[0] + M1n[0] + M1n[1] * t1 + M1n[2] * t2 + M1n[3] * t3 + M1n[4] * t4;
llr[0] = rad2mrad(llr[0]);
addPrece(jd, llr);
return llr;
}
private void addPrece(double jd, double[] zb) {
int i;
double t = 1, v = 0, t1 = jd / 365250;
for (i = 1; i < 8; i++) {
t *= t1;
v += preceB[i] * t;
}
zb[0] = rad2mrad(zb[0] + (v + 2.9965 * t1) / rad);
}
private double mnn(double[] F) {
double v = 0, t1 = mnNT, t2 = t1 * t1, t3 = t2 * t1, t4 = t3 * t1;
for (int i = 0; i < F.length; i += 6)
v += F[i] * Math.sin(F[i + 1] + t1 * F[i + 2] + t2 * F[i + 3] + t3 * F[i + 4] + t4 * F[i + 5]);
return v;
}
private ZD nutation(double t) {
ZD d = new ZD();
d.Lon = 0;
d.Obl = 0;
t /= 36525;
double c, t1 = t, t2 = t1 * t1, t3 = t2 * t1, t4 = t3 * t1;
for (int i = 0; i < nutB.length; i += 9) {
c = nutB[i] + nutB[i + 1] * t1 + nutB[i + 2] * t2 + nutB[i + 3] * t3 + nutB[i + 4] * t4;
d.Lon += (nutB[i + 5] + nutB[i + 6] * t / 10) * Math.sin(c);
d.Obl += (nutB[i + 7] + nutB[i + 8] * t / 10) * Math.cos(c);
}
d.Lon /= rad * 10000;
d.Obl /= rad * 10000;
return d;
}
private void addGxc(double t, double[] zb) {
double t1 = t / 36525;
double t2 = t1 * t1;
double t3 = t2 * t1;
double t4 = t3 * t1;
double L = GXC_l[0] + GXC_l[1] * t1 + GXC_l[2] * t2 + GXC_l[3] * t3 + GXC_l[4] * t4;
double p = GXC_p[0] + GXC_p[1] * t1 + GXC_p[2] * t2;
double e = GXC_e[0] + GXC_e[1] * t1 + GXC_e[2] * t2;
double dL = L - zb[0], dP = p - zb[0];
zb[0] -= GXC_k * (Math.cos(dL) - e * Math.cos(dP)) / Math.cos(zb[1]);
zb[1] -= GXC_k * Math.sin(zb[1]) * (Math.sin(dL) - e * Math.sin(dP));
zb[0] = rad2mrad(zb[0]);
}
private double[] earCal(double jd) {
enNT = jd / 365250;
double llr[] = new double[3];
double t1 = enNT, t2 = t1 * t1, t3 = t2 * t1, t4 = t3 * t1, t5 = t4 * t1;
llr[0] = enn(E10) + enn(E11) * t1 + enn(E12) * t2 + enn(E13) * t3 + enn(E14) * t4 + enn(E15) * t5;
llr[1] = enn(E20) + enn(E21) * t1;
llr[2] = enn(E30) + enn(E31) * t1 + enn(E32) * t2 + enn(E33) * t3;
llr[0] = rad2mrad(llr[0]);
return llr;
}
private double rad2mrad(double v) {
v = v % (2 * Math.PI);
if (v < 0)
return v + 2 * Math.PI;
return v;
}
private double enn(double[] F) {
double v = 0;
for (int i = 0; i < F.length; i += 3)
v += F[i] * Math.cos(F[i + 1] + enNT * F[i + 2]);
return v;
}
}
| [
"Lin.Hou@deltaww.com"
] | Lin.Hou@deltaww.com |
ae7c93632ebc67378c310243b039d164cc40f502 | e9dc4e9b5046322b02c54e6a035f6620f0abbc89 | /lian_hjy_project/src/main/java/com/zhanghp/service/base/FyPropertyMoneyDistService.java | f0bd1c9ecee5f899859ec5f2b0de921b2ecef8d5 | [] | no_license | zhp1221/hjy | 333003784ca8c97b0ef2e5af6d7b8843c2c6eeb7 | 88db8f0aca84e0b837de6dc8ebb43de3f0cf8e85 | refs/heads/master | 2023-08-28T04:02:54.552694 | 2021-10-31T11:24:21 | 2021-10-31T11:24:21 | 406,342,462 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 339 | java | package com.zhanghp.service.base;
import com.zhanghp.bean.FyPropertyMoneyDist;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 物业费分布 服务类
* </p>
*
* @author zhanghp
* @since 2021-09-12
*/
public interface FyPropertyMoneyDistService extends IService<FyPropertyMoneyDist> {
}
| [
"zhanghp1221@126.com"
] | zhanghp1221@126.com |
6bae72b02b7addd19210b6e522c6c7d6f6e98d05 | 5353e45fb6da907645729f42d400330e7f382313 | /teams/team154/CommunicationProtocol.java | 381791d0f798cd05a3c0d4a3e82ea3daed98a9a4 | [
"MIT"
] | permissive | jlmart88/youcantmilkthose | 856d798640d38cda499b99c28c124212d96911c8 | 2ac7dd61bc77cb787391654d3ddf6d2f1144d33c | refs/heads/master | 2021-04-30T23:15:12.763169 | 2014-01-24T03:44:58 | 2014-01-24T03:44:58 | 15,715,858 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,661 | java | package team154;
import team154.roles.RobotRoles;
/**
* This class provides the definitions for how robots will broadcast and read to the
* global channels
*
* @author jlmart88
*
*/
public class CommunicationProtocol {
//channel definitions
//the default spacer to use between data on broadcasts
public static final int DEFAULT_SPACER = 101;
/**roleChannels display what role each robot should play
*
* exist on the range 100-124
* format for channel data: (robotID)(defaultSpacer)(robotRole)
*/
public static final int ROLE_CHANNEL_MIN = 100;
public static final int ROLE_CHANNEL_MAX = 124;
public static final int ROLE_CHANNELS[] = range(ROLE_CHANNEL_MIN,ROLE_CHANNEL_MAX+1);
public static final int ROLE_CHANNEL_NUM = ROLE_CHANNELS.length;
/**
* pastrLocationChannels display where we should be building pastrs
* finishedChannel is 0 when not finished, 1 when finished analyzing map
*
* exist on range 15000-4
* format: see VectorFunctions.locToInt()
*/
public static final int PASTR_LOCATION_CHANNEL_MIN = 15000;
public static final int PASTR_LOCATION_CHANNEL_MAX = 15004;
public static final int PASTR_LOCATION_CHANNELS[] = range(PASTR_LOCATION_CHANNEL_MIN,PASTR_LOCATION_CHANNEL_MAX+1);
public static final int PASTR_LOCATION_CHANNEL_NUM = PASTR_LOCATION_CHANNELS.length;
public static final int PASTR_LOCATION_FINISHED_CHANNEL = 15005;
/** Takes in the data stored in a channel and returns what role the channel data is displaying
*
* If the channelData is not properly formatted for displaying a role, it will default to returning
* RobotRoles.CONSTRUCTOR
*
* @param channelData the integer stored in the data
* @return RobotRoles the role the channel is displaying
*/
public static RobotRoles dataToRole(int channelData){
//take the last digit of the data, since roles are only one digit
int communicationID = channelData%10;
for (RobotRoles role: RobotRoles.values()){
if (role.communicationID == communicationID){
return role;
}
}
// if we get here, then the channel data was improperly formatted,
// so default to returning the Constructor role
return RobotRoles.CONSTRUCTOR;
}
/** Takes in the data stored in a channel and returns what robotID the channel data is displaying
*
* If the channelData is not properly formatted for displaying the robotID, then will default to returning
* -1
*
* BYTECODE COST: 20
*
* @param channelData the integer stored in the data
* @return RobotRoles the role the channel is displaying
*/
public static int dataToRobotID(int channelData){
String dataString = Integer.toString(channelData);
int spacerLocation = dataString.lastIndexOf(Integer.toString(DEFAULT_SPACER));
if (spacerLocation != -1){
return Integer.parseInt(dataString.substring(0, spacerLocation));
}
// if we get here, then the channel data was improperly formatted,
// so default to returning -1
return -1;
}
/** Takes in a robotID and a robotRole and returns the corresponding channelData
*
*
* @param robotID integer of the robot's id
* @param role RobotRoles the robot should have
* @return int the channel data to broadcast
*/
public static int roleToData(int robotID, RobotRoles role){
return Integer.parseInt(Integer.toString(robotID)+
Integer.toString(DEFAULT_SPACER)+Integer.toString(role.communicationID));
}
//returns an int[] array where 'begin' is inclusive, 'end' is exclusive
//ex: range(3,6) ---> [3,4,5]
private static int[] range(int begin, int end){
int out[] = new int[end-begin];
for (int i=0;i<end-begin;i++){
out[i]=begin+i;
}
return out;
}
}
| [
"jlmart88@mit.edu"
] | jlmart88@mit.edu |
13106a396511eab6ee4fa2fc237886c5417bf147 | a0d27c35888f2e04ab0776c7a4367ddb136ba654 | /src/Tickets/Ticket.java | 6e114ab5a9c0fc93f34c1daf2d9ad2ceca78103a | [] | no_license | awdsw/demosupport | cb99669cfd852fdf4117adb8a2e732f06f25c3d8 | 11237332c175d6e66f0f5426c0f8da5c0d87fb18 | refs/heads/master | 2023-04-15T16:22:24.408387 | 2021-04-25T18:39:56 | 2021-04-25T18:39:56 | 359,246,384 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,452 | java | package Tickets;
import strategy.Operator;
import strategy.User;
public class Ticket {
private static int ticketNumber;
private String id;
private String description;
private User request;
private Operator assign;
public Ticket(String date, String description, User request) {
ticketNumber++;
id = date + " " + ticketNumber;
this.description = description;
this.request = new User(request);
}
public static int getTicketNumber() {
return ticketNumber;
}
public String getId() {
return id;
}
public String getDescription() {
return description;
}
public User getRequest() {
return request;
}
public void setAgent(Operator assign) {
String name = assign.getName();
String id = assign.getId();
String specialist = assign.getSpecialist();
assign = new Operator(name, id, specialist);
//this.assign = assign;
}
public String toString() {
String data = "ID#: " + getId();
data += "\nProblem: " + getDescription();
data += "\n----Requsted----\n" + request;
data += "\n----Assigned----\n" + assign;
return data;
}
public boolean equals(Ticket other) {
if (description.equals(other.description) && request.equals(other.request)) {
return true;
} else {
return false;
}
}
} | [
"anton.spirit88@gmail.com"
] | anton.spirit88@gmail.com |
be1ac43f274eb9c1c32a87293e5cedc89ca3f99f | 805c319551daccf2f619b3a99e3ae4abdb3be81b | /pro4/src/main/java/in/co/sunrays/proj4/controller/UserRegistrationCtl.java | f8dae66f077442241d9cfe2f95140a0ff2858427 | [] | no_license | sahil7941/HelloWorld | b02b169ef93a5ba99cac8c12c4aaee15c7ba56bb | df1ae3049ae731d24d89f391758fb4437a611e7b | refs/heads/master | 2023-02-07T16:01:22.960006 | 2021-01-02T15:15:42 | 2021-01-02T15:15:42 | 326,207,881 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,170 | java | package in.co.sunrays.proj4.controller;
import in.co.sunrays.proj4.bean.BaseBean;
import in.co.sunrays.proj4.bean.RoleBean;
import in.co.sunrays.proj4.bean.UserBean;
import in.co.sunrays.proj4.exception.ApplicationException;
import in.co.sunrays.proj4.exception.DatabaseException;
import in.co.sunrays.proj4.exception.DuplicateRecordException;
import in.co.sunrays.proj4.model.UserModel;
import in.co.sunrays.proj4.util.DataUtility;
import in.co.sunrays.proj4.util.DataValidator;
import in.co.sunrays.proj4.util.PropertyReader;
import in.co.sunrays.proj4.util.ServletUtility;
import java.io.IOException;
import javax.mail.MessagingException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
/**
* User registration functionality Controller. Performs operation for User
* Registration
*
* @author SunilOS
* @version 1.0
* @Copyright (c) SunilOS
*/
@WebServlet(name = "UserRegistrationCtl", urlPatterns = { "/UserRegistrationCtl" })
public class UserRegistrationCtl extends BaseCtl {
public static final String OP_SIGN_UP = "SignUp";
private static Logger log = Logger.getLogger(UserRegistrationCtl.class);
/**
* Validates the input data entered by user
*
* @param request:
* HttpServletRequest object
* @return pass: a boolean variable
*/
@Override
protected boolean validate(HttpServletRequest request) {
log.debug("UserRegistrationCtl Method validate Started");
boolean pass = true;
String login = request.getParameter("login");
String dob = request.getParameter("dob");
if (DataValidator.isNull(request.getParameter("firstName"))) {
request.setAttribute("firstName", PropertyReader.getValue("error.require", "First name"));
pass = false;
} else if (!DataValidator.isFname(request.getParameter("firstName"))) {
request.setAttribute("firstName", PropertyReader.getValue("error.fname", "First name "));
pass = false;
}
if (DataValidator.isNull(request.getParameter("lastName"))) {
request.setAttribute("lastName", PropertyReader.getValue("error.require", "Last name"));
pass = false;
} else if (!DataValidator.isLname(request.getParameter("lastName"))) {
request.setAttribute("lastName", PropertyReader.getValue("error.lname", "Last name"));
pass = false;
}
if (DataValidator.isNull(login)) {
request.setAttribute("login", PropertyReader.getValue("error.require", "Login Id"));
pass = false;
} else if (!DataValidator.isEmail(login)) {
request.setAttribute("login", PropertyReader.getValue("error.email", "Login "));
pass = false;
}
if (DataValidator.isNull(request.getParameter("password"))) {
request.setAttribute("password", PropertyReader.getValue("error.require", "Password"));
pass = false;
} else if (!DataValidator.isPassword(request.getParameter("password"))) {
request.setAttribute("password", PropertyReader.getValue("error.pass", "Password "));
pass = false;
}
if (DataValidator.isNull(request.getParameter("confirmPassword"))) {
request.setAttribute("confirmPassword", PropertyReader.getValue("error.require", "Confirm Password"));
pass = false;
}
if (DataUtility.getString(request.getParameter("gender")).equals("")) {
request.setAttribute("gender", PropertyReader.getValue("error.select", "gender"));
pass = false;
}
if (DataValidator.isNull(dob)) {
request.setAttribute("dob", PropertyReader.getValue("error.require", "Date Of Birth"));
pass = false;
} else if (!DataValidator.isDate(dob)) {
request.setAttribute("dob", PropertyReader.getValue("error.date", "Date Of Birth"));
pass = false;
}
if (DataValidator.isNull(request.getParameter("contactNo"))) {
request.setAttribute("contactNo", PropertyReader.getValue("error.require", "Mobile no "));
pass = false;
} else if (!DataValidator.isMobileNo(request.getParameter("contactNo"))) {
request.setAttribute("contactNo", PropertyReader.getValue("error.mono", "Mobile no"));
pass = false;
}
if (!request.getParameter("password").equals(request.getParameter("confirmPassword"))
&& !"".equals(request.getParameter("confirmPassword"))) {
request.setAttribute("confirmPassword", PropertyReader.getValue("error.confirm", "Confirm Password "));
pass = false; }
log.debug("UserRegistrationCtl Method validate Ended");
return pass;
}
/**
* Populates the UserBean object from request parameters
*
* @param request:
* HttpServletRequest object
* @return bean: UserBean object
*/
@Override
protected BaseBean populateBean(HttpServletRequest request) {
log.debug("UserRegistrationCtl Method populatebean Started");
UserBean bean = new UserBean();
bean.setId(DataUtility.getLong(request.getParameter("id")));
bean.setRoleId(RoleBean.STUDENT);
bean.setFirstName(DataUtility.getString(request.getParameter("firstName")));
bean.setLastName(DataUtility.getString(request.getParameter("lastName")));
bean.setLogin(DataUtility.getString(request.getParameter("login")));
bean.setPassword(DataUtility.getString(request.getParameter("password")));
bean.setConfirmPassword(DataUtility.getString(request.getParameter("confirmPassword")));
bean.setGender(DataUtility.getString(request.getParameter("gender")));
bean.setDob(DataUtility.getDate(request.getParameter("dob")));
bean.setMobileNo(DataUtility.getString(request.getParameter("contactNo")));
populateDTO(bean, request);
log.debug("UserRegistrationCtl Method populatebean Ended");
return bean;
}
/**
* Display User Registration form
*
* @param request:
* HttpServletRequest object
* @param response:
* HttpServletResponse object
* @throws ServletException
* @throws IOException
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
log.debug("UserRegistrationCtl Method doGet Started");
ServletUtility.forward(getView(), request, response);
}
/**
* Submit concept of user registration
*
* @param request:
* HttpServletRequest object
* @param response:
* HttpServletResponse object
* @throws ServletException
* @throws IOException
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("in get method");
log.debug("UserRegistrationCtl Method doPost Started");
String op = DataUtility.getString(request.getParameter("operation"));
// get model
UserModel model = new UserModel();
long id = DataUtility.getLong(request.getParameter("id"));
if (OP_SIGN_UP.equalsIgnoreCase(op)) {
UserBean bean = (UserBean) populateBean(request);
long pk = 0;
try {
pk = model.registerUser(bean);
bean.setId(pk);
request.getSession().setAttribute("UserBean", bean);
ServletUtility.redirect(ORSView.LOGIN_CTL, request, response);
return;
} catch (ApplicationException e) {
log.error(e);
ServletUtility.handleException(e, request, response);
return;
} catch (DuplicateRecordException e) {
log.error(e);
ServletUtility.setBean(bean, request);
ServletUtility.setErrorMessage("Login id already exists", request);
ServletUtility.forward(getView(), request, response);
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else if (OP_CANCEl.equalsIgnoreCase(op)) {
ServletUtility.redirect(ORSView.LOGIN_CTL, request, response);
return;
}
log.debug("UserRegistrationCtl Method doPost Ended");
}
/**
* Returns the view page of UserRegistrationCtl
*
* @return UserRegistrationView.jsp: View page of UserRegistrationCtl
*/
@Override
protected String getView() {
return ORSView.USER_REGISTRATION_VIEW;
}
} | [
"SAHIL KHAN@DESKTOP-65GRP1E"
] | SAHIL KHAN@DESKTOP-65GRP1E |
654db6fe364f5fb83445f10a59bbb21715a79831 | 360c9e5141018de60d70ceb9042b50496f1de491 | /egakat-io-solicitudes-clientes-gws-rest/src/main/java/com/egakat/io/clientes/gws/service/impl/solicitudes/SolicitudesDespachoNotificacionReciboPushServiceImpl.java | 136d90046582befe25a6236bcfdbd0054fca63ea | [] | no_license | github-ek/egakat-io-solicitudes | bb870b6e4c0e02a06a9b1b19904b39757d0b0e48 | bcc713e355ef70d420de1506b15cce6a8a17bb5a | refs/heads/master | 2021-06-12T04:58:44.945934 | 2019-09-23T04:01:14 | 2019-09-23T04:01:14 | 136,371,425 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 4,067 | java | package com.egakat.io.clientes.gws.service.impl.solicitudes;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egakat.core.web.client.components.RestClient;
import com.egakat.core.web.client.properties.RestProperties;
import com.egakat.integration.dto.ActualizacionDto;
import com.egakat.integration.dto.ErrorIntegracionDto;
import com.egakat.integration.enums.EstadoIntegracionType;
import com.egakat.integration.enums.EstadoNotificacionType;
import com.egakat.integration.service.impl.rest.RestPushServiceImpl;
import com.egakat.io.clientes.gws.components.GwsRestClient;
import com.egakat.io.clientes.gws.constants.IntegracionesConstants;
import com.egakat.io.clientes.gws.constants.RestConstants;
import com.egakat.io.clientes.gws.constants.SolicitudDespachoClienteEstadoConstants;
import com.egakat.io.clientes.gws.properties.SolicitudesDespachoRestProperties;
import com.egakat.io.clientes.gws.service.api.solicitudes.SolicitudesDespachoNotificacionReciboPushService;
import lombok.val;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class SolicitudesDespachoNotificacionReciboPushServiceImpl
extends RestPushServiceImpl<ActualizacionDto, Object, Object>
implements SolicitudesDespachoNotificacionReciboPushService {
@Autowired
private SolicitudesDespachoRestProperties properties;
@Autowired
private GwsRestClient restClient;
@Override
protected RestProperties getProperties() {
return properties;
}
@Override
protected RestClient getRestClient() {
return restClient;
}
@Override
protected String getApiEndPoint() {
return RestConstants.SOLICITUDES_DESPACHO;
}
@Override
protected String getIntegracion() {
return IntegracionesConstants.SOLICITUDES_DESPACHO;
}
@Override
protected String getOperacion() {
val result = String.format("PUSH NOTIFICACION RECIBO %s", getIntegracion());
return result;
}
@Override
protected List<ActualizacionDto> getPendientes() {
val estado = EstadoIntegracionType.ESTRUCTURA_VALIDA;
val subestado = "";
val result = getActualizacionesService()
.findAllByIntegracionAndEstadoIntegracionAndSubEstadoIntegracionIn(getIntegracion(), estado, subestado);
return result;
}
@Override
protected ActualizacionDto getInput(ActualizacionDto actualizacion, List<ErrorIntegracionDto> errores) {
return actualizacion;
}
@Override
protected Object asOutput(ActualizacionDto input, ActualizacionDto actualizacion,
List<ErrorIntegracionDto> errores) {
return "";
}
@Override
protected Object push(Object output, ActualizacionDto input, ActualizacionDto actualizacion,
List<ErrorIntegracionDto> errores) {
val url = getUrl();
val query = "/{id}?status={status}";
val id = actualizacion.getIdExterno();
val status = SolicitudDespachoClienteEstadoConstants.RECIBIDA_OPL;
getRestClient().put(url + query, output, Object.class, id, status);
return "";
}
@Override
protected void onSuccess(Object result, Object output, ActualizacionDto input, ActualizacionDto actualizacion) {
val estadoNotificacion = EstadoNotificacionType.NOTIFICADA;
val subestado = SolicitudDespachoClienteEstadoConstants.RECIBIDA_OPL;
actualizacion.setEstadoNotificacion(estadoNotificacion);
actualizacion.setSubEstadoIntegracion(subestado);
actualizacion.setReintentos(0);
}
@Override
protected void updateOnSuccess(Object result, Object output, ActualizacionDto input,
ActualizacionDto actualizacion) {
getActualizacionesService().update(actualizacion);
}
@Override
protected void onError(ActualizacionDto actualizacion, List<ErrorIntegracionDto> errores) {
val estadoNotificacion = EstadoNotificacionType.ERROR;
actualizacion.setEstadoNotificacion(estadoNotificacion);
}
@Override
protected void updateOnError(ActualizacionDto actualizacion, List<ErrorIntegracionDto> errores) {
try {
getActualizacionesService().updateErrorNotificacion(actualizacion, errores);
} catch (RuntimeException e) {
log.error("Exception:", e);
}
}
} | [
"esb.ega.kat@gmail.com"
] | esb.ega.kat@gmail.com |
0b992c76518c3ec3ff558b015833f90f02de9a58 | 99d36f2d48fdc3e0e5907bf6cd3690b1c8b8214c | /src/com/zhuangjieying/view/FunctionPanel.java | 9ca26b0bbfed87d2c081c738035d37733420f826 | [] | no_license | jayying007/Game_2048 | 21ff493f0a74480386f575a84e6406cc36247dd9 | 4ce69496518bbe4e351d8f092e91302d7a81eb01 | refs/heads/master | 2023-06-16T02:24:01.538035 | 2021-07-10T06:28:59 | 2021-07-10T06:28:59 | 384,627,979 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,617 | java | package com.zhuangjieying.view;
import com.zhuangjieying.model.UserData;
import javax.swing.*;
import java.awt.*;
public class FunctionPanel extends JPanel {
private final JLabel playerNameLabel;
public FunctionPanel() {
this.init();
this.initMenu();
this.playerNameLabel = new JLabel("(暂无玩家)");
this.playerNameLabel.setBounds(30, 10, 300, 30);
this.add(this.playerNameLabel);
}
private void init() {
this.setBounds(400, 0, 400, 570);
this.setBackground(new Color(200,200,200));
this.setLayout(null);
}
private void initMenu() {
JButton button = new JButton("读取存档");
button.setBounds(300, 10, 90, 30);
button.addActionListener(e -> new LoadPlayerView());
this.add(button);
button = new JButton("新游戏");
button.setBounds(130, 150, 150, 50);
button.addActionListener(e -> new NewPlayerView());
this.add(button);
button = new JButton("排行榜");
button.setBounds(130, 250, 150, 50);
button.addActionListener(e -> new RankingView());
this.add(button);
button = new JButton("帮助");
button.setBounds(130, 350, 150, 50);
button.addActionListener(e -> new GetHelpView());
this.add(button);
button = new JButton("退出");
button.setBounds(130, 450, 150, 50);
button.addActionListener(e -> System.exit(0));
this.add(button);
}
public void refresh() {
this.playerNameLabel.setText(UserData.getInstance().getUsername());
}
}
| [
"1172510964@qq.com"
] | 1172510964@qq.com |
6a5a9d58d1281f2e9512f837a56af2fa86d2e3b3 | 96b0379f4d42e33ebec0925e0b11ae7a1d87f74b | /src/base/code/Stringcalculator.java | 20649fa8bf1ea347f79bce5055a772f13331cc19 | [] | no_license | dsarok/testingAdd | a4670fd9b40e26cbee4cb4a32a5b9be8c6c357ef | 8cb8597ecb38e59e5e694bee6bb78336494ea0a8 | refs/heads/master | 2023-08-13T18:09:01.782607 | 2021-09-09T16:41:21 | 2021-09-09T16:41:21 | 404,506,497 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 936 | java | package base.code;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Stringcalculator extends Exception{
public static int count=0;
public int GetCalledCount() {
return Stringcalculator.count;
}
public static void increment() {
count++;
}
public int Add(String r) throws Exception {
increment();
String ss="";
String[] kh=(r.split("\\D{1}"));
String pattern="\\-\\d+";
Pattern re=Pattern.compile(pattern);
Matcher m=re.matcher(r);
while (m.find()) {
ss+=m.group()+ " ";
}
if(kh.length==0) {
System.out.print("no integer");
return 0;
}
int ir=0;
for(int i=0;i<kh.length;i++) {
if(kh[i].length()>0)
{int y=Integer.parseInt(kh[i]);
if(y<0) {
ss+=y+" ";
}
else if(y<1000) {
ir+=y;
}
}
}
if(ss.length()>0) {
throw new Exception("no negative numbers allowed "+ss);
}
return ir;
}
}
| [
"divyashankaranand@gmail.com"
] | divyashankaranand@gmail.com |
370751f80663fbbdeab45487e8a2270528d2d797 | 48062a51edd626f04d3cb516c7e305c742ce6c97 | /Practice/src/com/practice/thread/Second.java | b07258f8d0e32a7690c57174ea90631f029be073 | [] | no_license | maneesh1318/JavaDSAlgo | 685a4830758e4b45d02772699f4a30292089b9b6 | 1b0ef7fed1af0d46d52146eb22f2d88492019345 | refs/heads/master | 2021-07-15T07:22:13.896985 | 2021-07-04T13:45:11 | 2021-07-04T13:45:11 | 176,718,659 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 965 | java | package com.practice.thread;
/**
* Created by Manish Richhariya(manish.richhariya@99acres.com) on 20/4/18.
*/
public class Second implements Runnable {
public static Object lock = CommonUtil.mLock;
@Override
public void run() {
synchronized (lock) {
int i = 2;
while(i<100){
if(CommonUtil.turn == 1) {
try{
Thread.sleep(500);
}catch (InterruptedException ex){}
System.out.println(i);
i +=3;
CommonUtil.turn = 2;
lock.notifyAll();
try {
lock.wait();
}catch (InterruptedException ex){}
}
else{
try {
lock.wait();
}catch (InterruptedException ex){}
}
}
}
}
}
| [
"manish.richhariya@99acres.com"
] | manish.richhariya@99acres.com |
b5d9dc0459229db0b909cc33d04eaaa83276380b | d504cc2dc84e2519146b615fe6a3ab6847566f41 | /interview/src/main/java/com/saucedemo/interview/mypages/BasePage.java | 3035d30e4ddae65c306a67eaa17a5623f0d99b51 | [] | no_license | Anandktr/saucedemoTask | e18f145d11ca7a233aa2811afadf32fdd1d4ee2c | c31d6e8a01453525cee60b72ad0313a5b143208e | refs/heads/master | 2022-12-29T00:06:58.647253 | 2020-10-18T10:01:21 | 2020-10-18T10:01:21 | 304,559,775 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,266 | java | package com.saucedemo.interview.mypages;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
public class BasePage extends Page {
public BasePage(WebDriver driver) {
super(driver);
}
public static void getPage(String url) {
driver.get(url);
}
@Override
public String getPageTitle() {
return driver.getTitle();
}
@Override
public void sendkeys(By locator, String keysToSend) {
getElement(locator).sendKeys(keysToSend);
}
@Override
public WebElement getElement(By locator) {
WebElement element = null;
try {
waitForWebElement(locator);
element = driver.findElement(locator);
return element;
} catch (Exception e) {
System.out.println("Some error occured while creating element: " + locator.toString());
e.printStackTrace();
}
return null;
}
public List<WebElement> getElements(By locator) {
List<WebElement> elements = null;
try {
waitForWebElement(locator);
elements = driver.findElements(locator);
return elements;
} catch (Exception e) {
System.out.println("Some error occured while creating element: " + locator.toString());
e.printStackTrace();
}
return null;
}
public String getText(By locator) {
return getElement(locator).getText();
}
@Override
public void waitForWebElement(By locator) {
try {
wait.until(ExpectedConditions.presenceOfElementLocated(locator));
} catch (Exception e) {
System.out.println("Unable to find the element: " + locator.toString());
}
}
@Override
public void waitForclickableWebElement(By locator) {
try {
wait.until(ExpectedConditions.elementToBeClickable(locator));
} catch (Exception e) {
System.out.println("Unable to find the element: " + locator.toString());
}
}
public void listSelect(WebElement element, String listVal) {
Select dropdown = new Select(element);
dropdown.selectByVisibleText(listVal);
}
public void javascriptClick(WebElement element) {
js.executeScript("arguments[0].click();", element);
}
}
| [
"new@DESKTOP-C784JLS"
] | new@DESKTOP-C784JLS |
fe4d14c088cbd495b07e20559115efe31e37b1c9 | 43f673e154d9d2a8039d515158ce42020f3596b4 | /src/main/java/com/pilot/reservation/AbstractEvent.java | d27761afd3e6ae83ffa77d269df71d2d02c256e4 | [] | no_license | djkim81/reservation | da5dd636b6f4d35736fd26d6efe619083243ad2e | f93d7810d85b659f3987e34d307491aae529abf6 | refs/heads/master | 2022-11-21T13:22:45.568855 | 2020-07-14T10:49:04 | 2020-07-14T10:49:04 | 279,558,066 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,647 | java | package com.pilot.reservation;
import com.pilot.reservation.config.kafka.KafkaProcessor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.util.MimeTypeUtils;
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import java.text.SimpleDateFormat;
import java.util.Date;
public class AbstractEvent {
String eventType;
String timestamp;
public AbstractEvent(){
this.setEventType(this.getClass().getSimpleName());
SimpleDateFormat defaultSimpleDateFormat = new SimpleDateFormat("YYYYMMddHHmmss");
this.timestamp = defaultSimpleDateFormat.format(new Date());
}
public String toJson(){
ObjectMapper objectMapper = new ObjectMapper();
String json = null;
try {
json = objectMapper.writeValueAsString(this);
} catch (JsonProcessingException e) {
throw new RuntimeException("JSON format exception", e);
}
return json;
}
public void publish(String json){
if( json != null ){
/**
* spring streams 방식
*/
KafkaProcessor processor = ReservationApplication.applicationContext.getBean(KafkaProcessor.class);
MessageChannel outputChannel = processor.outboundTopic();
outputChannel.send(MessageBuilder
.withPayload(json)
.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON)
.build());
}
}
public void publish(){
this.publish(this.toJson());
}
public void publishAfterCommit(){
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCompletion(int status) {
AbstractEvent.this.publish();
}
});
}
public String getEventType() {
return eventType;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public boolean isMe(){
return getEventType().equals(getClass().getSimpleName());
}
}
| [
"2pac81@sk.com"
] | 2pac81@sk.com |
6164a530e5bdf4b9e7848ff0e39b35516cdf0abe | 46a41e638a71d35a8a7e9375c389433d0aa64bc5 | /src/com/plmt/boommall/ui/view/webview/jsbridge/CallBackFunction.java | e3724ac72bb41677904c5d61829844542a6fd546 | [] | no_license | xiguofeng/BoomMall | 8c3fa50257e6f0a4d41504a673f0dbcbaff362b9 | 8aa14d3a1d2fd6c906c96226086f4bee4b551705 | refs/heads/master | 2021-01-18T15:22:24.165639 | 2016-01-14T07:43:38 | 2016-01-14T07:43:38 | 42,432,677 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 132 | java | package com.plmt.boommall.ui.view.webview.jsbridge;
public interface CallBackFunction {
public void onCallBack(String data);
}
| [
"king.xgf@gmail.com"
] | king.xgf@gmail.com |
520e159c79d158e52a6b13ee6148fa2ef8f46582 | 349c3262800d326337436a68abd929bd3282550f | /src/main/java/org/mada/es/mibolsa/facade/IPortfolioFacade.java | 0fc391bd0e5f385a0a3faae5731484eb4317c05f | [] | no_license | gorilux/mi-cartera-core | bb679e85f75759b5f8ea438e0ba205b783c1c345 | 476472b6a4cdffddb0f7dadf180bcdb9895e5393 | refs/heads/master | 2021-01-09T20:54:50.408240 | 2015-09-14T18:11:34 | 2015-09-14T18:11:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 780 | java | package org.mada.es.mibolsa.facade;
import java.util.List;
import org.mada.es.mibolsa.entity.Detail;
import org.mada.es.mibolsa.entity.Portfolio;
/**
* Interfaz de la fachada de cartera
*
* @author Pumuki
*
*/
public interface IPortfolioFacade {
/**
* devuelve todas las carteras existentes
*
* @return lista de carteras
*/
List<Portfolio> findAllPortfolio();
/**
* Recuperar todas las carteras de un usuario
*
* @param idUser
* id del usuario
* @return lista de carteras
*/
List<Portfolio> findAllPortfolioByUser(int idUser);
/**
* Devuelve el detalle de una cartera de valores
*
* @param idPortfolio
* id de la cartera
* @return lista de detalle
*/
List<Detail> findDetailPortfolio(int idPortfolio);
}
| [
"mdrodrey@gmail.com"
] | mdrodrey@gmail.com |
5918987df8089c9156e13ca4e11eaea380fcbe1c | 7aff958d5c6480bab135878b360e1fc500ab1603 | /src/main/java/com/internship/tailormanager/controller/InventoryController.java | 828caaa7e4795bb97eb0a09df9b6202912464815 | [] | no_license | Drt36/tailor-manager | cec305069a01e8c9969b596ada380322d3065b1c | 80952499025a7075c27554b89459908a3ea3857c | refs/heads/master | 2023-08-24T17:07:57.398123 | 2021-10-24T09:04:01 | 2021-10-24T09:04:01 | 417,995,180 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,869 | java | package com.internship.tailormanager.controller;
import com.internship.tailormanager.dto.InventoryDto;
import com.internship.tailormanager.service.InventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.transaction.Transactional;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
@RestController
@CrossOrigin(origins = "http://localhost:3000")
public class InventoryController {
@Autowired
private InventoryService inventoryService;
@PostMapping( "/api/user/inventory")
public ResponseEntity<InventoryDto> saveInventory(@Valid @RequestBody InventoryDto inventoryDto) {
InventoryDto savedInventoryDto = inventoryService.saveInventory(inventoryDto);
return new ResponseEntity<InventoryDto>(savedInventoryDto, HttpStatus.OK);
}
@GetMapping("/api/user/inventory/{id}")
public InventoryDto getInventory(@NotNull @PathVariable("id") Long id) {
return inventoryService.getInventoryById(id);
}
@GetMapping("/api/user/inventory")
public Page<InventoryDto> getAllInventory(@RequestParam("page") int page) {
Page<InventoryDto> inventoryDtos = inventoryService.getAllActiveInventory(page);
return inventoryDtos;
}
@Transactional
@PutMapping("/api/user/inventory/{id}")
public ResponseEntity<InventoryDto> updateInventory(@NotNull @PathVariable("id") Long id, @RequestBody InventoryDto inventoryDto) {
InventoryDto savedInventoryDto = inventoryService.updateInventory(id, inventoryDto);
return new ResponseEntity<InventoryDto>(savedInventoryDto, HttpStatus.OK);
}
} | [
"dharmarajthanait25@gmail.com"
] | dharmarajthanait25@gmail.com |
6880f9deece7b3f4403a7d542cd6956cfbd03d5f | 18cd98e9f6229ff5ac06d0f4ab75a8157a085239 | /src/main/java/ru/ulfr/poc/modules/bank/BankDao.java | cb9272319de8262e141191e604f5c9676fd56baf | [] | no_license | svulfr/poc-inetbank | 96f7ea23b17114c58ee331495d9f0d2c3f6395c8 | 7200aab7c165ce201c60ec5a4753bf875bb82a4e | refs/heads/master | 2021-01-10T03:09:30.058861 | 2015-11-24T14:47:29 | 2015-11-24T14:47:29 | 46,795,484 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 266 | java | package ru.ulfr.poc.modules.bank;
import ru.ulfr.poc.modules.bank.model.Currency;
import java.util.List;
/**
* Interface for Bank Data Access Object bean
*/
public interface BankDao {
Currency getCurrency(int code);
List<Currency> listCurrencies();
}
| [
"svulfr@gmail.com"
] | svulfr@gmail.com |
a64bc58782e2e20ab53f92182d0f8d9b2dad9327 | 9690ae68809b8952f0792ff3a350a398fcf4c816 | /dependencies/QueueInterface.java | d7f15c52a8312b03e8353e8b151d9c0ca35aee33 | [] | no_license | nicokaegi/DSA-project | 154b9c683b7648febd836f1f157a2f3eafc28be4 | 7feb61fe56bee6ab2074e7bb668f684c4343eb44 | refs/heads/master | 2022-04-11T23:48:48.702508 | 2019-12-06T01:35:04 | 2019-12-06T01:35:04 | 220,060,483 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,452 | java | package dependencies;
public interface QueueInterface<T> {
public boolean isEmpty();
// Determines whether a queue is empty.
// Precondition: None.
// Postcondition: Returns true if the queue is empty;
// otherwise returns false.
public void enqueue(T newItem) throws QueueException;
// Adds an item at the back of a queue.
// Precondition: newItem is the item to be inserted.
// Postcondition: If the operation was successful, newItem
// is at the back of the queue. Some implementations
// may throw QueueException if newItem cannot be added
// to the queue.
public T dequeue() throws QueueException;
// Retrieves and removes the front of a queue.
// Precondition: None.
// Postcondition: If the queue is not empty, the item that
// was added to the queue earliest is removed. If the queue is
// empty, the operation is impossible and QueueException is thrown.
public void dequeueAll();
// Removes all items of a queue.
// Precondition: None.
// Postcondition: The queue is empty.
public T peek() throws QueueException;
// Retrieves the item at the front of a queue.
// Precondition: None.
// Postcondition: If the queue is not empty, the item
// that was added to the queue earliest is returned.
// If the queue is empty, the operation is impossible
// and QueueException is thrown.
public String toString();
} // end QueueInterface
| [
"reesecup1108@gmail.com"
] | reesecup1108@gmail.com |
046c005100b94788bf5fa162b64a9ecc53020bc9 | c5c616ec3c051cce1f9f80a5e4ae52fdfb04fda8 | /src/main/java/com/magmaphonebook/validators/CPFValidator.java | 87c94dea478bc60215c8f73f928a40345b077df8 | [] | no_license | dirceurjunior/MagmaPhoneBook | 2bf86b3bdd3cdf60e428e9862862b2b6a6553e7a | 739858fd184e068ada3f80d84b7ff9d381a4c074 | refs/heads/master | 2020-04-15T18:09:15.524842 | 2015-06-01T20:50:40 | 2015-06-01T20:50:40 | 31,263,304 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,557 | java | package com.magmaphonebook.validators;
import com.magmaphonebook.model.users.Users;
import com.magmaphonebook.model.users.UsersRN;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
/**
* Validação de CPF.
*
*/
@FacesValidator(value = "cpfValidator")
public class CPFValidator implements Validator {
@Override
public void validate(FacesContext arg0, UIComponent arg1, Object value) throws ValidatorException {
if (!String.valueOf(value).equals("")) {
if (!validaCPF(String.valueOf(value))) {
FacesMessage message = new FacesMessage();
message.setSeverity(FacesMessage.SEVERITY_ERROR);
message.setSummary("CPF Inválido");
throw new ValidatorException(message);
}
// else {
// FacesMessage msg = new FacesMessage("CPF TA CERTINHO!!!!");
// FacesContext.getCurrentInstance().addMessage(null, msg);
// }
}
}
/**
* Valida CPF do usuário. Não aceita CPF's padrões como 11111111111 ou
* 22222222222
*
* @param cpf String valor com 11 dígitos
*/
private static boolean validaCPF(String cpf) {
if (cpf == null || cpf.length() != 11 || isCPFPadrao(cpf)) {
return false;
}
try {
Long.parseLong(cpf);
} catch (NumberFormatException e) { // CPF não possui somente números
return false;
}
if (!calcDigVerif(cpf.substring(0, 9)).equals(cpf.substring(9, 11))) {
return false;
}
return true;
}
/**
*
* @param cpf String valor a ser testado
* @return boolean indicando se o usuário entrou com um CPF padrão
*/
private static boolean isCPFPadrao(String cpf) {
if (cpf.equals("11111111111") || cpf.equals("22222222222")
|| cpf.equals("33333333333")
|| cpf.equals("44444444444")
|| cpf.equals("55555555555")
|| cpf.equals("66666666666")
|| cpf.equals("77777777777")
|| cpf.equals("88888888888")
|| cpf.equals("99999999999")) {
return true;
}
return false;
}
private static String calcDigVerif(String num) {
Integer primDig, segDig;
int soma = 0, peso = 10;
for (int i = 0; i < num.length(); i++) {
soma += Integer.parseInt(num.substring(i, i + 1)) * peso--;
}
if (soma % 11 == 0 | soma % 11 == 1) {
primDig = new Integer(0);
} else {
primDig = new Integer(11 - (soma % 11));
}
soma = 0;
peso = 11;
for (int i = 0; i < num.length(); i++) {
soma += Integer.parseInt(num.substring(i, i + 1)) * peso--;
}
soma += primDig.intValue() * 2;
if (soma % 11 == 0 | soma % 11 == 1) {
segDig = new Integer(0);
} else {
segDig = new Integer(11 - (soma % 11));
}
return primDig.toString() + segDig.toString();
}
public Users CPFExistente(String cpf) {
UsersRN usuario = new UsersRN();
return usuario.findByCPF(cpf);
}
}
| [
"Dirceu R Junior@drjunior"
] | Dirceu R Junior@drjunior |
718a0ac73f7e42c42ef5f92aae378d0d3a1f763f | 4cb903017b23c68ecd965fa828f03a679b188bcc | /src/main/java/com/jieming/miaosha/MiaoshaApplication.java | 2c5149cc20f50db3d6d934363f5a45577c5bc442 | [] | no_license | JiemingLi/myProjects | 859411be5f816405f47a3fc648119a61c7cd8834 | 3a6edcee38c0cb8067b99cd9306937979631a802 | refs/heads/master | 2022-07-22T10:21:46.243350 | 2019-08-08T07:20:29 | 2019-08-08T07:20:29 | 201,201,607 | 0 | 0 | null | 2022-06-17T02:21:05 | 2019-08-08T07:19:19 | Java | UTF-8 | Java | false | false | 434 | java | package com.jieming.miaosha;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement
@SpringBootApplication
public class MiaoshaApplication {
public static void main(String[] args) {
SpringApplication.run(MiaoshaApplication.class, args);
}
}
| [
"1207734468@qq.com"
] | 1207734468@qq.com |
a3dab397a3a643543e881767050f7fe27e0acea6 | b5686a7fe4e813345c932fdbf6d6613d617c3920 | /src/main/java/app/InvalidArgumentException.java | 92b9702b7008181b40378dc4e911ede45bb3e790 | [] | no_license | johnnicholson/309 | f04be3833bb22de4474b66915047180b19efd08f | a005fb24a2f71fca5ae5904171528b139cac49c6 | refs/heads/master | 2021-01-12T01:59:16.765205 | 2017-03-10T09:19:06 | 2017-03-10T09:19:06 | 78,455,134 | 1 | 0 | null | 2017-02-13T01:22:57 | 2017-01-09T18:09:48 | Java | UTF-8 | Java | false | false | 132 | java | package app;
public class InvalidArgumentException extends Exception {
private static final long serialVersionUID = 1L;
}
| [
"johnathan.nicholson3@gmail.com"
] | johnathan.nicholson3@gmail.com |
dcc60c2d28363bde4d29c010ce0b6878893423ad | a3e6aa577fd27babc3f58a093db222ae33d1261c | /app/src/androidTest/java/com/alobot/dummymockandroiddependencies/ExampleInstrumentedTest.java | ad7106672d11553f5bcb4b0ce96f2cab4a169a82 | [] | no_license | alessandrycruz/DummyMockAndroidDependencies | c0aea67e6c7f0d1e215d81900e8f6de33376da0e | 184087c5c572c841ba361560f8945130ac342cc9 | refs/heads/master | 2021-01-20T14:10:19.646397 | 2017-05-07T23:42:27 | 2017-05-07T23:42:27 | 90,568,808 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 782 | java | package com.alobot.dummymockandroiddependencies;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.alobot.dummymockandroiddependencies", appContext.getPackageName());
}
}
| [
"alessandrycruz@outlook.com"
] | alessandrycruz@outlook.com |
66b030c9ed4825974b670022574c4659a3bd0a73 | 125f35e9c465bc2b76349465d0f1777bce7a3eed | /src/main/java/com/jyan/mapper/UserMapper.java | 66b95bd519e1ecb470ce5789f268151cd4819931 | [] | no_license | MCAmoxicillin/JYan_blog | e5cfbdedfeb217c2c6fc7e91dab3376c3b8249db | 3dc92e5b818c23737c4be7c0dbac39f9d5bda69d | refs/heads/master | 2023-01-11T23:03:05.079549 | 2020-11-11T01:45:18 | 2020-11-11T01:45:18 | 307,005,153 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 315 | java | package com.jyan.mapper;
import com.jyan.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author 江延
* @since 2020-10-30
*/
@Repository
public interface UserMapper extends BaseMapper<User> {
}
| [
"1748871764@qq.com"
] | 1748871764@qq.com |
2cad9e677cbd1bd80784294fc73865a6e7e8b82b | 9f30fbae8035c2fc1cb681855db1bc32964ffbd4 | /Java/wangyongzhi/Task1/src/main/java/cc/myhome/mybatis/mapper/Network1Mapper.java | 7ec0db728edb8307b9ec181e47e892183cae3d1c | [] | no_license | IT-xzy/Task | f2d309cbea962bec628df7be967ac335fd358b15 | 4f72d55b8c9247064b7c15db172fd68415492c48 | refs/heads/master | 2022-12-23T04:53:59.410971 | 2019-06-20T21:14:15 | 2019-06-20T21:14:15 | 126,955,174 | 18 | 395 | null | 2022-12-16T12:17:21 | 2018-03-27T08:34:32 | null | UTF-8 | Java | false | false | 670 | java | package cc.myhome.mybatis.mapper;
import cc.myhome.model.Network1;
import cc.myhome.model.*;
import org.springframework.stereotype.Component;
import java.util.List;
public interface Network1Mapper {
//INSERT插入数据
int insert(Network1 network1);
//UPDATE方法:优先根据学生学号更新,其次根据姓名更新数据方法
int update(Network1 network1);
//SELECT查询全部数据方法
List<Network1> selectAll();
//SELECT根据姓名或者学号查询单条数据方法
Network1 selectByIdName(Network1 network1);
//根据学生学号删除记录方法
int deleteById(Long id);
}
| [
"noreply@github.com"
] | IT-xzy.noreply@github.com |
5d59064da98c87928bec9f1d96a81e66003bdfb3 | aa71f0584589383899ad27b6d5da031dffd27475 | /petrichor/core/src/main/java/com/jalinyiel/petrichor/core/PetrichorDb.java | 736b8d9aa7c4a4e7d041339bb826f264c3482d5d | [] | no_license | JIANGLY33/petrichor | b96cc75bdf26bc60b6ee974e1ae2fe6f1a605598 | e5514a48a5e46481e1661142aaf59ece610f038c | refs/heads/main | 2023-04-19T20:56:16.271792 | 2021-05-09T12:59:09 | 2021-05-09T12:59:09 | 328,933,569 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,331 | java | package com.jalinyiel.petrichor.core;
import com.jalinyiel.petrichor.core.collect.PetrichorEntry;
import com.jalinyiel.petrichor.core.collect.PetrichorString;
import com.jalinyiel.petrichor.core.task.TaskType;
import org.apache.lucene.util.RamUsageEstimator;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
public class PetrichorDb {
private int id;
private PetrichorDict keyValues;
//存在过期时间的键
private ExpireDict expireKeys;
private AtomicLong taskCount;
private List<PetrichorObject> hotSpotData;
//已经过期的键
private List<Map.Entry<PetrichorObject, PetrichorExpireInfo>> expireData;
private Map<TaskType, TreeMap<String, Long>> dataTypeTaskCount;
private Map<PetrichorObject, Duration> slowQueryStatistic;
public final int HOT_SPOT_DATA_CAPACITY = 10;
public final int EXPIRE_KEY_CAPACITY = 10;
public final int TASK_COUNTS_CAPACITY = 10;
public final int SLOW_QUERY_CAPACITY = 8;
public final long SLOW_QUERY_LIMIT = 1000;
public PetrichorDb(int id, PetrichorDict keyValues, ExpireDict expireKeys) {
this.id = id;
this.keyValues = keyValues;
this.expireKeys = expireKeys;
this.taskCount = new AtomicLong(0);
this.hotSpotData = new ArrayList<>(HOT_SPOT_DATA_CAPACITY);
this.expireData = new ArrayList<>(EXPIRE_KEY_CAPACITY);
this.dataTypeTaskCount = new HashMap<>();
this.slowQueryStatistic = new HashMap<>(SLOW_QUERY_CAPACITY);
dataTypeTaskCount.put(TaskType.LIST_TASK, new TreeMap<>(this::compare));
dataTypeTaskCount.put(TaskType.STRING_TASK, new TreeMap<>(this::compare));
dataTypeTaskCount.put(TaskType.MAP_TASK, new TreeMap<>(this::compare));
dataTypeTaskCount.put(TaskType.SET_TASK, new TreeMap<>(this::compare));
dataTypeTaskCount.put(TaskType.GLOBAL_TASK, new TreeMap<>(this::compare));
}
public int getId() {
return id;
}
public PetrichorDict getKeyValues() {
return keyValues;
}
public ExpireDict getExpireKeys() {
return expireKeys;
}
public AtomicLong getTaskCount() {
return taskCount;
}
public long taskCountIncre() {
return taskCount.incrementAndGet();
}
public long dataTypeCountIncre(TaskType taskType) {
TreeMap<String, Long> value = dataTypeTaskCount.entrySet().stream()
.filter(taskTypeListEntry -> taskTypeListEntry.getKey().equals(taskType))
.map(Map.Entry::getValue)
.findAny().get();
String key = LocalTime.now().format(DateTimeFormatter.ofPattern("hh:mm"));
Long count = value.get(key);
value.put(key, null == count ? 1 : count + 1);
if (value.size() > TASK_COUNTS_CAPACITY) value.pollFirstEntry();
// value.entrySet().stream()
// .forEach(integerLongEntry
// -> System.out.println(String.format("key is %s, value is %d", integerLongEntry.getKey(), integerLongEntry.getValue())));
return value.get(key);
}
public List<PetrichorObject> getHotSpotData() {
List<PetrichorObject> petrichorObjects = this.hotSpotData;
return petrichorObjects;
}
public List<Map.Entry<PetrichorObject,PetrichorExpireInfo>> getExpireData() {
return expireData;
}
public Map<TaskType, TreeMap<String, Long>> getDataTypeTaskCount() {
return dataTypeTaskCount;
}
private int compare(String t1, String t2) {
LocalTime localTime1 = LocalTime.parse(t1);
LocalTime localTime2 = LocalTime.parse(t2);
return localTime1.compareTo(localTime2);
}
public void setHotSpotData(List<PetrichorObject> hotSpotData) {
this.hotSpotData = hotSpotData;
}
public void setExpireData(List<Map.Entry<PetrichorObject, PetrichorExpireInfo>> expireData) {
this.expireData = expireData;
}
public Map<PetrichorObject, Duration> getSlowQueryStatistic() {
return slowQueryStatistic;
}
public void setSlowQueryStatistic(Map<PetrichorObject, Duration> slowQueryStatistic) {
this.slowQueryStatistic = slowQueryStatistic;
}
/**
* 唯一对外暴露存储容器的场景
*
* @return
*/
public List<Map.Entry<PetrichorObject,PetrichorExpireInfo>> removeExpire() {
Map<PetrichorObject, PetrichorObject> keyValues = getKeyValues().getDict();
Map<PetrichorObject,Long> expireDict = this.getExpireKeys().getDict();
Iterator<Map.Entry<PetrichorObject,Long>> iterator = expireDict.entrySet().iterator();
// Iterator<Map.Entry<PetrichorObject,PetrichorObject>> iterator = keyValues.entrySet().iterator();
List<Map.Entry<PetrichorObject,PetrichorExpireInfo>> res = new LinkedList<>();
Map<ObjectType,Long> dictSize = getKeyValues().getSizeDict();
while(iterator.hasNext()) {
Map.Entry<PetrichorObject,Long> entry = iterator.next();
PetrichorObject key = entry.getKey();
Long expireTime = entry.getValue();
if (expireTime <= Instant.now().getEpochSecond()) {
PetrichorObject value = keyValues.get(key);
long size = RamUsageEstimator.sizeOf(value);
res.add(new PetrichorEntry<>(key,new PetrichorExpireInfo(keyValues.get(key),expireTime)));
dictSize.put(value.getType(), dictSize.get(value.getType())-size);
iterator.remove();
keyValues.remove(key);
}
}
return res;
}
public static void main(String[] args) {
PetrichorObject p = PetrichorObjectFactory.of(ObjectType.PETRICHOR_STRING,ObjectEncoding.RAW_STRING, new PetrichorString("a"));
HashMap<PetrichorObject,Long> h = new HashMap<>();
h.put(p,12L);
PetrichorObject q = PetrichorObjectFactory.of(ObjectType.PETRICHOR_STRING,ObjectEncoding.RAW_STRING, new PetrichorString("a"));
Long l = h.get(q);
System.out.println(q.equals(p));
}
public Long getTaskMemory(ObjectType objectType) {
return this.getKeyValues().getTypeSize(objectType);
}
}
| [
"lingye.jly@alibaba-inc.com"
] | lingye.jly@alibaba-inc.com |
c2ddec5e8d9fbd5a302cce0805ea7d86f60555fd | 359475f9852b098636eb5e93bda84b3b8311ab2c | /app/src/main/java/com/example/tongxin/utils/ToastFactory.java | 61b3adb6a1b138c6e0f435784b245b906b7ba562 | [
"Apache-2.0"
] | permissive | djsdbbsfjz/TongXin | 74c1f0c371c95f084fbe6ec69701c06ad2390e38 | 04a448ebffc80829fa9a74c8cd10b05b71af7a09 | refs/heads/master | 2020-12-02T22:18:55.690063 | 2017-07-03T13:40:58 | 2017-07-03T13:40:58 | 96,107,075 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 652 | java | package com.example.tongxin.utils;
import android.content.Context;
import android.widget.Toast;
/**
* 保持全局只有一个Toast实例
* Created by djs on 2017/5/2.
*/
public class ToastFactory {
private static Context context = null;
private static Toast toast = null;
public static void show(Context context, String text) {
if (ToastFactory.context == context) {
toast.setText(text);
toast.setDuration(Toast.LENGTH_SHORT);
} else {
ToastFactory.context = context;
toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
}
toast.show();
}
}
| [
"1210090743@qq.com"
] | 1210090743@qq.com |
e50d311c736b07bece70230869e98f21c3502f48 | b1bf92e2ec898199e9e29770f056e25cc005c54f | /project/unisave2006/device/CommDeviceSettingFactory.java | 09cd3fee35200d0775f109f6de4897f1349ad2ab | [] | no_license | Temster/Bakalarka | 0bf355e40c7387b583cd9af4ac721b05b239a140 | 75d3ede9516d5e8f96f4cd6802549b7f9730b48e | refs/heads/master | 2021-01-13T02:02:09.961212 | 2013-05-31T12:10:45 | 2013-05-31T12:10:45 | null | 0 | 0 | null | null | null | null | WINDOWS-1250 | Java | false | false | 878 | java | /*
* Created on 11.8.2006
*
* Copyright (C) 2006
* David Ježek
* david.jezek@vsb.cz.
* All rights reserved.
*/
package unisave2006.device;
public class CommDeviceSettingFactory {
public static final int SERIAL_COM_DEVICE = 1;
public static final int IRDA_SERIAL_COM_DEVICE = 2;
public static final int NULL_COMM_DEVICE = 3;
public static CommDeviceSetting createCommDeviceSetting(int id){
CommDeviceSetting dev = null;
switch(id){
case SERIAL_COM_DEVICE:
dev = new SerialCommDeviceSetting();
break;
case IRDA_SERIAL_COM_DEVICE:
dev = new IrdaSerialCommDeviceSetting();
break;
case NULL_COMM_DEVICE:
dev = new NullCommDevice();
break;
}
if(dev != null)
dev.setComDeviceType(id);
return dev;
}
}
| [
"vlacil.michal@seznam.cz"
] | vlacil.michal@seznam.cz |
6d710b70b70a8df9cbb7ca7e6b39bf46f5e30d29 | bfb900a1840ae60169d2d5873731e92f7a5af150 | /Banco de Dados 2/atividade/src/main/java/br/cesed/si/bd/atividade/domain/Tecnologia.java | 4a8467ccf611884a5506459e3a12f96334ba2bb9 | [] | no_license | viniciusrsfilho/Facisa-BD | b7c310024c396254edac82ba1c26384ded10455a | 80539177bee7c8cfda440c0d10eaaf2f6cf804b8 | refs/heads/master | 2020-03-08T17:03:15.922513 | 2018-06-08T17:43:41 | 2018-06-08T17:43:41 | 128,258,464 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 494 | java | package br.cesed.si.bd.atividade.domain;
public class Tecnologia {
private String nome;
private String tipo;
private String link;
private String descricao;
public Tecnologia(String nome, String tipo, String link, String descricao) {
this.nome = nome;
this.tipo = tipo;
this.link = link;
this.descricao = descricao;
}
@Override
public String toString() {
return "Tecnologia [nome=" + nome + ", tipo=" + tipo + ", link=" + link + ", descricao=" + descricao + "]";
}
}
| [
"viniciusfilho98@gmail.com"
] | viniciusfilho98@gmail.com |
12df85816049a4faa73007bced4f5559ebaf13ff | e3e348f7732cf0a45b73628a51c54d7777690d0a | /src/main/java/shift/sextiarysector/tileentity/TileEntityShopMonitor.java | 56e55770bb9e006caafc153303b9e20b9dd03836 | [] | no_license | shift02/SextiarySector2 | cf89a03527cebd8a605c787e6d547f4ede5a8bde | 79a78d3008f573a52de87bcf9f828c121b8038ce | refs/heads/master | 2021-12-12T21:18:21.553111 | 2017-09-05T14:47:11 | 2017-09-05T14:47:11 | 25,522,254 | 10 | 16 | null | 2016-06-04T00:56:52 | 2014-10-21T12:56:47 | Java | UTF-8 | Java | false | false | 3,643 | java | package shift.sextiarysector.tileentity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import shift.sextiarysector.api.gearforce.tileentity.EnergyStorage;
import shift.sextiarysector.api.gearforce.tileentity.IGearForceGrid;
import shift.sextiarysector.api.gearforce.tileentity.IGearForceHandler;
import shift.sextiarysector.container.ItemBox;
public class TileEntityShopMonitor extends TileEntityDirection implements IGearForceHandler, IGearForceGrid {
public EnergyStorage storage = new EnergyStorage("Base", 1, 10000);
protected ItemBox items = new ItemBox("memory", 1);
public boolean on;
@Override
public void updateEntity() {
if (this.storage.getSpeedStored() > 0 && on) {
this.storage.drawEnergy(1, 20, false);
if (this.storage.getSpeedStored() == 0) {
this.changeON();
}
}
}
public void changeON() {
if (!this.worldObj.isRemote) {
if (!this.on && this.storage.getSpeedStored() > 0) {
this.on = true;
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 4);
} else {
this.on = false;
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 4);
}
this.worldObj.playSoundEffect(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, "random.click", 0.3F, 0.6F);
}
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
public ItemStack getMemory() {
return this.items.getStackInSlot(0);
}
public void setMemory(ItemStack item) {
if (item != null) item.stackSize = 1;
this.items.setInventorySlotContents(0, item);
}
//NBT関係
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
storage.readFromNBT(nbt);
this.on = nbt.getBoolean("on");
items.readFromNBT(nbt);
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
storage.writeToNBT(nbt);
nbt.setBoolean("on", on);
items.writeToNBT(nbt);
}
@Override
public int addEnergy(ForgeDirection from, int power, int speed, boolean simulate) {
if (!this.canInterface(from)) return 0;
int i = this.storage.addEnergy(power, speed, simulate);
return i;
}
@Override
public int drawEnergy(ForgeDirection from, int power, int speed, boolean simulate) {
if (!this.canInterface(from)) return 0;
return 0;
}
@Override
public boolean canInterface(ForgeDirection from) {
return ForgeDirection.DOWN.equals(from);
}
@Override
public int getPowerStored(ForgeDirection from) {
if (!this.canInterface(from)) return 0;
return 0;
}
@Override
public int getSpeedStored(ForgeDirection from) {
if (!this.canInterface(from)) return 0;
return 0;
}
@Override
public int getMaxPowerStored(ForgeDirection from) {
if (!this.canInterface(from)) return 0;
return this.storage.getMaxPower();
}
@Override
public int getMaxSpeedStored(ForgeDirection from) {
if (!this.canInterface(from)) return 0;
return this.storage.getMaxSpeed();
}
@Override
public boolean canIn(ForgeDirection from) {
return from.ordinal() == ForgeDirection.DOWN.ordinal();
}
@Override
public boolean canOut(ForgeDirection from) {
return false;
}
} | [
"shift02ss@gmail.com"
] | shift02ss@gmail.com |
aecf55dd2d6330200845e7fab33ca511c49e24bd | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/2/2_2252ee325dc2083b5fdd0449ec59d4e423b33b9e/XMLRPCCallingConvention/2_2252ee325dc2083b5fdd0449ec59d4e423b33b9e_XMLRPCCallingConvention_t.java | edb8c6e9e6bf41e74cf02ab4a38654b9952567c4 | [] | 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 | 28,186 | java | /*
* $Id$
*
* Copyright 2003-2005 Wanadoo Nederland B.V.
* See the COPYRIGHT file for redistribution and use restrictions.
*/
package org.xins.server;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.xins.common.MandatoryArgumentChecker;
import org.xins.common.collections.ProtectedPropertyReader;
import org.xins.common.io.FastStringWriter;
import org.xins.common.spec.DataSectionElementSpec;
import org.xins.common.spec.EntityNotFoundException;
import org.xins.common.spec.FunctionSpec;
import org.xins.common.spec.InvalidSpecificationException;
import org.xins.common.text.TextUtils;
import org.xins.common.types.Type;
import org.xins.common.xml.Element;
import org.xins.common.xml.ElementBuilder;
import org.znerd.xmlenc.XMLOutputter;
/**
* The XML-RPC calling convention.
*
* @version $Revision$ $Date$
* @author Anthony Goubard (<a href="mailto:anthony.goubard@nl.wanadoo.com">anthony.goubard@nl.wanadoo.com</a>)
*/
final class XMLRPCCallingConvention extends CallingConvention {
//-------------------------------------------------------------------------
// Class functions
//-------------------------------------------------------------------------
/**
* Returns the XML-RPC equivalent for the XINS type.
*
* @param parameterType
* the XINS type, cannot be <code>null</code>.
*
* @return
* the XML-RPC type, never <code>null</code>.
*/
private static String convertType(Type parameterType) {
if (parameterType instanceof org.xins.common.types.standard.Boolean) {
return "boolean";
} else if (parameterType instanceof org.xins.common.types.standard.Int8
|| parameterType instanceof org.xins.common.types.standard.Int16
|| parameterType instanceof org.xins.common.types.standard.Int32) {
return "int";
} else if (parameterType instanceof org.xins.common.types.standard.Float32
|| parameterType instanceof org.xins.common.types.standard.Float64) {
return "double";
} else if (parameterType instanceof org.xins.common.types.standard.Date
|| parameterType instanceof org.xins.common.types.standard.Timestamp) {
return "dateTime.iso8601";
} else if (parameterType instanceof org.xins.common.types.standard.Base64) {
return "base64";
} else {
return "string";
}
}
/**
* Attribute a number for the error code.
*
* @param errorCode
* the error code, cannot be <code>null</code>.
*
* @return
* the error code number, always > 0;
*/
private static int getErrorCodeNumber(String errorCode) {
if (errorCode.equals("_DisabledFunction")) {
return 1;
} else if (errorCode.equals("_InternalError")) {
return 2;
} else if (errorCode.equals("_InvalidRequest")) {
return 3;
} else if (errorCode.equals("_InvalidResponse")) {
return 4;
} else {
// Defined error code returned. For more information, see the
// faultString element.
return 99;
}
}
//-------------------------------------------------------------------------
// Class fields
//-------------------------------------------------------------------------
/**
* Secret key used when accessing <code>ProtectedPropertyReader</code>
* objects.
*/
private static final Object SECRET_KEY = new Object();
/**
* The formatter for XINS Date type.
*/
private static final DateFormat XINS_DATE_FORMATTER = new SimpleDateFormat("yyyyMMdd");
/**
* The formatter for XINS Timestamp type.
*/
private static final DateFormat XINS_TIMESTAMP_FORMATTER = new SimpleDateFormat("yyyyMMddHHmmss");
/**
* The formatter for XML-RPC dateTime.iso8601 type.
*/
private static final DateFormat XML_RPC_TIMESTAMP_FORMATTER = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
/**
* The key used to store the name of the function in the request attributes.
*/
private static final String FUNCTION_NAME = "_function";
/**
* The response encoding format.
*/
private static final String RESPONSE_ENCODING = "UTF-8";
/**
* The content type of the HTTP response.
*/
private static final String RESPONSE_CONTENT_TYPE = "text/xml;charset=" + RESPONSE_ENCODING;
//-------------------------------------------------------------------------
// Constructor
//-------------------------------------------------------------------------
/**
* Creates a new <code>XMLRPCCallingConvention</code> instance.
*
* @param api
* the API, needed for the XML-RPC messages, cannot be
* <code>null</code>.
*
* @throws IllegalArgumentException
* if <code>api == null</code>.
*/
public XMLRPCCallingConvention(API api)
throws IllegalArgumentException {
// This calling convention is not deprecated, so pass 'false' up
super(false);
// Check arguments
MandatoryArgumentChecker.check("api", api);
// Store the API reference (can be null!)
_api = api;
}
//-------------------------------------------------------------------------
// Fields
//-------------------------------------------------------------------------
/**
* The API. Never <code>null</code>.
*/
private final API _api;
//-------------------------------------------------------------------------
// Methods
//-------------------------------------------------------------------------
/**
* Checks if the specified request can be handled by this calling
* convention.
*
* <p>The return value is as follows:
*
* <ul>
* <li>a positive value indicates that the request <em>can</em>
* be handled;
* <li>the value <code>0</code> indicates that the request
* <em>cannot</em> be handled;
* <li>a negative number indicates that it is <em>unknown</em>
* whether the request can be handled by this calling convention.
* </ul>
*
* <p>This method will not throw any exception.
*
* @param httpRequest
* the HTTP request to investigate, cannot be <code>null</code>.
*
* @return
* a positive value if the request can be handled; <code>0</code> if the
* request cannot be handled or a negative value if it is unknown.
*/
int matchesRequest(HttpServletRequest httpRequest) {
// There is no match, unless XML can be parsed in the request and the
// name of the function to invoke can be determined
int match = NOT_MATCHING;
try {
// Parse the XML in the request (if any)
Element element = parseXMLRequest(httpRequest);
// The root element must be <methodCall/>
if (element.getLocalName().equals("methodCall")) {
// The text within the <methodName/> element is the function name
String function = getUniqueChild(element, "methodName").getText();
// There is a match only if the function name is non-empty
if (! TextUtils.isEmpty(function)) {
match = MATCHING;
}
}
// If an exception is caught, the fallback NOT_MATCHING will be used
} catch (Throwable exception) {
// fall through
}
return match;
}
protected FunctionRequest convertRequestImpl(HttpServletRequest httpRequest)
throws InvalidRequestException,
FunctionNotSpecifiedException {
Element xmlRequest = parseXMLRequest(httpRequest);
if (!xmlRequest.getLocalName().equals("methodCall")) {
throw new InvalidRequestException("Root element is not \"methodCall\" but \"" +
xmlRequest.getLocalName() + "\".");
}
Element methodNameElem = getUniqueChild(xmlRequest, "methodName");
String functionName = methodNameElem.getText();
httpRequest.setAttribute(FUNCTION_NAME, functionName);
// Determine function parameters and the data section
ProtectedPropertyReader functionParams = new ProtectedPropertyReader(SECRET_KEY);
Element dataSection = null;
List params = xmlRequest.getChildElements("params");
if (params.size() == 0) {
return new FunctionRequest(functionName, functionParams, null);
} else if (params.size() > 1) {
throw new InvalidRequestException("More than one params specified in the XML-RPC request.");
}
Element paramsElem = (Element) params.get(0);
Iterator itParam = paramsElem.getChildElements("param").iterator();
while (itParam.hasNext()) {
Element nextParam = (Element) itParam.next();
Element valueElem = getUniqueChild(nextParam, "value");
Element structElem = getUniqueChild(valueElem, null);
if (structElem.getLocalName().equals("struct")) {
// Parse the input parameter
Element memberElem = getUniqueChild(structElem, "member");
Element memberNameElem = getUniqueChild(memberElem, "name");
Element memberValueElem = getUniqueChild(memberElem, "value");
Element typeElem = getUniqueChild(memberValueElem, null);
String parameterName = memberNameElem.getText();
String parameterValue = typeElem.getText();
try {
FunctionSpec functionSpec = _api.getAPISpecification().getFunction(functionName);
Type parameterType = functionSpec.getInputParameter(parameterName).getType();
parameterValue = convertInput(parameterType, typeElem);
} catch (InvalidSpecificationException ise) {
// keep the old value
} catch (EntityNotFoundException enfe) {
// keep the old value
} catch (java.text.ParseException pex) {
throw new InvalidRequestException("Invalid value for parameter \"" +
parameterName + "\".", pex);
}
functionParams.set(SECRET_KEY, parameterName, parameterValue);
} else if (structElem.getLocalName().equals("array")) {
// Parse the input data section
Element arrayElem = getUniqueChild(valueElem, "array");
Element dataElem = getUniqueChild(arrayElem, "data");
if (dataSection != null) {
throw new InvalidRequestException("Only one data section is allowed per request");
}
Map dataSectionSpec = null;
try {
FunctionSpec functionSpec = _api.getAPISpecification().getFunction(functionName);
dataSectionSpec = functionSpec.getInputDataSectionElements();
} catch (InvalidSpecificationException ise) {
// keep the old value
} catch (EntityNotFoundException enfe) {
// keep the old value
}
ElementBuilder builder = new ElementBuilder("data");
Iterator itValueElems = dataElem.getChildElements("value").iterator();
while (itValueElems.hasNext()) {
Element childValueElem = (Element) itValueElems.next();
Element childElem = parseElement(childValueElem, dataSectionSpec);
builder.addChild(childElem);
}
dataSection = builder.createElement();
} else {
throw new InvalidRequestException("Only \"struct\" and \"array\" are valid as parameter type.");
}
}
return new FunctionRequest(functionName, functionParams, null);
}
protected void convertResultImpl(FunctionResult xinsResult,
HttpServletResponse httpResponse,
HttpServletRequest httpRequest)
throws IOException {
// Send the XML output to the stream and flush
httpResponse.setContentType(RESPONSE_CONTENT_TYPE);
PrintWriter out = httpResponse.getWriter();
httpResponse.setStatus(HttpServletResponse.SC_OK);
// Store the result in a StringWriter before sending it.
Writer buffer = new FastStringWriter(1024);
// Create an XMLOutputter
XMLOutputter xmlout = new XMLOutputter(buffer, RESPONSE_ENCODING);
// Output the declaration
xmlout.declaration();
xmlout.startTag("methodResponse");
String errorCode = xinsResult.getErrorCode();
if (errorCode != null) {
xmlout.startTag("fault");
xmlout.startTag("value");
xmlout.startTag("struct");
xmlout.startTag("member");
xmlout.startTag("name");
xmlout.pcdata("faultCode");
xmlout.endTag(); // name
xmlout.startTag("value");
xmlout.startTag("int");
xmlout.pcdata(String.valueOf(getErrorCodeNumber(errorCode)));
xmlout.endTag(); // int
xmlout.endTag(); // value
xmlout.endTag(); // member
xmlout.startTag("member");
xmlout.startTag("name");
xmlout.pcdata("faultString");
xmlout.endTag(); // name
xmlout.startTag("value");
xmlout.startTag("string");
xmlout.pcdata(errorCode);
xmlout.endTag(); // string
xmlout.endTag(); // value
xmlout.endTag(); // member
xmlout.endTag(); // struct
xmlout.endTag(); // value
xmlout.endTag(); // fault
} else {
String functionName = (String) httpRequest.getAttribute(FUNCTION_NAME);
xmlout.startTag("params");
xmlout.startTag("param");
xmlout.startTag("value");
xmlout.startTag("struct");
// Write the output parameters
Iterator outputParameterNames = xinsResult.getParameters().getNames();
while (outputParameterNames.hasNext()) {
String parameterName = (String) outputParameterNames.next();
String parameterValue = xinsResult.getParameter(parameterName);
String parameterTag = "string";
try {
FunctionSpec functionSpec = _api.getAPISpecification().getFunction(functionName);
Type parameterType = functionSpec.getOutputParameter(parameterName).getType();
parameterValue = convertOutput(parameterType, parameterValue);
parameterTag = convertType(parameterType);
} catch (InvalidSpecificationException ise) {
// keep the old value
} catch (EntityNotFoundException enfe) {
// keep the old value
} catch (java.text.ParseException pex) {
throw new IOException("Invalid value for parameter \"" + parameterName + "\".");
}
// Write the member element
xmlout.startTag("member");
xmlout.startTag("name");
xmlout.pcdata(parameterName);
xmlout.endTag();
xmlout.startTag("value");
xmlout.startTag(parameterTag);
xmlout.pcdata(parameterValue);
xmlout.endTag(); // type tag
xmlout.endTag(); // value
xmlout.endTag(); // member
}
// Write the data section if needed
Element dataSection = xinsResult.getDataElement();
if (dataSection != null) {
Map dataSectionSpec = null;
try {
FunctionSpec functionSpec = _api.getAPISpecification().getFunction(functionName);
dataSectionSpec = functionSpec.getOutputDataSectionElements();
} catch (InvalidSpecificationException ise) {
// keep the old value
} catch (EntityNotFoundException enfe) {
// keep the old value
}
xmlout.startTag("member");
xmlout.startTag("name");
xmlout.pcdata("data");
xmlout.endTag();
xmlout.startTag("value");
xmlout.startTag("array");
xmlout.startTag("data");
Iterator children = dataSection.getChildElements().iterator();
while (children.hasNext()) {
Element nextChild = (Element) children.next();
writeElement(nextChild, xmlout, dataSectionSpec);
}
xmlout.endTag(); // data
xmlout.endTag(); // array
xmlout.endTag(); // value
xmlout.endTag(); // member
}
xmlout.endTag(); // struct
xmlout.endTag(); // value
xmlout.endTag(); // param
xmlout.endTag(); // params
}
xmlout.endTag(); // methodResponse
// Write the result to the servlet response
out.write(buffer.toString());
out.close();
}
/**
* Gets the unique child of the element.
*
* @param parentElement
* the parent element, cannot be <code>null</code>.
*
* @param elementName
* the name of the child element to get, or <code>null</code> if the
* parent have a unique child.
*
* @return
* The sub-element of this element.
*
* @throws InvalidRequestException
* if no child was found or more than one child was found.
*/
private Element getUniqueChild(Element parentElement, String elementName)
throws InvalidRequestException {
List childList = null;
if (elementName == null) {
childList = parentElement.getChildElements();
} else {
childList = parentElement.getChildElements(elementName);
}
if (childList.size() == 0) {
throw new InvalidRequestException("No \"" + elementName +
"\" children found in the \"" + parentElement.getLocalName() +
"\" element of the XML-RPC request.");
} else if (childList.size() > 1) {
throw new InvalidRequestException("More than one \"" + elementName +
"\" children found in the \"" + parentElement.getLocalName() +
"\" element of the XML-RPC request.");
}
return (Element) childList.get(0);
}
/**
* Parses the data section element.
*
* @param valueElem
* the value element, cannot be <code>null</code>.
*
* @param dataSection
* the specification of the elements, cannot be <code>null</code>.
*
* @return
* the data section element, never <code>null</code>.
*
* @throws InvalidRequestException
* if the XML request is incorrect.
*/
private Element parseElement(Element valueElem, Map dataSection) throws InvalidRequestException {
Element structElem = getUniqueChild(valueElem, "struct");
DataSectionElementSpec elementSpec = null;
Iterator itMemberElems = structElem.getChildElements("member").iterator();
ElementBuilder builder = null;
if (itMemberElems.hasNext()) {
Element memberElem = (Element) itMemberElems.next();
Element memberNameElem = getUniqueChild(memberElem, "name");
Element memberValueElem = getUniqueChild(memberElem, "value");
Element typeElem = getUniqueChild(memberValueElem, null);
String parameterName = memberNameElem.getText();
elementSpec = (DataSectionElementSpec) dataSection.get(parameterName);
builder = new ElementBuilder(parameterName);
if (typeElem.getLocalName().equals("string")) {
builder.setText(typeElem.getText());
} else if (typeElem.getLocalName().equals("array")) {
Map childrenSpec = elementSpec.getSubElements();
Element dataElem = getUniqueChild(typeElem, "data");
Iterator itValueElems = dataElem.getChildElements("value").iterator();
while (itValueElems.hasNext()) {
Element childValueElem = (Element) itValueElems.next();
Element childElem = parseElement(childValueElem, childrenSpec);
builder.addChild(childElem);
}
} else {
throw new InvalidRequestException("Only \"string\" and \"array\" are valid as member value type.");
}
} else {
throw new InvalidRequestException("The \"struct\" element should at least have one member");
}
// Fill in the attributes
while (itMemberElems.hasNext()) {
Element memberElem = (Element) itMemberElems.next();
Element memberNameElem = getUniqueChild(memberElem, "name");
Element memberValueElem = getUniqueChild(memberElem, "value");
Element typeElem = getUniqueChild(memberValueElem, null);
String parameterName = memberNameElem.getText();
String parameterValue = typeElem.getText();
try {
Type xinsElemType = elementSpec.getAttribute(parameterName).getType();
parameterValue = convertInput(xinsElemType, memberValueElem);
} catch (EntityNotFoundException enfe) {
// keep the old value
} catch (java.text.ParseException pex) {
throw new InvalidRequestException("Invalid value for parameter \"" + parameterName + "\".");
}
builder.setAttribute(parameterName, parameterValue);
}
return builder.createElement();
}
/**
* Write the given data section element to the output.
*
* @param dataElement
* the data section element, cannot be <code>null</code>.
*
* @param xmlout
* the output where the data section element should be serialised, cannot be <code>null</code>.
*
* @param dataSectionSpec
* the specification of the data element to be written, cannot be <code>null</code>.
*
* @throws IOException
* if an IO error occurs while writing on the output.
*/
private void writeElement(Element dataElement, XMLOutputter xmlout, Map dataSectionSpec) throws IOException {
xmlout.startTag("value");
xmlout.startTag("member");
xmlout.startTag("name");
xmlout.pcdata(dataElement.getLocalName());
xmlout.endTag(); // name
xmlout.startTag("value");
DataSectionElementSpec elementSpec = (DataSectionElementSpec) dataSectionSpec.get(dataElement.getLocalName());
List children = dataElement.getChildElements();
if (children.size() > 0) {
Map childrenSpec = elementSpec.getSubElements();
xmlout.startTag("array");
xmlout.startTag("data");
Iterator itChildren = children.iterator();
while (itChildren.hasNext()) {
Element nextChild = (Element) itChildren.next();
writeElement(nextChild, xmlout, childrenSpec);
}
xmlout.endTag(); // data
xmlout.endTag(); // array
} else {
xmlout.startTag("string");
if (dataElement.getText() != null) {
xmlout.pcdata(dataElement.getText());
}
xmlout.endTag(); // string
}
xmlout.endTag(); // value
xmlout.endTag(); // member
// Write the attributes
Map attributesMap = dataElement.getAttributeMap();
Iterator itAttributes = attributesMap.keySet().iterator();
while (itAttributes.hasNext()) {
Element.QualifiedName attributeQName = (Element.QualifiedName) itAttributes.next();
String attributeName = attributeQName.getLocalName();
String attributeValue = (String) attributesMap.get(attributeQName);
String attributeTag = "string";
try {
Type attributeType = elementSpec.getAttribute(attributeName).getType();
attributeValue = convertOutput(attributeType, attributeValue);
attributeTag = convertType(attributeType);
} catch (EntityNotFoundException enfe) {
// keep the old value
} catch (java.text.ParseException pex) {
throw new IOException("Invalid value for parameter \"" + attributeName + "\".");
}
xmlout.startTag("member");
xmlout.startTag("name");
xmlout.pcdata(attributeName);
xmlout.endTag(); // name
xmlout.startTag("value");
xmlout.startTag(attributeTag);
xmlout.pcdata(attributeValue);
xmlout.endTag(); // tag
xmlout.endTag(); // value
xmlout.endTag(); // member
}
xmlout.endTag(); // value
}
/**
* Converts the XML-RPC input values to XINS input values.
*
* @param parameterType
* the type of the XINS parameter, cannot be <code>null</code>.
*
* @param typeElem
* the content of the XML-RPC value, cannot be <code>null</code>.
*
* @return
* the XINS value, never <code>null</code>.
*
* @throws java.text.ParseException
* if the parameterValue is incorrect for the type.
*/
private String convertInput(Type parameterType, Element typeElem) throws java.text.ParseException {
String xmlRpcType = typeElem.getLocalName();
String parameterValue = typeElem.getText();
if (parameterType instanceof org.xins.common.types.standard.Boolean) {
if (parameterValue.equals("1")) {
return "true";
} else if (parameterValue.equals("0")) {
return "false";
} else {
throw new java.text.ParseException("Incorrect value for boolean: " + parameterValue, 0);
}
}
//System.err.println("type: " + xmlRpcType + " ; value: " + parameterValue);
if (xmlRpcType.equals("dateTime.iso8601")) {
Date date = XML_RPC_TIMESTAMP_FORMATTER.parse(parameterValue);
if (parameterType instanceof org.xins.common.types.standard.Date) {
return XINS_DATE_FORMATTER.format(date);
} else if (parameterType instanceof org.xins.common.types.standard.Timestamp) {
return XINS_TIMESTAMP_FORMATTER.format(date);
}
}
return parameterValue;
}
/**
* Converts the XINS output values to XML-RPC output values.
*
* @param parameterType
* the type of the XINS parameter, cannot be <code>null</code>.
*
* @param parameterValue
* the XINS parameter value to convert, cannot be <code>null</code>.
*
* @return
* the XML-RPC value, never <code>null</code>.
*
* @throws java.text.ParseException
* if the parameterValue is incorrect for the type.
*/
private String convertOutput(Type parameterType, String parameterValue) throws java.text.ParseException {
if (parameterType instanceof org.xins.common.types.standard.Boolean) {
if (parameterValue.equals("true")) {
return "1";
} else if (parameterValue.equals("false")) {
return "0";
} else {
throw new java.text.ParseException("Incorrect value for boolean: " + parameterValue, 0);
}
} else if (parameterType instanceof org.xins.common.types.standard.Date) {
Date date = XINS_DATE_FORMATTER.parse(parameterValue);
return XML_RPC_TIMESTAMP_FORMATTER.format(date);
} else if (parameterType instanceof org.xins.common.types.standard.Timestamp) {
Date date = XINS_TIMESTAMP_FORMATTER.parse(parameterValue);
return XML_RPC_TIMESTAMP_FORMATTER.format(date);
}
return parameterValue;
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
6e64dd2d36fc99fd3a8d51eba0214ac1d015d973 | 652e5f1eda5e8f5cf70cc3b443ebf4f6f0797b32 | /src/test/java/com/ccs/testCases/TC_CreateContDDT_011.java | e78ebdbfae5a3c1bdd31b4b41455a8e2913f1688 | [] | no_license | mreddy25/CommunicationCloud | 38841b326f9578baf56e6db44c4baa058367a5e8 | d4000352e4ac8dc7b0b83d4012bd112ba4034bf6 | refs/heads/master | 2023-02-11T01:31:17.259895 | 2021-01-11T12:19:48 | 2021-01-11T12:19:48 | 272,646,535 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,974 | java | package com.ccs.testCases;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.ccs.pageObjects.CCSPageObjects;
import com.ccs.pageObjects.ContentPage;
import com.ccs.pageObjects.LoginPage;
import com.ccs.utilities.XLUtils;
public class TC_CreateContDDT_011 extends BaseClass {
String timeStamp = new SimpleDateFormat("yy.MM.dd.HH.mm.ss").format(new Date());
@Test(dataProvider = "ContData")
public void ContCreateDDT(String uname, String pwd, String bconName, String bconLName, String bconDesc,
String conVname, String contDesc, String activeDate, String cKEditData)
throws InterruptedException, IOException
{
// calling SignIn method
driver.get(baseURL);
Thread.sleep(3000);
logger.info("URL is opened: " + baseURL);
Thread.sleep(3000);
// here LoginPage- pageObject class
LoginPage lp = new LoginPage(driver);
ContentPage cp = new ContentPage(driver);
CCSPageObjects cob = new CCSPageObjects(driver);
// if details button is exists then click otherwise skip
if (lp.noDetaislBtn().isEmpty()) {
logger.info("Details-button is not dispayed to click");
Thread.sleep(2000);
} else {
lp.detailBtn().click();
logger.info("Clicked on 'details-button'");
Thread.sleep(2000);
}
// if Proceed link is exists then click otherwise skip
if (lp.noProceedLnk().isEmpty()) {
logger.info("Proceed-link is not displayed to click");
Thread.sleep(2000);
} else {
lp.proceedLnk().click();
logger.info("Clicked on 'proceed-link'");
Thread.sleep(2000);
}
// enter username
lp.setUserName(uname);
logger.info("Entered username: " + uname);
// enter password
lp.setPassword(pwd);
logger.info("Entered password");
// click on Sign In button
lp.clickSignin();
logger.info("Clicked on Sign In");
Thread.sleep(45000);
// validation window name
if(lp.loginSuccess().isDisplayed())
{
logger.info("Login test passed and Logged in as a: " + uname);
}else{
//call the capture screen method which is declared in base class
captureScreen(driver,"loginTest_TC0011");
Assert.assertTrue(false);
logger.info("Login test failed");
}
// Calling MapConfig Id function
TC_MapConfigID_013 mapConfigId = new TC_MapConfigID_013();
mapConfigId.mapConfigID();
// Calling Class- Go to Content Landing page
ContentLandingPage ContLandingPage = new ContentLandingPage();
ContLandingPage.ContLandingPage();
Thread.sleep(5000);
cob.createBtn().click();
logger.info("Clicked on 'Plus(+) icon button to create new Content");
Thread.sleep(5000);
//Validating Content Selection window name
//boolean res1 = driver.findElement(By.xpath("//span[text()='Choose Content Type']")) != null;
if (cp.contSelectionWindow().isDisplayed())
{
Assert.assertTrue(true);
logger.info("You are at 'Choose Content Type' window");
} else {
logger.info("You are not at Choose Content Type window");
captureScreen(driver, "ContSelectionWindow_TC010");
Assert.assertTrue(false);
}
Thread.sleep(3000);
cp.radioBtn().click();
logger.info("Selected Text radio button to create new Content");
Thread.sleep(3000);
//if (driver.findElement(By.xpath("//span[text()='Continue']")).isDisplayed())
if (cob.continueBtn().isDisplayed()){
cob.continueBtn().click();
logger.info("Clicked on continue button 1/4 Choose Content Type");
Thread.sleep(3000);
}
// Create Base Content
//boolean cad = driver.getPageSource().contains("Add Identification");
if (cp.addIdentificationWind().isDisplayed()) {
logger.info("You are at 2/4 Add Identification dialog window");
Thread.sleep(5000);
} else {
logger.info("You are not at 2/4 Add Identification dialog window");
captureScreen(driver, "ContentAddIdentWindow_TC010");
Assert.assertTrue(false);
}
//EnterName for content
if(cob.baseNameField().isEnabled())
{
cob.baseNameField().sendKeys(bconName + timeStamp);
logger.info("Entered Base Content name as : " + bconName + timeStamp);
Thread.sleep(3000);
}else {
cp.baseContName(bconName + timeStamp);
logger.info("Entered Base Content name as-2 : " + bconName + timeStamp);
Thread.sleep(3000);
}
//enter Long Name for Content
if(cob.longNameField().isEnabled())
{
cob.longNameField().sendKeys(bconLName + timeStamp);
logger.info("Entered Base Content Long name as : " + bconLName + timeStamp);
Thread.sleep(3000);
}else {
cp.baseContLongName(bconLName + timeStamp);
logger.info("Entered Base Content long name as -2:" + bconLName + timeStamp);
Thread.sleep(3000);
}
//Enter Description for Content
if (cob.baseDescriptionField().get(1).isEnabled())
{
cob.baseDescriptionField().get(1).sendKeys(bconDesc + timeStamp);
logger.info("Entered Base Contant Description as : " + bconDesc + timeStamp);
}
/*
cob.continueBtn().click();
logger.info("Clicked on continue button in '2/4 Add Identification' window");
Thread.sleep(18000);
*/
//Continue button
if(driver.findElement(By.xpath("//span[text()='Continue']")).isDisplayed())
{
driver.findElement(By.xpath("//span[text()='Continue']")).click();
logger.info("Clicked on continue button in '2/4 Add Identification' window");
Thread.sleep(18000);
}
// validating window title
driver.getTitle().equals("Create Content Version");
logger.info("You are at 'Create Content Version' window");
Thread.sleep(3000);
// enter content version name
if(cob.versionNameField().isDisplayed())
{
cob.versionNameField().sendKeys(conVname + timeStamp);
logger.info("Entered Contant Version Name:" + conVname + timeStamp);
Thread.sleep(3000);
}
// enter cont description
//if (driver.findElement(By.xpath("//*[starts-with(@id,'textArea')]")).isDisplayed()) {
if (cob.descriptionField().isDisplayed())
{
cob.descriptionField().sendKeys(contDesc + timeStamp);
logger.info("Entered Contant Description:" + contDesc + timeStamp);
Thread.sleep(3000);
}
// enter active date
//driver.findElement(By.xpath("//*[starts-with(@id,'fromDate')]"))
if (cob.dateField().isEnabled()) {
cob.dateField().sendKeys(activeDate);
logger.info("Entered Active Date: " + activeDate);
Thread.sleep(10000);
}
// click on continue
//cob.continueBtn().isDisplayed();
//cob.continueBtn().click();
if (driver.findElement(By.xpath("//span[contains(@class,'oj-button-text') and contains(text(),'Continue')]")).isDisplayed())
{
driver.findElement(By.xpath("//span[contains(@class,'oj-button-text') and contains(text(),'Continue')]")).click();
logger.info("clicked continue in contenet version window to create base content ");
}
Thread.sleep(150000);
// ck toolbar
//driver.findElement(By.xpath("//*[contains(@class,'ck-toolbar')]")).isDisplayed()
if (cp.ckToolbar().isDisplayed()) {
logger.info("ck-toolbar is displayed");
} else {
logger.info("ck-toolbar bar is not displayed");
captureScreen(driver, "CKEditorToolBar_TC0011");
Assert.assertTrue(false);
}
// CKEditor
//WebElement ckeditor = driver.findElement(By.xpath("//*[contains(@class,'ck-editor__editable')]"));
if (cp.ckEditor().isDisplayed()) {
cp.ckEditor().click();
logger.info("Clicked on ckeditor'");
Thread.sleep(2000);
}
/*
* ckeditor.sendKeys("Dear Customer,"); ckeditor.sendKeys(Keys.ENTER);
*/
// enter data in ckeditor
cp.ckEditor().sendKeys(cKEditData);
logger.info("Entered content details in 'CKEditor'");
Thread.sleep(3000);
// Click Continue
//driver.findElement(By.xpath("//span[text()='Continue' and @class='oj-button-text']"))
/* if(cob.continueBtn().isDisplayed()) {
cob.continueBtn().click();
logger.info("Clicked on Continue after entering the content details in CKEditor");
}
*/
if (driver.findElement(By.xpath("//span[text()='Continue' and @class='oj-button-text']")).isDisplayed()) {
driver.findElement(By.xpath("//span[text()='Continue' and @class='oj-button-text']")).click();
logger.info("Clicked on Continue after entering the content details in CKEditor");
}
Thread.sleep(20000);
// Content Creation status window
driver.findElement(By.xpath("//span[text()='Success!']")).isDisplayed();
boolean successWind = cp.successMsgWind().isDisplayed();
if (successWind == true) {
Assert.assertTrue(true);
logger.info("Content creation windows is displayed with 'Success'");
} else {
logger.info("Content creation windows is not displayed with 'Success'");
captureScreen(driver, "ContCreatSuccess_TC011");
Assert.assertTrue(false);
}
Thread.sleep(2000);
// Finish Button-
//driver.findElement(By.xpath("//span[text()='Finish' and @class='oj-button-text']"))
if (cob.finishBtn().isEnabled()) {
cob.finishBtn().click();
logger.info("Clicked on Finish Button to complete the Content creation process");
}
// validating content title after creation
Thread.sleep(30000);
//Boolean contTitle = driver.findElement(By.tagName("h1")).isDisplayed();
Boolean contTitle = cob.assetTitle().isDisplayed();
if (contTitle == true) {
Assert.assertTrue(true);
logger.info("Content is created with the name of :" + conVname + timeStamp);
} else {
logger.info("Content is not created with the name of :" + conVname + timeStamp);
captureScreen(driver, "ContCreatSuccess_TC011");
Assert.assertTrue(false);
}
// Sign off the application
Thread.sleep(8000);
TC_SignOff signOff = new TC_SignOff();
signOff.signOff();
logger.info("User is Signed off from the application ");
// Clear browser history
driver.get("chrome://settings/clearBrowserData");
driver.findElement(By.xpath("//settings-ui")).sendKeys(Keys.ENTER);
logger.info("Browser Data: Clear history, CCookies and Cache are cleared ");
Thread.sleep(3000);
//Close the browser
//driver.quit();
//logger.info("Browser is closed ");
}
// data read from excel
@DataProvider(name = "ContData")
String[][] getData() throws IOException {
String path = System.getProperty("user.dir") + "/src/test/java/com/ccs/testData/LoginData.xlsx";
// read the data from xlsx //get row count
int rownum = XLUtils.getRowCount(path, "ContentData");// path- xl location path and sheet1 - sheet name //get
// cell count
int colcount = XLUtils.getCellCount(path, "ContentData", 1); // here 1- row number
String contentdata[][] = new String[rownum][colcount];
for (int i = 1; i <= rownum; i++)// outer for loop for row
{
for (int j = 0; j < colcount; j++)// inner for loop for column
{
contentdata[i - 1][j] = XLUtils.getCellData(path, "ContentData", i, j);
}
}
return contentdata;
}
}
| [
"muni.reddy25@gmail.com"
] | muni.reddy25@gmail.com |
4998fd987f65adf5f86280c4a719407502355d25 | ddd75ac71d7e92f994dbc7d56feff27280d67a5e | /src/test/java/g_tdd_solution/FizzBuzzTest.java | 39e1f24193278dbbee705142f6e260b10b329402 | [] | no_license | mateuszlajming/tdd | dc325e04586afd42cdf1678a32afc3128c2c5bc3 | a52fc9b755dca39756ce57007e071c22921077b6 | refs/heads/master | 2022-11-30T19:52:46.329383 | 2020-08-09T12:17:47 | 2020-08-09T12:17:47 | 284,090,949 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,313 | java | package g_tdd_solution;
import org.assertj.core.api.Assertions;
import org.junit.Test;
public class FizzBuzzTest {
FizzBuzz fizzBuzz = new FizzBuzz();
@Test
public void fizzBuzz_whenPassing3_shouldReturnFizz() {
String ret = fizzBuzz.fizzBuzz(3);
Assertions.assertThat(ret).isEqualTo("Fizz");
}
@Test
public void fizzBuzz_whenPassing9_shouldReturnFizz() {
String ret = fizzBuzz.fizzBuzz(9);
Assertions.assertThat(ret).isEqualTo("Fizz");
}
@Test
public void fizzBuzz_whenPassing5_shouldReturnBuzz() {
String ret = fizzBuzz.fizzBuzz(5);
Assertions.assertThat(ret).isEqualTo("Buzz");
}
@Test
public void fizzBuzz_whenPassing10_shouldReturnBuzz() {
String ret = fizzBuzz.fizzBuzz(10);
Assertions.assertThat(ret).isEqualTo("Buzz");
}
@Test
public void fizzBuzz_whenPassing15_shouldReturnFizzBuzz() {
String ret = fizzBuzz.fizzBuzz(15);
Assertions.assertThat(ret).isEqualTo("FizzBuzz");
}
@Test
public void fizzBuzz_whenPassing30_shouldReturnFizzBuzz() {
String ret = fizzBuzz.fizzBuzz(30);
Assertions.assertThat(ret).isEqualTo("FizzBuzz");
}
@Test
public void fizzBuzz_whenPassingOtherNumbers_shouldReturnOther() {
String ret = fizzBuzz.fizzBuzz(8);
Assertions.assertThat(ret).isEqualTo("Other");
}
}
| [
"mateusz.lajming@tomtom.com"
] | mateusz.lajming@tomtom.com |
a5e9c701a728441a2cfcda2843ad741d6fe3c2f7 | 603928abae6badbec7f06d98ee348d1ecc962bc9 | /src/sotaynauan/dao/TaiKhoanDAO.java | 1ef8ea24e8e5fce78fe22951fc7a666f27534a0f | [] | no_license | hoang2807/sotaynauan | 52e2f173e2244c09054b1439d3ab974b4fd4c618 | 021f498506a1f2a249673594e56a389e0bdc861b | refs/heads/main | 2023-07-01T07:31:14.699837 | 2021-08-02T21:13:33 | 2021-08-02T21:13:33 | 378,553,195 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 240 | java |
package sotaynauan.dao;
import sotaynauan.model.TaiKhoan;
/**
*
* @author hoang
*/
public interface TaiKhoanDAO {
public TaiKhoan login(String username,String password);
public int logout(String username,String password);
}
| [
"viethoang28072000@gmail.com"
] | viethoang28072000@gmail.com |
87c724847bc8ee3524faa28d63792a0f4e0b51d9 | a25ffce70545f7a6afeb58e5c70eb24a17426318 | /jbm-framework/jbm-framework-autoconfigure/jbm-framework-autoconfigure-taskflow/src/test/java/com/jbm/test/stepchain/test/PipelineTest.java | 250689010efc644c1a602411659a94bb8f8de3b5 | [
"Apache-2.0"
] | permissive | numen06/JBM | 4b3b2158f8199957c6e1500ab05ae5aca375a98f | 827df87659e9392d73897753142271ab1e573974 | refs/heads/7.1 | 2023-08-31T15:35:34.579275 | 2023-08-23T01:12:01 | 2023-08-23T01:12:01 | 160,906,536 | 10 | 9 | Apache-2.0 | 2023-04-14T19:31:19 | 2018-12-08T05:16:32 | Java | UTF-8 | Java | false | false | 3,509 | java | package com.jbm.test.stepchain.test;
import com.alibaba.fastjson.JSON;
import com.github.zengfr.project.stepchain.*;
import com.github.zengfr.project.stepchain.context.UnaryContext;
import com.jbm.test.stepchain.test.context.SetProductContext;
import com.jbm.test.stepchain.test.context.SetProductDataMiddle;
import com.jbm.test.stepchain.test.processor.*;
import java.util.function.Function;
public class PipelineTest {
public static void testPipeline(IPipeline pipeline) throws Exception {
SetProductRequest req = new SetProductRequest();
SetProductResponse resp = new SetProductResponse();
SetProductDataMiddle middle = new SetProductDataMiddle();
SetProductContext context = new SetProductContext(req, middle, resp);
IStep<SetProductContext> step = pipeline.createStep();
step.put(new InitProcessor());
step.put(new TaxProcessor());
step.put(new FeeProcessor());
step.put(new IncreaseProcessor());
step.put(new DiscountProcessor());
Function<SetProductContext, Boolean> func = (c) -> {
c.middle.Price += 10;
return true;
};
step.put(func);
step.process(context);
System.out.println(context.middle.Price);
}
public static void testPipeline2(IPipeline pipeline) throws Exception {
Function<UnaryContext<Integer>, Boolean> func = (context) -> {
if (context.context == null)
context.context = 1;
context.context += 1;
return true;
};
Function<UnaryContext<Integer>, String> func3 = (context) -> {
if (context.context == null)
context.context = 1;
context.context += 1;
return JSON.toJSONString(context.context);
};
UnaryContext<Integer> context = pipeline.createContext(12345678);
IStep<UnaryContext<Integer>> step = pipeline.createStep();
IStep<UnaryContext<Integer>> step2 = pipeline.createStep();
IChain<UnaryContext<Integer>, Boolean> c2 = pipeline.createChain(func);
IChain<UnaryContext<Integer>, String> c3 = pipeline.createChain(func3);
Function<String, Integer> func4 = null;
Function<Integer, String> func5 = null;
Function<String, Boolean> func6 = null;
IChain<String, Integer> c4 = pipeline.createChain(func4);
IChain<Integer, String> c5 = pipeline.createChain(func5);
IChain<String, Boolean> c6 = pipeline.createChain(func6);
IChain<UnaryContext<Integer>, Boolean> c7 = c3.next(c4).next(c5).next(c6);
step2.put(c2);
step2.put(step);
step2.put(func);
//step2.put(c7);
step2.process(context);
System.out.println(context.context);
}
public static void testPipeline3(IPipeline pipeline) throws Exception {
IProcessor<String, String> selector = null;
IProcessor<String, Boolean> validator = null;
IProcessor<String, String> processor = null;
IProcessor<String, String> first = null;
IProcessor<String, String> second = null;
IConditionSelectorProcessor<String, Boolean, String> p3 = pipeline.createConditionValidatorProcessor(validator, first, second);
IConditionLoopProcessor<String, String> p2 = pipeline.createConditionLoopProcessor(validator, processor);
IConditionSelectorProcessor<String, String, String> p1 = pipeline.createConditionSelectorProcessor(selector);
}
}
| [
"numen06@sina.com"
] | numen06@sina.com |
2e54ec6f6d562088206010bd8be838be4779e036 | ac51f3adc256fa6f1fb171018f1e589025297b80 | /uploadOne drive/micro-service/search-service/search-service/src/main/java/com/cts/search/service/model/Technology.java | e20c2761eb8221aeb08e0f65314e0391d7abfe6e | [] | no_license | vishwatejachalla/mystuff | b4210abd75996d4bae0a450d860f428292c5ae2e | 4f4085603eaa29c40aa1439678a9271329c0a8f9 | refs/heads/master | 2022-12-31T05:04:54.952150 | 2020-10-18T15:59:08 | 2020-10-18T15:59:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,745 | java | package com.cts.search.service.model;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
@Table(name = "technology")
public class Technology {
@Id
@NotNull
@Column(name = "t_id")
private int id;
@NotEmpty(message = "please provide technology name")
@Column(name = "t_name")
private String name;
@NotNull(message = "please provide technology duration")
@Column(name = "t_duration")
private int duration;
@NotEmpty(message = "please provide prerequisites")
@Column(name = "t_prerequisites")
private String prerequisites;
@JsonIgnore
@OneToMany(mappedBy = "technologies")
private Set<MentorSkills> mentorSkills;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getDuration() {
return duration;
}
public void setDuration(int duration) {
this.duration = duration;
}
public String getPrerequisites() {
return prerequisites;
}
public void setPrerequisites(String prerequisites) {
this.prerequisites = prerequisites;
}
public Set<MentorSkills> getMentorSkills() {
return mentorSkills;
}
public void setMentorSkills(Set<MentorSkills> mentorSkills) {
this.mentorSkills = mentorSkills;
}
@Override
public String toString() {
return "Technology [id=" + id + ", name=" + name + ", duration=" + duration + ", prerequisites=" + prerequisites
+ "]";
}
}
| [
"799357@cognizant.com"
] | 799357@cognizant.com |
35493d659d5eff36495ad20178ee8235c6e1e080 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/34/34_e86c1705c25f71e915feefeda6338e5ad0d76ff6/DownloadBeverageTask/34_e86c1705c25f71e915feefeda6338e5ad0d76ff6_DownloadBeverageTask_s.java | 900ea45cbd8fd23064374c01d7f78dac181b889e | [] | 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 | 2,976 | java | package ws.wiklund.guides.util;
import java.io.IOException;
import ws.wiklund.guides.R;
import ws.wiklund.guides.bolaget.SystembolagetParser;
import ws.wiklund.guides.db.BeverageDatabaseHelper;
import ws.wiklund.guides.model.Beverage;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;
public class DownloadBeverageTask extends AsyncTask<String, Void, Beverage> {
private BeverageDatabaseHelper helper;
private Boolean useSubTasks;
private Activity activity;
@SuppressWarnings("rawtypes")
private Class activityClass;
private String no;
private String errorMsg;
private long startRead = 0;
private ProgressDialog dialog;
@SuppressWarnings("rawtypes")
public DownloadBeverageTask(BeverageDatabaseHelper helper, Boolean useSubTasks, Activity activity, Class activityClass) {
this.helper = helper;
this.useSubTasks = useSubTasks;
this.activity = activity;
this.activityClass = activityClass;
}
@Override
protected Beverage doInBackground(String... no) {
this.no = no[0];
dialog.setMessage(String.format(activity.getString(R.string.systembolaget_wait_msg), new Object[]{this.no}));
try {
if(this.no == null) {
Log.w(DownloadBeverageTask.class.getName(), "Failed to get info for wine, no is null");
errorMsg = activity.getString(R.string.genericParseError);
} else {
startRead = System.currentTimeMillis();
return SystembolagetParser.parseResponse(this.no, helper, useSubTasks);
}
} catch (IOException e) {
Log.w(DownloadBeverageTask.class.getName(), "Failed to get info for wine with no: " + this.no + " after " + (System.currentTimeMillis() - startRead + " milli secs"), e);
errorMsg = activity.getString(R.string.genericParseError);
}
return null;
}
@Override
protected void onPostExecute(Beverage beverage) {
Intent intent = new Intent(activity, activityClass);
if (beverage != null) {
Log.d(DownloadBeverageTask.class.getName(), "Got beverage after " + (System.currentTimeMillis() - startRead) + " milli secs");
intent.putExtra("ws.wiklund.guides.model.Beverage", beverage);
activity.startActivity(intent);
} else {
Toast.makeText(activity, errorMsg == null ? String.format(activity.getString(R.string.missingNoError), this.no) : errorMsg, Toast.LENGTH_SHORT).show();
errorMsg = null;
}
dialog.dismiss();
super.onPostExecute(beverage);
}
@Override
protected void onPreExecute() {
dialog = new ProgressDialog(activity, R.style.CustomDialog);
dialog.setTitle(activity.getString(R.string.wait));
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.show();
super.onPreExecute();
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
42e0bc2ecb9fb16147edd0234aa3ef960f337e22 | 1fadfe474add2f92c104794e28c612e46a2c6f27 | /Classwork/CodeAlongsM2/src/main/java/Inheritance/Iguana.java | 56c1ef862c62449f4c623a358a82e6c8c9e0f9f6 | [] | no_license | karlmarx/classWork-mirrored | 3a2a5c0c338ba47862044db3ca6d46315cc14563 | 041b3b62b3e6834f571313d53e1b85ac56bb31bd | refs/heads/master | 2020-07-21T20:04:09.485795 | 2019-09-14T19:32:24 | 2019-09-14T19:32:24 | 206,961,839 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 432 | 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 Inheritance;
/**
*
* @author karlmarx
*/
public class Iguana extends Pet {
public void blink(){
System.out.println("Blink");
}
public Iguana(String name, String owner) {
super(name, owner);
}
}
| [
"5042021062karlmarx@gmail.com"
] | 5042021062karlmarx@gmail.com |
e8ba4ae1dbcae6c2f3ac106f17d53e18912c39cd | a969f85d448c84ab9bdc4e5ed5be8540bda6184c | /src/main/java/by/hustlestar/bean/entity/Actor.java | db271f938f25122019e3c7cfd699d4bf1faad966 | [] | no_license | hustlestar/WebProject_v1_Malashchytski | 71a525cf2d21fe32d6b644261d8c6d9a4c1f9a64 | ae98ac24f4951e3a858c3a281c149bbd790bc022 | refs/heads/master | 2021-01-13T13:32:13.110522 | 2017-04-21T14:12:30 | 2017-04-21T14:12:31 | 72,621,520 | 0 | 2 | null | 2016-12-26T09:29:09 | 2016-11-02T08:55:58 | Java | UTF-8 | Java | false | false | 2,344 | java | package by.hustlestar.bean.entity;
import java.io.Serializable;
import java.util.List;
/**
* Entity represents actor.
*/
public class Actor implements Serializable {
/**
* unique identifier
*/
private int id;
/**
* actor name in russian
*/
private String nameRu;
/**
* actor name in english
*/
private String nameEn;
/**
* list of movies where actor participated
*/
private List<Movie> movies;
/**
* path to actor photo
*/
private String image;
public Actor() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getNameRu() {
return nameRu;
}
public void setNameRu(String nameRu) {
this.nameRu = nameRu;
}
public String getNameEn() {
return nameEn;
}
public void setNameEn(String nameEn) {
this.nameEn = nameEn;
}
public List<Movie> getMovies() {
return movies;
}
public void setMovies(List<Movie> movies) {
this.movies = movies;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Actor actor = (Actor) o;
if (id != actor.id) return false;
if (nameRu != null ? !nameRu.equals(actor.nameRu) : actor.nameRu != null) return false;
if (nameEn != null ? !nameEn.equals(actor.nameEn) : actor.nameEn != null) return false;
if (movies != null ? !movies.equals(actor.movies) : actor.movies != null) return false;
return image != null ? image.equals(actor.image) : actor.image == null;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + (nameRu != null ? nameRu.hashCode() : 0);
result = 31 * result + (nameEn != null ? nameEn.hashCode() : 0);
result = 31 * result + (movies != null ? movies.hashCode() : 0);
result = 31 * result + (image != null ? image.hashCode() : 0);
return result;
}
}
| [
"hustlequeen@mail.ru"
] | hustlequeen@mail.ru |
65ac9d7d39059206800aa49dab191d92de15dff5 | 405db9621d0d7e0fabcc82ee906a03837186c03a | /src/org/traccar/events/MotionEventHandler.java | 4b652a727f8d1f1aefd2913d93cbe79fbfbbcaad | [
"Apache-2.0"
] | permissive | cmelgarejo/traccar | d8f9bdc18a6d01ee724645db0c9732b9d20f794a | c2e051e71de5268cb572790613d30a029d083154 | refs/heads/master | 2020-12-30T17:32:28.183971 | 2016-07-28T11:26:26 | 2016-07-28T11:26:26 | 51,580,099 | 0 | 0 | null | 2016-07-28T11:26:26 | 2016-02-12T10:15:03 | Java | UTF-8 | Java | false | false | 2,855 | java | /*
* Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.traccar.events;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import org.traccar.BaseEventHandler;
import org.traccar.Context;
import org.traccar.helper.Log;
import org.traccar.model.Device;
import org.traccar.model.Event;
import org.traccar.model.Position;
public class MotionEventHandler extends BaseEventHandler {
private static final double SPEED_THRESHOLD = 0.01;
private int suppressRepeated;
public MotionEventHandler() {
suppressRepeated = Context.getConfig().getInteger("event.suppressRepeated", 60);
}
@Override
protected Collection<Event> analyzePosition(Position position) {
Device device = Context.getIdentityManager().getDeviceById(position.getDeviceId());
if (device == null) {
return null;
}
if (!Context.getDeviceManager().isLatestPosition(position) || !position.getValid()) {
return null;
}
Collection<Event> result = null;
double speed = position.getSpeed();
double oldSpeed = 0;
Position lastPosition = Context.getDeviceManager().getLastPosition(position.getDeviceId());
if (lastPosition != null) {
oldSpeed = lastPosition.getSpeed();
}
try {
if (speed > SPEED_THRESHOLD && oldSpeed <= SPEED_THRESHOLD) {
result = new ArrayList<>();
result.add(new Event(Event.TYPE_DEVICE_MOVING, position.getDeviceId(), position.getId()));
} else if (speed <= SPEED_THRESHOLD && oldSpeed > SPEED_THRESHOLD) {
result = new ArrayList<>();
result.add(new Event(Event.TYPE_DEVICE_STOPPED, position.getDeviceId(), position.getId()));
}
if (result != null && !result.isEmpty()) {
for (Event event : result) {
if (!Context.getDataManager().getLastEvents(position.getDeviceId(),
event.getType(), suppressRepeated).isEmpty()) {
event = null;
}
}
}
} catch (SQLException error) {
Log.warning(error);
}
return result;
}
}
| [
"abyss@fox5.ru"
] | abyss@fox5.ru |
a2380b959f68e8460987b7d132cee597186bbdb0 | a9481aae95a3da88c7ce2147b2d532997e51b4a6 | /src/main/java/ProsperLoans.java | 1f67603ebd40ca610999979ef5548c2b81e752e0 | [
"MIT"
] | permissive | partlok2/cse881 | 84f404983c0cdba21e8bb19a094b3356acf04ba6 | 7b3f998296685bb7f9dfcd4fa74ffa400e76e359 | refs/heads/master | 2020-02-26T16:48:44.098791 | 2016-12-13T15:10:26 | 2016-12-13T15:10:26 | 71,513,373 | 1 | 1 | null | 2016-11-23T21:43:28 | 2016-10-20T23:47:53 | Python | UTF-8 | Java | false | false | 6,270 | java | import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Map;
import java.awt.List;
import java.net.URI;
import java.net.URISyntaxException;
import static spark.Spark.*;
import spark.template.freemarker.FreeMarkerEngine;
import spark.ModelAndView;
import static spark.Spark.get;
import com.heroku.sdk.jdbc.DatabaseUrl;
import java.sql.*;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Map;
import java.net.URI;
import java.net.URISyntaxException;
import static spark.Spark.*;
import spark.template.freemarker.FreeMarkerEngine;
import weka.classifiers.Classifier;
import weka.core.Instances;
import spark.ModelAndView;
import static spark.Spark.get;
import com.heroku.sdk.jdbc.DatabaseUrl;
public class ProsperLoans{
public ArrayList<Loan> aLoans = new ArrayList<Loan>();
public ArrayList<Loan> aaLoans = new ArrayList<Loan>();
public ArrayList<Loan> bLoans = new ArrayList<Loan>();
public ArrayList<Loan> cLoans = new ArrayList<Loan>();
public ArrayList<Loan> dLoans = new ArrayList<Loan>();
public ArrayList<Loan> eLoans = new ArrayList<Loan>();
public ArrayList<Loan> hrLoans = new ArrayList<Loan>();
public String getHTML(HashMap<Integer, Double> classificationData, Instances prosperData){
populateLoanData(classificationData, prosperData);
String outputHTML = "<!DOCTYPE html><html><head><style>table { font-family: arial, sans-serif; border-collapse: collapse; width: 100%;}td, th { border: 1px solid #dddddd; text-align: left; padding: 8px;}tr:nth-child(even) { background-color: #dddddd;}</style></head><body>";
//Header
outputHTML = outputHTML + "<h1 align=\"center\">Prosper Loan Default Classification: CSE 881</h1><hr>";
long yourmilliseconds = System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");
Date resultdate = new Date(yourmilliseconds);
System.out.println(sdf.format(resultdate));
outputHTML = outputHTML + "<h2 align=\"center\">Updated: " + sdf.format(resultdate) + "</h2>";
outputHTML = outputHTML + "<h5 align=\"center\">All loans listed have been flagged as \"Not Likely to Default\" by the model</h5><hr>";
//A Classification
outputHTML = outputHTML + "<h2>Classification: A</h2>";
outputHTML = outputHTML + "<table>";
outputHTML = outputHTML + getHeaders();
outputHTML = outputHTML + getData(aLoans);
outputHTML = outputHTML + "</table>";
//AA Classification
outputHTML = outputHTML + "<h2>Classification: AA</h2>";
outputHTML = outputHTML + "<table>";
outputHTML = outputHTML + getHeaders();
outputHTML = outputHTML + getData(aaLoans);
outputHTML = outputHTML + "</table>";
//B Classification
outputHTML = outputHTML + "<h2>Classification: B</h2>";
outputHTML = outputHTML + "<table>";
outputHTML = outputHTML + getHeaders();
outputHTML = outputHTML + getData(bLoans);
outputHTML = outputHTML + "</table>";
//C Classification
outputHTML = outputHTML + "<h2>Classification: C</h2>";
outputHTML = outputHTML + "<table>";
outputHTML = outputHTML + getHeaders();
outputHTML = outputHTML + getData(cLoans);
outputHTML = outputHTML + "</table>";
//D Classification
outputHTML = outputHTML + "<h2>Classification: D</h2>";
outputHTML = outputHTML + "<table>";
outputHTML = outputHTML + getHeaders();
outputHTML = outputHTML + getData(dLoans);
outputHTML = outputHTML + "</table>";
//E Classification
outputHTML = outputHTML + "<h2>Classification: E</h2>";
outputHTML = outputHTML + "<table>";
outputHTML = outputHTML + getHeaders();
outputHTML = outputHTML + getData(eLoans);
outputHTML = outputHTML + "</table>";
//HR Classification
outputHTML = outputHTML + "<h2>Classification: HR</h2>";
outputHTML = outputHTML + "<table>";
outputHTML = outputHTML + getHeaders();
outputHTML = outputHTML + getData(hrLoans);
outputHTML = outputHTML + "</table>";
outputHTML = outputHTML + "</body></html>";
return outputHTML;
}
private String getHeaders(){
String headers = "<tr>";
String[] fieldNames = {"Loan Number", "Loan Amount", "Fico score", "Monthly Income", "Monthly Debt"};
for(int i = 0; i < fieldNames.length; i++){
headers = headers + "<th>";
headers = headers + fieldNames[i];
headers = headers + "</th>";
}
return headers + "</tr>";
}
private String getData(ArrayList<Loan> list){
String data = "";
for(int i = 0; i < list.size(); i++){
data = data + "<tr>";
data = data + "<th>";
data = data + list.get(i).id;
data = data + "</th>";
data = data + "<th>";
data = data + "$" + list.get(i).loanAmount;
data = data + "</th>";
data = data + "<th>";
data = data + list.get(i).fico;
data = data + "</th>";
data = data + "<th>";
data = data + "$" + list.get(i).monthlyIncome;
data = data + "</th>";
data = data + "<th>";
data = data + "$" + list.get(i).monthlyDebt;
data = data + "</th>";
data = data + "</tr>";
}
return data ;
}
private void populateLoanData(HashMap<Integer, Double> classificationData, Instances prosperData){
for (Map.Entry<Integer, Double> entry : classificationData.entrySet()) {
//prosperData.get(entry.getKey()).value(1);
Loan testLoan = new Loan((int)prosperData.get(entry.getKey()).value(37),
(int)prosperData.get(entry.getKey()).value(1),
(int)prosperData.get(entry.getKey()).value(7),
(int)prosperData.get(entry.getKey()).value(9),
(int)prosperData.get(entry.getKey()).value(14));
if(entry.getValue() == 1.0){
switch((int)prosperData.get(entry.getKey()).value(35)){
case 0:
aLoans.add(testLoan);
break;
case 1:
aaLoans.add(testLoan);
break;
case 2:
bLoans.add(testLoan);
break;
case 3:
cLoans.add(testLoan);
break;
case 4:
dLoans.add(testLoan);
break;
case 5:
eLoans.add(testLoan);
break;
case 6:
hrLoans.add(testLoan);
break;
}
}
}
//populate aLoans,bLoans etc... here.
//aLoans.add(testLoan);
//bLoans.add(testLoan);
//cLoans.add(testLoan);
//dLoans.add(testLoan);
}
} | [
"partlok2@gmail.com"
] | partlok2@gmail.com |
4e8d6349984786e1592d3a9ad778047a0d659c0f | 8ff6f8542af125c35abe562e9d56039f22482d00 | /src/main/java/com/sonicle/webtop/drm/TimetableSummaryExcelQuery.java | e46d4bed87d7ec050710795751d16bd157ebf378 | [] | no_license | sonicle-webtop/webtop-drm | b2e8730f41f764d1c78f1e7ef8ccbee7f7c697b1 | e87c61830da0f16cca27e19e0549ac7c6ab4895b | refs/heads/master | 2023-07-20T10:56:41.755782 | 2023-06-13T08:11:59 | 2023-06-13T08:11:59 | 121,223,046 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,482 | java | /*
* Copyright (C) 2017 Sonicle S.r.l.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by
* the Free Software Foundation with the addition of the following permission
* added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
* WORK IN WHICH THE COPYRIGHT IS OWNED BY SONICLE, SONICLE DISCLAIMS THE
* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program; if not, see http://www.gnu.org/licenses or write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA.
*
* You can contact Sonicle S.r.l. at email address sonicle[at]sonicle[dot]com
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License
* version 3, these Appropriate Legal Notices must retain the display of the
* Sonicle logo and Sonicle copyright notice. If the display of the logo is not
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
* display the words "Copyright (C) 2017 Sonicle S.r.l.".
*/
package com.sonicle.webtop.drm;
import com.sonicle.commons.web.json.JsonResult;
import org.joda.time.LocalDate;
/**
*
* @author lssndrvs
*/
public class TimetableSummaryExcelQuery {
public String operatorId;
public Integer companyId;
public LocalDate fromDate;
public LocalDate toDate;
public TimetableSummaryExcelQuery() {
}
public static TimetableSummaryExcelQuery fromJson(String value) {
if (value == null) {
return null;
}
return JsonResult.gson().fromJson(value, TimetableSummaryExcelQuery.class);
}
public static String toJson(TimetableSummaryExcelQuery value) {
if (value == null) {
return null;
}
return JsonResult.gson().toJson(value, TimetableSummaryExcelQuery.class);
}
}
| [
"gbulfon@sonicle.com"
] | gbulfon@sonicle.com |
2e5a8cf87c0d5d4679e02208b5f3fa1db0a2335b | 8ab3fbb764acabef4fc300ed0d94be7aad884c82 | /src/main/java/pl/cwiczenia/restApi/model/Post.java | 5634de41998d6a42ba9cdad74fa4d84aa21a9fb5 | [] | no_license | TeaIceLemon/restApi | d2701efffe014c9c8e9830202eb41791fcfd4003 | 9cecb598e6c1c292e7014d15bae48657fcce37e4 | refs/heads/master | 2023-04-17T09:56:58.061733 | 2021-04-18T19:33:30 | 2021-04-18T19:33:30 | 357,674,617 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 539 | java | package pl.cwiczenia.restApi.model;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Getter
@Setter
public class Post {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String title;
private String content;
private LocalDateTime created;
@OneToMany(cascade = CascadeType.DETACH)
@JoinColumn(name = "postId", updatable = false, insertable = false)
private List<Comment> comment;
}
| [
"piotr.wieczorek1993@gmail.com"
] | piotr.wieczorek1993@gmail.com |
9775749d5c7e5ad962416777bcddc526e3714dfb | 8b6a5bcfa25972bfd9463eabf8b3e4b998fedca8 | /app/build/generated/source/r/release/com/google/android/gms/safetynet/R.java | 1e71bceff9b224ba5710a071490434c05a540807 | [] | no_license | masterUNG/ProjeckMooK | f276c07ba92d26ed3e9c1d89ece6250c2e39caa5 | c50fbfb47cb002f35b0958039e0c6b6b30e8fbc4 | refs/heads/master | 2021-01-10T07:22:22.866837 | 2016-02-18T07:45:04 | 2016-02-18T07:45:04 | 51,973,040 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,443 | java | /* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.google.android.gms.safetynet;
public final class R {
public static final class attr {
public static final int adSize = 0x7f010026;
public static final int adSizes = 0x7f010027;
public static final int adUnitId = 0x7f010028;
public static final int ambientEnabled = 0x7f010050;
public static final int appTheme = 0x7f0100eb;
public static final int buyButtonAppearance = 0x7f0100f2;
public static final int buyButtonHeight = 0x7f0100ef;
public static final int buyButtonText = 0x7f0100f1;
public static final int buyButtonWidth = 0x7f0100f0;
public static final int cameraBearing = 0x7f010041;
public static final int cameraTargetLat = 0x7f010042;
public static final int cameraTargetLng = 0x7f010043;
public static final int cameraTilt = 0x7f010044;
public static final int cameraZoom = 0x7f010045;
public static final int circleCrop = 0x7f01003f;
public static final int environment = 0x7f0100ec;
public static final int fragmentMode = 0x7f0100ee;
public static final int fragmentStyle = 0x7f0100ed;
public static final int imageAspectRatio = 0x7f01003e;
public static final int imageAspectRatioAdjust = 0x7f01003d;
public static final int liteMode = 0x7f010046;
public static final int mapType = 0x7f010040;
public static final int maskedWalletDetailsBackground = 0x7f0100f5;
public static final int maskedWalletDetailsButtonBackground = 0x7f0100f7;
public static final int maskedWalletDetailsButtonTextAppearance = 0x7f0100f6;
public static final int maskedWalletDetailsHeaderTextAppearance = 0x7f0100f4;
public static final int maskedWalletDetailsLogoImageType = 0x7f0100f9;
public static final int maskedWalletDetailsLogoTextColor = 0x7f0100f8;
public static final int maskedWalletDetailsTextAppearance = 0x7f0100f3;
public static final int uiCompass = 0x7f010047;
public static final int uiMapToolbar = 0x7f01004f;
public static final int uiRotateGestures = 0x7f010048;
public static final int uiScrollGestures = 0x7f010049;
public static final int uiTiltGestures = 0x7f01004a;
public static final int uiZoomControls = 0x7f01004b;
public static final int uiZoomGestures = 0x7f01004c;
public static final int useViewLifecycle = 0x7f01004d;
public static final int windowTransitionStyle = 0x7f010031;
public static final int zOrderOnTop = 0x7f01004e;
}
public static final class color {
public static final int common_action_bar_splitter = 0x7f0c0012;
public static final int common_signin_btn_dark_text_default = 0x7f0c0013;
public static final int common_signin_btn_dark_text_disabled = 0x7f0c0014;
public static final int common_signin_btn_dark_text_focused = 0x7f0c0015;
public static final int common_signin_btn_dark_text_pressed = 0x7f0c0016;
public static final int common_signin_btn_default_background = 0x7f0c0017;
public static final int common_signin_btn_light_text_default = 0x7f0c0018;
public static final int common_signin_btn_light_text_disabled = 0x7f0c0019;
public static final int common_signin_btn_light_text_focused = 0x7f0c001a;
public static final int common_signin_btn_light_text_pressed = 0x7f0c001b;
public static final int common_signin_btn_text_dark = 0x7f0c005b;
public static final int common_signin_btn_text_light = 0x7f0c005c;
public static final int wallet_bright_foreground_disabled_holo_light = 0x7f0c0044;
public static final int wallet_bright_foreground_holo_dark = 0x7f0c0045;
public static final int wallet_bright_foreground_holo_light = 0x7f0c0046;
public static final int wallet_dim_foreground_disabled_holo_dark = 0x7f0c0047;
public static final int wallet_dim_foreground_holo_dark = 0x7f0c0048;
public static final int wallet_dim_foreground_inverse_disabled_holo_dark = 0x7f0c0049;
public static final int wallet_dim_foreground_inverse_holo_dark = 0x7f0c004a;
public static final int wallet_highlighted_text_holo_dark = 0x7f0c004b;
public static final int wallet_highlighted_text_holo_light = 0x7f0c004c;
public static final int wallet_hint_foreground_holo_dark = 0x7f0c004d;
public static final int wallet_hint_foreground_holo_light = 0x7f0c004e;
public static final int wallet_holo_blue_light = 0x7f0c004f;
public static final int wallet_link_text_light = 0x7f0c0050;
public static final int wallet_primary_text_holo_light = 0x7f0c005f;
public static final int wallet_secondary_text_holo_dark = 0x7f0c0060;
}
public static final class drawable {
public static final int cast_ic_notification_0 = 0x7f020043;
public static final int cast_ic_notification_1 = 0x7f020044;
public static final int cast_ic_notification_2 = 0x7f020045;
public static final int cast_ic_notification_connecting = 0x7f020046;
public static final int cast_ic_notification_on = 0x7f020047;
public static final int common_full_open_on_phone = 0x7f020049;
public static final int common_ic_googleplayservices = 0x7f02004a;
public static final int common_signin_btn_icon_dark = 0x7f02004b;
public static final int common_signin_btn_icon_disabled_dark = 0x7f02004c;
public static final int common_signin_btn_icon_disabled_focus_dark = 0x7f02004d;
public static final int common_signin_btn_icon_disabled_focus_light = 0x7f02004e;
public static final int common_signin_btn_icon_disabled_light = 0x7f02004f;
public static final int common_signin_btn_icon_focus_dark = 0x7f020050;
public static final int common_signin_btn_icon_focus_light = 0x7f020051;
public static final int common_signin_btn_icon_light = 0x7f020052;
public static final int common_signin_btn_icon_normal_dark = 0x7f020053;
public static final int common_signin_btn_icon_normal_light = 0x7f020054;
public static final int common_signin_btn_icon_pressed_dark = 0x7f020055;
public static final int common_signin_btn_icon_pressed_light = 0x7f020056;
public static final int common_signin_btn_text_dark = 0x7f020057;
public static final int common_signin_btn_text_disabled_dark = 0x7f020058;
public static final int common_signin_btn_text_disabled_focus_dark = 0x7f020059;
public static final int common_signin_btn_text_disabled_focus_light = 0x7f02005a;
public static final int common_signin_btn_text_disabled_light = 0x7f02005b;
public static final int common_signin_btn_text_focus_dark = 0x7f02005c;
public static final int common_signin_btn_text_focus_light = 0x7f02005d;
public static final int common_signin_btn_text_light = 0x7f02005e;
public static final int common_signin_btn_text_normal_dark = 0x7f02005f;
public static final int common_signin_btn_text_normal_light = 0x7f020060;
public static final int common_signin_btn_text_pressed_dark = 0x7f020061;
public static final int common_signin_btn_text_pressed_light = 0x7f020062;
public static final int ic_plusone_medium_off_client = 0x7f020077;
public static final int ic_plusone_small_off_client = 0x7f020078;
public static final int ic_plusone_standard_off_client = 0x7f020079;
public static final int ic_plusone_tall_off_client = 0x7f02007a;
public static final int powered_by_google_dark = 0x7f020088;
public static final int powered_by_google_light = 0x7f020089;
}
public static final class id {
public static final int adjust_height = 0x7f0d001d;
public static final int adjust_width = 0x7f0d001e;
public static final int book_now = 0x7f0d0031;
public static final int buyButton = 0x7f0d002e;
public static final int buy_now = 0x7f0d0032;
public static final int buy_with = 0x7f0d0033;
public static final int buy_with_google = 0x7f0d0034;
public static final int cast_notification_id = 0x7f0d0004;
public static final int classic = 0x7f0d0038;
public static final int donate_with = 0x7f0d0035;
public static final int donate_with_google = 0x7f0d0036;
public static final int google_wallet_classic = 0x7f0d0039;
public static final int google_wallet_grayscale = 0x7f0d003a;
public static final int google_wallet_monochrome = 0x7f0d003b;
public static final int grayscale = 0x7f0d003c;
public static final int holo_dark = 0x7f0d0028;
public static final int holo_light = 0x7f0d0029;
public static final int hybrid = 0x7f0d001f;
public static final int logo_only = 0x7f0d0037;
public static final int match_parent = 0x7f0d0030;
public static final int monochrome = 0x7f0d003d;
public static final int none = 0x7f0d000f;
public static final int normal = 0x7f0d000b;
public static final int production = 0x7f0d002a;
public static final int sandbox = 0x7f0d002b;
public static final int satellite = 0x7f0d0020;
public static final int selectionDetails = 0x7f0d002f;
public static final int slide = 0x7f0d0019;
public static final int strict_sandbox = 0x7f0d002c;
public static final int terrain = 0x7f0d0021;
public static final int test = 0x7f0d002d;
public static final int wrap_content = 0x7f0d0027;
}
public static final class integer {
public static final int google_play_services_version = 0x7f0b0004;
}
public static final class raw {
public static final int gtm_analytics = 0x7f060000;
}
public static final class string {
public static final int accept = 0x7f070037;
public static final int auth_google_play_services_client_facebook_display_name = 0x7f070039;
public static final int auth_google_play_services_client_google_display_name = 0x7f07003a;
public static final int cast_notification_connected_message = 0x7f07003e;
public static final int cast_notification_connecting_message = 0x7f07003f;
public static final int cast_notification_disconnect = 0x7f070040;
public static final int common_android_wear_notification_needs_update_text = 0x7f070011;
public static final int common_android_wear_update_text = 0x7f070012;
public static final int common_android_wear_update_title = 0x7f070013;
public static final int common_google_play_services_api_unavailable_text = 0x7f070014;
public static final int common_google_play_services_enable_button = 0x7f070015;
public static final int common_google_play_services_enable_text = 0x7f070016;
public static final int common_google_play_services_enable_title = 0x7f070017;
public static final int common_google_play_services_error_notification_requested_by_msg = 0x7f070018;
public static final int common_google_play_services_install_button = 0x7f070019;
public static final int common_google_play_services_install_text_phone = 0x7f07001a;
public static final int common_google_play_services_install_text_tablet = 0x7f07001b;
public static final int common_google_play_services_install_title = 0x7f07001c;
public static final int common_google_play_services_invalid_account_text = 0x7f07001d;
public static final int common_google_play_services_invalid_account_title = 0x7f07001e;
public static final int common_google_play_services_needs_enabling_title = 0x7f07001f;
public static final int common_google_play_services_network_error_text = 0x7f070020;
public static final int common_google_play_services_network_error_title = 0x7f070021;
public static final int common_google_play_services_notification_needs_update_title = 0x7f070022;
public static final int common_google_play_services_notification_ticker = 0x7f070023;
public static final int common_google_play_services_sign_in_failed_text = 0x7f070024;
public static final int common_google_play_services_sign_in_failed_title = 0x7f070025;
public static final int common_google_play_services_unknown_issue = 0x7f070026;
public static final int common_google_play_services_unsupported_text = 0x7f070027;
public static final int common_google_play_services_unsupported_title = 0x7f070028;
public static final int common_google_play_services_update_button = 0x7f070029;
public static final int common_google_play_services_update_text = 0x7f07002a;
public static final int common_google_play_services_update_title = 0x7f07002b;
public static final int common_google_play_services_updating_text = 0x7f07002c;
public static final int common_google_play_services_updating_title = 0x7f07002d;
public static final int common_open_on_phone = 0x7f07002e;
public static final int common_signin_button_text = 0x7f070041;
public static final int common_signin_button_text_long = 0x7f070042;
public static final int create_calendar_message = 0x7f070043;
public static final int create_calendar_title = 0x7f070044;
public static final int decline = 0x7f070045;
public static final int store_picture_message = 0x7f07004e;
public static final int store_picture_title = 0x7f07004f;
public static final int wallet_buy_button_place_holder = 0x7f070036;
}
public static final class style {
public static final int Theme_IAPTheme = 0x7f0900e8;
public static final int WalletFragmentDefaultButtonTextAppearance = 0x7f0900f0;
public static final int WalletFragmentDefaultDetailsHeaderTextAppearance = 0x7f0900f1;
public static final int WalletFragmentDefaultDetailsTextAppearance = 0x7f0900f2;
public static final int WalletFragmentDefaultStyle = 0x7f0900f3;
}
public static final class styleable {
public static final int[] AdsAttrs = { 0x7f010026, 0x7f010027, 0x7f010028 };
public static final int AdsAttrs_adSize = 0;
public static final int AdsAttrs_adSizes = 1;
public static final int AdsAttrs_adUnitId = 2;
public static final int[] CustomWalletTheme = { 0x7f010031 };
public static final int CustomWalletTheme_windowTransitionStyle = 0;
public static final int[] LoadingImageView = { 0x7f01003d, 0x7f01003e, 0x7f01003f };
public static final int LoadingImageView_circleCrop = 2;
public static final int LoadingImageView_imageAspectRatio = 1;
public static final int LoadingImageView_imageAspectRatioAdjust = 0;
public static final int[] MapAttrs = { 0x7f010040, 0x7f010041, 0x7f010042, 0x7f010043, 0x7f010044, 0x7f010045, 0x7f010046, 0x7f010047, 0x7f010048, 0x7f010049, 0x7f01004a, 0x7f01004b, 0x7f01004c, 0x7f01004d, 0x7f01004e, 0x7f01004f, 0x7f010050 };
public static final int MapAttrs_ambientEnabled = 16;
public static final int MapAttrs_cameraBearing = 1;
public static final int MapAttrs_cameraTargetLat = 2;
public static final int MapAttrs_cameraTargetLng = 3;
public static final int MapAttrs_cameraTilt = 4;
public static final int MapAttrs_cameraZoom = 5;
public static final int MapAttrs_liteMode = 6;
public static final int MapAttrs_mapType = 0;
public static final int MapAttrs_uiCompass = 7;
public static final int MapAttrs_uiMapToolbar = 15;
public static final int MapAttrs_uiRotateGestures = 8;
public static final int MapAttrs_uiScrollGestures = 9;
public static final int MapAttrs_uiTiltGestures = 10;
public static final int MapAttrs_uiZoomControls = 11;
public static final int MapAttrs_uiZoomGestures = 12;
public static final int MapAttrs_useViewLifecycle = 13;
public static final int MapAttrs_zOrderOnTop = 14;
public static final int[] WalletFragmentOptions = { 0x7f0100eb, 0x7f0100ec, 0x7f0100ed, 0x7f0100ee };
public static final int WalletFragmentOptions_appTheme = 0;
public static final int WalletFragmentOptions_environment = 1;
public static final int WalletFragmentOptions_fragmentMode = 3;
public static final int WalletFragmentOptions_fragmentStyle = 2;
public static final int[] WalletFragmentStyle = { 0x7f0100ef, 0x7f0100f0, 0x7f0100f1, 0x7f0100f2, 0x7f0100f3, 0x7f0100f4, 0x7f0100f5, 0x7f0100f6, 0x7f0100f7, 0x7f0100f8, 0x7f0100f9 };
public static final int WalletFragmentStyle_buyButtonAppearance = 3;
public static final int WalletFragmentStyle_buyButtonHeight = 0;
public static final int WalletFragmentStyle_buyButtonText = 2;
public static final int WalletFragmentStyle_buyButtonWidth = 1;
public static final int WalletFragmentStyle_maskedWalletDetailsBackground = 6;
public static final int WalletFragmentStyle_maskedWalletDetailsButtonBackground = 8;
public static final int WalletFragmentStyle_maskedWalletDetailsButtonTextAppearance = 7;
public static final int WalletFragmentStyle_maskedWalletDetailsHeaderTextAppearance = 5;
public static final int WalletFragmentStyle_maskedWalletDetailsLogoImageType = 10;
public static final int WalletFragmentStyle_maskedWalletDetailsLogoTextColor = 9;
public static final int WalletFragmentStyle_maskedWalletDetailsTextAppearance = 4;
}
}
| [
"phrombutr@gmail.com"
] | phrombutr@gmail.com |
76e4af64f9a35882b6ff16e59cb22c7f52731a60 | 7787cd0012213b23b522c33240bbd16759b55cc1 | /app/src/main/java/com/example/workncardio/Homescreen.java | 21ea1c6f925754f2ab4ea03bf0821f2377285f8b | [] | no_license | savar25/Project | 2df6209ac0c23b0617a25b56b02c364140a34a45 | 149a6de6e4761deae586e4f7c01cd583bacf1584 | refs/heads/master | 2023-06-27T18:58:05.776000 | 2021-08-03T19:49:29 | 2021-08-03T19:49:29 | 290,764,841 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 29,167 | java | package com.example.workncardio;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.graphics.drawable.IconCompat;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import android.Manifest;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.provider.MediaStore;
import android.util.Log;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.example.databases.UserDets;
import com.example.databases.UserInfo;
import com.example.workncardio.dummy.ColourItem;
import com.example.workncardio.dummy.ProfileItem;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.dialog.MaterialDialogs;
import com.google.android.material.navigation.NavigationView;
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.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Array;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
public class Homescreen extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener,ProfileFragment.NavigListener,cardio_cal_fragment.ButtonListener,workoutFragment.BacktoOriginal,calorie_foodFragment.modif {
private static final int IMAGE_CAPTURE_CODE =1001 ;
private static final int IMAGE_PICK=1002;
DrawerLayout drawerLayout;
NavigationView navigationView;
ActionBarDrawerToggle actionBarDrawerToggle;
Toolbar toolbar;
FragmentManager manager;
FragmentTransaction transaction;
public static String USER_NAME;
public static Integer setup;
Double kcal;
TextView prof,name,id;
UserDets userDets;
ImageView cam_image,colour;
ImageButton camBtn;
Uri image_uri;
SharedPreferences picPref;
SharedPreferences.Editor editor;
Bitmap thumbnail;
OutputStream outputStream;
ConstraintLayout nav_layout;
Integer[] integers=new Integer[]{
R.drawable.ic_box1,
R.drawable.ic_box2,
R.drawable.ic_box3,
R.drawable.ic_box4
};
String[] strings=new String[]{
"Grey",
"Blue",
"Orange",
"Green"
};
private static final String TAG = "Homescreen";
private int request_code=100;
FirebaseDatabase firebaseDatabase=FirebaseDatabase.getInstance();
DatabaseReference reference=firebaseDatabase.getReference("Users");
UserInfo baseInfo;
Intent intent;
String cho="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_homescreen);
setTitle("Home");
userDets=new UserDets(this);
if(workoutFragment.mediaPlayer!=null) {
workoutFragment.mediaPlayer.stop();
}
intent=getIntent();
USER_NAME=intent.getStringExtra("Name1");
Log.d(TAG, "onCreate: "+USER_NAME);
drawerLayout = findViewById(R.id.drawer);
navigationView = findViewById(R.id.navigation_view);
navigationView.setNavigationItemSelectedListener(this);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
actionBarDrawerToggle = new ActionBarDrawerToggle(Homescreen.this, drawerLayout, toolbar, R.string.open, R.string.close);
drawerLayout.addDrawerListener(actionBarDrawerToggle);
actionBarDrawerToggle.setDrawerIndicatorEnabled(true);
actionBarDrawerToggle.syncState();
manager = getSupportFragmentManager();
transaction = manager.beginTransaction();
transaction.replace(R.id.container, new ProfileFragment());
transaction.setCustomAnimations(R.anim.right_entry,R.anim.right_exit);
transaction.commit();
getSupportFragmentManager().beginTransaction().replace(R.id.profile_container, new stepFragment()).setCustomAnimations(R.anim.right_entry,R.anim.right_exit).commit();
drawerLayout.closeDrawer(GravityCompat.START);
NavigationView navigationView=findViewById(R.id.navigation_view);
View header=navigationView.getHeaderView(0);
prof=header.findViewById(R.id.prof_icon);
name=header.findViewById(R.id.nav_name);
id=header.findViewById(R.id.nav_id);
cam_image=header.findViewById(R.id.cam_image);
camBtn=header.findViewById(R.id.camButton);
nav_layout=header.findViewById(R.id.nav_header_layout);
colour=header.findViewById(R.id.backGround);
camBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final ArrayList<ProfileItem> profileItems=new ArrayList<>();
if(!baseInfo.isPic()) {
profileItems.add(new ProfileItem("From Camera", R.drawable.ic_menu_camera));
profileItems.add(new ProfileItem("From Gallery", R.drawable.ic_menu_gallery));
}else{
profileItems.add(new ProfileItem("From Camera", R.drawable.ic_menu_camera));
profileItems.add(new ProfileItem("From Gallery", R.drawable.ic_menu_gallery));
profileItems.add(new ProfileItem("Remove Profile Picture",R.drawable.ic_cross));
}
ListAdapter adapter=new ArrayAdapter<ProfileItem>(Homescreen.this,android.R.layout.select_dialog_item,android.R.id.text1,profileItems){
public View getView(int position, View convertView, ViewGroup parent) {
//Use super class to create the View
View v = super.getView(position, convertView, parent);
TextView tv = (TextView)v.findViewById(android.R.id.text1);
//Put the image on the TextView
tv.setCompoundDrawablesWithIntrinsicBounds(profileItems.get(position).getIcon(), 0, 0, 0);
tv.setText(profileItems.get(position).getText());
tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,18);
//Add margin between image and text (support various screen densities)
int dp5 = (int) (5 * getResources().getDisplayMetrics().density + 0.5f);
tv.setCompoundDrawablePadding(dp5);
return v;
}
};
AlertDialog.Builder builder=new AlertDialog.Builder(Homescreen.this);
builder.setTitle("Set Profile Image");
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
switch (i){
case 0:
Intent photoClick=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(photoClick,IMAGE_CAPTURE_CODE);
break;
case 1:
Intent photoPick=new Intent(Intent.ACTION_PICK);
photoPick.setType("image/*");
startActivityForResult(photoPick,IMAGE_PICK);
break;
case 2:
baseInfo.setPic(false);
reference.child(baseInfo.getID()).setValue(baseInfo);
drawerLayout.closeDrawer(GravityCompat.START);
checkProfImage();
}
}
});
AlertDialog alertDialog=builder.create();
alertDialog.show();
}
});
colour.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final ArrayList<ProfileItem> profileItems=new ArrayList<>();
for( int i=0;i<4;i++){
profileItems.add(new ProfileItem(strings[i],integers[i]));
}
ListAdapter adapter=new ArrayAdapter<ProfileItem>(Homescreen.this,android.R.layout.select_dialog_item,android.R.id.text1,profileItems){
public View getView(int position, View convertView, ViewGroup parent) {
//Use super class to create the View
View v = super.getView(position, convertView, parent);
TextView tv = (TextView)v.findViewById(android.R.id.text1);
//Put the image on the TextView
tv.setCompoundDrawablesWithIntrinsicBounds(profileItems.get(position).getIcon(), 0, 0, 0);
tv.setText(profileItems.get(position).getText());
tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,18);
//Add margin between image and text (support various screen densities)
int dp5 = (int) (5 * getResources().getDisplayMetrics().density + 0.5f);
tv.setCompoundDrawablePadding(dp5);
return v;
}
};
AlertDialog.Builder builder=new AlertDialog.Builder(Homescreen.this);
builder.setTitle("Set Profile Image");
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
switch (i){
case 0:
nav_layout.setBackgroundColor(Color.parseColor("#DDDDDD"));
break;
case 1:
nav_layout.setBackgroundColor(Color.parseColor("#8aebdd"));
break;
case 2:
nav_layout.setBackgroundColor(Color.parseColor("#DD973e"));
break;
case 3:
nav_layout.setBackgroundColor(Color.parseColor("#32dd24"));
break;
}
baseInfo.setBackground(i);
reference.child(baseInfo.getID()).setValue(baseInfo);
}
});
AlertDialog alertDialog=builder.create();
alertDialog.show();
}
});
}
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
if(workoutFragment.mediaPlayer!=null){
workoutFragment.mediaPlayer.stop();
workoutFragment.cancelNotifications();
workoutFragment.sendonchannel3(new View(this),"Workout Stopped",2);
}
switch (item.getItemId()) {
case R.id.drawer_profile:
manager = getSupportFragmentManager();
transaction = manager.beginTransaction();
transaction.replace(R.id.container, new ProfileFragment());
transaction.setCustomAnimations(R.anim.right_entry,R.anim.right_exit);
transaction.commit();
getSupportFragmentManager().beginTransaction().replace(R.id.profile_container, new stepFragment()).setCustomAnimations(R.anim.right_entry,R.anim.right_exit).commit();
drawerLayout.closeDrawer(GravityCompat.START);
break;
case R.id.drawer_calorie:
manager = getSupportFragmentManager();
transaction = manager.beginTransaction();
transaction.replace(R.id.container, new CalorieFragment());
transaction.setCustomAnimations(R.anim.right_entry,R.anim.right_exit);
transaction.commit();
setTitle("Calorie Charts");
drawerLayout.closeDrawer(GravityCompat.START);
break;
case R.id.drawer_screen:
manager = getSupportFragmentManager();
transaction = manager.beginTransaction();
transaction.replace(R.id.container, new ScreenFragment());
transaction.setCustomAnimations(R.anim.right_entry,R.anim.right_exit);
transaction.commit();
setTitle("Manage Sleep");
drawerLayout.closeDrawer(GravityCompat.START);
break;
case R.id.cardio:
manager = getSupportFragmentManager();
transaction = manager.beginTransaction();
transaction.replace(R.id.container, new CardioFragment());
transaction.setCustomAnimations(R.anim.right_entry,R.anim.right_exit);
transaction.commit();
setTitle("Cardio");
drawerLayout.closeDrawer(GravityCompat.START);
getSupportFragmentManager().beginTransaction().add(R.id.cardio_container,new cardio_cal_fragment()).setCustomAnimations(R.anim.right_entry,R.anim.right_exit).commit();
break;
case R.id.logout:
Intent intent=new Intent(this,login.class);
intent.putExtra("logVal",0);
Intent intent1=new Intent(this,StepService.class);
stopService(intent1);
startActivity(intent);
}
return true;
}
@Override
public void onBackPressed() {
if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
drawerLayout.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public void onItemSelected(int ID) {
switch (ID) {
case R.id.steps:
getSupportFragmentManager().beginTransaction().replace(R.id.profile_container, new stepFragment()).setCustomAnimations(R.anim.left_entry,R.anim.right_exit).commit();
break;
case R.id.analysis:
getSupportFragmentManager().beginTransaction().replace(R.id.profile_container, new analysisFragment()).commit();
break;
case R.id.goal:
getSupportFragmentManager().beginTransaction().replace(R.id.profile_container, new goalChange()).setCustomAnimations(R.anim.right_entry,R.anim.right_exit).commit();
break;
}
}
@Override
public void onPress(int choice, Double kcal) {
getSupportFragmentManager().beginTransaction().replace(R.id.cardio_container,new workoutFragment(choice,kcal,0)).setCustomAnimations(R.anim.right_entry,R.anim.right_exit).commit();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == IMAGE_PICK) {
if (resultCode == RESULT_OK) {
try {
Uri image_uri = data.getData();
InputStream imageStream = getContentResolver().openInputStream(image_uri);
Bitmap selectedImage = BitmapFactory.decodeStream(imageStream);
cam_image.setImageBitmap(selectedImage);
setImage();
checkProfImage();
} catch (FileNotFoundException f) {
f.printStackTrace();
}
}
} else if (requestCode == IMAGE_CAPTURE_CODE) {
if (resultCode == RESULT_OK) {
onCaptureImageResult(data);
Log.d(TAG, "onActivityResult: "+data.getData());
checkProfImage();
}
}
super.onActivityResult(requestCode, resultCode, data);
}
public void onCaptureImageResult(Intent intent){
thumbnail=(Bitmap)intent.getExtras().get("data");
cam_image.setImageBitmap(thumbnail);
setImage();
}
public void checkProfImage(){
if(!baseInfo.isPic()){
prof.setVisibility(View.VISIBLE);
cam_image.setVisibility(View.GONE);
}else if(baseInfo.isPic()){
prof.setVisibility(View.GONE);
cam_image.setVisibility(View.VISIBLE);
setProfilePic();
}
}
public void setImage(){
Log.d(TAG, "setImage: called");
BitmapDrawable drawable=(BitmapDrawable)cam_image.getDrawable();
Bitmap bitmap=drawable.getBitmap();
File filepath= Environment.getExternalStorageDirectory();
File dir=new File(getFilesDir(),"Profile");
if(dir.exists() && dir.isDirectory()) {
Log.d(TAG, "setImage: "+dir.exists());
File imageFile = new File(dir, "profile.jpg");
try {
outputStream = new FileOutputStream(imageFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
Toast.makeText(this, "Image Saved", Toast.LENGTH_SHORT).show();
baseInfo.setPic(true);
reference.child(baseInfo.getID()).setValue(baseInfo);
try {
outputStream.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void setProfilePic(){
File file=new File(getFilesDir(),"Profile");
File main=new File(file,"profile.jpg");
try {
Bitmap bm=BitmapFactory.decodeStream(new FileInputStream(main));
cam_image.setImageBitmap(bm);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public void setBack(){
switch (baseInfo.getBackground()){
case 0:
nav_layout.setBackgroundColor(Color.parseColor("#DDDDDD"));
break;
case 1:
nav_layout.setBackgroundColor(Color.parseColor("#8aebdd"));
break;
case 2:
nav_layout.setBackgroundColor(Color.parseColor("#DD973e"));
break;
case 3:
nav_layout.setBackgroundColor(Color.parseColor("#32dd24"));
break;
}
}
@Override
public void goBack(Double kcal) {
getSupportFragmentManager().beginTransaction().replace(R.id.cardio_container,new cardio_cal_fragment()).setCustomAnimations(R.anim.right_entry,R.anim.right_exit).commit();
}
public void setShortcut(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutManager shortcutManager=(ShortcutManager)getSystemService(Context.SHORTCUT_SERVICE);
final Intent intent1=new Intent(this,Homescreen.class);
intent1.putExtra("Name1",Homescreen.USER_NAME);
intent1.setAction("step");
final Intent intent2=new Intent(this,Homescreen.class);
intent2.putExtra("Name1",Homescreen.USER_NAME);
intent2.setAction("cardio");
final Intent intent3=new Intent(this,Homescreen.class);
intent3.putExtra("Name1",Homescreen.USER_NAME);
intent3.setAction("analysis");
ShortcutInfo shortcut1=new ShortcutInfo.Builder(this,"STEPS")
.setShortLabel("Get Steps")
.setLongLabel("Get Today's Steps")
.setIcon(Icon.createWithResource(this,R.drawable.step_shortcut_icon_blue))
.setIntent(intent1)
.build();
ShortcutInfo shortcut2=new ShortcutInfo.Builder(this,"ANALYSIS")
.setShortLabel("Get Analysis")
.setLongLabel("Get Net Analysis")
.setIcon(Icon.createWithResource(this,R.drawable.analysis_blue))
.setIntent(intent3)
.build();
ShortcutInfo shortcut3=new ShortcutInfo.Builder(this,"CARDIO")
.setShortLabel("Go Cardio")
.setLongLabel("Go Cardio")
.setIcon(Icon.createWithResource(this,R.drawable.heart1_blue))
.setIntent(intent2)
.build();
List<ShortcutInfo> shortcutInfoList=new ArrayList<>();
shortcutInfoList.add(shortcut1);
shortcutInfoList.add(shortcut2);
shortcutInfoList.add(shortcut3);
shortcutManager.addDynamicShortcuts(shortcutInfoList);
}
}
public void handleAction(String action){
switch (action){
case "step":
manager = getSupportFragmentManager();
transaction = manager.beginTransaction();
transaction.replace(R.id.container, new ProfileFragment());
transaction.setCustomAnimations(R.anim.right_entry,R.anim.right_exit);
transaction.commit();
setTitle("Home");
getSupportFragmentManager().beginTransaction().replace(R.id.profile_container, new stepFragment()).commit();
drawerLayout.closeDrawer(GravityCompat.START);
break;
case "cardio":
manager = getSupportFragmentManager();
transaction = manager.beginTransaction();
transaction.replace(R.id.container, new CardioFragment());
transaction.setCustomAnimations(R.anim.right_entry,R.anim.right_exit);
transaction.commit();
setTitle("Cardio");
drawerLayout.closeDrawer(GravityCompat.START);
getSupportFragmentManager().beginTransaction().add(R.id.cardio_container,new cardio_cal_fragment()).commit();
break;
case "analysis":
manager = getSupportFragmentManager();
transaction = manager.beginTransaction();
transaction.replace(R.id.container, new ProfileFragment())
.setCustomAnimations(R.anim.right_entry,R.anim.right_exit);
transaction.commit();
setTitle("Home");
getSupportFragmentManager().beginTransaction().replace(R.id.profile_container, new analysisFragment()).commit();
drawerLayout.closeDrawer(GravityCompat.START);
}
}
@Override
public void onModify() {
getSupportFragmentManager().beginTransaction().replace(R.id.container,new CalorieFragment() ).commit();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater=getMenuInflater();
inflater.inflate(R.menu.option_menu,menu);
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()){
case R.id.settings:
manager = getSupportFragmentManager();
transaction = manager.beginTransaction();
transaction.replace(R.id.container, new version());
setTitle("Version");
transaction.setCustomAnimations(R.anim.right_entry,R.anim.right_exit);
transaction.commit();
}
return true;
}
@Override
protected void onStart() {
super.onStart();
if(intent.getStringExtra("fragment")!=null) {
cho = intent.getStringExtra("fragment");
}else {
cho="";
}
kcal=intent.getDoubleExtra("kcal",0.0);
setup=intent.getIntExtra("setup",0);
reference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
for(DataSnapshot snapshot1:snapshot.getChildren()){
UserInfo info=snapshot1.getValue(UserInfo.class);
if(info.getName().equals(USER_NAME)){
baseInfo=info;
Log.d(TAG, "onCreate: "+baseInfo);
Log.d(TAG, "onDataChange: called");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
setupMain();
}
},2000);
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
Intent intent = new Intent(this, StepService.class);
stopService(intent);
Log.d(TAG, "onCreate: intent");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent);
}else {
startService(intent);
}
}
public void setupMain(){
prof.setText(USER_NAME.substring(0,1));
name.setText(String.valueOf(USER_NAME));
id.setText(String.valueOf(baseInfo.geteID()));
checkProfImage();
setBack();
Log.d(TAG, "onCreate: "+ USER_NAME);
switch (cho){
case "workout":
manager = getSupportFragmentManager();
transaction = manager.beginTransaction();
transaction.add(R.id.container, new CardioFragment());
transaction.setCustomAnimations(R.anim.right_entry,R.anim.right_exit);
transaction.commit();
setTitle("Workout");
getSupportFragmentManager().beginTransaction().add(R.id.cardio_container,new workoutFragment(setup,kcal,intent.getIntExtra("stepCount",0))).commit();
break;
case "def":
manager = getSupportFragmentManager();
transaction = manager.beginTransaction();
transaction.add(R.id.container, new ProfileFragment());
transaction.setCustomAnimations(R.anim.right_entry,R.anim.right_exit);
transaction.commit();
getSupportFragmentManager().beginTransaction().add(R.id.profile_container, new stepFragment()).commit();
break;
case "Cardio":
manager = getSupportFragmentManager();
transaction = manager.beginTransaction();
transaction.add(R.id.container, new CardioFragment());
transaction.setCustomAnimations(R.anim.right_entry,R.anim.right_exit);
transaction.commit();
setTitle("Cardio");
getSupportFragmentManager().beginTransaction().add(R.id.cardio_container,new cardio_cal_fragment()).commit();
break;
}
setShortcut();
handleAction(intent.getAction());
}
} | [
"41923689+savar25@users.noreply.github.com"
] | 41923689+savar25@users.noreply.github.com |
063ed616cc57ba47013669cb050ce664e84bf9dc | 5774e32ee46cad7ce2c1b1b0ad055d4dd99fd574 | /teach/teach-common/src/main/java/cn/logicalthinking/common/util/SmsCodeGen.java | 2c51ac3901cd99c485e2980eafe1abeafcee2e13 | [] | no_license | hsjadmin/text | e467ab8ee94ca099409afbbc5759824589c1338f | 5d8afda1811b38a392c61ed163c492a34716ba4e | refs/heads/master | 2020-05-25T03:35:16.440342 | 2019-05-20T09:00:05 | 2019-05-20T09:00:05 | 187,603,856 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 237 | java | package cn.logicalthinking.common.util;
/**
* 验证码生成
* @author XHX
* @date 2018/10/10
*/
public class SmsCodeGen {
public static String getCode() {
return (int) ((Math.random() * 9 + 1) * 100000) + "";
}
}
| [
"1907377985@qq.com"
] | 1907377985@qq.com |
4c12e265f8337adc54ea20b5fce731c6ad7581cf | d60743b3efccf6b0cc50b82019e859cb14524a99 | /src/main/java/com/puzzlers/chap04/exceptionalpuzzlers/Puzzle39HelloGoodbye.java | 7e5682d71afed7401b502b8f88747de3d187d418 | [] | no_license | shubozhang/java-puzzlers | 7821d6278829c68513b8c92133f8ab375842169e | 29b5e605c5724e429f2b4dfc3bb9c6af9842c2c6 | refs/heads/master | 2021-03-19T11:34:37.673532 | 2017-09-05T20:19:57 | 2017-09-05T20:19:57 | 61,046,509 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 351 | java | package com.puzzlers.chap04.exceptionalpuzzlers;
/**
* Created by Shubo on 10/23/2016.
*/
public class Puzzle39HelloGoodbye {
public static void main(String[] args) {
try {
System.out.println("Hello world");
System.exit(0);
} finally {
System.out.println("Goodbye world");
}
}
}
| [
"bryanshubo@gmail.com"
] | bryanshubo@gmail.com |
57045a8b3b088ebc6776296092652451e8bbadf4 | 2eee509a34f8ef404322ef1ff1700d72b29f471d | /src/main/java/com/wbyweb/bolg/po/Shuoshuo.java | a4232fa5c98d4bb61f531d87454795537ba03a2e | [
"MIT"
] | permissive | blog-wby/springboot-bolg | 6aec677ad5198d98250c1963a65275be073a6d8c | 7f5dfe9f026c4abfd116e9d11f4528ab287782a2 | refs/heads/master | 2020-04-03T05:19:25.653781 | 2018-10-28T07:19:15 | 2018-10-28T07:19:15 | 155,041,879 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,168 | java | package com.wbyweb.bolg.po;
public class Shuoshuo {
private Integer shuoId;
private Integer userId;
private Integer shuoTime;
private String shuoIp;
private String shuoshuo;
private Byte typeId;
public Integer getShuoId() {
return shuoId;
}
public void setShuoId(Integer shuoId) {
this.shuoId = shuoId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getShuoTime() {
return shuoTime;
}
public void setShuoTime(Integer shuoTime) {
this.shuoTime = shuoTime;
}
public String getShuoIp() {
return shuoIp;
}
public void setShuoIp(String shuoIp) {
this.shuoIp = shuoIp == null ? null : shuoIp.trim();
}
public String getShuoshuo() {
return shuoshuo;
}
public void setShuoshuo(String shuoshuo) {
this.shuoshuo = shuoshuo == null ? null : shuoshuo.trim();
}
public Byte getTypeId() {
return typeId;
}
public void setTypeId(Byte typeId) {
this.typeId = typeId;
}
} | [
"weibiaoyi@126.com"
] | weibiaoyi@126.com |
9fe5ef8cb66b471d6c4b4b3e6adbbc3d67f0477e | c45ad9c7c1a1a24b5fa6a3bfa6ce9400f15497a6 | /Java_Basics/list/src/S.java | c3cb96a03117c0b85be12b6268a051c1872881e0 | [] | no_license | vishwasnavadak/javaprogramming | a95a54395b969d6540456df973fbdda88fd9107b | 9a9e0062acaa93a2d9e115fe5407784e3f89568d | refs/heads/master | 2021-01-22T02:21:32.933993 | 2016-04-13T09:21:51 | 2016-04-13T09:21:51 | 56,131,416 | 2 | 0 | null | 2016-04-13T07:41:53 | 2016-04-13T07:41:53 | null | UTF-8 | Java | false | false | 940 | java | import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
class ListDemo implements ListSelectionListener
{
JList<String>jlist;
JLabel l;
JScrollPane jp;
String city[]={"India","USA","SA","AUS"};
ListDemo()
{
JFrame jfrm=new JFrame("List Event");
jfrm.setLayout(new FlowLayout());
jfrm.setSize(300,300);
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jlist=new JList<String>(city);
jlist.addListSelectionListener(this);
jp=new JScrollPane(jlist);
jp.setPreferredSize(new Dimension(90,120));
jfrm.add(jp);
l=new JLabel("Select a city");
jfrm.add(l);
jfrm.setVisible(true);
}
public void valueChanged(ListSelectionEvent le)
{
int i=jlist.getSelectedIndex();
if(i!=-1)
{
l.setText("Selected country is "+city[i]);
}
else
{
l.setText("No value");
}
}
}
public class S
{
public static void main(String args[])
{
ListDemo l=new ListDemo();
}
}
| [
"manju.mpsn@gmail.com"
] | manju.mpsn@gmail.com |
6cd6be7adaffef916397207f966780479cb1524a | 1a313c4d5921beafcf5fb87e343eade0d5981580 | /src/main/java/com/search/dto/backend/ValueList.java | 62ffaad8dc6b867b7e9a66cef31d56cd2be82156 | [] | no_license | rdnaidu/SprongRESTSecurity | a5045510455d978eab1965d22d3d3cafa79e0522 | e743036679e9f3bfa52a900f454010f6f30d6325 | refs/heads/master | 2022-05-24T12:13:03.410625 | 2019-08-07T06:11:43 | 2019-08-07T06:11:43 | 221,551,216 | 0 | 0 | null | 2022-05-20T21:15:13 | 2019-11-13T21:03:25 | Java | UTF-8 | Java | false | false | 1,364 | java |
package com.search.dto.backend;
import com.fasterxml.jackson.annotation.*;
import java.util.HashMap;
import java.util.Map;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"exclude",
"type",
"value"
})
public class ValueList {
@JsonProperty("exclude")
private Boolean exclude;
@JsonProperty("type")
private String type;
@JsonProperty("value")
private String value;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<>();
@JsonProperty("exclude")
public Boolean getExclude() {
return exclude;
}
@JsonProperty("exclude")
public void setExclude(Boolean exclude) {
this.exclude = exclude;
}
@JsonProperty("type")
public String getType() {
return type;
}
@JsonProperty("type")
public void setType(String type) {
this.type = type;
}
@JsonProperty("value")
public String getValue() {
return value;
}
@JsonProperty("value")
public void setValue(String value) {
this.value = value;
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}
}
| [
"antonio1313@gmail.com"
] | antonio1313@gmail.com |
77670b56b69e2b0b0bc811570aab7e9dc85e51ee | db528d657d05c533d4d6f08924c4ddf7576e8a23 | /src/jasbro/game/character/battle/DefenderData.java | 43f07dee2a3adbec350bb62f1c525e3509d4bef6 | [] | no_license | Crystal-Line/JaSBro | deae8050f7ce10e1244b8a42b2e4fe409bb4aeae | cec1029fbbd8b34008b2923e9236a74033802447 | refs/heads/master | 2020-05-28T01:59:56.660514 | 2019-06-02T17:02:16 | 2019-06-02T17:02:16 | 188,848,810 | 0 | 2 | null | 2019-06-02T17:02:17 | 2019-05-27T13:29:54 | Java | UTF-8 | Java | false | false | 75 | java | package jasbro.game.character.battle;
public class DefenderData {
}
| [
"jackwrenn@comcast.net"
] | jackwrenn@comcast.net |
7b15b0966fe27fdb540ef527f52aa23baf4a8472 | 9e8f3b5319d38a4f7701b64928850169edbb67af | /src/main/java/bizchoollab/roomEscape/repository/BookingRepository.java | 25b2e8fb8949b058837adc7dbb0faff0c1dd62e4 | [] | no_license | yoongyo/Spring-RoomEscape | c98cf026b1cf8da89ae9c3c8afd6b70363528308 | 4e6980ba18d0d73d6777497a7c345128b9aeac44 | refs/heads/main | 2023-07-13T05:37:37.121914 | 2021-08-29T16:18:45 | 2021-08-29T16:18:45 | 400,716,042 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 326 | java | package bizchoollab.roomEscape.repository;
import bizchoollab.roomEscape.entity.Booking;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface BookingRepository extends JpaRepository<Booking, Long> {
List<Booking> findBookingsByRoomEscapeName(String roomEscape_name);
}
| [
"33406406+yoongyo@users.noreply.github.com"
] | 33406406+yoongyo@users.noreply.github.com |
2d07561da1ed46272ee40ea40e39438cf37998fb | 51fa3cc281eee60058563920c3c9059e8a142e66 | /Java/src/testcases/CWE80_XSS/s02/CWE80_XSS__Servlet_URLConnection_45.java | 357c7046742c07f785d2a71e95b41166ac4761e6 | [] | no_license | CU-0xff/CWE-Juliet-TestSuite-Java | 0b4846d6b283d91214fed2ab96dd78e0b68c945c | f616822e8cb65e4e5a321529aa28b79451702d30 | refs/heads/master | 2020-09-14T10:41:33.545462 | 2019-11-21T07:34:54 | 2019-11-21T07:34:54 | 223,105,798 | 1 | 4 | null | null | null | null | UTF-8 | Java | false | false | 4,719 | java | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE80_XSS__Servlet_URLConnection_45.java
Label Definition File: CWE80_XSS__Servlet.label.xml
Template File: sources-sink-45.tmpl.java
*/
/*
* @description
* CWE: 80 Cross Site Scripting (XSS)
* BadSource: URLConnection Read data from a web server with URLConnection
* GoodSource: A hardcoded string
* Sinks:
* BadSink : Display of data in web page without any encoding or validation
* Flow Variant: 45 Data flow: data passed as a private class member variable from one function to another in the same class
*
* */
package testcases.CWE80_XSS.s02;
import testcasesupport.*;
import javax.servlet.http.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.logging.Level;
public class CWE80_XSS__Servlet_URLConnection_45 extends AbstractTestCaseServlet
{
private String dataBad;
private String dataGoodG2B;
private void badSink(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
String data = dataBad;
if (data != null)
{
/* POTENTIAL FLAW: Display of data in web page without any encoding or validation */
response.getWriter().println("<br>bad(): data = " + data);
}
}
/* uses badsource and badsink */
public void bad(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
String data;
data = ""; /* Initialize data */
/* read input from URLConnection */
{
URLConnection urlConnection = (new URL("http://www.example.org/")).openConnection();
BufferedReader readerBuffered = null;
InputStreamReader readerInputStream = null;
try
{
readerInputStream = new InputStreamReader(urlConnection.getInputStream(), "UTF-8");
readerBuffered = new BufferedReader(readerInputStream);
/* POTENTIAL FLAW: Read data from a web server with URLConnection */
/* This will be reading the first "line" of the response body,
* which could be very long if there are no newlines in the HTML */
data = readerBuffered.readLine();
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
}
finally
{
/* clean up stream reading objects */
try
{
if (readerBuffered != null)
{
readerBuffered.close();
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO);
}
try
{
if (readerInputStream != null)
{
readerInputStream.close();
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO);
}
}
}
dataBad = data;
badSink(request, response);
}
public void good(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
goodG2B(request, response);
}
private void goodG2BSink(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
String data = dataGoodG2B;
if (data != null)
{
/* POTENTIAL FLAW: Display of data in web page without any encoding or validation */
response.getWriter().println("<br>bad(): data = " + data);
}
}
/* goodG2B() - use goodsource and badsink */
private void goodG2B(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
String data;
/* FIX: Use a hardcoded string */
data = "foo";
dataGoodG2B = data;
goodG2BSink(request, response);
}
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
public static void main(String[] args) throws ClassNotFoundException,
InstantiationException, IllegalAccessException
{
mainFromParent(args);
}
}
| [
"frank@fischer.com.mt"
] | frank@fischer.com.mt |
055b9c8eb2ecfff9c06932847ed95b44653635fc | 682fd0e5be76fe1fdaeda9f4af9aabc4c322e6b8 | /BotaniaEnderTransport/src/main/java/trainerredstone7/botaniaendertransport/block/subtile/SubTileEnderLavender.java | 117f184302ce698684039550e608ca8f4e5eb5d6 | [
"MIT"
] | permissive | Trainerredstone7/BotaniaEnderTransport | 4d338f270884b7b33b72d0331daec87617a057cd | 45df3b2ba1b85618149576a8d63da26388642d2a | refs/heads/master | 2023-03-29T11:33:14.734862 | 2021-04-06T07:01:36 | 2021-04-06T07:01:36 | 342,133,316 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,370 | java | package trainerredstone7.botaniaendertransport.block.subtile;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import trainerredstone7.botaniaendertransport.BotaniaEnderTransport;
import trainerredstone7.botaniaendertransport.EnderLavenderTeleporter;
import vazkii.botania.api.mana.IManaItem;
import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.TileEntityFunctionalFlower;
import vazkii.botania.common.network.PacketBotaniaEffect;
import vazkii.botania.common.network.PacketHandler;
import vazkii.botania.mixin.AccessorItemEntity;
public class SubTileEnderLavender extends TileEntityFunctionalFlower {
private static final int COST = 24;
private static final int RANGE = 2;
public SubTileEnderLavender() {
super(BotaniaEnderTransport.ENDER_LAVENDER_TILE.get());
}
@Override
public void tickFlower() {
super.tickFlower();
if (!getWorld().isRemote) {
ServerWorld destination;
RegistryKey<World> worldKey = getWorld().getDimensionKey();
if (worldKey == World.THE_END) destination = getWorld().getServer().getWorld(World.OVERWORLD);
else if (worldKey == World.OVERWORLD) destination = getWorld().getServer().getWorld(World.THE_END);
else return;
if (redstoneSignal == 0 && destination.isBlockLoaded(getEffectivePos())) {
BlockPos pos = getEffectivePos();
boolean did = false;
List<ItemEntity> items = getWorld().getEntitiesWithinAABB(
ItemEntity.class,
new AxisAlignedBB(pos.add(-RANGE, -RANGE, -RANGE),
pos.add(RANGE + 1, RANGE + 1, RANGE + 1)));
int slowdown = getSlowdownFactor();
for (ItemEntity item : items) {
int age = ((AccessorItemEntity) item).getAge();
if (age < 60 + slowdown || !item.isAlive()) {
continue;
}
ItemStack stack = item.getItem();
if (!stack.isEmpty()) {
Item sitem = stack.getItem();
if (sitem instanceof IManaItem) {
continue;
}
int cost = stack.getCount() * COST;
if (getMana() >= cost) {
spawnExplosionParticles(item, 10);
item.changeDimension(destination, EnderLavenderTeleporter.getInstance());
item.setMotion(Vector3d.ZERO);
spawnExplosionParticles(item, 10);
addMana(-cost);
did = true;
}
}
}
if (did) {
sync();
}
}
}
}
static void spawnExplosionParticles(Entity item, int p) {
PacketHandler.sendToNearby(item.world, item.getPosition(), new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.ITEM_SMOKE, item.getPosX(), item.getPosY(), item.getPosZ(), item.getEntityId(), p));
}
@Override
public RadiusDescriptor getRadius() {
return new RadiusDescriptor.Square(getEffectivePos(), RANGE);
}
@Override
public boolean acceptsRedstone() {
return true;
}
@Override
public int getColor() {
return 0xB544E6;
}
@Override
public int getMaxMana() {
return 16000;
}
}
| [
"trainerredstone7@gmail.com"
] | trainerredstone7@gmail.com |
eabe043901738a3ecc0113435c79606a3e2456a4 | 58d4fdf03133183cb67c24aae95662e42579554d | /src/main/java/com/soraxus/prisons/enchants/api/enchant/EnchantInfo.java | a3adb8e315a47d99908a917420d6d9275b527b09 | [] | no_license | mattlack15/PrisonCore | e2aa969293efaff0812e898cda90d17dac06b880 | 9895aa6c246d0064dbc9b01f72ae5cd8661b9758 | refs/heads/master | 2023-06-21T17:10:25.909666 | 2021-08-01T04:17:35 | 2021-08-01T04:17:35 | 374,835,952 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 235 | java | package com.soraxus.prisons.enchants.api.enchant;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Map;
@AllArgsConstructor
@Getter
public class EnchantInfo {
private Map<AbstractCE, Integer> enchants;
}
| [
"unconfigured@null.spigotmc.org"
] | unconfigured@null.spigotmc.org |
ef56a9a9f1ba0d03e031b139c1bbcd39a12a6d09 | 24d8cf871b092b2d60fc85d5320e1bc761a7cbe2 | /DrJava/rev3734-3807/base-trunk-3734/src/edu/rice/cs/util/swing/FileChooser.java | 6f6a7139d381d4e31d9b6066c5cddeef0c6b8cc7 | [] | no_license | joliebig/featurehouse_fstmerge_examples | af1b963537839d13e834f829cf51f8ad5e6ffe76 | 1a99c1788f0eb9f1e5d8c2ced3892d00cd9449ad | refs/heads/master | 2016-09-05T10:24:50.974902 | 2013-03-28T16:28:47 | 2013-03-28T16:28:47 | 9,080,611 | 3 | 2 | null | null | null | null | UTF-8 | Java | false | false | 899 | java |
package edu.rice.cs.util.swing;
import edu.rice.cs.util.FileOps;
import edu.rice.cs.util.swing.Utilities;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileView;
import java.awt.Component;
public class FileChooser extends JFileChooser {
protected File _root;
public FileChooser(File root) {
super(root);
_init(root);
}
private void _init(final File root) {
_root = root;
if (root != null) {
if (! root.exists()) _root = null;
else if (! root.isDirectory()) _root = root.getParentFile();
}
setFileSelectionMode(FILES_ONLY);
setDialogType(CUSTOM_DIALOG);
setApproveButtonText("Select");
}
public boolean isTraversable(File f) {
if (_root == null) return super.isTraversable(f);
return f != null && f.isDirectory() && FileOps.isInFileTree(f, _root);
}
}
| [
"joliebig@fim.uni-passau.de"
] | joliebig@fim.uni-passau.de |
d200fc710e9a48465874f0dadfaf3d8b4d968533 | f2fad2e550e947b53d4ba152ec8b35d79f35ab44 | /PlayU/src/dao/impl/ManagerDaoImp.java | 3212ed0448b27fd2c9c1b51428e372f4fca6bf68 | [] | no_license | HuiHuiXD/Web-Project | 8bb318efe7df62f7c78fa86cdc6cbe78b74a43bf | 86b6f942e2ded06cba86490e4d7761fac7280563 | refs/heads/master | 2020-03-17T23:08:57.535144 | 2019-04-20T14:21:17 | 2019-04-20T14:21:17 | 134,033,232 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,132 | java | /*
* Copyright (c) PlayU
* 2018-5-19
* by YSH
*/
package dao.impl;
import bean.Manager;
import bean.User;
import dao.UserDao;
import org.hibernate.Session;
import org.hibernate.query.Query;
import util.HibernateSessionFactory;
import java.util.List;
public class ManagerDaoImp implements UserDao {
@Override
public User get(int id) {
Session session = HibernateSessionFactory.getSession();
Manager manager = (Manager) session.get(Manager.class, id);
session.getTransaction().commit();
HibernateSessionFactory.closeSession();
return manager;
}
@Override
public void modifyPass(User manager, String pass) {
Session session = HibernateSessionFactory.getSession();
session.update(manager);
session.getTransaction().commit();
session.close();
}
@Override
public void save(User manager) {
Session session = HibernateSessionFactory.getSession();
session.save(manager);
session.getTransaction().commit();
HibernateSessionFactory.closeSession();
}
@Override
public void delete(int id) {
Session session = HibernateSessionFactory.getSession();
Manager user = session.get(Manager.class,id);
session.delete(user);
session.getTransaction().commit();
HibernateSessionFactory.closeSession();
}
@Override
public List<User> selectAll() {
Session session = HibernateSessionFactory.getSession();
String hql = "from Manager";
List<User> list = session.createQuery(hql).list();
session.getTransaction().commit();
HibernateSessionFactory.closeSession();
return list;
}
@Override
public List<User> search(String parse) {
Session session = HibernateSessionFactory.getSession();
String hql = "from Manager where name like ?";
//设置参数'?'为parse
Query query = session.createQuery(hql).setParameter(0, parse);
List<User> list = query.list();
session.getTransaction().commit();
session.close();
return list;
}
}
| [
"shaohui_yuan0_0@163.com"
] | shaohui_yuan0_0@163.com |
9708bb5c0b533ea90b726911eba00b946893458e | 5ecd15baa833422572480fad3946e0e16a389000 | /framework/MPS-Open/subsystems/runtime/main/api/java/com/volantis/mps/session/pool/SessionValidator.java | 0e61e1f9d073e725c5b4272bc4725484359f5614 | [] | no_license | jabley/volmobserverce | 4c5db36ef72c3bb7ef20fb81855e18e9b53823b9 | 6d760f27ac5917533eca6708f389ed9347c7016d | refs/heads/master | 2021-01-01T05:31:21.902535 | 2009-02-04T02:29:06 | 2009-02-04T02:29:06 | 38,675,289 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 7,352 | java | /*
This file is part of Volantis Mobility Server.
Volantis Mobility Server 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.
Volantis Mobility Server 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 Volantis Mobility Server. If not, see <http://www.gnu.org/licenses/>.
*/
/* ----------------------------------------------------------------------------
* (c) Volantis Systems Ltd 2007.
* ----------------------------------------------------------------------------
*/
package com.volantis.mps.session.pool;
import org.smpp.Data;
import org.smpp.Session;
import org.smpp.SmppException;
import org.smpp.pdu.EnquireLinkResp;
import com.volantis.mps.localization.LocalizationFactory;
import com.volantis.synergetics.log.LogDispatcher;
import java.io.IOException;
import java.util.Iterator;
/**
* Regularly checks (at specified intervals) that the sessions in the supplied
* pool are still valid (by sending EnquireLink PDUs to the SMSC).
*/
public class SessionValidator implements Runnable {
/**
* Used for logging.
*/
private static final LogDispatcher LOGGER =
LocalizationFactory.createLogger(SessionValidator.class);
/**
* Pool whose sessions should be regularly validated.
*/
private final SessionPool sessionPool;
/**
* Flag which indicates that the validator should wait forever i.e.
* not check.
*/
public static final int WAIT_FOREVER = -1;
/**
* The interval at which the sessions should be validated in ms (Defaults
* to waiting forever).
*/
protected int validationInterval = WAIT_FOREVER;
/**
* Initialize a new instance using the given parameters.
*
* @param sessionPool whose contents to validate
* @param validationInterval the time to sleep between checking the
* sessions' state.
*/
public SessionValidator(SessionPool sessionPool, int validationInterval) {
this.sessionPool = sessionPool;
this.validationInterval = validationInterval;
}
public void run() {
// Only bother starting to check if a non infinite interval has been
// specified.
if (validationInterval != WAIT_FOREVER) {
// Once started should keep checking forever.
while (true) {
try {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("SessionValidator will now sleep for " +
validationInterval + " ms");
}
Thread.sleep(validationInterval);
} catch (InterruptedException e) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("SessionValidator was interrupted", e);
}
}
try {
synchronized (sessionPool) {
// Note when the sweep started...
long timer = System.currentTimeMillis();
// Go through the pool and check that all the available
// borrowable objects are still valid.
Iterator i = sessionPool.iterator();
while (i.hasNext()) {
Session session = (Session)i.next();
validateSession(session);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Finished checking sessions: [took "
+ (System.currentTimeMillis() - timer)
+ " ms]");
}
}
} catch (Exception e) {
LOGGER.warn("An exception occurred while validating " +
"sessions - ignoring", e);
}
}
}
}
/**
* Validate the supplied {@link Session} by sending an EnquireLink PDU.
* NB: When running MPS asynchronously, sessions will always appear to be
* invalid as they don't respond synchronously.
*
* @param session to be validated
* @throws Exception if there was a problem validating the session
*/
private void validateSession(Session session) throws Exception {
// If a valid EnquireLinkResponse is not received, then the session is
// considered to be invalid. NB: this will always be the case when MPS
// is communicating asynchronously with the SMSC.
if (!sendEnquireLink(session)) {
// The session is no longer valid and should be removed from the
// pool. A new one will be created when it is next needed.
sessionPool.invalidateObject(session);
} else {
// Session is still valid
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Session "+ session + " is still valid");
}
}
}
/**
* This method attempts to send an EnquireLink PDU over a bound Session to
* an SMSC. Returns true if an valid EnquireLinkResponse PDU is recieved in
* response, and false otherwise.
* <p/>
* NB: the response will always be null when MPS is communicating
* asynchronously with the SMSC.
*
* @param session for which to send an enquireLink PDU
* @return true if a valid EnquireLinkResponse was received and false
* otherwise
*/
public static boolean sendEnquireLink(Session session) {
boolean valid = false;
if (session != null) {
EnquireLinkResp enquireResp = null;
try {
enquireResp = session.enquireLink();
} catch (SmppException e) {
LOGGER.error("SmppException while sending EnquireLink PDU", e);
} catch (IOException e) {
LOGGER.error("IOException while sending EnquireLink PDU", e);
}
if (enquireResp != null) {
valid = enquireResp.getCommandStatus() == Data.ESME_ROK;
if (!valid) {
LOGGER.warn("Unexpected response to EnquireLink PDU: " +
enquireResp.debugString());
}
} else {
LOGGER.error("No response to the EnquireLink PDU - may be " +
"communicating asynchronously or the session " +
"may be invalid");
}
}
return valid;
}
/**
* Retrieve the interval at which all the sessions in the pool will be
* revalidated by this session validator.
*
* @return int the interval at which all the sessions in the pool will be
* revalidated by this session validator.
*/
public int getValidationInterval() {
return validationInterval;
}
}
| [
"iwilloug@b642a0b7-b348-0410-9912-e4a34d632523"
] | iwilloug@b642a0b7-b348-0410-9912-e4a34d632523 |
46ffd1f30b8374210c3dbc86c3147a71dd2b6706 | edeb76ba44692dff2f180119703c239f4585d066 | /libGPE/src-test/org/gvsig/gpe/containers/Curve.java | 3bfc768e77137b6ec54006ab04a3e07baed9d02b | [] | no_license | CafeGIS/gvSIG2_0 | f3e52bdbb98090fd44549bd8d6c75b645d36f624 | 81376f304645d040ee34e98d57b4f745e0293d05 | refs/heads/master | 2020-04-04T19:33:47.082008 | 2012-09-13T03:55:33 | 2012-09-13T03:55:33 | 5,685,448 | 2 | 1 | null | null | null | null | ISO-8859-1 | Java | false | false | 2,288 | java | package org.gvsig.gpe.containers;
import java.util.ArrayList;
/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
*
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
*
* For more information, contact:
*
* Generalitat Valenciana
* Conselleria d'Infraestructures i Transport
* Av. Blasco Ibáñez, 50
* 46010 VALENCIA
* SPAIN
*
* +34 963862235
* gvsig@gva.es
* www.gvsig.gva.es
*
* or
*
* IVER T.I. S.A
* Salamanca 50
* 46005 Valencia
* Spain
*
* +34 963163400
* dac@iver.es
*/
/**
* This class represetnts a Curve
* @author Jorge Piera LLodrá (jorge.piera@iver.es)
*/
public class Curve extends Geometry {
private ArrayList coordinates = null;
private ArrayList segments = null;
public Curve(){
segments = new ArrayList();
coordinates = new ArrayList();
}
/**
* Adds a segment
* @param segment
* The segment to add
*/
public void addSegment(LineString segment){
segments.add(segment);
}
/**
* Gets a segment
* @param i
* The segment position
* @return
* A Segment
*/
public LineString getSegmentAt(int i){
return (LineString)segments.get(i);
}
/**
* @return the number of seg
*/
public int getSegmentsSize(){
return segments.size();
}
public void addCoordinate(double[] coordinate){
coordinates.add(coordinate);
}
public double geCoordinateAt(int index, int dimension){
return ((double[])(coordinates.get(index)))[dimension];
}
public int getCoordinatesNumber(){
return coordinates.size();
}
}
| [
"tranquangtruonghinh@gmail.com"
] | tranquangtruonghinh@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.