blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 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
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
83a3ff5188985c4084b5839abfca29216b60471a | a2fb1776a53ea89c76246fb634cb3cb30740e990 | /src/main/java/com/danny/bot/handler/TypingEventHandler.java | 8c4e28ea36d733e303bad37e568ecc69a68b0c38 | [] | no_license | dannyhn/DiscoBot | 1e073ca5b85d7e3b581789b30d27fb318f4d0541 | 75c1be72e2bffdcbe046523a5b6d01bea9b2abdf | refs/heads/master | 2021-01-11T18:44:52.768312 | 2018-03-19T23:48:00 | 2018-03-19T23:48:00 | 79,616,723 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,227 | java | package com.danny.bot.handler;
import java.util.Random;
import com.danny.bot.service.RandomWordService;
import com.danny.bot.util.MessageUtil;
import com.danny.bot.util.UserUtil;
import sx.blah.discord.handle.obj.IChannel;
import sx.blah.discord.handle.obj.IUser;
/**
* @author Danny
*
*/
public class TypingEventHandler {
private static long time = 1;
private static final long FIFTEENSECONDS = 15000;
public void handleTypingEvent(IChannel channel, IUser user) {
long currentTime = System.currentTimeMillis();
if (currentTime - time > FIFTEENSECONDS) {
String insult = typingInsult(UserUtil.getName(user, channel.getGuild()));
time = currentTime;
MessageUtil.sendMessage(channel, insult, null, false);
}
}
private String typingInsult(String userName) {
Random random = new Random();
int randInt = random.nextInt(3);
switch(randInt) {
case 0:
return userName + " types slower than a " + RandomWordService.getInstance().randomAnimal();
case 1:
return "does " + userName + " know that you can type with two hands";
case 2:
return userName + " types so god damn much";
default:
return userName + " sucks cows";
}
}
}
| [
"[email protected]"
] | |
171e2a752c6062ea7a82768e3fda08e7b96ec270 | 8191908d9aeb5c77da3c4f5599393f6349ba028b | /src/Model/AlunosDAO.java | e8d09ed8a0d7038de1bd1a903bc50038f9f578c9 | [] | no_license | humbertoftneto/SistemaUniversidade | bad2f43246c5126372cd33dd132df531f4a6e6dc | f411fd1baf1022e49f5f8c49d2262f31b07d631f | refs/heads/master | 2020-09-30T19:37:34.965148 | 2019-12-11T18:06:42 | 2019-12-11T18:06:42 | 227,358,393 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,471 | java | package Model;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
public class AlunosDAO {
private static AlunosDAO instance;
private AlunosDAO() {
MySQLDAO.getConnection();
}
public static AlunosDAO getInstance() {
if (instance == null) {
instance = new AlunosDAO();
}
return instance;
}
public long create(AlunosBEAN aluno) {
String query = "INSERT INTO aluno (nomeAluno, cpfAluno, situacaoAluno, ultimaAtualizacao) VALUES (?,?,?,?)";
return MySQLDAO.executeQuery(query, aluno.getNomeAluno(), aluno.getCpfAluno(), aluno.getSituacaoAluno(), aluno.getUltimaAtualizacao());
}
public void update(AlunosBEAN aluno) {
String query = "UPDATE aluno SET nomeAluno=?, cpfAluno=?, situacaoAluno=?, ultimaAtualizacao=? WHERE matriculaAluno = ?";
MySQLDAO.executeQuery(query, aluno.getNomeAluno(), aluno.getCpfAluno(), aluno.getSituacaoAluno(), aluno.getUltimaAtualizacao(), aluno.getMatriculaAluno());
}
public ArrayList<AlunosBEAN> findAllAluno() {
return listaAlunos("SELECT * FROM aluno ORDER BY matriculaAluno");
}
public ArrayList<AlunosBEAN> listaAlunos(String query) {
ArrayList<AlunosBEAN> lista = new ArrayList<AlunosBEAN>();
ResultSet rs = null;
rs = MySQLDAO.getResultSet(query);
try {
while (rs.next()) {
lista.add(new AlunosBEAN(rs.getInt("matriculaAluno"), rs.getString("nomeAluno"), rs.getString("cpfAluno"), rs.getInt("situacaoAluno"), rs.getTimestamp("ultimaAtualizacao")));
}
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
return lista;
}
public AlunosBEAN findAluno(int matriculaAluno) {
AlunosBEAN result = null;
ResultSet rs = null;
rs = MySQLDAO.getResultSet("SELECT * FROM aluno WHERE matriculaAluno=?", matriculaAluno);
try {
if (rs.next()) {
result = new AlunosBEAN(rs.getInt("matriculaAluno"), rs.getString("nomeAluno"), rs.getString("cpfAluno"), rs.getInt("situacaoAluno"), rs.getTimestamp("ultimaAtualizacao"));
}
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result;
}
public int findMatriculaAluno(AlunosBEAN aluno) {
int result = 0;
ResultSet rs = null;
rs = MySQLDAO.getResultSet("SELECT * FROM aluno WHERE nomeAluno= ? and cpfAluno= ? and situacaoAluno= ? and ultimaAtualizacao=?", aluno.getNomeAluno(), aluno.getCpfAluno(), aluno.getSituacaoAluno(), aluno.getUltimaAtualizacao());
try {
if (rs.next()) {
result = rs.getInt("matriculaAluno");
}
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result;
}
public Boolean isExistAluno(int matriculaAluno) {
Boolean result = false;
ResultSet rs = null;
rs = MySQLDAO.getResultSet("SELECT * FROM aluno WHERE matriculaAluno= ?", matriculaAluno);
try {
if (rs.next()) {
result = true;
}
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result;
}
}
| [
"[email protected]"
] | |
2d7f717f18a533392985e6ce4ba33351c18d2428 | dee07d3c83cd020a6a9faaf2a51a61f890098cac | /RetinexTheoryProject/src/retinextheoryproject/gui/RetinexTheoryProject.java | a9ef8776c7e99e0775f542c3d6cc000e866fcb6d | [] | no_license | krf12/Uni-Projects | fac4c0d820aca0e731444931a5617bc69e953b22 | 84795969f227465253e8ee829886d9367455c4a9 | refs/heads/master | 2016-09-05T19:03:23.642082 | 2015-01-25T15:20:18 | 2015-01-25T15:20:18 | 6,663,099 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 579 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package retinextheoryproject.gui;
import java.awt.*;
import java.awt.image.*;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
/**
*
* @author Kit
*/
public class RetinexTheoryProject {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
String filename = "Jellyfish.jpg";
MainFrame mf = new MainFrame(filename);
}
}
| [
"[email protected]"
] | |
73d574dc7729a25eeee9d859cce87d712b39b98b | 0d6ea46c83a6f28b9751ad3cf1ace7bb4e777a5d | /sibad_repo_cert_sibad/src/main/java/gob/osinergmin/sibad/domain/builder/AlcanceAcreditacionBuilder.java | c2e99239cc9bff4eb0900387f0af294a17510b8d | [] | no_license | stevecerdan/SIGUO | 00c08830aaba7f60e11f208123deb77979b45093 | 6566ab0dbeeccd767536ecc40c9fdc7c3b5d7069 | refs/heads/master | 2020-03-08T06:23:28.151263 | 2018-07-15T02:39:23 | 2018-07-15T02:39:23 | 127,970,819 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,182 | java | package gob.osinergmin.sibad.domain.builder;
import java.util.ArrayList;
import java.util.List;
import gob.osinergmin.sibad.domain.PghAlcanceAcreditacion;
import gob.osinergmin.sibad.domain.dto.AlcanceAcreditacionDTO;
public class AlcanceAcreditacionBuilder {
public static List<AlcanceAcreditacionDTO> toListAlcanceAcreditacionDto(List<PghAlcanceAcreditacion> lista) {
AlcanceAcreditacionDTO registroDTO;
List<AlcanceAcreditacionDTO> retorno = new ArrayList<AlcanceAcreditacionDTO>();
if (lista != null) {
for (PghAlcanceAcreditacion maestro : lista) {
registroDTO = toRegistrarAlcanceAcreditacion(maestro);
retorno.add(registroDTO);
}
}
return retorno;
}
public static AlcanceAcreditacionDTO toAlcanceAcreditacionDTO(PghAlcanceAcreditacion registro) {
AlcanceAcreditacionDTO registroDTO = new AlcanceAcreditacionDTO();
registroDTO.setIdAlcanceAcreditacion(registro.getIdAlcanceAcreditacion());
registroDTO.setEstado(registro.getEstado());
registroDTO.setEstadoAccion(registro.getEstadoAccion());
return registroDTO;
}
public static AlcanceAcreditacionDTO toRegistrarAlcanceAcreditacion(PghAlcanceAcreditacion registro) {
AlcanceAcreditacionDTO registroDTO = new AlcanceAcreditacionDTO();
registroDTO.setIdAlcanceAcreditacion(registro.getIdAlcanceAcreditacion());
registroDTO.setIdEmpresaAcreditada(registro.getIdEmpresaAcreditada());
registroDTO.setIdTipoPrueba(registro.getIdTipoPrueba());
registroDTO.setIdOrganismoAcreditador(registro.getIdOrganismoAcreditador());
registroDTO.setResolucionCedula(registro.getResolucionCedula());
registroDTO.setIdPrimerAlcanceAcreditacion(registro.getIdPrimerAlcanceAcreditacion());
registroDTO.setIdDocumentoAdjunto(registro.getIdDocumentoAdjunto());
registroDTO.setIdDocumentoAlcanceAcreditada(registro.getIdDocumentoAlcanceAcreditada());
registroDTO.setIdTipoOrganismo(registro.getIdTipoOrganismo());
registroDTO.setNormaEvualada(registro.getNormaEvualada());
registroDTO.setFechaAcreditacion(registro.getFechaAcreditacion());
registroDTO.setFechaUltimaActualizacion(registro.getFechaUltimaActualizacion());
registroDTO.setFechaInicioVigencia(registro.getFechaInicioVigencia());
registroDTO.setFechaVencimiento(registro.getFechaVencimiento());
registroDTO.setEstado(registro.getEstado());
registroDTO.setEstadoAccion(registro.getEstadoAccion());
return registroDTO;
}
public static PghAlcanceAcreditacion getAlcanceAcreditacion(AlcanceAcreditacionDTO registroDTO) {
PghAlcanceAcreditacion registro = null;
if(registroDTO!=null){
registro=new PghAlcanceAcreditacion();
registro.setIdAlcanceAcreditacion(registroDTO.getIdAlcanceAcreditacion());
registro.setIdEmpresaAcreditada(registroDTO.getIdEmpresaAcreditada());
registro.setIdTipoPrueba(registroDTO.getIdTipoPrueba());
registro.setIdOrganismoAcreditador(registroDTO.getIdOrganismoAcreditador());
registro.setResolucionCedula(registroDTO.getResolucionCedula());
registro.setIdPrimerAlcanceAcreditacion(registroDTO.getIdPrimerAlcanceAcreditacion());
registro.setIdDocumentoAdjunto(registroDTO.getIdDocumentoAdjunto());
registro.setIdDocumentoAlcanceAcreditada(registroDTO.getIdDocumentoAlcanceAcreditada());
registro.setIdTipoOrganismo(registroDTO.getIdTipoOrganismo());
registro.setNormaEvualada(registroDTO.getNormaEvualada());
registro.setFechaUltimaActualizacion(registroDTO.getFechaUltimaActualizacion());
registro.setFechaAcreditacion(registroDTO.getFechaAcreditacion());
registro.setFechaVencimiento(registroDTO.getFechaVencimiento());
registro.setFechaInicioVigencia(registroDTO.getFechaInicioVigencia());
registro.setEstado(registroDTO.getEstado());
registro.setEstadoAccion(registroDTO.getEstadoAccion());
}
return registro;
}
}
| [
"[email protected]"
] | |
50cfa417e84d3fc58f50146dc4d47f08f94cffd5 | fdd4cc6f8b5a473c0081af5302cb19c34433a0cf | /src/modules/agrega/ModificadorWeb/src/main/java/es/pode/modificador/presentacion/pendientes/ListadoSubmitFormImpl.java | 08c1e16a81363ab9c5051a3cd17f8436defdd35f | [] | no_license | nwlg/Colony | 0170b0990c1f592500d4869ec8583a1c6eccb786 | 07c908706991fc0979e4b6c41d30812d861776fb | refs/heads/master | 2021-01-22T05:24:40.082349 | 2010-12-23T14:49:00 | 2010-12-23T14:49:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 25,683 | java | // license-header java merge-point
package es.pode.modificador.presentacion.pendientes;
public class ListadoSubmitFormImpl
extends org.apache.struts.validator.ValidatorForm
implements java.io.Serializable
, es.pode.modificador.presentacion.pendientes.IniciarTareaForm
, es.pode.modificador.presentacion.pendientes.SubmitForm
, es.pode.modificador.presentacion.pendientes.SelectActionForm
{
private es.pode.modificador.negocio.servicio.ConfiguracionTarea tarea;
private java.lang.Object[] tareaValueList;
private java.lang.Object[] tareaLabelList;
private java.util.List identificadores;
private java.lang.Object[] identificadoresValueList;
private java.lang.Object[] identificadoresLabelList;
private java.lang.String action;
private java.lang.Object[] actionValueList;
private java.lang.Object[] actionLabelList;
private java.lang.String tipoBusqueda;
private java.lang.Object[] tipoBusquedaValueList;
private java.lang.Object[] tipoBusquedaLabelList;
private java.util.List idModificacionRowSelection = null;
private java.lang.Object[] idModificacionValueList;
private java.lang.Object[] idModificacionLabelList;
private java.lang.String idiomaBuscador;
private java.lang.Object[] idiomaBuscadorValueList;
private java.lang.Object[] idiomaBuscadorLabelList;
public ListadoSubmitFormImpl()
{
}
/**
* Resets the given <code>tarea</code>.
*/
public void resetTarea()
{
this.tarea = null;
}
public void setTarea(es.pode.modificador.negocio.servicio.ConfiguracionTarea tarea)
{
this.tarea = tarea;
}
/**
*
*/
public es.pode.modificador.negocio.servicio.ConfiguracionTarea getTarea()
{
return this.tarea;
}
public java.lang.Object[] getTareaBackingList()
{
java.lang.Object[] values = this.tareaValueList;
java.lang.Object[] labels = this.tareaLabelList;
if (values == null || values.length == 0)
{
return values;
}
if (labels == null || labels.length == 0)
{
labels = values;
}
final int length = java.lang.Math.min(labels.length, values.length);
java.lang.Object[] backingList = new java.lang.Object[length];
for (int i=0; i<length; i++)
{
backingList[i] = new LabelValue(labels[i], values[i]);
}
return backingList;
}
public java.lang.Object[] getTareaValueList()
{
return this.tareaValueList;
}
public void setTareaValueList(java.lang.Object[] tareaValueList)
{
this.tareaValueList = tareaValueList;
}
public java.lang.Object[] getTareaLabelList()
{
return this.tareaLabelList;
}
public void setTareaLabelList(java.lang.Object[] tareaLabelList)
{
this.tareaLabelList = tareaLabelList;
}
public void setTareaBackingList(java.util.Collection items, java.lang.String valueProperty, java.lang.String labelProperty)
{
if (valueProperty == null || labelProperty == null)
{
throw new IllegalArgumentException("ListadoSubmitFormImpl.setTareaBackingList requires non-null property arguments");
}
this.tareaValueList = null;
this.tareaLabelList = null;
if (items != null)
{
this.tareaValueList = new java.lang.Object[items.size()];
this.tareaLabelList = new java.lang.Object[items.size()];
try
{
int i = 0;
for (java.util.Iterator iterator = items.iterator(); iterator.hasNext(); i++)
{
final java.lang.Object item = iterator.next();
this.tareaValueList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, valueProperty);
this.tareaLabelList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, labelProperty);
}
}
catch (Exception ex)
{
throw new java.lang.RuntimeException("ListadoSubmitFormImpl.setTareaBackingList encountered an exception", ex);
}
}
}
/**
* Resets the given <code>identificadores</code>.
*/
public void resetIdentificadores()
{
this.identificadores = null;
}
public void setIdentificadores(java.util.List identificadores)
{
this.identificadores = identificadores;
}
/**
*
*/
public java.util.List getIdentificadores()
{
return this.identificadores;
}
public void setIdentificadoresAsArray(Object[] identificadores)
{
this.identificadores = (identificadores == null) ? null : java.util.Arrays.asList(identificadores);
}
/**
* Returns this collection as an array, if the collection itself would be <code>null</code> this method
* will also return <code>null</code>.
*
* @see es.pode.modificador.presentacion.pendientes.ListadoSubmitFormImpl#getIdentificadores
*/
public java.lang.Object[] getIdentificadoresAsArray()
{
return (identificadores == null) ? null : identificadores.toArray();
}
public java.lang.Object[] getIdentificadoresBackingList()
{
java.lang.Object[] values = this.identificadoresValueList;
java.lang.Object[] labels = this.identificadoresLabelList;
if (values == null || values.length == 0)
{
return values;
}
if (labels == null || labels.length == 0)
{
labels = values;
}
final int length = java.lang.Math.min(labels.length, values.length);
java.lang.Object[] backingList = new java.lang.Object[length];
for (int i=0; i<length; i++)
{
backingList[i] = new LabelValue(labels[i], values[i]);
}
return backingList;
}
public java.lang.Object[] getIdentificadoresValueList()
{
return this.identificadoresValueList;
}
public void setIdentificadoresValueList(java.lang.Object[] identificadoresValueList)
{
this.identificadoresValueList = identificadoresValueList;
}
public java.lang.Object[] getIdentificadoresLabelList()
{
return this.identificadoresLabelList;
}
public void setIdentificadoresLabelList(java.lang.Object[] identificadoresLabelList)
{
this.identificadoresLabelList = identificadoresLabelList;
}
public void setIdentificadoresBackingList(java.util.Collection items, java.lang.String valueProperty, java.lang.String labelProperty)
{
if (valueProperty == null || labelProperty == null)
{
throw new IllegalArgumentException("ListadoSubmitFormImpl.setIdentificadoresBackingList requires non-null property arguments");
}
this.identificadoresValueList = null;
this.identificadoresLabelList = null;
if (items != null)
{
this.identificadoresValueList = new java.lang.Object[items.size()];
this.identificadoresLabelList = new java.lang.Object[items.size()];
try
{
int i = 0;
for (java.util.Iterator iterator = items.iterator(); iterator.hasNext(); i++)
{
final java.lang.Object item = iterator.next();
this.identificadoresValueList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, valueProperty);
this.identificadoresLabelList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, labelProperty);
}
}
catch (Exception ex)
{
throw new java.lang.RuntimeException("ListadoSubmitFormImpl.setIdentificadoresBackingList encountered an exception", ex);
}
}
}
/**
* Resets the given <code>action</code>.
*/
public void resetAction()
{
this.action = null;
}
public void setAction(java.lang.String action)
{
this.action = action;
}
/**
*
*/
public java.lang.String getAction()
{
return this.action;
}
public java.lang.Object[] getActionBackingList()
{
java.lang.Object[] values = this.actionValueList;
java.lang.Object[] labels = this.actionLabelList;
if (values == null || values.length == 0)
{
return values;
}
if (labels == null || labels.length == 0)
{
labels = values;
}
final int length = java.lang.Math.min(labels.length, values.length);
java.lang.Object[] backingList = new java.lang.Object[length];
for (int i=0; i<length; i++)
{
backingList[i] = new LabelValue(labels[i], values[i]);
}
return backingList;
}
public java.lang.Object[] getActionValueList()
{
return this.actionValueList;
}
public void setActionValueList(java.lang.Object[] actionValueList)
{
this.actionValueList = actionValueList;
}
public java.lang.Object[] getActionLabelList()
{
return this.actionLabelList;
}
public void setActionLabelList(java.lang.Object[] actionLabelList)
{
this.actionLabelList = actionLabelList;
}
public void setActionBackingList(java.util.Collection items, java.lang.String valueProperty, java.lang.String labelProperty)
{
if (valueProperty == null || labelProperty == null)
{
throw new IllegalArgumentException("ListadoSubmitFormImpl.setActionBackingList requires non-null property arguments");
}
this.actionValueList = null;
this.actionLabelList = null;
if (items != null)
{
this.actionValueList = new java.lang.Object[items.size()];
this.actionLabelList = new java.lang.Object[items.size()];
try
{
int i = 0;
for (java.util.Iterator iterator = items.iterator(); iterator.hasNext(); i++)
{
final java.lang.Object item = iterator.next();
this.actionValueList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, valueProperty);
this.actionLabelList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, labelProperty);
}
}
catch (Exception ex)
{
throw new java.lang.RuntimeException("ListadoSubmitFormImpl.setActionBackingList encountered an exception", ex);
}
}
}
/**
* Resets the given <code>tipoBusqueda</code>.
*/
public void resetTipoBusqueda()
{
this.tipoBusqueda = null;
}
public void setTipoBusqueda(java.lang.String tipoBusqueda)
{
this.tipoBusqueda = tipoBusqueda;
}
/**
*
*/
public java.lang.String getTipoBusqueda()
{
return this.tipoBusqueda;
}
public java.lang.Object[] getTipoBusquedaBackingList()
{
java.lang.Object[] values = this.tipoBusquedaValueList;
java.lang.Object[] labels = this.tipoBusquedaLabelList;
if (values == null || values.length == 0)
{
return values;
}
if (labels == null || labels.length == 0)
{
labels = values;
}
final int length = java.lang.Math.min(labels.length, values.length);
java.lang.Object[] backingList = new java.lang.Object[length];
for (int i=0; i<length; i++)
{
backingList[i] = new LabelValue(labels[i], values[i]);
}
return backingList;
}
public java.lang.Object[] getTipoBusquedaValueList()
{
return this.tipoBusquedaValueList;
}
public void setTipoBusquedaValueList(java.lang.Object[] tipoBusquedaValueList)
{
this.tipoBusquedaValueList = tipoBusquedaValueList;
}
public java.lang.Object[] getTipoBusquedaLabelList()
{
return this.tipoBusquedaLabelList;
}
public void setTipoBusquedaLabelList(java.lang.Object[] tipoBusquedaLabelList)
{
this.tipoBusquedaLabelList = tipoBusquedaLabelList;
}
public void setTipoBusquedaBackingList(java.util.Collection items, java.lang.String valueProperty, java.lang.String labelProperty)
{
if (valueProperty == null || labelProperty == null)
{
throw new IllegalArgumentException("ListadoSubmitFormImpl.setTipoBusquedaBackingList requires non-null property arguments");
}
this.tipoBusquedaValueList = null;
this.tipoBusquedaLabelList = null;
if (items != null)
{
this.tipoBusquedaValueList = new java.lang.Object[items.size()];
this.tipoBusquedaLabelList = new java.lang.Object[items.size()];
try
{
int i = 0;
for (java.util.Iterator iterator = items.iterator(); iterator.hasNext(); i++)
{
final java.lang.Object item = iterator.next();
this.tipoBusquedaValueList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, valueProperty);
this.tipoBusquedaLabelList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, labelProperty);
}
}
catch (Exception ex)
{
throw new java.lang.RuntimeException("ListadoSubmitFormImpl.setTipoBusquedaBackingList encountered an exception", ex);
}
}
}
/**
* Resets the given <code>idModificacionRowSelection</code>.
*/
public void resetIdModificacion()
{
this.idModificacionRowSelection = null;
}
public void setIdModificacionRowSelection(java.util.List idModificacionRowSelection)
{
this.idModificacionRowSelection = idModificacionRowSelection;
}
public java.util.List getIdModificacionRowSelection()
{
return this.idModificacionRowSelection;
}
public void setIdModificacionRowSelectionAsArray(java.lang.String[] idModificacionRowSelection)
{
this.idModificacionRowSelection = (idModificacionRowSelection == null) ? null : java.util.Arrays.asList(idModificacionRowSelection);
}
public java.lang.String[] getIdModificacionRowSelectionAsArray()
{
return (idModificacionRowSelection == null) ? null : (java.lang.String[])idModificacionRowSelection.toArray(new java.lang.String[idModificacionRowSelection.size()]);
}
public java.lang.Object[] getIdModificacionBackingList()
{
java.lang.Object[] values = this.idModificacionValueList;
java.lang.Object[] labels = this.idModificacionLabelList;
if (values == null || values.length == 0)
{
return values;
}
if (labels == null || labels.length == 0)
{
labels = values;
}
final int length = java.lang.Math.min(labels.length, values.length);
java.lang.Object[] backingList = new java.lang.Object[length];
for (int i=0; i<length; i++)
{
backingList[i] = new LabelValue(labels[i], values[i]);
}
return backingList;
}
public java.lang.Object[] getIdModificacionValueList()
{
return this.idModificacionValueList;
}
public void setIdModificacionValueList(java.lang.Object[] idModificacionValueList)
{
this.idModificacionValueList = idModificacionValueList;
}
public java.lang.Object[] getIdModificacionLabelList()
{
return this.idModificacionLabelList;
}
public void setIdModificacionLabelList(java.lang.Object[] idModificacionLabelList)
{
this.idModificacionLabelList = idModificacionLabelList;
}
public void setIdModificacionBackingList(java.util.Collection items, java.lang.String valueProperty, java.lang.String labelProperty)
{
if (valueProperty == null || labelProperty == null)
{
throw new IllegalArgumentException("ListadoSubmitFormImpl.setIdModificacionBackingList requires non-null property arguments");
}
this.idModificacionValueList = null;
this.idModificacionLabelList = null;
if (items != null)
{
this.idModificacionValueList = new java.lang.Object[items.size()];
this.idModificacionLabelList = new java.lang.Object[items.size()];
try
{
int i = 0;
for (java.util.Iterator iterator = items.iterator(); iterator.hasNext(); i++)
{
final java.lang.Object item = iterator.next();
this.idModificacionValueList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, valueProperty);
this.idModificacionLabelList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, labelProperty);
}
}
catch (Exception ex)
{
throw new java.lang.RuntimeException("ListadoSubmitFormImpl.setIdModificacionBackingList encountered an exception", ex);
}
}
}
/**
* Resets the given <code>idiomaBuscador</code>.
*/
public void resetIdiomaBuscador()
{
this.idiomaBuscador = null;
}
public void setIdiomaBuscador(java.lang.String idiomaBuscador)
{
this.idiomaBuscador = idiomaBuscador;
}
/**
*
*/
public java.lang.String getIdiomaBuscador()
{
return this.idiomaBuscador;
}
public java.lang.Object[] getIdiomaBuscadorBackingList()
{
java.lang.Object[] values = this.idiomaBuscadorValueList;
java.lang.Object[] labels = this.idiomaBuscadorLabelList;
if (values == null || values.length == 0)
{
return values;
}
if (labels == null || labels.length == 0)
{
labels = values;
}
final int length = java.lang.Math.min(labels.length, values.length);
java.lang.Object[] backingList = new java.lang.Object[length];
for (int i=0; i<length; i++)
{
backingList[i] = new LabelValue(labels[i], values[i]);
}
return backingList;
}
public java.lang.Object[] getIdiomaBuscadorValueList()
{
return this.idiomaBuscadorValueList;
}
public void setIdiomaBuscadorValueList(java.lang.Object[] idiomaBuscadorValueList)
{
this.idiomaBuscadorValueList = idiomaBuscadorValueList;
}
public java.lang.Object[] getIdiomaBuscadorLabelList()
{
return this.idiomaBuscadorLabelList;
}
public void setIdiomaBuscadorLabelList(java.lang.Object[] idiomaBuscadorLabelList)
{
this.idiomaBuscadorLabelList = idiomaBuscadorLabelList;
}
public void setIdiomaBuscadorBackingList(java.util.Collection items, java.lang.String valueProperty, java.lang.String labelProperty)
{
if (valueProperty == null || labelProperty == null)
{
throw new IllegalArgumentException("ListadoSubmitFormImpl.setIdiomaBuscadorBackingList requires non-null property arguments");
}
this.idiomaBuscadorValueList = null;
this.idiomaBuscadorLabelList = null;
if (items != null)
{
this.idiomaBuscadorValueList = new java.lang.Object[items.size()];
this.idiomaBuscadorLabelList = new java.lang.Object[items.size()];
try
{
int i = 0;
for (java.util.Iterator iterator = items.iterator(); iterator.hasNext(); i++)
{
final java.lang.Object item = iterator.next();
this.idiomaBuscadorValueList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, valueProperty);
this.idiomaBuscadorLabelList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, labelProperty);
}
}
catch (Exception ex)
{
throw new java.lang.RuntimeException("ListadoSubmitFormImpl.setIdiomaBuscadorBackingList encountered an exception", ex);
}
}
}
/**
* @see org.apache.struts.validator.ValidatorForm#reset(org.apache.struts.action.ActionMapping,javax.servlet.http.HttpServletRequest)
*/
public void reset(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
{
this.identificadores = null;
this.identificadoresValueList = new java.lang.Object[0];
this.identificadoresLabelList = new java.lang.Object[0];
this.idModificacionRowSelection = null;
this.idiomaBuscador = null;
}
public java.lang.String toString()
{
org.apache.commons.lang.builder.ToStringBuilder builder =
new org.apache.commons.lang.builder.ToStringBuilder(this);
builder.append("tarea", this.tarea);
builder.append("identificadores", this.identificadores);
builder.append("action", this.action);
builder.append("tipoBusqueda", this.tipoBusqueda);
builder.append("idModificacionRowSelection", this.idModificacionRowSelection);
builder.append("idiomaBuscador", this.idiomaBuscador);
return builder.toString();
}
/**
* Allows you to clean all values from this form. Objects will be set to <code>null</code>, numeric values will be
* set to zero and boolean values will be set to <code>false</code>. Backinglists for selectable fields will
* also be set to <code>null</code>.
*/
public void clean()
{
this.tarea = null;
this.tareaValueList = null;
this.tareaLabelList = null;
this.identificadores = null;
this.identificadoresValueList = null;
this.identificadoresLabelList = null;
this.action = null;
this.actionValueList = null;
this.actionLabelList = null;
this.tipoBusqueda = null;
this.tipoBusquedaValueList = null;
this.tipoBusquedaLabelList = null;
this.idModificacionRowSelection = null;
this.idiomaBuscador = null;
this.idiomaBuscadorValueList = null;
this.idiomaBuscadorLabelList = null;
}
/**
* Override to provide population of current form with request parameters when validation fails.
*
* @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
*/
public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
{
final org.apache.struts.action.ActionErrors errors = super.validate(mapping, request);
if (errors != null && !errors.isEmpty())
{
// we populate the current form with only the request parameters
Object currentForm = request.getSession().getAttribute("form");
// if we can't get the 'form' from the session, try from the request
if (currentForm == null)
{
currentForm = request.getAttribute("form");
}
if (currentForm != null)
{
final java.util.Map parameters = new java.util.HashMap();
for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();)
{
final String name = String.valueOf(names.nextElement());
parameters.put(name, request.getParameter(name));
}
try
{
org.apache.commons.beanutils.BeanUtils.populate(currentForm, parameters);
}
catch (java.lang.Exception populateException)
{
// ignore if we have an exception here (we just don't populate).
}
}
}
return errors;
}
public final static class LabelValue
{
private java.lang.Object label = null;
private java.lang.Object value = null;
public LabelValue(Object label, java.lang.Object value)
{
this.label = label;
this.value = value;
}
public java.lang.Object getLabel()
{
return this.label;
}
public java.lang.Object getValue()
{
return this.value;
}
public java.lang.String toString()
{
return label + "=" + value;
}
}
} | [
"[email protected]"
] | |
c11db244d9f14c43048ceddfcb31a5f102a65a27 | deea1700278be65c36bcc7a0fde610b209e6b78e | /demos/classes-abstraites/src/Forme2D.java | ef99948dd11f97a839caaeef7869146f8872f861 | [] | no_license | injailoutsoon/inf2120-demo | cba9fe8a20ae9bee1770e0c9e869f959e04f0a2a | 1ca03e958d9c27dd83b3824ea33c67d450be0439 | refs/heads/master | 2021-08-28T08:17:46.726608 | 2017-12-11T17:22:39 | 2017-12-11T17:22:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 127 | java | /**
* Created by thomas on 9/16/17.
*/
public abstract class Forme2D {
Forme2D(){};
public abstract double aire();
}
| [
"[email protected]"
] | |
99cdadcddf6deb8cb9b40f349153cc407fb53050 | e68581f10d2ac8138f89833654a94adb86796871 | /src/cc4/PurchaseBO.java | afa2b8c02d39d817fde6505dd2a1e01f5b9e3683 | [] | no_license | roysantu/sdetu-training | bdc78b132ae5b90c59d0aa08929babc6564ce72e | c22ed0726f42deb79150088b58d6042c532eb341 | refs/heads/master | 2020-04-20T02:09:03.419763 | 2019-01-31T17:36:28 | 2019-01-31T17:36:28 | 168,563,882 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 285 | java | package cc4;
public class PurchaseBO {
public void addNewItem(PurchaseOrder purchaseOrder, Item item, int quantity) {
// fill code here.
}
public void updateItem(OrderLine orderLineObj,int quantity)
{
// fill code here.
}
}
| [
"[email protected]"
] | |
d652da39cce0d112a8911bfff862d9aa74f1b5a0 | ff5e1af7801a68583a5e52099859ae6814c05a2f | /src/cg/ncn/JspJEE/servlets/ListeClient.java | a1797d1c8148ba250a18b1030598b245e8f78a32 | [] | no_license | ncn17/JEE_8_JSP_JDBC | 10bf8b6503277395fa53c7512265ae7dcc2e10d1 | 0585dcbcd56baa5fb63db03f4aa79706bbaf3c96 | refs/heads/master | 2020-08-05T05:46:47.368948 | 2019-10-02T19:06:38 | 2019-10-02T19:06:38 | 212,418,890 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 947 | java | package cg.ncn.JspJEE.servlets;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet( "/listeClient" )
public class ListeClient extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final String VUE = "/WEB-INF/jsp/creationClient.jsp";
public ListeClient() {
}
protected void doGet( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException {
this.getServletContext().getRequestDispatcher( VUE ).forward( request, response );
}
protected void doPost( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException {
doGet( request, response );
}
}
| [
"atir17@[email protected]"
] | atir17@[email protected] |
ad1701e0e7c01ac644f817b545254875db224949 | 1317fe3677c684401988d219b9fb6b2f677c1766 | /src/main/java/edu/sjsu/cmpe273/facebookarchiver/results/DeletedPics.java | db2d441021c5c52546afac2408e6cb03c042ff93 | [] | no_license | The-ThinkTank/CMPE273Project | b8b901781002778053e1aa7e7a8de14ae4b1534e | cbff7ae9a95cce68cacd8080e5ef0cdc3d81ac11 | refs/heads/master | 2021-01-23T07:20:51.248189 | 2015-06-06T16:48:48 | 2015-06-06T16:48:48 | 33,701,843 | 0 | 1 | null | 2015-05-13T03:47:59 | 2015-04-10T01:33:40 | Shell | UTF-8 | Java | false | false | 775 | java | package edu.sjsu.cmpe273.facebookarchiver.results;
import edu.sjsu.cmpe273.facebookarchiver.entity.UserPhotos;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.List;
/**
* Created by Rajat on 5/13/2015.
*/
@Document(collection="DeletedPhotos")
public class DeletedPics {
private String id;
private List<UserPhotos> userPhotoses;
public DeletedPics()
{
}
public void setId(String Id){
this.id=Id;
}
public String getId()
{
return id;
}
public void setUserPhotoses(List<UserPhotos> userPhotoses){
this.userPhotoses=userPhotoses;
}
public List<UserPhotos> getUserPhotoses()
{
return this.userPhotoses;
}
}
| [
"[email protected]"
] | |
ad2482755cf0fb415e48cbe0e3052ff99ecae748 | e501067bc494b7fc51e7ed9c3afd5fe6b0c92e72 | /app/src/main/java/com/technotapp/servicestation/adapter/DataModel/ProductFactorAdapterModel.java | bd0b92b83eacf3ab4ea31c16af180b74f4915362 | [] | no_license | abdolmaleki/ServiceStation | be96a97e664116285e9ad5ac96a61cd6fc0116fe | 1dbb7d2121ce9b6fe3d12f336039c44fce045d6c | refs/heads/master | 2020-06-20T03:48:33.932405 | 2018-04-18T11:19:21 | 2018-04-18T11:19:21 | 196,981,332 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,580 | java | package com.technotapp.servicestation.adapter.DataModel;
import io.realm.Realm;
import io.realm.RealmObject;
public class ProductFactorAdapterModel extends RealmObject {
private long nidProduct;
private String unitPrice;
private String unit;
private String name;
private String description;
private String sumPrice;
public int amount = 0;
public long getNidProduct() {
return nidProduct;
}
public void setnidProduct(long id) {
this.nidProduct = id;
}
public String getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(String unitPrice) {
this.unitPrice = unitPrice;
}
public String getUnit() {
return unit;
}
public void setAmount(int amount) {
this.amount = amount;
}
public int getAmount() {
return amount;
}
public String getSumPrice() {
Realm realm = getRealm();
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
sumPrice = String.valueOf(amount * Long.parseLong(unitPrice));
}
});
return sumPrice;
}
public void setUnit(String unit) {
this.unit = unit;
}
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;
}
}
| [
"[email protected]"
] | |
0679857d3409cbb94667778220b53bc64e0f0923 | 128eb90ce7b21a7ce621524dfad2402e5e32a1e8 | /laravel-converted/src/main/java/com/project/convertedCode/servlets/vendor/laravel/framework/src/Illuminate/Notifications/Channels/servlet_DatabaseChannel_php.java | 7abf1983cb01442ca4e2ad0c15b6047a188e778f | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | RuntimeConverter/RuntimeConverterLaravelJava | 657b4c73085b4e34fe4404a53277e056cf9094ba | 7ae848744fbcd993122347ffac853925ea4ea3b9 | refs/heads/master | 2020-04-12T17:22:30.345589 | 2018-12-22T10:32:34 | 2018-12-22T10:32:34 | 162,642,356 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,265 | java | package com.project.convertedCode.servlets.vendor.laravel.framework.src.Illuminate.Notifications.Channels;
import com.runtimeconverter.runtime.includes.RuntimeIncludable;
import com.runtimeconverter.runtime.includes.RuntimeConverterServlet;
import com.runtimeconverter.runtime.RuntimeEnv;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.annotation.WebServlet;
@WebServlet("/vendor/laravel/framework/src/Illuminate/Notifications/Channels/DatabaseChannel.php")
public class servlet_DatabaseChannel_php extends RuntimeConverterServlet {
protected final RuntimeIncludable getInclude() {
return com.project
.convertedCode
.includes
.vendor
.laravel
.framework
.src
.Illuminate
.Notifications
.Channels
.file_DatabaseChannel_php
.instance;
}
protected final RuntimeEnv getRuntimeEnv(
String httpRequestType, HttpServletRequest req, HttpServletResponse resp) {
return new com.project.convertedCode.main.ConvertedProjectRuntimeEnv(
req, resp, this.getInclude());
}
}
| [
"[email protected]"
] | |
a4018c963967e50195cbf3deffadd3ef666aa74e | 71c6a840321e68d7739467dc10a6cff50b9c81fe | /src/main/java/com/example/Application.java | 66c3e051ed8631011ca28782656f9eaaa57547bb | [] | no_license | ThePinkRaven/raven-news-server | 124677c5901f7cd128b7d2c81ae385a5f6212988 | 61a22387d72bff0e74fc0f7bf6cd3548d648574e | refs/heads/master | 2021-09-07T20:50:35.043916 | 2018-02-28T22:37:00 | 2018-02-28T22:37:00 | 119,746,052 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 920 | java | /*
* Copyright 2016-2017 Red Hat, Inc, and individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application
{
public static void main(String[] args)
{
SpringApplication.run(Application.class, args);
}
}
| [
"[email protected]"
] | |
c7e8681c986c1db42c7f1354f2b88c040da30599 | 9af2b9a991d1295439e884b34c12f21e03c5a873 | /app/src/main/java/com/hs/qrconde/camera/PreviewCallback.java | 98242c2b0a24b498c4187c0417f277948b8bec48 | [] | no_license | haishuang/qrconde | 6275759cf7f79a469a0f07a01980156f05487b1d | 1ca0b0333f520852242c4897d886865746eadf47 | refs/heads/master | 2020-11-30T18:56:07.285043 | 2016-09-02T07:52:12 | 2016-09-02T07:52:12 | 67,201,735 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,803 | java | /*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hs.qrconde.camera;
import android.graphics.Point;
import android.hardware.Camera;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
final class PreviewCallback implements Camera.PreviewCallback {
private static final String TAG = PreviewCallback.class.getSimpleName();
private final CameraConfigurationManager configManager;
private Handler previewHandler;
private int previewMessage;
PreviewCallback(CameraConfigurationManager configManager) {
this.configManager = configManager;
}
void setHandler(Handler previewHandler, int previewMessage) {
this.previewHandler = previewHandler;
this.previewMessage = previewMessage;
}
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
Point cameraResolution = configManager.getCameraResolution();
Handler thePreviewHandler = previewHandler;
if (thePreviewHandler != null) {
Message message = thePreviewHandler.obtainMessage(previewMessage, cameraResolution.x,
cameraResolution.y, data);
message.sendToTarget();
previewHandler = null;
} else {
Log.d(TAG, "Got preview callback, but no handler for it");
}
}
}
| [
"[email protected]"
] | |
618e716f0606e04990bf74ac3005623d1e7f1843 | 30d64cf8d9c97a44902ad04e1ce792f953a8beb2 | /pz3/app/src/main/java/io/github/gubarsergey/pz3/ReversePolishNotation.java | 5c67d13744c10403260058a2ba76a2c44730684c | [] | no_license | SergeyGubar/ppandroid-labs | 00489b9a68750b346cc66f591f409c4bbde5bdbb | 03eaa87874a84e3ccb4b8a13b5db881ec807c5df | refs/heads/master | 2020-08-06T19:13:07.512265 | 2019-12-27T07:36:16 | 2019-12-27T07:36:16 | 213,119,627 | 3 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,933 | java | package io.github.gubarsergey.pz3;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
public class ReversePolishNotation {
public List<String> getRPN(String expression) {
List<String> rpnExpression = new ArrayList<>();
Stack<Character> operations = new Stack();
String number = "";
for(int i = 0; i < expression.length(); i++){
char character = expression.charAt(i);
if(!(this.isNumeric(character) || character == '.') && number != "") {
rpnExpression.add(number);
number = "";
}
if(this.isNumeric(character) || character == '.')
number += Character.toString(character);
else if(character == '(')
operations.push(character);
else if(character == ')') {
while (!(operations.isEmpty()) && operations.peek() != '(')
rpnExpression.add(Character.toString(operations.pop()));
if(!(operations.isEmpty())) //delete open bracket
operations.pop();
}
else if(this.isOperation(character))
{
int currentOperationPriority = this.getPriority(character);
if(!(operations.empty())) {
int previousOperationPriority = this.getPriority(operations.peek());
if(currentOperationPriority > previousOperationPriority)
operations.push(character);
else {
char previousOperation = operations.pop();
rpnExpression.add(Character.toString(previousOperation));
operations.push(character);
}
}
else {
operations.push(character);
}
}
}
if(number != "")
rpnExpression.add(number);
while (!(operations.isEmpty())){
if(!this.isOperation(operations.peek()))
operations.pop();
else
rpnExpression.add(Character.toString(operations.pop()));
}
return rpnExpression;
}
private int getPriority(char operation) {
switch (operation) {
case '+':
return 1;
case '-':
return 1;
case '*':
return 2;
case '/':
return 2;
default:
return 0;
}
}
private Boolean isNumeric(char value) {
try {
Double.parseDouble(Character.toString(value));
return true;
} catch(NumberFormatException e){
return false;
}
}
private Boolean isOperation(char value) {
return value == '+' || value == '-' || value == '*' || value == '/';
}
}
| [
"[email protected]"
] | |
a263570d6ba4e922f048857024e80cee5114f86b | 2075e2209755a8b777acc8f38a36aff32f5d0060 | /app/src/androidTest/java/com/example/bhaum/dditconnect/ExampleInstrumentedTest.java | 7a578c4be5dc5ad52fe4ab6995135070f25d6ccd | [] | no_license | bhaumik1561/CampusWide | 3995c966619aa023c6674aa10f55adf49c0ca0be | 78ce81bf2bb8d3275de712c49566e7425988e0a4 | refs/heads/master | 2021-01-20T09:46:30.681190 | 2018-11-21T21:15:41 | 2018-11-21T21:15:41 | 90,286,962 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 762 | java | package com.example.bhaum.dditconnect;
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.example.bhaum.dditconnect", appContext.getPackageName());
}
}
| [
"bhaumik ichhaporia"
] | bhaumik ichhaporia |
f83b2e15e541cdb89da54e2ce58d440793721880 | bdf86b37da5777c18453c17c64b820f6a3add41b | /sixteen_coins_problem/version2/UnweightedGraph.java | 5c68f3631a6d358ddc4b459760023b128ca0d8a4 | [] | no_license | Heenjiang/- | 344253b91266e4c056698f089295ed4c0f15e39c | 1abcc0bcd2f54264e68ba63ec3dd4505b4c77197 | refs/heads/master | 2020-04-15T15:34:40.858973 | 2019-01-09T05:43:16 | 2019-01-09T05:43:16 | 164,799,673 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 305 | java | package version2;
import java.util.*;
public class UnweightedGraph<V> extends AbstractGraph<V> {
/** Construct a graph for integer vertices 0, 1, 2 and edge list */
public UnweightedGraph(List<Edge> edges, int numberOfVertices) {
super(edges, numberOfVertices);
}
}
| [
"[email protected]"
] | |
e03be5c5626a392c475680d8d7e00b5205d292e3 | 5efad863e6aae8955b76fe36f47aaffd24f483bb | /app/src/main/java/DAL/Entidades/Mod_and_tipo.java | cc842dbb29ddaae70e572d9d7d633ce1e4efbcf8 | [] | no_license | etien-andres/EzbrnFood | e0471c20a4b6b64c4a0dda28d8396543454ebbe0 | f1d98923bbeee9264214785d332493155f3cfb75 | refs/heads/master | 2020-04-14T19:04:15.320697 | 2019-02-07T01:25:26 | 2019-02-07T01:25:26 | 164,043,690 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 481 | java | package DAL.Entidades;
public class Mod_and_tipo {
Modificadores mod;
Integer tipo;
public Mod_and_tipo(Modificadores mod, Integer tipo) {
this.mod = mod;
this.tipo = tipo;
}
public Modificadores getMod() {
return mod;
}
public void setMod(Modificadores mod) {
this.mod = mod;
}
public Integer getTipo() {
return tipo;
}
public void setTipo(Integer tipo) {
this.tipo = tipo;
}
}
| [
"[email protected]"
] | |
f1c4b75111bcb1fcd4df4b27f3483dd2036c9eae | 785810ba6c708c8841e304ffd36914fa42cce34a | /app/src/main/java/com/example/pratamajambipelayangan/PersyaratanDetail.java | 8404dd4ee16ce1db07a233815b0107d2324caed0 | [] | no_license | ekastan/PratamaJambiPelayanganV4 | 497d45f9e211393b6fe57d019f89f2e4ed581551 | 2c1bdd0d32225ee55c40dd0f81a4f9d4892e5394 | refs/heads/master | 2022-12-19T14:56:49.044658 | 2020-10-02T00:41:40 | 2020-10-02T00:41:40 | 300,462,758 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,918 | java | package com.example.pratamajambipelayangan;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class PersyaratanDetail extends AppCompatActivity {
private String urlData = konfigurasi.URL_GET_LAYANAN_DETAIL;
private RecyclerView recyclerViewDokumen;
private PersyaratanDetailAdapter mAdapter;
private ProgressDialog mProgressDialog;
private List<PersyaratanModel> mListData;
private String id_layanan;
private String hari_kerja;
private String nama_layanan;
private String url_formulir;
private Button btnFormulir;
private TextView txtIdLayanan;
private TextView txtNamaLayanan;
private TextView txtHariKerja;
private TextView txtURL;
private TextView txtURLFormulir;
Dialog myDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_persyaratan_detail);
recyclerViewDokumen = findViewById(R.id.recyclerviewDokumen);
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setMessage("Loading ...");
mProgressDialog.show();
mListData = new ArrayList<>();
myDialog = new Dialog(this);
Intent intent = getIntent();
hari_kerja = intent.getStringExtra(konfigurasi.TAG_HARI_KERJA);
id_layanan = intent.getStringExtra(konfigurasi.EMP_ID_LAYANAN);
nama_layanan = intent.getStringExtra(konfigurasi.TAG_NAMA_LAYANAN);
url_formulir = intent.getStringExtra(konfigurasi.TAG_URL_FORMULIR);
txtURL = findViewById(R.id.txtURL);
txtURL.setText(konfigurasi.URL_GET_LAYANAN_DETAIL+id_layanan);
txtNamaLayanan = findViewById(R.id.txtNamaLayanan);
txtNamaLayanan.setText(nama_layanan);
txtHariKerja = findViewById(R.id.txtharikerja);
txtHariKerja.setText(hari_kerja+" hari kerja");
btnFormulir = findViewById(R.id.btnFormulir);
getDataVolley();
btnFormulir.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url_formulir));
intent.putExtra(konfigurasi.EMP_ID_LAYANAN,id_layanan);
intent.putExtra(konfigurasi.TAG_HARI_KERJA,hari_kerja);
intent.putExtra(konfigurasi.TAG_NAMA_LAYANAN,nama_layanan);
intent.putExtra(konfigurasi.TAG_URL_FORMULIR,url_formulir);
startActivity(intent);
}
});
}
private void getDataVolley(){
urlData = txtURL.getText().toString();
final StringRequest request = new StringRequest(Request.Method.GET, urlData,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
mProgressDialog.dismiss();
iniData(response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(request);
}
private void iniData(String response){
try {
JSONObject jsonObject = new JSONObject(response);
// ini utk mengambil attribute array yg ada di json (yaitu attribute data)
// karna attribute data adalah array makanya kita get menggunakan JSONArray
JSONArray jsonArray = jsonObject.getJSONArray("data");
//looping utk array
for(int i=0; i<jsonArray.length(); i++){
//get json berdasarkan banyaknya data (index i)
JSONObject objectPersyaratan = jsonArray.getJSONObject(i);
//get data berdasarkan attribte yang ada dijsonnya (harus sama)
String Dokumen = objectPersyaratan.getString("dokumen");
//add data ke modelnya
PersyaratanModel persyaratanModel = new PersyaratanModel();
persyaratanModel.setDokumen(Dokumen);
//add model ke list
mListData.add(persyaratanModel);
//passing data list ke adapter
mAdapter = new PersyaratanDetailAdapter(mListData, PersyaratanDetail.this);
mAdapter.notifyDataSetChanged();
recyclerViewDokumen.setLayoutManager(new LinearLayoutManager(PersyaratanDetail.this));
recyclerViewDokumen.setItemAnimator(new DefaultItemAnimator());
recyclerViewDokumen.setAdapter(mAdapter);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
} | [
"[email protected]"
] | |
192a84923efc16f5f8a28f50de16a2558c162e5c | ef1388fb3db855ca4c5ce0d4bae1a2ef210603fc | /src/main/java/com/example/app/controller/ControllerUtils.java | eac89d40bcadd5c170e4f91370783befa6021579 | [] | no_license | trilitra/agregator-shops | 2e7e00b0ca1111fbe6314f5d578498e1e9b199b4 | 375bc71284024be55983227189e61386124a39b8 | refs/heads/master | 2023-03-05T09:14:26.783920 | 2021-02-18T08:00:22 | 2021-02-18T08:00:22 | 339,976,712 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 624 | java | package com.example.app.controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import java.util.Map;
import java.util.stream.Collector;
import java.util.stream.Collectors;
public class ControllerUtils {
static Map<String, String> getErrors(BindingResult bindingResult) {
Collector<FieldError, ?, Map<String, String>> collector = Collectors.toMap(
fieldError -> fieldError.getField() + "Error",
FieldError::getDefaultMessage
);
return bindingResult.getFieldErrors().stream().collect(collector);
}
} | [
"[email protected]"
] | |
e9bc916bb646886c8b1803221d60447148b22f76 | 0a4d4b808ee0724114e6153c1204de4e253c1dcb | /samples/86/a.java | a43b541a8e4dc293d0aeca2284b09759f39294ca | [
"MIT"
] | permissive | yura-hb/sesame-sampled-pairs | 543b19bf340f6a35681cfca1084349bd3eb8f853 | 33b061e3612a7b26198c17245c2835193f861151 | refs/heads/main | 2023-07-09T04:15:05.821444 | 2021-08-08T12:01:04 | 2021-08-08T12:01:04 | 393,947,142 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 958 | java | import java.util.Hashtable;
class LRUCache<K, V> implements Cloneable {
/**
* Flushes all entries from the cache.
*/
public void flush() {
this.currentSpace = 0;
LRUCacheEntry<K, V> entry = this.entryQueueTail; // Remember last entry
this.entryTable = new Hashtable<>(); // Clear it out
this.entryQueue = this.entryQueueTail = null;
while (entry != null) { // send deletion notifications in LRU order
entry = entry.previous;
}
}
/**
* Amount of cache space used so far
*/
protected int currentSpace;
/**
* End of queue (least recently used entry)
*/
protected LRUCacheEntry<K, V> entryQueueTail;
/**
* Hash table for fast random access to cache entries
*/
protected Hashtable<K, LRUCacheEntry<K, V>> entryTable;
/**
* Start of queue (most recently used entry)
*/
protected LRUCacheEntry<K, V> entryQueue;
}
| [
"[email protected]"
] | |
747479dbbc58148a7ced44a3464aed2b5e5a6001 | 636e5c82bd0d2f56b192cb6289d41ad5ab7ec68c | /andAlarmManager/src/main/java/com/babacit/alarm/ui/activity/ChangePhoneNumActivity.java | 081c934b574d02751a73b347295ba1d18a063b98 | [] | no_license | jiaxisyy/AndAlarmManager | 3cf3aeac732b01a66b73fa3f6a9c0f49aff9a295 | b32fe821669e553b99a2e74b96cad4ab152f0382 | refs/heads/master | 2020-03-09T16:46:41.388001 | 2018-04-10T08:01:20 | 2018-04-10T08:01:20 | 115,099,258 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,024 | java | package com.babacit.alarm.ui.activity;
import java.util.Timer;
import java.util.TimerTask;
import com.babacit.alarm.R;
import com.babacit.alarm.config.SharedConfig;
import com.babacit.alarm.err.ErrUtils;
import com.babacit.alarm.interfaces.RequestCallBack;
import com.babacit.alarm.server.GetVerifyTypeServer;
import com.babacit.alarm.server.UpdatePhoneNoServer;
import com.babacit.alarm.utils.NetworkUtils;
import com.babacit.alarm.utils.PhoneNumCheckUtil;
import com.babacit.alarm.utils.ToastUtil;
import com.umeng.analytics.MobclickAgent;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class ChangePhoneNumActivity extends BaseActivity implements
OnClickListener {
private EditText mEtOriginNum, mEtNewNum, mEtCode, mEtPwd;
private String originNum, newNum, code, pwd;
private Button mBtFetchCode;
private static final int MSG_FETCH_CODE_SUCCESS = 0;
private static final int MSG_FETCH_CODE_FAIL = 1;
private static final int MSG_UPDATE_PHONE_SUCCESS = 2;
private static final int MSG_UPDATE_PHONE_FAIL = 3;
private SharedConfig config;
private static final int MSG_ENABLE_FETCH_BTN = 2003;
private static final int MSG_REFRESH_BTN_TEXT = 2004;
private Timer timer;
private static int mCountDown;
private RequestCallBack fetchCodeCallBack = new RequestCallBack() {
@Override
public void onSuccess(Object obj) {
mHandler.sendEmptyMessage(MSG_FETCH_CODE_SUCCESS);
}
@Override
public void onFail(Object object, int errCode) {
Message msg = mHandler.obtainMessage(MSG_FETCH_CODE_FAIL);
msg.arg1 = errCode;
msg.sendToTarget();
}
};
private RequestCallBack updatePhoneNoCallBack = new RequestCallBack() {
@Override
public void onSuccess(Object obj) {
mHandler.sendEmptyMessage(MSG_UPDATE_PHONE_SUCCESS);
}
@Override
public void onFail(Object object, int errCode) {
Message msg = mHandler.obtainMessage(MSG_UPDATE_PHONE_FAIL);
msg.arg1 = errCode;
msg.sendToTarget();
}
};
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_UPDATE_PHONE_SUCCESS:
Intent data = new Intent();
data.putExtra("phone", newNum);
setResult(0, data);
finish();
break;
case MSG_UPDATE_PHONE_FAIL:
ToastUtil.showToast(getApplicationContext(),
ErrUtils.getErrorReasonStr(msg.arg1));
break;
case MSG_FETCH_CODE_SUCCESS:
break;
case MSG_FETCH_CODE_FAIL:
ToastUtil.showToast(getApplicationContext(),
ErrUtils.getErrorReasonStr(msg.arg1));
break;
case MSG_REFRESH_BTN_TEXT:
if (msg.arg2 == 0) {
mHandler.sendEmptyMessage(MSG_ENABLE_FETCH_BTN);
}
mBtFetchCode.setText(String.valueOf(msg.arg2)
+ getResources().getString(
R.string.txt_retry_after_seconds));
break;
case MSG_ENABLE_FETCH_BTN:
mBtFetchCode.setText(getResources().getString(
R.string.txt_fetch_verification_code));
mBtFetchCode.setEnabled(true);
stopTimer();
break;
default:
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_change_phone_num);
config = new SharedConfig(this);
bindField();
}
private void bindField() {
mEtOriginNum = (EditText) findViewById(R.id.et_change_phone_number_origin);
mEtOriginNum.setText(getIntent().getStringExtra("origin"));
mEtNewNum = (EditText) findViewById(R.id.et_change_phone_number_new);
mEtCode = (EditText) findViewById(R.id.et_change_phone_num_verification_code);
mEtPwd = (EditText) findViewById(R.id.et_change_phone_num_input_password);
findViewById(R.id.btn_change_phone_num_back).setOnClickListener(this);
findViewById(R.id.btn_confirm).setOnClickListener(this);
mBtFetchCode = (Button) findViewById(R.id.btn_change_phone_num_fetch_verification_code);
mBtFetchCode.setOnClickListener(this);
}
@Override
public void onClick(View v) {
originNum = mEtOriginNum.getText().toString().trim();
newNum = mEtNewNum.getText().toString().trim();
code = mEtCode.getText().toString().trim();
pwd = mEtPwd.getText().toString().trim();
switch (v.getId()) {
case R.id.btn_change_phone_num_back:
finish();
break;
case R.id.btn_confirm:
if (!NetworkUtils.isNetWorkOk(getApplicationContext())) {
ToastUtil.showToast(getApplicationContext(), "请检查您的网络!");
return;
}
if (originNum.equals("")) {
ToastUtil.showToast(ChangePhoneNumActivity.this, getResources()
.getString(R.string.txt_phone_number_cannot_be_empty));
return;
}
if (!PhoneNumCheckUtil.isMobileNum(originNum)) {
ToastUtil.showToast(getApplicationContext(), getResources()
.getString(R.string.txt_phone_number_wrong_format));
return;
}
if (newNum.equals("")) {
ToastUtil.showToast(ChangePhoneNumActivity.this, getResources()
.getString(R.string.txt_phone_number_cannot_be_empty));
return;
}
if (!PhoneNumCheckUtil.isMobileNum(newNum)) {
ToastUtil.showToast(getApplicationContext(), getResources()
.getString(R.string.txt_phone_number_wrong_format));
return;
}
if (code.equals("")) {
ToastUtil
.showToast(
ChangePhoneNumActivity.this,
getResources()
.getString(
R.string.txt_verification_code_cannot_be_empty));
return;
}
if (pwd.equals("")) {
ToastUtil.showToast(ChangePhoneNumActivity.this, getResources()
.getString(R.string.txt_password_cannot_be_empty));
return;
}
new UpdatePhoneNoServer().start(config.getUserId(), originNum, pwd,
newNum, code, updatePhoneNoCallBack);
break;
case R.id.btn_change_phone_num_fetch_verification_code:
if (newNum.equals("")) {
ToastUtil.showToast(ChangePhoneNumActivity.this, getResources()
.getString(R.string.txt_phone_number_cannot_be_empty));
return;
}
if (!PhoneNumCheckUtil.isMobileNum(newNum)) {
ToastUtil.showToast(getApplicationContext(), getResources()
.getString(R.string.txt_phone_number_wrong_format));
return;
}
mBtFetchCode.setEnabled(false);
startTimer();
new GetVerifyTypeServer().start(newNum, 2, fetchCodeCallBack);
break;
default:
break;
}
}
private void startTimer() {
mCountDown = 30;
if (timer == null) {
timer = new Timer();
}
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
Message msg = mHandler.obtainMessage(MSG_REFRESH_BTN_TEXT);
msg.arg2 = mCountDown--;
msg.sendToTarget();
}
}, 0, 1000);
}
private void stopTimer() {
if (timer != null) {
timer.cancel();
timer = null;
}
}
@Override
protected void onPause() {
super.onPause();
MobclickAgent.onPause(this);
}
@Override
protected void onResume() {
super.onResume();
MobclickAgent.onResume(this);
}
}
| [
"[email protected]"
] | |
a2d57588cc329a340aa69c147c08372919653756 | d4d1013d3215088f7ec445b393b58fb30249ca1b | /jonix-onix3/src/main/java/com/tectonica/jonix/onix3/TextItemIdentifier.java | ce62265601d253a0ea78266bc0f04f9553399749 | [
"Apache-2.0"
] | permissive | miyewd/jonix | 70de3ba4b2054e0a66f688185834c9b0c73a101f | 2ce4c9d7fddd453c4c76cf2a4bfae17b98e9b91d | refs/heads/master | 2022-11-28T18:00:52.049749 | 2020-08-06T09:21:47 | 2020-08-06T09:21:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,876 | java | /*
* Copyright (C) 2012-2020 Zach Melamed
*
* Latest version available online at https://github.com/zach-m/jonix
* Contact me at [email protected]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tectonica.jonix.onix3;
import com.tectonica.jonix.common.JPU;
import com.tectonica.jonix.common.OnixComposite.OnixDataCompositeWithKey;
import com.tectonica.jonix.common.codelist.RecordSourceTypes;
import com.tectonica.jonix.common.codelist.TextItemIdentifierTypes;
import com.tectonica.jonix.common.struct.JonixTextItemIdentifier;
import java.io.Serializable;
/*
* NOTE: THIS IS AN AUTO-GENERATED FILE, DO NOT EDIT MANUALLY
*/
/**
* <h1>Text item identifier composite</h1>
* <p>
* A repeatable group of data elements which together define an identifier of a text item in accordance with a specified
* scheme. The composite is optional.
* </p>
* <table border='1' cellpadding='3'>
* <tr>
* <td>Reference name</td>
* <td><tt><TextItemIdentifier></tt></td>
* </tr>
* <tr>
* <td>Short tag</td>
* <td><tt><textitemidentifier></tt></td>
* </tr>
* <tr>
* <td>Cardinality</td>
* <td>0…n</td>
* </tr>
* </table>
* <p/>
* This tag may be included in the following composites:
* <ul>
* <li><{@link TextItem}></li>
* </ul>
* <p/>
* Possible placements within ONIX message:
* <ul>
* <li>{@link ONIXMessage} ⯈ {@link Product} ⯈ {@link ContentDetail} ⯈ {@link ContentItem} ⯈ {@link TextItem} ⯈
* {@link TextItemIdentifier}</li>
* </ul>
*/
public class TextItemIdentifier
implements OnixDataCompositeWithKey<JonixTextItemIdentifier, TextItemIdentifierTypes>, Serializable {
private static final long serialVersionUID = 1L;
public static final String refname = "TextItemIdentifier";
public static final String shortname = "textitemidentifier";
/////////////////////////////////////////////////////////////////////////////////
// ATTRIBUTES
/////////////////////////////////////////////////////////////////////////////////
/**
* (type: dt.DateOrDateTime)
*/
public String datestamp;
public RecordSourceTypes sourcetype;
/**
* (type: dt.NonEmptyString)
*/
public String sourcename;
/////////////////////////////////////////////////////////////////////////////////
// CONSTRUCTION
/////////////////////////////////////////////////////////////////////////////////
private boolean initialized;
private final boolean exists;
private final org.w3c.dom.Element element;
public static final TextItemIdentifier EMPTY = new TextItemIdentifier();
public TextItemIdentifier() {
exists = false;
element = null;
initialized = true; // so that no further processing will be done on this intentionally-empty object
}
public TextItemIdentifier(org.w3c.dom.Element element) {
exists = true;
initialized = false;
this.element = element;
datestamp = JPU.getAttribute(element, "datestamp");
sourcetype = RecordSourceTypes.byCode(JPU.getAttribute(element, "sourcetype"));
sourcename = JPU.getAttribute(element, "sourcename");
}
@Override
public void _initialize() {
if (initialized) {
return;
}
initialized = true;
JPU.forElementsOf(element, e -> {
final String name = e.getNodeName();
switch (name) {
case TextItemIDType.refname:
case TextItemIDType.shortname:
textItemIDType = new TextItemIDType(e);
break;
case IDValue.refname:
case IDValue.shortname:
idValue = new IDValue(e);
break;
case IDTypeName.refname:
case IDTypeName.shortname:
idTypeName = new IDTypeName(e);
break;
default:
break;
}
});
}
/**
* @return whether this tag (<TextItemIdentifier> or <textitemidentifier>) is explicitly provided in the
* ONIX XML
*/
@Override
public boolean exists() {
return exists;
}
@Override
public org.w3c.dom.Element getXmlElement() {
return element;
}
/////////////////////////////////////////////////////////////////////////////////
// MEMBERS
/////////////////////////////////////////////////////////////////////////////////
private TextItemIDType textItemIDType = TextItemIDType.EMPTY;
/**
* <p>
* An ONIX code identifying the scheme from which the identifier in <IDValue> is taken. Mandatory in each
* occurrence of the <TextItemIdentifier> composite, and non-repeating.
* </p>
* Jonix-Comment: this field is required
*/
public TextItemIDType textItemIDType() {
_initialize();
return textItemIDType;
}
private IDValue idValue = IDValue.EMPTY;
/**
* <p>
* An identifier of the type specified in <TextItemIDType>. Mandatory in each occurrence of the
* <TextItemIdentifier> composite, and non-repeating.
* </p>
* Jonix-Comment: this field is required
*/
public IDValue idValue() {
_initialize();
return idValue;
}
private IDTypeName idTypeName = IDTypeName.EMPTY;
/**
* <p>
* A name which identifies a proprietary identifier scheme (<i>ie</i> a scheme which is not a standard and for which
* there is no individual ID type code). Must be included when, and only when, the code in <TextItemIDType>
* indicates a proprietary scheme, <i>eg</i> a publisher’s own code. Optional and non-repeating
* </p>
* Jonix-Comment: this field is optional
*/
public IDTypeName idTypeName() {
_initialize();
return idTypeName;
}
@Override
public JonixTextItemIdentifier asStruct() {
_initialize();
JonixTextItemIdentifier struct = new JonixTextItemIdentifier();
struct.textItemIDType = textItemIDType.value;
struct.idTypeName = idTypeName.value;
struct.idValue = idValue.value;
return struct;
}
@Override
public TextItemIdentifierTypes structKey() {
return textItemIDType().value;
}
}
| [
"[email protected]"
] | |
319465abf8fac152b8a68a0e839be91cc556b98c | 83103555afbbbd7114addda3f66d1ab9dc089955 | /src/lambdas/CalculoTeste.java | fce27f31c78e3ced00166cc347906350aaaf3b29 | [] | no_license | garciawell/curso-java | c4dd820c9f44567dc99515a719e5bda56e181317 | aa7efbf0b607f7e9e64e7c8541925718f6aac3e4 | refs/heads/master | 2021-01-15T01:19:52.490739 | 2020-04-23T00:01:34 | 2020-04-23T00:01:34 | 242,828,661 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 292 | java | package lambdas;
public class CalculoTeste {
public static void main(String[] args) {
Calculo soma = new Soma();
System.out.println(soma.executar(2,3));
Calculo multiplicacao = new Multiplicar();
System.out.println(multiplicacao.executar(2,3));
}
}
| [
"[email protected]"
] | |
96d32dd0163ddfca742ca5e552892d4c68f7d39b | c1116c7ff8314ec43b16d455ee1aea7d8d289943 | /enderio-base/src/main/java/crazypants/enderio/base/item/eggs/RenderEntityOwlEgg.java | ea3c62f67076ab299e64b71a403103925208b3d5 | [
"Unlicense",
"CC-BY-NC-3.0",
"CC0-1.0",
"CC-BY-3.0",
"LicenseRef-scancode-public-domain"
] | permissive | FinalCraftMC/EnderIO | 71054da73fe329d5d49c9a2c239b4545a8b7ed7b | a173868d1659d511154d9b195cd0d4759164029b | refs/heads/master | 2023-04-23T19:20:36.682724 | 2021-05-10T18:42:24 | 2021-05-10T18:42:24 | 298,419,938 | 0 | 0 | Unlicense | 2020-09-26T23:02:13 | 2020-09-24T23:40:35 | null | UTF-8 | Java | false | false | 1,533 | java | package crazypants.enderio.base.item.eggs;
import javax.annotation.Nonnull;
import crazypants.enderio.base.init.ModObject;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderEntityOwlEgg extends RenderSnowball<EntityOwlEgg> {
public static final Factory FACTORY = new Factory();
public RenderEntityOwlEgg(RenderManager renderManagerIn, RenderItem itemRendererIn) {
super(renderManagerIn, ModObject.item_owl_egg.getItemNN(), itemRendererIn);
}
@Override
public void doRender(@Nonnull EntityOwlEgg entity, double x, double y, double z, float entityYaw, float partialTicks) {
super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
@Override
public @Nonnull ItemStack getStackToRender(@Nonnull EntityOwlEgg entityIn) {
return new ItemStack(ModObject.item_owl_egg.getItemNN());
}
public static class Factory implements IRenderFactory<EntityOwlEgg> {
@Override
public Render<? super EntityOwlEgg> createRenderFor(RenderManager manager) {
return new RenderEntityOwlEgg(manager, Minecraft.getMinecraft().getRenderItem());
}
}
}
| [
"[email protected]"
] | |
fb01c92b81452532cc73224e87e0f4d5779f0b11 | 30b6b7ebdedb3bb05399d64c5ad1150dbf456925 | /ucanaccess/tags/ucanaccess-3.0.6/src/test/java/net/ucanaccess/test/ColumnOrderTest.java | 97fffb962050c65683627a681c76c9be6cebf361 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | pchaozhong/ucanaccess-1 | 229e35d1507d6ad2aa2768953e15c96c19fe993f | e71f19748d5ec815f8bb27456c0aa66bf3492298 | refs/heads/master | 2020-03-31T11:20:39.568788 | 2017-04-14T18:26:18 | 2017-04-14T18:26:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,479 | java | /*
Copyright (c) 2012 Marco Amadei.
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 net.ucanaccess.test;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import com.healthmarketscience.jackcess.Database.FileFormat;
public class ColumnOrderTest extends UcanaccessTestBase {
public ColumnOrderTest() {
super();
}
public ColumnOrderTest(FileFormat accVer) {
super(accVer);
}
public String getAccessPath() {
return "net/ucanaccess/test/resources/columnOrder.accdb";
}
protected void setUp() throws Exception {}
public void testColumnOrder1() throws Exception {
super.setColumnOrder("display");
Connection uca = getUcanaccessConnection();
PreparedStatement ps=uca.prepareStatement("insert into t1 values (?,?,?)");
ps.setInt(3, 3);
ps.setDate(2, new Date(System.currentTimeMillis()));
ps.setString(1, "This is the display order");
ps.close();
uca.close();
}
}
| [
"jamadei@0d68d6fd-73e9-4e6e-8cf7-27d5ccde7a4d"
] | jamadei@0d68d6fd-73e9-4e6e-8cf7-27d5ccde7a4d |
3dbd90545faeff3bb7ddefb5e22fb96eab25ccd0 | 6b609e3f4f95082342428d2d8921b66429a26308 | /src/main/java/org/jpos/iso/channel/ChannelPool.java | 0f49bbe548a338fea716c8d0da61ea8fb9406295 | [] | no_license | an262110/nettyserver | 4b8f7ab9545d70af6c1e28e5e9ec6a4753fd7c92 | 1226fd4308eecee4c7fdc425029ef7853de8c6e4 | refs/heads/master | 2020-03-20T19:41:47.470139 | 2018-06-17T11:59:07 | 2018-06-17T11:59:07 | 137,649,336 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,567 | java | /*
* jPOS Project [http://jpos.org]
* Copyright (C) 2000-2010 Alejandro P. Revilla
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 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 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/>.
*/
package org.jpos.iso.channel;
import org.jpos.core.Configurable;
import org.jpos.core.Configuration;
import org.jpos.core.ConfigurationException;
import org.jpos.iso.ISOChannel;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOPackager;
import org.jpos.util.LogEvent;
import org.jpos.util.LogSource;
import org.jpos.util.Logger;
import org.jpos.util.NameRegistrar;
import java.io.IOException;
import java.util.List;
import java.util.Vector;
public class ChannelPool implements ISOChannel, LogSource, Configurable, Cloneable {
boolean usable = true;
String name = "";
protected Logger logger;
protected String realm;
Configuration cfg = null;
List pool;
ISOChannel current;
public ChannelPool () {
super ();
pool = new Vector ();
}
public void setPackager(ISOPackager p) {
// nothing to do
}
public synchronized void connect () throws IOException {
current = null;
LogEvent evt = new LogEvent(this, "connect");
evt.addMessage ("pool-size=" + Integer.toString (pool.size()));
for (int i=0; i<pool.size(); i++) {
try {
evt.addMessage ("pool-" + Integer.toString (i));
ISOChannel c = (ISOChannel) pool.get (i);
c.connect ();
if (c.isConnected()) {
current = c;
usable = true;
break;
}
} catch (IOException e) {
evt.addMessage (e);
}
}
if (current == null)
evt.addMessage ("connect failed");
Logger.log (evt);
if (current == null) {
throw new IOException ("unable to connect");
}
}
public synchronized void disconnect () throws IOException {
current = null;
LogEvent evt = new LogEvent(this, "disconnect");
for (int i=0; i<pool.size(); i++) {
try {
ISOChannel c = (ISOChannel) pool.get (i);
c.disconnect ();
} catch (IOException e) {
evt.addMessage (e);
}
}
Logger.log (evt);
}
public synchronized void reconnect() throws IOException {
disconnect ();
connect ();
}
public synchronized boolean isConnected() {
try {
return getCurrent().isConnected ();
} catch (IOException e) {
return false;
}
}
public ISOMsg receive() throws IOException, ISOException {
return getCurrent().receive ();
}
public void send (ISOMsg m) throws IOException, ISOException {
getCurrent().send (m);
}
public void send (byte[] b) throws IOException, ISOException {
getCurrent().send (b);
}
public void setUsable(boolean b) {
this.usable = b;
}
public void setName (String name) {
this.name = name;
NameRegistrar.register ("channel."+name, this);
}
public String getName() {
return this.name;
}
public ISOPackager getPackager () {
return (ISOPackager) null;
}
public void setLogger (Logger logger, String realm) {
this.logger = logger;
this.realm = realm;
}
public String getRealm () {
return realm;
}
public Logger getLogger() {
return logger;
}
public synchronized void setConfiguration (Configuration cfg)
throws ConfigurationException
{
this.cfg = cfg;
String channelName[] = cfg.getAll ("channel");
for (int i=0; i<channelName.length; i++) {
try {
addChannel (channelName[i]);
} catch (NameRegistrar.NotFoundException e) {
throw new ConfigurationException(e);
}
}
}
public void addChannel (ISOChannel channel) {
pool.add (channel);
}
public void addChannel (String name)
throws NameRegistrar.NotFoundException
{
pool.add ((ISOChannel) NameRegistrar.get ("channel."+name));
}
public void removeChannel (ISOChannel channel) {
pool.remove (channel);
}
public void removeChannel (String name) throws NameRegistrar.NotFoundException {
pool.remove ((ISOChannel) NameRegistrar.get ("channel."+name));
}
public int size() {
return pool.size();
}
public synchronized ISOChannel getCurrent () throws IOException {
if (current == null)
connect();
else if (!usable)
reconnect();
return current;
}
public Object clone(){
try {
return (ChannelPool)super.clone();
} catch (CloneNotSupportedException e) {
throw new InternalError();
}
}
}
| [
"[email protected]"
] | |
a6275acddca4d2196f4ecbeeb888d9f0dfb76d9b | b3571dbbfe3eadbf095b968b6d47a100607c44e9 | /src/controlador/PrinciplaController.java | 55efcbf262f663aebddb9bfc142443e8ede952e6 | [] | no_license | warrenxxx/alim22 | d8177251a9ac0f30d2d3e9cc6cafacaffc56eaa5 | 7cf518ce8805a64937d591c54ca47989705b0732 | refs/heads/master | 2021-01-18T20:39:10.331570 | 2017-04-02T12:02:27 | 2017-04-02T12:02:27 | 86,981,892 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,100 | 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 controlador;
import clases.CPersona;
import controlador.admi.SideController;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.Menu;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import static modelo.Fx2.USER;
/**
* FXML Controller class
*
* @author WARREN
*/
public class PrinciplaController implements Initializable {
/**
* Initializes the controller class.
*/
@FXML Menu file;
@FXML BorderPane borderPane;
public void init(String warren) throws IOException{
file.setText(warren);
if( warren.compareTo("1")==0){
FXMLLoader loader=new FXMLLoader(getClass().getResource("/vista/admi/side.fxml"));
VBox root =(VBox)loader.load();
SideController pc=(SideController)loader.getController();
pc.set_border_pane(borderPane);
borderPane.setLeft(root);
}
}
public void init(){
System.out.println("ss");
}
@Override
public void initialize(URL url, ResourceBundle rb) {
USER=new CPersona();
FXMLLoader loader=new FXMLLoader(getClass().getResource("/vista/admi/side.fxml"));
VBox root = null;
try {
root = (VBox)loader.load();
} catch (IOException ex) {
Logger.getLogger(PrinciplaController.class.getName()).log(Level.SEVERE, null, ex);
}
SideController pc=(SideController)loader.getController();
pc.set_border_pane(borderPane);
borderPane.setLeft(root);
}
}
| [
"ALIM@alim-6b335301f6"
] | ALIM@alim-6b335301f6 |
95e632abdd406943a50ed28350964401f09adf83 | b9ab86c9dd3a742aea8f0bace53c11c3027b32a4 | /src/main/java/com/alibaba/middleware/race/rpc/model/RpcResponse.java | f95941158ec90b615016450f5886b3ba46364b64 | [] | no_license | janck13/my-RPC-Framwork | 62b0386500e022ff9b97902655f264e07427fa6e | ca4d5f1adae086151fe424b0fa4a33e10ee111c0 | refs/heads/master | 2020-05-21T21:24:16.109734 | 2016-02-09T12:57:04 | 2016-02-09T12:57:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,716 | java | /**
*
*/
package com.alibaba.middleware.race.rpc.model;
import java.io.Serializable;
/**
* @author keehang
*
*/
public class RpcResponse implements Serializable {
/**
*
*/
private static final long serialVersionUID = -225640454370459555L;
private String errorMsg; //这个用来返回异常信息
private Object appResponse; //这个用来返回结果
//一切响应消息都通过调用下面的工厂方法创建
public synchronized static RpcResponse factory(long requestId,Object appResponse,String errorMsg){ //这个方法需要一定的线程安全性
return new RpcResponse(requestId,appResponse,errorMsg);
}
private RpcResponse(long requestId,Object appResponse, String errorMsg){
this.requestId = requestId;
this.appResponse = appResponse;
this.errorMsg = errorMsg;
}
public Object getAppResponse() {
return appResponse;
}
public String getErrorMsg() {
return errorMsg;
}
public boolean isError(){
return errorMsg == null ? false:true;
}
private long requestId; //增加一个请求Id,用以区别请求
public long getRequestId(){
return requestId;
}
/**
* @param errorMsg the errorMsg to set
*/
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
/**
* @param appResponse the appResponse to set
*/
public void setAppResponse(Object appResponse) {
this.appResponse = appResponse;
}
/**
* @param requestId the requestId to set
*/
public void setRequestId(long requestId) {
this.requestId = requestId;
}
}
| [
"[email protected]"
] | |
c6bca7348cb45fb77e7c2fc9c9ab813a221ca2e7 | 8fc86deabf8a0316df1af39442b79f62e811a8c4 | /src/main/java/com/nanda/java8/strings/SplitStrings.java | 3fc896077f7bf456684569da7adc4dc10c599893 | [] | no_license | nandansn/java8 | 346fb4b06802091af4a928f493a8080ea001d35b | 5d151cc52bcbf2011e58f9d5f85f43de67114354 | refs/heads/master | 2022-03-07T07:03:14.967008 | 2019-11-30T15:57:03 | 2019-11-30T15:57:03 | 116,780,752 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 70 | java | package com.nanda.java8.strings;
public class SplitStrings {
}
| [
"[email protected]"
] | |
8451ca74661e5ee58e92b8ea0d366c205e697e95 | 88e4c2a0f6e9097efe89b47612509f32b79badb8 | /src/main/java/com/alipay/api/response/AlipayMobileBeaconDeviceModifyResponse.java | c1227a0bb86ad4c9e976539b4d7102ab0a2f9674 | [] | no_license | xushaomin/alipay-sdk-java | 15f8e311b6ded9a565f473cd732e2747ed33d8b0 | a03324a1ddc6eb3469c18f831512d5248bc98461 | refs/heads/master | 2020-06-15T13:26:40.913354 | 2016-12-01T12:23:27 | 2016-12-01T12:23:27 | 75,289,929 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 811 | java | package com.alipay.api.response;
import com.alipay.api.internal.mapping.ApiField;
import com.alipay.api.AlipayResponse;
/**
* ALIPAY API: alipay.mobile.beacon.device.modify response.
*
* @author auto create
* @since 1.0, 2015-02-03 19:48:29
*/
public class AlipayMobileBeaconDeviceModifyResponse extends AlipayResponse {
private static final long serialVersionUID = 8691383457445268438L;
/**
* 返回的操作码
*/
@ApiField("code")
private String code;
/**
* 操作结果说明
*/
@ApiField("msg")
private String msg;
public void setCode(String code) {
this.code = code;
}
public String getCode( ) {
return this.code;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getMsg( ) {
return this.msg;
}
}
| [
"[email protected]"
] | |
e82855dad1d97c171a0146d59b524780fad2e112 | 3e48cec4fcd759da71f615e69e8f8b08dd6c2e79 | /iot-cloud3/iot-cloud-web-admin/src/main/java/net/work100/training/stage2/iot/cloud/web/admin/web/interceptor/LoginInterceptor.java | 06b60e0cf40e60c8f2a287c6c87472727cc0f016 | [] | no_license | work100-net/training-stage2 | 615bb464b6d3993a3e0367fc34285f0983e9d62d | f130f9077f83d5a2829202549f7581d64412d8d8 | refs/heads/master | 2022-12-22T08:59:46.026883 | 2021-11-29T04:32:55 | 2021-11-29T04:32:55 | 238,898,365 | 3 | 6 | null | 2022-12-16T15:25:32 | 2020-02-07T10:37:15 | JavaScript | UTF-8 | Java | false | false | 1,695 | java | package net.work100.training.stage2.iot.cloud.web.admin.web.interceptor;
import net.work100.training.stage2.iot.cloud.commons.constant.ConstantUtils;
import net.work100.training.stage2.iot.cloud.commons.utils.SessionUtils;
import net.work100.training.stage2.iot.cloud.domain.AuthManager;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* <p>Title: LoginInterceptor</p>
* <p>Description: </p>
* <p>Url: http://www.work100.net/training/monolithic-project-iot-cloud-admin.html</p>
*
* @author liuxiaojun
* @date 2020-02-20 16:22
* ------------------- History -------------------
* <date> <author> <desc>
* 2020-02-20 liuxiaojun 初始创建
* -----------------------------------------------
*/
public class LoginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
AuthManager authManager = SessionUtils.get(request, ConstantUtils.SESSION_MANAGER);
// 未登录
if (authManager == null) {
response.sendRedirect("/login");
}
// 为 true 时放行,进入 postHandle
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
}
}
| [
"[email protected]"
] | |
e93ef6810ee5ce8d0b013e2813fdbd905cbce4b8 | 8af1164bac943cef64e41bae312223c3c0e38114 | /results-java/JetBrains--intellij-community/dc181637f24f1ec18c690d3bcc51f3010cf91045/before/IncProjectBuilder.java | 4fcdea4f03b3d98b6aa1dcc2d0dccbffd7a1df3f | [] | no_license | fracz/refactor-extractor | 3ae45c97cc63f26d5cb8b92003b12f74cc9973a9 | dd5e82bfcc376e74a99e18c2bf54c95676914272 | refs/heads/master | 2021-01-19T06:50:08.211003 | 2018-11-30T13:00:57 | 2018-11-30T13:00:57 | 87,353,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 42,999 | java | package org.jetbrains.jps.incremental;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ConcurrentHashSet;
import com.intellij.util.io.MappingFailedException;
import com.intellij.util.io.PersistentEnumerator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.ether.dependencyView.Callbacks;
import org.jetbrains.jps.*;
import org.jetbrains.jps.api.CanceledStatus;
import org.jetbrains.jps.api.GlobalOptions;
import org.jetbrains.jps.api.RequestFuture;
import org.jetbrains.jps.api.SharedBuilderThreadPool;
import org.jetbrains.jps.cmdline.ProjectDescriptor;
import org.jetbrains.jps.incremental.fs.BuildFSState;
import org.jetbrains.jps.incremental.fs.RootDescriptor;
import org.jetbrains.jps.incremental.java.ExternalJavacDescriptor;
import org.jetbrains.jps.incremental.java.JavaBuilder;
import org.jetbrains.jps.incremental.java.JavaBuilderLogger;
import org.jetbrains.jps.incremental.messages.*;
import org.jetbrains.jps.incremental.storage.*;
import org.jetbrains.jps.model.java.JpsJavaClasspathKind;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.service.SharedThreadPool;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
/**
* @author Eugene Zhuravlev
* Date: 9/17/11
*/
public class IncProjectBuilder {
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.IncProjectBuilder");
public static final String BUILD_NAME = "EXTERNAL BUILD";
private static final String CLASSPATH_INDEX_FINE_NAME = "classpath.index";
private static final boolean GENERATE_CLASSPATH_INDEX = Boolean.parseBoolean(System.getProperty(GlobalOptions.GENERATE_CLASSPATH_INDEX_OPTION, "false"));
private static final boolean PARALLEL_BUILD_ENABLED = Boolean.parseBoolean(System.getProperty(GlobalOptions.COMPILE_PARALLEL_OPTION, "false"));
private final ProjectDescriptor myProjectDescriptor;
private final BuilderRegistry myBuilderRegistry;
private final Map<String, String> myBuilderParams;
private final CanceledStatus myCancelStatus;
@Nullable private final Callbacks.ConstantAffectionResolver myConstantSearch;
private ProjectChunks myProductionChunks;
private ProjectChunks myTestChunks;
private final List<MessageHandler> myMessageHandlers = new ArrayList<MessageHandler>();
private final MessageHandler myMessageDispatcher = new MessageHandler() {
public void processMessage(BuildMessage msg) {
for (MessageHandler h : myMessageHandlers) {
h.processMessage(msg);
}
}
};
private volatile float myModulesProcessed = 0.0f;
private final float myTotalModulesWork;
private final int myTotalModuleLevelBuilderCount;
private final List<Future> myAsyncTasks = new ArrayList<Future>();
public IncProjectBuilder(ProjectDescriptor pd, BuilderRegistry builderRegistry, Map<String, String> builderParams, CanceledStatus cs,
@Nullable Callbacks.ConstantAffectionResolver constantSearch) {
myProjectDescriptor = pd;
myBuilderRegistry = builderRegistry;
myBuilderParams = builderParams;
myCancelStatus = cs;
myConstantSearch = constantSearch;
myProductionChunks = new ProjectChunks(pd.jpsProject, JpsJavaClasspathKind.PRODUCTION_COMPILE);
myTestChunks = new ProjectChunks(pd.jpsProject, JpsJavaClasspathKind.TEST_COMPILE);
myTotalModulesWork = (float)pd.rootsIndex.getTotalModuleCount() * 2; /* multiply by 2 to reflect production and test sources */
myTotalModuleLevelBuilderCount = builderRegistry.getModuleLevelBuilderCount();
}
public void addMessageHandler(MessageHandler handler) {
myMessageHandlers.add(handler);
}
public void build(CompileScope scope, final boolean isMake, final boolean isProjectRebuild, boolean forceCleanCaches)
throws RebuildRequestedException {
final LowMemoryWatcher memWatcher = LowMemoryWatcher.register(new Runnable() {
@Override
public void run() {
myProjectDescriptor.dataManager.flush(false);
myProjectDescriptor.timestamps.getStorage().force();
}
});
CompileContextImpl context = null;
try {
context = createContext(scope, isMake, isProjectRebuild);
runBuild(context, forceCleanCaches);
myProjectDescriptor.dataManager.saveVersion();
}
catch (ProjectBuildException e) {
final Throwable cause = e.getCause();
if (cause instanceof PersistentEnumerator.CorruptedException ||
cause instanceof MappingFailedException ||
cause instanceof IOException) {
myMessageDispatcher.processMessage(new CompilerMessage(
BUILD_NAME, BuildMessage.Kind.INFO,
"Internal caches are corrupted or have outdated format, forcing project rebuild: " +
e.getMessage())
);
throw new RebuildRequestedException(cause);
}
else {
if (cause == null) {
final String msg = e.getMessage();
if (!StringUtil.isEmpty(msg)) {
myMessageDispatcher.processMessage(new ProgressMessage(msg));
}
}
else {
myMessageDispatcher.processMessage(new CompilerMessage(BUILD_NAME, cause));
}
}
}
finally {
memWatcher.stop();
flushContext(context);
// wait for the async tasks
for (Future task : myAsyncTasks) {
try {
task.get();
}
catch (Throwable th) {
LOG.info(th);
}
}
}
}
private static void flushContext(CompileContext context) {
if (context != null) {
final ProjectDescriptor pd = context.getProjectDescriptor();
pd.timestamps.getStorage().force();
pd.dataManager.flush(false);
}
final ExternalJavacDescriptor descriptor = ExternalJavacDescriptor.KEY.get(context);
if (descriptor != null) {
try {
final RequestFuture future = descriptor.client.sendShutdownRequest();
future.waitFor(500L, TimeUnit.MILLISECONDS);
}
finally {
// ensure process is not running
descriptor.process.destroyProcess();
}
ExternalJavacDescriptor.KEY.set(context, null);
}
//cleanupJavacNameTable();
}
private static boolean ourClenupFailed = false;
private static void cleanupJavacNameTable() {
try {
if (JavaBuilder.USE_EMBEDDED_JAVAC && !ourClenupFailed) {
final Field freelistField = Class.forName("com.sun.tools.javac.util.Name$Table").getDeclaredField("freelist");
freelistField.setAccessible(true);
freelistField.set(null, com.sun.tools.javac.util.List.nil());
}
}
catch (Throwable e) {
ourClenupFailed = true;
//LOG.info(e);
}
}
private float updateFractionBuilderFinished(final float delta) {
myModulesProcessed += delta;
float processed = myModulesProcessed;
return processed / myTotalModulesWork;
}
private void runBuild(CompileContextImpl context, boolean forceCleanCaches) throws ProjectBuildException {
context.setDone(0.0f);
LOG.info("Building project '" + context.getProjectDescriptor().project.getProjectName() + "'; isRebuild:" + context.isProjectRebuild() + "; isMake:" + context.isMake() + " parallel compilation:" + PARALLEL_BUILD_ENABLED);
for (ProjectLevelBuilder builder : myBuilderRegistry.getProjectLevelBuilders()) {
builder.buildStarted(context);
}
for (ModuleLevelBuilder builder : myBuilderRegistry.getModuleLevelBuilders()) {
builder.buildStarted(context);
}
try {
if (context.isProjectRebuild() || forceCleanCaches) {
cleanOutputRoots(context);
}
context.processMessage(new ProgressMessage("Running 'before' tasks"));
runTasks(context, myBuilderRegistry.getBeforeTasks());
context.setCompilingTests(false);
context.processMessage(new ProgressMessage("Checking production sources"));
buildChunks(context, myProductionChunks);
context.setCompilingTests(true);
context.processMessage(new ProgressMessage("Checking test sources"));
buildChunks(context, myTestChunks);
context.processMessage(new ProgressMessage("Building project"));
runProjectLevelBuilders(context);
context.processMessage(new ProgressMessage("Running 'after' tasks"));
runTasks(context, myBuilderRegistry.getAfterTasks());
// cleanup output roots layout, commented for efficiency
//final ModuleOutputRootsLayout outputRootsLayout = context.getDataManager().getOutputRootsLayout();
//try {
// final Iterator<String> keysIterator = outputRootsLayout.getKeysIterator();
// final Map<String, JpsModule> modules = myProjectDescriptor.project.getModules();
// while (keysIterator.hasNext()) {
// final String moduleName = keysIterator.next();
// if (modules.containsKey(moduleName)) {
// outputRootsLayout.remove(moduleName);
// }
// }
//}
//catch (IOException e) {
// throw new ProjectBuildException(e);
//}
}
finally {
for (ProjectLevelBuilder builder : myBuilderRegistry.getProjectLevelBuilders()) {
builder.buildFinished(context);
}
for (ModuleLevelBuilder builder : myBuilderRegistry.getModuleLevelBuilders()) {
builder.buildFinished(context);
}
context.processMessage(new ProgressMessage("Finished, saving caches..."));
}
}
private CompileContextImpl createContext(CompileScope scope, boolean isMake, final boolean isProjectRebuild) throws ProjectBuildException {
final CompileContextImpl context = new CompileContextImpl(
scope, myProjectDescriptor, isMake, isProjectRebuild, myProductionChunks, myTestChunks, myMessageDispatcher,
myBuilderParams, myCancelStatus
);
ModuleLevelBuilder.CONSTANT_SEARCH_SERVICE.set(context, myConstantSearch);
return context;
}
private void cleanOutputRoots(CompileContext context) throws ProjectBuildException {
// whole project is affected
final boolean shouldClear = context.getProjectDescriptor().project.getCompilerConfiguration().isClearOutputDirectoryOnRebuild();
try {
if (shouldClear) {
clearOutputs(context);
}
else {
for (JpsModule module : context.getProjectDescriptor().jpsProject.getModules()) {
final String moduleName = module.getName();
clearOutputFiles(context, moduleName, true);
clearOutputFiles(context, moduleName, false);
}
}
}
catch (IOException e) {
throw new ProjectBuildException("Error cleaning output files", e);
}
try {
context.getProjectDescriptor().timestamps.getStorage().clean();
}
catch (IOException e) {
throw new ProjectBuildException("Error cleaning timestamps storage", e);
}
try {
context.getProjectDescriptor().dataManager.clean();
}
catch (IOException e) {
throw new ProjectBuildException("Error cleaning compiler storages", e);
}
myProjectDescriptor.fsState.clearAll();
}
private static void clearOutputFiles(CompileContext context, final String moduleName, boolean forTests) throws IOException {
final SourceToOutputMapping map = context.getProjectDescriptor().dataManager.getSourceToOutputMap(moduleName, forTests);
for (String srcPath : map.getKeys()) {
final Collection<String> outs = map.getState(srcPath);
if (outs != null && !outs.isEmpty()) {
for (String out : outs) {
new File(out).delete();
}
context.processMessage(new FileDeletedEvent(outs));
}
}
}
private void clearOutputs(CompileContext context) throws ProjectBuildException, IOException {
final Collection<JpsModule> modulesToClean = context.getProjectDescriptor().jpsProject.getModules();
final Map<File, Set<Pair<String, Boolean>>> rootsToDelete = new HashMap<File, Set<Pair<String, Boolean>>>(); // map: outputRoot-> setOfPairs([module, isTest])
final Set<File> annotationOutputs = new HashSet<File>(); // separate collection because no root intersection checks needed for annotation generated sources
final Set<File> allSourceRoots = new HashSet<File>();
final ProjectPaths paths = context.getProjectPaths();
for (JpsModule module : modulesToClean) {
final File out = paths.getModuleOutputDir(module, false);
if (out != null) {
appendRootInfo(rootsToDelete, out, module, false);
}
final File testOut = paths.getModuleOutputDir(module, true);
if (testOut != null) {
appendRootInfo(rootsToDelete, testOut, module, true);
}
final AnnotationProcessingProfile profile = context.getAnnotationProcessingProfile(module);
if (profile.isEnabled()) {
File annotationOut =
paths.getAnnotationProcessorGeneratedSourcesOutputDir(module, false, profile.getGeneratedSourcesDirName());
if (annotationOut != null) {
annotationOutputs.add(annotationOut);
}
annotationOut =
paths.getAnnotationProcessorGeneratedSourcesOutputDir(module, true, profile.getGeneratedSourcesDirName());
if (annotationOut != null) {
annotationOutputs.add(annotationOut);
}
}
final List<RootDescriptor> moduleRoots = context.getProjectDescriptor().rootsIndex.getModuleRoots(context, module);
for (RootDescriptor d : moduleRoots) {
allSourceRoots.add(d.root);
}
}
// check that output and source roots are not overlapping
final List<File> filesToDelete = new ArrayList<File>();
for (Map.Entry<File, Set<Pair<String, Boolean>>> entry : rootsToDelete.entrySet()) {
context.checkCanceled();
boolean okToDelete = true;
final File outputRoot = entry.getKey();
if (JpsPathUtil.isUnder(allSourceRoots, outputRoot)) {
okToDelete = false;
}
else {
final Set<File> _outRoot = Collections.singleton(outputRoot);
for (File srcRoot : allSourceRoots) {
if (JpsPathUtil.isUnder(_outRoot, srcRoot)) {
okToDelete = false;
break;
}
}
}
if (okToDelete) {
// do not delete output root itself to avoid lots of unnecessary "roots_changed" events in IDEA
final File[] children = outputRoot.listFiles();
if (children != null) {
filesToDelete.addAll(Arrays.asList(children));
}
}
else {
context.processMessage(new CompilerMessage(BUILD_NAME, BuildMessage.Kind.WARNING, "Output path " +
outputRoot.getPath() +
" intersects with a source root. The output cannot be cleaned."));
// clean only those files we are aware of
for (Pair<String, Boolean> info : entry.getValue()) {
clearOutputFiles(context, info.first, info.second);
}
}
}
for (File annotationOutput : annotationOutputs) {
// do not delete output root itself to avoid lots of unnecessary "roots_changed" events in IDEA
final File[] children = annotationOutput.listFiles();
if (children != null) {
filesToDelete.addAll(Arrays.asList(children));
}
}
context.processMessage(new ProgressMessage("Cleaning output directories..."));
myAsyncTasks.add(
FileUtil.asyncDelete(filesToDelete)
);
}
private static void appendRootInfo(Map<File, Set<Pair<String, Boolean>>> rootsToDelete, File out, JpsModule module, boolean isTest) {
Set<Pair<String, Boolean>> infos = rootsToDelete.get(out);
if (infos == null) {
infos = new HashSet<Pair<String, Boolean>>();
rootsToDelete.put(out, infos);
}
infos.add(Pair.create(module.getName(), isTest));
}
private static void runTasks(CompileContext context, final List<BuildTask> tasks) throws ProjectBuildException {
for (BuildTask task : tasks) {
task.build(context);
}
}
private void buildChunks(final CompileContextImpl context, ProjectChunks chunks) throws ProjectBuildException {
final CompileScope scope = context.getScope();
final ProjectDescriptor pd = context.getProjectDescriptor();
try {
if (PARALLEL_BUILD_ENABLED) {
final List<ChunkGroup> chunkGroups = buildChunkGroups(context, chunks);
for (ChunkGroup group : chunkGroups) {
final List<ModuleChunk> groupChunks = group.getChunks();
final int chunkCount = groupChunks.size();
if (chunkCount == 0) {
continue;
}
try {
if (chunkCount == 1) {
_buildChunk(createContextWrapper(context), scope, groupChunks.iterator().next());
}
else {
final CountDownLatch latch = new CountDownLatch(chunkCount);
final Ref<Throwable> exRef = new Ref<Throwable>(null);
if (LOG.isDebugEnabled()) {
final StringBuilder logBuilder = new StringBuilder("Building chunks in parallel: ");
for (ModuleChunk chunk : groupChunks) {
logBuilder.append(chunk.getName()).append("; ");
}
LOG.debug(logBuilder.toString());
}
for (final ModuleChunk chunk : groupChunks) {
final CompileContext chunkLocalContext = createContextWrapper(context);
SharedBuilderThreadPool.INSTANCE.submitBuildTask(new Runnable() {
@Override
public void run() {
try {
_buildChunk(chunkLocalContext, scope, chunk);
}
catch (Throwable e) {
synchronized (exRef) {
if (exRef.isNull()) {
exRef.set(e);
}
}
LOG.info(e);
}
finally {
latch.countDown();
}
}
});
}
try {
latch.await();
}
catch (InterruptedException e) {
LOG.info(e);
}
final Throwable exception = exRef.get();
if (exception != null) {
if (exception instanceof ProjectBuildException) {
throw (ProjectBuildException)exception;
}
else {
throw new ProjectBuildException(exception);
}
}
}
}
finally {
pd.dataManager.closeSourceToOutputStorages(groupChunks, context.isCompilingTests());
pd.dataManager.flush(true);
}
}
}
else {
// non-parallel build
for (ModuleChunk chunk : chunks.getChunkList()) {
try {
_buildChunk(context, scope, chunk);
}
finally {
pd.dataManager.closeSourceToOutputStorages(Collections.singleton(chunk), context.isCompilingTests());
pd.dataManager.flush(true);
}
}
}
}
catch (IOException e) {
throw new ProjectBuildException(e);
}
}
private void _buildChunk(CompileContext context, CompileScope scope, ModuleChunk chunk) throws ProjectBuildException {
if (scope.isAffected(chunk)) {
buildChunk(context, chunk);
}
else {
final float fraction = updateFractionBuilderFinished(chunk.getModules().size());
context.setDone(fraction);
}
}
private void buildChunk(CompileContext context, final ModuleChunk chunk) throws ProjectBuildException {
boolean doneSomething = false;
try {
Utils.ERRORS_DETECTED_KEY.set(context, Boolean.FALSE);
ensureFSStateInitialized(context, chunk);
if (context.isMake()) {
processDeletedPaths(context, chunk);
doneSomething |= Utils.hasRemovedSources(context);
}
myProjectDescriptor.fsState.beforeChunkBuildStart(context, chunk);
doneSomething = runModuleLevelBuilders(context, chunk);
}
catch (ProjectBuildException e) {
throw e;
}
catch (Exception e) {
throw new ProjectBuildException(e);
}
finally {
try {
for (BuilderCategory category : BuilderCategory.values()) {
for (ModuleLevelBuilder builder : myBuilderRegistry.getBuilders(category)) {
builder.cleanupResources(context, chunk);
}
}
}
finally {
try {
onChunkBuildComplete(context, chunk);
}
catch (Exception e) {
throw new ProjectBuildException(e);
}
finally {
final Collection<RootDescriptor> tempRoots = context.getProjectDescriptor().rootsIndex.clearTempRoots(context);
if (!tempRoots.isEmpty()) {
final Set<File> rootFiles = new HashSet<File>();
for (RootDescriptor rd : tempRoots) {
rootFiles.add(rd.root);
context.getProjectDescriptor().fsState.clearRecompile(rd);
}
myAsyncTasks.add(
FileUtil.asyncDelete(rootFiles)
);
}
try {
// restore deleted paths that were not procesesd by 'integrate'
final Map<String, Collection<String>> map = Utils.REMOVED_SOURCES_KEY.get(context);
if (map != null) {
final boolean forTests = context.isCompilingTests();
for (Map.Entry<String, Collection<String>> entry : map.entrySet()) {
final String moduleName = entry.getKey();
final Collection<String> paths = entry.getValue();
if (paths != null) {
for (String path : paths) {
myProjectDescriptor.fsState.registerDeleted(moduleName, new File(path), forTests, null);
}
}
}
}
}
catch (IOException e) {
throw new ProjectBuildException(e);
}
Utils.REMOVED_SOURCES_KEY.set(context, null);
if (doneSomething && GENERATE_CLASSPATH_INDEX) {
final boolean forTests = context.isCompilingTests();
final Future<?> future = SharedThreadPool.getInstance().executeOnPooledThread(new Runnable() {
@Override
public void run() {
createClasspathIndex(chunk, forTests);
}
});
myAsyncTasks.add(future);
}
}
}
}
}
private static void createClasspathIndex(final ModuleChunk chunk, boolean forTests) {
final Set<File> outputPaths = new LinkedHashSet<File>();
for (JpsModule module : chunk.getModules()) {
final String outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, forTests);
if (outputUrl != null) {
outputPaths.add(JpsPathUtil.urlToFile(outputUrl));
}
}
for (File outputRoot : outputPaths) {
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(outputRoot, CLASSPATH_INDEX_FINE_NAME)));
try {
writeIndex(writer, outputRoot, "");
}
finally {
writer.close();
}
}
catch (IOException e) {
// Ignore. Failed to create optional classpath index
}
}
}
private static void writeIndex(final BufferedWriter writer, final File file, final String path) throws IOException {
writer.write(path);
writer.write('\n');
final File[] files = file.listFiles();
if (files != null) {
for (File child : files) {
final String _path = path.isEmpty() ? child.getName() : path + "/" + child.getName();
writeIndex(writer, child, _path);
}
}
}
private void processDeletedPaths(CompileContext context, ModuleChunk chunk) throws ProjectBuildException {
try {
// cleanup outputs
final Map<String, Collection<String>> removedSources = new HashMap<String, Collection<String>>();
for (JpsModule module : chunk.getModules()) {
final Collection<String> deletedPaths = myProjectDescriptor.fsState.getAndClearDeletedPaths(module.getName(),
context.isCompilingTests());
if (deletedPaths.isEmpty()) {
continue;
}
removedSources.put(module.getName(), deletedPaths);
final SourceToOutputMapping sourceToOutputStorage = context.getProjectDescriptor().dataManager.getSourceToOutputMap(module.getName(), context.isCompilingTests());
// actually delete outputs associated with removed paths
for (String deletedSource : deletedPaths) {
// deleting outputs corresponding to non-existing source
final Collection<String> outputs = sourceToOutputStorage.getState(deletedSource);
if (outputs != null && !outputs.isEmpty()) {
final JavaBuilderLogger logger = context.getLoggingManager().getJavaBuilderLogger();
if (logger.isEnabled()) {
final String[] buffer = new String[outputs.size()];
int i = 0;
for (final String o : outputs) {
buffer[i++] = o;
}
Arrays.sort(buffer);
logger.log("Cleaning output files:");
for (final String o : buffer) {
logger.log(o);
}
logger.log("End of files");
}
for (String output : outputs) {
new File(output).delete();
}
context.processMessage(new FileDeletedEvent(outputs));
}
// check if deleted source was associated with a form
final SourceToFormMapping sourceToFormMap = context.getProjectDescriptor().dataManager.getSourceToFormMap();
final String formPath = sourceToFormMap.getState(deletedSource);
if (formPath != null) {
final File formFile = new File(formPath);
if (formFile.exists()) {
FSOperations.markDirty(context, formFile);
}
sourceToFormMap.remove(deletedSource);
}
}
}
if (!removedSources.isEmpty()) {
final Map<String, Collection<String>> existing = Utils.REMOVED_SOURCES_KEY.get(context);
if (existing != null) {
for (Map.Entry<String, Collection<String>> entry : existing.entrySet()) {
final Collection<String> paths = removedSources.get(entry.getKey());
if (paths != null) {
paths.addAll(entry.getValue());
}
else {
removedSources.put(entry.getKey(), entry.getValue());
}
}
}
Utils.REMOVED_SOURCES_KEY.set(context, removedSources);
}
}
catch (IOException e) {
throw new ProjectBuildException(e);
}
}
// return true if changed something, false otherwise
private boolean runModuleLevelBuilders(final CompileContext context, ModuleChunk chunk) throws ProjectBuildException {
boolean doneSomething = false;
boolean rebuildFromScratchRequested = false;
float stageCount = myTotalModuleLevelBuilderCount;
final int modulesInChunk = chunk.getModules().size();
int buildersPassed = 0;
boolean nextPassRequired;
do {
nextPassRequired = false;
myProjectDescriptor.fsState.beforeNextRoundStart(context, chunk);
if (!context.isProjectRebuild()) {
syncOutputFiles(context, chunk);
}
BUILDER_CATEGORY_LOOP:
for (BuilderCategory category : BuilderCategory.values()) {
final List<ModuleLevelBuilder> builders = myBuilderRegistry.getBuilders(category);
if (builders.isEmpty()) {
continue;
}
for (ModuleLevelBuilder builder : builders) {
if (context.isMake()) {
processDeletedPaths(context, chunk);
}
final ModuleLevelBuilder.ExitCode buildResult = builder.build(context, chunk);
doneSomething |= (buildResult != ModuleLevelBuilder.ExitCode.NOTHING_DONE);
if (buildResult == ModuleLevelBuilder.ExitCode.ABORT) {
throw new ProjectBuildException("Builder " + builder.getDescription() + " requested build stop");
}
context.checkCanceled();
if (buildResult == ModuleLevelBuilder.ExitCode.ADDITIONAL_PASS_REQUIRED) {
if (!nextPassRequired) {
// recalculate basis
myModulesProcessed -= (buildersPassed * modulesInChunk) / stageCount;
stageCount += myTotalModuleLevelBuilderCount;
myModulesProcessed += (buildersPassed * modulesInChunk) / stageCount;
}
nextPassRequired = true;
}
else if (buildResult == ModuleLevelBuilder.ExitCode.CHUNK_REBUILD_REQUIRED) {
if (!rebuildFromScratchRequested && !context.isProjectRebuild()) {
LOG.info("Builder " + builder.getDescription() + " requested rebuild of module chunk " + chunk.getName());
// allow rebuild from scratch only once per chunk
rebuildFromScratchRequested = true;
try {
// forcibly mark all files in the chunk dirty
FSOperations.markDirty(context, chunk);
// reverting to the beginning
myModulesProcessed -= (buildersPassed * modulesInChunk) / stageCount;
stageCount = myTotalModuleLevelBuilderCount;
buildersPassed = 0;
nextPassRequired = true;
break BUILDER_CATEGORY_LOOP;
}
catch (Exception e) {
throw new ProjectBuildException(e);
}
}
else {
context.getLoggingManager().getJavaBuilderLogger().log(
"Builder " + builder.getDescription() + " requested second chunk rebuild");
}
}
buildersPassed++;
final float fraction = updateFractionBuilderFinished(modulesInChunk / (stageCount));
context.setDone(fraction);
}
}
}
while (nextPassRequired);
return doneSomething;
}
private void runProjectLevelBuilders(CompileContext context) throws ProjectBuildException {
for (ProjectLevelBuilder builder : myBuilderRegistry.getProjectLevelBuilders()) {
builder.build(context);
context.checkCanceled();
}
}
private static void syncOutputFiles(final CompileContext context, ModuleChunk chunk) throws ProjectBuildException {
final BuildDataManager dataManager = context.getProjectDescriptor().dataManager;
final boolean compilingTests = context.isCompilingTests();
try {
final Collection<String> allOutputs = new LinkedList<String>();
FSOperations.processFilesToRecompile(context, chunk, new FileProcessor() {
private final Map<JpsModule, SourceToOutputMapping> storageMap = new HashMap<JpsModule, SourceToOutputMapping>();
@Override
public boolean apply(JpsModule module, File file, String sourceRoot) throws IOException {
SourceToOutputMapping srcToOut = storageMap.get(module);
if (srcToOut == null) {
srcToOut = dataManager.getSourceToOutputMap(module.getName(), compilingTests);
storageMap.put(module, srcToOut);
}
final String srcPath = FileUtil.toSystemIndependentName(file.getPath());
final Collection<String> outputs = srcToOut.getState(srcPath);
if (outputs != null) {
final JavaBuilderLogger logger = context.getLoggingManager().getJavaBuilderLogger();
for (String output : outputs) {
if (logger.isEnabled()) {
allOutputs.add(output);
}
new File(output).delete();
}
if (!outputs.isEmpty()) {
context.processMessage(new FileDeletedEvent(outputs));
}
srcToOut.remove(srcPath);
}
return true;
}
});
final JavaBuilderLogger logger = context.getLoggingManager().getJavaBuilderLogger();
if (logger.isEnabled()) {
if (context.isMake() && allOutputs.size() > 0) {
logger.log("Cleaning output files:");
final String[] buffer = new String[allOutputs.size()];
int i = 0;
for (String output : allOutputs) {
buffer[i++] = output;
}
Arrays.sort(buffer);
for (String output : buffer) {
logger.log(output);
}
logger.log("End of files");
}
}
}
catch (Exception e) {
throw new ProjectBuildException(e);
}
}
private static List<ChunkGroup> buildChunkGroups(CompileContext context, ProjectChunks chunks) {
final List<ModuleChunk> allChunks = chunks.getChunkList();
// building aux dependencies map
final Map<JpsModule, Set<JpsModule>> depsMap = new HashMap<JpsModule, Set<JpsModule>>();
final boolean compilingTests = context.isCompilingTests();
for (JpsModule module : context.getProjectDescriptor().jpsProject.getModules()) {
Set<JpsModule> dependent = depsMap.get(module);
if (dependent == null) {
dependent = ProjectPaths.getModulesWithDependentsRecursively(module, compilingTests);
dependent.remove(module);
depsMap.put(module, dependent);
}
}
final List<ChunkGroup> groups = new ArrayList<ChunkGroup>();
ChunkGroup currentGroup = new ChunkGroup();
groups.add(currentGroup);
for (ModuleChunk chunk : allChunks) {
if (dependsOnGroup(chunk, currentGroup, depsMap)) {
currentGroup = new ChunkGroup();
groups.add(currentGroup);
}
currentGroup.addChunk(chunk);
}
return groups;
}
public static boolean dependsOnGroup(ModuleChunk chunk, ChunkGroup group, Map<JpsModule, Set<JpsModule>> depsMap) {
for (ModuleChunk groupChunk : group.getChunks()) {
final Set<JpsModule> groupChunkModules = groupChunk.getModules();
for (JpsModule module : chunk.getModules()) {
if (Utils.intersects(depsMap.get(module), groupChunkModules)) {
return true;
}
}
}
return false;
}
private static void onChunkBuildComplete(CompileContext context, @NotNull ModuleChunk chunk) throws IOException {
final ProjectDescriptor pd = context.getProjectDescriptor();
final BuildFSState fsState = pd.fsState;
fsState.clearContextRoundData(context);
fsState.clearContextChunk(context);
if (!Utils.errorsDetected(context) && !context.getCancelStatus().isCanceled()) {
boolean marked = false;
for (JpsModule module : chunk.getModules()) {
if (context.isMake()) {
// ensure non-incremental flag cleared
context.clearNonIncrementalMark(module);
}
if (context.isProjectRebuild()) {
fsState.markInitialScanPerformed(module.getName(), context.isCompilingTests());
}
final Timestamps timestamps = pd.timestamps.getStorage();
final List<RootDescriptor> roots = pd.rootsIndex.getModuleRoots(context, module);
for (RootDescriptor rd : roots) {
if (context.isCompilingTests() ? rd.isTestRoot : !rd.isTestRoot) {
marked |= fsState.markAllUpToDate(context.getScope(), rd, timestamps, context.getCompilationStartStamp());
}
}
}
if (marked) {
context.processMessage(UptoDateFilesSavedEvent.INSTANCE);
}
}
}
private static void ensureFSStateInitialized(CompileContext context, ModuleChunk chunk) throws IOException {
final ProjectDescriptor pd = context.getProjectDescriptor();
final Timestamps timestamps = pd.timestamps.getStorage();
for (JpsModule module : chunk.getModules()) {
if (context.isProjectRebuild()) {
FSOperations.markDirtyFiles(context, module, timestamps, true,
context.isCompilingTests() ? FSOperations.DirtyMarkScope.TESTS : FSOperations.DirtyMarkScope.PRODUCTION, null);
updateOutputRootsLayout(context, module);
}
else {
if (context.isMake()) {
if (pd.fsState.markInitialScanPerformed(module.getName(), context.isCompilingTests())) {
initModuleFSState(context, module);
updateOutputRootsLayout(context, module);
}
}
else {
// forced compilation mode
if (context.getScope().isRecompilationForced(module.getName())) {
FSOperations.markDirtyFiles(context, module, timestamps, true,
context.isCompilingTests() ? FSOperations.DirtyMarkScope.TESTS : FSOperations.DirtyMarkScope.PRODUCTION,
null);
updateOutputRootsLayout(context, module);
}
}
}
}
}
private static void initModuleFSState(CompileContext context, JpsModule module) throws IOException {
boolean forceMarkDirty = false;
final File currentOutput = context.getProjectPaths().getModuleOutputDir(module, context.isCompilingTests());
final ProjectDescriptor pd = context.getProjectDescriptor();
if (currentOutput != null) {
Pair<String, String> outputsPair = pd.dataManager.getOutputRootsLayout().getState(module.getName());
if (outputsPair != null) {
final String previousPath = context.isCompilingTests() ? outputsPair.second : outputsPair.first;
forceMarkDirty = StringUtil.isEmpty(previousPath) || !FileUtil.filesEqual(currentOutput, new File(previousPath));
}
else {
forceMarkDirty = true;
}
}
final Timestamps timestamps = pd.timestamps.getStorage();
final HashSet<File> currentFiles = new HashSet<File>();
FSOperations.markDirtyFiles(context, module, timestamps, forceMarkDirty, context.isCompilingTests() ? FSOperations.DirtyMarkScope.TESTS : FSOperations.DirtyMarkScope.PRODUCTION, currentFiles);
// handle deleted paths
final BuildFSState fsState = pd.fsState;
fsState.clearDeletedPaths(module.getName(), context.isCompilingTests());
final SourceToOutputMapping sourceToOutputMap = pd.dataManager.getSourceToOutputMap(module.getName(), context.isCompilingTests());
for (final Iterator<String> it = sourceToOutputMap.getKeysIterator(); it.hasNext();) {
final String path = it.next();
// can check if the file exists
final File file = new File(path);
if (!currentFiles.contains(file)) {
fsState.registerDeleted(module.getName(), file, context.isCompilingTests(), timestamps);
}
}
}
private static void updateOutputRootsLayout(CompileContext context, JpsModule module) throws IOException {
final File currentOutput = context.getProjectPaths().getModuleOutputDir(module, context.isCompilingTests());
if (currentOutput == null) {
return;
}
final ModuleOutputRootsLayout outputRootsLayout = context.getProjectDescriptor().dataManager.getOutputRootsLayout();
Pair<String, String> outputsPair = outputRootsLayout.getState(module.getName());
// update data
final String productionPath;
final String testPath;
if (context.isCompilingTests()) {
productionPath = outputsPair != null? outputsPair.first : "";
testPath = FileUtil.toSystemIndependentName(currentOutput.getPath());
}
else {
productionPath = FileUtil.toSystemIndependentName(currentOutput.getPath());
testPath = outputsPair != null? outputsPair.second : "";
}
outputRootsLayout.update(module.getName(), Pair.create(productionPath, testPath));
}
private static class ChunkGroup {
private final List<ModuleChunk> myChunks = new ArrayList<ModuleChunk>();
public void addChunk(ModuleChunk chunk) {
myChunks.add(chunk);
}
public List<ModuleChunk> getChunks() {
return myChunks;
}
}
private static final Set<Key> GLOBAL_CONTEXT_KEYS = new HashSet<Key>();
static {
// keys for data that must be visible to all threads
GLOBAL_CONTEXT_KEYS.add(ExternalJavacDescriptor.KEY);
}
private static CompileContext createContextWrapper(final CompileContext delegate) {
final ClassLoader loader = delegate.getClass().getClassLoader();
final UserDataHolderBase localDataHolder = new UserDataHolderBase();
final Set deletedKeysSet = new ConcurrentHashSet();
final Class<UserDataHolder> dataHolderinterface = UserDataHolder.class;
final Class<MessageHandler> messageHandlerinterface = MessageHandler.class;
return (CompileContext)Proxy.newProxyInstance(loader, new Class[] {CompileContext.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
final Class<?> declaringClass = method.getDeclaringClass();
if (dataHolderinterface.equals(declaringClass)) {
final Object firstArgument = args[0];
final boolean isGlobalContextKey = firstArgument instanceof Key && GLOBAL_CONTEXT_KEYS.contains((Key)firstArgument);
if (!isGlobalContextKey) {
final boolean isWriteOperation = args.length == 2 /*&& void.class.equals(method.getReturnType())*/;
if (isWriteOperation) {
if (args[1] == null) {
deletedKeysSet.add(firstArgument);
}
else {
deletedKeysSet.remove(firstArgument);
}
}
else {
if (deletedKeysSet.contains(firstArgument)) {
return null;
}
}
final Object result = method.invoke(localDataHolder, args);
if (isWriteOperation || result != null) {
return result;
}
}
}
else if (messageHandlerinterface.equals(declaringClass)) {
final BuildMessage msg = (BuildMessage)args[0];
if (msg.getKind() == BuildMessage.Kind.ERROR) {
Utils.ERRORS_DETECTED_KEY.set(localDataHolder, Boolean.TRUE);
}
}
return method.invoke(delegate, args);
}
});
}
} | [
"[email protected]"
] | |
dbd936ae4d84a493e4e2f3e54765eb6bb7adde39 | e1b078a6d5ce30297cac45808e08c577535cca2a | /src/main/java/frc/robot/utils/filters/MovingAverageFilter.java | edd8c0ff9bd61ac44ad8609d3447373650c0a724 | [
"MIT"
] | permissive | frc6357/robot_code_2019 | 035a96a5614509565a95c2b41e64352f15adda8f | 7984592c4347ba143f4c9f73f21fdedcee6c4b7d | refs/heads/master | 2020-04-16T11:56:48.910115 | 2020-01-04T15:07:14 | 2020-01-04T15:07:14 | 165,558,321 | 1 | 1 | MIT | 2019-10-22T23:24:10 | 2019-01-13T21:49:45 | Java | UTF-8 | Java | false | false | 2,073 | java | package frc.robot.utils.filters;
/**
* This class creates a filter which has active dampening The function essentially works by creating a moving average and adjusting the
* returned value based on this average.
*/
public class MovingAverageFilter extends Filter
{
private int MAX_VALUES;
private double average, gain;
private boolean firstPass;
/**
* Constructor for an object with the given number of maximum values
*
* @param max
* the maximum number of values to be passed
*/
public MovingAverageFilter(int max)
{
gain = 1;
MAX_VALUES = max;
}
/**
* Constructor which allows you to pass both mmaximum number of values and gain
*
* @param max
* the max number of values calculated in the average
* @param g
* the gain to which you set the filter
*/
public MovingAverageFilter(int max, double g)
{
MAX_VALUES = max;
gain = g;
}
/**
* Filter which uses a moving average to calculate the rate of acceleration Primarily exists for gentler acceleration and reduced
* slippage
*
* @param rawAxis
* the data to be passed in, from -1 to 1
* @return the filtered data, which is generated with a moving average
*/
@Override
public double filter(double rawAxis)
{
if (firstPass)
{
average = rawAxis;
firstPass = false;
}
else
{
average -= average / MAX_VALUES;
average += rawAxis / MAX_VALUES;
}
return average * gain;
}
/**
* Sets the number of maximum values
*
* @param m
* the new number of maximum values
*/
public void setMaxValues(int m)
{
MAX_VALUES = m;
}
/**
* Sets the gain to a new parameter
*
* @param g
* the new gain with which to adjust output
*/
public void setGain(double g)
{
gain = g;
}
}
| [
"[email protected]"
] | |
bb2f8be32d88cd85d4d8bd807201e96d351e959e | 1ded2d159107f5f9273bbcfeeedbc93e3abd2983 | /src/main/java/com/venkat/algos/dp/BracesBalancer.java | 78014eb37776714f74640ace35ebacd0be1ea6fd | [] | no_license | venkatbabukr/Algos-And-Programs | 6b501dc475199365fa38623a36c8a433133fefc5 | 3f51fc6dc8b9d490d6ae2e0287e42f407f0a34a7 | refs/heads/master | 2023-09-01T02:30:21.387583 | 2023-08-25T13:40:31 | 2023-08-25T13:40:31 | 225,018,286 | 0 | 0 | null | 2021-07-30T07:21:53 | 2019-11-30T13:42:05 | Java | UTF-8 | Java | false | false | 2,702 | java | package com.venkat.algos.dp;
import java.util.HashSet;
import java.util.Set;
public class BracesBalancer {
private static final char OPEN_BRACE = '(';
private static final char CLOSED_BRACE = ')';
private boolean isBalanced(String str) {
int openBraceCount = 0;
if (str != null && str.length() > 0) {
char[] strArray = str.toCharArray();
for (int i = 0 ; i < strArray.length && openBraceCount > -1 ; i++) {
char c = strArray[i];
switch (c) {
case OPEN_BRACE:
openBraceCount++;
break;
case CLOSED_BRACE:
openBraceCount--;
break;
}
}
}
return(openBraceCount == 0);
}
public Set<String> balanceWithMinimumRemoval(String inputString) {
Set<String> balancedCombos = new HashSet<>();
Set<String> currentLevelCombos = new HashSet<>();
currentLevelCombos.add(inputString);
while (!currentLevelCombos.isEmpty()) {
Set<String> nextLevelCombos = new HashSet<>();
for (String str : currentLevelCombos) {
if (isBalanced(str)) {
balancedCombos.add(str);
/*
* Clear nextLevelCombos, as we have found balanced str at current level...
* Just iterate on the remaining strs at this level to see if we can get
* any other combination also balanced...
*/
nextLevelCombos.clear();
} else if (balancedCombos.isEmpty()) {
// If balanced string is not yet found...
for (int i = 0 ; i < str.length() ; i++) {
switch (str.charAt(i)) {
case OPEN_BRACE:
case CLOSED_BRACE:
String nextLevelStr = str.substring(0, i).concat(str.substring(i+1));
nextLevelCombos.add(nextLevelStr);
}
}
}
}
currentLevelCombos = nextLevelCombos;
}
return balancedCombos;
}
public static void main(String[] args) {
String[] imbalancedCases = new String[] {"((A())", "())((()", "())(", "())()("};
BracesBalancer balancer = new BracesBalancer();
for (String str : imbalancedCases) {
System.out.format("Balanced set for %s: %s\n", str, balancer.balanceWithMinimumRemoval(str));
}
}
}
| [
"[email protected]"
] | |
4e6e6eb1c3dfbad085bd2d89f7f77f4b7377caa5 | adae8ad2eb8c6836a69dd25b760c3c90e244f078 | /app/src/main/java/com/example/sarjhu/parkingtest/Otpgen.java | 5b587222ec970a75213de86b7d92fd938fe7e6df | [] | no_license | Sarjhana/ParkSmart | d59888b58c9e5fd7f03c28c7583effde718a1868 | 7487ac04fc12ae65427e685171140c0a90820c0d | refs/heads/master | 2021-05-22T21:16:18.666988 | 2020-04-04T21:13:22 | 2020-04-04T21:13:22 | 253,099,974 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,274 | java | package com.example.sarjhu.parkingtest;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.Random;
public class Otpgen extends AppCompatActivity {
Button generateRandom;
TextView randomResult;
Random myRandom;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_otpgen);
generateRandom = findViewById(R.id.generate);
randomResult = findViewById(R.id.randomresult);
//popup = findViewById(R.id.popup);
generateRandom.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String result = " ";
myRandom = new Random();
int rand = myRandom.nextInt(10000);
while(String.valueOf(rand).length()<5)
{
rand += rand;
}
result = String.valueOf(rand).substring(0,5);
randomResult.setText(String.valueOf(result));
}});
}
}
| [
"[email protected]"
] | |
4672eef1ec6770d65be0193f6823a2e0659adb23 | 9a942a741f3ab466be8b2807aba5272f80377498 | /app7/part0/src/X.java | 21740bc39205b26cdb8dc7f33cea291034e98ff8 | [] | no_license | Vijay-Ky/MyJavaPracticeTest | 82db8c507be9fde66f68efe3c3b7bb35dc086f67 | 6d427886b847e9af8a1af7d73ae8e340a4f47dd5 | refs/heads/master | 2021-09-27T18:45:11.963373 | 2018-11-17T15:17:07 | 2018-11-17T15:17:07 | 154,494,698 | 0 | 3 | null | 2021-09-23T01:16:57 | 2018-10-24T12:10:37 | Java | UTF-8 | Java | false | false | 186 | java | class X
{
int i;
public static void main(String[] args)
{
X x1 = new X();
X x2 = new X();
x1.i = 10;
x2.i = 20;
System.out.println(x1.i);
System.out.println(x2.i);
}
}
| [
"[email protected]"
] | |
71de3862fa1956b117e264b6bfaaaa66df4c3cb1 | d8931d2f25b36993d1c6e4f97f84d054634f74c6 | /src/main/java/net/codelizard/hoc/content/Hero.java | 913cc1ebf55579e03477d0814d088e68c646041a | [
"MIT"
] | permissive | Codelizard/HeroesOfCordan | 9dd213a24d2279be35dd1f5999799bb169c88dd1 | 6310fd00aa5feccf9080b4c14e3b76444745b6cd | refs/heads/master | 2020-11-29T20:56:25.518221 | 2018-05-07T22:25:44 | 2018-05-07T22:25:44 | 96,591,233 | 0 | 0 | MIT | 2018-05-06T14:58:48 | 2017-07-08T02:40:07 | Java | UTF-8 | Java | false | false | 4,385 | java | package net.codelizard.hoc.content;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;
/**
* Represents one of the titular Heroes of Cordan.
*
* @author Codelizard
*/
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonIgnoreProperties(ignoreUnknown=true)
public class Hero {
/** An internal-use ID. */
private String id;
/** The hero's default name if the player doesn't supply one. */
private String name;
/** The hero's RPG class (fighter, rogue, etc). */
@JsonProperty("class")
private String rpgClass;
/** A short description of the hero, such as "Physical Specialist" or "Arcane/Divine Hybrid". */
private String description;
/** A flavor text description about the (default) hero. */
private String flavor;
/** A quote from the hero. */
private String quote;
/** The discount the hero applies. */
private HeroDiscount discount;
/** The resources the character contributes at each level. */
private Map<Integer, Map<ResourceType, Integer>> resources;
/**
* @return An internal-use ID.
*/
public String getId() {
return id;
}
/**
* @return The hero's name, which can be overridden by the player.
*/
public String getName() {
return name;
}
/**
* @return The hero's RPG class (fighter, rogue, etc).
*/
public String getRpgClass() {
return rpgClass;
}
/**
* @return The hero's one-line description.
*/
public String getDescription() {
return description;
}
/**
* @return A description of the character.
*/
public String getFlavor() {
return flavor;
}
/**
* @return A quote from the default character.
*/
public String getQuote() {
return quote;
}
/**
* @return The discount the hero applies.
*/
public HeroDiscount getDiscount() {
return discount;
}
/**
* @return The resources the hero contributes to the party total each level.
*/
public Map<Integer, Map<ResourceType, Integer>> getResources() {
return resources;
}
/**
* @param id The new ID to use.
*/
public void setId(final String id) {
this.id = id;
}
/**
* @param name The new name to use.
*/
public void setName(final String name) {
this.name = name;
}
/**
* @param rpgClass The new RPG class to use.
*/
public void setRpgClass(final String rpgClass) {
this.rpgClass = rpgClass;
}
/**
* @param description The new description to use.
*/
public void setDescription(final String description) {
this.description = description;
}
/**
* @param flavor The new flavor text description to use.
*/
public void setFlavor(final String flavor) {
this.flavor = flavor;
}
/**
* @param quote The new character quote to use.
*/
public void setQuote(final String quote) {
this.quote = quote;
}
/**
* @param discount The new character discount to use.
*/
public void setDiscount(final HeroDiscount discount) {
this.discount = discount;
}
/**
* @param resources The new resource map to use.
*/
public void setResources(final Map<Integer, Map<ResourceType, Integer>> resources) {
this.resources = resources;
}
public String getInitialResourcesText() {
final StringBuilder output = new StringBuilder();
final Map<ResourceType, Integer> levelOneResources = resources.get(1);
for(ResourceType nextResource : levelOneResources.keySet()) {
if(output.length() > 0) {
output.append(" | ");
}
output.append(nextResource.name)
.append(": ")
.append(levelOneResources.get(nextResource));
}
return output.toString();
}
/**
* @return A one-line description of this Hero for debugging purposes.
*/
@Override
public String toString() {
return name + " (" + rpgClass + ")";
}
}
| [
"[email protected]"
] | |
3d416408e21bb71222031f99407403a9f072c506 | 7d7bc3372c988c2e9af3902be868bcd34a73c3c0 | /app/src/main/java/com/example/farzadfarshad/adeiye/BoomMenu/BoomButtons/SimpleCircleButton.java | e2fcaa734d232d711ca6d219141b22ff203b6d67 | [] | no_license | farshadkiani/Adeiye | c6686c3f866a574c87f74396274515c6655dec6e | 63aa633e76dc3cab89030af3bac5ccc45f39ac3f | refs/heads/master | 2020-05-26T21:44:27.033291 | 2018-06-09T17:18:16 | 2018-06-09T17:18:16 | 72,527,119 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,457 | java | package com.example.farzadfarshad.adeiye.BoomMenu.BoomButtons;
import android.content.Context;
import android.graphics.PointF;
import android.view.LayoutInflater;
import android.view.View;
import com.example.farzadfarshad.adeiye.BoomMenu.ButtonEnum;
import com.example.farzadfarshad.adeiye.R;
import java.util.ArrayList;
/**
* Created by Weiping Huang at 01:33 on 16/11/18
* For Personal Open Source
* Contact me at [email protected] or [email protected]
* For more projects: https://github.com/Nightonke
*/
@SuppressWarnings("unused")
public class SimpleCircleButton extends BoomButton {
private SimpleCircleButton(Builder builder, Context context) {
super(context);
this.context = context;
this.buttonEnum = ButtonEnum.SimpleCircle;
init(builder);
}
private void init(Builder builder) {
LayoutInflater.from(context).inflate(R.layout.bmb_simple_circle_button, this, true);
initAttrs(builder);
if (isRound) initShadow(buttonRadius + shadowRadius);
else initShadow(shadowCornerRadius);
initCircleButton();
initImage();
centerPoint = new PointF(
buttonRadius + shadowRadius + shadowOffsetX,
buttonRadius + shadowRadius + shadowOffsetY);
}
private void initAttrs(Builder builder) {
super.initAttrs(builder);
}
@Override
public ButtonEnum type() {
return ButtonEnum.SimpleCircle;
}
@Override
public ArrayList<View> goneViews() {
ArrayList<View> goneViews = new ArrayList<>();
goneViews.add(image);
return goneViews;
}
@Override
public ArrayList<View> rotateViews() {
ArrayList<View> rotateViews = new ArrayList<>();
if (rotateImage) rotateViews.add(image);
return rotateViews;
}
@Override
public int trueWidth() {
return buttonRadius * 2 + shadowRadius * 2 + shadowOffsetX * 2;
}
@Override
public int trueHeight() {
return buttonRadius * 2 + shadowRadius * 2 + shadowOffsetY * 2;
}
@Override
public int contentWidth() {
return buttonRadius * 2;
}
@Override
public int contentHeight() {
return buttonRadius * 2;
}
@Override
public void toHighlighted() {
if (lastStateIsNormal && ableToHighlight) {
toHighlightedImage();
lastStateIsNormal = false;
}
}
@Override
public void toNormal() {
if (!lastStateIsNormal) {
toNormalImage();
lastStateIsNormal = true;
}
}
@Override
public void setRotateAnchorPoints() {
image.setPivotX(buttonRadius - imageRect.left);
image.setPivotY(buttonRadius - imageRect.top);
}
@Override
public void setSelfScaleAnchorPoints() {
}
public static class Builder extends BoomButtonBuilder<Builder> {
/**
* The radius of boom-button, in pixel.
*
* @param buttonRadius the button radius
* @return the builder
*/
public Builder buttonRadius(int buttonRadius) {
this.buttonRadius = buttonRadius;
return this;
}
/**
* Set the corner-radius of button.
*
* @param buttonCornerRadius corner-radius of button
* @return the builder
*/
public Builder buttonCornerRadius(int buttonCornerRadius) {
this.buttonCornerRadius = buttonCornerRadius;
return this;
}
/**
* Whether the button is a circle shape.
*
* @param isRound is or not
* @return the builder
*/
public Builder isRound(boolean isRound) {
this.isRound = isRound;
return this;
}
/**
* Gets button radius, used in BMB package.
*
* @return the button radius
*/
public int getButtonRadius() {
return buttonRadius;
}
/**
* Build simple circle button, only used in BMB package.
*
* @param context the context
* @return the simple circle button
*/
@Override
public SimpleCircleButton build(Context context) {
SimpleCircleButton button = new SimpleCircleButton(this, context);
weakReferenceButton(button);
return button;
}
}
}
| [
"[email protected]"
] | |
8112bc92bd0edd1f0e597a8b5f258ae7ab96af48 | 37b7dffeff3dc59022e9ff2afa7827dcf590376e | /SeleniumProject/src/Gmail/test/email_validator.java | 9aa67051163e0303bb34c2cb0970a57db1c79e46 | [] | no_license | Hu7ein/Compose-Automation | 8963d8539670c92154eba693fc37161961dbc74a | aa701eb0dde9494670ec3440c4cc54a71610229b | refs/heads/main | 2023-07-24T05:49:41.998379 | 2021-08-27T16:27:59 | 2021-08-27T16:27:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 722 | java | package Gmail.test;
import java.util.regex.Pattern;
public class email_validator {
//taking input from the main class and validating the email
protected boolean isValid(String email)
{
String emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\."+
"[a-zA-Z0-9_+&*-]+)*@" +
"(?:[a-zA-Z0-9-]+\\.)+[a-z" +
"A-Z]{2,7}$";
//using system inbuilt Regex method to validate the email and sending output to main method
Pattern emailpattern = Pattern.compile(emailRegex);
if (email == null)
return false;
return emailpattern.matcher(email).matches();
}
}
| [
"[email protected]"
] | |
6a3d58e7dbb8cd811e8f75431a739c7500975436 | f3d078fbe6b1009757284dd6496c633073c1aef4 | /history/code/solutions/acmp_ru/solutions/_60_precalculated.java | 2a37f8150d3b67a549e1655d3b1280860525faeb | [] | no_license | kabulov/code | 7b944b394ad2d0289a0f62c4a5647370cdceba84 | 47021d99fabdc1558a0aee3196be83dad783801b | refs/heads/master | 2020-04-05T07:28:31.037806 | 2015-05-06T16:18:41 | 2015-05-06T16:18:41 | 26,828,215 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,653 | java | import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
out = new PrintWriter("output.txt");
in = new StreamTokenizer(new FileReader("input.txt"));
init();
out.println(vect[nextInt() - 1]);
out.close();
}
static int[] vect;
static void init() {
vect = new int[500];
vect[0] = 3;
vect[1] = 5;
vect[2] = 11;
vect[3] = 17;
vect[4] = 31;
vect[5] = 41;
vect[6] = 59;
vect[7] = 67;
vect[8] = 83;
vect[9] = 109;
vect[10] = 127;
vect[11] = 157;
vect[12] = 179;
vect[13] = 191;
vect[14] = 211;
vect[15] = 241;
vect[16] = 277;
vect[17] = 283;
vect[18] = 331;
vect[19] = 353;
vect[20] = 367;
vect[21] = 401;
vect[22] = 431;
vect[23] = 461;
vect[24] = 509;
vect[25] = 547;
vect[26] = 563;
vect[27] = 587;
vect[28] = 599;
vect[29] = 617;
vect[30] = 709;
vect[31] = 739;
vect[32] = 773;
vect[33] = 797;
vect[34] = 859;
vect[35] = 877;
vect[36] = 919;
vect[37] = 967;
vect[38] = 991;
vect[39] = 1031;
vect[40] = 1063;
vect[41] = 1087;
vect[42] = 1153;
vect[43] = 1171;
vect[44] = 1201;
vect[45] = 1217;
vect[46] = 1297;
vect[47] = 1409;
vect[48] = 1433;
vect[49] = 1447;
vect[50] = 1471;
vect[51] = 1499;
vect[52] = 1523;
vect[53] = 1597;
vect[54] = 1621;
vect[55] = 1669;
vect[56] = 1723;
vect[57] = 1741;
vect[58] = 1787;
vect[59] = 1823;
vect[60] = 1847;
vect[61] = 1913;
vect[62] = 2027;
vect[63] = 2063;
vect[64] = 2081;
vect[65] = 2099;
vect[66] = 2221;
vect[67] = 2269;
vect[68] = 2341;
vect[69] = 2351;
vect[70] = 2381;
vect[71] = 2417;
vect[72] = 2477;
vect[73] = 2549;
vect[74] = 2609;
vect[75] = 2647;
vect[76] = 2683;
vect[77] = 2719;
vect[78] = 2749;
vect[79] = 2803;
vect[80] = 2897;
vect[81] = 2909;
vect[82] = 3001;
vect[83] = 3019;
vect[84] = 3067;
vect[85] = 3109;
vect[86] = 3169;
vect[87] = 3229;
vect[88] = 3259;
vect[89] = 3299;
vect[90] = 3319;
vect[91] = 3407;
vect[92] = 3469;
vect[93] = 3517;
vect[94] = 3559;
vect[95] = 3593;
vect[96] = 3637;
vect[97] = 3733;
vect[98] = 3761;
vect[99] = 3911;
vect[100] = 3943;
vect[101] = 4027;
vect[102] = 4091;
vect[103] = 4133;
vect[104] = 4153;
vect[105] = 4217;
vect[106] = 4273;
vect[107] = 4339;
vect[108] = 4397;
vect[109] = 4421;
vect[110] = 4463;
vect[111] = 4517;
vect[112] = 4549;
vect[113] = 4567;
vect[114] = 4663;
vect[115] = 4759;
vect[116] = 4787;
vect[117] = 4801;
vect[118] = 4877;
vect[119] = 4933;
vect[120] = 4943;
vect[121] = 5021;
vect[122] = 5059;
vect[123] = 5107;
vect[124] = 5189;
vect[125] = 5281;
vect[126] = 5381;
vect[127] = 5441;
vect[128] = 5503;
vect[129] = 5557;
vect[130] = 5623;
vect[131] = 5651;
vect[132] = 5701;
vect[133] = 5749;
vect[134] = 5801;
vect[135] = 5851;
vect[136] = 5869;
vect[137] = 6037;
vect[138] = 6113;
vect[139] = 6217;
vect[140] = 6229;
vect[141] = 6311;
vect[142] = 6323;
vect[143] = 6353;
vect[144] = 6361;
vect[145] = 6469;
vect[146] = 6599;
vect[147] = 6653;
vect[148] = 6661;
vect[149] = 6691;
vect[150] = 6823;
vect[151] = 6841;
vect[152] = 6863;
vect[153] = 6899;
vect[154] = 7057;
vect[155] = 7109;
vect[156] = 7193;
vect[157] = 7283;
vect[158] = 7351;
vect[159] = 7417;
vect[160] = 7481;
vect[161] = 7523;
vect[162] = 7607;
vect[163] = 7649;
vect[164] = 7699;
vect[165] = 7753;
vect[166] = 7841;
vect[167] = 7883;
vect[168] = 8011;
vect[169] = 8059;
vect[170] = 8101;
vect[171] = 8117;
vect[172] = 8221;
vect[173] = 8233;
vect[174] = 8287;
vect[175] = 8377;
vect[176] = 8389;
vect[177] = 8513;
vect[178] = 8527;
vect[179] = 8581;
vect[180] = 8719;
vect[181] = 8747;
vect[182] = 8761;
vect[183] = 8807;
vect[184] = 8849;
vect[185] = 8923;
vect[186] = 8999;
vect[187] = 9041;
vect[188] = 9103;
vect[189] = 9293;
vect[190] = 9319;
vect[191] = 9403;
vect[192] = 9461;
vect[193] = 9539;
vect[194] = 9619;
vect[195] = 9661;
vect[196] = 9739;
vect[197] = 9833;
vect[198] = 9859;
vect[199] = 9923;
vect[200] = 9973;
vect[201] = 10009;
vect[202] = 10079;
vect[203] = 10169;
vect[204] = 10267;
vect[205] = 10433;
vect[206] = 10457;
vect[207] = 10487;
vect[208] = 10559;
vect[209] = 10589;
vect[210] = 10631;
vect[211] = 10663;
vect[212] = 10687;
vect[213] = 10723;
vect[214] = 10853;
vect[215] = 10861;
vect[216] = 10909;
vect[217] = 11257;
vect[218] = 11311;
vect[219] = 11369;
vect[220] = 11447;
vect[221] = 11633;
vect[222] = 11743;
vect[223] = 11867;
vect[224] = 11909;
vect[225] = 11927;
vect[226] = 11953;
vect[227] = 12007;
vect[228] = 12097;
vect[229] = 12113;
vect[230] = 12143;
vect[231] = 12203;
vect[232] = 12301;
vect[233] = 12409;
vect[234] = 12421;
vect[235] = 12457;
vect[236] = 12479;
vect[237] = 12503;
vect[238] = 12547;
vect[239] = 12647;
vect[240] = 12763;
vect[241] = 12841;
vect[242] = 12959;
vect[243] = 13003;
vect[244] = 13037;
vect[245] = 13103;
vect[246] = 13171;
vect[247] = 13217;
vect[248] = 13297;
vect[249] = 13331;
vect[250] = 13469;
vect[251] = 13513;
vect[252] = 13591;
vect[253] = 13613;
vect[254] = 13649;
vect[255] = 13693;
vect[256] = 13709;
vect[257] = 13757;
vect[258] = 13859;
vect[259] = 14051;
vect[260] = 14107;
vect[261] = 14159;
vect[262] = 14177;
vect[263] = 14437;
vect[264] = 14479;
vect[265] = 14503;
vect[266] = 14591;
vect[267] = 14713;
vect[268] = 14723;
vect[269] = 14783;
vect[270] = 14867;
vect[271] = 14923;
vect[272] = 14969;
vect[273] = 15061;
vect[274] = 15227;
vect[275] = 15271;
vect[276] = 15299;
vect[277] = 15313;
vect[278] = 15413;
vect[279] = 15511;
vect[280] = 15641;
vect[281] = 15683;
vect[282] = 15823;
vect[283] = 15973;
vect[284] = 16061;
vect[285] = 16073;
vect[286] = 16091;
vect[287] = 16127;
vect[288] = 16141;
vect[289] = 16253;
vect[290] = 16411;
vect[291] = 16451;
vect[292] = 16519;
vect[293] = 16693;
vect[294] = 16703;
vect[295] = 16901;
vect[296] = 16921;
vect[297] = 17117;
vect[298] = 17189;
vect[299] = 17291;
vect[300] = 17333;
vect[301] = 17377;
vect[302] = 17387;
vect[303] = 17417;
vect[304] = 17483;
vect[305] = 17539;
vect[306] = 17627;
vect[307] = 17659;
vect[308] = 17761;
vect[309] = 17911;
vect[310] = 17987;
vect[311] = 18049;
vect[312] = 18149;
vect[313] = 18181;
vect[314] = 18217;
vect[315] = 18229;
vect[316] = 18311;
vect[317] = 18433;
vect[318] = 18443;
vect[319] = 18617;
vect[320] = 18661;
vect[321] = 18719;
vect[322] = 18757;
vect[323] = 18787;
vect[324] = 18917;
vect[325] = 19013;
vect[326] = 19213;
vect[327] = 19433;
vect[328] = 19463;
vect[329] = 19501;
vect[330] = 19577;
vect[331] = 19759;
vect[332] = 19777;
vect[333] = 19819;
vect[334] = 19913;
vect[335] = 20047;
vect[336] = 20063;
vect[337] = 20107;
vect[338] = 20161;
vect[339] = 20231;
vect[340] = 20297;
vect[341] = 20341;
vect[342] = 20441;
vect[343] = 20477;
vect[344] = 20719;
vect[345] = 20759;
vect[346] = 20773;
vect[347] = 20873;
vect[348] = 20899;
vect[349] = 20959;
vect[350] = 21089;
vect[351] = 21149;
vect[352] = 21179;
vect[353] = 21191;
vect[354] = 21269;
vect[355] = 21317;
vect[356] = 21379;
vect[357] = 21493;
vect[358] = 21529;
vect[359] = 21587;
vect[360] = 21727;
vect[361] = 21757;
vect[362] = 21817;
vect[363] = 21937;
vect[364] = 22027;
vect[365] = 22067;
vect[366] = 22093;
vect[367] = 22367;
vect[368] = 22549;
vect[369] = 22651;
vect[370] = 22721;
vect[371] = 22751;
vect[372] = 22811;
vect[373] = 22853;
vect[374] = 22907;
vect[375] = 23087;
vect[376] = 23209;
vect[377] = 23251;
vect[378] = 23431;
vect[379] = 23539;
vect[380] = 23563;
vect[381] = 23669;
vect[382] = 23801;
vect[383] = 23887;
vect[384] = 23899;
vect[385] = 23929;
vect[386] = 24019;
vect[387] = 24071;
vect[388] = 24107;
vect[389] = 24133;
vect[390] = 24151;
vect[391] = 24197;
vect[392] = 24251;
vect[393] = 24379;
vect[394] = 24419;
vect[395] = 24439;
vect[396] = 24509;
vect[397] = 24631;
vect[398] = 24671;
vect[399] = 24781;
vect[400] = 24859;
vect[401] = 24917;
vect[402] = 25057;
vect[403] = 25163;
vect[404] = 25301;
vect[405] = 25307;
vect[406] = 25357;
vect[407] = 25409;
vect[408] = 25423;
vect[409] = 25601;
vect[410] = 25733;
vect[411] = 25763;
vect[412] = 25841;
vect[413] = 25919;
vect[414] = 25969;
vect[415] = 26003;
vect[416] = 26189;
vect[417] = 26263;
vect[418] = 26371;
vect[419] = 26423;
vect[420] = 26489;
vect[421] = 26591;
vect[422] = 26693;
vect[423] = 26783;
vect[424] = 26921;
vect[425] = 26953;
vect[426] = 27017;
vect[427] = 27073;
vect[428] = 27091;
vect[429] = 27437;
vect[430] = 27457;
vect[431] = 27581;
vect[432] = 27689;
vect[433] = 27733;
vect[434] = 27809;
vect[435] = 27847;
vect[436] = 27943;
vect[437] = 28057;
vect[438] = 28109;
vect[439] = 28279;
vect[440] = 28307;
vect[441] = 28393;
vect[442] = 28573;
vect[443] = 28643;
vect[444] = 28657;
vect[445] = 28807;
vect[446] = 29101;
vect[447] = 29137;
vect[448] = 29153;
vect[449] = 29269;
vect[450] = 29333;
vect[451] = 29383;
vect[452] = 29483;
vect[453] = 29569;
vect[454] = 29641;
vect[455] = 29683;
vect[456] = 29803;
vect[457] = 30071;
vect[458] = 30091;
vect[459] = 30113;
vect[460] = 30133;
vect[461] = 30253;
vect[462] = 30557;
vect[463] = 30577;
vect[464] = 30661;
vect[465] = 30707;
vect[466] = 30781;
vect[467] = 30829;
vect[468] = 30869;
vect[469] = 30881;
vect[470] = 31033;
vect[471] = 31069;
vect[472] = 31181;
vect[473] = 31189;
vect[474] = 31267;
vect[475] = 31277;
vect[476] = 31489;
vect[477] = 31513;
vect[478] = 31667;
vect[479] = 31729;
vect[480] = 32003;
vect[481] = 32143;
vect[482] = 32233;
vect[483] = 32261;
vect[484] = 32299;
vect[485] = 32323;
vect[486] = 32341;
vect[487] = 32533;
vect[488] = 32603;
vect[489] = 32719;
vect[490] = 32797;
vect[491] = 32911;
vect[492] = 32933;
vect[493] = 32969;
vect[494] = 33013;
vect[495] = 33029;
vect[496] = 33083;
vect[497] = 33191;
vect[498] = 33203;
vect[499] = 33347;
}
static PrintWriter out;
static StreamTokenizer in;
static int nextInt() throws IOException {
in.nextToken();
return (int)in.nval;
}
}
/*
boolean[] vect = new boolean[100001];
Arrays.fill(vect, true);
for (int i = 2; i <= 50000; ++i) {
for (int j = i; j + i <= 100000; j += i) {
vect[j + i] = false;
}
}
int len = 0;
int[] prime = new int[50000];
for (int i = 2; i < 100001; i++)
if (vect[i])
prime[len++] = i;
for (int i = 0; i < 500; ++i) {
out.println("vect[" + i + "] = " + prime[prime[i] - 1] + ";");
}
*/ | [
"[email protected]"
] | |
c35191f17e1c61815095da1483ccc2eea2390594 | 18c96e35d364028a5f32ac28cfa449d0a2658ae4 | /src/com/company/design_patterns/composite/MyList.java | 97ceb875bb257c441b5a14b6b48425bd2c7783e3 | [] | no_license | mmgrigorova/design-patterns-sandbox | bb909d11280b939818edc0e99663e11cb158f227 | 0803be02f74b666f3e6fc029b283713c9025f826 | refs/heads/master | 2022-08-01T09:33:06.574431 | 2020-05-27T07:44:04 | 2020-05-27T07:44:04 | 262,832,701 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 467 | java | package com.company.design_patterns.composite;
import java.util.ArrayList;
import java.util.Collection;
public class MyList extends ArrayList<ValueContainer> {
public MyList(Collection<? extends ValueContainer> c) {
super(c);
}
public int sum(){
int result = 0;
for(ValueContainer container : this){
for(int value : container){
result += value;
}
}
return result;
}
}
| [
"[email protected]"
] | |
fbbb0067d8e8e27cee9911e8b71dbcf37b126b51 | 162c40ed24b0006a1186da4205a5b86cc2f9746c | /app/src/main/java/com/webfarmatics/exptrack/ActivitySaveLoanDetails.java | 27cd1d001d8173205b2f195711d1bb1c75047c6c | [] | no_license | jagtapvivek127/ExpTrack | 8d63ad0549122c631a8ee50ddc8d7071cc274407 | 34b2f3eea4f0f0d56ee4f7ffb6d2e1eeb2744a46 | refs/heads/master | 2020-11-28T23:56:38.857109 | 2019-12-23T13:24:55 | 2019-12-23T13:24:55 | 229,954,921 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,767 | java | package com.webfarmatics.exptrack;
import android.annotation.SuppressLint;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import com.webfarmatics.exptrack.bean.BeanLoan;
import com.webfarmatics.exptrack.bean.BeanPurchase;
import com.webfarmatics.exptrack.utils.AppDatabase;
import com.webfarmatics.exptrack.utils.GlobalData;
import java.util.Calendar;
public class ActivitySaveLoanDetails extends AppCompatActivity implements View.OnClickListener {
private Context context;
private AppDatabase database;
private RadioButton rbGiven, rbTaken;
private EditText edtFromTo, edtLoAmount, edtLoPaymentDesc;
private TextView tvLoDate, tvReDate, tvLoError, tvLoanHint;
private LinearLayout llWalletIn, llBankIn;
private boolean bankSelected = false, walletSelected = false;
private int day, month, year, count = 0, day1, month1, year1;
private String date = null;
private static final int LOAN_DATE_ID = 127;
private static final int LOAN_RETURN_DATE_ID = 122;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_save_loan_details);
initialize();
initToolbar();
MobileAds.initialize(context, GlobalData.ADD_ID);
AdView adView = findViewById(R.id.adView);
AdRequest request = new AdRequest.Builder().build();
adView.loadAd(request);
}
private void initialize() {
context = ActivitySaveLoanDetails.this;
database = AppDatabase.getInstance(this);
rbGiven = findViewById(R.id.rbGiven);
rbTaken = findViewById(R.id.rbTaken);
edtFromTo = findViewById(R.id.edtFromTo);
edtLoAmount = findViewById(R.id.edtLoAmount);
edtLoPaymentDesc = findViewById(R.id.edtLoPaymentDesc);
tvLoDate = findViewById(R.id.tvLoDate);
tvReDate = findViewById(R.id.tvReDate);
tvLoError = findViewById(R.id.tvLoError);
tvLoanHint = findViewById(R.id.tvLoanHint);
Button btnLoSave = findViewById(R.id.btnLoSave);
llWalletIn = findViewById(R.id.llWalletIn);
llBankIn = findViewById(R.id.llBankIn);
Calendar calendar = Calendar.getInstance();
day = calendar.get(Calendar.DAY_OF_MONTH);
month = calendar.get(Calendar.MONTH);
year = calendar.get(Calendar.YEAR);
showDateFirst(day, month, year);
day1 = calendar.get(Calendar.DAY_OF_MONTH);
month1 = calendar.get(Calendar.MONTH);
year1 = calendar.get(Calendar.YEAR);
showDateReturn(day1, month1, year1);
llWalletIn.setOnClickListener(this);
llBankIn.setOnClickListener(this);
tvLoDate.setOnClickListener(this);
tvReDate.setOnClickListener(this);
btnLoSave.setOnClickListener(this);
rbTaken.setOnClickListener(this);
rbGiven.setOnClickListener(this);
AdView adView = findViewById(R.id.adView);
AdRequest request = new AdRequest.Builder().build();
adView.loadAd(request);
}
@SuppressLint("ResourceAsColor")
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.llBankIn:
if (walletSelected) {
bankSelected = true;
walletSelected = false;
llBankIn.setBackgroundResource(R.drawable.select_box);
llWalletIn.setBackgroundResource(R.drawable.comment_box);
} else {
bankSelected = true;
llBankIn.setBackgroundResource(R.drawable.select_box);
}
break;
case R.id.llWalletIn:
if (bankSelected) {
bankSelected = false;
walletSelected = true;
llBankIn.setBackgroundResource(R.drawable.comment_box);
llWalletIn.setBackgroundResource(R.drawable.select_box);
} else {
walletSelected = true;
llWalletIn.setBackgroundResource(R.drawable.select_box);
}
break;
case R.id.tvLoDate:
showDialog(LOAN_DATE_ID);
break;
case R.id.tvReDate:
showDialog(LOAN_RETURN_DATE_ID);
break;
case R.id.btnLoSave:
saveLoanDetails();
break;
case R.id.rbGiven:
tvLoanHint.setText("Debit from");
tvLoanHint.setVisibility(View.VISIBLE);
break;
case R.id.rbTaken:
tvLoanHint.setText("Credit in");
tvLoanHint.setVisibility(View.VISIBLE);
break;
}
}
private void showDateFirst(int day, int month, int year) {
month = month + 1;
Log.e("error", "showDateFirst day " + day + " month " + month + " year " + year);
tvLoDate.setText(day + "/" + month + "/" + year);
}
private void showDateReturn(int day1, int month1, int year1) {
month1 = month1 + 1;
Log.e("error", "showReturnDate day1 " + day1 + " month1 " + month1 + " year1 " + year1);
// tvReDate.setText(day1 + "/" + month1 + "/" + year1);
tvReDate.setText("N/A");
}
@Override
protected Dialog onCreateDialog(int id) {
if (id == LOAN_DATE_ID) {
return new DatePickerDialog(context, myDateListener, year, month, day);
} else {
return new DatePickerDialog(context, myDateListener1, year1, month1, day1);
}
}
private DatePickerDialog.OnDateSetListener myDateListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int y, int m, int d) {
count++;
Log.e("error", "DatePickerDialog initial date count " + count);
Log.e("error", "DatePickerDialog initial day " + day + " month " + month + " year " + year);
int selectedDate = datePicker.getDayOfMonth();
int selectedMonth = datePicker.getMonth();
int selectedYear = datePicker.getYear();
Log.e("error", "DatePickerDialog new Date day " + selectedDate + " month " + selectedMonth + " year " + selectedYear);
setLoanDate(selectedDate, selectedMonth, selectedYear);
}
};
private DatePickerDialog.OnDateSetListener myDateListener1 = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int y, int m, int d) {
count++;
Log.e("error", "DatePickerDialog initial date count " + count);
Log.e("error", "DatePickerDialog initial day " + day + " month " + month + " year " + year);
int selectedDate = datePicker.getDayOfMonth();
int selectedMonth = datePicker.getMonth();
int selectedYear = datePicker.getYear();
Log.e("error", "DatePickerDialog new Date day " + selectedDate + " month " + selectedMonth + " year " + selectedYear);
setReturnDate(selectedDate, selectedMonth, selectedYear);
}
};
private void setLoanDate(int day, int month, int year) {
month = month + 1;
date = day + "/" + month + "/" + year;
tvLoDate.setText(date);
}
private void setReturnDate(int day, int month, int year) {
month = month + 1;
date = day + "/" + month + "/" + year;
tvReDate.setText(date);
}
private void saveLoanDetails() {
String loanStatus = null;
boolean isGiven = rbGiven.isChecked();
boolean isTaekn = rbTaken.isChecked();
if (isGiven)
loanStatus = "GIVEN";
else if (isTaekn)
loanStatus = "TAKEN";
else {
toastMsg("Select Loan Given or Taken");
return;
}
String fromTo = edtFromTo.getText().toString();
String loanAmt = edtLoAmount.getText().toString();
String loanDesc = edtLoPaymentDesc.getText().toString();
String loanDate = tvLoDate.getText().toString();
String returnDate = tvReDate.getText().toString();
if (fromTo.isEmpty()) {
toastMsg("Enter Name...");
edtFromTo.setError("require");
return;
}
if (loanAmt.isEmpty()) {
toastMsg("Enter Amount...");
edtLoAmount.setError("require");
return;
}
if (loanDesc.isEmpty()) {
toastMsg("Enter Comment...");
edtLoPaymentDesc.setError("require");
return;
}
if (returnDate.equalsIgnoreCase("N/A")) {
toastMsg("Select return Date.");
return;
}
int amt = Integer.parseInt(loanAmt);
if (loanStatus.equalsIgnoreCase("GIVEN")) {
if (walletSelected) {
String walletbal = database.getWalletBalance();
int bBal = Integer.parseInt(walletbal);
if (bBal < amt) {
tvLoError.setText("Wallet balance is low... " + walletbal);
tvLoError.setVisibility(View.VISIBLE);
return;
} else {
database.reduceWalletBal(amt);
}
} else if (bankSelected) {
String bankBal = database.getBankBalance();
int bBal = Integer.parseInt(bankBal);
if (bBal < amt) {
tvLoError.setText("Bank balance is low... " + bankBal);
tvLoError.setVisibility(View.VISIBLE);
return;
} else {
database.reduceBankBal(amt);
}
}
} else if (loanStatus.equalsIgnoreCase("TAKEN")) {
if (walletSelected) {
database.addToWallet(amt);
} else if (bankSelected) {
database.addToBank(amt);
}
} else {
toastMsg("Select Bank or Wallet");
return;
}
String amount = "" + amt;
BeanLoan loan = new BeanLoan("", fromTo, amount, loanDate, returnDate, loanDesc, loanStatus);
boolean saved = database.saveLoanDetails(loan);
if (saved) {
toastMsg("Loan details saved...");
finish();
Log.e("Loan", " savePurchase " + saved);
} else {
toastMsg("Loan failed...");
Log.e("Loan", " savePurchase " + saved);
}
BeanPurchase purchase = null;
String paymentBy = null;
if (walletSelected) {
paymentBy = "Wallet";
Log.e("LoanTr", " paymentBy " + paymentBy);
purchase = new BeanPurchase("Loan " + loanStatus, amt, loanDesc, loanDate, "Loan", paymentBy);
} else if (bankSelected) {
paymentBy = "Card";
Log.e("LoanTr", " paymentBy " + paymentBy);
purchase = new BeanPurchase("Loan " + loanStatus, amt, loanDesc, loanDate, "Loan", paymentBy);
}
if (purchase == null) {
return;
}
boolean saved12 = database.saveTransaction(purchase);
if (saved12) {
// toastMsg("Loan Transaction saved...");
Log.e("LoanTr", " Loan Transaction saved " + saved12);
finish();
} else {
toastMsg("Loan Transaction failed..!");
Log.e("LoanTr", " Loan Transaction failed " + saved12);
}
}
public void toastMsg(String msg) {
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
}
public void initToolbar() {
//this set back button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//this is set custom image to back button
getSupportActionBar().setHomeAsUpIndicator(R.drawable.back_arrow);
}
//this method call when you press back button
@Override
public boolean onSupportNavigateUp() {
this.finish();
return true;
}
}
| [
"[email protected]"
] | |
3a3fa1988260af219f1eb3fb2023ad3162952d88 | a150d03a87a28af74abae0f9b2cbfef164e69a8f | /src/org/dmd/mvw/tools/mvwgenerator/generated/types/adapters/SubMenuREFMVAdapter.java | bbbaa7893cf04275e4578fa6d8ed43e6cab862f3 | [] | no_license | dark-matter-org/dark-matter-mvw | 4d25454cdf9225c4dffb684b9f2c95be565ac874 | 88b1aea221571c080292fe7f28c9f8a0b0fc6eb1 | refs/heads/master | 2021-07-19T20:39:50.448942 | 2019-12-07T20:04:11 | 2019-12-07T20:04:11 | 46,194,408 | 0 | 0 | null | 2021-06-07T18:05:21 | 2015-11-14T22:21:05 | Java | UTF-8 | Java | false | false | 1,559 | java | package org.dmd.mvw.tools.mvwgenerator.generated.types.adapters;
import org.dmd.dmc.presentation.DmcAdapterIF;
import org.dmd.dmc.DmcAttribute;
import org.dmd.dmc.DmcAttributeInfo;
import org.dmd.dms.generated.types.DmcTypeModifierMV;
import org.dmd.mvw.tools.mvwgenerator.generated.types.DmcTypeSubMenuREFMV;
@SuppressWarnings("serial")
// org.dmd.dms.util.AdapterFormatter.dumpAdapter(AdapterFormatter.java:59)
// Called from: org.dmd.dms.util.AdapterFormatter.dumpAdapterMV(AdapterFormatter.java:16)
public class SubMenuREFMVAdapter extends DmcTypeSubMenuREFMV implements DmcAdapterIF {
transient DmcTypeSubMenuREFMV existingValue;
public SubMenuREFMVAdapter(DmcAttributeInfo ai){
super(ai);
}
public void setEmpty(){
value = null;
}
public boolean hasValue(){
if (value == null)
return(false);
return(true);
}
public void resetToExisting() {
if (existingValue == null)
value = null;
else
value = existingValue.getMVCopy();
}
public void setExisting(DmcAttribute<?> attr) {
existingValue = (DmcTypeSubMenuREFMV) attr;
if (existingValue != null)
value = existingValue.getMVCopy();
}
public boolean valueChanged(){
return(valueChangedMV(existingValue, this));
}
public void addMods(DmcTypeModifierMV mods){
addModsMV(mods, existingValue, this);
}
public DmcAttribute<?> getExisting() {
return(existingValue);
}
public Object getValue() {
return(value);
}
}
| [
"pstrong99@c0aa5241-de7e-54de-0197-666b8cbfb6a2"
] | pstrong99@c0aa5241-de7e-54de-0197-666b8cbfb6a2 |
9c2d8e9ce1ae4acf50da5b8229d43654b9f7dcdd | de253e9ebe39b43912c879f71206dfd934318c52 | /microservices/services/filtering-service/src/main/java/org/xcolab/service/filtering/domain/filteredentry/FilteredEntryDao.java | a8173c3310372bd633d30a7234ddb2bf3ae213dc | [
"MIT"
] | permissive | carlosbpf/XCoLab | 9d3a8432bf5a94fc24944d38a5c722823cae708c | eb68c86843eedf29e8e0c109b485e04a508b07f2 | refs/heads/master | 2021-01-19T10:06:33.281981 | 2017-02-18T17:18:03 | 2017-02-18T17:18:03 | 82,162,079 | 0 | 0 | null | 2017-02-16T09:16:18 | 2017-02-16T09:16:18 | null | UTF-8 | Java | false | false | 648 | java | package org.xcolab.service.filtering.domain.filteredentry;
import org.xcolab.model.tables.pojos.FilteredEntry;
import org.xcolab.service.filtering.exceptions.NotFoundException;
import java.util.List;
public interface FilteredEntryDao {
FilteredEntry create(FilteredEntry memberContentEntry);
boolean update(FilteredEntry filteredEntry);
FilteredEntry get(Long memberContentEntryId) throws NotFoundException;
List<FilteredEntry> getByStatus(Integer statusId);
FilteredEntry getByAuthorAndSourceAndSourceId(Long authorId, Long sourceId, Long source);
FilteredEntry getByUuid(String uuid) throws NotFoundException;
}
| [
"[email protected]"
] | |
c3b25ada1834a1c0b891b7ad29f15e49b9963dfe | 72c1f6c17f1d9a4cd70e9d2e7979b42d30fc7eb1 | /app/src/main/java/com/xzwzz/lady/pay/alipay/SignUtils.java | 4f4abce49282df888429c2daeca9d519cc3e2380 | [] | no_license | gaoyuan117/Lady | e8845334bd436ce7f9222dfa7d190c0fb68be303 | 39a8f21eecd4d928262f4f0d55df8a6fce1d0670 | refs/heads/master | 2020-03-28T12:29:02.158314 | 2018-09-27T10:44:15 | 2018-09-27T10:44:15 | 148,303,083 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 957 | java | package com.xzwzz.lady.pay.alipay;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.spec.PKCS8EncodedKeySpec;
public class SignUtils {
private static final String ALGORITHM = "RSA";
private static final String SIGN_ALGORITHMS = "SHA1WithRSA";
private static final String DEFAULT_CHARSET = "UTF-8";
public static String sign(String content, String privateKey) {
try {
PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(
Base64.decode(privateKey));
KeyFactory keyf = KeyFactory.getInstance(ALGORITHM);
PrivateKey priKey = keyf.generatePrivate(priPKCS8);
java.security.Signature signature = java.security.Signature
.getInstance(SIGN_ALGORITHMS);
signature.initSign(priKey);
signature.update(content.getBytes(DEFAULT_CHARSET));
byte[] signed = signature.sign();
return Base64.encode(signed);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
| [
"[email protected]"
] | |
08007adc9fca1ee597634215e07d63f792868e3f | 33ddea28587c8e9ffbd8534535330ad522e11aa4 | /src/main/java/com/yuzhihao/myplatform/bot/core/middleware/pre/ContextMiddleware.java | f70f5d848c86278121912d5c1bdb31c6f2dfca83 | [] | no_license | yuzhihao/myplatform-bot-dm | 0c4f5702d099d42f332af621f79f84dfa63bd53d | 0c8ba113cc6f0dcd166877acfdc5ede323d689dc | refs/heads/master | 2020-03-20T23:05:48.008727 | 2018-07-09T01:13:07 | 2018-07-09T01:13:07 | 137,829,090 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,328 | java | package com.yuzhihao.myplatform.bot.core.middleware.pre;
import com.yuzhihao.myPlatform.common.utils.JacksonUtils;
import com.yuzhihao.myplatform.bot.core.DMThreadContext;
import com.yuzhihao.myplatform.bot.core.client.redis.RedisServiceImpl;
import com.yuzhihao.myplatform.bot.core.middleware.DialogueMiddleware;
import com.yuzhihao.myplatform.bot.core.pojo.Bot;
import com.yuzhihao.myplatform.bot.core.pojo.DialogContext;
import com.yuzhihao.myplatform.bot.core.pojo.Session;
import com.yuzhihao.myplatform.bot.core.pojo.enums.DMThreadContextEnum;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Optional;
/**
* 获取对话上下文信息
* 可以使用的数据:BOT,CONTEXT
*/
public class ContextMiddleware extends DialogueMiddleware {
@Autowired
RedisServiceImpl redisService;
@Override
protected boolean isRequired() {
return true;
}
@Override
protected boolean checkParam() {
return true;
}
@Override
public void preProcessing() {
//DMThreadContext threadCtx = DMThreadContext.getInstance();
//DialogContext context = (DialogContext) threadCtx.get(DMThreadContextEnum.CONTEXT);
//Bot bot = (Bot)threadCtx.get(DMThreadContextEnum.BOT);
}
@Override
public void afterProcessing() {}
}
| [
"[email protected]"
] | |
8573fe1cd0c62f562ffaa2821f1463dc6c27e50b | d23e6c9b99a455e9af9b61cdcfa4b4cc37506f35 | /KmzProgramm/src/ru/kmz/web/common/client/window/ShowHistoryWindow.java | a05c338ff2362c01506959937ba5c1376e3e1c25 | [] | no_license | kmzproject/kmz | 2e1d4f7fff6e56fa9bf84aea0418254e382fed4d | de697b1796c8ec2dee070f9245b95d3bda498995 | refs/heads/master | 2020-05-16T22:14:57.567622 | 2014-02-12T07:07:59 | 2014-02-12T07:07:59 | 14,015,707 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,025 | java | package ru.kmz.web.common.client.window;
import ru.kmz.web.common.client.control.HistoryGrid;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.Container;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
public class ShowHistoryWindow extends Window {
private long objectId;
public ShowHistoryWindow(long objectId) {
super();
this.objectId = objectId;
add(getInfoContainer());
setPixelSize(500, 300);
setModal(true);
setBlinkModal(true);
createButtons();
}
private Container getInfoContainer() {
VerticalLayoutContainer p = new VerticalLayoutContainer();
HistoryGrid grid = HistoryGrid.getHistoryGrid();
grid.setObjectId(objectId);
p.add(grid);
return p;
}
protected void createButtons() {
TextButton cancelButton = new TextButton("Закрыть");
cancelButton.addSelectHandler(new CancelSelectHandler(this));
addButton(cancelButton);
}
} | [
"[email protected]"
] | |
500000b6e021e693a6a303c9c645e72084bbc895 | 1cee36069591bd026ad3d5f1f7ebbe3800798f24 | /src/main/java/chan/com/usbserialforandroid/datas/util/FLog.java | dcc92f16bcf7b9080d8f9a5c3e4e04cc0d46131f | [] | no_license | fyyy4030/UsbSerialforAndroidDemos | e151cca794d5c1cd9ffb63ed23bbcac43f0f3946 | 24684c46f3bff4fc53cce9512890f2cb46591fbb | refs/heads/master | 2023-03-15T19:00:27.288415 | 2017-12-29T08:56:50 | 2017-12-29T08:56:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,567 | java | package chan.com.usbserialforandroid.datas.util;
import android.util.Log;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import static android.util.Log.getStackTraceString;
/**
* Created by 28851274 on 7/27/15.
*/
public final class FLog {
private final static String LOG_TAG = "FLog";
/**
* Pls set to "true" if you want to save none log in SD card and print none log in ADB.
* Otherwise set to "false".
* Pls set to false always except in your debug test.
*/
private final static boolean NO_LOG = false;
//The max of log file is 2M bytes.
private final static int LOG_FILE_SIZE_MAX = 2 * 1024 * 1024;
//The max of log buffer size is 8K bytes.
private final static int LOG_BUFFER_SIZE_MAX = 8 * 1024;
//Internal log buffer
private static byte[] buffer = new byte[LOG_BUFFER_SIZE_MAX];
private static int mPos = 0;
private static String mLogPath = "/usb_service/log/";
private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ");
private static SimpleDateFormat fileNameFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SS");
public static int v(String tag, String msg) {
if (NO_LOG) return 0;
if (tag == null || msg == null) return 0;
saveLogs(tag, msg, null);
return Log.v(tag, msg);
}
public static int v(String tag, String msg, Throwable tr) {
if (NO_LOG) return 0;
if (tag == null || tr == null) return 0;
if (msg == null) {
saveLogs(tag, "verbose info", tr);
return Log.v(tag, "verbose info", tr);
} else {
saveLogs(tag, msg, tr);
return Log.v(tag, msg, tr);
}
}
public static int d(String tag, String msg) {
if (NO_LOG) return 0;
if (tag == null || msg == null) return 0;
saveLogs(tag, msg, null);
return Log.d(tag, msg);
}
public static int d(String tag, String msg, Throwable tr) {
if (NO_LOG) return 0;
if (tag == null || tr == null) return 0;
if (msg == null) {
saveLogs(tag, "debug info", tr);
return Log.d(tag, "debug info", tr);
} else {
saveLogs(tag, msg, tr);
return Log.d(tag, msg, tr);
}
}
public static int i(String tag, String msg) {
if (NO_LOG) return 0;
if (tag == null || msg == null) return 0;
saveLogs(tag, msg, null);
return Log.i(tag, msg);
}
public static int i(String tag, String msg, Throwable tr) {
if (NO_LOG) return 0;
if (tag == null || tr == null) return 0;
if (msg == null) {
saveLogs(tag, "information info", tr);
return Log.i(tag, "information info", tr);
} else {
saveLogs(tag, msg, tr);
return Log.i(tag, msg, tr);
}
}
public static int w(String tag, String msg) {
if (NO_LOG) return 0;
if (tag == null || msg == null) return 0;
saveLogs(tag, msg, null);
return Log.w(tag, msg);
}
public static int w(String tag, String msg, Throwable tr) {
if (NO_LOG) return 0;
if (tag == null || tr == null) return 0;
if (msg == null) {
saveLogs(tag, "wrong info", tr);
return Log.w(tag, "wrong info", tr);
} else {
saveLogs(tag, msg, tr);
return Log.w(tag, msg, tr);
}
}
public static int e(String tag, String msg) {
if (NO_LOG) return 0;
if (tag == null || msg == null) return 0;
saveLogs(tag, msg, null);
return Log.e(tag, msg);
}
public static int e(String tag, String msg, Throwable tr) {
if (NO_LOG) return 0;
if (tag == null || tr == null) return 0;
if (msg == null) {
saveLogs(tag, "error info", tr);
return Log.e(tag, "error info", tr);
} else {
saveLogs(tag, msg, tr);
return Log.e(tag, msg, tr);
}
}
protected static void saveLogs(String tag, String msg, Throwable tr) {
StringBuilder sb = new StringBuilder(tag);
sb.append(": ");
sb.append(msg);
sb.append("\n");
//Also save throwable string if tr is not null.
if (tr != null) {
String str = getStackTraceString(tr);
sb.append(str);
}
//long t1 = System.currentTimeMillis();
internalLog(sb);
//long t2 = System.currentTimeMillis();
//Log.i(LOG_TAG, "saveLogs():Cost of format log and save log is " + (t2 - t1) + " ms!");
}
/**
* Produce internal log format and save to SD card.
*
* @param msg
*/
private synchronized static void internalLog(StringBuilder msg) {
//add time header
String timeStamp = simpleDateFormat.format(new Date());
msg.insert(0, timeStamp);
byte[] contentArray = msg.toString().getBytes();
int length = contentArray.length;
int srcPos = 0;
if (mPos == LOG_BUFFER_SIZE_MAX) {
//Flush internal buffer
flushInternalBuffer();
}
if (length > buffer.length) {
//Strongly flush the current buffer no matter whether it is full
flushInternalBuffer();
//Flush all msg string to sd card
while (length > buffer.length) {
System.arraycopy(contentArray, srcPos, buffer, mPos, buffer.length);
flushInternalBuffer();
length -= buffer.length;
srcPos += buffer.length;
}
} else if (length == buffer.length) {
flushInternalBuffer();
//Copy contents to buffer
System.arraycopy(contentArray, 0, buffer, mPos, length);
flushInternalBuffer();
length = 0;
}
if (length < buffer.length && length > 0) {
if ((mPos + length) > buffer.length) {
flushInternalBuffer();
//Copy contents to buffer
System.arraycopy(contentArray, srcPos, buffer, mPos, length);
mPos += length;
} else if ((mPos + length) == buffer.length) {
//Add content to buffer
System.arraycopy(contentArray, srcPos, buffer, mPos, length);
mPos += length;
flushInternalBuffer();
} else {
//Add content to buffer
System.arraycopy(contentArray, srcPos, buffer, mPos, length);
mPos += length;
}
}
}
/**
* Flush internal buffer to SD card and then clear buffer to 0.
*/
private static void flushInternalBuffer() {
//Strongly set the last byte to "0A"(new line)
if (mPos < LOG_BUFFER_SIZE_MAX) {
buffer[LOG_BUFFER_SIZE_MAX - 1] = 10;
}
long t1, t2;
//Save buffer to SD card.
t1 = System.currentTimeMillis();
writeToSDCard();
//calculate write file cost
t2 = System.currentTimeMillis();
Log.i(LOG_TAG, "internalLog():Cost of write file to SD card is " + (t2 - t1) + " ms!");
//flush buffer.
Arrays.fill(buffer, (byte) 0);
mPos = 0;
}
/**
* Flush buffer date to SD card.
* <p>
* This method is used ont only internal, but also used external.
* UI developer should invoke this method explicitly to strongly flush buffer to SD card file
* when the application is going to die, no matter whether the internal buffer is full {@link FLog#LOG_BUFFER_SIZE_MAX} .
* </p>
*/
public static void writeToSDCard() {
File logDir = new File(StorageUtil.getAbsoluteSdcardPath() + mLogPath);
if (!logDir.exists()) {
logDir.setWritable(true);
boolean ret = logDir.mkdirs();
Log.i(LOG_TAG, "writeToSDCard(): create log dir: " + logDir.getAbsolutePath() + " " + ret);
}
if (!logDir.canWrite()) {
logDir.setWritable(true);
}
//Find the last modified file
File lastFile = getLastModifiedFile(logDir);
//Write to last modified file
writeToLastFile(logDir, lastFile);
}
/**
* Flush logs in {@link FLog#buffer} to last modified file.
* <p>
* Write to last modified file directly if <code>buffer.length+lastFile.length()</code>
* is smaller than {@link FLog#LOG_FILE_SIZE_MAX}. Otherwise it should create another new
* file to flush buffer.
* </p>
*
* @param logDir log file folder
* @param lastFile last modified file
*/
private static void writeToLastFile(File logDir, File lastFile) {
if (lastFile == null) {
Log.e(LOG_TAG, "writeToLastFile(): File is null. lastFile= " + lastFile);
}
if ((buffer.length + lastFile.length()) > LOG_FILE_SIZE_MAX) {
//New another file to flush buffer logs.
File file = new File(logDir, fileNameFormat.format(new Date()) + ".txt");
lastFile = file;
}
String fileName = lastFile.getAbsolutePath();
Log.i(LOG_TAG, "writeToLastFile(): fileName = " + fileName);
try {
String bufferStr = new String(buffer, "UTF-8");
appendFileSdCardFile(fileName, bufferStr);
} catch (UnsupportedEncodingException e) {
Log.e(LOG_TAG, "writeToLastFile(): Change from byte[] to String failed!");
e.printStackTrace();
}
}
/**
* Get last modified file in Log folder <code>logDir</code>.
*
* @param logDir Log folder
* @return last modified file if exist. null if <code>logDir</code> is invalid.
*/
private static File getLastModifiedFile(File logDir) {
File[] files = logDir.listFiles();
if (files == null) {
Log.e(LOG_TAG, "getLastModifiedFile(): This file dir is invalid. logDir= " + logDir.getAbsolutePath());
return null;
}
//Create a new file if no file exists in this folder
if (files.length == 0) {
File file = new File(logDir, fileNameFormat.format(new Date()) + ".txt");
return file;
}
//Find the last modified file
long lastModifiedTime = 0;
File lastModifiedFile = null;
for (File f : files) {
if (lastModifiedTime <= f.lastModified()) {
lastModifiedTime = f.lastModified();
lastModifiedFile = f;
}
}
return lastModifiedFile;
}
/**
* Write to a file <code>fileName</code> with content <code>writeStr</code>.
*
* @param fileName file name must be an absolute path name.
* @param writeStr content to be written.
*/
public static void writeFileSdCardFile(String fileName, String writeStr) {
FileOutputStream fout = null;
try {
fout = new FileOutputStream(fileName);
byte[] bytes = writeStr.getBytes();
fout.write(bytes);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fout != null) {
try {
fout.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* Append <code>content</code> to a SD card file.
*
* @param fileName a SD card file would be written.
* @param content content want to be written.
*/
public static void appendFileSdCardFile(String fileName, String content) {
FileWriter writer = null;
try {
//Open a file writer and write a file with appending format with "true".
writer = new FileWriter(fileName, true);
writer.write(content);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
| [
"[email protected]"
] | |
735275195cc923ddf2e5d9029ba1c8c8cee58607 | 75f4432cff52c29767a2fe10de5462e7eb458598 | /sepa-pain-lib/src/main/java/iso/std/iso/_20022/tech/xsd/pain_008_001_02/PersonIdentificationSchemeName1Choice.java | 1071314402cb8a178527740ea461f068085dab81 | [
"Apache-2.0"
] | permissive | germamix/sepa-pain-lib | 893d0a238cf6d2e843f95b80716f72382ed310fe | 1c5ea9edc0bbda8b00287611dd3e78e834357852 | refs/heads/master | 2016-09-06T15:03:25.832970 | 2015-03-22T09:04:01 | 2015-03-22T09:04:01 | 32,666,740 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,628 | java | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2013.11.14 at 08:41:30 AM CET
//
package iso.std.iso._20022.tech.xsd.pain_008_001_02;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for PersonIdentificationSchemeName1Choice complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="PersonIdentificationSchemeName1Choice">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <choice>
* <element name="Cd" type="{urn:iso:std:iso:20022:tech:xsd:pain.008.001.02}ExternalPersonIdentification1Code"/>
* <element name="Prtry" type="{urn:iso:std:iso:20022:tech:xsd:pain.008.001.02}Max35Text"/>
* </choice>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PersonIdentificationSchemeName1Choice", propOrder = {
"cd",
"prtry"
})
public class PersonIdentificationSchemeName1Choice {
@XmlElement(name = "Cd")
protected String cd;
@XmlElement(name = "Prtry")
protected String prtry;
/**
* Gets the value of the cd property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCd() {
return cd;
}
/**
* Sets the value of the cd property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCd(String value) {
this.cd = value;
}
/**
* Gets the value of the prtry property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getPrtry() {
return prtry;
}
/**
* Sets the value of the prtry property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setPrtry(String value) {
this.prtry = value;
}
}
| [
"[email protected]"
] | |
a9a76fd66f3fb31598291cacb52b0b60aa32edec | a574aa1075ca863168aa5200bb3153baf9767662 | /services/bsi-entities/src/main/java/com/bsi/common/beans/Service.java | f4bd59884107f6e44d24739216614f195a6d3621 | [] | no_license | nmsgit1234/bsip | 55652fd88d2c29fe8ccbb23895a834def37f6576 | abbeb6d21f57c40c568900735a19316f4d80be94 | refs/heads/master | 2020-12-24T08:55:07.358768 | 2016-08-25T02:37:44 | 2016-08-25T02:37:44 | 42,491,522 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,108 | java | package com.bsi.common.beans;
import java.util.HashSet;
import java.util.Set;
public class Service {
private Long nodeId;
private Long prntNodeId;
private String name;
private String description;
private Set properties = new HashSet();
private Set persons = new HashSet();
public void setNodeId(Long nodeId) {
this.nodeId = nodeId;
}
public Long getNodeId() {
return nodeId;
}
public void setPrntNodeId(Long prntNodeId) {
this.prntNodeId = prntNodeId;
}
public Long getPrntNodeId() {
return prntNodeId;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
public void setProperties(Set properties) {
this.properties = properties;
}
public Set getProperties() {
return properties;
}
public void setPersons(Set persons) {
this.persons = persons;
}
public Set getPersons() {
return persons;
}
}
| [
"anonymus@anonymus"
] | anonymus@anonymus |
8cace0a59c8a6f7f19a935174ef2907808362d10 | 8cc5301089d99891992ee81a345fb02677a56c72 | /android/tools_r22.6/sdklib/src/main/java/com/android/sdklib/repository/SdkSysImgConstants.java | d9983279b9a9ccc29b632bd8ef7b989f964f4ab9 | [] | no_license | litengfei/srcnote | 3f21dbd7b83ba9a4d003946910c0c7b8dd954b8e | 8e1ce1732d48d048c6b2c71c3ada03cdc6b76509 | refs/heads/master | 2021-01-11T04:24:42.030363 | 2019-05-20T01:57:57 | 2019-05-20T02:00:04 | 71,199,156 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,256 | java | /*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.eclipse.org/org/documents/epl-v10.php
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.sdklib.repository;
import com.android.sdklib.internal.repository.sources.SdkSource;
import java.io.InputStream;
/**
* Public constants for the sdk-sys-img XML Schema.
*/
public class SdkSysImgConstants extends RepoConstants {
/**
* The default name looked for by {@link SdkSource} when trying to load an
* sdk-sys-img XML if the URL doesn't match an existing resource.
*/
public static final String URL_DEFAULT_FILENAME = "sys-img.xml"; //$NON-NLS-1$
/** The base of our sdk-sys-img XML namespace. */
private static final String NS_BASE =
"http://schemas.android.com/sdk/android/sys-img/"; //$NON-NLS-1$
/**
* The pattern of our sdk-sys-img XML namespace.
* Matcher's group(1) is the schema version (integer).
*/
public static final String NS_PATTERN = NS_BASE + "([1-9][0-9]*)"; //$NON-NLS-1$
/**
* The latest version of the sdk-sys-img XML Schema.
* Valid version numbers are between 1 and this number, included.
*/
public static final int NS_LATEST_VERSION = 2;
/** The XML namespace of the latest sdk-sys-img XML. */
public static final String NS_URI = getSchemaUri(NS_LATEST_VERSION);
/** The root sdk-sys-img element */
public static final String NODE_SDK_SYS_IMG = "sdk-sys-img"; //$NON-NLS-1$
/** A system-image tag id. */
public static final String ATTR_TAG_ID = "tag-id"; //$NON-NLS-1$
/** The user-visible display part of a system-image tag id. Optional. */
public static final String ATTR_TAG_DISPLAY = "tag-display"; //$NON-NLS-1$
/**
* List of possible nodes in a repository XML. Used to populate options automatically
* in the no-GUI mode.
*/
public static final String[] NODES = {
NODE_SYSTEM_IMAGE,
};
/**
* Returns a stream to the requested {@code sdk-sys-img} XML Schema.
*
* @param version Between 1 and {@link #NS_LATEST_VERSION}, included.
* @return An {@link InputStream} object for the local XSD file or
* null if there is no schema for the requested version.
*/
public static InputStream getXsdStream(int version) {
return getXsdStream(NODE_SDK_SYS_IMG, version);
}
/**
* Returns the URI of the sdk-sys-img schema for the given version number.
* @param version Between 1 and {@link #NS_LATEST_VERSION} included.
*/
public static String getSchemaUri(int version) {
return String.format(NS_BASE + "%d", version); //$NON-NLS-1$
}
}
| [
"[email protected]"
] | |
c93801054cafaa8377a431bcd9027565156a20f4 | ed5159d056e98d6715357d0d14a9b3f20b764f89 | /test/irvine/oeis/a169/A169269Test.java | 0664a693bd4593c8ca3639852050d930a7a20686 | [] | no_license | flywind2/joeis | c5753169cf562939b04dd246f8a2958e97f74558 | e5efd6971a0062ac99f4fae21a7c78c9f9e74fea | refs/heads/master | 2020-09-13T18:34:35.080552 | 2019-11-19T05:40:55 | 2019-11-19T05:40:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 195 | java | package irvine.oeis.a169;
import irvine.oeis.AbstractSequenceTest;
/**
* Tests the corresponding class.
* @author Sean A. Irvine
*/
public class A169269Test extends AbstractSequenceTest {
}
| [
"[email protected]"
] | |
d61f8d1aed3ed30d44aeee364b254eed7d13da75 | 105da5a97e8b6d8184ba17a2dc95cfa0a2176c7f | /app/src/main/java/com/application/kurukshetrauniversitypapers/PlaylistsAvailableActivity.java | df9ed8f12626dc98ffa547cc6569107e133b81aa | [] | no_license | avidraghav/Qsol | 3f87f0eb879f94312315bf3ed10232326fb53cc7 | 0bfd1b7ad39f5f62b0fa6577f334b6231ff64da9 | refs/heads/master | 2023-06-01T13:25:30.112082 | 2021-06-20T10:39:06 | 2021-06-20T10:39:06 | 258,963,971 | 3 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,464 | java | package com.application.kurukshetrauniversitypapers;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.List;
import Adapters.PlaylistsAvailableAdapter;
import utils.Videoinfo;
public class PlaylistsAvailableActivity extends AppCompatActivity {
ListView listView;
List<Videoinfo> playlist_info;
String directory;
DatabaseReference databaseReference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_playlists_available);
listView=findViewById(R.id.playlists_available_listview);
playlist_info = new ArrayList<>();
checkConnection();
Intent intent1=getIntent();
directory = intent1.getStringExtra("video_loc");
databaseReference= FirebaseDatabase.getInstance().getReference(directory);
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
playlist_info.clear();
for(DataSnapshot playlistsnapshot: dataSnapshot.getChildren()){
Videoinfo playlistinfodata=playlistsnapshot.getValue(Videoinfo.class);
playlist_info.add(playlistinfodata);
}
PlaylistsAvailableAdapter adapter= new PlaylistsAvailableAdapter(PlaylistsAvailableActivity.this,playlist_info);
listView.setAdapter(adapter);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Log.e("info", databaseError+"");
}
});
listView.setOnItemClickListener((adapterView, view, position, l) -> {
Videoinfo playlistinfodata=playlist_info.get(position);
Log.e("info",playlistinfodata.getPlaylistid());
Intent intent=new Intent(PlaylistsAvailableActivity.this, VideosListActivity.class);
intent.putExtra("PlaylistId",playlistinfodata.getPlaylistid());
startActivity(intent);
});
}
private void checkConnection() {
ConnectivityManager manager = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activenetwork = manager.getActiveNetworkInfo();
if (null != activenetwork) {
if (activenetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
}
} else {
View view =findViewById(R.id.playlists_display_layout);
Snackbar snackbar = Snackbar.make(view, "Kindly Enable Internet Connection To View Results", Snackbar.LENGTH_LONG);
snackbar.setDuration(5000);
snackbar.show();
}
}
} | [
"[email protected]"
] | |
a69bc003a4cd06da03fd83296c7e78167443b04d | 55c6a63c22d4720df1be11838bbc418d35bf1f0e | /src/com/drai/eventosapp2/model/EventoObj.java | 5ea8605dbdff659842cf9a3b1ad0a52d0c5c500b | [] | no_license | exteban34/EventosDrai | 1e4d304edf59f7255aaa91f8bff3990fc663b4f2 | 3e89adb70197aa2a0a66b908551a8b249631d525 | refs/heads/master | 2021-01-02T22:39:04.954414 | 2015-10-19T14:21:20 | 2015-10-19T14:21:20 | 35,692,493 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,232 | java | package com.drai.eventosapp2.model;
import java.io.Serializable;
/**
* Clase para el tranporte de datos de Eventos en el sistema
* @author Heinner Esteban Alvarez Rivas <[email protected]>
* @version 1.0 21/05/2015
*/
public class EventoObj implements Serializable {
private String id;
private String titulo;
private String lugar;
private String sitioWeb;
private String fechaInicio;
private String horaInicio;
private String descripcion;
private String fechaFinalizacion;
private String horaFinalizacion;
/**
* Constructor de la clase EventoObj
* @param id del evento
* @param titulo del evento
* @param fechaInicio del evento
* @param horaInicio del evento
*/
public EventoObj(String id, String titulo,
String fechaInicio, String horaInicio) {
super();
this.id = id;
this.titulo = titulo;
this.fechaInicio = fechaInicio;
this.horaInicio = horaInicio;
}
/**
* Getters y Setters de los valores de la clase EventoObj
*
*/
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
public String getLugar() {
return lugar;
}
public void setLugar(String lugar) {
this.lugar = lugar;
}
public String getSitioWeb() {
return sitioWeb;
}
public void setSitioWeb(String sitioWeb) {
this.sitioWeb = sitioWeb;
}
public String getFechaInicio() {
return fechaInicio;
}
public void setFechaInicio(String fechaInicio) {
this.fechaInicio = fechaInicio;
}
public String getHoraInicio() {
return horaInicio;
}
public void setHoraInicio(String horaInicio) {
this.horaInicio = horaInicio;
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
public String getFechaFinalizacion() {
return fechaFinalizacion;
}
public void setFechaFinalizacion(String fechaFinalizacion) {
this.fechaFinalizacion = fechaFinalizacion;
}
public String getHoraFinalizacion() {
return horaFinalizacion;
}
public void setHoraFinalizacion(String horaFinalizacion) {
this.horaFinalizacion = horaFinalizacion;
}
}
| [
"[email protected]"
] | |
b79e9f99a00260dd176b7fc3280b5e33a1206e58 | c543956c5f0af9213715d295241cd242fffd1668 | /src/main/java/route_planner/SingleSourceSolver.java | bb9073157d79a8d40e420e220a33057c50486e3f | [
"MIT"
] | permissive | yu-peng/temporal-spatial-filter | ab181be8a7b8681e629109700509043e5dd02e35 | 4deb796874d612ff2f063080bc2e52f0a2fa6179 | refs/heads/master | 2021-01-24T06:12:34.444707 | 2015-07-22T17:46:29 | 2015-07-22T17:46:29 | 39,149,145 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,649 | java | package route_planner;
import java.util.concurrent.Callable;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
public class SingleSourceSolver implements Callable<JSONObject> {
double originLat;
double originLon;
double destLat;
double destLon;
boolean returnPolyline;
boolean returnInstruction;
String mode;
public SingleSourceSolver(double _originLat, double _originLon, double _destLat, double _destLon,
boolean _returnPolyline, boolean _returnInstruction, String _mode){
originLat = _originLat;
originLon = _originLon;
destLat = _destLat;
destLon = _destLon;
returnPolyline = _returnPolyline;
returnInstruction = _returnInstruction;
mode = _mode;
}
public JSONObject call() throws JSONException{
return solve();
}
public JSONObject solve() throws JSONException{
JSONObject result = new JSONObject();
// Record the initial parameters
try {
result.put("OriginLat",originLat);
result.put("OriginLon",originLon);
result.put("POILat",destLat);
result.put("POILon",destLon);
result.put("Mode",mode);
} catch (JSONException e) {
e.printStackTrace();
}
Route route = Initialization.path_planner.getRoute(originLat,originLon,destLat,destLon,returnPolyline,returnInstruction,mode);
if (route != null){
result.put("Status","Complete");
result.put("Route",Description.getRouteDescription(route));
} else {
result.put("Status","Route generator error. No feasible route in any form of transportation can be found between your origin and destination.");
}
return result;
}
}
| [
"[email protected]"
] | |
103a7ef5dcf722730462c9fd0c14465b8ef25ca8 | 72036b45061f9de95c66ebc4e38e676c111eaad5 | /analyzer/src/net/reduls/sanmoku/dic/WordDic.java | a6ac0cfbefd01b45cad899cc3ad6f322e26cda3b | [
"MIT",
"NAIST-2003"
] | permissive | azuru/sanmoku | 6ae6d2f569c03f0f8d922eae52c364fda1a3b3e6 | f8f45c2b42264ecac63b2d87699094e34e22f17a | refs/heads/master | 2021-01-18T03:32:07.717577 | 2011-11-06T21:21:53 | 2011-11-06T21:21:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 838 | java | package net.reduls.sanmoku.dic;
import java.util.List;
public final class WordDic {
public static interface Callback {
public void call(ViterbiNode vn);
public boolean isEmpty();
}
public static void search(String text, int start, Callback fn) {
SurfaceId.eachCommonPrefix(text, start, fn);
}
public static void eachViterbiNode(Callback fn, int surfaceId,
int start, int length, boolean isSpace) {
final int i_start = Morpheme.morphemesBegin(surfaceId);
final int i_end = Morpheme.morphemesEnd(surfaceId);
for(int i=i_start; i < i_end; i++)
fn.call(new ViterbiNode(start, (short)length,
Morpheme.cost(i), Morpheme.posId(i),
isSpace));
}
} | [
"[email protected]"
] | |
9fdd857c9981fd01b23f8e1ca85eb20b521d09df | d89f77bcbcd3474cbb038d79a407c912c6e00cf9 | /src/main/java/com/tencentcloudapi/mongodb/v20190725/models/DescribeAsyncRequestInfoResponse.java | 57dce0850c6bc014ed52de26d60c3a893b7d0259 | [
"Apache-2.0"
] | permissive | victoryckl/tencentcloud-sdk-java | 23e5486445d7e4316f85247b35a2e2ba69b92546 | 73a6e6632e0273cfdebd5487cc7ecff920c5e89c | refs/heads/master | 2022-11-20T16:14:11.452984 | 2020-07-28T01:08:50 | 2020-07-28T01:08:50 | 283,146,154 | 0 | 1 | Apache-2.0 | 2020-07-28T08:14:10 | 2020-07-28T08:14:09 | null | UTF-8 | Java | false | false | 2,481 | java | /*
* Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tencentcloudapi.mongodb.v20190725.models;
import com.tencentcloudapi.common.AbstractModel;
import com.google.gson.annotations.SerializedName;
import com.google.gson.annotations.Expose;
import java.util.HashMap;
public class DescribeAsyncRequestInfoResponse extends AbstractModel{
/**
* 状态
*/
@SerializedName("Status")
@Expose
private String Status;
/**
* 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
*/
@SerializedName("RequestId")
@Expose
private String RequestId;
/**
* Get 状态
* @return Status 状态
*/
public String getStatus() {
return this.Status;
}
/**
* Set 状态
* @param Status 状态
*/
public void setStatus(String Status) {
this.Status = Status;
}
/**
* Get 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
* @return RequestId 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
*/
public String getRequestId() {
return this.RequestId;
}
/**
* Set 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
* @param RequestId 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
*/
public void setRequestId(String RequestId) {
this.RequestId = RequestId;
}
/**
* Internal implementation, normal users should not use it.
*/
public void toMap(HashMap<String, String> map, String prefix) {
this.setParamSimple(map, prefix + "Status", this.Status);
this.setParamSimple(map, prefix + "RequestId", this.RequestId);
}
}
| [
"[email protected]"
] | |
1287912ae52ee407ceb653732f493fa7683a0295 | 4b3bcd40888671ec6cf602586d639a7a4c6b28d0 | /src/ObjectLibrary/Objects/Wall.java | 7ad21d8d59a9120f2d2175f8638894568a72b124 | [
"MIT"
] | permissive | IgnusG/project-awesome-game | c3b141472d29f4320ae0315535c9ecf7bf611e7c | 0ab8669c67d8dd24d2594f72e4439d970bedd86a | refs/heads/master | 2022-04-23T16:56:37.106165 | 2020-04-20T11:41:47 | 2020-04-20T11:46:59 | 257,262,252 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 304 | java | /*
* Autor: Jonatan Juhas - Informatik WS15
* Projekt: Objects
*/
package ObjectLibrary.Objects;
import ObjectLibrary.Item;
public class Wall extends Item {
public Wall(){
super(Objects.WALL);
}
@Override
public String toString(){
return "Wall";
}
}
| [
"[email protected]"
] | |
b131fd819ee1d21389f351bda2c2c5a3fa729df3 | 6c11c9f55ff0671ba9b896ec05a02a2ced63eb27 | /JPACRUDApp/src/test/java/com/skilldistillery/jpacrud/entities/UserTest.java | baa59733f90f420a84e51e7177d76d79a9ce7152 | [] | no_license | Alexwagner1990/JPACRUDProject | 3e4486eb254c095600d393c3e996d2ac501e52b8 | b26c6e3b383be8881778aa3e5b092b10000141b1 | refs/heads/master | 2020-03-11T21:58:22.359538 | 2018-04-25T15:36:53 | 2018-04-25T15:36:53 | 130,279,502 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,186 | java | package com.skilldistillery.jpacrud.entities;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
class UserTest {
private EntityManagerFactory emf;
private EntityManager em;
private User user;
@BeforeEach
void setUp() throws Exception {
emf = Persistence.createEntityManagerFactory("RestaurantPickerWebApp");
em = emf.createEntityManager();
user = new User();
user.setPassword("testing");
user.setUsername("tester");
}
@AfterEach
void tearDown() throws Exception {
em.close();
emf.close();
}
@Test
@DisplayName("User Mapping")
void test() {
user = em.find(User.class, 2);
assertEquals("test", user.getUsername());
assertEquals("tester", user.getPassword());
}
@Test
@DisplayName("User Adding")
void testAdd() {
String query = "select u from User u";
em.getTransaction().begin();
List<User> count = em.createQuery(query, User.class).getResultList();
int size = count.size();
em.persist(user);
em.flush();
count = em.createQuery(query, User.class).getResultList();
int size2 = count.size();
assertEquals(size, (size2 - 1));
em.getTransaction().rollback();
}
@Test
@DisplayName("User Updating")
void testUpdate() {
em.getTransaction().begin();
user = em.find(User.class, 1);
user.setUsername("Batman");
em.flush();
user = em.find(User.class, 1);
assertEquals("Batman", user.getUsername());
em.getTransaction().rollback();
}
@Test
@DisplayName("User Deleting")
void testDelete() {
em.getTransaction().begin();
user = em.find(User.class, 1);
em.remove(user);
em.flush();
assertEquals(null, em.find(User.class, 1));
em.getTransaction().rollback();
}
@Test
@DisplayName("User Relationship with Restaurant")
void testRestaurantRelationship() {
em.getTransaction().begin();
assertEquals("alexwagner", em.find(Restaurant.class, 1).getUser().getUsername());
}
}
| [
"[email protected]"
] | |
c80e97ab4635813a83db26e51ba4bc6f6878f2fb | 0da72d62107115bc7623726b67c10edfaf3921d7 | /src/main/java/springfive/cms/domain/models/CMSObject.java | 70d56a8308e603ba78d40bf7b9bdde8909c63845 | [] | no_license | PrathameshBeri/NewsReviewSite | a0047703a5e792eff6f45f80873a6c1f5ab4a384 | aa624eae83e95c6d9157ad40832875e41c68640b | refs/heads/master | 2022-12-16T12:29:41.249976 | 2020-09-23T18:21:47 | 2020-09-23T18:21:47 | 289,999,204 | 0 | 0 | null | 2020-09-23T18:21:48 | 2020-08-24T17:50:42 | Java | UTF-8 | Java | false | false | 283 | java | package springfive.cms.domain.models;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import java.time.LocalDateTime;
public class CMSObject {
@Column
LocalDateTime creationDate;
@Column
LocalDateTime modificationDate;
}
| [
"[email protected]"
] | |
4270e3bd776093917e06db5e34fea835705ffdeb | 6ebe19081305cf4201e79f988009ac5f05eb9a68 | /src/org/cakelab/oge/utils/ktx/KTX.java | 3e4274e22f2c64584628b6f01a4c628ee5f68d1c | [] | no_license | homacs/org.cakelab.soapbox | ab6ee28f48e484b68e7ceb689383d5bddc7426e4 | 36f3190d949d8821281cac59e995fb27f9608886 | refs/heads/master | 2022-06-06T11:35:14.222582 | 2022-05-09T17:29:01 | 2022-05-09T17:29:01 | 204,141,155 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,787 | java | package org.cakelab.oge.utils.ktx;
import static org.lwjgl.opengl.GL11.GL_NONE;
import static org.lwjgl.opengl.GL11.GL_RED;
import static org.lwjgl.opengl.GL11.GL_RGB;
import static org.lwjgl.opengl.GL11.GL_RGBA;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_1D;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
import static org.lwjgl.opengl.GL11.GL_UNPACK_ALIGNMENT;
import static org.lwjgl.opengl.GL11.glBindTexture;
import static org.lwjgl.opengl.GL11.glGenTextures;
import static org.lwjgl.opengl.GL11.glPixelStorei;
import static org.lwjgl.opengl.GL11.glTexSubImage1D;
import static org.lwjgl.opengl.GL11.glTexSubImage2D;
import static org.lwjgl.opengl.GL12.GL_BGR;
import static org.lwjgl.opengl.GL12.GL_BGRA;
import static org.lwjgl.opengl.GL12.GL_TEXTURE_3D;
import static org.lwjgl.opengl.GL12.glTexSubImage3D;
import static org.lwjgl.opengl.GL13.GL_TEXTURE_CUBE_MAP;
import static org.lwjgl.opengl.GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X;
import static org.lwjgl.opengl.GL30.GL_RG;
import static org.lwjgl.opengl.GL30.GL_TEXTURE_1D_ARRAY;
import static org.lwjgl.opengl.GL30.GL_TEXTURE_2D_ARRAY;
import static org.lwjgl.opengl.GL30.glGenerateMipmap;
import static org.lwjgl.opengl.GL40.GL_TEXTURE_CUBE_MAP_ARRAY;
import static org.lwjgl.opengl.GL42.glTexStorage1D;
import static org.lwjgl.opengl.GL42.glTexStorage2D;
import static org.lwjgl.opengl.GL42.glTexStorage3D;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import org.cakelab.oge.texture.GPUTexture;
import org.cakelab.oge.utils.BufferUtilsHelper;
import org.cakelab.util.types.ArrayListByte;
public class KTX {
public static class Header {
byte[] identifier = new byte[12]; // 12 byte
int endianness;
int gltype;
int gltypesize;
int glformat;
int glinternalformat;
int glbaseinternalformat;
int pixelwidth;
int pixelheight;
int pixeldepth;
int arrayelements;
int faces;
int miplevels;
int keypairbytes;
public boolean read(InputStream fp) throws IOException {
DataInputStream in = new DataInputStream(fp);
in.read(identifier);
endianness = in.readInt();
gltype = in.readInt();
gltypesize = in.readInt();
glformat = in.readInt();
glinternalformat = in.readInt();
glbaseinternalformat = in.readInt();
pixelwidth = in.readInt();
pixelheight = in.readInt();
pixeldepth = in.readInt();
arrayelements = in.readInt();
faces = in.readInt();
miplevels = in.readInt();
keypairbytes = in.readInt();
return true;
}
}
// union keyvaluepair
// {
// unsigned int size;
// unsigned char rawbytes[4];
// };
static byte[] identifier = new byte[] { (byte) 0xAB, 0x4B, 0x54, 0x58,
0x20, 0x31, 0x31, (byte) 0xBB, 0x0D, 0x0A, 0x1A, 0x0A };
public static int swap32(int value) {
int b1 = (value >> 0) & 0xff;
int b2 = (value >> 8) & 0xff;
int b3 = (value >> 16) & 0xff;
int b4 = (value >> 24) & 0xff;
return b1 << 24 | b2 << 16 | b3 << 8 | b4 << 0;
}
public static short swap(short value) {
int b1 = value & 0xff;
int b2 = (value >> 8) & 0xff;
return (short) (b1 << 8 | b2 << 0);
}
public static int calculate_stride(Header h, int width) {
int pad = 4;
return calculate_stride(h, width, pad);
}
public static int calculate_stride(Header h, int width, int pad) {
int channels = 0;
switch (h.glbaseinternalformat) {
case GL_RED:
channels = 1;
break;
case GL_RG:
channels = 2;
break;
case GL_BGR:
case GL_RGB:
channels = 3;
break;
case GL_BGRA:
case GL_RGBA:
channels = 4;
break;
}
int stride = h.gltypesize * channels * width;
stride = (stride + (pad - 1)) & ~(pad - 1);
return stride;
}
public static int calculate_face_size(Header h) {
int stride = calculate_stride(h, h.pixelwidth);
return stride * h.pixelheight;
}
public static GPUTexture load(String filename) throws IOException {
return load(filename, 0);
}
public static GPUTexture load(InputStream in) throws IOException {
return load(in, 0);
}
public static GPUTexture load(String filename, int tex) throws IOException {
return load(new FileInputStream(filename), tex);
}
public static GPUTexture load(InputStream fp, int tex) throws IOException {
Header header = new Header();
byte[] data;
int target = GL_NONE;
if (!header.read(fp)) {
fp.close();
throw new IOException("Failed reading header");
}
if (!Arrays.equals(header.identifier, identifier)) {
fp.close();
throw new IOException("Magic number test failed. File corrupted.");
}
if (header.endianness == 0x04030201) {
// No swap needed
} else if (header.endianness == 0x01020304) {
// Swap needed
header.endianness = swap32(header.endianness);
header.gltype = swap32(header.gltype);
header.gltypesize = swap32(header.gltypesize);
header.glformat = swap32(header.glformat);
header.glinternalformat = swap32(header.glinternalformat);
header.glbaseinternalformat = swap32(header.glbaseinternalformat);
header.pixelwidth = swap32(header.pixelwidth);
header.pixelheight = swap32(header.pixelheight);
header.pixeldepth = swap32(header.pixeldepth);
header.arrayelements = swap32(header.arrayelements);
header.faces = swap32(header.faces);
header.miplevels = swap32(header.miplevels);
header.keypairbytes = swap32(header.keypairbytes);
} else {
fp.close();
throw new IOException(
"Couldn't identify endianess. File corrupted.");
}
// Guess target (texture type)
if (header.pixelheight == 0) {
if (header.arrayelements == 0) {
target = GL_TEXTURE_1D;
} else {
target = GL_TEXTURE_1D_ARRAY;
}
} else if (header.pixeldepth == 0) {
if (header.arrayelements == 0) {
if (header.faces == 0) {
target = GL_TEXTURE_2D;
} else {
target = GL_TEXTURE_CUBE_MAP;
}
} else {
if (header.faces == 0) {
target = GL_TEXTURE_2D_ARRAY;
} else {
target = GL_TEXTURE_CUBE_MAP_ARRAY;
}
}
} else {
target = GL_TEXTURE_3D;
}
// Check for insanity...
if (target == GL_NONE || // Couldn't figure out target
(header.pixelwidth == 0) || // Texture has no width???
(header.pixelheight == 0 && header.pixeldepth != 0)) // Texture
// has
// depth
// but
// no
// height???
{
fp.close();
throw new IOException("Failed reading header");
}
if (tex == 0) {
tex = glGenTextures();
}
//
// read all data in one buffer
//
ArrayListByte buffer = new ArrayListByte(1024);
buffer.copy(fp);
fp.close();
data = buffer.toArray();
if (header.miplevels == 0) {
header.miplevels = 1;
}
glBindTexture(target, tex);
switch (target) {
case GL_TEXTURE_1D:
glTexStorage1D(GL_TEXTURE_1D, header.miplevels,
header.glinternalformat, header.pixelwidth);
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, header.pixelwidth,
header.glformat, header.glinternalformat,
BufferUtilsHelper.createByteBuffer(data));
break;
case GL_TEXTURE_2D:
glTexStorage2D(GL_TEXTURE_2D, header.miplevels,
header.glinternalformat, header.pixelwidth,
header.pixelheight);
{
int ptr = 0;
int height = header.pixelheight;
int width = header.pixelwidth;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
for (int i = 0; i < header.miplevels; i++) {
int stride_len = calculate_stride(header, width, 1);
glTexSubImage2D(GL_TEXTURE_2D, i, 0, 0, width, height,
header.glformat, header.gltype,
BufferUtilsHelper.createByteBuffer(data, ptr,
height*stride_len));
ptr += height * stride_len;
height >>= 1;
width >>= 1;
if (height == 0)
height = 1;
if (width == 0)
width = 1;
}
}
break;
case GL_TEXTURE_3D:
glTexStorage3D(GL_TEXTURE_3D, header.miplevels,
header.glinternalformat, header.pixelwidth,
header.pixelheight, header.pixeldepth);
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, header.pixelwidth,
header.pixelheight, header.pixeldepth, header.glformat,
header.gltype, BufferUtilsHelper.createByteBuffer(data));
break;
case GL_TEXTURE_1D_ARRAY:
glTexStorage2D(GL_TEXTURE_1D_ARRAY, header.miplevels,
header.glinternalformat, header.pixelwidth,
header.arrayelements);
glTexSubImage2D(GL_TEXTURE_1D_ARRAY, 0, 0, 0, header.pixelwidth,
header.arrayelements, header.glformat, header.gltype,
BufferUtilsHelper.createByteBuffer(data));
break;
case GL_TEXTURE_2D_ARRAY:
glTexStorage3D(GL_TEXTURE_2D_ARRAY, header.miplevels,
header.glinternalformat, header.pixelwidth,
header.pixelheight, header.arrayelements);
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, header.pixelwidth,
header.pixelheight, header.arrayelements, header.glformat,
header.gltype, BufferUtilsHelper.createByteBuffer(data));
break;
case GL_TEXTURE_CUBE_MAP:
glTexStorage2D(GL_TEXTURE_CUBE_MAP, header.miplevels,
header.glinternalformat, header.pixelwidth,
header.pixelheight);
// glTexSubImage3D(GL_TEXTURE_CUBE_MAP, 0, 0, 0, 0, h.pixelwidth,
// h.pixelheight, h.faces, h.glformat, h.gltype, data);
{
int face_size = calculate_face_size(header);
for (int i = 0; i < header.faces; i++) {
glTexSubImage2D(
GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
0,
0,
0,
header.pixelwidth,
header.pixelheight,
header.glformat,
header.gltype,
BufferUtilsHelper.createByteBuffer(data, face_size
* i, face_size));
}
}
break;
case GL_TEXTURE_CUBE_MAP_ARRAY:
glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, header.miplevels,
header.glinternalformat, header.pixelwidth,
header.pixelheight, header.arrayelements);
glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, 0,
header.pixelwidth, header.pixelheight, header.faces
* header.arrayelements, header.glformat,
header.gltype, BufferUtilsHelper.createByteBuffer(data));
break;
default: // Should never happen
throw new Error("Unknown texture target type");
}
if (header.miplevels == 1) {
glGenerateMipmap(target);
}
return new GPUTexture(target, tex);
}
// TOTO: remove?
// boolean save(String filename, int target, int tex)
// {
// header h;
//
// memset(&h, 0, sizeof(h));
// memcpy(h.identifier, identifier, sizeof(identifier));
// h.endianness = 0x04030201;
//
// glBindTexture(target, tex);
//
// glGetTexLevelParameteriv(target, 0, GL_TEXTURE_WIDTH, (GLint
// *)&h.pixelwidth);
// glGetTexLevelParameteriv(target, 0, GL_TEXTURE_HEIGHT, (GLint
// *)&h.pixelheight);
// glGetTexLevelParameteriv(target, 0, GL_TEXTURE_DEPTH, (GLint
// *)&h.pixeldepth);
//
// return true;
// }
}
| [
"[email protected]"
] | |
c096e7875f80b56359ed6102b628c5f3cf6c30f2 | 5941f48153e82ad5b69ffc9731a7570d439ff3a9 | /src/ru/tasha2k7/mail/library/datamodel/Books.java | 31bcf9805000601edf38d177852ef83c3392ec39 | [] | no_license | TashaB1/Library | 9a2291f6667e1e75a7920aa6c9b6c0c706e1628c | 1cf7332286b6c90e6357b7eed6eba20b727e7ca6 | refs/heads/master | 2021-05-04T15:29:57.468750 | 2018-02-04T22:33:06 | 2018-02-04T22:33:06 | 120,230,027 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,667 | java | package ru.tasha2k7.mail.library.datamodel;
import com.google.gson.annotations.SerializedName;
import java.util.List;
/**
* Created by Ната on 01.02.2018.
*/
public class Books extends AbstractModel {
public enum Accessibility {
reading_room, // читальный зал
storage, // хранилище
open_access // открытый доступ (срок)
}
public enum Branch { //???
Brest,
Vitebsk,
Gomel,
Grodno,
Minsk,
Mogilev
}
private String title;
private List<Author> author;
@SerializedName("publishing_house")
private String publishingHouse;
private int year;
@SerializedName("number_pages")
private int numberPages;
private List<Genre> genre;
private Branch location;
private Accessibility accessibility;
private boolean available;
private List<Journal> journal;
public Books() {
}
public Books(String title, List<Author> author, String publishingHouse, int year, int numberPages, List<Genre> genre, Branch location, Accessibility accessibility, boolean available, List<Journal> journal) {
this.title = title;
this.author = author;
this.publishingHouse = publishingHouse;
this.year = year;
this.numberPages = numberPages;
this.genre = genre;
this.location = location;
this.accessibility = accessibility;
this.available = available;
this.journal = journal;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public List<Author> getAuthor() {
return author;
}
public void setAuthor(List<Author> author) {
this.author = author;
}
public String getPublishingHouse() {
return publishingHouse;
}
public void setPublishingHouse(String publishingHouse) {
this.publishingHouse = publishingHouse;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int getNumberPages() {
return numberPages;
}
public void setNumberPages(int numberPages) {
this.numberPages = numberPages;
}
public List<Genre> getGenre() {
return genre;
}
public void setGenre(List<Genre> genre) {
this.genre = genre;
}
public Branch getLocation() {
return location;
}
public void setLocation(Branch location) {
this.location = location;
}
public Accessibility getAccessibility() {
return accessibility;
}
public void setAccessibility(Accessibility accessibility) {
this.accessibility = accessibility;
}
public boolean isAvailable() {
return available;
}
public void setAvailable(boolean available) {
this.available = available;
}
public List<Journal> getJournal() {
return journal;
}
public void setJournal(List<Journal> journal) {
this.journal = journal;
}
@Override
public String toString() {
return "Books{" +
"title='" + title + '\'' +
", author=" + author +
", publishingHouse='" + publishingHouse + '\'' +
", year=" + year +
", numberPages=" + numberPages +
", genre=" + genre +
", location=" + location +
", accessibility=" + accessibility +
", available=" + available +
", journal=" + journal +
'}';
}
}
| [
"[email protected]"
] | |
7ff82360b158c0557aee74fa1bc9f5c86df3c68f | 801c39e8bbeee2e25ed1ba2b74aa039f8b3d62ae | /fizteh-java-2014/src/ru/fizteh/fivt/students/ivan_ivanov/filemap/Get.java | 26d512632d7f4c7e6e1b2a5098bd99fc66839b24 | [] | no_license | grapefroot/mipt | 2f6572b3120e28a0e63e28f2542782520384828f | 51d13fa07b37bdbdda943bd47d7e356a3a126177 | refs/heads/master | 2020-12-24T21:12:03.706690 | 2016-11-08T07:40:20 | 2016-11-08T07:40:20 | 56,529,254 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 702 | java | package ru.fizteh.fivt.students.ivan_ivanov.filemap;
import ru.fizteh.fivt.students.ivan_ivanov.shell.Shell;
import ru.fizteh.fivt.students.ivan_ivanov.shell.Command;
import java.io.IOException;
public class Get implements Command {
public final String getName() {
return "get";
}
public final void executeCmd(final Shell filemap, final String[] args) throws IOException {
String key = args[0];
String value = ((FileMap) filemap).getFileMapState().getDataBase().get(key);
if (value == null) {
System.out.println("not found");
} else {
System.out.println("found");
System.out.println(value);
}
}
}
| [
"[email protected]"
] | |
7bcf7206eda977567c25352d8d0b14352f5b6fc6 | f66debe94a8d66db207c6ac9928f502c8061d5aa | /src/main/java/com/revolut/query/service/QueryService.java | 74b0baa8ff276a7ee8762072741c5129f61a6d72 | [] | no_license | dhawalschumi/Revolut | 4297058b05b7a56015032e63fa30a5a444183018 | f70ba918a05c9712d0799327faa6d9a4fa7ff143 | refs/heads/master | 2022-07-01T14:38:28.769697 | 2019-07-22T06:35:15 | 2019-07-22T06:35:15 | 197,375,095 | 0 | 0 | null | 2022-06-21T01:28:08 | 2019-07-17T11:20:14 | Java | UTF-8 | Java | false | false | 557 | java | /**
*
*/
package com.revolut.query.service;
import java.math.BigDecimal;
import com.revolut.transfers.account.Account;
import com.revolut.transfers.account.Balance;
/**
* @author Dhawal Patel
*
*/
public interface QueryService {
public Balance executeGetBalanceQuery(final long accountId) throws Exception;
public void updateAccountBalance(final Account fromAccount, final Account toAccount, final BigDecimal amount)
throws Exception;
public Account executeGetAccountForCustomer(long customerId) throws Exception;
}
| [
"schum@LAPTOP-VOF4C0JC"
] | schum@LAPTOP-VOF4C0JC |
9f400ca575d14ed9f106a0bfcac446163bf6f98f | fff8f77f810bbd5fb6b4e5f7a654568fd9d3098d | /src/main/java/com/google/android/gms/internal/fitness/zzev.java | dbf8e21beb82671e8dc4d0e9fdff814b37f6ed64 | [] | no_license | TL148/gorkiy | b6ac8772587e9e643d939ea399bf5e7a42e89f46 | da8fbd017277cf72020c8c800326954bb1a0cee3 | refs/heads/master | 2021-05-21T08:24:39.286900 | 2020-04-03T02:57:49 | 2020-04-03T02:57:49 | 252,618,229 | 0 | 0 | null | 2020-04-03T02:54:39 | 2020-04-03T02:54:39 | null | UTF-8 | Java | false | false | 1,201 | java | package com.google.android.gms.internal.fitness;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelReader;
import com.google.android.gms.fitness.data.DataSource;
/* compiled from: com.google.android.gms:play-services-fitness@@18.0.0 */
public final class zzev implements Parcelable.Creator<zzes> {
public final /* synthetic */ Object[] newArray(int i) {
return new zzes[i];
}
public final /* synthetic */ Object createFromParcel(Parcel parcel) {
int validateObjectHeader = SafeParcelReader.validateObjectHeader(parcel);
DataSource dataSource = null;
while (parcel.dataPosition() < validateObjectHeader) {
int readHeader = SafeParcelReader.readHeader(parcel);
if (SafeParcelReader.getFieldId(readHeader) != 1) {
SafeParcelReader.skipUnknownField(parcel, readHeader);
} else {
dataSource = (DataSource) SafeParcelReader.createParcelable(parcel, readHeader, DataSource.CREATOR);
}
}
SafeParcelReader.ensureAtEnd(parcel, validateObjectHeader);
return new zzes(dataSource);
}
}
| [
"[email protected]"
] | |
e7ba37ae28b2f6320ed9129b47feddf76a86f9f0 | 78a217e39f766b0595f0f339c479a86adcb754e1 | /src/com/javarush/test/level04/lesson04/task09/Solution.java | 96665446708e5cd61031084c97ec0e56b2a11f10 | [] | no_license | Olegusplatypus/JavaRushHomeWork | af9785d88209291ba95bbf9ccc6a1d97f1b7bcb5 | 5b9b17d94be85d820a4b07b964dad51d293454a0 | refs/heads/master | 2020-12-25T14:22:55.066156 | 2016-08-02T11:27:42 | 2016-08-02T11:27:42 | 64,745,213 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,867 | java | package com.javarush.test.level04.lesson04.task09;
/* Светофор
Работа светофора для пешеходов запрограммирована следующим образом: в начале каждого часа в течение трех минут горит зеленый сигнал,
затем в течение одной минуты — желтый, а потом в течение одной минуты — красный, затем опять зеленый горит три минуты и т. д.
Ввести с клавиатуры вещественное число t, означающее время в минутах, прошедшее с начала очередного часа.
Определить, сигнал какого цвета горит для пешеходов в этот момент.
Результат вывести на экран в следующем виде:
"зеленый" - если горит зеленый цвет, "желтый" - если горит желтый цвет, "красный" - если горит красный цвет.
Пример для числа 2.5:
зеленый
Пример для числа 3:
желтый
Пример для числа 4:
красный
Пример для числа 5:
зеленый
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
double t = Double.parseDouble(reader.readLine()); //напишите тут ваш код
if (t % 5 >= 0 && t % 5 < 3)
System.out.println("зеленый");
else if (t % 5 >= 3 && t % 5 < 4)
System.out.println("желтый");
else
System.out.println("красный");
}
} | [
"[email protected]"
] | |
07b234886056a04e39f12d67ee9f5d080dec4912 | 20c1a4ac8405886fd26e6778f37c02df88ae268d | /src/main/java/asia/redact/bracket/properties/RandomAccessFileOutputAdapter.java | e75e9c89c89283fc4c65babe45a3458e7b146ea1 | [
"Apache-2.0"
] | permissive | buttermilk-crypto/bracket | 413cd3121ff216df5b58569da587ac4881d43d9b | 8fb4e734af8c152afed5745a12e645548f799b99 | refs/heads/master | 2021-01-17T14:30:42.058871 | 2018-05-21T06:09:38 | 2018-05-21T06:09:38 | 55,750,302 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,381 | java | /*
* This file is part of Buttermilk(TM)
* Copyright 2013-2014 David R. Smith for cryptoregistry.com
*
*/
package asia.redact.bracket.properties;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Set;
import java.util.Map.Entry;
import asia.redact.bracket.properties.OutputFormat;
import asia.redact.bracket.properties.Properties;
import asia.redact.bracket.properties.ValueModel;
/**
* Joins an OutputFormatter with a file to output. RandomAccessFiles can handle
* file locking semantics for example if the data is being written to a file share
* (shared file system)
*
* @author Dave
*
*/
public class RandomAccessFileOutputAdapter {
Properties props;
public RandomAccessFileOutputAdapter(Properties props) {
super();
this.props = props;
}
/**
* Write it out. The file must be closed externally
*
*/
public void writeTo(RandomAccessFile file, OutputFormat format) throws IOException {
Set<Entry<String,ValueModel>> set = props.getPropertyMap().entrySet();
file.writeChars(format.formatHeader());
for(Entry<String,ValueModel> e: set) {
String key = e.getKey();
ValueModel model = e.getValue();
file.writeBytes(format.format(key, model.getSeparator(),model.getValues(),model.getComments()));
}
file.writeBytes(format.formatFooter());
}
}
| [
"Dave@a12e1f22-4431-4adc-8947-0a92dc9a4dba"
] | Dave@a12e1f22-4431-4adc-8947-0a92dc9a4dba |
acc2ddeaa6ef904fdd053afd719fa9a8b054a15e | 8e2c9555f6ed0e03e339e805587600a61bc6d2a0 | /java/347. Top K Frequent Elements.java | 5e7702e09adebe316ffa3795089633e115678a16 | [] | no_license | fei051466/leetcode | 3d4e430c375d131180b2e99fc4d26a12e1058036 | 15811a27265a729978349f0a3e803bf5aadb98e8 | refs/heads/master | 2021-01-16T23:51:22.509775 | 2017-03-30T06:17:50 | 2017-03-30T06:17:50 | 59,805,985 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,002 | java | public class Solution {
public List<Integer> topKFrequent(int[] nums, int k) {
Map<Integer, Integer> my_map = new HashMap<Integer, Integer>(nums.length);
List<Integer> res = new ArrayList<Integer>();
List<Integer>[] bucket = new List[nums.length+1];
for(int i=0; i<nums.length; i++){
if(my_map.containsKey(nums[i])){
my_map.put(nums[i], my_map.get(nums[i])+1);
}
else{
my_map.put(nums[i], 1);
}
}
for(int key:my_map.keySet()){
int count = my_map.get(key);
if(bucket[count] == null){
bucket[count] = new ArrayList<Integer>();
}
bucket[count].add(key);
}
for(int i=bucket.length-1; i>=0; i--){
if(bucket[i] != null){
res.addAll(bucket[i]);
}
if(res.size() == k){
break;
}
}
return res;
}
} | [
"[email protected]"
] | |
ab027f8172967eb168aca11116f8883b754d0245 | 149f6a8e826ba749b1303acadfa9bdae1da871e2 | /src/main/java/com/sise/controller/IndexController.java | 2da2474cca2ec63851fc6a823bb65698d67d8426 | [] | no_license | swyeah/decorationsystem | c596e1daa4b8759f2ca0ce4bbf4abdbe28bb5fa6 | 2443e3c2481567d963c51d29b954e19d245c015a | refs/heads/master | 2020-03-22T01:19:27.289780 | 2018-07-01T03:36:40 | 2018-07-01T03:36:40 | 139,297,894 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 25,578 | java | package com.sise.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.gson.Gson;
import com.sise.po.*;
import com.sise.service.*;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpSession;
import java.sql.Date;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/welcome")
public class IndexController {
@Autowired
private ConsumerService consumerService;
@Autowired
private AreaTypeService areaTypeService;
@Autowired
private HouseTypeService houseTypeService;
@Autowired
private DecorationStyleService decorationStyleService;
@Autowired
private DesignerShowService designerShowService;
@Autowired
private EmployeeService employeeService;
@Autowired
private RegistrationTableService registrationTableService;
@Autowired
private HousepicService housepicService;
@Autowired
private DesignerpicService designerpicService;
@Autowired
private ContractService contractService;
@Autowired
private ProjectTimeService projectTimeService;
@Autowired
private InspectionReportService inspectionReportService;
@RequestMapping("/index")
public String goIndex(@RequestParam(value = "sname",defaultValue = "",required = false) String sname,@RequestParam(value = "houseId",defaultValue = "0",required = false) Integer houseId,
@RequestParam(value = "styleId",defaultValue = "0",required = false) Integer styleId,
@RequestParam(value = "areaId",defaultValue = "0",required = false) Integer areaId,Model model, @RequestParam(defaultValue = "1",required = false) Integer pageNum){
SearchDesignerShow searchContent =new SearchDesignerShow();
if (sname!=null)
searchContent.setSname(sname);
if (styleId !=null)
searchContent.setStyleId(styleId);
if (houseId !=null)
searchContent.setHouseId(houseId);
if(areaId!=null)
searchContent.setAreaId(areaId);
System.out.println(searchContent.toString());
PageHelper.startPage(pageNum, 8);
List<DesignerShow> designerShows = designerShowService.searchDesignerToIndex(searchContent);
for (DesignerShow d:designerShows){
Integer collectcount = designerShowService.getCountCollectionByShowId(d.getShowId());
Integer praisecount = designerShowService.getCountPraiseByShowId(d.getShowId());
d.setCollectCount(collectcount);
d.setPraiseCount(praisecount);
}
PageInfo<DesignerShow> pageInfo = new PageInfo<DesignerShow>(designerShows);
List<AreaType> areaTypes = areaTypeService.findAllAreaType();
List<HouseType> houseTypes = houseTypeService.findAllHousetype();
List<DecorationStyle> decorationStyles = decorationStyleService.searchAllDecorationStyle();
model.addAttribute("areaTypes",areaTypes);
model.addAttribute("houseTypes",houseTypes);
model.addAttribute("decorationStyles",decorationStyles);
model.addAttribute("designerShows",designerShows);
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("searchContent",searchContent);
return "index";
}
/*跳转到客户装修意向提交*/
@RequestMapping("/consumer_intention")
public String GoConsumerIntention(Model model){
List<Province> provinces = consumerService.searchAllProvince();
model.addAttribute("provinces",provinces);
return "consumer_control/consumer_intention";
}
@RequestMapping(value = "/getcity",method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
@ResponseBody
public String getCity(@RequestBody String provinceId){
Gson gson = new Gson();
JSONObject jsonObject = JSONObject.fromObject(provinceId);
String province = jsonObject.getString("provinceId");
List<City> cities = consumerService.searchCityByProvinceId(Integer.parseInt(province));
String result = gson.toJson(cities);
return result;
}
@RequestMapping(value = "/setgood",method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
@ResponseBody
public String setgood(@RequestBody String showId){
JSONObject jsonObject1 = JSONObject.fromObject(showId);
String msg = "";;
Integer show = jsonObject1.getInt("showId");
Integer praiseMan = jsonObject1.getInt("praiseMan");
Praise praise = new Praise(praiseMan,show);
JSONObject jsonObject2 = new JSONObject();
if (designerShowService.findPraiseByShowId(praise)){
jsonObject2.put("msg","已点赞过,不能再点!");
return jsonObject2.toString();
}else {
designerShowService.savePraise(praise);
msg = "1";
}
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
@RequestMapping("/designershow")
public String designershow(@RequestParam("showId") Integer showId,Model model){
DesignerShow designerShow = designerShowService.searchDesignerShowByShowId(showId);
Integer collectcount = designerShowService.getCountCollectionByShowId(showId);
Integer praisecount = designerShowService.getCountPraiseByShowId(showId);
Employee employee = employeeService.searchEmployeeById(designerShow.getEmployeeId());
designerShow.setCollectCount(collectcount);
designerShow.setPraiseCount(praisecount);
model.addAttribute("designerShow",designerShow);
model.addAttribute("employee",employee);
return "consumer_control/index_designershow";
}
@RequestMapping(value = "/setcollect",method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
@ResponseBody
public String setcollect(@RequestBody String showId){
JSONObject jsonObject1 = JSONObject.fromObject(showId);
String msg = "";;
Integer show = jsonObject1.getInt("showId");
Integer collectman = jsonObject1.getInt("collectman");
CollectionShow collectionShow = new CollectionShow(collectman,show);
JSONObject jsonObject2 = new JSONObject();
if (designerShowService.findCollectByShowId(collectionShow)){
jsonObject2.put("msg","已收藏过,不能再点!");
return jsonObject2.toString();
}else {
designerShowService.saveCollectionShow(collectionShow);
msg = "1";
}
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
@RequestMapping("/index_register")
public String index_register(Model model){
List<Province> provinces = consumerService.searchAllProvince();
model.addAttribute("provinces",provinces);
return "consumer_control/index_register";
}
@RequestMapping(value = "/doregistration" ,method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
@ResponseBody
public String doregistration(@RequestBody RegistrationTable registrationTable){
registrationTable.setRegistrationTime(new Date(System.currentTimeMillis()));
System.out.println(registrationTable);
Integer column = registrationTableService.saveRegistration(registrationTable);
JSONObject jsonObject = new JSONObject();
jsonObject.put("result","true");
return jsonObject.toString();
}
/*返回指定设计师数据*/
@RequestMapping(value = "/getDesigner" ,method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
@ResponseBody
public String getDesigner(@RequestBody String requestdata){
JSONObject jsonObject = JSONObject.fromObject(requestdata);
Integer pageNum = Integer.parseInt(jsonObject.getString("pageNum"));
String search =jsonObject.getString("search");
List list = new ArrayList();
if (search.equals("")){
List<Employee> employees = new ArrayList<Employee>();
PageHelper.startPage(pageNum, 5);
employees = employeeService.searchAllDesigner();
PageInfo<Employee> pageInfo = new PageInfo<Employee>(employees);
list.add(pageInfo);
list.add(employees);
}else {
List<Employee> employees = new ArrayList<Employee>();
PageHelper.startPage(pageNum, 5);
employees= employeeService.searchEmployBySearch(search);
PageInfo<Employee> pageInfo = new PageInfo<Employee>(employees);
list.add(pageInfo);
list.add(employees);
}
Gson gson = new Gson();
String result = gson.toJson(list);
return result;
}
@RequestMapping("/myproject")
public String myproject(HttpSession session,Model model,@RequestParam(defaultValue = "1",required = false) Integer pageNum){
Consumer consumer =(Consumer) session.getAttribute("consumer");
if (consumer!=null){
String userName = consumer.getUserName();
PageHelper.startPage(pageNum, 3);
List<RegistrationTable> registrationTables =registrationTableService.searchRegistrationByUserName(userName);
PageInfo<RegistrationTable> pageInfo = new PageInfo<RegistrationTable>(registrationTables);
model.addAttribute("resultStatus","1");
model.addAttribute("registrationTables",registrationTables);
model.addAttribute("pageInfo",pageInfo);
}else {
model.addAttribute("resultStatus","0");
}
return "consumer_control/myproject";
}
@RequestMapping("/housepic")
public String housepic(@RequestParam("registrationId") Integer registrationId, Model model,HttpSession session){
Consumer consumer =(Consumer) session.getAttribute("consumer");
RegistrationTable registrationTable = registrationTableService.searchRegistrationById(registrationId);
if (consumer!=null®istrationTable!=null){
if (consumer.getUserName().equals(registrationTable.getUserName())){
Housepic housepic = housepicService.findHousepicByRegistrationId(registrationId);
if (housepic == null) {
model.addAttribute("resultStatus", "false");
} else {
List<HousepicFile> housepicFiles = housepicService.findHousepicFileByHousepicId(housepic.getHousepicId());
model.addAttribute("housepic", housepic);
model.addAttribute("housepicFiles", housepicFiles);
model.addAttribute("registrationId", registrationId);
model.addAttribute("resultStatus", "true");
}
}
}
model.addAttribute("registrationId", registrationId);
return "consumer_control/index_housepic";
}
@RequestMapping(value = "/setStatus",method =RequestMethod.POST,produces = "text/html;charset=UTF-8" )
@ResponseBody
public String setStatus(@RequestBody String str){
JSONObject jsonObject1 = JSONObject.fromObject(str);
Integer housepicId = jsonObject1.getInt("housepicId");
String userName = jsonObject1.getString("userName");
Integer version = jsonObject1.getInt("version");
JSONObject jsonObject2 = new JSONObject();
String msg="";
Integer column = 0;
if (version>=housepicService.searchVersionById(housepicId)){
if (registrationTableService.compareHousepicAndConusmer(userName,housepicId)){
column = housepicService.changeStatusById(housepicId,3);
}else {
msg="无法访问别的客户信息!";
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
}else {
msg="数据已被刷新,请重新访问!";
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
if (column==1){
jsonObject2.put("msg","确认成功!");
}else{
jsonObject2.put("msg","确认失败!");
}
return jsonObject2.toString();
}
@RequestMapping(value = "/setStatusFalse" ,method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
@ResponseBody
public String setStatusFalse(@RequestBody String str){
JSONObject jsonObject1 = JSONObject.fromObject(str);
Integer housepicId = jsonObject1.getInt("housepicId");
String userName = jsonObject1.getString("userName");
Integer version = jsonObject1.getInt("version");
JSONObject jsonObject2 = new JSONObject();
String msg="";
Integer column = 0;
if (version>=housepicService.searchVersionById(housepicId)){
if (registrationTableService.compareHousepicAndConusmer(userName,housepicId)){
column = housepicService.changeStatusById(housepicId,2);
}else {
msg="无法访问别的客户信息!";
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
}else {
msg="数据已被刷新,请重新访问!";
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
if (column==1){
msg = "确认户型图错误待修改!";
}else{
msg = "请刷新界面,重新确认!";
}
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
@RequestMapping("/designerpic")
public String designer(@RequestParam("registrationId") Integer registrationId, Model model,HttpSession session){
Consumer consumer =(Consumer) session.getAttribute("consumer");
RegistrationTable registrationTable = registrationTableService.searchRegistrationById(registrationId);
if (consumer!=null®istrationTable!=null){
if (consumer.getUserName().equals(registrationTable.getUserName())){
Designerpic designerpic = designerpicService.searchDesignerpicByRegistrationId(registrationId);
if (designerpic == null) {
model.addAttribute("resultStatus", "false");
} else {
List<DesignerpicFile> designerpicFiles = designerpicService.searchAllDesignerpicFileByDesignerId(designerpic.getDesignerpicId());
model.addAttribute("designerpic", designerpic);
model.addAttribute("designerpicFiles", designerpicFiles);
model.addAttribute("resultStatus", "true");
}
}
}
model.addAttribute("registrationId", registrationId);
return "consumer_control/index_designerpic";
}
@RequestMapping(value = "/setdesignerpicStatus",method =RequestMethod.POST,produces = "text/html;charset=UTF-8" )
@ResponseBody
public String setdesignerpicStatus(@RequestBody String str,HttpSession session){
JSONObject jsonObject1 = JSONObject.fromObject(str);
Integer designerpicId = jsonObject1.getInt("designerpicId");
Consumer consumer =(Consumer) session.getAttribute("consumer");
Integer version = jsonObject1.getInt("version");
JSONObject jsonObject2 = new JSONObject();
String msg="";
Integer column = 0;
if (version>=designerpicService.searchVersionByDesignerpicId(designerpicId)){
if (consumer!=null && registrationTableService.compareDesignerpicAndConusmer(consumer.getUserName(),designerpicId)){
column = designerpicService.changeStatusByDesignerpicId(designerpicId,3);
}else {
msg="无法访问别的客户信息!";
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
}else {
msg="数据已被刷新,请重新访问!";
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
if (column==1){
jsonObject2.put("msg","同意成功!");
}else{
jsonObject2.put("msg","同意失败!");
}
return jsonObject2.toString();
}
@RequestMapping(value = "/setdesignerpicStatusFalse" ,method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
@ResponseBody
public String setdesignerpicStatusFalse(@RequestBody String str,HttpSession session){
JSONObject jsonObject1 = JSONObject.fromObject(str);
Integer designerpicId = jsonObject1.getInt("designerpicId");
Consumer consumer =(Consumer) session.getAttribute("consumer");
Integer version = jsonObject1.getInt("version");
JSONObject jsonObject2 = new JSONObject();
String msg="";
Integer column = 0;
if (version>=designerpicService.searchVersionByDesignerpicId(designerpicId)){
if (consumer!=null && registrationTableService.compareDesignerpicAndConusmer(consumer.getUserName(),designerpicId)){
column = designerpicService.changeStatusByDesignerpicId(designerpicId,2);
}else {
msg="无法访问别的客户信息!";
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
}else {
msg="数据已被刷新,请重新访问!";
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
if (column==1){
msg = "操作成功!";
}else{
msg = "请刷新界面,重新确认!";
}
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
@RequestMapping("/contract")
public String contract(@RequestParam("registrationId") Integer registrationId, Model model,HttpSession session){
Consumer consumer =(Consumer) session.getAttribute("consumer");
RegistrationTable registrationTable = registrationTableService.searchRegistrationById(registrationId);
if (consumer!=null®istrationTable!=null){
if (consumer.getUserName().equals(registrationTable.getUserName())){
Contract contract = contractService.findContractByRegistrationId(registrationId);
if (contract == null) {
model.addAttribute("resultStatus", "false");
} else {
List<ContractFile> contractFiles = contractService.findContractFileByContractId(contract.getContractId());
model.addAttribute("contract", contract);
model.addAttribute("contractFiles", contractFiles);
model.addAttribute("resultStatus", "true");
}
}
}
model.addAttribute("registrationId", registrationId);
return "consumer_control/index_contract";
}
@RequestMapping(value = "/setcontractStatus",method =RequestMethod.POST,produces = "text/html;charset=UTF-8" )
@ResponseBody
public String setcontractStatus(@RequestBody String str,HttpSession session){
JSONObject jsonObject1 = JSONObject.fromObject(str);
Integer contractId = jsonObject1.getInt("contractId");
Consumer consumer =(Consumer) session.getAttribute("consumer");
Integer version = jsonObject1.getInt("version");
JSONObject jsonObject2 = new JSONObject();
String msg="";
Integer column = 0;
if (version>=contractService.searchVersionById(contractId)){
if (consumer!=null && registrationTableService.compareContractAndConusmer(consumer.getUserName(),contractId)){
column = contractService.changeStatusById(contractId,5);
}else {
msg="无法访问别的客户信息!";
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
}else {
msg="数据已被刷新,请重新访问!";
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
if (column==1){
jsonObject2.put("msg","同意成功!");
}else{
jsonObject2.put("msg","同意失败!");
}
return jsonObject2.toString();
}
@RequestMapping(value = "/setcontractStatusFalse" ,method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
@ResponseBody
public String setcontractStatusFalse(@RequestBody String str,HttpSession session){
JSONObject jsonObject1 = JSONObject.fromObject(str);
Integer contractId = jsonObject1.getInt("contractId");
Consumer consumer =(Consumer) session.getAttribute("consumer");
Integer version = jsonObject1.getInt("version");
JSONObject jsonObject2 = new JSONObject();
String msg="";
Integer column = 0;
if (version>=contractService.searchVersionById(contractId)){
if (consumer!=null && registrationTableService.compareContractAndConusmer(consumer.getUserName(),contractId)){
column = contractService.changeStatusById(contractId,4);
}else {
msg="无法访问别的客户信息!";
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
}else {
msg="数据已被刷新,请重新访问!";
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
if (column==1){
msg = "操作成功!";
}else{
msg = "请刷新界面,重新确认!";
}
jsonObject2.put("msg",msg);
return jsonObject2.toString();
}
@RequestMapping("/project_time")
public String project_time(@RequestParam("registrationId") Integer registrationId,@RequestParam(value = "startTime",defaultValue = "",required = false) String startTime,@RequestParam(value = "endTime",defaultValue = "",required = false) String endTime,
Model model,@RequestParam(defaultValue = "1",required = false) Integer pageNum){
Map<String ,Object> map = new HashMap<String ,Object>();
if (startTime!="")
map.put("startTime",startTime);
if (endTime!="")
map.put("endTime",endTime);
map.put("registrationId",registrationId);
PageHelper.startPage(pageNum, 30);
List<ProjectTime> projectTimes =projectTimeService.searchProjectTimeBySearch(map);
PageInfo<ProjectTime> pageInfo = new PageInfo<ProjectTime>(projectTimes);
model.addAttribute("projectTimes",projectTimes);
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("map",map);
return "consumer_control/index_project_time";
}
@RequestMapping("/progressContent")
public String progressContent(@RequestParam(value = "progressId",required = false) Integer progressId,@RequestParam(value = "projectId" ) Integer projectId,Model model){
List<ProgressContent> progressContents = new ArrayList<ProgressContent>();
if (projectId!=null){
progressContents = projectTimeService.searchAllProgressContentTitleByProjectId(projectId);
}
ProgressContent progressContent = null;
ProjectTime projectTime=null;
if (progressContents.size()>0){
if (progressId==null){
progressId = progressContents.get(0).getProgressId();
}
projectTime = projectTimeService.searchProjectTimeByProjectId(projectId);
progressContent = projectTimeService.searchProgressContentByProgressId(progressId);
}
model.addAttribute("projectId",projectId);
model.addAttribute("projectTime",projectTime);
model.addAttribute("progressContents",progressContents);
model.addAttribute("progressContent",progressContent);
return "consumer_control/index_progress_content";
}
@RequestMapping("/inspection_report")
public String inspection_report(@RequestParam("registrationId")Integer registrationId, Model model){
if (registrationId!=null){
InspectionReport inspectionReport = inspectionReportService.searchInspectionReportByRegistrationId(registrationId);
if (inspectionReport!=null){
List<InspectionReportPic> inspectionReportPics = inspectionReportService.searchInspectionReportpicByReportId(inspectionReport.getReportId());
model.addAttribute("resultStatus","1");
model.addAttribute("inspectionReport",inspectionReport);
model.addAttribute("inspectionReportPics",inspectionReportPics);
}else {
model.addAttribute("resultStatus",0);
}
}
model.addAttribute("registrationId",registrationId);
return "consumer_control/index_inspection_report";
}
@RequestMapping(value = "/logout" ,method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
@ResponseBody
public String logout(HttpSession session){
session.removeAttribute("consumer");
session.removeAttribute("name");
JSONObject jsonObject = new JSONObject();
jsonObject.put("msg","退出成功!");
return jsonObject.toString();
}
}
| [
"[email protected]"
] | |
6a9be8552febc3b9c15b46b93b5e8989bc4ac8b8 | 8cf2bf13e4b6ccc2d8ac78aacfb7a21466ae8244 | /huifa-cnki-core/src/main/java/com/huifa/paper/parent/cnki/dao/common/ISystemTopicDao.java | d40e085ae5156bf51b6aca7c004dbfcd63adb95d | [] | no_license | kit-chen/huifa-paper-parent | 2ac37b51e67b8a413679abcb422953f8e8a9af33 | 15dc6d7dcf903a016bc7cd7e76bc6edb691387ee | refs/heads/master | 2020-06-10T22:37:41.719235 | 2016-12-07T16:40:00 | 2016-12-07T16:40:00 | 75,855,128 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 859 | java | package com.huifa.paper.parent.cnki.dao.common;
import com.huifa.paper.parent.cnki.entity.common.SystemTopic;
import com.huifa.paper.parent.cnki.vo.common.SystemTopicVo;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* Created by kchen on 2016-12-03.
*/
public interface ISystemTopicDao {
SystemTopicVo getById(Long id);
List<SystemTopicVo> getBeforeOrAfter(Map<Serializable, Serializable> updateMap);
SystemTopicVo createTopic(SystemTopic systemTopic) throws IOException;
void updateTopic(Map<Serializable, Serializable> updateMap);
void logicDelSysTopicById(Long id);
void deleteSysTopicById(Long id);
List<SystemTopicVo> getSysTopicByMap(Map<Serializable, Serializable> params);
Integer getSysTopicCountByMap(Map<Serializable, Serializable> params);
}
| [
"[email protected]"
] | |
f368f80dceb63d2eed92302ec1e9942c39587009 | a7f2ddc615fe0e66b06cafa386a2d16d3ea4cc85 | /src/main/java/com/example/passwordkeeper/sevice/UserServiceImpl.java | 9ff7bbb34aa9c7de891154006b54235343441931 | [] | no_license | sonus2884/PasswordKeeper | e7f62320354303425f9d0fffbd2a1bd12cde7792 | 4b35febdd3937668376fcd5638d14fd9955daf89 | refs/heads/master | 2022-12-23T22:49:13.415407 | 2020-10-01T17:54:51 | 2020-10-01T17:54:51 | 290,804,451 | 0 | 0 | null | 2020-10-01T17:54:52 | 2020-08-27T14:55:45 | Java | UTF-8 | Java | false | false | 1,599 | java | package com.example.passwordkeeper.sevice;
import com.example.passwordkeeper.dto.UserDto;
import com.example.passwordkeeper.exception.UserExistsException;
import com.example.passwordkeeper.exception.UserNotFoundException;
import com.example.passwordkeeper.model.User;
import com.example.passwordkeeper.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
@Service
public class UserServiceImpl implements UserService{
@Autowired
private UserRepository userRepository;
@Autowired
private PasswordEncoder passwordEncoder;
@Override
public User createUser(UserDto userDto) {
if (userRepository.findUserByEmail(userDto.getEmail()) != null){
throw new UserNotFoundException("User with \'" + userDto.getEmail()+ " \' email already exists");
}
User user = new User();
user.setEmail(userDto.getEmail());
user.setPassword(passwordEncoder.encode(userDto.getPassword()));
User savedUser = userRepository.save(user);
return savedUser;
}
@Override
public User findUser(UserDto userDto) {
if (userRepository.findUserByEmail(userDto.getEmail()) == null){
throw new UserExistsException("User with \'" + userDto.getEmail()+ " \' email not exists");
}
return userRepository.findUserByEmail(userDto.getEmail());
}
}
| [
"[email protected]"
] | |
4ea2168c8778ac138d5ac3eed288466a12922ef1 | f26dbcfeb28f04722cefe17480d97ff52945f716 | /app/src/main/java/com/sp/parcial_1/AgregarAlimento.java | c12f9234b0fbd26886b0bf555f96f0d48b8ceaeb | [] | no_license | santipineda26/Parcial_1 | 78d785d130ad04e4b1e655c337faec0804834fbf | 38b726e7854beb6ad53eb5faadeef6f6acfc1c87 | refs/heads/master | 2023-03-29T18:43:28.525737 | 2021-04-09T04:00:04 | 2021-04-09T04:00:04 | 356,128,384 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,792 | java | package com.sp.parcial_1;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.ib.custom.toast.CustomToastView;
import java.util.ArrayList;
import Clases.Producto;
import static java.lang.Integer.parseInt;
public class AgregarAlimento extends AppCompatActivity implements View.OnClickListener {
Producto producto = new Producto();
public static ArrayList<Producto> productos = new ArrayList();
private Button btnAgregar;
private Button btnInicio;
private EditText txtNombre;
private EditText txtCodigo;
private EditText txtValor;
private EditText txtIva;
private EditText txtDescripcion;
private EditText txtCategoria;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_agregar_alimento);
btnAgregar = findViewById(R.id.btnAgregar);
btnInicio = findViewById(R.id.btnInicio);
txtNombre = findViewById(R.id.txtNombre);
txtCodigo = findViewById(R.id.txtCodigo);
txtValor = findViewById(R.id.txtValor);
txtIva = findViewById(R.id.txtIva);
txtDescripcion = findViewById(R.id.txtDescripcion);
txtCategoria = findViewById(R.id.txtCategoria);
btnInicio.setOnClickListener(this);
btnAgregar.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.btnAgregar) {
String nombre = txtNombre.getText().toString();
String codigo = txtCodigo.getText().toString();
String valor = txtValor.getText().toString();
String iva = txtIva.getText().toString();
String descripcion = txtDescripcion.getText().toString();
String categoria = txtCategoria.getText().toString();
if (nombre.isEmpty()) {
CustomToastView.makeErrorToast(this, "Error al validar el Nombre", R.layout.custom_toast).show();
return;
}
if (codigo.isEmpty()) {
CustomToastView.makeErrorToast(this, "Error al validar el Código", R.layout.custom_toast).show();
return;
}
if (valor.isEmpty()) {
CustomToastView.makeErrorToast(this, "Error al validar el Valor", R.layout.custom_toast).show();
return;
}
if (iva.isEmpty()) {
CustomToastView.makeErrorToast(this, "Error al validar el IVA", R.layout.custom_toast).show();
return;
}
if (descripcion.isEmpty()) {
CustomToastView.makeErrorToast(this, "Error al validar la Descripción", R.layout.custom_toast).show();
return;
}
if (categoria.isEmpty()) {
CustomToastView.makeErrorToast(this, "Error al validar la Categoría", R.layout.custom_toast).show();
return;
}
Producto nuevoProducto;
nuevoProducto = new Producto();
nuevoProducto.setNombre(nombre);
nuevoProducto.setCodigo(codigo);
nuevoProducto.setValor(parseInt(valor));
nuevoProducto.setIva(iva);
nuevoProducto.setDescripcion(descripcion);
nuevoProducto.setCategoria(categoria);
productos.add(nuevoProducto);
Intent intent = new Intent(this, ListarAlimentos.class);
startActivity(intent);
}
if (v.getId() == R.id.btnInicio) {
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
}
}
| [
"[email protected]"
] | |
b3acbc45637f963755946e78d53f1f38d9c7ec07 | 0f43560c526c89ecc0596d4daa0fab45063c135c | /src/main/java/com/zjw/smallioc/aop/PointcutAdvisor.java | b4d56866d76f44e32ae3fe0bdd242e2eccadfcef | [] | no_license | XiaoXia001/small-spring | f6e7b2829f672799ae5ad854232641da433ab4bc | c6e5dda10a7a4cd15a059dc9cfdeb85959f26d6d | refs/heads/master | 2021-07-06T15:52:06.105548 | 2019-08-20T12:21:59 | 2019-08-20T12:21:59 | 190,680,260 | 0 | 0 | null | 2020-10-13T13:44:30 | 2019-06-07T02:55:03 | Java | UTF-8 | Java | false | false | 68 | java | package com.zjw.smallioc.aop;
public interface PointcutAdvisor {
}
| [
"[email protected]"
] | |
3d7ac45e16755421a34ef3da535e1c444443d331 | eca99e2af37ede85f4c291ea886d05357305d011 | /app/src/main/java/com/cadyd/app/utils/GPUImageFilterTools.java | 754c8ee732c5694a2ddc84f62723db116c64f7b2 | [] | no_license | Brave-wan/cadyd | 302fc5f47cdb246ab1ad88f585adcaa87518e080 | 7fb26a29a8609520c7be8b72016c1ecccf5872ca | refs/heads/master | 2020-07-29T14:15:44.080887 | 2016-11-14T03:40:31 | 2016-11-14T03:40:31 | 73,664,047 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 36,810 | java | /*
* Copyright (C) 2012 CyberAgent
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.cadyd.app.utils;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.BitmapFactory;
import android.graphics.PointF;
import android.opengl.Matrix;
import com.cadyd.app.R;
import java.util.LinkedList;
import java.util.List;
import jp.co.cyberagent.android.gpuimage.GPUImage3x3ConvolutionFilter;
import jp.co.cyberagent.android.gpuimage.GPUImage3x3TextureSamplingFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageAddBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageAlphaBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageBilateralFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageBoxBlurFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageBrightnessFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageBulgeDistortionFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageCGAColorspaceFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageChromaKeyBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageColorBalanceFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageColorBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageColorBurnBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageColorDodgeBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageColorInvertFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageContrastFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageCrosshatchFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageDarkenBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageDifferenceBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageDilationFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageDirectionalSobelEdgeDetectionFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageDissolveBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageDivideBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageEmbossFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageExclusionBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageExposureFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageFalseColorFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageFilterGroup;
import jp.co.cyberagent.android.gpuimage.GPUImageGammaFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageGaussianBlurFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageGlassSphereFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageGrayscaleFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageHalftoneFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageHardLightBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageHazeFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageHighlightShadowFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageHueBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageHueFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageKuwaharaFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageLaplacianFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageLevelsFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageLightenBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageLinearBurnBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageLookupFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageLuminosityBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageMonochromeFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageMultiplyBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageNonMaximumSuppressionFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageNormalBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageOpacityFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageOverlayBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImagePixelationFilter;
import jp.co.cyberagent.android.gpuimage.GPUImagePosterizeFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageRGBDilationFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageRGBFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageSaturationBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageSaturationFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageScreenBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageSepiaFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageSharpenFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageSketchFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageSmoothToonFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageSobelEdgeDetection;
import jp.co.cyberagent.android.gpuimage.GPUImageSoftLightBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageSourceOverBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageSphereRefractionFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageSubtractBlendFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageSwirlFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageToneCurveFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageToonFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageTransformFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageTwoInputFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageVignetteFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageWeakPixelInclusionFilter;
import jp.co.cyberagent.android.gpuimage.GPUImageWhiteBalanceFilter;
public class GPUImageFilterTools {
public static void showDialog(final Context context,
final OnGpuImageFilterChosenListener listener) {
final FilterList filters = new FilterList();
filters.addFilter("Contrast", FilterType.CONTRAST);
filters.addFilter("Invert", FilterType.INVERT);
filters.addFilter("Pixelation", FilterType.PIXELATION);
filters.addFilter("Hue", FilterType.HUE);
filters.addFilter("Gamma", FilterType.GAMMA);
filters.addFilter("Brightness", FilterType.BRIGHTNESS);
filters.addFilter("Sepia", FilterType.SEPIA);
filters.addFilter("Grayscale", FilterType.GRAYSCALE);
filters.addFilter("Sharpness", FilterType.SHARPEN);
filters.addFilter("Sobel Edge Detection", FilterType.SOBEL_EDGE_DETECTION);
filters.addFilter("3x3 Convolution", FilterType.THREE_X_THREE_CONVOLUTION);
filters.addFilter("Emboss", FilterType.EMBOSS);
filters.addFilter("Posterize", FilterType.POSTERIZE);
filters.addFilter("Grouped filters", FilterType.FILTER_GROUP);
filters.addFilter("Saturation", FilterType.SATURATION);
filters.addFilter("Exposure", FilterType.EXPOSURE);
filters.addFilter("Highlight Shadow", FilterType.HIGHLIGHT_SHADOW);
filters.addFilter("Monochrome", FilterType.MONOCHROME);
filters.addFilter("Opacity", FilterType.OPACITY);
filters.addFilter("RGB", FilterType.RGB);
filters.addFilter("White Balance", FilterType.WHITE_BALANCE);
filters.addFilter("Vignette", FilterType.VIGNETTE);
filters.addFilter("ToneCurve", FilterType.TONE_CURVE);
filters.addFilter("Blend (Difference)", FilterType.BLEND_DIFFERENCE);
filters.addFilter("Blend (Source Over)", FilterType.BLEND_SOURCE_OVER);
filters.addFilter("Blend (Color Burn)", FilterType.BLEND_COLOR_BURN);
filters.addFilter("Blend (Color Dodge)", FilterType.BLEND_COLOR_DODGE);
filters.addFilter("Blend (Darken)", FilterType.BLEND_DARKEN);
filters.addFilter("Blend (Dissolve)", FilterType.BLEND_DISSOLVE);
filters.addFilter("Blend (Exclusion)", FilterType.BLEND_EXCLUSION);
filters.addFilter("Blend (Hard Light)", FilterType.BLEND_HARD_LIGHT);
filters.addFilter("Blend (Lighten)", FilterType.BLEND_LIGHTEN);
filters.addFilter("Blend (Add)", FilterType.BLEND_ADD);
filters.addFilter("Blend (Divide)", FilterType.BLEND_DIVIDE);
filters.addFilter("Blend (Multiply)", FilterType.BLEND_MULTIPLY);
filters.addFilter("Blend (Overlay)", FilterType.BLEND_OVERLAY);
filters.addFilter("Blend (Screen)", FilterType.BLEND_SCREEN);
filters.addFilter("Blend (Alpha)", FilterType.BLEND_ALPHA);
filters.addFilter("Blend (Color)", FilterType.BLEND_COLOR);
filters.addFilter("Blend (Hue)", FilterType.BLEND_HUE);
filters.addFilter("Blend (Saturation)", FilterType.BLEND_SATURATION);
filters.addFilter("Blend (Luminosity)", FilterType.BLEND_LUMINOSITY);
filters.addFilter("Blend (Linear Burn)", FilterType.BLEND_LINEAR_BURN);
filters.addFilter("Blend (Soft Light)", FilterType.BLEND_SOFT_LIGHT);
filters.addFilter("Blend (Subtract)", FilterType.BLEND_SUBTRACT);
filters.addFilter("Blend (Chroma Key)", FilterType.BLEND_CHROMA_KEY);
filters.addFilter("Blend (Normal)", FilterType.BLEND_NORMAL);
filters.addFilter("Lookup (Amatorka)", FilterType.LOOKUP_AMATORKA);
filters.addFilter("Gaussian Blur", FilterType.GAUSSIAN_BLUR);
filters.addFilter("Crosshatch", FilterType.CROSSHATCH);
filters.addFilter("Box Blur", FilterType.BOX_BLUR);
filters.addFilter("CGA Color Space", FilterType.CGA_COLORSPACE);
filters.addFilter("Dilation", FilterType.DILATION);
filters.addFilter("Kuwahara", FilterType.KUWAHARA);
filters.addFilter("RGB Dilation", FilterType.RGB_DILATION);
filters.addFilter("Sketch", FilterType.SKETCH);
filters.addFilter("Toon", FilterType.TOON);
filters.addFilter("Smooth Toon", FilterType.SMOOTH_TOON);
filters.addFilter("Halftone", FilterType.HALFTONE);
filters.addFilter("Bulge Distortion", FilterType.BULGE_DISTORTION);
filters.addFilter("Glass Sphere", FilterType.GLASS_SPHERE);
filters.addFilter("Haze", FilterType.HAZE);
filters.addFilter("Laplacian", FilterType.LAPLACIAN);
filters.addFilter("Non Maximum Suppression", FilterType.NON_MAXIMUM_SUPPRESSION);
filters.addFilter("Sphere Refraction", FilterType.SPHERE_REFRACTION);
filters.addFilter("Swirl", FilterType.SWIRL);
filters.addFilter("Weak Pixel Inclusion", FilterType.WEAK_PIXEL_INCLUSION);
filters.addFilter("False Color", FilterType.FALSE_COLOR);
filters.addFilter("Color Balance", FilterType.COLOR_BALANCE);
filters.addFilter("Levels Min (Mid Adjust)", FilterType.LEVELS_FILTER_MIN);
filters. addFilter("Bilateral Blur", FilterType.BILATERAL_BLUR);
filters.addFilter("Transform (2-D)", FilterType.TRANSFORM2D);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Choose a filter");
builder.setItems(filters.names.toArray(new String[filters.names.size()]),
new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int item) {
listener.onGpuImageFilterChosenListener(
createFilterForType(context, filters.filters.get(item)));
}
});
builder.create().show();
}
private static GPUImageFilter createFilterForType(final Context context, final FilterType type) {
switch (type) {
case CONTRAST:
return new GPUImageContrastFilter(2.0f);
case GAMMA:
return new GPUImageGammaFilter(2.0f);
case INVERT:
return new GPUImageColorInvertFilter();
case PIXELATION:
return new GPUImagePixelationFilter();
case HUE:
return new GPUImageHueFilter(90.0f);
case BRIGHTNESS:
return new GPUImageBrightnessFilter(1.5f);
case GRAYSCALE:
return new GPUImageGrayscaleFilter();
case SEPIA:
return new GPUImageSepiaFilter();
case SHARPEN:
GPUImageSharpenFilter sharpness = new GPUImageSharpenFilter();
sharpness.setSharpness(2.0f);
return sharpness;
case SOBEL_EDGE_DETECTION:
return new GPUImageSobelEdgeDetection();
case THREE_X_THREE_CONVOLUTION:
GPUImage3x3ConvolutionFilter convolution = new GPUImage3x3ConvolutionFilter();
convolution.setConvolutionKernel(new float[] {
-1.0f, 0.0f, 1.0f,
-2.0f, 0.0f, 2.0f,
-1.0f, 0.0f, 1.0f
});
return convolution;
case EMBOSS:
return new GPUImageEmbossFilter();
case POSTERIZE:
return new GPUImagePosterizeFilter();
case FILTER_GROUP:
List<GPUImageFilter> filters = new LinkedList<GPUImageFilter>();
filters.add(new GPUImageContrastFilter());
filters.add(new GPUImageDirectionalSobelEdgeDetectionFilter());
filters.add(new GPUImageGrayscaleFilter());
return new GPUImageFilterGroup(filters);
case SATURATION:
return new GPUImageSaturationFilter(1.0f);
case EXPOSURE:
return new GPUImageExposureFilter(0.0f);
case HIGHLIGHT_SHADOW:
return new GPUImageHighlightShadowFilter(0.0f, 1.0f);
case MONOCHROME:
return new GPUImageMonochromeFilter(1.0f, new float[]{0.6f, 0.45f, 0.3f, 1.0f});
case OPACITY:
return new GPUImageOpacityFilter(1.0f);
case RGB:
return new GPUImageRGBFilter(1.0f, 1.0f, 1.0f);
case WHITE_BALANCE:
return new GPUImageWhiteBalanceFilter(5000.0f, 0.0f);
case VIGNETTE:
PointF centerPoint = new PointF();
centerPoint.x = 0.5f;
centerPoint.y = 0.5f;
return new GPUImageVignetteFilter(centerPoint, new float[] {0.0f, 0.0f, 0.0f}, 0.3f, 0.75f);
case TONE_CURVE:
GPUImageToneCurveFilter toneCurveFilter = new GPUImageToneCurveFilter();
toneCurveFilter.setFromCurveFileInputStream(
context.getResources().openRawResource(R.raw.tone_cuver_sample));
return toneCurveFilter;
case BLEND_DIFFERENCE:
return createBlendFilter(context, GPUImageDifferenceBlendFilter.class);
case BLEND_SOURCE_OVER:
return createBlendFilter(context, GPUImageSourceOverBlendFilter.class);
case BLEND_COLOR_BURN:
return createBlendFilter(context, GPUImageColorBurnBlendFilter.class);
case BLEND_COLOR_DODGE:
return createBlendFilter(context, GPUImageColorDodgeBlendFilter.class);
case BLEND_DARKEN:
return createBlendFilter(context, GPUImageDarkenBlendFilter.class);
case BLEND_DISSOLVE:
return createBlendFilter(context, GPUImageDissolveBlendFilter.class);
case BLEND_EXCLUSION:
return createBlendFilter(context, GPUImageExclusionBlendFilter.class);
case BLEND_HARD_LIGHT:
return createBlendFilter(context, GPUImageHardLightBlendFilter.class);
case BLEND_LIGHTEN:
return createBlendFilter(context, GPUImageLightenBlendFilter.class);
case BLEND_ADD:
return createBlendFilter(context, GPUImageAddBlendFilter.class);
case BLEND_DIVIDE:
return createBlendFilter(context, GPUImageDivideBlendFilter.class);
case BLEND_MULTIPLY:
return createBlendFilter(context, GPUImageMultiplyBlendFilter.class);
case BLEND_OVERLAY:
return createBlendFilter(context, GPUImageOverlayBlendFilter.class);
case BLEND_SCREEN:
return createBlendFilter(context, GPUImageScreenBlendFilter.class);
case BLEND_ALPHA:
return createBlendFilter(context, GPUImageAlphaBlendFilter.class);
case BLEND_COLOR:
return createBlendFilter(context, GPUImageColorBlendFilter.class);
case BLEND_HUE:
return createBlendFilter(context, GPUImageHueBlendFilter.class);
case BLEND_SATURATION:
return createBlendFilter(context, GPUImageSaturationBlendFilter.class);
case BLEND_LUMINOSITY:
return createBlendFilter(context, GPUImageLuminosityBlendFilter.class);
case BLEND_LINEAR_BURN:
return createBlendFilter(context, GPUImageLinearBurnBlendFilter.class);
case BLEND_SOFT_LIGHT:
return createBlendFilter(context, GPUImageSoftLightBlendFilter.class);
case BLEND_SUBTRACT:
return createBlendFilter(context, GPUImageSubtractBlendFilter.class);
case BLEND_CHROMA_KEY:
return createBlendFilter(context, GPUImageChromaKeyBlendFilter.class);
case BLEND_NORMAL:
return createBlendFilter(context, GPUImageNormalBlendFilter.class);
case LOOKUP_AMATORKA:
GPUImageLookupFilter amatorka = new GPUImageLookupFilter();
amatorka.setBitmap(BitmapFactory.decodeResource(context.getResources(), R.drawable.lookup_amatorka));
return amatorka;
case GAUSSIAN_BLUR:
return new GPUImageGaussianBlurFilter();
case CROSSHATCH:
return new GPUImageCrosshatchFilter();
case BOX_BLUR:
return new GPUImageBoxBlurFilter();
case CGA_COLORSPACE:
return new GPUImageCGAColorspaceFilter();
case DILATION:
return new GPUImageDilationFilter();
case KUWAHARA:
return new GPUImageKuwaharaFilter();
case RGB_DILATION:
return new GPUImageRGBDilationFilter();
case SKETCH:
return new GPUImageSketchFilter();
case TOON:
return new GPUImageToonFilter();
case SMOOTH_TOON:
return new GPUImageSmoothToonFilter();
case BULGE_DISTORTION:
return new GPUImageBulgeDistortionFilter();
case GLASS_SPHERE:
return new GPUImageGlassSphereFilter();
case HAZE:
return new GPUImageHazeFilter();
case LAPLACIAN:
return new GPUImageLaplacianFilter();
case NON_MAXIMUM_SUPPRESSION:
return new GPUImageNonMaximumSuppressionFilter();
case SPHERE_REFRACTION:
return new GPUImageSphereRefractionFilter();
case SWIRL:
return new GPUImageSwirlFilter();
case WEAK_PIXEL_INCLUSION:
return new GPUImageWeakPixelInclusionFilter();
case FALSE_COLOR:
return new GPUImageFalseColorFilter();
case COLOR_BALANCE:
return new GPUImageColorBalanceFilter();
case LEVELS_FILTER_MIN:
GPUImageLevelsFilter levelsFilter = new GPUImageLevelsFilter();
levelsFilter.setMin(0.0f, 3.0f, 1.0f);
return levelsFilter;
case HALFTONE:
return new GPUImageHalftoneFilter();
case BILATERAL_BLUR:
return new GPUImageBilateralFilter();
case TRANSFORM2D:
return new GPUImageTransformFilter();
default:
throw new IllegalStateException("No filter of that type!");
}
}
private static GPUImageFilter createBlendFilter(Context context, Class<? extends GPUImageTwoInputFilter> filterClass) {
try {
GPUImageTwoInputFilter filter = filterClass.newInstance();
filter.setBitmap(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher));
return filter;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public interface OnGpuImageFilterChosenListener {
void onGpuImageFilterChosenListener(GPUImageFilter filter);
}
private enum FilterType {
CONTRAST, GRAYSCALE, SHARPEN, SEPIA, SOBEL_EDGE_DETECTION, THREE_X_THREE_CONVOLUTION, FILTER_GROUP, EMBOSS, POSTERIZE, GAMMA, BRIGHTNESS, INVERT, HUE, PIXELATION,
SATURATION, EXPOSURE, HIGHLIGHT_SHADOW, MONOCHROME, OPACITY, RGB, WHITE_BALANCE, VIGNETTE, TONE_CURVE, BLEND_COLOR_BURN, BLEND_COLOR_DODGE, BLEND_DARKEN, BLEND_DIFFERENCE,
BLEND_DISSOLVE, BLEND_EXCLUSION, BLEND_SOURCE_OVER, BLEND_HARD_LIGHT, BLEND_LIGHTEN, BLEND_ADD, BLEND_DIVIDE, BLEND_MULTIPLY, BLEND_OVERLAY, BLEND_SCREEN, BLEND_ALPHA,
BLEND_COLOR, BLEND_HUE, BLEND_SATURATION, BLEND_LUMINOSITY, BLEND_LINEAR_BURN, BLEND_SOFT_LIGHT, BLEND_SUBTRACT, BLEND_CHROMA_KEY, BLEND_NORMAL, LOOKUP_AMATORKA,
GAUSSIAN_BLUR, CROSSHATCH, BOX_BLUR, CGA_COLORSPACE, DILATION, KUWAHARA, RGB_DILATION, SKETCH, TOON, SMOOTH_TOON, BULGE_DISTORTION, GLASS_SPHERE, HAZE, LAPLACIAN, NON_MAXIMUM_SUPPRESSION,
SPHERE_REFRACTION, SWIRL, WEAK_PIXEL_INCLUSION, FALSE_COLOR, COLOR_BALANCE, LEVELS_FILTER_MIN, BILATERAL_BLUR, HALFTONE, TRANSFORM2D
}
private static class FilterList {
public List<String> names = new LinkedList<String>();
public List<FilterType> filters = new LinkedList<FilterType>();
public void addFilter(final String name, final FilterType filter) {
names.add(name);
filters.add(filter);
}
}
public static class FilterAdjuster {
private final Adjuster<? extends GPUImageFilter> adjuster;
public FilterAdjuster(final GPUImageFilter filter) {
if (filter instanceof GPUImageSharpenFilter) {
adjuster = new SharpnessAdjuster().filter(filter);
} else if (filter instanceof GPUImageSepiaFilter) {
adjuster = new SepiaAdjuster().filter(filter);
} else if (filter instanceof GPUImageContrastFilter) {
adjuster = new ContrastAdjuster().filter(filter);
} else if (filter instanceof GPUImageGammaFilter) {
adjuster = new GammaAdjuster().filter(filter);
} else if (filter instanceof GPUImageBrightnessFilter) {
adjuster = new BrightnessAdjuster().filter(filter);
} else if (filter instanceof GPUImageSobelEdgeDetection) {
adjuster = new SobelAdjuster().filter(filter);
} else if (filter instanceof GPUImageEmbossFilter) {
adjuster = new EmbossAdjuster().filter(filter);
} else if (filter instanceof GPUImage3x3TextureSamplingFilter) {
adjuster = new GPU3x3TextureAdjuster().filter(filter);
} else if (filter instanceof GPUImageHueFilter) {
adjuster = new HueAdjuster().filter(filter);
} else if (filter instanceof GPUImagePosterizeFilter) {
adjuster = new PosterizeAdjuster().filter(filter);
} else if (filter instanceof GPUImagePixelationFilter) {
adjuster = new PixelationAdjuster().filter(filter);
} else if (filter instanceof GPUImageSaturationFilter) {
adjuster = new SaturationAdjuster().filter(filter);
} else if (filter instanceof GPUImageExposureFilter) {
adjuster = new ExposureAdjuster().filter(filter);
} else if (filter instanceof GPUImageHighlightShadowFilter) {
adjuster = new HighlightShadowAdjuster().filter(filter);
} else if (filter instanceof GPUImageMonochromeFilter) {
adjuster = new MonochromeAdjuster().filter(filter);
} else if (filter instanceof GPUImageOpacityFilter) {
adjuster = new OpacityAdjuster().filter(filter);
} else if (filter instanceof GPUImageRGBFilter) {
adjuster = new RGBAdjuster().filter(filter);
} else if (filter instanceof GPUImageWhiteBalanceFilter) {
adjuster = new WhiteBalanceAdjuster().filter(filter);
} else if (filter instanceof GPUImageVignetteFilter) {
adjuster = new VignetteAdjuster().filter(filter);
} else if (filter instanceof GPUImageDissolveBlendFilter) {
adjuster = new DissolveBlendAdjuster().filter(filter);
} else if (filter instanceof GPUImageGaussianBlurFilter) {
adjuster = new GaussianBlurAdjuster().filter(filter);
} else if (filter instanceof GPUImageCrosshatchFilter) {
adjuster = new CrosshatchBlurAdjuster().filter(filter);
} else if (filter instanceof GPUImageBulgeDistortionFilter) {
adjuster = new BulgeDistortionAdjuster().filter(filter);
} else if (filter instanceof GPUImageGlassSphereFilter) {
adjuster = new GlassSphereAdjuster().filter(filter);
} else if (filter instanceof GPUImageHazeFilter) {
adjuster = new HazeAdjuster().filter(filter);
} else if (filter instanceof GPUImageSphereRefractionFilter) {
adjuster = new SphereRefractionAdjuster().filter(filter);
} else if (filter instanceof GPUImageSwirlFilter) {
adjuster = new SwirlAdjuster().filter(filter);
} else if (filter instanceof GPUImageColorBalanceFilter) {
adjuster = new ColorBalanceAdjuster().filter(filter);
} else if (filter instanceof GPUImageLevelsFilter) {
adjuster = new LevelsMinMidAdjuster().filter(filter);
} else if (filter instanceof GPUImageBilateralFilter) {
adjuster = new BilateralAdjuster().filter(filter);
} else if (filter instanceof GPUImageTransformFilter) {
adjuster = new RotateAdjuster().filter(filter);
}
else {
adjuster = null;
}
}
public boolean canAdjust() {
return adjuster != null;
}
public void adjust(final int percentage) {
if (adjuster != null) {
adjuster.adjust(percentage);
}
}
private abstract class Adjuster<T extends GPUImageFilter> {
private T filter;
@SuppressWarnings("unchecked")
public Adjuster<T> filter(final GPUImageFilter filter) {
this.filter = (T) filter;
return this;
}
public T getFilter() {
return filter;
}
public abstract void adjust(int percentage);
protected float range(final int percentage, final float start, final float end) {
return (end - start) * percentage / 100.0f + start;
}
protected int range(final int percentage, final int start, final int end) {
return (end - start) * percentage / 100 + start;
}
}
private class SharpnessAdjuster extends Adjuster<GPUImageSharpenFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setSharpness(range(percentage, -4.0f, 4.0f));
}
}
private class PixelationAdjuster extends Adjuster<GPUImagePixelationFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setPixel(range(percentage, 1.0f, 100.0f));
}
}
private class HueAdjuster extends Adjuster<GPUImageHueFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setHue(range(percentage, 0.0f, 360.0f));
}
}
private class ContrastAdjuster extends Adjuster<GPUImageContrastFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setContrast(range(percentage, 0.0f, 2.0f));
}
}
private class GammaAdjuster extends Adjuster<GPUImageGammaFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setGamma(range(percentage, 0.0f, 3.0f));
}
}
private class BrightnessAdjuster extends Adjuster<GPUImageBrightnessFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setBrightness(range(percentage, -1.0f, 1.0f));
}
}
private class SepiaAdjuster extends Adjuster<GPUImageSepiaFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setIntensity(range(percentage, 0.0f, 2.0f));
}
}
private class SobelAdjuster extends Adjuster<GPUImageSobelEdgeDetection> {
@Override
public void adjust(final int percentage) {
getFilter().setLineSize(range(percentage, 0.0f, 5.0f));
}
}
private class EmbossAdjuster extends Adjuster<GPUImageEmbossFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setIntensity(range(percentage, 0.0f, 4.0f));
}
}
private class PosterizeAdjuster extends Adjuster<GPUImagePosterizeFilter> {
@Override
public void adjust(final int percentage) {
// In theorie to 256, but only first 50 are interesting
getFilter().setColorLevels(range(percentage, 1, 50));
}
}
private class GPU3x3TextureAdjuster extends Adjuster<GPUImage3x3TextureSamplingFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setLineSize(range(percentage, 0.0f, 5.0f));
}
}
private class SaturationAdjuster extends Adjuster<GPUImageSaturationFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setSaturation(range(percentage, 0.0f, 2.0f));
}
}
private class ExposureAdjuster extends Adjuster<GPUImageExposureFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setExposure(range(percentage, -10.0f, 10.0f));
}
}
private class HighlightShadowAdjuster extends Adjuster<GPUImageHighlightShadowFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setShadows(range(percentage, 0.0f, 1.0f));
getFilter().setHighlights(range(percentage, 0.0f, 1.0f));
}
}
private class MonochromeAdjuster extends Adjuster<GPUImageMonochromeFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setIntensity(range(percentage, 0.0f, 1.0f));
//getFilter().setColor(new float[]{0.6f, 0.45f, 0.3f, 1.0f});
}
}
private class OpacityAdjuster extends Adjuster<GPUImageOpacityFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setOpacity(range(percentage, 0.0f, 1.0f));
}
}
private class RGBAdjuster extends Adjuster<GPUImageRGBFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setRed(range(percentage, 0.0f, 1.0f));
//getFilter().setGreen(range(percentage, 0.0f, 1.0f));
//getFilter().setBlue(range(percentage, 0.0f, 1.0f));
}
}
private class WhiteBalanceAdjuster extends Adjuster<GPUImageWhiteBalanceFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setTemperature(range(percentage, 2000.0f, 8000.0f));
//getFilter().setTint(range(percentage, -100.0f, 100.0f));
}
}
private class VignetteAdjuster extends Adjuster<GPUImageVignetteFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setVignetteStart(range(percentage, 0.0f, 1.0f));
}
}
private class DissolveBlendAdjuster extends Adjuster<GPUImageDissolveBlendFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setMix(range(percentage, 0.0f, 1.0f));
}
}
private class GaussianBlurAdjuster extends Adjuster<GPUImageGaussianBlurFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setBlurSize(range(percentage, 0.0f, 1.0f));
}
}
private class CrosshatchBlurAdjuster extends Adjuster<GPUImageCrosshatchFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setCrossHatchSpacing(range(percentage, 0.0f, 0.06f));
getFilter().setLineWidth(range(percentage, 0.0f, 0.006f));
}
}
private class BulgeDistortionAdjuster extends Adjuster<GPUImageBulgeDistortionFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setRadius(range(percentage, 0.0f, 1.0f));
getFilter().setScale(range(percentage, -1.0f, 1.0f));
}
}
private class GlassSphereAdjuster extends Adjuster<GPUImageGlassSphereFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setRadius(range(percentage, 0.0f, 1.0f));
}
}
private class HazeAdjuster extends Adjuster<GPUImageHazeFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setDistance(range(percentage, -0.3f, 0.3f));
getFilter().setSlope(range(percentage, -0.3f, 0.3f));
}
}
private class SphereRefractionAdjuster extends Adjuster<GPUImageSphereRefractionFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setRadius(range(percentage, 0.0f, 1.0f));
}
}
private class SwirlAdjuster extends Adjuster<GPUImageSwirlFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setAngle(range(percentage, 0.0f, 2.0f));
}
}
private class ColorBalanceAdjuster extends Adjuster<GPUImageColorBalanceFilter> {
@Override
public void adjust(int percentage) {
getFilter().setMidtones(new float[]{
range(percentage, 0.0f, 1.0f),
range(percentage / 2, 0.0f, 1.0f),
range(percentage / 3, 0.0f, 1.0f)});
}
}
private class LevelsMinMidAdjuster extends Adjuster<GPUImageLevelsFilter> {
@Override
public void adjust(int percentage) {
getFilter().setMin(0.0f, range(percentage, 0.0f, 1.0f), 1.0f);
}
}
private class BilateralAdjuster extends Adjuster<GPUImageBilateralFilter> {
@Override
public void adjust(final int percentage) {
getFilter().setDistanceNormalizationFactor(range(percentage, 0.0f, 15.0f));
}
}
private class RotateAdjuster extends Adjuster<GPUImageTransformFilter> {
@Override
public void adjust(final int percentage) {
float[] transform = new float[16];
Matrix.setRotateM(transform, 0, 360 * percentage / 100, 0, 0, 1.0f);
getFilter().setTransform3D(transform);
}
}
}
}
| [
"[email protected]"
] | |
5a03a59d9fa988068a2401be8ba1b30e464b1bbb | 82b341cb79ab5413492dba167b0004f3e0826651 | /src/main/java/com/company/service/CitiesService.java | b1a9062a3b868c437d6454acb1875c3ade917fb3 | [] | no_license | musanabiyev/bankAPI | 6faceeccd33954cbe705215b653cd33091b32d5d | cc61dc6c7904dfcf28547f3142d6bf9a4fe11ec8 | refs/heads/main | 2023-08-01T22:41:52.544642 | 2021-09-16T14:46:36 | 2021-09-16T14:46:36 | 405,349,739 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,246 | java | package com.company.service;
import com.company.model.Cities;
import com.company.repository.CitiesRepository;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@Service
public class CitiesService {
private final CitiesRepository citiesRepository;
public CitiesService(CitiesRepository citiesRepository) {
this.citiesRepository = citiesRepository;
}
public List<Cities> getAllCities() {
return new ArrayList<Cities>((Collection<? extends Cities>) citiesRepository.findAll());
}
public Cities getCitiesById(Long id) {
return citiesRepository.findById(id).orElseThrow(() -> new RuntimeException("Couldnt find city by id: " + id));
}
public Cities createCities(Cities cities){
return citiesRepository.save(cities);
}
public Cities updateCities(Long id, Cities cities){
Cities oldCity = getCitiesById(id);
oldCity.setName(cities.getName());
oldCity.setPlateCode(cities.getPlateCode());
return citiesRepository.save(oldCity);
}
public void deleteCities(Long id){
Cities city = getCitiesById(id);
citiesRepository.delete(city);
}
}
| [
"[email protected]"
] | |
5542fd8f6d8b01800d87c8c6e44dc9962f5f7845 | 14c69415beaaad2f75a92aae2929da27cbf60887 | /e-SToPP/app/src/androidTest/java/com/shamsed/e_stopp/ExampleInstrumentedTest.java | 64fd7ab0fd8033e9f39de9c0f1de2e42681deae9 | [] | no_license | FIU-SCIS-Senior-Projects/Social-APP-Ver-1.0 | 860fd13aa6c1811a351f3cbf0e43d8fe09c40b9f | c81459e6a5fdda80e53ad9eb7e566322421af578 | refs/heads/master | 2020-12-06T19:00:50.831734 | 2016-12-05T21:40:49 | 2016-12-05T21:40:49 | 67,468,216 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 742 | java | package com.shamsed.e_stopp;
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.shamsed.e_stopp", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
906b2157f8c288fa0ab313d7a77104f61656878b | 13c2d3db2d49c40c74c2e6420a9cd89377f1c934 | /program_data/JavaProgramData/21/1932.java | 7eefa5321fcf2e054eac002bfd1ee946041d975e | [
"MIT"
] | permissive | qiuchili/ggnn_graph_classification | c2090fefe11f8bf650e734442eb96996a54dc112 | 291ff02404555511b94a4f477c6974ebd62dcf44 | refs/heads/master | 2021-10-18T14:54:26.154367 | 2018-10-21T23:34:14 | 2018-10-21T23:34:14 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 840 | java | package <missing>;
public class GlobalMembers
{
public static int Main()
{
int n;
int i;
int middle;
double[] a = new double[301];
double[] d = new double[301];
double dmax = 0;
double sum = 0.0;
double x;
n = Integer.parseInt(ConsoleInput.readToWhiteSpace(true));
for (i = 0;i < n;i++)
{
a[i] = Double.parseDouble(ConsoleInput.readToWhiteSpace(true));
}
for (i = 0;i < n;i++)
{
sum = sum + a[i];
}
x = sum / n;
sort(a,a + n);
for (i = 0;i < n;i++)
{
d[i] = Math.abs(a[i] - x);
if (d[i] > dmax)
{
dmax = d[i];
}
}
for (i = 0;i < n;i++)
{
if (d[i] == dmax)
{
System.out.print(a[i]);
middle = i;
break;
}
}
for (i = middle+1;i < n;i++)
{
if (d[i] == dmax)
{
System.out.print(",");
System.out.print(a[i]);
}
}
return 0;
}
}
| [
"[email protected]"
] | |
ab14633e6760fbf3a1b1b68c76086686ca3972e3 | f886812ecab339023ecf23ff5aa28b7051cc951e | /src/main/java/com/twineworks/tweakflow/lang/interpreter/ops/ClosureReferenceOp.java | f82f288db299d24d9234ce60787e6c72290d3cac | [
"MIT"
] | permissive | twineworks/tweakflow | 995608af17f309bacb0064769499077aca7e1f8d | b6aa5241b9347c14d58bb0ef8f6b75a955ea92b6 | refs/heads/master | 2023-02-21T12:51:35.647910 | 2023-02-17T10:52:09 | 2023-02-17T10:52:09 | 97,735,381 | 31 | 6 | MIT | 2022-01-07T18:52:04 | 2017-07-19T15:55:15 | Java | UTF-8 | Java | false | false | 2,108 | java | /*
* The MIT License (MIT)
*
* Copyright (c) 2019 Twineworks GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.twineworks.tweakflow.lang.interpreter.ops;
import com.twineworks.tweakflow.lang.ast.expressions.ReferenceNode;
import com.twineworks.tweakflow.lang.values.Value;
import com.twineworks.tweakflow.lang.values.ValueProvider;
import com.twineworks.tweakflow.lang.interpreter.EvaluationContext;
import com.twineworks.tweakflow.lang.interpreter.Stack;
final public class ClosureReferenceOp implements ExpressionOp {
private final ReferenceNode node;
public ClosureReferenceOp(ReferenceNode node) {
this.node = node;
}
@Override
public Value eval(Stack stack, EvaluationContext context) {
ValueProvider vp = stack.peek().getClosures().get(node);
return vp.getValue();
}
@Override
public boolean isConstant() {
return false;
}
@Override
public ExpressionOp specialize() {
return new ClosureReferenceOp(node);
}
@Override
public ExpressionOp refresh() {
return new ClosureReferenceOp(node);
}
}
| [
"[email protected]"
] | |
848a70299223019d56ebd363d0ab20970ff4714b | 8614f770d651a9a4402e9e34e3918f15e9bc5486 | /src/view/Main.java | 0634fadab8d230cae468d229931497c811f1be00 | [] | no_license | NguyenViet07/Kiem_tra_module2_jav_01 | 68bae33b40c54c7dfd33f5c2b1b4abcd8ebed5d8 | 779e0f4e56aa8c82816187384a88be77a6456e0d | refs/heads/master | 2020-07-03T04:08:48.906176 | 2019-08-11T15:01:23 | 2019-08-11T15:01:23 | 201,779,040 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,135 | java | package view;
import controller.Controller;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Controller controller = new Controller();
int keyword = 0;
int id,price,stt;
String name,status,description;
do{
System.out.println("============================");
System.out.println("Enter selection:");
System.out.println("1. Show all products");
System.out.println("2. Add new products");
System.out.println("3. Edit products");
System.out.println("4. Delete products");
System.out.println("5. Search products by name");
System.out.println("6. Sort products");
System.out.println("0. Exit");
System.out.println("============================");
keyword = sc.nextInt();
switch (keyword){
case 1:
System.out.println("==> Show products: ");
controller.showProducts();
break;
case 2:
System.out.println("==> Add product: ");
System.out.print("Input ID: ");
id = sc.nextInt();
while(controller.checkID(id)){
System.out.print("ID products is exist. Please input ID again: ");
id = sc.nextInt();
}
System.out.print("Input Name: ");
name = sc.next();
System.out.print("Input Price: ");
price= sc.nextInt();
System.out.print("Input Status: ");
status = sc.next();
System.out.print("Input Description: ");
description = sc.next();
controller.addProduct(id,name,price,status,description);
System.out.println("Add product success");
break;
case 3:
System.out.println("==> Edit product: ");
System.out.print("Input ID: ");
id = sc.nextInt();
if(controller.checkID(id)){
System.out.print("Input Name: ");
name = sc.next();
System.out.print("Input Price: ");
price= sc.nextInt();
System.out.print("Input Status: ");
status = sc.next();
System.out.print("Input Description: ");
description = sc.next();
controller.editProduct(id,name,price,status,description);
System.out.println("Edit product success");
} else {
System.out.println("ID Product is not exist.");
}
break;
case 4:
System.out.println("==> Delete product: ");
System.out.print("Input ID: ");
id = sc.nextInt();
if(controller.deleteProducts(id)){
System.out.println("Delete Product success");
} else {
System.out.println("ID Product is not exist.");
}
break;
case 5:
System.out.println("==> Search product by Name: ");
System.out.print("Input Name: ");
name = sc.next();
if(!controller.searchByName(name)){
System.out.println("no Products");
}
break;
case 6:
System.out.println("==> Sort by: ");
System.out.println("Increase: 1 | Descrease : 2");
stt = sc.nextInt();
controller.showSortProduct(stt);
break;
}
}while(keyword != 0);
}
}
| [
"[email protected]"
] | |
26a67560891a93e2d4301f78d61c88c1b04e8fd9 | c7fa44c7281a7d86d752fcb02a96578d1bb71b16 | /Month/src/month/Month.java | ae36004bb6ae0c242a3f10a0390d9d12c3205fc9 | [] | no_license | asu-cse-source-code/csc-205 | 2476a6421a88da08264c332880f57435da138f02 | 9120580b95cad358e62d241e690b51254b043475 | refs/heads/master | 2023-02-02T00:25:57.597001 | 2020-12-21T03:54:59 | 2020-12-21T03:54:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,005 | 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 month;
/**
*
* @author austinspencer
*/
public class Month
{
private int monthNumber;
String monthName;
public Month()
{
monthNumber = 1; //initializing monthNumber to 1
}
public Month(int m)
{
this.monthNumber = m; //initializing monthNumber to m
}
/**
*
* @param monthName initializing monthNumber according to monthName
*/
public Month(String monthName) //if for each month to its corresponding number
{
this.monthName = monthName;
if (this.monthName.equals("January"))
{
this.monthNumber = 1;
}
else if (this.monthName.equals("February"))
{
this.monthNumber = 2;
}
else if (this.monthName.equals("March"))
{
this.monthNumber = 3;
}
else if (this.monthName.equals("April"))
{
this.monthNumber = 4;
}
else if (this.monthName.equals("May"))
{
this.monthNumber = 5;
}
else if (this.monthName.equals("June"))
{
this.monthNumber = 6;
}
else if (this.monthName.equals("July"))
{
this.monthNumber = 7;
}
else if (this.monthName.equals("August"))
{
this.monthNumber = 8;
}
else if (this.monthName.equals("September"))
{
this.monthNumber = 9;
}
else if (this.monthName.equals("October"))
{
this.monthNumber = 10;
}
else if (this.monthName.equals("November"))
{
this.monthNumber = 11;
}
else if (this.monthName.equals("December"))
{
this.monthNumber = 12;
}
else
{
this.monthNumber = 1;
}
}
public String getMonthName() //gets the monthName from the monthNumber
{
if (this.monthNumber == 1)
{
this.monthName = "January";
}
else if (this.monthNumber == 2)
{
this.monthName = "February";
}
else if (this.monthNumber == 3)
{
this.monthName = "March";
}
else if (this.monthNumber == 4)
{
this.monthName = "April";
}
else if (this.monthNumber == 5)
{
this.monthName = "May";
}
else if (this.monthNumber == 6)
{
this.monthName = "June";
}
else if (this.monthNumber == 7)
{
this.monthName = "July";
}
else if (this.monthNumber == 8)
{
this.monthName = "August";
}
else if (this.monthNumber == 9)
{
this.monthName = "September";
}
else if (this.monthNumber == 10)
{
this.monthName = "October";
}
else if (this.monthNumber == 11)
{
this.monthName = "November";
}
else if (this.monthNumber == 12)
{
this.monthName = "December";
}
else
{
this.monthName = "January"; // Allows for bad month to be January
}
return monthName;
}
public int getMonthNumber()
{
return monthNumber;
}
/**
*
* @param m sets the month numbers from 0 to 12
*/
public void setMonthNumber(int m)
{
if (monthNumber >= 0 && monthNumber <= 12)
{
this.monthNumber = m;
}
else
{
m = 1;
}
}
/**
*
* @param month2 // sees if the calling object month is greater than month2
* @return
*/
public boolean greaterThan(Month month2)
{
if (this.getMonthNumber() > month2.getMonthNumber())
{
return true;
}
else
{
return false;
}
}
/**
*
* @param month2 sees if the calling object month is less than month2
* @return
*/
public boolean lessThan(Month month2)
{
if (this.getMonthNumber() < month2.getMonthNumber())
{
return true;
}
else
{
return false;
}
}
/**
*
* @param month2 sees is the calling object month is equal to month2
* @return
*/
public boolean equals(Month month2)
{
if (this.getMonthNumber() == month2.getMonthNumber())
{
return true;
}
else
{
return false;
}
}
public String toString()
{
return getMonthName();
}
}
| [
"[email protected]"
] | |
d4b4fe75aa3123af129d9aa9667e3fbae4d997e9 | 81e8d7189799312a1694e103e52cd31eb25d3ab8 | /src/main/java/manmaed/petslow/libs/SoundFiles.java | e2a503d491cbb71f63c4f0e5d09fad0fe5ce648c | [] | no_license | Naxanria/PetSlow | a7f5a1da5cc7e0ad9f131e3cd50fc6adf48f4a4f | d51948f779d63018344dc8a350381c0e509722ce | refs/heads/master | 2020-05-02T15:50:38.204786 | 2019-03-17T17:28:02 | 2019-03-17T17:28:02 | 178,053,621 | 0 | 0 | null | 2019-03-27T18:34:54 | 2019-03-27T18:34:54 | null | UTF-8 | Java | false | false | 716 | java | package manmaed.petslow.libs;
import net.minecraft.util.ResourceLocation;
/**
* Created by manmaed on 13/01/2019.
*/
public class SoundFiles {
public static final String SOUNDFILES = "textures/entity/";
public static final ResourceLocation SLOWPOKE = ResourceLocationHelper.getResourceLocation(SOUNDFILES + "slowpoke64.ogg");
private static class ResourceLocationHelper {
public static ResourceLocation getResourceLocation(String modId, String path) {
return new ResourceLocation(modId, path);
}
public static ResourceLocation getResourceLocation(String path) {
return getResourceLocation(Reference.MOD_ID.toLowerCase(), path);
}
}
}
| [
"[email protected]"
] | |
469661aaeee66b3a7fcdd228b388c69aacb7d46b | 314d16b521af200617173842905525ce1404b2da | /src/main/java/com/mycompany/myapp/service/StoreService.java | 6ba7473c8638f0d362d207cb96141f6d98c8d316 | [] | no_license | pdeoliveira/equipmentManagement-start | 39c94dfea5ba3a1976e56ef90c0dcb4a0ef8f139 | a3fa04fcaed69f5090dd879cb4720bef3174c390 | refs/heads/main | 2023-01-24T13:33:07.164090 | 2020-12-05T16:05:06 | 2020-12-05T16:05:06 | 318,887,775 | 0 | 5 | null | null | null | null | UTF-8 | Java | false | false | 1,915 | java | package com.mycompany.myapp.service;
import com.mycompany.myapp.domain.Store;
import com.mycompany.myapp.repository.StoreRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/**
* Service Implementation for managing {@link Store}.
*/
@Service
@Transactional
public class StoreService {
private final Logger log = LoggerFactory.getLogger(StoreService.class);
private final StoreRepository storeRepository;
public StoreService(StoreRepository storeRepository) {
this.storeRepository = storeRepository;
}
/**
* Save a store.
*
* @param store the entity to save.
* @return the persisted entity.
*/
public Store save(Store store) {
log.debug("Request to save Store : {}", store);
return storeRepository.save(store);
}
/**
* Get all the stores.
*
* @param pageable the pagination information.
* @return the list of entities.
*/
@Transactional(readOnly = true)
public Page<Store> findAll(Pageable pageable) {
log.debug("Request to get all Stores");
return storeRepository.findAll(pageable);
}
/**
* Get one store by id.
*
* @param id the id of the entity.
* @return the entity.
*/
@Transactional(readOnly = true)
public Optional<Store> findOne(Long id) {
log.debug("Request to get Store : {}", id);
return storeRepository.findById(id);
}
/**
* Delete the store by id.
*
* @param id the id of the entity.
*/
public void delete(Long id) {
log.debug("Request to delete Store : {}", id);
storeRepository.deleteById(id);
}
}
| [
"[email protected]"
] | |
bc2588e27e447482ceb9a2435cf5b8837e3da43b | 0484c4c753db5c8ba9f5ac58afb3a3dcf691ecfb | /src/main/java/com/he/study/java8/common/NewMan.java | 5eb844a427e19b441b47dedad19002028fbbd1c2 | [] | no_license | he1217/study | 590468f49ad6fb75ff09302f890e1638a07e192e | b3c5de951b4a2d1c633ebde97882de3bd41224db | refs/heads/master | 2023-08-17T12:39:31.860594 | 2021-10-14T03:21:02 | 2021-10-14T03:21:02 | 261,707,186 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 605 | java | package com.he.study.java8.common;
import java.util.Optional;
//注意:Optional 不能被序列化
public class NewMan {
private Optional<Godness> godness = Optional.empty();
private Godness god;
public Optional<Godness> getGod(){
return Optional.of(god);
}
public NewMan() {
}
public NewMan(Optional<Godness> godness) {
this.godness = godness;
}
public Optional<Godness> getGodness() {
return godness;
}
public void setGodness(Optional<Godness> godness) {
this.godness = godness;
}
@Override
public String toString() {
return "NewMan [godness=" + godness + "]";
}
}
| [
"[email protected]"
] | |
0b34b9407ff2e81611ea9abb09321e6bdc020138 | ea22aa4fd5a987264faca1c506c348ab7c040510 | /04bLottery/src/lottery/LottoNums.java | 708be0500e6146b0aace1ef6939ce05eb33e0762 | [] | no_license | Carlmoy/GUI | 1609d1dcc86edc690eb0cdd4c22517a058408af5 | e84061839a3eb346650209e004193b09621b51a7 | refs/heads/master | 2020-07-05T00:51:45.454752 | 2016-11-30T19:56:21 | 2016-11-30T19:56:21 | 74,132,551 | 2 | 0 | null | 2016-11-30T19:49:41 | 2016-11-18T13:36:37 | Java | UTF-8 | Java | false | false | 2,963 | 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 lottery;
/**
*
* @author Carl
*/
public class LottoNums {
private int[] lottoNums = new int[5];//R.K 1D array with 5 indexs for lottoNums
private int[] lottoPlusOneNums = new int[5];//V.V
private int[] lottoPlusTwoNums = new int[5];
//Overloaded Constructor
public LottoNums() {
lottoNums = new int[5];
lottoPlusOneNums = new int[5];
lottoPlusOneNums = new int[5];
}
//R.K Method to generate numbers for lottoNums
public void lottoNums() {
for (int i = 0; i < lottoNums.length; i++) {//R.K Generating 1 to 40 numbers
lottoNums[i] = (int) Math.floor(1 + Math.random() * 40);//R.K Using Math.random
for (int j = 0; j < i; j++) {
//R.K Values with indexes i and j are compared. In case when they are the same, one is rejected
if (lottoNums[i] == lottoNums[j]) {
i--;
}
}
}
}
//V.V Method to generate numbers for lotto Plus One
public void lottoPlusOneNums() {
for (int i = 0; i < lottoPlusOneNums.length; i++) {//R.K Generating 1 to 40 numbers
lottoPlusOneNums[i] = (int) Math.floor(1 + Math.random() * 40);//R.K Using Math.random
for (int j = 0; j < i; j++) {
//R.K Values with indexes i and j are compared. In case when they are the same, one is rejected
if (lottoPlusOneNums[i] == lottoPlusOneNums[j]) {
i--;
}
}
}
}
//V.V Method to generate numbers for lotto Plus Two
public void lottoPlusTwoNums() {
for (int i = 0; i < lottoPlusTwoNums.length; i++) {//R.K Generating 1 to 40 numbers
lottoPlusTwoNums[i] = (int) Math.floor(1 + Math.random() * 40);//R.K Using Math.random
for (int j = 0; j < i; j++) {
//R.K Values with indexes i and j are compared. In case when they are the same, one is rejected
if (lottoPlusTwoNums[i] == lottoPlusTwoNums[j]) {
i--;
}
}
}
}
//V.V Get method to display numbers random numbers to main class, will display numbers from lottoNums
public int[] getLottoNums() {
return lottoNums;
}
//V.V Get method to display numbers random numbers to main class, will display numbers from lottoPlusOneNums
public int[] getLottoPlusOneNums() {
return lottoPlusOneNums;
}
//V.V Get method to display numbers random numbers to main class, will display numbers from lottoPlusTwoNums
public int[] getLottoPlusTwoNums() {
return lottoPlusTwoNums;
}
}
| [
"[email protected]"
] | |
de2f09bdb1361117d508b15aa6e73c7d5c36b60f | 45e172fbf60c13b2c7e20ce0d0cc674421ab53a5 | /packages/apps/PIM/src/com/lewa/PIM/mms/transaction/AbstractRetryScheme.java | 107b1ec40fcb2f6bc98f77d6d2a4b6f63b4f2d03 | [
"Apache-2.0"
] | permissive | manfeel/android_vendor_lewa | 17d9de4963f8a9b00088b15cea9fb8cec035bc08 | 567f54d25d0477a7e872153e66c0fe42789896b7 | refs/heads/master | 2020-07-14T10:53:49.421254 | 2013-05-27T07:22:54 | 2013-05-27T07:22:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,044 | java | /*
* Copyright (C) 2008 Esmertec AG.
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.lewa.PIM.mms.transaction;
public abstract class AbstractRetryScheme {
public static final int OUTGOING = 1;
public static final int INCOMING = 2;
protected int mRetriedTimes;
public AbstractRetryScheme(int retriedTimes) {
mRetriedTimes = retriedTimes;
}
abstract public int getRetryLimit();
abstract public long getWaitingInterval();
}
| [
"[email protected]"
] | |
9f133b1f72c3e74998c755bfcc1b27717030fbe0 | 15683d5aea4b4ecf6dd476813614aaa09db3ea80 | /src/com/jemmic/addressbook/exception/PersonNotFoundException.java | fb643956fce43bee8efdf1ba2d83827dcd97ce00 | [] | no_license | reza-javaEE/Addressbook-command-line | 5d972bf1ccae413bed2a09cc3b0b0a2a6761317e | 5eb88144cd38001ff105f4f047623173c09137c9 | refs/heads/master | 2023-04-16T14:02:57.339700 | 2021-04-22T09:26:20 | 2021-04-22T09:26:20 | 353,364,728 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 233 | java | package com.jemmic.addressbook.exception;
/**
* Alert that the person was not found.
*/
public class PersonNotFoundException extends Exception {
public PersonNotFoundException(String message) {
super(message);
}
} | [
"[email protected]"
] | |
7e3a5f811e997049e273786f1c38649ab2514171 | 7938f326cd023007ffeab60bb977a99edd30e86c | /src/test/java/fr/paris/lutece/util/beanvalidation/Bean.java | 9ef2e8296f01cbdda94a30df143db4449ace7d5f | [
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause"
] | permissive | eahuma/lutece-core | 0a83cbd24a0dcf37e80c4e8f1d6ad32acf2d060b | 469c86d0263e9f68d94397b79adcd3c2c2092267 | refs/heads/master | 2022-12-22T04:52:32.298071 | 2020-07-01T16:38:01 | 2020-07-01T16:38:01 | 278,385,330 | 0 | 0 | BSD-3-Clause | 2020-07-09T14:21:13 | 2020-07-09T14:21:12 | null | UTF-8 | Java | false | false | 4,095 | java | /*
* Copyright (c) 2002-2020, City of Paris
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright notice
* and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice
* and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* License 1.0
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fr.paris.lutece.util.beanvalidation;
import java.math.BigDecimal;
import java.sql.Date;
/**
*
* @author pierre
*/
public interface Bean
{
/**
* Returns the Age
*
* @return The Age
*/
int getAge( );
/**
* @return the _strCurrency
*/
String getCurrency( );
/**
* @return the _dateBirth
*/
Date getDateBirth( );
/**
* @return the _dateEndOfWorld
*/
Date getDateEndOfWorld( );
/**
* Returns the Description
*
* @return The Description
*/
String getDescription( );
/**
* Returns the Email
*
* @return The Email
*/
String getEmail( );
/**
* Returns the IdObject
*
* @return The IdObject
*/
int getIdObject( );
/**
* Returns the Name
*
* @return The Name
*/
String getName( );
/**
* @return the _percent
*/
BigDecimal getPercent( );
/**
* @return the _salary
*/
BigDecimal getSalary( );
/**
* Sets the Age
*
* @param nAge
* The Age
*/
void setAge( int nAge );
/**
* @param strCurrency
* the _strCurrency to set
*/
void setCurrency( String strCurrency );
/**
* @param dateBirth
* the _dateBirth to set
*/
void setDateBirth( Date dateBirth );
/**
* @param dateEndOfWorld
* the _dateEndOfWorld to set
*/
void setDateEndOfWorld( Date dateEndOfWorld );
/**
* Sets the Description
*
* @param strDescription
* The Description
*/
void setDescription( String strDescription );
/**
* Sets the Email
*
* @param strEmail
* The Email
*/
void setEmail( String strEmail );
/**
* Sets the IdObject
*
* @param nIdObject
* The IdObject
*/
void setIdObject( int nIdObject );
/**
* Sets the Name
*
* @param strName
* The Name
*/
void setName( String strName );
/**
* @param percent
* the _percent to set
*/
void setPercent( BigDecimal percent );
/**
* @param salary
* the _salary to set
*/
void setSalary( BigDecimal salary );
void setUrl( String strUrl );
String getUrl( );
}
| [
"[email protected]"
] | |
1c92a9c75fcbf4193ce90015f94d7f42da364090 | c5722543df574b7cc7b6d734117ec64f55c8b3ff | /StaticUse.java | 305cb5b0b053ba5c0afb523b8d99bd546b11f035 | [] | no_license | ashishaurea54/codefix | 8e60932242f801a5fdc51ea5f25bfa58a89cc521 | 4a574e074a264fda00b417a827e5fe64514823a4 | refs/heads/master | 2020-06-01T18:36:42.981491 | 2019-06-08T12:34:50 | 2019-06-08T12:34:50 | 190,885,830 | 0 | 1 | null | 2019-06-08T14:06:10 | 2019-06-08T12:34:07 | Java | UTF-8 | Java | false | false | 922 | java |
public class StaticUse {
public static void main(String[] args) {
meth(10);
StaticDemo.callme(); // static method called using classname
// Static variables called using classname
int aa = StaticDemo.a;
int bb = StaticDemo.b;
System.out.println("sum = " + (aa+bb));
}
// Static Variable
static int a = 3;
static int b;
int c =10;
// Static Method
static void meth(int x) {
System.out.println("x = " + x);
System.out.println("a = " + a);
System.out.println("b = " + b);
//Non Static Variable can not be used
//System.out.println("c = " + c);
}
// Static Block
static {
System.out.println("Static block initialized.");
b = a * 4;
// non static variable can not be used directly
// c++;
}
}
class StaticDemo {
static int a = 42;
static int b = 99;
static void callme() {
System.out.println("a = " + a);
}
}
| [
"[email protected]"
] | |
bbcccc723418bf4d7edb2c8ff7ce8b5ba19c6142 | 6e6db7db5aa823c77d9858d2182d901684faaa24 | /sample/webservice/HelloeBayTrading/src/com/ebay/trading/api/LocalListingDistancesNonSubscriptionDefinitionType.java | 7e386b75a0bea63b8e7ce4b5be153752843522a8 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | 4everalone/nano | 68a480d07d80f0f50d73ec593443bfb362d646aa | 71779b1ad546663ee90a29f1c2d4236a6948a621 | refs/heads/master | 2020-12-25T14:08:08.303942 | 2013-07-25T13:28:41 | 2013-07-25T13:28:41 | 10,792,684 | 0 | 1 | Apache-2.0 | 2019-04-24T20:12:27 | 2013-06-19T13:14:26 | Java | UTF-8 | Java | false | false | 673 | java | // Generated by xsd compiler for android/java
// DO NOT CHANGE!
package com.ebay.trading.api;
import java.io.Serializable;
import com.leansoft.nano.annotation.*;
import java.util.List;
/**
*
* Defines the LocalListingDistancesNonSubscription feature. This feature displays all the supported local
* listing distances for items listed by sellers who have not subscribed to either Local Market for Vehicles
* or Local Market for Specialty Vehicles.
*
*/
public class LocalListingDistancesNonSubscriptionDefinitionType implements Serializable {
private static final long serialVersionUID = -1L;
@AnyElement
@Order(value=0)
public List<Object> any;
} | [
"[email protected]"
] | |
88ee4c9c62f34dbfa30c8d49a6e703ed36f1ada0 | 70c90ded406435cedbf4aa48949c4f7d5f947308 | /Project2-Ships_And_Ports/src/interfaces/IPort.java | ace3e1e2983525ae1cdf97490eb5f6a003e2950d | [] | no_license | edonmez01/CMPE160 | 1c5629c56ead69e28025d8747d75478669346640 | bbdaf38d127873034688885f37da7db3b7196242 | refs/heads/main | 2023-06-18T04:13:53.020975 | 2021-07-01T08:32:35 | 2021-07-01T08:32:35 | 367,043,069 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 368 | java | package interfaces;
import ships.Ship;
public interface IPort {
/*
* Do not modify the code in this file!
* You are responsible for all the compilation errors that originated from the changes
* made in any of these files including the addition or removal of libraries.
*
*/
void incomingShip(Ship s);
void outgoingShip(Ship s);
}
| [
"[email protected]"
] | |
e76bffd20b407dd8696d3725b7dc5dc883069249 | a63d907ad63ba6705420a6fb2788196d1bd3763c | /src/dataflow/codecheck/src/test/java/com/tencent/bk/base/dataflow/codecheck/util/db/DBConnectionUtilTest.java | f9530df69c4b2fdbefc61d583802d0ef7aa2a034 | [
"MIT"
] | permissive | Tencent/bk-base | a38461072811667dc2880a13a5232004fe771a4b | 6d483b4df67739b26cc8ecaa56c1d76ab46bd7a2 | refs/heads/master | 2022-07-30T04:24:53.370661 | 2022-04-02T10:30:55 | 2022-04-02T10:30:55 | 381,257,882 | 101 | 51 | NOASSERTION | 2022-04-02T10:30:56 | 2021-06-29T06:10:01 | Python | UTF-8 | Java | false | false | 6,106 | java | /*
* Tencent is pleased to support the open source community by making BK-BASE 蓝鲸基础平台 available.
*
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
*
* BK-BASE 蓝鲸基础平台 is licensed under the MIT License.
*
* License for BK-BASE 蓝鲸基础平台:
* --------------------------------------------------------------------
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.tencent.bk.base.dataflow.codecheck.util.db;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import com.tencent.bk.base.dataflow.codecheck.util.Configuration;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import java.sql.Connection;
import java.util.Properties;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
@RunWith(PowerMockRunner.class)
@PrepareForTest({DBConnectionUtil.class, Configuration.class, HikariConfig.class, HikariDataSource.class})
public class DBConnectionUtilTest {
private AutoCloseable closeable;
@Before
public void openMocks() {
closeable = MockitoAnnotations.openMocks(this);
}
@After
public void releaseMocks() throws Exception {
closeable.close();
}
@Test
public void testGetSingleton() throws Exception {
DBConnectionUtil singleton = PowerMockito.mock(DBConnectionUtil.class);
Configuration configuration = PowerMockito.mock(Configuration.class);
PowerMockito.mockStatic(Configuration.class);
PowerMockito.when(Configuration.getSingleton()).thenReturn(configuration);
Properties properties = new Properties();
PowerMockito.when(configuration.getDBConfig()).thenReturn(properties);
HikariConfig hikariConfig = PowerMockito.mock(HikariConfig.class);
HikariDataSource hikariDataSource = PowerMockito.mock(HikariDataSource.class);
PowerMockito.whenNew(HikariConfig.class).withAnyArguments().thenReturn(hikariConfig);
PowerMockito.whenNew(HikariDataSource.class).withArguments(hikariConfig).thenReturn(hikariDataSource);
Whitebox.setInternalState(DBConnectionUtil.class, "dbConfig", hikariConfig);
Whitebox.setInternalState(DBConnectionUtil.class, "ds", hikariDataSource);
PowerMockito.whenNew(DBConnectionUtil.class).withAnyArguments().thenReturn(singleton);
PowerMockito.mockStatic(DBConnectionUtil.class);
PowerMockito.doCallRealMethod().when(DBConnectionUtil.class, "getSingleton");
Assert.assertEquals(DBConnectionUtil.getSingleton(), singleton);
}
@Test
public void testGetConnection() throws Exception {
DBConnectionUtil dbConnectionUtil = PowerMockito.mock(DBConnectionUtil.class);
PowerMockito.mockStatic(DBConnectionUtil.class);
PowerMockito.when(DBConnectionUtil.getSingleton()).thenReturn(dbConnectionUtil);
Connection conn = PowerMockito.mock(Connection.class);
HikariDataSource ds = PowerMockito.mock(HikariDataSource.class);
PowerMockito.when(ds, "getConnection").thenReturn(conn);
Whitebox.setInternalState(DBConnectionUtil.class, "ds", ds);
PowerMockito.doCallRealMethod().when(dbConnectionUtil).getConnection();
Connection result = DBConnectionUtil.getSingleton().getConnection();
Assert.assertEquals(conn, result);
}
@Test
public void testGetConnection2() throws Exception {
DBConnectionUtil dbConnectionUtil = PowerMockito.mock(DBConnectionUtil.class);
PowerMockito.mockStatic(DBConnectionUtil.class);
PowerMockito.when(DBConnectionUtil.getSingleton()).thenReturn(dbConnectionUtil);
HikariDataSource ds = PowerMockito.mock(HikariDataSource.class);
PowerMockito.when(ds, "getConnection").thenThrow(
new RuntimeException(), new RuntimeException(),
new RuntimeException(), new RuntimeException());
Whitebox.setInternalState(DBConnectionUtil.class, "ds", ds);
PowerMockito.doCallRealMethod().when(dbConnectionUtil).getConnection();
Connection result2 = DBConnectionUtil.getSingleton().getConnection();
Assert.assertNull(result2);
}
@Test
public void testShutdown() throws Exception {
DBConnectionUtil dBConnectionUtil = PowerMockito.mock(DBConnectionUtil.class);
PowerMockito.mockStatic(DBConnectionUtil.class);
HikariDataSource ds = PowerMockito.mock(HikariDataSource.class);
PowerMockito.doNothing().when(ds, "close");
Whitebox.setInternalState(DBConnectionUtil.class, "ds", ds);
PowerMockito.doCallRealMethod().when(dBConnectionUtil, "shutdown");
dBConnectionUtil.shutdown();
verify(dBConnectionUtil, times(3)).shutdown();
}
}
| [
"[email protected]"
] | |
1a84866da8ae2e313ba6dd4e6050926feae694b9 | af4290ed57180aae81fb128780f4d99e27d99adf | /boot-home/src/test/java/com/shenofusc/module/manager/service/ManagerServiceTest.java | f6a0cf9f62f056a0ae3c5149d71ea9321436f020 | [] | no_license | smacheng/saas-base-platform | 9e4273f76e0778e40151c172675427c4effd2163 | 2dedac1006553443b8f262c82da4261a9d22acf4 | refs/heads/master | 2021-04-26T22:43:41.287782 | 2017-08-16T07:12:05 | 2017-08-16T07:12:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 741 | java | package com.shenofusc.module.manager.service;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.shenofusc.core.entity.Manager;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:conf/applicationContext.xml")
public class ManagerServiceTest {
@Resource
private ManagerService managerService;
/*@Resource
private ManagerMapper managerMapper;*/
@Test
public void testFindByUserName() {
String userName = "admin";
Manager manager = managerService.findByUserName(userName);
// assertNotNull(manager);
}
}
| [
"[email protected]"
] | |
4e06d743d2215c786cf4785b84c0c33bb5e3f19c | de5f344e514e447a32c3b71d6356144b84aa17c9 | /app/src/main/java/com/hfad/beeradviser/BeerExpert.java | e4ec97acc02eeb91e9a8ae9a6bc70e0394062f09 | [] | no_license | SER210-SP21/headfirst-ch2-ijcrawford | f210238faceee229b252d668e078724038579460 | 600a4bc0b96352268fcebe2cc4d824949d50bb6e | refs/heads/master | 2023-03-02T17:35:32.419604 | 2021-02-09T20:11:53 | 2021-02-09T20:11:53 | 335,474,670 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 456 | java | package com.hfad.beeradviser;
import java.util.ArrayList;
import java.util.List;
public class BeerExpert {
public List<String> getBrands(String color) {
List<String> brands = new ArrayList<>();
if(color.equals("amber")) {
brands.add("Jack Amber");
brands.add("Red Moose");
} else {
brands.add("Jail Pale Ale");
brands.add("Gout Stout");
}
return brands;
}
}
| [
"[email protected]"
] | |
b345d678ceac0c10fa08c14134262d266c8cdd60 | 75cd764739a399af6ea3bda47c9305a962fe8a57 | /jar-project/OceanusLiveTvMiddleware/tvmiddlewareinterface/src/main/java/Oceanus/Tv/Service/PictureManager/PictureManagerDefinitions/EN_PICTURE_MODE.java | 4976fe27b5ddc7d1dcf1b1756c3c7cd717c03ed3 | [] | no_license | changxiangzhong/oceanus | a6a2a8d7a84c1070cc2f00e6eb277aadf7511dbd | 92ec2d6e5a94159dae1ce7f1183dcc93dd85c7df | refs/heads/master | 2023-08-31T12:27:22.813420 | 2017-08-04T06:57:17 | 2017-08-04T06:57:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 671 | java | package Oceanus.Tv.Service.PictureManager.PictureManagerDefinitions;
/**
* Created by sky057509 on 2016/8/19.
*/
public enum EN_PICTURE_MODE {
// ** Standrad mode
E_PICTURE_MODE_STANDARD,
// ** Vivid mode
E_PICTURE_MODE_VIVID,
// ** Soft mode
E_PICTURE_MODE_SOFT,
// ** User mode
E_PICTURE_MODE_USER,
// ** Game mode
E_PICTURE_MODE_GAME,
// ** Auto mode
E_PICTURE_MODE_AUTO,
// ** Natural mode
E_PICTURE_MODE_NATURAL,
// ** Sports mode
E_PICTURE_MODE_SPORTS,
// ** PC mode
E_PICTURE_MODE_PC,
// ** Dymanic mode
E_PICTURE_MODE_DYMANIC,
// ** Invalid mode
E_PICTURE_MODE_INVALID;
}
| [
"[email protected]"
] | |
8c50d119cbd5bc61315f69a63572ec790a9294f7 | 28c26a46a8c24b0dcc2b76b776d37af218dab3b5 | /acmicpc/java/_2845/Main.java | d603493ad100ab73322b6669610c2f8c8008d6ed | [] | no_license | kingesay/algorithm_hub | 062898fc61a27f5f28ebe45716b1eb4489eb9061 | 09ec614e96d9b2c4deab1c8ca18e406536c4e5ea | refs/heads/master | 2022-11-23T20:14:13.179329 | 2020-07-26T23:37:37 | 2020-07-26T23:37:37 | 265,223,532 | 1 | 0 | null | 2020-05-19T11:04:40 | 2020-05-19T11:04:39 | null | UTF-8 | Java | false | false | 886 | java | package _2845;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s1 = br.readLine();
String[] strings1 = s1.split(" ");
int l = Integer.parseInt(strings1[0]);
int p = Integer.parseInt(strings1[1]);
int sol = l*p;
String s2 = br.readLine();
String[] strings2 = s2.split(" ");
int size = 5;
int[] target = new int[5];
for (int i = 0; i < size; i++) {
target[i] = Integer.parseInt(strings2[i]);
int gap = 0;
gap = target[i] - sol;
bw.write(gap+" ");
}
bw.write("\n");
bw.flush();
bw.close();
}
}
| [
"[email protected]"
] | |
dcabc7714870a092765f65a8453581d49a28e364 | e52d9e1f01e93d1a00a653ea21e94095d1c37a8e | /app/src/main/java/com/augmentis/ayp/dnd/DragAndDrawActivity.java | 33854214834352af034fed57bc0223cbf3c55bec | [] | no_license | rawinng/Drag-and-draw | 12a82b3441982e6e3af0601e46cf26813c0fd19f | ba5ac15caac6d1b44e9a926dca21847d90cf72d1 | refs/heads/master | 2021-06-05T01:08:26.476660 | 2016-08-30T08:41:52 | 2016-08-30T08:41:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 288 | java | package com.augmentis.ayp.dnd;
import android.support.v4.app.Fragment;
/**
* Created by Rawin on 30-Aug-16.
*/
public class DragAndDrawActivity extends SingleFragmentActivity {
@Override
Fragment onCreateFragment() {
return DragAndDrawFragment.newInstance();
}
}
| [
"[email protected]"
] | |
cebab17a25cfd6cca680b58c259d7d546456e5b5 | 1aaeae6ca0cceabeb8f2aa71fc5fb409f838e227 | /xjcloud-common/xjcloud-common-core/src/main/java/gov/pbc/xjcloud/common/core/config/MessageSourceConfig.java | 70b84dcc3ba42a73bd01d73d8538f0f2ad718307 | [] | no_license | lizxGitHub/xjcloud-master | e03d7079bd0d262ba8b6f964b2f560589421e1a8 | d73c5553c94e6ac133bd1e0b80277ffa34f80dc3 | refs/heads/master | 2023-06-21T20:40:54.854381 | 2021-05-31T14:18:40 | 2021-05-31T14:18:40 | 231,402,466 | 0 | 1 | null | 2023-06-20T18:32:04 | 2020-01-02T14:52:34 | Java | UTF-8 | Java | false | false | 575 | java | package gov.pbc.xjcloud.common.core.config;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
@Configuration
public class MessageSourceConfig {
@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename("classpath:i18n/messages");
return messageSource;
}
}
| [
"[email protected]"
] | |
70bc721898e1bf0a3d866f7112e8723a791e03c4 | 536ad227b030891a250271945133d5deb36bad0c | /dubbo-demo-parent/dubbo-demo-consumer/src/main/java/com/wjq/ConsumerStart.java | 6282001cce8ab2ae09e794dd4ff90522a82bc217 | [] | no_license | wenjiaquan/dubbo-zuoye-arithmetic | ed61eaefc0efb5f9e62773207b5ac24fb9653ca1 | 575edbf386c2cfdf8fbd833b2e0b648f7c4704fc | refs/heads/master | 2022-01-15T04:03:44.153888 | 2020-02-23T09:07:04 | 2020-02-23T09:07:04 | 242,486,324 | 0 | 0 | null | 2022-01-12T23:05:02 | 2020-02-23T09:03:51 | Java | UTF-8 | Java | false | false | 838 | java | package com.wjq;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.wjq.entity.Student;
import com.wjq.service.StudentService;
public class ConsumerStart {
private static StudentService studentService;
private static ClassPathXmlApplicationContext context;
public static void main(String[] args) {
context = new ClassPathXmlApplicationContext("classpath:ApplicantionContext.xml");
studentService=context.getBean(StudentService.class);
Student stu = studentService.getByid(20);
System.out.println("student is" + stu);
Student setAge = studentService.setAge(stu, 5);
System.out.println("加岁数以后的数据 " + setAge);
System.out.println("两数相加的结果:"+studentService.jia(2,3));
System.out.println("两数相减的结果:"+studentService.jian(6,3));
}
}
| [
"[email protected]"
] | |
334a03d9eda0086682ea2329f8526a174cd8f150 | 630bb44600d426673c5f2a20768890be330f085e | /9th-july/candy.java | 55eb1f946f2fc6a0de39b6507dbb94376447f46a | [] | no_license | nabigeaala/internship | efea67ebc3cc838a627ae89ad1d40db3380bf64d | 4b9705ed22df765574fb8a17f964ff9f8a9ae996 | refs/heads/main | 2023-06-15T22:32:49.993826 | 2021-07-10T11:06:48 | 2021-07-10T11:06:48 | 383,406,493 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,212 | java | /*
There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings.
You are giving candies to these children subjected to the following requirements:
Each child must have at least one candy.
Children with a higher rating get more candies than their neighbors.
Return the minimum number of candies you need to have to distribute the candies to the children.
*/
class Candy {
public int candy(int[] ratings) {
int temp[] = new int[ratings.length];
//intialize with zero
for(int i=0; i<temp.length; i++){
temp[i] = 1;
}
//traverse from left to right
for(int i=1; i<ratings.length; i++){
if(ratings[i] > ratings[i-1] ){
temp[i]= temp[i-1]+1;
}
}
//traverse from right to left
for(int i=ratings.length-2; i>=0; i--){
if(ratings[i] > ratings[i+1]){
temp[i] = Math.max(temp[i], temp[i+1] +1);
}
}
int ans=0;
for(int val : temp){
System.out.print(val + " ");
ans+= val;
}
return ans;
}
}
| [
"[email protected]"
] | |
1939236d340860833f0ec8f80fa33c6e742cb52d | dcca538a05b5084d3491cc9e7b477a7b32aecde1 | /app/src/main/java/com/beamotivator/beam/SavedPost.java | 238e96e39f1892eff72c737e0a0a3164e4cfd130 | [] | no_license | rakulav/My-Android-App | 3b0cb042cba802701f1de796cf035d9c71945398 | 60f5dc1d135624a9436d4b76ffa39fb3dcade56a | refs/heads/master | 2022-12-13T07:40:15.068440 | 2020-09-06T06:41:17 | 2020-09-06T06:41:17 | 292,741,912 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,921 | java | package com.beamotivator.beam;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
import androidx.appcompat.widget.Toolbar;
import com.beamotivator.beam.adapters.AdapterPosts;
import com.beamotivator.beam.models.ModelPost;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.List;
public class SavedPost extends AppCompatActivity {
RecyclerView savedPostsRv;
List<ModelPost> postList;
AdapterPosts adapterPosts;
FirebaseAuth firebaseAuth;
String myId ;
String ig = "";
int count = 0;
//Toolbar savedPosts;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = this.getWindow();
Drawable background = this.getResources().getDrawable(R.drawable.main_gradient);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(this.getResources().getColor(android.R.color.transparent));
// window.setNavigationBarColor(this.getResources().getColor(android.R.color.transparent));
window.setBackgroundDrawable(background);
}
setContentView(R.layout.activity_saved_post);
//set firebase
firebaseAuth = FirebaseAuth.getInstance();
myId = firebaseAuth.getCurrentUser().getUid();
Toolbar savedTlbr = (Toolbar) findViewById(R.id.savedPostTlbr);
setSupportActionBar(savedTlbr);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
savedPostsRv = findViewById(R.id.savedRecyclerView);
postList = new ArrayList<>();
loadSavedPosts();
}
private void loadSavedPosts() {
//linear layout for recyclerview
LinearLayoutManager layoutManager = new LinearLayoutManager(SavedPost.this);
//show newest posts, load from last
layoutManager.setStackFromEnd(true);
layoutManager.setReverseLayout(true);
//set this layout to recycler view
savedPostsRv.setLayoutManager(layoutManager);
myId = firebaseAuth.getCurrentUser().getUid();
DatabaseReference ref = FirebaseDatabase.getInstance().getReference("Extras").child(myId).child("Saved");
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
postList.clear();
for(DataSnapshot ds:snapshot.getChildren()){
String postId = ""+ds.getKey();
//now check for the post details
DatabaseReference ref1 = FirebaseDatabase.getInstance().getReference("Posts");
ref1.orderByChild("pId")
.equalTo(postId)
.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot datasnapshot) {
for(DataSnapshot ds1:datasnapshot.getChildren()){
ModelPost modelPost = ds1.getValue(ModelPost.class);
//add post
postList.add(modelPost);
//adapter
adapterPosts = new AdapterPosts(SavedPost.this,postList);
//set adapter to recycler view
savedPostsRv.setAdapter(adapterPosts);
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
@Override
public boolean onSupportNavigateUp() {
onBackPressed();
return super.onSupportNavigateUp();
}
} | [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.