blob_id
stringlengths 40
40
| language
stringclasses 1
value | repo_name
stringlengths 5
132
| path
stringlengths 2
382
| src_encoding
stringclasses 34
values | length_bytes
int64 9
3.8M
| score
float64 1.5
4.94
| int_score
int64 2
5
| detected_licenses
listlengths 0
142
| license_type
stringclasses 2
values | text
stringlengths 9
3.8M
| download_success
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
5264bed0c0bd9a215a000fb4074949ec6d2e4ef8
|
Java
|
kbmaz/Java-Programming-Foundations
|
/Java3_Homework12/src/ui/panels/MainPanel.java
|
UTF-8
| 593
| 2.625
| 3
|
[] |
no_license
|
package ui.panels;
import interfaces.Resettable;
import java.awt.GridLayout;
import java.awt.Panel;
import model.Model;
public class MainPanel extends Panel implements Resettable {
ActionPanel actionPanel;
ControlsPanel controlsPanel;
public MainPanel(Model model) {
actionPanel = new ActionPanel(model);
controlsPanel = new ControlsPanel(model);
setLayout(new GridLayout(2,1));
add(controlsPanel);
add(actionPanel);
}
public void resetComponents() {
controlsPanel.resetComponents();
actionPanel.resetComponents();
}
}
| true
|
6bff26c696eac561cf113735abc3400389d36e92
|
Java
|
Phantoms007/zhihuAPK
|
/src/main/java/com/zhihu/android/topic/platfrom/p1964d/$$Lambda$a$z7FmWKdD_FRtkUNkaYFUUqSyCJc.java
|
UTF-8
| 724
| 1.71875
| 2
|
[] |
no_license
|
package com.zhihu.android.topic.platfrom.p1964d;
import java8.util.p2234b.AbstractC32237i;
/* renamed from: com.zhihu.android.topic.platfrom.d.-$$Lambda$a$z7FmWKdD_FRtkUNkaYFUUqSyCJc reason: invalid class name */
/* compiled from: lambda */
public final /* synthetic */ class $$Lambda$a$z7FmWKdD_FRtkUNkaYFUUqSyCJc implements AbstractC32237i {
public static final /* synthetic */ $$Lambda$a$z7FmWKdD_FRtkUNkaYFUUqSyCJc INSTANCE = new $$Lambda$a$z7FmWKdD_FRtkUNkaYFUUqSyCJc();
private /* synthetic */ $$Lambda$a$z7FmWKdD_FRtkUNkaYFUUqSyCJc() {
}
@Override // java8.util.p2234b.AbstractC32237i
public final Object apply(Object obj) {
return BaseHeadThemeHelper.m126019b((String) obj);
}
}
| true
|
26ad46d236ca328d09789852166cbae7ce1577c7
|
Java
|
hbliyafei/nianfojishu
|
/HHTask/.svn/pristine/19/19f28db561bfc47ca49535d7f4c14a7553a027e1.svn-base
|
UTF-8
| 941
| 2.015625
| 2
|
[] |
no_license
|
package com.task.entity.approval;
import java.io.Serializable;
/***
* 序列表
* ta_sequences
* @author 毛小龙
*
*/
public class Sequences implements Serializable{
private Integer id;
private String code;//工号
private String module_name;//模块名称
private String se_number;//序列编号
private String se_date;//添加序列时间
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getModule_name() {
return module_name;
}
public void setModule_name(String moduleName) {
module_name = moduleName;
}
public String getSe_number() {
return se_number;
}
public void setSe_number(String seNumber) {
se_number = seNumber;
}
public String getSe_date() {
return se_date;
}
public void setSe_date(String seDate) {
se_date = seDate;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
| true
|
6f206ac040c31b7804dcd082b0c0084aad04b2f6
|
Java
|
domikul/Squash-courts
|
/src/main/java/pl/euvic/squash/security/UserDetailsServiceImpl.java
|
UTF-8
| 1,194
| 2.296875
| 2
|
[] |
no_license
|
package pl.euvic.squash.security;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;
import pl.euvic.squash.exception.WrongRequestException;
import pl.euvic.squash.model.entity.User;
import pl.euvic.squash.model.repository.UserRepository;
import static java.util.Collections.emptyList;
@Component
public class UserDetailsServiceImpl implements UserDetailsService {
private final UserRepository userRepository;
public UserDetailsServiceImpl(UserRepository userRepository) {
this.userRepository = userRepository;
}
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
try {
User user = userRepository.findByEmail(username).get();
return new org.springframework.security.core.userdetails.User(user.getEmail(), user.getPassword(), emptyList());
} catch (WrongRequestException e) {
throw new WrongRequestException("Wrong email");
}
}
}
| true
|
e53b244fa5d2743b0b1f9c02d3d294a408a1d297
|
Java
|
Mart95777/Thinkinginjavaextended
|
/src/access/mypackage/MyClass.java
|
UTF-8
| 157
| 2.3125
| 2
|
[] |
no_license
|
//: access/mypackage/MyClass.java
package access.mypackage;
public class MyClass {
public MyClass(){
System.out.println("Inside MyClass");
}
} ///:~
| true
|
09cf80a6cef925ca0f3a8797c588508b8e379ab7
|
Java
|
finalaurora/multisvc-sys
|
/jetty-mw/src/main/java/jettymw/server/SampleHandler.java
|
UTF-8
| 1,177
| 2.71875
| 3
|
[] |
no_license
|
package jettymw.server;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.HandlerWrapper;
public class SampleHandler extends HandlerWrapper {
final String greeting;
final String body;
public SampleHandler() {
this("Hello World");
}
public SampleHandler(String greeting) {
this(greeting, null);
}
public SampleHandler(String greeting, String body) {
this.greeting = greeting;
this.body = body;
}
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/html; charset=utf-8");
response.setStatus(HttpServletResponse.SC_OK);
PrintWriter out = response.getWriter();
out.println("<h1>" + greeting + "</h1>");
if (body != null) {
out.println(body);
}
baseRequest.setHandled(true);
}
}
| true
|
60c83c80d33f018c6c6f115e0f02a505655cb02c
|
Java
|
sgholamian/log-aware-clone-detection
|
/LACCPlus/Hadoop/2383_1.java
|
UTF-8
| 1,155
| 2.140625
| 2
|
[
"MIT"
] |
permissive
|
//,temp,TestFsDatasetImpl.java,805,833,temp,TestFsDatasetImpl.java,762,803
//,3
public class xxx {
@Test(timeout = 30000)
public void testMoveBlockSuccess() {
MiniDFSCluster cluster = null;
try {
cluster = new MiniDFSCluster.Builder(conf)
.numDataNodes(1)
.storageTypes(new StorageType[]{StorageType.DISK, StorageType.DISK})
.storagesPerDatanode(2)
.build();
FileSystem fs = cluster.getFileSystem();
DataNode dataNode = cluster.getDataNodes().get(0);
Path filePath = new Path("testData");
DFSTestUtil.createFile(fs, filePath, 100, (short) 1, 0);
ExtendedBlock block = DFSTestUtil.getFirstBlock(fs, filePath);
FsDatasetImpl fsDataSetImpl = (FsDatasetImpl) dataNode.getFSDataset();
ReplicaInfo newReplicaInfo = createNewReplicaObj(block, fsDataSetImpl);
fsDataSetImpl.finalizeNewReplica(newReplicaInfo, block);
} catch (Exception ex) {
LOG.info("Exception in testMoveBlockSuccess ", ex);
fail("MoveBlock operation should succeed");
} finally {
if (cluster.isClusterUp()) {
cluster.shutdown();
}
}
}
};
| true
|
e134e5982ca4069dc5a2244c2e4804a58de0b2c8
|
Java
|
joooogle/miceProfiler
|
/plugins/fab/MiceProfiler/EventTimeLine.java
|
UTF-8
| 5,505
| 2.59375
| 3
|
[] |
no_license
|
/*
* Copyright 2011, 2012 Institut Pasteur.
*
* This file is part of MiceProfiler.
*
* MiceProfiler is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MiceProfiler is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MiceProfiler. If not, see <http://www.gnu.org/licenses/>.
*/
package plugins.fab.MiceProfiler;
import java.util.ArrayList;
import java.util.HashMap;
public class EventTimeLine
{
public String criteriaName;
public EventType eventType;
public TimeLineCategory timeLineCategory;
ArrayList<EventCriteria> eventList = new ArrayList<EventCriteria>();
HashMap<Integer, Double> hashValue = new HashMap<Integer, Double>();
public EventTimeLine(String criteriaName, EventType eventType, TimeLineCategory timeLineCategory)
{
this.timeLineCategory = timeLineCategory;
this.criteriaName = criteriaName;
this.eventType = eventType;
}
public void addValue(int frame, double value)
{
hashValue.put(frame, value);
}
public void removeValue(int frame)
{
hashValue.remove(frame);
}
public double getValueAt(int frame)
{
final Double value = hashValue.get(frame);
if (value == null)
return 0;
return value;
}
public void addEvent(EventCriteria eventCriteria)
{
eventList.add(eventCriteria);
}
public void removeEvent(EventCriteria eventCriteria)
{
eventList.remove(eventCriteria);
}
// look if a previous event exist with t-1.
// if yes extends previous event.
// if not create new event.
public void addPunctualEvent(int t)
{
for (final EventCriteria event : eventList)
{
if (event.endFrame == t - 1)
{
event.endFrame = t;
return;
}
}
for (final EventCriteria event : eventList)
{
if (event.startFrame == t + 1)
{
event.startFrame = t;
return;
}
}
// nothing found
// creates a new event
final EventCriteria event = new EventCriteria(eventType, t, t);
addEvent(event);
}
public void removeEventLessThanLength(int length)
{
for (final EventCriteria eventCriteria : (ArrayList<EventCriteria>) eventList.clone())
{
if (eventCriteria.getLength() < length)
{
eventList.remove(eventCriteria);
}
}
}
public double getMeanValue(int tStart, int tEnd)
{
int nbValue = 0;
double total = 0;
for (int t = tStart; t <= tEnd; t++)
{
total += getValueAt(t);
nbValue++;
}
if (nbValue == 0)
return 0;
return total / nbValue;
}
public double getNbEvent(int tStart, int tEnd)
{
double nbEvent = 0;
for (final EventCriteria eventCriteria : eventList)
{
if (eventCriteria.startFrame >= tStart && eventCriteria.startFrame <= tEnd)
{
nbEvent++;
}
if (eventCriteria.startFrame < tStart && eventCriteria.endFrame > tEnd)
{
nbEvent++;
}
}
return nbEvent;
}
public double getDensity(int tStart, int tEnd)
{
double nbEvent = 0;
for (int t = tStart; t <= tEnd; t++)
{
for (final EventCriteria eventCriteria : eventList)
{
if (eventCriteria.startFrame <= t && eventCriteria.endFrame >= t)
{
if ( tStart == 0 ){
// System.out.println("Start: " + eventCriteria.startFrame + " end: " + eventCriteria.endFrame );
}
nbEvent++;
break;
}
}
}
final double ret = nbEvent / (tEnd - tStart);
System.out.println("density: " + tStart + " : " + tEnd + ":" + nbEvent + ":" + ret );
return ret;
}
public double getLengthEvent(int tStart, int tEnd)
{
double totalLength = 0;
double nbEvent = 0;
for (final EventCriteria eventCriteria : eventList)
{
if (eventCriteria.startFrame >= tStart && eventCriteria.startFrame <= tEnd)
{
totalLength += eventCriteria.getLength();
nbEvent++;
}
if (eventCriteria.startFrame < tStart && eventCriteria.endFrame > tEnd)
{
totalLength += eventCriteria.getLength();
nbEvent++;
}
}
if (nbEvent == 0)
return 0;
return totalLength / nbEvent;
}
}
| true
|
1db33c72400bc67e903d14923d3fdbc42f19821b
|
Java
|
seshu-talent/ManPower
|
/src/com/ts/manpower/dto/WorkReference.java
|
UTF-8
| 1,816
| 2.1875
| 2
|
[] |
no_license
|
package com.ts.manpower.dto;
import java.util.*;
public class WorkReference {
private String firstName;
private String lastName;
private long mobileNumber;
private String emailId;
private ServiceType serviceType;
private Date serviceDate;
private char verifiedThrough;
private int rating;
private boolean deleted;
private int user_id;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public long getMobileNumber() {
return mobileNumber;
}
public void setMobileNumber(long mobileNumber) {
this.mobileNumber = mobileNumber;
}
public String getEmailId() {
return emailId;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
public ServiceType getServiceType() {
return serviceType;
}
public void setServiceType(ServiceType serviceType) {
this.serviceType = serviceType;
}
public Date getServiceDate() {
return serviceDate;
}
public void setServiceDate(Date serviceDate) {
this.serviceDate = serviceDate;
}
public char getVerifiedThrough() {
return verifiedThrough;
}
public void setVerifiedThrough(char verifiedThrough) {
this.verifiedThrough = verifiedThrough;
}
public int getRating() {
return rating;
}
public void setRating(int rating) {
this.rating = rating;
}
public boolean isDeleted() {
return deleted;
}
public void setDeleted(boolean deleted) {
this.deleted = deleted;
}
public int getUser_id() {
return user_id;
}
public void setUser_id(int user_id) {
this.user_id = user_id;
}
}
| true
|
f7e2dd7c9d3e7c28fd2d0e9c245a6910ef259067
|
Java
|
Timon2180/MavenTest
|
/IRR_Search_FullText/src/main/java/pack_utils/Proper.java
|
UTF-8
| 712
| 2.734375
| 3
|
[] |
no_license
|
package pack_utils;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;
public class Proper
{
protected static Properties prop;
static
{
prop = new Properties();
try
{
//prop.load(ClassLoader.getSystemResourceAsStream("./src/main/resource/config.properties"));
prop.load(new FileReader("./src/main/resource/config.properties"));
}
catch(IOException exc)
{
exc.printStackTrace();
System.out.println("Не удалось загрузить файл конфигурации"); // здесь валить тест
}
}
public static String GetProperty(String sKey)
{
return prop.getProperty(sKey);
}
}
| true
|
33c811415653a7db4f35fe86777b495f81995443
|
Java
|
ryanwbass/DorasDungeon
|
/DorasDungeon/src/view/Credits.java
|
UTF-8
| 1,638
| 2.6875
| 3
|
[] |
no_license
|
/*
* 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 view;
import java.awt.Color;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author dil5315
*/
public class Credits extends JPanel
{
JLabel label;
JLabel katie;
JLabel ryan;
JLabel colin;
JLabel dan;
public JButton back;
Credits()
{
this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
this.setBackground(Color.DARK_GRAY);
label = new JLabel("TEAM 2");
label.setForeground(Color.CYAN);
katie = new JLabel("Katie Dodds");
katie.setForeground(Color.CYAN);
ryan = new JLabel("Ryan Bass");
ryan.setForeground(Color.CYAN);
colin = new JLabel("Colin Burns");
colin.setForeground(Color.CYAN);
dan = new JLabel("Daniel Lavanier");
dan.setForeground(Color.CYAN);
back = new JButton("Return");
add(label);
add(Box.createVerticalStrut(20));
add(katie);
add(Box.createVerticalStrut(20));
add(ryan);
add(Box.createVerticalStrut(20));
add(colin);
add(Box.createVerticalStrut(20));
add(dan);
add(Box.createVerticalStrut(20));
add(back);
}
public void addReturnButtonListener(ActionListener al)
{
back.addActionListener(al);
}
}
| true
|
a0e5da77b373e70ad4fe865cc1bfaecc7c30b3b7
|
Java
|
ChandimaMaduwanthi/Alert-Management-System
|
/src/main/java/com/temperature/alert/api/controller/AlertDataController.java
|
UTF-8
| 853
| 2.171875
| 2
|
[] |
no_license
|
package com.temperature.alert.api.controller;
import com.temperature.alert.api.model.AlertData;
import com.temperature.alert.api.service.AlertDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api")
public class AlertDataController {
@Autowired
AlertDataService alertDataService;
@GetMapping("/alerts")
public List<AlertData> getAlerts(){
return alertDataService.getAlerts();
}
@GetMapping("/alerts/{sensor_id}")
public List<AlertData> getAlertsById(@PathVariable int sensor_id){
return alertDataService.getAlertsById(sensor_id);
}
@GetMapping("/alerts/latest")
public AlertData getLatestReadings(){
return alertDataService.getLatestAlert();
}
}
| true
|
63326b8d101356e34af211acfef51a38bb2aa8d2
|
Java
|
AMOS-NextHMI/launcher
|
/Launcher/automotive/src/main/java/com/example/myapplication/ContextualViewModel.java
|
UTF-8
| 3,177
| 2.03125
| 2
|
[
"Apache-2.0"
] |
permissive
|
/*
* Copyright (C) 2018 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.example.myapplication;
import android.app.Application;
import android.car.CarNotConnectedException;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.MediatorLiveData;
import androidx.lifecycle.ViewModel;
// import android.car.CarProjectionManager.ProjectionStatusListener;
/**
* Implementation {@link ViewModel} for {@link ContextualFragment}.
*
* Returns the first non-null {@link ContextualInfo} from a set of delegates.
*/
public class ContextualViewModel extends AndroidViewModel {
private final MediatorLiveData<ContextualInfo> mContextualInfo = new MediatorLiveData<>();
//private final List<LiveData<ContextualInfo>> mInfoDelegates;
public ContextualViewModel(Application application) throws CarNotConnectedException{
super(application);
// this(application, getCarProjectionManager(application));
}
// private static CarProjectionManager getCarProjectionManager(Context context) throws CarNotConnectedException {
//
// return (CarProjectionManager)
// Car.createCar(context, new ServiceConnection() {
// @Override
// public void onServiceConnected(ComponentName name, IBinder service) {
//
// }
//
// @Override
// public void onServiceDisconnected(ComponentName name) {
//
// }
// }).getCarManager(Car.PROJECTION_SERVICE);
// }
public MediatorLiveData<ContextualInfo> getContextualInfo() {
return mContextualInfo;
}
/* @VisibleForTesting
ContextualViewModel(Application application, CarProjectionManager carProjectionManager) {
super(application);
mInfoDelegates =
Collections.unmodifiableList(Arrays.asList(
// new ProjectionContextualInfoLiveData(application, carProjectionManager),
new WeatherContextualInfoLiveData(application)
));
Observer<Object> observer = x -> updateLiveData();
for (LiveData<ContextualInfo> delegate : mInfoDelegates) {
mContextualInfo.addSource(delegate, observer);
}
}
private void updateLiveData() {
for (LiveData<ContextualInfo> delegate : mInfoDelegates) {
ContextualInfo value = delegate.getValue();
if (value != null) {
mContextualInfo.setValue(value);
return;
}
}
mContextualInfo.setValue(null);
}
*/
}
| true
|
d0936aa53a6d6b232369596438578361804a76d9
|
Java
|
konglong123/KFlow
|
/src/main/java/BP/WF/Template/FrmNodeExts.java
|
UTF-8
| 871
| 2.5
| 2
|
[] |
no_license
|
package BP.WF.Template;
import BP.En.EntitiesMyPK;
import BP.En.Entity;
public class FrmNodeExts extends EntitiesMyPK{
/**
* 节点表单
*/
public FrmNodeExts() { }
// #endregion 构造方法..
//#region 公共方法.
/**
* 得到它的 Entity
*/
@Override
public Entity getGetNewEntity() {
return new FrmNodeExt();
}
// #endregion 公共方法.
public final java.util.List<FrmNodeExt> ToJavaList()
{
return (java.util.List<FrmNodeExt>)(Object)this;
}
/// <summary>
/// 转化成list
/// </summary>
/// <returns>List</returns>
public final java.util.ArrayList<FrmNodeExt> Tolist()
{
java.util.ArrayList<FrmNodeExt> list = new java.util.ArrayList<FrmNodeExt>();
for (int i = 0; i < this.size(); i++)
{
list.add((FrmNodeExt)this.get(i));
}
return list;
}
}
| true
|
ae5eb1a5bcd6ddaa95db6b33d5dd686c8d55fc95
|
Java
|
10yangbin/JinMaoChinaApp
|
/app/src/main/java/com/guomao/propertyservice/model/offlineoperate/OfflineOperateDao.java
|
UTF-8
| 782
| 2.28125
| 2
|
[] |
no_license
|
package com.guomao.propertyservice.model.offlineoperate;
import java.util.List;
/**
* 离线报事dao的接口
* @author Administrator
*
*/
public interface OfflineOperateDao {
/**
* 将要离线的数据保存至数据库
*
* @param operate
* 离线的实体
* @param urserId
* @return id
*/
long save(Operation operate);
/**
* 提交离线
*
* @param operation
*/
void saveOrUpdate(Operation operation);
/**
* 获取该用户的所有离线操作
*
* @param userId
* @return
*/
List<Operation> getOfflineOperates();
/**
* 通过id获取Operate
*
* @param id
* @return
*/
Operation getOfflineOperateById(String id);
/**
* 删除该id对应的数据
*
* @param id
*/
void deleteById(int id);
}
| true
|
d2317b96933800eb3f95bc299a2886f11a9de4c5
|
Java
|
SteveYuOWO/airplane-ticket-system
|
/src/test/java/com/littlepage/airplaneticketsystem/fakedata/Fake.java
|
UTF-8
| 6,462
| 2.296875
| 2
|
[] |
no_license
|
package com.littlepage.airplaneticketsystem.fakedata;
import com.littlepage.airplaneticketsystem.dao.AirflightRepository;
import com.littlepage.airplaneticketsystem.dao.AirlineRepository;
import com.littlepage.airplaneticketsystem.dao.CompanyRepository;
import com.littlepage.airplaneticketsystem.dao.PlaneRepository;
import com.littlepage.airplaneticketsystem.pojo.Airflight;
import com.littlepage.airplaneticketsystem.pojo.Airline;
import com.littlepage.airplaneticketsystem.pojo.Company;
import com.littlepage.airplaneticketsystem.pojo.Plane;
import com.littlepage.airplaneticketsystem.utils.AirflightUUID;
import com.littlepage.airplaneticketsystem.utils.DBUtils;
import com.littlepage.airplaneticketsystem.utils.DateUtils;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.junit.jupiter.api.Test;
import java.sql.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.UUID;
/**
* Fake Data
*/
public class Fake {
/**
* Company Fake Data
*/
@Test
public void fakeCompany() {
new CompanyRepository().addCompany(new Company(UUID.randomUUID().toString(),"鸿运航空","有好事发生","北京西城区"));
new CompanyRepository().addCompany(new Company(UUID.randomUUID().toString(),"东方航空","最大的航空中心","上海浦东"));
new CompanyRepository().addCompany(new Company(UUID.randomUUID().toString(),"南方航空","普通航空中心","浙江杭州"));
System.out.println("success");
}
/**
* Test Query Company
*/
@Test
public void getCompany(){
System.out.println(new CompanyRepository().getCompanyByName("南方航空"));
}
/**
* Plane Fake Data
*/
@Test
public void fakePlane(){
PlaneRepository planeR = new PlaneRepository();
Company com = new CompanyRepository().getCompanyByName("南方航空");
Company com1 = new CompanyRepository().getCompanyByName("东方航空");
for (String prince : princes) {
Plane plane = new Plane(UUID.randomUUID().toString(),
"播音777",
300,
100,
100,
prince+"机场",
com.getCCID());
planeR.addPlane(plane);
}
}
/**
* Test Query Plane
*/
@Test
public void getPlane(){
System.out.println(new PlaneRepository().getPlane("浦东机场"));
}
/**
* Fake Airline
*/
@Test
public void fakeAirline() throws SQLException {
HashSet<String> hashSet = new HashSet<>();
AirlineRepository air = new AirlineRepository();
PlaneRepository plane = new PlaneRepository();
Airline airline = new Airline();
Connection conn = DBUtils.getConnection();
conn.setAutoCommit(false);
Statement stmt = DBUtils.getStatement(conn);
for (int j=0;j<princes.length;j++) {
for (int i=0;i<princes2.length;i++) {
String str=UUID.randomUUID().toString().substring(0,36);
while(hashSet.contains(str)){
str=UUID.randomUUID().toString().substring(0,36);
}
hashSet.add(str);
if(!princes[j].equals(princes2[i])){
airline.setAlid(str).
setStartPlace(princes[j]).setArrivePlace(princes2[i]).
setPPID(plane.getPlane(princes[j]+"机场").getPPID());
air.addAirline(airline);
String sql = "insert t_airline values('"+
airline.getAlid()+"','"+
airline.getStartPlace()+"','"+
airline.getArrivePlace()+"','"+
airline.getPPID()+"')";
stmt.addBatch(sql);
}
}
}
stmt.executeBatch();
conn.setAutoCommit(true);
stmt.close();
conn.close();
}
/**
* Test Query Airline start & arrive
*/
@Test
public void getAirline(){
System.out.println(new AirlineRepository().getAirline("上海","北京"));
}
/**
* Test Query Airline one place
*/
@Test
public void getAirlineOnePlace(){
new AirlineRepository().getAirline("上海").forEach((x)->{
System.out.println(x);
});
}
/**
* add Airflight
*/
@Test
public void airflightfake() throws SQLException {
Airflight af = new Airflight();
AirflightRepository afr = new AirflightRepository();
Random r = new Random();
Connection conn= DBUtils.getConnection();
Statement stmt = DBUtils.getStatement(conn);
ResultSet rs = stmt.executeQuery("select * from t_airline");
while (rs.next()){
int starthour = r.nextInt(24);
af.setAfId(AirflightUUID.getAirflightUUID()).
setStartTime(DateUtils.getDate("2020-1-10 "+starthour+":"+r.nextInt(60)+"")).
setArriveTime(DateUtils.getDate("2020-1-10 "+(starthour+2)+":"+r.nextInt(60)+"")).
setTouristPrice((r.nextInt(100)+300)*1.0).
setFirstPrice((r.nextInt(100)+700)*1.0).
setBusinessPrice((r.nextInt(100)+500)*1.0).
setAlid(rs.getString("alid"));
afr.addAirflight(af);
}
}
static String[] princes ={"陕西省","甘肃省","青海省","宁夏","新疆",
"北京市","天津市","上海市","重庆市","河北省","山西省","辽宁省","吉林省",
"黑龙江省","江苏省","浙江省","安徽省","福建省","江西省","山东省","河南省",
"湖北省","湖南省","广东省","海南省","四川省","贵州省","云南省","台湾省",
"内蒙古","广西","西藏","香港","澳门"};
static String[] princes2 ={"陕西省","甘肃省","青海省","宁夏","新疆",
"北京市","天津市","上海市","重庆市","河北省","山西省","辽宁省","吉林省",
"黑龙江省","江苏省","浙江省","安徽省","福建省","江西省","山东省","河南省",
"湖北省","湖南省","广东省","海南省","四川省","贵州省","云南省","台湾省",
"内蒙古","广西","西藏","香港","澳门"};
}
| true
|
f85ec6ce37c3812c9460a8b53349b20596601520
|
Java
|
szepma/hotel
|
/src/java/Repository/CityRepo.java
|
UTF-8
| 1,657
| 2.71875
| 3
|
[] |
no_license
|
package Repository;
import Model.Database;
import Model.Cities;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.ParameterMode;
import javax.persistence.StoredProcedureQuery;
public class CityRepo {
public static boolean addNewCity(Cities city) {
try {
EntityManager em = Database.getDbConn();
StoredProcedureQuery spq = em.createStoredProcedureQuery("addNewCity");
spq.registerStoredProcedureParameter("nameIN", String.class, ParameterMode.IN);
spq.setParameter("nameIN", city.getCityname());
spq.execute();
return true;
}
catch (Exception ex) {
System.out.println(ex.getMessage());
return false;
}
}
public static Cities checkCity(String cityName) {
Cities result = new Cities(-1, cityName);
try {
EntityManager em = Database.getDbConn();
StoredProcedureQuery spq = em.createStoredProcedureQuery("checkCity");
spq.registerStoredProcedureParameter("cityIN", String.class, ParameterMode.IN);
spq.setParameter("cityIN", cityName);
List<Object[]> cityList = spq.getResultList();
for (Object[] current : cityList) {
int id = Integer.parseInt(current[0].toString());
result = result.getCityById(id);
}
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
finally {
return result;
}
}
}
| true
|
67e9ed22188703c86e48e4e121df7cafe823968e
|
Java
|
gcoronelc/SISTUNI_JAVA_WEB_007
|
/Clase04/EurekaWeb/src/pe/egcc/eureka/prueba/Rene.java
|
UTF-8
| 401
| 2.515625
| 3
|
[] |
no_license
|
package pe.egcc.eureka.prueba;
import java.math.BigDecimal;
public class Rene {
public static void main(String[] args) {
BigDecimal a = new BigDecimal("7.10");
BigDecimal b = new BigDecimal("5.55");
BigDecimal c = a.add(b);
System.out.println("a = " + a.toString());
System.out.println("b = " + b.toString());
System.out.println("c = " + c.toString());
}
}
| true
|
0f509b289ca3674708e8af3b7bc97e7c53d94820
|
Java
|
youaitbella/DP
|
/DataPortalCalc/src/main/java/org/inek/dataportal/calc/enums/ExternalStaffType.java
|
UTF-8
| 1,046
| 3.015625
| 3
|
[] |
no_license
|
package org.inek.dataportal.calc.enums;
public enum ExternalStaffType {
NURSING(1, "NURSING"),
ASSISTANTNURSING(2, "ASSISTANTNURSING"),
OTHERNURSING(3, "OTHERNURSING");
private int _id;
private String _name;
ExternalStaffType(int id, String name) {
this._id = id;
this._name = name;
}
public int getId() {
return _id;
}
public String getName() {
return _name;
}
public static ExternalStaffType fromId(int id) {
for (ExternalStaffType externalStaffType : ExternalStaffType.values()) {
if (externalStaffType.getId() == id) {
return externalStaffType;
}
}
return null;
}
public static ExternalStaffType getByName(String _name) {
for (ExternalStaffType externalStaffType:ExternalStaffType.values()) {
if(externalStaffType.getName().toUpperCase().equals(_name.toUpperCase())){
return externalStaffType;
}
}
return null;
}
}
| true
|
49bbd3195cfaa48a4c2b7931eab9a7469c3b4175
|
Java
|
nhudacin/xunit-converter
|
/src/main/java/com/tw/xunit/model/mstest/StackTrace.java
|
UTF-8
| 863
| 2.484375
| 2
|
[
"Apache-2.0"
] |
permissive
|
package com.tw.xunit.model.mstest;
/**
* Created by nhudacin on 4/22/2015.
*/
import org.simpleframework.xml.Text;
public class StackTrace {
@Text(required = false)
public String value;
public StackTrace() {
}
public StackTrace(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
StackTrace that = (StackTrace) o;
if (value != null ? !value.equals(that.value) : that.value != null) return false;
return true;
}
@Override
public int hashCode() {
return value != null ? value.hashCode() : 0;
}
}
| true
|
c5b426cc454c04b6a5e8386da3acc08a381d62af
|
Java
|
BenParker23/LBSAndroid
|
/app/src/main/java/com/lbs/model/MProduct.java
|
UTF-8
| 1,430
| 2.484375
| 2
|
[] |
no_license
|
package com.lbs.model;
/**
* Created by BenPa on 12/05/2018.
*/
public class MProduct extends DBObject{
private String name;
private String imageURL;
private int m_Product_ID;
private boolean isActive;
private String description;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getM_Product_ID() {
return m_Product_ID;
}
public void setM_Product_ID(int m_Product_ID) {
this.m_Product_ID = m_Product_ID;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getImageURL() {
return imageURL;
}
public void setImageURL(String imageURL) {
this.imageURL = imageURL;
}
public boolean isActive() {
return isActive;
}
public void setActive(boolean isActive) {
this.isActive = isActive;
}
@Override
public int save() {
return 0;
}
@Override
public int fromJson(String json) {
MProduct prod = gson.fromJson(json, MProduct.class);
m_Product_ID = prod.getM_Product_ID();
name = prod.getName();
description = prod.getDescription();
isActive = prod.isActive();
imageURL = prod.getImageURL();
return 1;
}
}
| true
|
189af871aba11fd4a8dc22505dc9e72fe88272f5
|
Java
|
therbdwolverine/loki
|
/app/src/main/java/loki/project/com/loki/src/models/Location.java
|
UTF-8
| 253
| 1.757813
| 2
|
[] |
no_license
|
package loki.project.com.loki.src.models;
/**
* Created by User on 4/14/2017.
*/
public class Location {
private String address1;
private String address2;
private Long postalCode;
private String state;
private String country;
}
| true
|
e9411fb865de797ba0adede56b37912bb6affa01
|
Java
|
jerryfan2000/500px_fandroid_sdk
|
/src/com/fivehundredpx/api/PxApi.java
|
UTF-8
| 5,403
| 2.25
| 2
|
[] |
no_license
|
package com.fivehundredpx.api;
import android.util.Log;
import com.fivehundredpx.api.auth.AccessToken;
import com.kiumiu.ca.api500px.RESTTransport;
import com.kiumiu.ca.api500px.blog.blogInterface;
import com.kiumiu.ca.api500px.collections.collectionsInterface;
import com.kiumiu.ca.api500px.comments.commentInterface;
import com.kiumiu.ca.api500px.photo.photoInterface;
import com.kiumiu.ca.api500px.user.userInterface;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.List;
import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
import oauth.signpost.exception.OAuthCommunicationException;
import oauth.signpost.exception.OAuthExpectationFailedException;
import oauth.signpost.exception.OAuthMessageSignerException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONObject;
/**
* 500px API main class. This is where you should start everything. It is recommended to use getInstance method to create PxApi instance to guarantee
* a new instance of PxApi will be instantiated.
*/
public class PxApi {
private static final String TAG = "ApiHelper";
private static String HOST = "https://api.500px.com/v1";
private AccessToken accessToken;
private String consumerKey;
private String consumerSecret;
private RESTTransport transport;
/**
* Constructor for PxApi creation with access token
* @param accessToken Access token obtained from 500px server.
* @param consumerKey Your consumer key for 500px.
* @param consumerSecret Your consumer secret for 500px.
*/
public PxApi(AccessToken accessToken, String consumerKey,
String consumerSecret) {
super();
this.accessToken = accessToken;
this.consumerKey = consumerKey;
this.consumerSecret = consumerSecret;
}
/**
* Constructor for PxApi creation without access token. A new instance of PxApi will be created every time this method is called.
* @param consumerKey Your consumer key for 500px.
* @param consumerSecret Your consumer secret for 500px.
*/
public PxApi(String consumerKey, String consumerSecret) {
super();
this.consumerKey = consumerKey;
this.consumerSecret = consumerSecret;
}
/**
* Method for PxApi creation in convenience with accessToken. A new instance of PxApi will be created every time this method is called.
* @param accessToken Access token obtained from 500px server.
* @param consumerKey Your consumer key for 500px.
* @param consumerSecret Your consumer secret for 500px.
*/
public static PxApi getInstance(AccessToken accessToken, String consumerKey,
String consumerSecret) {
return new PxApi(accessToken, consumerKey, consumerSecret);
}
/**
* Method for PxApi creation in convenience without accessToken
* @param consumerKey Your consumer key for 500px.
* @param consumerSecret Your consumer secret for 500px.
*/
public static PxApi getInstance(String consumerKey, String consumerSecret) {
return new PxApi(consumerKey, consumerSecret);
}
/**
* Get an instance of photoInterface object
* @return An instance of photoInterface.
*/
public photoInterface getPhotoInterface() {
if(accessToken != null)
return new photoInterface(accessToken, consumerKey, consumerSecret);
else
return new photoInterface(consumerKey, consumerSecret);
}
/**
* Get an instance of commentInterface object
* @return An instance of commentInterface. Return null if PxApi is not initialized with valid access token.
*/
public commentInterface getCommentInterface() {
if(accessToken != null)
return new commentInterface(accessToken, consumerKey, consumerSecret);
else
return null;
}
/**
* Get an instance of blogInterface object
* @return An instance of blogInterface.
*/
public blogInterface getBlogInterface() {
if(accessToken != null)
return new blogInterface(accessToken, consumerKey, consumerSecret);
else
return new blogInterface(consumerKey, consumerSecret);
}
/**
* Get an instance of userInterface object
* @return An instance of userInterface.
*/
public userInterface getUserInterface() {
if(accessToken != null)
return new userInterface(accessToken, consumerKey, consumerSecret);
else
return new userInterface(consumerKey, consumerSecret);
}
/**
* Get an instance of collectionsInterface object
* @return An instance of collectionsInterface.
*/
public collectionsInterface getCollectionsInterface() {
if(accessToken != null)
return new collectionsInterface(accessToken, consumerKey, consumerSecret);
else
return new collectionsInterface(consumerKey, consumerSecret);
}
}
| true
|
0acc3ca4c69212192799490fcddeb5c2fc891645
|
Java
|
ElEd0/ConsoleUi
|
/src/main/java/es/ed0/terminalui/TerminalUi.java
|
UTF-8
| 7,240
| 3.03125
| 3
|
[] |
no_license
|
/**
* Created by Ed0 in 22 feb. 2019
*/
package es.ed0.terminalui;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import es.ed0.terminalui.input.CommandListener;
import es.ed0.terminalui.input.InputListener;
import es.ed0.terminalui.input.LineListener;
import es.ed0.terminalui.ui.Component;
import es.ed0.terminalui.ui.Separator;
/**
* Main class that controls all the terminal input and output. Prints text and components and handles input commands.
*/
public class TerminalUi {
/**
* TODO:
* - entry table +
* - prompt +
* - commandhandler +
* - loading bar +
* - y/n prompt +
* - line +
* - list +
* - hierarchy view (tree view) +
* - line margin +
* - set output stream +
* - panel (padding, etc) +
* - grid - wip
* - fix grid omg, remove getWidth -> cannot call toString twice
* - canvas drawAt(x, y) +
* - canvas draw circle +
* - canvas line +
* - better borders, with title
* - graphs (?)
* - progress last progress char
* - \r repaint console
* - prompt options (int)
*/
private Scanner t;
private PrintStream out;
private int lastPrintLength = 10;
private int lineSpacing = 1;
private final ArrayList<InputListener> listeners;
private final ArrayList<String> commands;
private boolean acceptAnythingAsCommand = false;
public TerminalUi() {
t = new Scanner(System.in);
out = System.out;
commands = new ArrayList<String>();
listeners = new ArrayList<InputListener>();
}
private void dispatchInput(String line) {
if (line == null || line.equals(""))
return;
boolean brk = false;
for (InputListener li : listeners) {
if (li instanceof LineListener) {
brk = ((LineListener) li).onLine(line);
} else if (li instanceof CommandListener) {
final String[] coma = line.split(" ");
final String[] as = new String[coma.length - 1];
for (int c = 0; c < as.length; c++)
as[c] = coma[c + 1];
for (String c : commands) {
if (this.acceptAnythingAsCommand || c.equals(coma[0])) {
brk = ((CommandListener) li).onCommand(c, as);
break;
}
}
}
if (brk)
break;
}
}
/**
* It will activate the user input and send the next entered line or command to the available listeners
* @param message
*/
public void promptInput(String message) {
print(message + " ");
dispatchInput(t.nextLine());
}
/**
* Prompt the given message and wait for a response.
* @param message Prompt message
* @return User input answer
*/
public String promptText(String message) {
out.print(message);
return t.nextLine();
}
/**
* Prompt the given message and wait for a yes/no response.
* @param message Prompt message
* @return true if user entered "y" or "yes". Case insensitive
*/
public boolean promptAccept(String message) {
switch (promptText(message).toLowerCase()) {
case "y": case "yes": return true;
default: return false;
}
}
/**
* Promt the given message and wait for a numeric response
* @param message Prompt message
* @return The input as an int, or -1 if the input could not be parsed as an int
*/
public int promptOption(String message) {
out.print(message);
try {
return t.nextInt();
} catch (Exception e) {
return -1;
}
}
/**
* Prints the elements in the given list. It will do so by calling the toString() method for each object<br>
* Ie:<br>
* - element1<br>
* - element2<br>
* - element3<br>
* @param list
*/
public void printList(List<?> list) {
final StringBuilder sb = new StringBuilder();
for (Object obj : list)
sb.append(" - ").append(obj.toString()).append("\n");
println(sb.toString());
}
/**
* Print a terminal ui component to the console
* @param com component to print
*/
public void print(Component com) {
println(com.toString());
}
/**
* Prints the given text to the terminal
* @param line
*/
public void print(String line) {
out.print(line);
if (!line.equals("\n"))
lastPrintLength = line.length();
if (line.endsWith("\n"))
for (int i = 0; i < lineSpacing - 1; i++)
out.println();
}
/**
* Prints the given object to the terminal
* @param obj
*/
public void print(Object obj) {
this.print(obj.toString());
}
/**
* Prints the given text to the terminal and appends a line jump
* @param line
*/
public void println(String line) {
print(line + "\n");
}
/**
* Prints the given object to the terminal and appends a line jump
* @param obj
*/
public void println(Object obj) {
println(obj.toString());
}
/**
* Prints a line jump
*/
public void println() {
print("\n");
}
/**
* Prints a separator with the same length as the last printed text line
*/
public void separator() {
print(new Separator(lastPrintLength));
}
/**
* Sets the printing output stream. Default is System.out
* @param stream new PrintStream
*/
public void setOutputStream(PrintStream stream) {
this.out = stream;
}
/**
* Sets the input stream. Default is System.in
* @param stream InputStream
*/
public void setInputStream(InputStream stream) {
t.close();
t = new Scanner(stream);
}
/**
* Return the current line spacing. Default is 1
* @return line spacing
*/
public int getLineSpacing() {
return lineSpacing;
}
/**
* Set the line spacing. The line jumps between print and print, this includes println prints. Default is 1
* @param lineSpacing new linespacing
*/
public void setLineSpacing(int lineSpacing) {
this.lineSpacing = lineSpacing;
}
/**
* Add a recognizable command to the list of commands that trigger the onCommand() method in any declared CommandListener.<br>
* Spaces are not allowed and will be replaced with "-"
* @param command command
*/
public void addCommand(String command) {
commands.add(command.replace(" ", "-"));
}
/**
* Add commands to the list of commands that trigger the onCommand() method in any declared CommandListener.<br>
* Spaces are not allowed and will be replaced with "-"
* @param commands command or commands
*/
public void addCommands(String... commands) {
for (String c : commands)
addCommand(c);
}
/**
* If set to true the command listeners will be triggered by any string without
* the need of adding them as valid commands via {@link #addCommand(String)}
* @param accept
*/
public void acceptAnythingAsCommand(boolean accept) {
this.acceptAnythingAsCommand = accept;
}
/**
* Add an inputListener to listen for user keyboard input.
* If a CommandListener is given, commands must be set using {@link #addCommand(String)} or {@link #addCommands(String...)}
* to trigger the {@link CommandListener#onCommand(String, String[])} method.
* Alternatively one can set to true acceptAnythingAsCommand by calling {@link #acceptAnythingAsCommand(boolean)}
* @param listener listener to add
*/
public void addInputListener(InputListener listener) {
listeners.add(listener);
}
/**
* Removes the given listener from the available listeners list
* @param listener
*/
public void removeInputListener(InputListener listener) {
listeners.remove(listener);
}
}
| true
|
613ad308c4d46c5dd907ab60e737401c6041fa0c
|
Java
|
qq9630232/Management
|
/app/src/main/java/com/example/freightmanagement/presenter/TrainingSelectPresenter.java
|
UTF-8
| 1,493
| 1.882813
| 2
|
[] |
no_license
|
package com.example.freightmanagement.presenter;
import com.example.freightmanagement.Base.BaseApiConstants;
import com.example.freightmanagement.Base.BasePresenter;
import com.example.freightmanagement.Bean.TrainAnswerListBean;
import com.example.freightmanagement.Bean.TrainingStartBean;
import com.example.freightmanagement.Utils.Network.OnRequestResultForCommon;
import com.example.freightmanagement.Utils.Network.RestApi;
import com.example.freightmanagement.presenter.constract.TrainingSelectConstact;
import com.google.gson.Gson;
/**
* Created by songdechuan on 2020/8/6.
*/
public class TrainingSelectPresenter extends BasePresenter<TrainingSelectConstact.View> implements TrainingSelectConstact {
@Override
public void getAnswerResultList(String driverId) {
RestApi.getInstance().get(BaseApiConstants.API_ANSWER_RESULT_LIST, new OnRequestResultForCommon() {
@Override
public void onSuccess(String json) {
super.onSuccess(json);
TrainAnswerListBean trainAnswerListBean = new Gson().fromJson(json, TrainAnswerListBean.class);
mView.trainingList(trainAnswerListBean.getData());
}
@Override
public void onFail() {
super.onFail();
}
@Override
public void netUnlink() {
super.netUnlink();
}
});
}
// @Override
// public void getTestList(int id) {
//
// }
}
| true
|
9c0192169d871a1e438a9e9a4503af6b5ae9bc69
|
Java
|
nagabhairavas/docextractor
|
/src/main/java/com/competency/model/CompetencyEntity.java
|
UTF-8
| 2,345
| 2.25
| 2
|
[] |
no_license
|
package com.competency.model;
public class CompetencyEntity {
private int competencyId;
private String competency;
private int categoryId;
private String category;
private int questionId;
private int questionNbr;
private int itemId;
private String question;
private String answerType;
private int choiceId;
private int choiceNbr;
private String choice;
private int weight;
private String explanation;
public int getCompetencyId() {
return competencyId;
}
public void setCompetencyId(int competencyId) {
this.competencyId = competencyId;
}
public String getCompetency() {
return competency;
}
public void setCompetency(String competency) {
this.competency = competency;
}
public int getCategoryId() {
return categoryId;
}
public void setCategoryId(int categoryId) {
this.categoryId = categoryId;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public int getQuestionId() {
return questionId;
}
public void setQuestionId(int questionId) {
this.questionId = questionId;
}
public int getQuestionNbr() {
return questionNbr;
}
public void setQuestionNbr(int questionNbr) {
this.questionNbr = questionNbr;
}
public int getItemId() {
return itemId;
}
public void setItemId(int itemId) {
this.itemId = itemId;
}
public String getQuestion() {
return question;
}
public void setQuestion(String question) {
this.question = question;
}
public String getAnswerType() {
return answerType;
}
public void setAnswerType(String answerType) {
this.answerType = answerType;
}
public int getChoiceId() {
return choiceId;
}
public void setChoiceId(int choiceId) {
this.choiceId = choiceId;
}
public int getChoiceNbr() {
return choiceNbr;
}
public void setChoiceNbr(int choiceNbr) {
this.choiceNbr = choiceNbr;
}
public String getChoice() {
return choice;
}
public void setChoice(String choice) {
this.choice = choice;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public String getExplanation() {
return explanation;
}
public void setExplanation(String explanation) {
this.explanation = explanation;
}
}
| true
|
4130d1513b3698ed214be177726387a0f02fc8dc
|
Java
|
xiongyf/springcloud
|
/order-api/src/main/java/com/kevin/orderapi/api/ProductFeignClient.java
|
UTF-8
| 701
| 2.09375
| 2
|
[] |
no_license
|
package com.kevin.orderapi.api;
import com.kevin.productapi.domain.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient(value = "product-api", fallback = ProductFeignClientFallback.class)
public interface ProductFeignClient {
@RequestMapping(value = "/product/{id}", method = RequestMethod.GET)
Product queryById(@PathVariable("id") String id);
@PostMapping(value = "/product")
void update(Product product);
}
| true
|
6a3d2692561de1d2c018adcea2de9c66f6b2d32d
|
Java
|
annastakanova/U_01-linearProgram
|
/Task01a.java
|
UTF-8
| 628
| 4.0625
| 4
|
[] |
no_license
|
//1. Даны два действительных числа х и у. Вычислить их сумму, разность, произведение и частное.
public class Task01a {
public static void main(String[] args) {
double x = 1.01;
double y = 2.02;
double sum = x+y;
double sub = x-y;
double mult = x*y;
double div = x/y;
System.out.println("сумма = " + sum);
System.out.println("разность = " + sub);
System.out.println("произведение = " + mult);
System.out.println("частное " + div);
}
}
| true
|
726de66771bcd4a1f18677ac1d6cd9c77539e130
|
Java
|
gabrieeeuu/cyan_challenge_backend
|
/src/main/java/com/cyan/Gabriel/model/Farm.java
|
UTF-8
| 955
| 2.609375
| 3
|
[] |
no_license
|
package com.cyan.Gabriel.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import javax.persistence.*;
import java.util.List;
@Table
@Entity
public class Farm {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column
private long id;
@Column
private String name;
@OneToMany(targetEntity = Field.class)
@JoinColumn
@Column
private List<Field> fields;
public Farm(){
}
public Farm(@JsonProperty("name") String name,
@JsonProperty("fields") List<Field> fields) {
this.name = name;
this.fields = fields;
}
public Farm addField(Field field) {
if(!this.fields.contains(field)){
this.fields.add(field);
}
return this;
}
public long getId() {
return id;
}
public String getName() {
return name;
}
public List<Field> getFields() {
return fields;
}
}
| true
|
16586ba86addcd3a591e8c909ddd6fff1895c73f
|
Java
|
AbhishekRajgaria-ps/sapient-asde-june-2021-training
|
/Project/product-phase-development@97ff8629ba9/micro-services/vehicle-service/src/test/java/com/sapient/asde/batch5/vehicleservice/service/pod_a/pjmb1151/StoreVehicleComparisonTest.java
|
UTF-8
| 2,060
| 2.09375
| 2
|
[] |
no_license
|
package com.sapient.asde.batch5.vehicleservice.service.pod_a.pjmb1151;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.sapient.asde.batch5.vehicleservice.entity.VehicleComparison;
import com.sapient.asde.batch5.vehicleservice.repository.VehicleComparisonRepository;
import com.sapient.asde.batch5.vehicleservice.service.ServiceException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
/**
* @author Neha Neha1@publicissapient.com
*/
@SpringBootTest
class StoreVehicleComparisonTest {
@Autowired
StoreVehicleComparisonService service;
@MockBean
VehicleComparisonRepository repo;
private String userId;
VehicleComparison v1;
@BeforeEach
void setup() {
userId = "userId";
List<String> vehicleIds = new ArrayList<>();
vehicleIds.add("id1");
vehicleIds.add("id2");
Date date = Date.from(Instant.parse("2000-01-01T00:00:00.000Z"));
v1 = new VehicleComparison("id", userId, vehicleIds, "comparisonMatrixName", date);
Mockito.when(repo.save(v1)).thenReturn(v1);
}
@Test
void shouldStoreVehicle() throws ServiceException {
VehicleComparison actual = service.storeVehicle(v1,userId);
VehicleComparison expected = v1;
assertEquals(expected, actual);
}
@Test
void shouldThrowServiceException_whenIdOrUserIdIsEmpty() throws ServiceException {
assertThrows(ServiceException.class, () -> service.storeVehicle(v1, ""));
assertThrows(ServiceException.class, () -> service.storeVehicle(v1, " "));
assertThrows(ServiceException.class, () -> service.storeVehicle(v1,null));
}
}
| true
|
d8a69b92b68d7de15201361bf3904499b278b867
|
Java
|
Tarunjain19/DXC_SVN
|
/trunk/IVRAppliction/sourcecode/RCOM_CF_Metro_IVR/WEB-INF/src/flow/Capture_ANI_DNIS_BC.java
|
UTF-8
| 12,088
| 1.632813
| 2
|
[] |
no_license
|
package flow;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.log4j.Logger;
import com.avaya.sce.runtimecommon.ITraceInfo;
import com.avaya.sce.runtimecommon.SCESession;
import com.rcom.metro.Constants;
import com.rcom.metro.StackTrace;
import com.rcom.metro.model.IVRRoutingInfo;
import com.rcom.metro.resource.IVRDBServiceInstance;
import com.servion.prepaid.report.GetReportObject;
import com.servion.prepaid.report.IVRREPORTDATA;
import com.servion.prepaid.report.IVRREPORTDATA.CALLINFO;
import com.servion.util.AppProperties;
import com.servion.util.IVRDataBean;
/**
* The Data class handles many types of server-side operations including data
* collection (from a data sources such as a database, or web service), variable
* assignments and operations (like copying variable values, performing mathematic
* operations, and collection iteration), conditional evaluation to control callflow
* execution based on variable values, and logging/tracing statements.
*
* Items created in the getDataActions() method are executed/evaluated in order
* and if a condional branch condition evaluates to "true" then the branch is
* activated and the execution of data actions is halted. If no "true" conditions
* are encountered, then all data actions will be executed/evaluated and the
* application will proceed to the "Default" servlet.
* Last generated by Orchestration Designer at: 2015-APR-02 03:17:43 PM
*/
public class Capture_ANI_DNIS_BC extends com.avaya.sce.runtime.Data {
//{{START:CLASS:FIELDS
//}}END:CLASS:FIELDS
/**
* Default constructor
* Last generated by Orchestration Designer at: 2015-APR-02 03:17:43 PM
*/
public Capture_ANI_DNIS_BC() {
//{{START:CLASS:CONSTRUCTOR
super();
//}}END:CLASS:CONSTRUCTOR
}
@Override
public void requestBegin(SCESession mySession) {
AppProperties ivrProperties = null;
try{
GetReportObject getReportObject = null;
IVRREPORTDATA ivrreportdata = null;
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
InetAddress ip = null;
CALLINFO callInfo = null;
Logger logger = Logger.getLogger("Dialog.Designer.TraceWriter.RCOM_CF_Metro_IVR");
ITraceInfo trace = mySession.getTraceOutput();
String sessionId = mySession.getSessionId();
String ANI = mySession.getVariableField(IProjectVariables.SESSION, IProjectVariables.SESSION_FIELD_ANI).getStringValue();
String DNIS = mySession.getVariableField(IProjectVariables.SESSION, IProjectVariables.SESSION_FIELD_DNIS).getStringValue();
trace.writeln(ITraceInfo.TRACE_LEVEL_DEBUG, "SESSION ID : " +sessionId);
trace.writeln(ITraceInfo.TRACE_LEVEL_DEBUG, "ANI : " +ANI);
trace.writeln(ITraceInfo.TRACE_LEVEL_DEBUG, "DNIS : " +DNIS);
ivrProperties = AppProperties.GetInstance(Constants.IVR_CONFIG);
mySession.getVariableField(IProjectVariables.APP_VARIABLES, IProjectVariables.APP_VARIABLES_FIELD_UUI_DATA).setValue(ANI+"|" + DNIS + "|");
//Setting IVRDataBean in session for DB Transactions - Start
IVRDataBean ivrDataBean = new IVRDataBean();
ivrDataBean.setSessionID(sessionId);
ivrDataBean.setLogger(logger);
//Setting IVRDataBean in session for DB Transactions - End
/*
* Setting Report data
*/
getReportObject = new GetReportObject();
ivrreportdata = getReportObject.createIVRReportObject();
mySession.setProperty(Constants.BEANREPORTDATA, getReportObject);
getReportObject.setIvrreportdata(ivrreportdata);
ivrDataBean.setGetReportObject(getReportObject);
mySession.getVariableField(IProjectVariables.APP_VARIABLES, IProjectVariables.APP_VARIABLES_FIELD_APP_NAME).setValue(ivrProperties.getIVRProp(Constants.APP_NAME));
/**Assigning call info data for report*/
ip= InetAddress.getLocalHost();
callInfo = ivrreportdata.getCALLINFO();
callInfo.setUNIQUECALLID(mySession.getVariableField(IProjectVariables.SESSION, IProjectVariables.SESSION_FIELD_UCID).getStringValue());
callInfo.setSESSIONID(sessionId);
callInfo.setVXMLIP(String.valueOf(ip));
callInfo.setSTARTDATETIME(dateFormat.format(new Date()));
callInfo.setAPPNAME(mySession.getVariableField(IProjectVariables.APP_VARIABLES, IProjectVariables.APP_VARIABLES_FIELD_APP_NAME).getStringValue());
callInfo.setCALLERTYPE("NA");
callInfo.setCATEGORY("NA");
callInfo.setCIRCLEID("NA");
callInfo.setCLI(ANI);
callInfo.setDNIS(DNIS);
callInfo.setDNISTYPE("NA");
callInfo.setHUB(ivrProperties.getIVRProp(Constants.HUB));
callInfo.setAGENTID("NA");
callInfo.setAGENTEXTN("NA");
callInfo.setTRANSCODE("NA");
callInfo.setTRANSFERVDN("NA");
callInfo.setUUIDATA("NA");
callInfo.setABANDONEDFLAG("NA");
callInfo.setTRANSTOIVR("NA");
callInfo.setSKILLNAME("NA");
callInfo.setLANGCODE(ivrProperties.getIVRProp(Constants.LANGUAGE_MARATHI));
callInfo.setENDDATETIME("NA");
callInfo.setDTMFPATH("NA");
callInfo.setMENUPATH("NA");
callInfo.setCALLERPATH("NA");
callInfo.setLASTMENUACCESSED("NA");
callInfo.setLASTNODEACCESSED("NA");
callInfo.setDISPOSITION("ID");
callInfo.setCALLENDREASON("IVR_DISCONNECT");
callInfo.setHOWCALLENDED("DISCONNECT");
callInfo.setERRREASON("NA");
callInfo.setRESERVE1("NA");
callInfo.setRESERVE2("NA");
callInfo.setRESERVE3("NA");
callInfo.setRESERVE4("NA");
callInfo.setRESERVE5("NA");
callInfo.setLANGUAGEFROM("NA");
callInfo.setLANGUAGETO("NA");
callInfo.setTAGGING("NA");
ivrreportdata.setCALLINFO(callInfo);
ivrDataBean.setGetReportObject(getReportObject);
trace.writeln(ITraceInfo.TRACE_LEVEL_DEBUG, "Application Name:: "+mySession.getVariableField(IProjectVariables.APP_VARIABLES, IProjectVariables.APP_VARIABLES_FIELD_APP_NAME).getStringValue());
String DM_Properties_Location_Marathi = ivrProperties.getIVRProp(Constants.DM_PROPERTIES_LOCATION_MARATHI);
trace.writeln(ITraceInfo.TRACE_LEVEL_DEBUG, "DM_Properties_Location_Marathi : " +DM_Properties_Location_Marathi);
mySession.getVariableField(IProjectVariables.DM__PROPERTIES__LOCATION, IProjectVariables.DM__PROPERTIES__LOCATION_FIELD_MARATHI).setValue(DM_Properties_Location_Marathi);
String DM_Properties_Location_Hindi = ivrProperties.getIVRProp(Constants.DM_PROPERTIES_LOCATION_HINDI);
trace.writeln(ITraceInfo.TRACE_LEVEL_DEBUG, "DM_Properties_Location_Hindi : " +DM_Properties_Location_Hindi);
mySession.getVariableField(IProjectVariables.DM__PROPERTIES__LOCATION, IProjectVariables.DM__PROPERTIES__LOCATION_FIELD_HINDI).setValue(DM_Properties_Location_Hindi);
String DM_Properties_Location_English = ivrProperties.getIVRProp(Constants.DM_PROPERTIES_LOCATION_ENGLISH);
trace.writeln(ITraceInfo.TRACE_LEVEL_DEBUG, "DM_Properties_Location_English : " +DM_Properties_Location_English);
mySession.getVariableField(IProjectVariables.DM__PROPERTIES__LOCATION, IProjectVariables.DM__PROPERTIES__LOCATION_FIELD_ENGLISH).setValue(DM_Properties_Location_English);
String Lang_English = ivrProperties.getIVRProp(Constants.LANGUAGE_ENGLISH);
trace.writeln(ITraceInfo.TRACE_LEVEL_DEBUG, "Language_English : " +Lang_English);
mySession.getVariableField(IProjectVariables.LANGUAGES, IProjectVariables.LANGUAGES_FIELD_ENGLISH).setValue(Lang_English);
String Lang_Hindi = ivrProperties.getIVRProp(Constants.LANGUAGE_HINDI);
trace.writeln(ITraceInfo.TRACE_LEVEL_DEBUG, "Language_Hindi : " +Lang_Hindi);
mySession.getVariableField(IProjectVariables.LANGUAGES, IProjectVariables.LANGUAGES_FIELD_HINDI).setValue(Lang_Hindi);
String Lang_Marathi = ivrProperties.getIVRProp(Constants.LANGUAGE_MARATHI);
trace.writeln(ITraceInfo.TRACE_LEVEL_DEBUG, "Language_Marathi : " +Lang_Marathi);
mySession.getVariableField(IProjectVariables.LANGUAGES, IProjectVariables.LANGUAGES_FIELD_MARATHI).setValue(Lang_Marathi);
//Setting Marathi DM properties location in project variable
mySession.getVariableField(IProjectVariables.DM__INPUT, IProjectVariables.DM__INPUT_FIELD_DM__PROPERTIES_LOCATION).setValue(DM_Properties_Location_Marathi);
mySession.getVariableField(IProjectVariables.APP_VARIABLES, IProjectVariables.APP_VARIABLES_FIELD_LANGUAGE).setValue(mySession.getVariableField(IProjectVariables.LANGUAGES, IProjectVariables.LANGUAGES_FIELD_MARATHI).getStringValue());
/*
* DB Hit to get Circle
*/
IVRRoutingInfo reqIvrRoutingInfo = new IVRRoutingInfo();
reqIvrRoutingInfo.setDnis(DNIS);
trace.writeln(ITraceInfo.TRACE_LEVEL_DEBUG, "Calling DB service IVRRoutingInfo to get circle.");
IVRRoutingInfo resIvrRoutingInfo = IVRDBServiceInstance.getIVRDBInstance().getIVRRoutingInfo(ivrDataBean, reqIvrRoutingInfo);
trace.writeln(ITraceInfo.TRACE_LEVEL_DEBUG, "IVR Routing Info" +resIvrRoutingInfo.toString());
String circle = resIvrRoutingInfo.getCircle();
trace.writeln(ITraceInfo.TRACE_LEVEL_DEBUG, "Circle : " +circle);
if(circle !=null)
{
mySession.getVariableField(IProjectVariables.APP_VARIABLES, IProjectVariables.APP_VARIABLES_FIELD_CIRCLE).setValue(circle);
}
else
{
mySession.getVariableField(IProjectVariables.APP_VARIABLES, IProjectVariables.APP_VARIABLES_FIELD_CIRCLE).setValue("NA");
}
callInfo.setCIRCLEID(mySession.getVariableField(IProjectVariables.APP_VARIABLES, IProjectVariables.APP_VARIABLES_FIELD_CIRCLE).getStringValue());
ivrreportdata.setCALLINFO(callInfo);
ivrDataBean.setGetReportObject(getReportObject);
mySession.setProperty(Constants.IVR_DATA_BEAN, ivrDataBean);
}catch(Exception e) {
mySession.getVariableField(IProjectVariables.DM__PROPERTIES__LOCATION, IProjectVariables.DM__PROPERTIES__LOCATION_FIELD_MARATHI).setValue(ivrProperties.getIVRProp(Constants.DM_PROPERTIES_LOCATION_MARATHI));
mySession.getVariableField(IProjectVariables.APP_VARIABLES, IProjectVariables.APP_VARIABLES_FIELD_IS_EXCEPTION).setValue(Constants.Yes);
StackTrace.PrintException(e);
}
}
/**
* Returns the Next item which will forward application execution
* to the next form in the call flow.
* Last generated by Orchestration Designer at: 2016-JAN-28 05:42:45 PM
*/
public com.avaya.sce.runtime.Next getNext(com.avaya.sce.runtimecommon.SCESession mySession) {
com.avaya.sce.runtime.Next next = new com.avaya.sce.runtime.Next("WelcomeAnn_PP", "Success");
next.setDebugId(9);
return next;
}
/**
* Create a list of local variables used by items in the data node.
*
* This method is generated automatically by the code generator
* and should not be manually edited. Manual edits may be overwritten
* by the code generator.
* Last generated by Orchestration Designer at: 2016-JAN-28 05:42:45 PM
*/
public java.util.Collection<VariableInfo> getLocalVariables(){
java.util.Collection<VariableInfo> variables = new java.util.ArrayList<VariableInfo>();
return variables;
}
/**
* Creates and conditionally executes operations that have been configured
* in the Callflow. This method will build a collection of operations and
* have the framework execute the operations by calling evaluateActions().
* If the evaluation causes the framework to forward to a different servlet
* then execution stops.
* Returning true from this method means that the framework has forwarded the
* request to a different servlet. Returning false means that the default
* Next will be invoked.
*
* This method is generated automatically by the code generator
* and should not be manually edited. Manual edits may be overwritten
* by the code generator.
* Last generated by Orchestration Designer at: 2016-JAN-28 05:42:45 PM
*/
public boolean executeDataActions(com.avaya.sce.runtimecommon.SCESession mySession) throws Exception {
java.util.Collection actions = null;
actions = new java.util.ArrayList(1);
if(evaluateActions(actions, mySession)) {
return true;
}
actions = null;
// return false if the evaluation of actions did not cause a servlet forward or redirect
return false;
}
}
| true
|
25941d6c0d23d66e276d97250d997caac75ae24a
|
Java
|
edvelezg/unb-java2
|
/src/recursion/Permutations.java
|
UTF-8
| 1,452
| 3.421875
| 3
|
[] |
no_license
|
package recursion;
public class Permutations {
private boolean[] used;
private StringBuilder out = new StringBuilder();
private final String in;
public static void main(String[] args) {
Permutations p = new Permutations("abcd");
p.permute();
}
public Permutations(final String str) {
in = str;
used = new boolean[in.length()];
}
public void permute() {
// System.out.println("permute()");
if ( out.length() == in.length() ) {
// System.out.println("out.length() == in.length()");
System.out.println(out);
return;
}
for ( int i = 0; i < in.length(); ++i ) {
if ( used[i] ) continue;
out.append(in.charAt(i));
used[i] = true;
// System.out.println(String.format("befor: %5d%8s%12s", i, out, join(used)));
permute();
used[i] = false;
out.setLength(out.length() - 1);
// System.out.println(String.format("after: %5d%8s%12s", i, out, join(used)));
}
}
public String join(boolean[] array) {
StringBuffer b = new StringBuffer();
for ( int i = 0; i < array.length - 1; i++ ) {
b.append(array[i] ? "T" : "F");
b.append(",");
}
b.append(array[array.length - 1] ? "T" : "F");
return b.toString();
}
}
| true
|
172e3a61405b59d0d29a08eb1e7b3972c847a22e
|
Java
|
outboy-github/leetCode
|
/leetCode_04_FindMedianSortedArrays.java
|
UTF-8
| 683
| 3.515625
| 4
|
[] |
no_license
|
package com.wyw.leetCode01_10;
import java.util.Arrays;
public class LeetCode_04_FindMedianSortedArrays {
public static void main(String[] args){
int[] arr1 = {};
int[] arr2 = {2,3};
double num = findMedianSortedArrays(arr1, arr2);
System.out.println(num);
}
public static double findMedianSortedArrays(int[] A, int[] B){
int[] array = new int[A.length + B.length];
System.arraycopy(A, 0, array, 0, A.length);
System.arraycopy(B, 0, array, A.length, B.length);
Arrays.sort(array);
int length = array.length;
if((length & 1) == 1){
return array[length / 2] / 1.0;
}
else{
return (array[length / 2 - 1] + array[length / 2]) / 2.0;
}
}
}
| true
|
651da14caa03f3f6fb5b6d202f9c3bc5be9df443
|
Java
|
ITcathyh/Interpreter
|
/app/src/main/java/com/cheelem/interpreter/entity/SocketInfo.java
|
UTF-8
| 587
| 2.515625
| 3
|
[] |
no_license
|
package com.cheelem.interpreter.entity;
/**
* Created by 黄宇航 on 2018/2/28.
*/
public class SocketInfo {
private int code;
private Object obj = null;
public SocketInfo(int code, Object obj) {
this.code = code;
this.obj = obj;
}
public SocketInfo(int code) {
this.code = code;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public Object getObj() {
return obj;
}
public void setObj(Object obj) {
this.obj = obj;
}
}
| true
|
8684e7d343d31b6f307b396fa3ad361a2ea7cc23
|
Java
|
zhuo-github/design-patterns
|
/src/observer/ConcreteSubject.java
|
UTF-8
| 282
| 2.734375
| 3
|
[] |
no_license
|
package observer;
import java.util.ArrayList;
import java.util.Collection;
public class ConcreteSubject extends Subject {
@Override
public void execute() {
System.out.println("实体的主题执行了");
//通知观察者
notifyObserver();
}
}
| true
|
a1ea25706f40fcf3a1ae8595cf51a1a4f302471b
|
Java
|
Arst-zx/product
|
/src/main/java/com/imooc/product/service/ProductInfoService.java
|
UTF-8
| 652
| 2.015625
| 2
|
[] |
no_license
|
package com.imooc.product.service;
import com.imooc.product.DTO.CarDTO;
import com.imooc.product.dataobject.ProductInfo;
import java.util.List;
/**
* @author 章鑫
* @date 2018/8/23 10:27
*/
public interface ProductInfoService {
/**
* 1.查询所有在架商品
* @return List<ProductInfo>
*/
List<ProductInfo> findUpAll();
/**
* 按订单id查询商品列表
* @param productIdList
* @return List<ProductInfo>
*/
List<ProductInfo> findListByProductIdIn(List<String> productIdList);
/**
* 扣库存
* @param carDTOList
*/
void decreaseStock(List<CarDTO> carDTOList);
}
| true
|
c3ea362c195bee06beeef8d8245ba004417462cb
|
Java
|
nomadsystem/NOMADS
|
/server_open/NomadServerThread.java
|
UTF-8
| 4,259
| 2.640625
| 3
|
[] |
no_license
|
import java.net.*;
import java.io.*;
import nomads.v210.*;
public class NomadServerThread extends Thread
{ private NomadServer server = null;
private Socket socket = null;
private int THREAD_ID = -1;
private int APP_ID = -1;
private String IP;
private String USER;
private Boolean loginStatus = false;
private DataInputStream streamIn = null;
private DataOutputStream streamOut = null;
private NGrain threadGrain;
public NSand threadSand;
private Boolean runState = true;
private Object runLock = new Object();
private Object threadIDLock = new Object();
public Boolean getRun() {
synchronized (runLock) {
return threadSand.getRun();
}
}
class MyException extends Exception {
public MyException(String msg){
super(msg);
}
}
public NomadServerThread(NomadServer _server, Socket _socket) {
super();
server = _server;
socket = _socket;
THREAD_ID = socket.getPort();
}
public Socket getSock() {
return socket;
}
public void sendUTF(String msg) {
try {
streamOut.writeUTF(msg);
streamOut.flush();
}
catch(IOException ioe) {
System.out.println(THREAD_ID + " ERROR sending: " + ioe.getMessage());
server.removeByThreadID(THREAD_ID);
stop();
}
}
public int getThreadID() {
synchronized (threadIDLock) {
return THREAD_ID;
}
}
private Object loginStatusLock = new Object();
public Boolean getLoginStatus() {
// System.out.println(" getLoginStatus(" + loginStatus + ")");
synchronized (loginStatusLock) {
return loginStatus;
}
}
public synchronized void setLoginStatus(Boolean status) {
// System.out.println("setLoginStatus(" + status + ")");
synchronized (loginStatusLock) {
loginStatus = status;
}
}
public int getAppID() {
return APP_ID;
}
public synchronized void setAppID(byte id) {
APP_ID = id;
}
public synchronized void setIP(String ip) {
IP = new String(ip);
// System.out.println(" setIP(" + IP + ")");
}
public String getIP() {
// System.out.println(" getIP(" + IP + ")");
return IP;
}
public synchronized void setUser(String u) {
// System.out.println(" setUser(" + u + ")");
USER = new String(u);
}
public String getUser() {
// System.out.println(" getUser(" + USER + ")");
return USER;
}
public synchronized void run() {
Boolean myRun = true;
System.out.println("Server Thread " + THREAD_ID + " running.");
while (myRun && threadSand.getRun()) {
try {
byte tByte = streamIn.readByte();
if (tByte > 0) {
NGlobals.dtPrint("THREAD " + getThreadID() + " : getGrain: read byte: " + tByte);
threadGrain = threadSand.getGrain(tByte);
//threadGrain.print();
NGlobals.dtPrint("THREAD " + getThreadID() + " : server->handle()");
if (threadSand.getRun()) {
NGlobals.dtPrint("THREAD " + getThreadID() + ": CAN RUN");
server.handle(THREAD_ID, threadGrain);
}
else {
NGlobals.dtPrint("THREAd " + getThreadID() + " : NO RUN - REMOVE");
myRun = false;
threadSand.setRun(false);
server.removeByThreadID(THREAD_ID);
// interrupt();
stop();
}
}
}
catch(IOException ioe) {
System.out.println("LOG, THREAD " + THREAD_ID + " ERROR reading: " + ioe.getMessage());
myRun = false;
threadSand.setRun(false);
server.removeByThreadID(THREAD_ID);
// interrupt();
stop();
}
}
}
public synchronized void open() throws IOException {
NGlobals.sPrint("NomadServerThread:open()");
threadSand = new NSand(socket);
threadSand.openSocketStreams();
streamIn = threadSand.getInStream();
streamOut = threadSand.getOutStream();
}
public synchronized void close() throws IOException {
threadSand.closeSocketStreams();
threadSand.disConnectSocket();
// if (socket != null)
// socket.close();
// if (streamIn != null)
// streamIn.close();
// if (streamOut != null)
// streamOut.close();
// threadSand.disconnect();
}
}
| true
|
44fbbb74b861ddea1e69801f6f2f970781ad7368
|
Java
|
SaltedByte/Java-School-Projects
|
/Knapsack.java
|
UTF-8
| 3,784
| 3.40625
| 3
|
[] |
no_license
|
//Andrew Lucas CSC364 Knapsack Assignment 2
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
public class Knapsack {
public static void main(String Args[]) throws FileNotFoundException {
//Grab the initial inputs needed
Scanner input = new Scanner(System.in);
System.out.print("Enter the number of available employee work weeks: ");
int workWeeks = input.nextInt();
System.out.print("Enter the name of input file: ");
String source = input.next();
System.out.print("Enter the name of output file: ");
String output = input.next();
input.close();
File sourceFile = new File(source);
//Gather the contents of the file
Scanner injector = new Scanner(sourceFile);
ArrayList<Project> list = new ArrayList<>();
while (injector.hasNextLine()) {
String line = injector.nextLine();
String[] split = line.split(" ");
list.add(new Project(split[0], Integer.parseInt(split[1]), Integer.parseInt(split[2])));
}
injector.close();
System.out.println("Number of Projects: " + list.size());
//Make the Matrix thing
System.out.println(list.get(2).labor);
int[][] matrix = new int[workWeeks + 1][list.size() + 1];
for (int i = 1; i < list.size() + 1; i++) {
for (int j = 1; j < workWeeks + 1; j++) {
if (list.get(i - 1).labor > j) {
matrix[j][i] = matrix[j][i - 1];
}
else {
matrix[j][i] = Math.max(matrix[j - list.get(i - 1).labor][i - 1] + list.get(i - 1).profit, matrix[j][i - 1]);
}
}
}
//To print out the matrix for testing
/*for (int[] z : matrix) {
System.out.println(Arrays.toString(z));
}*/
//here is where we have to actually read the matrix...
ArrayList<Integer> answer = new ArrayList<Integer>();
int row = workWeeks;
int col = list.size();
int cur= matrix[row][col];
while (cur!= 0) {
if (matrix[row][col] != matrix[row][col - 1]) {
answer.add(col - 1);
cur = matrix[row - (list.get(col - 1).labor)][col];
row = row - list.get(col -1).labor;
col--;
}
else {
cur = matrix[row][col - 1];
col--;
}
}
int total = 0;
for (int i = 0; i <= answer.size() - 1; i++) {
total += list.get(answer.get(i)).profit;
}
//Writes the file
PrintWriter Writer = new PrintWriter(output);
Writer.println("Number of projects available: " + list.size() + " projects");
Writer.println("Available employee work weeks: " + workWeeks + " weeks");
Writer.println("Number of projects chosen: " + answer.size());
Writer.println("Total profit: $" + total);
for (int i = answer.size() - 1; i >= 0; i--) {
Writer.println(list.get(answer.get(i)).name + " " + list.get(answer.get(i)).labor + " " + list.get(answer.get(i)).profit);
}
//Done and tidy
Writer.close();
System.out.println("Done");
}
//object constructor to store the projects
private static class Project {
String name;
int labor;
int profit;
public Project(String name, int labor, int profit) {
this.name = name;
this.labor = labor;
this.profit = profit;
}
}
}
| true
|
0d268e61ce455fe0a45a82af896794b2e5514b60
|
Java
|
MewX/contendo-viewer-v1.6.3
|
/org/apache/http/protocol/ResponseServer.java
|
UTF-8
| 1,748
| 1.890625
| 2
|
[
"SMLNJ",
"Apache-1.1",
"Apache-2.0",
"BSD-2-Clause"
] |
permissive
|
/* */ package org.apache.http.protocol;
/* */
/* */ import java.io.IOException;
/* */ import org.apache.http.HttpException;
/* */ import org.apache.http.HttpResponse;
/* */ import org.apache.http.HttpResponseInterceptor;
/* */ import org.apache.http.annotation.Contract;
/* */ import org.apache.http.annotation.ThreadingBehavior;
/* */ import org.apache.http.util.Args;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Contract(threading = ThreadingBehavior.IMMUTABLE)
/* */ public class ResponseServer
/* */ implements HttpResponseInterceptor
/* */ {
/* */ private final String originServer;
/* */
/* */ public ResponseServer(String originServer) {
/* 55 */ this.originServer = originServer;
/* */ }
/* */
/* */ public ResponseServer() {
/* 59 */ this(null);
/* */ }
/* */
/* */
/* */
/* */ public void process(HttpResponse response, HttpContext context) throws HttpException, IOException {
/* 65 */ Args.notNull(response, "HTTP response");
/* 66 */ if (!response.containsHeader("Server") &&
/* 67 */ this.originServer != null)
/* 68 */ response.addHeader("Server", this.originServer);
/* */ }
/* */ }
/* Location: /mnt/r/ConTenDoViewer.jar!/org/apache/http/protocol/ResponseServer.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/
| true
|
19d3634665eb7a4974c3c86b7a560979babdc6f5
|
Java
|
rohityadavnotes/AddToCartUsingJava
|
/app/src/main/java/com/add/to/cart/ui/product/ProductViewModel.java
|
UTF-8
| 1,417
| 2.1875
| 2
|
[] |
no_license
|
package com.add.to.cart.ui.product;
import android.content.Context;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.ViewModel;
import com.add.to.cart.data.local.entity.Cart;
import com.add.to.cart.data.local.entity.Product;
import com.add.to.cart.data.local.relations.ProductWithCart;
import com.add.to.cart.data.repository.LocalRepository;
import java.util.Date;
import java.util.List;
public class ProductViewModel extends ViewModel {
private LocalRepository repository;
private LiveData<List<Product>> productList;
public ProductViewModel(Context context) {
repository = new LocalRepository(context);
productList = repository.getListOfProduct();
}
public void insertProduct(Product product) {
repository.insertProduct(product);
}
public LiveData<List<Product>> getListOfProduct() {
return productList;
}
public LiveData<List<ProductWithCart>> getListOfProductWithCart() {
return repository.getListOfProductWithCart();
}
public void insertCart(Cart cart) {
repository.insertCart(cart);
}
public void updateQuantity(int quantity, int totalPrice, Date updatedAt, int cartId) {
repository.updateQuantity(quantity, totalPrice, updatedAt, cartId);
}
public LiveData<Integer> getNumberOfProductAddedIntoCart() {
return repository.getNumberOfProductAddedIntoCart();
}
}
| true
|
15a43160d7f0c4e5aaf9ae7540229566ed456930
|
Java
|
MayconErhardt/depositoDeBebidas
|
/src/controle/ControleProduto.java
|
UTF-8
| 8,540
| 2.546875
| 3
|
[] |
no_license
|
/*
* 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 controle;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import modelo.Produto;
import modelo.Venda;
/**
*
* @author Maycon
*/
public class ControleProduto {
public void gravarNovo(Produto Novo) {
// Identificador para objeto que gerencia uma entidade(acesso ao banco)
EntityManager gerente = fabrica.gerente.criarGerente();
// gravar o objeto cliente recebido como parâmetro no banco de dados
// iniciar transação
gerente.getTransaction().begin();
// persistir o objeto no banco
gerente.persist(Novo);
// fazer um commit (salvar realmente no banco) na transação
gerente.getTransaction().commit();
// finalizar a conexão
gerente.close();
}
public List<Produto> listarTodos() {
// lista de usuários a ser retornada
List<Produto> listaUsuarios;
// criar uma conexão com o banco - gerente de entidades
EntityManager gerente = fabrica.gerente.criarGerente();
// Criar um identificar para uma consulta SQL
TypedQuery<Produto> consultaUsuarios;
// criar a consulta
consultaUsuarios = gerente.createNamedQuery("Produto.findAll", Produto.class);
// pegar o resultado da consulta realizada
listaUsuarios = consultaUsuarios.getResultList();
return listaUsuarios;
}
public void salvarAlteracao(Produto funcionario) {
// criar um gerente de entidades
EntityManager gerente = fabrica.gerente.criarGerente();
// iniciar uma transação com o banco
gerente.getTransaction().begin();
//salvar a alteração no banco de dados
// merge sobrepõe um registro no banco de dados com base na
//chave primária da entidade
gerente.merge(funcionario);
// finalizar a transação com o banco
gerente.getTransaction().commit();
// fecho a conexão
gerente.close();
}
public List<Produto> nomeIgual(String nomeProcurar) {
EntityManager gerente = fabrica.gerente.criarGerente();
TypedQuery<Produto> consulta
= gerente.createNamedQuery("Produto.nomeIgual", Produto.class);
consulta.setParameter("nomeProd", nomeProcurar);
return consulta.getResultList();
}
public void excluir(int codigo) throws NaoExisteException, IntegridadeException{
// cria uma conexão com o banco
EntityManager gerente = fabrica.gerente.criarGerente();
boolean encontrado;
// criando um identificador para um objeto usuário
Produto produto;
// pego o usuário que possui o código passado do banco de
// dados
produto = gerente.find(Produto.class, codigo);
// se o usuário não foi encontrado
if (produto == null) {
throw new NaoExisteException("Este Produto nao existe");
} else {
try{
// inicia uma transação
gerente.getTransaction().begin();
//excluir o usuário do banco de dados
gerente.remove(produto);
// finaliza a transação
gerente.getTransaction().commit();
// fechar a conexão
gerente.close();
}catch(Exception e){
throw new IntegridadeException("Não foi possível excluir o produto: "+ produto.getProdutoNome()+" ");
}
}
}
public List<Produto> listarPorNome(String nomeProcurar) {
EntityManager gerente = fabrica.gerente.criarGerente();
TypedQuery<Produto> consulta
= gerente.createNamedQuery("Produto.findByProdutoNome", Produto.class);
consulta.setParameter("prodNome", "%" + nomeProcurar + "%");
return consulta.getResultList();
}
public List<Produto> listarPorNomeEstoque(String nomeProcurar) {
EntityManager gerente = fabrica.gerente.criarGerente();
TypedQuery<Produto> consulta
= gerente.createNamedQuery("Produto.findByProdutoNomeEstoque", Produto.class);
consulta.setParameter("prodNome", "%" + nomeProcurar + "%");
return consulta.getResultList();
}
public List<Produto> listarTodosEstoque() {
// lista de usuários a ser retornada
List<Produto> listaUsuarios;
// criar uma conexão com o banco - gerente de entidades
EntityManager gerente = fabrica.gerente.criarGerente();
// Criar um identificar para uma consulta SQL
TypedQuery<Produto> consultaUsuarios;
// criar a consulta
consultaUsuarios = gerente.createNamedQuery("Produto.produtoQuantEstoque", Produto.class);
// pegar o resultado da consulta realizada
listaUsuarios = consultaUsuarios.getResultList();
return listaUsuarios;
}
public Produto buscaCod(int x) {
EntityManager gerente = fabrica.gerente.criarGerente();
//boolean encontrado;
// criando um identificador para um objeto usuário
Produto p;
// pego o usuário que possui o código passado do banco de
// dados
p = gerente.find(Produto.class, x);
return p;
}
public void devolverProduto(Produto x, Venda v) {
EntityManager gerente = fabrica.gerente.criarGerente();
//boolean encontrado;
// criando um identificador para um objeto usuário
Produto p;
// pego o usuário que possui o código passado do banco de
// dados
p = x;
gerente.getTransaction().begin();
p = gerente.find(Produto.class, x.getProdutoId());
Venda vendaAt = gerente.find(Venda.class, v.getVendaCod());
gerente.merge(v);
p.setProdutoQuantidade(p.getProdutoQuantidade() + x.getProdutoQuantidade());
gerente.merge(p);
gerente.getTransaction().commit();
// fecho a conexão
gerente.close();
}
public List<Produto> produtoVencimento(Date dataIni, Calendar dataFim) {
EntityManager gerente = fabrica.gerente.criarGerente();
TypedQuery<Produto> consulta = gerente.createNamedQuery("Produto.produtoVencimento", Produto.class);
Date hoje = new Date();
consulta.setParameter("dataIni", dataIni);
consulta.setParameter("dataFim", dataFim);
return consulta.getResultList();
}
public void gravarNovoETirarEstoque(Produto Novo, Produto produto) {
// Identificador para objeto que gerencia uma entidade(acesso ao banco)
EntityManager gerente = fabrica.gerente.criarGerente();
// gravar o objeto cliente recebido como parâmetro no banco de dados
// iniciar transação
gerente.getTransaction().begin();
produto.setProdutoQuantidade(produto.getProdutoQuantidade() - Novo.getProdutoQuantidade());
gerente.merge(produto);
// persistir o objeto no banco
gerente.persist(Novo);
// fazer um commit (salvar realmente no banco) na transação
gerente.getTransaction().commit();
// finalizar a conexão
gerente.close();
}
public List<Produto> buscarNomeProdutoPromocao(String nomeProcurar) {
EntityManager gerente = fabrica.gerente.criarGerente();
TypedQuery<Produto> consulta
= gerente.createNamedQuery("Produto.nomeIgual", Produto.class);
consulta.setParameter("nomeProd", nomeProcurar);
return consulta.getResultList();
}
public void alterarPorNomePromocao(Produto nomeIgual, Produto produto, Produto prod) {
EntityManager gerente = fabrica.gerente.criarGerente();
Produto p;
gerente.getTransaction().begin();
p = gerente.find(Produto.class, prod.getProdutoId());
p.setProdutoQuantidade(p.getProdutoQuantidade()-produto.getProdutoQuantidade());
gerente.merge(p);
nomeIgual.setProdutoQuantidade(nomeIgual.getProdutoQuantidade()+produto.getProdutoQuantidade());
nomeIgual.setProdutoValorVenda(produto.getProdutoValorVenda());
gerente.merge(nomeIgual);
gerente.getTransaction().commit();
gerente.close();
}
}
| true
|
2a8db9d2dbff9d196a5e29f3df9fe0de8cdfe869
|
Java
|
Dreamer206602/LoveWall
|
/app/src/main/java/com/confress/lovewall/Activity/UserSettingActivity.java
|
UTF-8
| 5,511
| 2.015625
| 2
|
[] |
no_license
|
package com.confress.lovewall.Activity;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.confress.lovewall.Fragment.HomeFragment4;
import com.confress.lovewall.R;
import com.confress.lovewall.Utils.PhotoViewUtils;
import com.confress.lovewall.Utils.T;
import com.confress.lovewall.model.User;
import com.confress.lovewall.presenter.AtyPresenter.UserSettingActivityPresenter;
import com.confress.lovewall.presenter.FragmentPresenter.HomeFragment4Presenter;
import com.confress.lovewall.view.AtyView.IUserSettingView;
import butterknife.Bind;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;
/**
* Created by admin on 2016/3/14.
*/
public class UserSettingActivity extends Activity implements View.OnClickListener, IUserSettingView {
@Bind(R.id.user_icon)
CircleImageView userIcon;
@Bind(R.id.tv_progress)
TextView tvprogress;
@Bind(R.id.change_image)
LinearLayout changeImage;
@Bind(R.id.nickname)
EditText nickname;
@Bind(R.id.sex)
EditText sex;
@Bind(R.id.age)
EditText age;
@Bind(R.id.tel)
EditText tel;
@Bind(R.id.submit)
Button submit;
//相册寻找照片
private static final int IMAGE_REQUEST_CODE1 = 0;
//拍照
private static final int IMAGE_REQUEST_CODE2 = 0;
private UserSettingActivityPresenter userSettingActivityPresenter=new UserSettingActivityPresenter(this,UserSettingActivity.this);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.usersetting_main);
ButterKnife.bind(this);
changeImage.setOnClickListener(this);
submit.setOnClickListener(this);
userSettingActivityPresenter.ShowUserData();
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.submit:
userSettingActivityPresenter.UpdataUserData();
Intent intent2=new Intent();
intent2.putExtra("nickname",getNickName());
intent2.putExtra("icon",getCurrentUser().getIcon());
UserSettingActivity.this.setResult(1, intent2);
UserSettingActivity.this.finish();
break;
case R.id.change_image:
//更换照片
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, IMAGE_REQUEST_CODE1);
break;
}
}
@Override
public String getNickName() {
return nickname.getText().toString();
}
@Override
public void setNickName(User user) {
nickname.setText(user.getNick());
}
@Override
public String getSex() {
return sex.getText().toString();
}
@Override
public void setSex(User user) {
sex.setText(user.getSex());
}
@Override
public int getAge() {
return Integer.parseInt(age.getText().toString());
}
@Override
public void setAge(User user) {
age.setText(user.getAge() + "");
}
@Override
public String getTel() {
return tel.getText().toString();
}
@Override
public void setTel(User user) {
tel.setText(user.getTel());
}
@Override
public String getUserIcon(User user) {
return user.getIcon();
}
@Override
public void setUserIcon(User user) {
if (TextUtils.isEmpty(user.getIcon())){
userIcon.setImageResource(R.drawable.wall);
}else {
Glide.with(UserSettingActivity.this).load(user.getIcon()).into(userIcon);
}
}
@Override
public User getCurrentUser() {
return User.getCurrentUser(UserSettingActivity.this, User.class);
}
@Override
public void Success() {
T.showShort(UserSettingActivity.this, "更新个人信息成功!");
}
@Override
public void Failure() {
T.showShort(UserSettingActivity.this, "更新个人信息失败!");
}
@Override
public void UploadIconSuccess() {
T.showShort(UserSettingActivity.this, "更新头像成功!");
}
@Override
public void UploadIconFailure() {
T.showShort(UserSettingActivity.this, "更新头像失败!");
}
@Override
public void showtvProgress(int progress) {
tvprogress.setText(progress + "%");
}
@Override
public void successTvprogress() {
tvprogress.setText("更新头像");
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == IMAGE_REQUEST_CODE1) {
if (data == null) {
return;
} else {
Uri uri = data.getData();
Uri imageUri = PhotoViewUtils.convertUri(uri, "confress", UserSettingActivity.this);
userIcon.setImageURI(imageUri);
userSettingActivityPresenter.updateIcon(PhotoViewUtils.getImagePath());
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
userSettingActivityPresenter=null;
}
}
| true
|
603ab60d889c3d651a46a3ee43e8373a72b38624
|
Java
|
rob-c/rapid_fit_gui
|
/src/rapidFit/main/XMLIOException.java
|
UTF-8
| 633
| 2.421875
| 2
|
[] |
no_license
|
package rapidFit.main;
@SuppressWarnings("serial")
public class XMLIOException extends RapidFitException {
public enum ErrorType {
WRITE_FILE_ERROR,
READ_FILE_ERROR,
XML_PARSING_ERROR,
WRITE_XML_SCHEMA_VALIDATION_ERROR,
READ_XML_SCHEMA_VALIDATION_ERROR,
READ_SCHEMA_ERROR,
INTERNAL_ERROR,
UNKNOWN_ERROR
}
private ErrorType error;
public XMLIOException(Exception e, ErrorType type){
super(e, null);
error = type;
}
public XMLIOException(Exception e, ErrorType type, String msg){
super(e, msg);
error = type;
}
public ErrorType getErrorType(){return error;}
}
| true
|
9f9bc7151b2481a4c90492338f43cf9708bbe779
|
Java
|
okanmenevseoglu/mancala-game
|
/mancala-api/src/test/java/io/github/okanmenevseoglu/mancalagameapi/service/rules/validation/CurrentPlayerNonEmptyPitRuleTest.java
|
UTF-8
| 2,548
| 2.484375
| 2
|
[] |
no_license
|
package io.github.okanmenevseoglu.mancalagameapi.service.rules.validation;
import io.github.okanmenevseoglu.mancalagameapi.model.Board;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.junit.jupiter.MockitoExtension;
import static org.assertj.core.api.Assertions.assertThat;
/**
* A unit test class that contains the tests of the {@link CurrentPlayerNonEmptyPitValidationRule} class.
*/
@ExtendWith(MockitoExtension.class)
class CurrentPlayerNonEmptyPitRuleTest {
@InjectMocks
private CurrentPlayerNonEmptyPitValidationRule rule;
@Test
void shouldValidateCurrentPlayerNonEmptyPitRule() {
Board board = new Board();
assertThat(rule.isValidated(board, -1)).isFalse();
assertThat(rule.isValidated(board, 6)).isFalse();
assertThat(rule.isValidated(board, 7)).isFalse();
assertThat(rule.isValidated(board, 13)).isFalse();
board.setCurrentPlayer(board.getPlayer2());
assertThat(rule.isValidated(board, -1)).isFalse();
assertThat(rule.isValidated(board, 5)).isFalse();
assertThat(rule.isValidated(board, 6)).isFalse();
assertThat(rule.isValidated(board, 13)).isFalse();
board.setStonesForGivenPitIndex(2, 1);
board.setCurrentPlayer(board.getPlayer1());
assertThat(rule.isValidated(board, 0)).isTrue();
assertThat(rule.isValidated(board, 1)).isTrue();
assertThat(rule.isValidated(board, 2)).isTrue();
assertThat(rule.isValidated(board, 3)).isTrue();
assertThat(rule.isValidated(board, 4)).isTrue();
assertThat(rule.isValidated(board, 5)).isTrue();
board.setCurrentPlayer(board.getPlayer2());
assertThat(rule.isValidated(board, 7)).isTrue();
assertThat(rule.isValidated(board, 8)).isTrue();
assertThat(rule.isValidated(board, 9)).isTrue();
assertThat(rule.isValidated(board, 10)).isTrue();
assertThat(rule.isValidated(board, 11)).isTrue();
assertThat(rule.isValidated(board, 12)).isTrue();
board.setStonesForGivenPitIndex(2, 0);
board.setCurrentPlayer(board.getPlayer1());
assertThat(rule.isValidated(board, 0)).isTrue();
assertThat(rule.isValidated(board, 1)).isTrue();
assertThat(rule.isValidated(board, 2)).isFalse();
}
@Test
void shouldGetMessage() {
Board board = new Board();
assertThat(rule.getMessage(board)).isEqualTo("It is Player ONE's turn.");
}
}
| true
|
00bad729edbbfb3d54bf991dc1cb7575fec87a7e
|
Java
|
Hellhound732/Bewitchment
|
/src/main/java/com/bewitchment/common/core/event/TransformationEvents.java
|
UTF-8
| 3,190
| 1.96875
| 2
|
[
"MIT"
] |
permissive
|
package com.bewitchment.common.core.event;
import com.bewitchment.api.BewitchmentAPI;
import com.bewitchment.api.transformation.DefaultTransformations;
import com.bewitchment.common.core.capability.transformation.CapabilityTransformationData;
import com.bewitchment.common.core.capability.transformation.ITransformationData;
import com.bewitchment.common.core.capability.transformation.TransformationDataProvider;
import com.bewitchment.common.core.helper.TransformationHelper;
import com.bewitchment.common.core.hotbar.HotbarAction;
import com.bewitchment.common.core.net.NetworkHandler;
import com.bewitchment.common.core.net.messages.EntityInternalBloodChanged;
import com.bewitchment.common.core.net.messages.NightVisionStatus;
import com.bewitchment.common.core.net.messages.PlayerTransformationChangedMessage;
import com.bewitchment.common.core.net.messages.PlayerVampireBloodChanged;
import com.bewitchment.common.lib.LibMod;
import com.bewitchment.common.potion.ModPotions;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
public class TransformationEvents {
public static final ResourceLocation PLAYER_DATA = new ResourceLocation(LibMod.MOD_ID, "transformations");
@SubscribeEvent
public void attachCapability(AttachCapabilitiesEvent<Entity> event) {
if (event.getObject() instanceof EntityPlayer) {
event.addCapability(PLAYER_DATA, new TransformationDataProvider());
}
}
@SubscribeEvent
public void onPlayerRespawn(PlayerEvent.Clone event) {
ITransformationData data = event.getOriginal().getCapability(CapabilityTransformationData.CAPABILITY, null);
BewitchmentAPI.getAPI().setTypeAndLevel(event.getEntityPlayer(), data.getType(), data.getLevel(), false);
if (event.isWasDeath()) {
TransformationHelper.setVampireBlood(event.getEntityPlayer(), (int) (data.getMaxBlood() * 0.1));
if (data.getType() == DefaultTransformations.VAMPIRE) {
event.getEntityPlayer().addPotionEffect(new PotionEffect(ModPotions.sun_ward, 600, 0));
}
} else {
TransformationHelper.setVampireBlood(event.getEntityPlayer(), data.getMaxBlood());
}
HotbarAction.refreshActions(event.getEntityPlayer(), event.getEntityPlayer().world);
}
@SubscribeEvent
public void onPlayerJoin(PlayerLoggedInEvent evt) {
if (evt.player instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) evt.player;
NetworkHandler.HANDLER.sendTo(new PlayerTransformationChangedMessage(player), player);
NetworkHandler.HANDLER.sendTo(new PlayerVampireBloodChanged(player), player);
NetworkHandler.HANDLER.sendTo(new EntityInternalBloodChanged(player), player);
NetworkHandler.HANDLER.sendTo(new NightVisionStatus(player.getCapability(CapabilityTransformationData.CAPABILITY, null).isNightVisionActive()), player);
}
}
}
| true
|
854db98f2a32daf80ec967cef4cfe58357e6f3b2
|
Java
|
RyanOliveiraCastro/LPR-Back
|
/src/main/java/edu/ifes/ci/si/les/lpr/services/ComissaoService.java
|
UTF-8
| 558
| 2.0625
| 2
|
[] |
no_license
|
package edu.ifes.ci.si.les.lpr.services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import edu.ifes.ci.si.les.lpr.model.Comissao;
import edu.ifes.ci.si.les.lpr.repositories.ComissaoRepository;
@Service
public class ComissaoService {
@Autowired
private ComissaoRepository comissaoRepository;
public Comissao salvar(Comissao comissao) {
return comissaoRepository.save(comissao);
}
public void excluir(Long comissaoId) {
comissaoRepository.deleteById(comissaoId);
}
}
| true
|
11e559b6be333b58ad8eb69191b3acc651791505
|
Java
|
VijayEluri/rsstotwitter
|
/src/main/java/nz/gen/wellington/rsstotwitter/repositories/mongo/MongoTwitterAccountDAO.java
|
UTF-8
| 962
| 2.09375
| 2
|
[] |
no_license
|
package nz.gen.wellington.rsstotwitter.repositories.mongo;
import nz.gen.wellington.rsstotwitter.model.TwitterAccount;
import nz.gen.wellington.rsstotwitter.repositories.AccountDAO;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class MongoTwitterAccountDAO implements AccountDAO {
private final static Logger log = Logger.getLogger(MongoTwitterAccountDAO.class);
private DataStoreFactory dataStoreFactory;
@Autowired
public MongoTwitterAccountDAO(DataStoreFactory dataStoreFactory) {
this.dataStoreFactory = dataStoreFactory;
}
@Override
public void saveAccount(TwitterAccount account) {
dataStoreFactory.getDs().save(account);
}
@Override
public TwitterAccount getUserByTwitterId(long id) {
return dataStoreFactory.getDs().find(TwitterAccount.class, "id", id).get();
}
}
| true
|
50bc80227eb08e5c6f6f84c9c566a55df87810b5
|
Java
|
KINGOFAURORA/aurora
|
/aurora-service/src/main/java/com/aurora/leetcode/Question3.java
|
UTF-8
| 1,783
| 3.765625
| 4
|
[] |
no_license
|
package com.aurora.leetcode;
import java.util.HashSet;
import java.util.Set;
/**
* 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。
* <p>
* 示例 1:
* <p>
* 输入: "abcabcbb"
* 输出: 3
* 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。
* 示例 2:
* <p>
* 输入: "bbbbb"
* 输出: 1
* 解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。
* 示例 3:
* <p>
* 输入: "pwwkew"
* 输出: 3
* 解释: 因为无重复字符的最长子串是 "wke",所以其长度为 3。
* 请注意,你的答案必须是 子串 的长度,"pwke" 是一个子序列,不是子串。
* <p>
* 来源:力扣(LeetCode)
* 链接:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters
* 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
*/
public class Question3 {
public static int lengthOfLongestSubstring(String s) {
int length = 0;
String[] ss = s.split("");
for (int i = 0; i < ss.length; i++) {
Set<String> charSet = new HashSet<>();
charSet.add(ss[i]);
int templength = 1;
for (int j = i + 1; j < ss.length; j++) {
if (!charSet.contains(ss[j])) {
charSet.add(ss[j]);
templength++;
} else {
if (templength > length) {
length = templength;
}
break;
}
}
}
return length;
}
public static void main(String[] args) {
System.out.println(lengthOfLongestSubstring("abcabcbb"));
}
}
| true
|
8c1399b248be9dc6f240e84dc6db04d733069463
|
Java
|
Janchu/Pizzicato_6G1C
|
/Pizzicato_6G1C/src/pizzicato/control/PoistaTayteServlet.java
|
UTF-8
| 1,771
| 2.390625
| 2
|
[] |
no_license
|
package pizzicato.control;
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;
import pizzicato.model.Tayte;
import pizzicato.model.dao.TayteDAO;
/**
* Servlet implementation class PoistaTayteServlet
*/
@WebServlet("/PoistaTayteServlet")
public class PoistaTayteServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// Pyydetään poistettavan täytteen id muokkaa-taytelista.jsp:ltä ja
// muutetaan se oikeaan muotoon.
String poistettavaTayteIdStr = request.getParameter("TayId");
int poistettavaTayteId = new Integer(poistettavaTayteIdStr);
// Luodaan tayteDAO johon haetaan täytteet kannasta.
TayteDAO taytedao = new TayteDAO();
// Pyydetään jsp:ltä mukana kuljetettu poistettavan täytteen id ja
// alustetaan muut nolliksi
String nimi = "";
String nimi_eng = "";
double hinta = 0;
double kilohinta = 0;
try {
// Luodaan Täyte-olio
Tayte poistettavatayte = new Tayte(poistettavaTayteId, nimi,
nimi_eng, hinta, kilohinta);
// Kutsutaan deleteTayte-metodia
taytedao.deleteTayte(poistettavatayte);
} catch (Exception e) {
System.out.println(e.getMessage());
}
// Palautetaan käyttäjä täytelistan muokkaustilaan.
response.sendRedirect("MuokkaaTaytelistaServlet");
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
}
}
| true
|
b8886d3aaf6dca54e04216a0c2f688fbc5719214
|
Java
|
andylx96/IST261
|
/src/ViewAllSearchPanel.java
|
UTF-8
| 1,482
| 2.5625
| 3
|
[] |
no_license
|
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
public class ViewAllSearchPanel extends JPanel {
JButton deleteButton, editButton, saveEditButton;
public ViewAllSearchPanel() {
setLayout(new GridLayout(10,1));
deleteButton = new JButton("Delete");
editButton = new JButton("Edit");
saveEditButton = new JButton("Save\nEdits");
add(deleteButton);
// add(editButton);
add(saveEditButton);
}
public void addDeleteButtonListener(ActionListener al) {
this.deleteButton.addActionListener(al);
}
public void addEditButtonListener(ActionListener al) {
this.editButton.addActionListener(al);
}
public void addSaveEditButtonListener(ActionListener al) {
this.saveEditButton.addActionListener(al);
}
public JButton getEditButton() {
return editButton;
}
public void setEditButton(JButton editButton) {
this.editButton = editButton;
}
public JButton getSaveEditButton() {
return saveEditButton;
}
public void setSaveEditButton(JButton saveEditButton) {
this.saveEditButton = saveEditButton;
}
public JButton getDeleteButton() {
return deleteButton;
}
public void setDeleteButton(JButton deleteButton) {
this.deleteButton = deleteButton;
}
}
| true
|
7c10b6afe2a9091b9cb6dbefaba40e537ea79bf2
|
Java
|
nmldiegues/stibt
|
/infinispan/core/src/main/java/org/infinispan/commands/write/EvictCommand.java
|
UTF-8
| 2,809
| 1.726563
| 2
|
[
"Apache-2.0",
"LGPL-2.0-or-later"
] |
permissive
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2009 Red Hat Inc. and/or its affiliates and other
* contributors as indicated by the @author tags. All rights reserved.
* See the copyright.txt in the distribution for a full listing of
* individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.infinispan.commands.write;
import org.infinispan.commands.LocalCommand;
import org.infinispan.commands.Visitor;
import org.infinispan.context.Flag;
import org.infinispan.context.InvocationContext;
import org.infinispan.notifications.cachelistener.CacheNotifier;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
import java.util.Set;
/**
* @author Mircea.Markus@jboss.com
* @since 4.0
*/
public class EvictCommand extends RemoveCommand implements LocalCommand {
private static final Log log = LogFactory.getLog(EvictCommand.class);
public EvictCommand(Object key, CacheNotifier notifier, Set<Flag> flags) {
super(key, null, notifier, flags);
}
@Override
public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable {
return visitor.visitEvictCommand(ctx, this);
}
@Override
public Object perform(InvocationContext ctx) throws Throwable {
if (key == null) {
throw new NullPointerException("Key is null!!");
}
super.perform(ctx);
return null;
}
@Override
public void notify(InvocationContext ctx, Object value, boolean isPre) {
if (!isPre) {
if (log.isTraceEnabled())
log.tracef("Notify eviction listeners for key=%", key);
notifier.notifyCacheEntryEvicted(key, value, ctx);
}
}
@Override
public byte getCommandId() {
return -1; // these are not meant for replication!
}
@Override
public String toString() {
return new StringBuilder()
.append("EvictCommand{key=")
.append(key)
.append(", value=").append(value)
.append(", flags=").append(flags)
.append("}")
.toString();
}
}
| true
|
ac561167b6061cab5d7039c362f68a30f9963888
|
Java
|
EstefaniaCC/NWSim
|
/NWSim/src/sim/dto/ColumnComb.java
|
UTF-8
| 2,458
| 3.328125
| 3
|
[] |
no_license
|
package sim.dto;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;
/**
* To create the combination of elements from an arraylist.
*
* @see Serializable
* @author Sadiya
*
*/
public class ColumnComb implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1058486567683333347L;
ArrayList<Float> combinations;
/**
* Creates a column instance for a matrix
* @param builder -required to create instance
*/
private ColumnComb(Builder builder) {
this.combinations = builder.combinations;
}
public ArrayList<Float> getCombinations() {
return combinations;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((combinations == null) ? 0 : combinations.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ColumnComb other = (ColumnComb) obj;
if (combinations == null) {
if (other.combinations != null)
return false;
} else if (!combinations.equals(other.combinations))
return false;
return true;
}
@Override
public String toString() {
return "ColumnComb [combinations=" + combinations + "]";
}
/**
* It is a builder class to built collumns.
* @author Sadiya
*
*/
public static class Builder{
// r is the number of combinations
private int r;
// List of combinations column value
private ArrayList<Float> combinations;
/**
* This is the constructor creatorbuilder class for collumns
* @param r - number of combination
*/
public Builder(int r) {
this.r = r;
this.combinations = new ArrayList<>(r);
}
/**
* To built first set of rows
* @param row- first r row values
* @return - buildr instance
*/
public Builder setRows(float row){
IntStream.range(0, r-1).forEach(i -> {
combinations.add(i,row);
});
return this;
}
/**
* This method to set instance of column
* @param column- passed last set of combination
* @return - builder instance
*/
public Builder setColumns(float column){
combinations.add(r-1,column);
return this;
}
/**
* This method creates a column instance
* @return -column instance
*/
public ColumnComb build(){
return new ColumnComb(this);
}
}
}
| true
|
3fe617a8aa913c057f580c44d4e648e7e4c1dddd
|
Java
|
zhongxingyu/Seer
|
/Diff-Raw-Data/22/22_34a8e67e7628665d2996d0b00ab843d2eb2ddd78/SpinnerWrapper/22_34a8e67e7628665d2996d0b00ab843d2eb2ddd78_SpinnerWrapper_t.java
|
UTF-8
| 1,920
| 2.34375
| 2
|
[] |
no_license
|
package ch.amana.android.cputuner.view.widget;
import java.util.HashSet;
import java.util.Set;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import ch.amana.android.cputuner.helper.GuiUtils;
public class SpinnerWrapper implements OnItemSelectedListener {
private static final int INITIAL = Integer.MIN_VALUE;
private final Spinner spinner;
private final Set<OnItemSelectedListener> listeners = new HashSet<AdapterView.OnItemSelectedListener>();
private int possition = INITIAL;
public SpinnerWrapper(Spinner spinner) {
this.spinner = spinner;
spinner.setOnItemSelectedListener(this);
}
public void setAdapter(SpinnerAdapter adapter) {
spinner.setAdapter(adapter);
if (possition != INITIAL) {
spinner.setSelection(possition);
}
}
public void setOnItemSelectedListener(OnItemSelectedListener onItemSelectedListener) {
listeners.add(onItemSelectedListener);
}
public void setSelection(int i) {
possition = i;
spinner.setSelection(i);
}
public void setSelectionDbId(long id) {
possition = GuiUtils.setSpinner(spinner, id);
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
if (pos == INITIAL || view == null || parent == null) {
// the spinner has been initalised to this value (no need to set it)
return;
}
possition = pos;
for (OnItemSelectedListener listener : listeners) {
if (listener != null) {
listener.onItemSelected(parent, view, pos, id);
}
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
for (OnItemSelectedListener listener : listeners) {
listener.onNothingSelected(parent);
}
}
public SpinnerAdapter getAdapter() {
return spinner.getAdapter();
}
}
| true
|
dcf51d658fe38e1376aafe833b17bc85c8128f20
|
Java
|
intrepiddhole/OfflineMap
|
/app/src/main/java/com/gps/offlinenavigation/map/routedirection/free/model/util/Calorie.java
|
UTF-8
| 822
| 2.28125
| 2
|
[] |
no_license
|
package com.gps.offlinenavigation.map.routedirection.free.model.util;
public class Calorie {
public static final double bicycling = 8.0D;
public static final double running = 7.0D;
public static final double walking = 3.0D;
public static final double weightKg = 77.0D;
public Calorie() {
}
public static double CalorieBurned(double var0, double var2) {
return CalorieBurned(var0, 77.0D, var2);
}
public static double CalorieBurned(double var0, double var2, double var4) {
return var0 * var2 * var4;
}
public static double CalorieBurned(double var0, double var2, double var4, double var6, double var8, boolean var10) {
return var10?(88.362D + 13.397D * var2 + 4.799D * var6 - 5.677D * var8) * var0 * var4:(447.593D + 9.247D * var2 + 3.098D * var6 - 4.33D * var8) * var0 * var4;
}
}
| true
|
0a4b2b16d8c1d0db5e8dd9ebe54fa02ee96d752e
|
Java
|
rexendz/bfarmobile
|
/app/src/main-bak/java/com/adzu/bfarmobile/activities/MainActivity.java
|
UTF-8
| 17,833
| 1.75
| 2
|
[] |
no_license
|
package com.adzu.bfarmobile.activities;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.adzu.bfarmobile.R;
import com.adzu.bfarmobile.entities.Account;
import com.adzu.bfarmobile.entities.DatabaseUtil;
import com.adzu.bfarmobile.entities.FishpondOperator;
import com.adzu.bfarmobile.entities.OnGetDataListener;
import com.adzu.bfarmobile.fragments.AccountFragment;
import com.adzu.bfarmobile.fragments.AddOperatorFragment;
import com.adzu.bfarmobile.fragments.ListFragment;
import com.adzu.bfarmobile.fragments.ProfileFragment;
import com.google.android.material.navigation.NavigationView;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.miguelcatalan.materialsearchview.MaterialSearchView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import net.cachapa.expandablelayout.ExpandableLayout;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, RadioGroup.OnCheckedChangeListener {
private static final String TAG = "AWIT";
private DrawerLayout drawer;
private ExpandableLayout expandableLayout;
private NavigationView navigationView;
private MaterialSearchView searchView;
private Spinner spinner;
private RadioGroup rg1, rg2;
private int filter = 0;
private int statusfilter = 0;
private boolean profile_exists = false;
private ListFragment fragment1;
private AddOperatorFragment fragment2;
private AccountFragment fragment3;
private ProfileFragment fragment4;
private FrameLayout fragmentContainer;
private String lastSearchText = "";
private Toolbar toolbar;
private FrameLayout searchContainer;
private Account user;
private Context ctx;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ctx = this;
spinner = findViewById(R.id.filter_active);
rg1 = findViewById(R.id.filtergroup);
rg2 = findViewById(R.id.filtergroup2);
fragmentContainer = findViewById(R.id.fragment_container);
searchContainer = findViewById(R.id.search_container);
navigationView = findViewById(R.id.nav_view);
drawer = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
navigationView.setCheckedItem(R.id.nav_operatorlist);
navigationView.setNavigationItemSelectedListener(this);
user = new Account();
Intent intent = getIntent();
user.setAdmin(intent.getBooleanExtra("account_admin", false));
user.setUsername(intent.getStringExtra("account_username"));
user.setFla_number(intent.getLongExtra("account_fla", 0));
user.setFirstname(intent.getStringExtra("account_firstname"));
user.setMiddlename(intent.getStringExtra("account_middlename"));
user.setLastname(intent.getStringExtra("account_lastname"));
user.setOperator(intent.getBooleanExtra("account_operator", true));
user.setSim1(intent.getStringExtra("account_sim1"));
user.setSim2(intent.getStringExtra("account_sim2"));
if (user.isAdmin()) {
fragment1 = new ListFragment();
fragment2 = new AddOperatorFragment();
fragment3 = new AccountFragment();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment1).commit();
fragmentTransaction.addToBackStack("FRAGMENT1");
showSearchView();
} else {
Menu navMenu = navigationView.getMenu();
navMenu.findItem(R.id.nav_admin).setVisible(false);
toolbar.setTitle("Operator Account");
new CountDownTimer(1000, 100) {
@Override
public void onTick(long l) {
}
@Override
public void onFinish() {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (!profile_exists) {
AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
alert.setTitle("Operator");
alert.setMessage("Account is activated but your profile is not yet created.");
alert.setPositiveButton("Logout", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(ctx, LoginActivity.class);
startActivity(intent);
finish();
}
});
alert.setNegativeButton("Continue", null);
alert.show();
}
}
});
}
}.start();
DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("operator");
ref.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
for (DataSnapshot snap : snapshot.getChildren()) {
if (user.getFla_number() == snap.getValue(FishpondOperator.class).getFla_number()) {
startProfileFragment(user.getFla_number(), user.isAdmin());
profile_exists = true;
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
}
public void startProfileFragment(long fla, boolean isAdmin) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
if (user.isAdmin()) {
searchView.closeSearch();
fragmentContainer.setPadding(0, 0, 0, 0);
expandableLayout.collapse();
hideSearchView();
fragmentTransaction.addToBackStack("FRAGMENT4");
}
toolbar.setTitle("Operator Profile");
fragment4 = new ProfileFragment();
Bundle bundle = new Bundle();
bundle.putLong("fla_num", fla);
bundle.putBoolean("is_admin", isAdmin);
fragment4.setArguments(bundle);
fragmentTransaction.replace(R.id.fragment_container, fragment4);
fragmentTransaction.commit();
}
@Override
public void onBackPressed() {
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
}
if (user.isAdmin()) {
if (searchView.isSearchOpen()) {
searchView.closeSearch();
}
if (getSupportFragmentManager().getBackStackEntryCount() > 1) {
int index = getSupportFragmentManager().getBackStackEntryCount() - 1;
FragmentManager.BackStackEntry backEntry = getSupportFragmentManager().getBackStackEntryAt(index);
String previousFragment = backEntry.getName();
if (previousFragment.equals("FRAGMENT1")) {
hideSearchView();
fragment1.setActive(false);
} else if (previousFragment.equals("FRAGMENT3")) {
fragment3.setActive(false);
}
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.popBackStackImmediate();
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
if (currentFragment instanceof ListFragment)
showSearchView();
if (currentFragment instanceof AccountFragment)
fragment3.setCurrentAccount(user);
}
}
}
public void populateCards() {
if (fragment1.getOperatorAdapter() != null) {
try {
fragment1.getOperatorAdapter().setFilter(filter, statusfilter);
fragment1.getOperatorAdapter().getFilter().filter(lastSearchText);
if (fragment1.getOperatorAdapter().getItemCount() == 0)
fragment1.updateTextView(View.VISIBLE);
else {
fragment1.updateTextView(View.GONE);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (user.isAdmin())
createSearchView(menu);
TextView acct_type = findViewById(R.id.acct_type);
TextView acct_name = findViewById(R.id.acct_name);
String loggedin = "Logged in as: " + user.getUsername();
acct_name.setText(loggedin);
if (user.isAdmin()) {
acct_type.setText("ADMIN");
acct_type.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.button_primarypurple));
} else if (user.isOperator()) {
acct_type.setText("OPERATOR");
acct_type.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.button_gray));
}
return super.onCreateOptionsMenu(menu);
}
public void createSearchView(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.search_menu, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
searchView = findViewById(R.id.search_view);
searchView.setMenuItem(searchItem);
expandableLayout = findViewById(R.id.expandable_layout);
filter = 1;
statusfilter = 0;
populateCards();
List<String> spinner_list = new ArrayList<>();
spinner_list.add("All");
spinner_list.add("Active");
spinner_list.add("Expired");
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.spinner_item, spinner_list);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
statusfilter = i;
populateCards();
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
rg1.setOnCheckedChangeListener(this);
rg2.setOnCheckedChangeListener(this);
searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
lastSearchText = newText;
populateCards();
return false;
}
});
searchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
@Override
public void onSearchViewShown() {
fragmentContainer.setPadding(0, 280, 0, 0);
expandableLayout.expand();
}
@Override
public void onSearchViewClosed() {
fragmentContainer.setPadding(0, 0, 0, 0);
expandableLayout.collapse();
populateCards();
}
});
}
public void showSearchView() {
try {
searchContainer.setVisibility(View.VISIBLE);
searchView.setVisibility(View.VISIBLE);
findViewById(R.id.action_search).setVisibility(View.VISIBLE);
populateCards();
} catch (Exception e) {
Log.d("Tester", "SearchView not yet created");
}
}
public void hideSearchView() {
try {
searchView.closeSearch();
searchContainer.setVisibility(View.GONE);
searchView.setVisibility(View.GONE);
findViewById(R.id.action_search).setVisibility(View.GONE);
} catch (Exception e) {
Log.d("Tester", "SearchView not yet created");
}
}
public void replaceFragment(int i) {
if (i == 1) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentContainer.setPadding(0, 0, 0, 0);
fragmentTransaction.replace(R.id.fragment_container, fragment1, "FRAGMENT1").commit();
showSearchView();
populateCards();
toolbar.setTitle("Fishpond Operators");
}
}
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
switch (item.getItemId()) {
case R.id.nav_operatorlist:
fragmentContainer.setPadding(0, 0, 0, 0);
fragment3.setActive(false);
fragmentTransaction.replace(R.id.fragment_container, fragment1, "FRAGMENT1");
fragmentTransaction.commit();
fragmentTransaction.addToBackStack("FRAGMENT1");
fragment1.setActive(true);
showSearchView();
populateCards();
toolbar.setTitle("Fishpond Operators");
break;
case R.id.nav_manageope:
fragmentContainer.setPadding(0, 0, 0, 0);
expandableLayout.collapse();
fragment1.setActive(false);
fragment3.setActive(false);
fragmentTransaction.replace(R.id.fragment_container, fragment2, "FRAGMENT2");
fragmentTransaction.commit();
fragmentTransaction.addToBackStack("FRAGMENT2");
hideSearchView();
toolbar.setTitle("Add New Operators");
break;
case R.id.nav_manageacc:
fragmentContainer.setPadding(0, 0, 0, 0);
expandableLayout.collapse();
fragment1.setActive(false);
fragment3.setCurrentAccount(user);
fragmentTransaction.replace(R.id.fragment_container, fragment3, "FRAGMENT3");
fragmentTransaction.commit();
fragmentTransaction.addToBackStack("FRAGMENT3");
hideSearchView();
toolbar.setTitle("Manage Accounts");
break;
case R.id.nav_logout:
Toast.makeText(getApplicationContext(), "Logged Out", Toast.LENGTH_LONG).show();
if (user.isAdmin()) {
fragment1.setActive(false);
fragment3.setActive(false);
}
Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
startActivity(intent);
finish();
break;
}
drawer.closeDrawer(GravityCompat.START);
return true;
}
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
RadioButton rb = findViewById(i);
RadioGroup rg1 = findViewById(R.id.filtergroup);
RadioGroup rg2 = findViewById(R.id.filtergroup2);
switch (radioGroup.getId()) {
case R.id.filtergroup:
rg2.setOnCheckedChangeListener(null);
rg2.clearCheck();
rg2.setOnCheckedChangeListener(this);
filter = radioGroup.indexOfChild(rb);
break;
case R.id.filtergroup2:
rg1.setOnCheckedChangeListener(null);
rg1.clearCheck();
rg1.setOnCheckedChangeListener(this);
filter = radioGroup.indexOfChild(rb) + 3;
break;
default:
Log.d("Tester", "Error");
}
populateCards();
}
}
| true
|
f0fc90c0057b02d41eb1e7c77ab230e66550451e
|
Java
|
jlam55555/project-euler-java
|
/pe/PE15.java
|
UTF-8
| 535
| 2.578125
| 3
|
[] |
no_license
|
package pe;
import harness.PERunnable;
public class PE15 extends PERunnable<Long> {
private final int n = 20;
// dp solution; can use combinatorics instead (40!/20!/20!)
@Override
public Long run(int version) {
long[][] matrix = new long[n+1][n+1];
int i, j;
for(i=0; i<n; i++)
matrix[n][i] = matrix[i][n] = 1;
for(i=n-1; i>=0; i--)
for(j=n-1; j>=0; j--)
matrix[i][j] = matrix[i+1][j] + matrix[i][j+1];
return matrix[0][0];
}
}
| true
|
f9a273719228173fc3a5a734e63f4b57cee1763c
|
Java
|
wonjina/spring-boot-12pmDcom
|
/src/main/java/com/gabia/project/internproject/service/review/ReviewService.java
|
UTF-8
| 3,897
| 2.125
| 2
|
[] |
no_license
|
package com.gabia.project.internproject.service.review;
import com.gabia.project.internproject.common.domain.Member;
import com.gabia.project.internproject.common.domain.Restaurant;
import com.gabia.project.internproject.common.domain.Review;
import com.gabia.project.internproject.common.helper.Notification;
import com.gabia.project.internproject.common.util.mapper.ReviewMapper;
import com.gabia.project.internproject.controller.review.requestDto.ReviewFilterDto;
import com.gabia.project.internproject.controller.review.requestDto.ReviewPostDto;
import com.gabia.project.internproject.repository.RestaurantRepository;
import com.gabia.project.internproject.repository.ReviewRepository;
import com.gabia.project.internproject.service.review.dto.ReviewsDto;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.stream.Collectors;
import static com.gabia.project.internproject.common.helper.customSpecifications.ReviewSpecifications.equalsRating;
import static com.gabia.project.internproject.common.helper.customSpecifications.ReviewSpecifications.equalsRestaurant;
import static com.gabia.project.internproject.common.helper.customSpecifications.ReviewSpecifications.equalsReviewId;
import static com.gabia.project.internproject.common.helper.customSpecifications.ReviewSpecifications.equalsWriter;
import static com.gabia.project.internproject.common.helper.customSpecifications.ReviewSpecifications.fetchMember;
import static com.gabia.project.internproject.common.helper.customSpecifications.ReviewSpecifications.gtDateTime;
import static org.springframework.data.jpa.domain.Specification.where;
@Service
@Transactional(readOnly=true)
@RequiredArgsConstructor
public class ReviewService {
private final ReviewRepository reviewRepository;
private final ReviewMapper reviewMapper;
private final RestaurantRepository restaurantRepository;
/**
* 리뷰 리스트 조회
* @param reviewFilterDto : 날짜, 작성자, 평점, 가게id, 리뷰id
* @param pageable : 정렬 및 페이징
* @return :
*/
public Page<ReviewsDto> getReviewsList(ReviewFilterDto reviewFilterDto, Pageable pageable) {
Page<Review> reviews = reviewRepository.findAll(where(fetchMember())
.and(gtDateTime(reviewFilterDto.getDateTime()))
.and(equalsWriter(Member.of(reviewFilterDto.getMemberId())))
.and(equalsRating(reviewFilterDto.getRating()))
.and(equalsRestaurant(Restaurant.of(reviewFilterDto.getRestaurantId())))
.and(equalsReviewId(reviewFilterDto.getId())),
pageable);
//hatoxes 로 변환하기 위해 page list 형태로 리턴
return new PageImpl( reviews.stream().map(ReviewsDto::new).collect(Collectors.toList())
, pageable
, reviews.getTotalPages() * reviews.getSize());
}
/**
* 리뷰 쓰기 (단건)
*/
@Transactional
public String writeReview(ReviewPostDto reviewPostDto) {
Restaurant restaurant = restaurantRepository.findRestaurantWithReviewsById(reviewPostDto.getRestaurantId());
restaurant.addReview(reviewMapper.toEntity(reviewPostDto));
restaurant.updateReviewsAmount();
restaurant.updateRating();
return Notification.SUCCESS_POST.getMsg();
}
}
| true
|
01b8ce27c40778b00168b6998603d9ca9b7e5a63
|
Java
|
tow84917/PlayFit
|
/src/main/java/com/java016/playfit/serviceimpl/OrderRecordServiceImpl.java
|
UTF-8
| 6,049
| 2.0625
| 2
|
[] |
no_license
|
package com.java016.playfit.serviceimpl;
import com.java016.playfit.dao.OrderRecordRepository;
import com.java016.playfit.dao.UserRepository;
import com.java016.playfit.model.OrderRecord;
import com.java016.playfit.model.User;
import com.java016.playfit.service.OrderRecordService;
import com.java016.playfit.service.UserService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
public class OrderRecordServiceImpl implements OrderRecordService {
private static final Logger logger = LogManager.getLogger(OrderRecordServiceImpl.class);
@Autowired
UserService userService;
@Autowired
OrderRecordRepository orderRecordRepository;
@Autowired
UserRepository userRepository;
@Override
public OrderRecord saveOrderRecord(Map<String, Object> paramsMap, Integer userId) {
Integer RtnCode = Integer.parseInt((String)paramsMap.get("RtnCode"));
logger.info(RtnCode);
OrderRecord orderRecord = new OrderRecord();
Date date;
Calendar calendar;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
for (String s : paramsMap.keySet()) {
System.out.println("----------------");
System.out.println(s);
System.out.println(paramsMap.get(s));
System.out.println("----------------");
switch (s){
case "MerchantTradeNo": // 訂單編號
// model.addAttribute("MerchantTradeNo", paramsMap.get(s));
orderRecord.setMerchantTradeNo((String)paramsMap.get(s));
break;
case "PaymentDate": // 付款時間
// model.addAttribute("PaymentDate", paramsMap.get(s));
try {
date = dateFormat.parse((String)paramsMap.get(s));
} catch (ParseException e) {
e.printStackTrace();
break;
}
calendar = Calendar.getInstance();
calendar.setTime(date);
orderRecord.setPaymentDate(calendar);
break;
case "PaymentType": // 付款方式
// model.addAttribute("PaymentType", paramsMap.get(s));
orderRecord.setPaymentType((String)paramsMap.get(s));
break;
case "PaymentTypeChargeFee": // 手續費
// model.addAttribute("PaymentTypeChargeFee", paramsMap.get(s));
orderRecord.setPaymentTypeChargeFee(Integer.parseInt((String)paramsMap.get(s)));
break;
case "TradeAmt": // 交易金額
// model.addAttribute("TradeAmt", paramsMap.get(s));
orderRecord.setTradeAmt(Integer.parseInt((String)paramsMap.get(s)));
break;
case "TradeDate": // 訂單成立時間
// model.addAttribute("TradeDate", paramsMap.get(s));
try {
date = dateFormat.parse((String)paramsMap.get(s));
} catch (ParseException e) {
e.printStackTrace();
break;
}
calendar = Calendar.getInstance();
calendar.setTime(date);
orderRecord.setTradeDate(calendar);
break;
case "TradeNo": // 綠界的交易編號
// model.addAttribute("TradeNo", paramsMap.get(s));
orderRecord.setTradeNo((String)paramsMap.get(s));
break;
}
}
// User loginUser = userService.getLoginUser().getUser();
User loginUser = userRepository.getById(userId);
logger.info(loginUser);
orderRecord.setUserId(loginUser);
logger.info(orderRecord);
System.out.println(orderRecord);
orderRecord.setUserId(loginUser);
orderRecordRepository.save(orderRecord);
return orderRecord;
}
@Override
public void page(){
List<OrderRecord> all = orderRecordRepository.findAll(Sort.by("id"));
System.out.println(all.size());
System.out.println("<<---->>");
Pageable firstPageWithTwoElements = PageRequest.of(0,1);
Page<OrderRecord> page = orderRecordRepository.findAll(firstPageWithTwoElements);
List<OrderRecord> content = page.getContent();
System.out.println(content);
}
@Override
public Long findCountByUserId() {
Long count = orderRecordRepository.countByUserId(userService.getLoginUser());
return count;
}
@Override
public Page<OrderRecord> findCurrentPage(Map<String, String> paramsMap) {
logger.info("findCurrentPage -->");
String onePageItems = paramsMap.get("onePageItems");
logger.info(onePageItems);
String currentPage = paramsMap.get("currentPage");
logger.info(currentPage);
Pageable firstPageWithTwoElements = PageRequest.of(Integer.parseInt((String) currentPage)-1
,Integer.parseInt((String) onePageItems));
Page<OrderRecord> allByUserId =
orderRecordRepository.findAllByUserId(userRepository.findById( userService.getLoginUserId() ).get(), firstPageWithTwoElements);
System.out.println(allByUserId);
return allByUserId;
}
}
| true
|
e5c00d879dc79e5a17c69068b48884add1ff915c
|
Java
|
RonaldoJa/Programas
|
/java/Alquiler_libros/src/main/java/com/mycompany/alquiler_libros/main.java
|
UTF-8
| 3,803
| 2.96875
| 3
|
[] |
no_license
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.alquiler_libros;
import java.util.ArrayList;
/**
*
* @author tomvargas
*/
public class main {
public static int cuentaPrestados(ArrayList<Libro> bookList){
int count=0;
for (int i=0; i<bookList.size(); i++){
if(bookList.get(i).getStatus()){
count++;
}
}
return count;
}
public ArrayList<Libro> retornaPrestados(ArrayList<Libro> bookList){
ArrayList<Libro> newlist = new ArrayList<Libro>();
for (int i=0; i<bookList.size(); i++){
if(!bookList.get(i).getStatus()){
newlist.add(bookList.get(i));
}
}
return newlist;
}
public static int publicacionesAnterioresA(ArrayList<Revista> magList, int y){
int count=0;
for (int i=0; i<magList.size(); i++){
if(magList.get(i).getYear()< y){
count++;
}
}
return count;
}
public static Libro newbook(String c, String t, int y){
Libro book = new Libro(c,t,y);
return book;
}
public static Revista newmag(String c, String t, int y, int n){
Revista mag = new Revista(c,t,y,n);
return mag;
}
public static void main(String[] args){
//--------------------------------------crear arrays de libros y revistas
ArrayList<Libro> books = new ArrayList<Libro>();
ArrayList<Revista> mag = new ArrayList<Revista>();
books.add(newbook("001","1000 anios de soledad",1998));
books.add(newbook("002","Software modeling and design",2011));
books.add(newbook("003","Metodología y herramientas UML",2005));
books.add(newbook("004","Viaje al centro de la tierra",1997));
books.add(newbook("005","Ciencias naturales",2017));
books.add(newbook("006","El señor de los anillos",1998));
books.add(newbook("007","Harry Potter",1998));
books.add(newbook("008","Anatomía humana",1998));
books.add(newbook("009","Algebra de baldor",1998));
books.add(newbook("010","Historia de la informática",1998));
//-----------------------------------------------prestar 5 publicaciones
for (int i=0; i<Math.round(books.size()/2); i++)
books.get(i).prestar();
mag.add(newmag("b001", "Generacion 21", 1989, 1234));
mag.add(newmag("b002", "Moda actual", 1985, 1235));
mag.add(newmag("b003", "Informática", 1984, 1236));
mag.add(newmag("b004", "diseño UX", 2020, 1237));
mag.add(newmag("b005", "web design", 2021, 1238));
//-----------------------------------------------mostrar array de libros
System.out.println("## Libros Registrados ##");
for (int i=0; i<books.size();i++)
System.out.println(books.get(i).toString());
//---------------------------------------------mostrar array de revistas
System.out.println("## Revistas registradas ##");
for (int i=0; i<mag.size();i++)
System.out.println(mag.get(i).toString());
//----------------------------------mostrar cantidad de libros prestados
System.out.println("Cantidad de libros prestados: "+ cuentaPrestados(books));
//-------------------mostrar cantidad de publicaciones anteriores a 1990
System.out.println("Cantidad de revistas publicadas antes de 1990: "+ publicacionesAnterioresA(mag,1990));
}
}
| true
|
5691f7af283f8643e4dc4cb1dbad31476c23f93d
|
Java
|
tt2nn/Gree-GPRS
|
/GreeGprs/src/com/gree/gprs/tcp/model/TimeModel.java
|
UTF-8
| 2,152
| 2.46875
| 2
|
[] |
no_license
|
package com.gree.gprs.tcp.model;
import com.gree.gprs.control.ControlCenter;
import com.gree.gprs.data.DataCenter;
import com.gree.gprs.tcp.TcpModel;
import com.gree.gprs.util.Logger;
import com.gree.gprs.util.Utils;
import com.gree.gprs.variable.Variable;
/**
* 时间
*
* @author lihaotian
*
*/
public class TimeModel {
/**
* 心跳
*/
public static void heart() {
Variable.Tcp_Out_Buffer[18] = (byte) 0xF3;
TcpModel.build(1, 19);
}
/**
* 心跳响应
*/
public static void heartResponse() {
int year = (Variable.Tcp_In_Buffer[19] & 0xFF) + 2000;
int month = Variable.Tcp_In_Buffer[20] & 0xFF;
int date = Variable.Tcp_In_Buffer[21] & 0xFF;
int hour = Variable.Tcp_In_Buffer[22] & 0xFF;
int min = Variable.Tcp_In_Buffer[23] & 0xFF;
int sec = Variable.Tcp_In_Buffer[24] & 0xFF;
Variable.System_Time = Utils.getTime(year, month, date, hour, min, sec);
Variable.Heart_Beat_Time = Variable.System_Time;
Variable.System_Delta_Time = Variable.System_Time - System.currentTimeMillis();
Logger.log("Tcp Heart Time", Variable.System_Time + "");
ControlCenter.heartBeatResp();
}
/**
* 静默时间 响应
*/
public static void stopTime() {
Variable.Tcp_Out_Buffer[18] = (byte) 0x98;
Variable.Tcp_Out_Buffer[19] = (byte) 0x00;
TcpModel.build(1, 20);
}
/**
* 服务器下发静默时间
*/
public static void stopTimeResponse() {
int year = (Variable.Tcp_In_Buffer[19] & 0xFF) + 2000;
int month = Variable.Tcp_In_Buffer[20] & 0xFF;
int date = Variable.Tcp_In_Buffer[21] & 0xFF;
int hour = Variable.Tcp_In_Buffer[22] & 0xFF;
int min = Variable.Tcp_In_Buffer[23] & 0xFF;
int sec = Variable.Tcp_In_Buffer[24] & 0xFF;
// 如果下发的时间 是 2000-1-1 0-0-0 清空静默时间
if (year == 2000 && month == 1 && date == 1 && hour == 0 && min == 0 && sec == 0) {
Variable.Stop_Time = 0;
stopTime();
return;
}
Variable.Stop_Time = Utils.getTime(year, month, date, hour, min, sec);
if (Variable.System_Time < Variable.Stop_Time) {
// 如果当前时间 小于静默时间 则 停止传输
DataCenter.destoryTransmit();
}
stopTime();
}
}
| true
|
7d9269cf825e35bc65fe03cebefe98103c00220f
|
Java
|
kubeflow/arena
|
/sdk/arena-java-sdk/src/main/java/com/github/kubeflow/arena/model/training/GPUMetric.java
|
UTF-8
| 870
| 2.140625
| 2
|
[
"Apache-2.0"
] |
permissive
|
package com.github.kubeflow.arena.model.training;
import com.alibaba.fastjson.JSON;
public class GPUMetric {
private double gpuDutyCycle;
private double usedGPUMemory;
private double totalGPUMemory;
public double getGpuDutyCycle() {
return this.gpuDutyCycle;
}
public void setGpuDutyCycle(double gpuDutyCycle) {
this.gpuDutyCycle = gpuDutyCycle;
}
public double getTotalGPUMemory() {
return totalGPUMemory;
}
public void setTotalGPUMemory(double totalGPUMemory) {
this.totalGPUMemory = totalGPUMemory;
}
public double getUsedGPUMemory() {
return usedGPUMemory;
}
public void setUsedGPUMemory(double usedGPUMemory) {
this.usedGPUMemory = usedGPUMemory;
}
@Override
public String toString() {
return JSON.toJSONString(this, true);
}
}
| true
|
fa554ce3913761f3ea74c0cd73ef05b8670c9b52
|
Java
|
Chetic/Phishpic
|
/app/src/main/java/com/phishcave/phishpic/CameraPreview.java
|
UTF-8
| 5,911
| 2.46875
| 2
|
[
"MIT"
] |
permissive
|
package com.phishcave.phishpic;
/**
* Created by freveny on 2015-03-10.
*/
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.hardware.Camera.Size;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import java.io.IOException;
import java.util.List;
@SuppressWarnings("deprecation")
/** A basic Camera preview class */
public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback {
private SurfaceHolder mHolder;
private Camera mCamera;
private int mCameraId;
private int previewHeight;
private int previewWidth;
public CameraPreview(Context context, int cameraId, Camera camera, int width, int height) {
super(context);
mCameraId = cameraId;
mCamera = camera;
previewHeight = height;
previewWidth = width;
//boolean did_disable_shutter_sound_work = mCamera.enableShutterSound(false);
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
// deprecated setting, but required on Android versions prior to 3.0
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
private Size getOptimalSize(List<Size> sizes,int w,int h){
final double ASPECT_TOLERANCE=0.0;
double targetRatio=(double)w / h;
if (sizes == null) return null;
Size optimalSize=null;
double minDiff=Double.MAX_VALUE;
int targetHeight=Math.min(h,w);
for ( Size size : sizes) {
double ratio=(double)size.width / size.height;
if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;
if (Math.abs(size.height - targetHeight) < minDiff) {
optimalSize=size;
minDiff=Math.abs(size.height - targetHeight);
}
}
if (optimalSize == null) {
minDiff=Double.MAX_VALUE;
for ( Size size : sizes) {
if (Math.abs(size.height - targetHeight) < minDiff) {
optimalSize=size;
minDiff=Math.abs(size.height - targetHeight);
}
}
}
return optimalSize;
}
public void surfaceCreated(SurfaceHolder holder) {
// The Surface has been created, now tell the camera where to draw the preview.
try {
mCamera.setPreviewDisplay(holder);
Camera.Parameters params = mCamera.getParameters();
List<Camera.Size> sizes = params.getSupportedPictureSizes();
Camera.Size optimalSize = getOptimalSize(sizes, previewWidth, previewHeight);
Log.d("Phishpic", "Setting picture size to: " + optimalSize.width + "x" + optimalSize.height);
params.setPictureSize(optimalSize.width, optimalSize.height);
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
params.setSceneMode(Camera.Parameters.SCENE_MODE_AUTO);
params.setPictureFormat(ImageFormat.JPEG);
params.setJpegQuality(100);
mCamera.setParameters(params);
mCamera.startPreview();
} catch (IOException e) {
Log.d("Phishpic", "Error setting camera preview: " + e.getMessage());
}
}
public void surfaceDestroyed(SurfaceHolder holder) {
close();
}
public void close() {
if ( mCamera != null ) {
mCamera.stopPreview();
mCamera.release();
mCamera = null;
mHolder.removeCallback(this);
}
}
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
// If your preview can change or rotate, take care of those events here.
// Make sure to stop the preview before resizing or reformatting it.
if (mHolder.getSurface() == null){
// preview surface does not exist
return;
}
// stop preview before making changes
try {
mCamera.stopPreview();
} catch (Exception e){
// ignore: tried to stop a non-existent preview
}
// set preview size and make any resize, rotate or
// reformatting changes here
setCameraDisplayOrientation();
// start preview with new settings
try {
mCamera.setPreviewDisplay(mHolder);
mCamera.startPreview();
} catch (Exception e){
Log.d("Phishpic", "Error starting camera preview: " + e.getMessage());
}
}
public void setCameraDisplayOrientation() {
android.hardware.Camera.CameraInfo info =
new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(mCameraId, info);
int rotation = Phishpic.activity.getWindowManager().getDefaultDisplay()
.getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0: degrees = 0; break;
case Surface.ROTATION_90: degrees = 90; break;
case Surface.ROTATION_180: degrees = 180; break;
case Surface.ROTATION_270: degrees = 270; break;
}
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation + degrees) % 360;
result = (360 - result) % 360; // compensate the mirror
} else { // back-facing
result = (info.orientation - degrees + 360) % 360;
}
mCamera.setDisplayOrientation(result);
Camera.Parameters params = mCamera.getParameters();
params.setRotation(result);
mCamera.setParameters(params);
}
}
| true
|
4f5a4ad7c7e5f650f954dedcfe27a68644809519
|
Java
|
lucmoreau/ProvToolbox
|
/modules-core/prov-jsonld/src/main/java/org/openprovenance/prov/core/json/serialization/deserial/CustomNamespacePrefixDeserializer.java
|
UTF-8
| 1,715
| 2.15625
| 2
|
[
"MIT"
] |
permissive
|
package org.openprovenance.prov.core.json.serialization.deserial;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import org.openprovenance.prov.model.Namespace;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
public class CustomNamespacePrefixDeserializer extends StdDeserializer<Map<String,String>> {
public static final Object CONTEXT_KEY_NAMESPACE = "CONTEXT_KEY_NAMESPACE";
public CustomNamespacePrefixDeserializer(JavaType tr) {
super(tr);
}
public CustomNamespacePrefixDeserializer() {
super(Map.class);
}
@Override
public Map<String, String> deserialize(JsonParser jp, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
JsonNode prefixes=jp.readValueAsTree();
Namespace ns=(Namespace)deserializationContext.getAttribute(CONTEXT_KEY_NAMESPACE);
if (ns==null) {
ns=new Namespace();
deserializationContext.setAttribute(CONTEXT_KEY_NAMESPACE,ns);
}
Hashtable<String, String> map=new Hashtable<String,String>();
for (Iterator<String> it = prefixes.fieldNames(); it.hasNext(); ) {
String prefix = it.next();
String namespace=prefixes.get(prefix).textValue();
map.put(prefix,namespace);
ns.register(prefix,namespace);
}
return map;
}
}
| true
|
c63bea1f0cf15c8cfd474a0a2bc2a11f8d2a7cde
|
Java
|
2016121009/bolg
|
/src/dao/userdao.java
|
UTF-8
| 3,176
| 2.484375
| 2
|
[] |
no_license
|
package dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import db.dbutil;
import java.lang.Exception;
import entity.user;
public class userdao {
Connection conn = null;
PreparedStatement psmt = null;
public userdao() {
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/boke", "root", "123456");
} catch (Exception e) {
e.printStackTrace();
}
}
public user checkUser(String name, String pwd) {
if (conn == null) {
return null;
}
try {
psmt = conn.prepareStatement("select * from user where name=? and pwd=?");
psmt.setString(1, name);
psmt.setString(2, pwd);
ResultSet rs = psmt.executeQuery();
user user = new user();
while (rs.next()) {
user.setName(rs.getString("name"));
user.setPwd(rs.getString("pwd"));
user.setEmail(rs.getString("email"));
user.setPhone(rs.getString("phone"));
user.setQq(rs.getString("qq"));
user.setInfo(rs.getString("info"));
return user;
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public boolean regeistUser(String name, String pwd, String email, String phone, String qq, String info) {
if (conn == null) {
return false;
}
try {
psmt = conn.prepareStatement("INSERT INTO user(name,pwd,email,phone,qq,info) VALUES (?,?,?,?,?,?);");
psmt.setString(1, name);
psmt.setString(2, pwd);
psmt.setString(3, email);
psmt.setString(4, phone);
psmt.setString(5, qq);
psmt.setString(6, info);
psmt.executeUpdate();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public List<user> findInfoAll() {
List<user> list = new ArrayList<user>();
try {
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM user;");
while (rs.next()) {
user user = new user();
user.setName(rs.getString("name"));
user.setPwd(rs.getString("pwd"));
user.setEmail(rs.getString("email"));
user.setPhone(rs.getString("phone"));
user.setQq(rs.getString("qq"));
user.setInfo(rs.getString("info"));
list.add(user);
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
public boolean deletUser(int id) {
if (conn == null) {
return false;
}
try {
psmt = conn.prepareStatement("DELETE FROM user WHERE id=?");
psmt.setInt(1, id);
psmt.executeUpdate();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public void updateuser(String name, String pwd, String email, String phone, String qq, String info) throws SQLException{
Connection conn=dbutil.getConnection();
String sql="" +
" update user " +
" set name=?,pwd=?,email=?,phone=?,qq=?,info=?, " +
" where id=? ";
PreparedStatement ptmt=conn.prepareStatement(sql);
ptmt.setString(1, name);
ptmt.setString(2, pwd);
ptmt.setString(3, email);
ptmt.setString(4, phone);
ptmt.setString(5, qq);
ptmt.setString(6, info);
ptmt.execute();
}
}
| true
|
072cf17f2729053cb4b0874ace0121ec71aea5a3
|
Java
|
IlnarH/Arrow
|
/app/src/main/java/com/arrowgame/gameprocess/gameobject/Decoration.java
|
UTF-8
| 1,052
| 2.671875
| 3
|
[] |
no_license
|
package com.arrowgame.gameprocess.gameobject;
import com.arrowgame.gameprocess.GameManager;
import com.arrowgame.gameprocess.animation.Animation;
import com.arrowgame.gameprocess.graphics.Camera;
public class Decoration extends GameObject {
public Decoration(GamePoint position, Animation animation) {
super(position, 0, animation, null, null);
}
@Override
public boolean update(double factor) {
updatePosition(factor);
if (!checkVisible()) {
remove();
return false;
}
return true;
}
@Override
protected void updatePosition(double factor) {
}
@Override
public boolean checkVisible() {
return Camera.getInstance().checkDecorationOnScreen(position);
}
@Override
public void add() {
GameManager.getBackground().addDecoration(this);
}
@Override
public void remove() {
GameManager.getBackground().removeDecoration(this);
}
@Override
public void destroy() {
remove();
}
}
| true
|
e95a99c87ac0a00a57eb12d9d33f227526d97f6d
|
Java
|
anehing/JavaConcurrencyPattern
|
/src/vh/exception/Task.java
|
UTF-8
| 184
| 1.859375
| 2
|
[
"MIT"
] |
permissive
|
package vh.exception;
public class Task implements Runnable {
@Override
public void run() {
// TODO Auto-generated method stub
int numero = Integer.parseInt("Tw是TT");
}
}
| true
|
c26d23019f802c0139c711941baa1cd653495e38
|
Java
|
BriannaZhou/BriannaZhou
|
/Class Practice/src/Student.java
|
UTF-8
| 1,117
| 3.34375
| 3
|
[] |
no_license
|
import java.util.ArrayList;
public class Student {
private String StudentName;
private static int StudentID = 0;
private int id;
private ArrayList<Courses> course;
private double Average;
Student(String StudentName) {
this.StudentName = StudentName;
id = StudentID;
StudentID++;
course = new ArrayList<>();
System.out.println("Student object created");
}
public void addCourse(Courses courses){
this.course.add(courses);
}
public ArrayList<Courses> getCourse() {
return course;
}
public static int getStudentID () {
return StudentID;
}
public double getAverage(){
double total = 0;
double Average = 0;
for (int i = 0; i < course.size(); i++) {
total = total + course.get(i).getStudentGrade();
}
Average = total/ course.size();
return Average;
}
public String toString () {
return "Student: \nName: " + StudentName + "\nStudent ID: " + StudentID;
}
}
| true
|
bc5a4b66b38868cf4644caf59efe5b50f7c60991
|
Java
|
lzzhuang777/questions
|
/questions-common/src/main/java/com/lzz/mapper/QmsQuestionMapper.java
|
UTF-8
| 640
| 1.75
| 2
|
[] |
no_license
|
package com.lzz.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzz.model.QmsQuestion;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author macro
* @since 2020-09-27
*/
@Mapper
public interface QmsQuestionMapper extends BaseMapper<QmsQuestion> {
List<QmsQuestion> getQuestionsByIds(@Param("ids") List<Long> ids);
List<QmsQuestion> selectQuesList(@Param("query") String query,@Param("testId")Long testId);
List<QmsQuestion> selectQuestionsByTestId (@Param("testId") Long testId);
}
| true
|
8ca3186ab3206a2bc278d07e362a0eb5d86ef8f4
|
Java
|
STAMP-project/Cling-application
|
/results/cling/time-org.joda.time.DateTimeZone-org.joda.time.format.DateTimeFormat-14/org/joda/time/DateTimeZone_ESTest.java
|
UTF-8
| 12,565
| 1.859375
| 2
|
[] |
no_license
|
/*
* Tue Mar 03 18:13:44 GMT 2020
*/
package org.joda.time;
import org.junit.Test;
import org.junit.Ignore;
import static org.junit.Assert.*;
import static org.evosuite.shaded.org.mockito.Mockito.*;
import static org.evosuite.runtime.EvoAssertions.*;
import java.util.Calendar;
import java.util.Locale;
import java.util.Set;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.evosuite.runtime.ViolatedAssumptionAnswer;
import org.joda.time.Chronology;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDateTime;
import org.joda.time.MonthDay;
import org.joda.time.MutableDateTime;
import org.joda.time.ReadableInstant;
import org.joda.time.chrono.BuddhistChronology;
import org.joda.time.chrono.ISOChronology;
import org.joda.time.tz.CachedDateTimeZone;
import org.joda.time.tz.DefaultNameProvider;
import org.joda.time.tz.FixedDateTimeZone;
import org.joda.time.tz.NameProvider;
import org.joda.time.tz.Provider;
import org.joda.time.tz.UTCProvider;
import org.junit.runner.RunWith;
@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = false, useJEE = true)
public class DateTimeZone_ESTest extends DateTimeZone_ESTest_scaffolding {
@Test(timeout = 4000)
public void test00() throws Throwable {
FixedDateTimeZone fixedDateTimeZone0 = (FixedDateTimeZone)DateTimeZone.UTC;
long long0 = fixedDateTimeZone0.convertLocalToUTC((-9223372036854775797L), false);
assertEquals((-9223372036854775797L), long0);
}
@Test(timeout = 4000)
public void test01() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.forTimeZone((TimeZone) null);
LocalDateTime localDateTime0 = new LocalDateTime((-1828800000L), dateTimeZone0);
boolean boolean0 = dateTimeZone0.isLocalDateTimeGap(localDateTime0);
assertFalse(boolean0);
}
@Test(timeout = 4000)
@Ignore
public void test02() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.forID("America/St_Johns");
String string0 = dateTimeZone0.getShortName(252L);
assertEquals("-03:30", string0);
}
@Test(timeout = 4000)
public void test03() throws Throwable {
Set<String> set0 = Calendar.getAvailableCalendarTypes();
Provider provider0 = mock(Provider.class, new ViolatedAssumptionAnswer());
doReturn(set0).when(provider0).getAvailableIDs();
// Undeclared exception!
try {
DateTimeZone.setProvider(provider0);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// The provider doesn't support UTC
//
verifyException("org.joda.time.DateTimeZone", e);
}
}
@Test(timeout = 4000)
@Ignore
public void test04() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.getDefault();
ISOChronology iSOChronology0 = ISOChronology.getInstanceUTC();
MutableDateTime mutableDateTime0 = MutableDateTime.now((Chronology) iSOChronology0);
dateTimeZone0.getOffset((ReadableInstant) mutableDateTime0);
assertEquals(1583259214851L, mutableDateTime0.getMillis());
}
@Test(timeout = 4000)
public void test05() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.getDefault();
DateTimeZone.setDefault(dateTimeZone0);
assertEquals("Europe/Amsterdam", dateTimeZone0.toString());
}
@Test(timeout = 4000)
public void test06() throws Throwable {
TimeZone timeZone0 = TimeZone.getTimeZone("HST");
UTCProvider uTCProvider0 = new UTCProvider();
DateTimeZone.setProvider(uTCProvider0);
// Undeclared exception!
try {
DateTimeZone.forTimeZone(timeZone0);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// The datetime zone id 'HST' is not recognised
//
verifyException("org.joda.time.DateTimeZone", e);
}
}
@Test(timeout = 4000)
@Ignore
public void test07() throws Throwable {
BuddhistChronology buddhistChronology0 = BuddhistChronology.getInstance();
DateTimeZone dateTimeZone0 = buddhistChronology0.getZone();
MonthDay monthDay0 = MonthDay.now();
long long0 = buddhistChronology0.set(monthDay0, 1);
assertEquals(5270400001L, long0);
long long1 = dateTimeZone0.convertLocalToUTC(637L, false);
assertEquals((-3599363L), long1);
}
@Test(timeout = 4000)
@Ignore
public void test08() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.forID("America/St_Johns");
// Undeclared exception!
try {
dateTimeZone0.convertLocalToUTC(9223372036847575819L, false, (-2518L));
fail("Expecting exception: ArithmeticException");
} catch(ArithmeticException e) {
//
// Subtracting time zone offset caused overflow
//
verifyException("org.joda.time.DateTimeZone", e);
}
}
@Test(timeout = 4000)
public void test09() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.getDefault();
long long0 = dateTimeZone0.adjustOffset((-766623600001L), false);
assertEquals((-766623600001L), long0);
}
@Test(timeout = 4000)
public void test10() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.forTimeZone((TimeZone) null);
LocalDateTime localDateTime0 = new LocalDateTime((-781052400001L), dateTimeZone0);
boolean boolean0 = dateTimeZone0.isLocalDateTimeGap(localDateTime0);
assertFalse(boolean0);
}
@Test(timeout = 4000)
public void test11() throws Throwable {
DefaultNameProvider defaultNameProvider0 = new DefaultNameProvider();
DateTimeZone.setNameProvider(defaultNameProvider0);
}
@Test(timeout = 4000)
public void test12() throws Throwable {
CachedDateTimeZone cachedDateTimeZone0 = (CachedDateTimeZone)DateTimeZone.getDefault();
DateTimeZone dateTimeZone0 = cachedDateTimeZone0.getUncachedZone();
long long0 = cachedDateTimeZone0.getMillisKeepLocal(dateTimeZone0, (-1L));
assertEquals((-1L), long0);
}
@Test(timeout = 4000)
public void test13() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.forOffsetHours(5);
dateTimeZone0.getMillisKeepLocal(dateTimeZone0, 0L);
assertEquals("+05:00", dateTimeZone0.toString());
}
@Test(timeout = 4000)
public void test14() throws Throwable {
try {
DateTimeZone.forOffsetHoursMinutes((-1307), (-1307));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// Minutes out of range: -1307
//
verifyException("org.joda.time.DateTimeZone", e);
}
}
@Test(timeout = 4000)
public void test15() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.forTimeZone((TimeZone) null);
// Undeclared exception!
try {
dateTimeZone0.convertLocalToUTC((-9223372036854775797L), false);
fail("Expecting exception: ArithmeticException");
} catch(ArithmeticException e) {
//
// Subtracting time zone offset caused overflow
//
verifyException("org.joda.time.DateTimeZone", e);
}
}
@Test(timeout = 4000)
public void test16() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.forID("+00:00:00.007");
assertNotNull(dateTimeZone0);
assertEquals("+00:00:00.007", dateTimeZone0.toString());
}
@Test(timeout = 4000)
public void test17() throws Throwable {
BuddhistChronology buddhistChronology0 = BuddhistChronology.getInstance();
DateTimeZone dateTimeZone0 = buddhistChronology0.getZone();
DateTimeZone.setNameProvider((NameProvider) null);
long long0 = dateTimeZone0.convertLocalToUTC(637L, false);
assertEquals((-3599363L), long0);
}
@Test(timeout = 4000)
public void test18() throws Throwable {
FixedDateTimeZone fixedDateTimeZone0 = (FixedDateTimeZone)DateTimeZone.UTC;
CachedDateTimeZone cachedDateTimeZone0 = CachedDateTimeZone.forZone(fixedDateTimeZone0);
int int0 = cachedDateTimeZone0.getOffsetFromLocal(965L);
assertEquals(0, int0);
}
@Test(timeout = 4000)
public void test19() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.getDefault();
Locale locale0 = Locale.TRADITIONAL_CHINESE;
String string0 = dateTimeZone0.UTC.getName(597L, locale0);
assertNotNull(string0);
assertEquals("+00:00", string0);
}
@Test(timeout = 4000)
public void test20() throws Throwable {
TimeZone timeZone0 = TimeZone.getTimeZone("AV{3G]v1evAz=_'cO`A");
DateTimeZone dateTimeZone0 = DateTimeZone.forTimeZone(timeZone0);
assertEquals("UTC", dateTimeZone0.toString());
}
@Test(timeout = 4000)
public void test21() throws Throwable {
try {
DateTimeZone.forOffsetHoursMinutes(0, 2010);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// Minutes out of range: 2010
//
verifyException("org.joda.time.DateTimeZone", e);
}
}
@Test(timeout = 4000)
public void test22() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.forTimeZone((TimeZone) null);
assertNotNull(dateTimeZone0);
boolean boolean0 = dateTimeZone0.isStandardOffset(766615920621L);
assertFalse(boolean0);
}
@Test(timeout = 4000)
public void test23() throws Throwable {
SimpleTimeZone simpleTimeZone0 = new SimpleTimeZone(7, "org.joda.time.chrono.BuddhistChronology");
// Undeclared exception!
try {
DateTimeZone.forTimeZone(simpleTimeZone0);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// The datetime zone id 'org.joda.time.chrono.BuddhistChronology' is not recognised
//
verifyException("org.joda.time.DateTimeZone", e);
}
}
@Test(timeout = 4000)
public void test24() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.getDefault();
assertNotNull(dateTimeZone0);
long long0 = dateTimeZone0.adjustOffset((-9223372036854775797L), false);
assertEquals((-9223372036854775797L), long0);
}
@Test(timeout = 4000)
@Ignore
public void test25() throws Throwable {
UTCProvider uTCProvider0 = new UTCProvider();
DateTimeZone.setProvider(uTCProvider0);
DateTimeZone dateTimeZone0 = DateTimeZone.getDefault();
assertEquals("UTC", dateTimeZone0.toString());
}
@Test(timeout = 4000)
public void test26() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.forID("America/St_Johns");
int int0 = dateTimeZone0.getOffsetFromLocal(889L);
assertEquals((-12600000), int0);
}
@Test(timeout = 4000)
public void test27() throws Throwable {
Locale locale0 = Locale.ROOT;
DateTimeZone dateTimeZone0 = DateTimeZone.getDefault();
assertNotNull(dateTimeZone0);
String string0 = dateTimeZone0.getShortName((-9223372036854775797L), locale0);
assertEquals("+00:19:32", string0);
assertNotNull(string0);
}
@Test(timeout = 4000)
public void test28() throws Throwable {
DateTimeZone.setProvider((Provider) null);
}
@Test(timeout = 4000)
public void test29() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.forOffsetHours(5);
TimeZone timeZone0 = dateTimeZone0.toTimeZone();
DateTimeZone.forTimeZone(timeZone0);
DateTimeZone dateTimeZone1 = DateTimeZone.forTimeZone(timeZone0);
assertEquals("+05:00", dateTimeZone1.toString());
assertEquals("+05:00", dateTimeZone0.toString());
}
@Test(timeout = 4000)
public void test30() throws Throwable {
DateTimeZone dateTimeZone0 = DateTimeZone.forTimeZone((TimeZone) null);
// Undeclared exception!
try {
dateTimeZone0.convertLocalToUTC((-9223372036854775797L), true);
fail("Expecting exception: ArithmeticException");
} catch(ArithmeticException e) {
//
// Subtracting time zone offset caused overflow
//
verifyException("org.joda.time.DateTimeZone", e);
}
}
}
| true
|
d400b9a2ec7e67de21923504fa20f0bd570c3d01
|
Java
|
tjbee/homework
|
/elective/SE452/hw1 2/src/main/java/edu/depaul/se/account/jdbc/AccountManager.java
|
UTF-8
| 1,465
| 2.625
| 3
|
[] |
no_license
|
package edu.depaul.se.account.jdbc;
import edu.depaul.se.account.AccountNotFoundException;
import edu.depaul.se.account.IAccount;
import edu.depaul.se.account.IAccountManager;
import edu.depaul.se.account.InsufficientFundsException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Implementation of solution using JDBC
*/
public class AccountManager implements IAccountManager {
public int createAccount(String name, float initialBalance) {
// TODO Auto-generated method stub
return 0;
}
public float deposit(int accountNbr, float amount)
throws AccountNotFoundException {
// TODO Auto-generated method stub
return 0;
}
public List<IAccount> getAllAccounts() {
// TODO Auto-generated method stub
return null;
}
public float withdraw(int accountNbr, float amount)
throws AccountNotFoundException, InsufficientFundsException {
// TODO Auto-generated method stub
return 0;
}
public float closeAccount(int accountNbr) throws AccountNotFoundException {
// TODO Auto-generated method stub
return 0;
}
@Override
public IAccount findAccount(int accountNbr) throws AccountNotFoundException {
// TODO Auto-generated method stub
return null;
}
}
| true
|
5659626898e31d77a4061106eacf17c04714a48f
|
Java
|
l2x6/cq-maven-plugin
|
/maven-plugin/src/test/expected/promote-extension-foo/extensions/foo/deployment/src/main/java/org/apache/camel/quarkus/component/foo/deployment/FooProcessor.java
|
UTF-8
| 678
| 1.601563
| 2
|
[
"Apache-2.0"
] |
permissive
|
package org.apache.camel.quarkus.component.foo.deployment;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.pkg.steps.NativeBuild;
import org.apache.camel.quarkus.core.JvmOnlyRecorder;
import org.jboss.logging.Logger;
public class FooProcessor {
private static final Logger LOG = Logger.getLogger(IrcProcessor.class);
private static final String FEATURE = "camel-foo";
@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}
}
| true
|
5c45c04371c449d2512c6f8011167b109e7d15fb
|
Java
|
sokon112/student
|
/src/ch5/Printer.java
|
UTF-8
| 339
| 3.25
| 3
|
[] |
no_license
|
package ch5;
public class Printer {
void println(int num) {
System.out.println(num);
}
void println(boolean bool) {
System.out.println(bool);
}
void println(double number) {
System.out.println(number);
}
void println(String name) {
System.out.println(name);
}
void println(char word) {
System.out.println(word);
}
}
| true
|
ae8f61028e2d474315c684a6c103e8f215e37e59
|
Java
|
MatousVales/RadioLocator
|
/app/src/main/java/com/example/matous/radiolocator/Classes/DBHelper.java
|
UTF-8
| 4,243
| 2.53125
| 3
|
[] |
no_license
|
package com.example.matous.radiolocator.Classes;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.example.matous.radiolocator.Activities.DatabaseActivity;
import com.example.matous.radiolocator.Models.Datapoint;
import com.example.matous.radiolocator.Models.Measurement;
import java.util.ArrayList;
/**
* Created by Matous on 27.02.2016.
*/
public class DBHelper extends SQLiteOpenHelper{
public static final String DATABASE_NAME = "Measurements.db";
public static final String TABLE_NAME = "Measurements";
public static final String COLUMN_mID = "mID";
public static final String COLUMN_DATE = "datetime";
public static final String COLUMN_LATITUDE = "latitude";
public static final String COLUMN_LONGITUDE = "longitude";
public static final String COLUMN_ANGLE = "angle";
private ArrayList<Measurement> measurements = null;
private ArrayList<Datapoint> datapoints = null;
public DBHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE Measurements ( mID INTEGER, datetime TEXT, latitude REAL, longitude REAL, angle REAL)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS Measurements");
onCreate(db);
}
public boolean deleteMeasurement(int id){
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_NAME, COLUMN_mID + "=" + id, null);
return true;
}
public boolean insertMeasurement(ContentValues cv){
SQLiteDatabase db = this.getWritableDatabase();
db.insert(TABLE_NAME, null, cv);
return true;
}
public ArrayList<Measurement> getMeasurement(int pos){
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery("select mID, count(mID) as Count from " + TABLE_NAME + " group by mID having mID =" + pos + "", null);
cursor.moveToFirst();
measurements = new ArrayList<>();
while(!cursor.isAfterLast()){
measurements.add(new Measurement(cursor.getInt(cursor.getColumnIndex(COLUMN_mID)),cursor.getInt(cursor.getColumnIndex("Count"))));
cursor.moveToNext();
}
return measurements;
}
public ArrayList<Measurement> getMeasurements(){
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery("select mID, count(mID) as Count from " + TABLE_NAME + " group by mID",null);
cursor.moveToFirst();
measurements = new ArrayList<>();
while(!cursor.isAfterLast()){
measurements.add(new Measurement(cursor.getInt(cursor.getColumnIndex(COLUMN_mID)),cursor.getInt(cursor.getColumnIndex("Count"))));
cursor.moveToNext();
}
return measurements;
}
public ArrayList<Datapoint> getDatapoints(int id){
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery("select * from " + TABLE_NAME + " where mID=" + id +"" ,null);
cursor.moveToFirst();
datapoints = new ArrayList<>();
while(!cursor.isAfterLast()){
datapoints.add(new Datapoint(cursor.getString(cursor.getColumnIndex(COLUMN_DATE)), cursor.getDouble(cursor.getColumnIndex(COLUMN_LATITUDE)), cursor.getDouble(cursor.getColumnIndex(COLUMN_LONGITUDE)), cursor.getDouble(cursor.getColumnIndex(COLUMN_ANGLE))));
cursor.moveToNext();
}
return datapoints;
}
public void removeAll()
{
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_NAME, "1", null);
}
public boolean isEmpty(){
SQLiteDatabase db = this.getWritableDatabase();
Cursor c = db.rawQuery("select count(*) from " + TABLE_NAME + "",null);
if(c != null){
c.moveToFirst();
if(c.getInt(0) == 0){
return true;
}
} else {
return false;
}
return false;
}
}
| true
|
6ccdda21af81e8ab464badef2f7107627d9db473
|
Java
|
HugoD98/BedugulVoyages
|
/AGPDynWebProj/src/tests/AlgorithmTest.java
|
UTF-8
| 3,516
| 3.046875
| 3
|
[] |
no_license
|
package tests;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import org.junit.Test;
import algorithm.Algorithm;
import algorithm.AlgorithmUtility;
import environment.TouristicSite;
import environment.Transport;
import organisation.Excursion;
import organisation.Stay;
public class AlgorithmTest {
public void testFillProgram() throws Exception {
Algorithm algo = new Algorithm("nager peintre", 4, 3, 10000, 3);
algo.fillProgram();
for(int i=0; i<algo.getProgram().length; i++) {
System.out.println("pour le jour : "+i+" on a "+algo.getProgram()[i]+" excursions.");
}
}
public void testCloserSite() {
TouristicSite t1 = new TouristicSite("templeA", "culturel", 25, 2, 10, 10);
TouristicSite t2 = new TouristicSite("templeB", "culturel", 25, 3, 1, 1);
TouristicSite t3 = new TouristicSite("surf", "sportive", 200, 2, 9, 9);
ArrayList<TouristicSite> touristicSiteMap1 = new ArrayList<TouristicSite>();
touristicSiteMap1.add(t1);
touristicSiteMap1.add(t2);
TouristicSite t = AlgorithmUtility.getCloserSite(t3, touristicSiteMap1);
assertEquals(t1, t);
}
public void testCreateExcursion() throws Exception {
Algorithm algo = new Algorithm("nager peintres panoramique plongée cyclisme mer volcan jet ski danse", 4, 3, 1000, 3);
Excursion exc = algo.createExcursion(100, 180);
ArrayList<Transport> trans = exc.getTransports();
ArrayList<TouristicSite> sites = exc.getTouristicSites();
int comfort = exc.getComfort();
int price = exc.getPrice();
for(TouristicSite t : sites) {
System.out.println(t.getName());
}
for(Transport t : trans) {
System.out.println(t.getName());
}
System.out.println(comfort);
System.out.println(price);
}
public void testSetHotel() throws Exception{
Algorithm algo = new Algorithm("nager peintres panoramique plongée cyclisme nature ", 4, 4, 100, 3);
algo.addHotel(100);
System.out.println(algo.getHotels().get(algo.getHotels().size()-1).getName());
System.out.println(algo.getHotels().get(algo.getHotels().size()-1).getStar());
algo.addHotel(100);
System.out.println(algo.getHotels().get(algo.getHotels().size()-1).getName());
System.out.println(algo.getHotels().get(algo.getHotels().size()-1).getStar());
algo.addHotel(100);
System.out.println(algo.getHotels().get(algo.getHotels().size()-1).getName());
System.out.println(algo.getHotels().get(algo.getHotels().size()-1).getStar());
algo.addHotel(100);
System.out.println(algo.getHotels().get(algo.getHotels().size()-1).getName());
System.out.println(algo.getHotels().get(algo.getHotels().size()-1).getStar());
algo.addHotel(100);
System.out.println(algo.getHotels().get(algo.getHotels().size()-1).getName());
System.out.println(algo.getHotels().get(algo.getHotels().size()-1).getStar());
algo.addHotel(100);
System.out.println(algo.getHotels().get(algo.getHotels().size()-1).getName());
System.out.println(algo.getHotels().get(algo.getHotels().size()-1).getStar());
}
@Test
public void testAlgo() throws Exception {
Algorithm algo = new Algorithm("nager peintres panoramique plongée cyclisme volcanique nature Quad mer jet ski danse falaise", 3, 3, 500, 1);
ArrayList<Stay> test = algo.launch(3);
ArrayList<Stay> test2 = AlgorithmUtility.stays;
assertEquals(test, test2);
}
public void testRecupText() throws Exception {
String s = AlgorithmUtility.getText("Mont Batur");
System.out.println("test "+s);
}
}
| true
|
75b3071d27a4b814c6a35bc6beec263b90001c04
|
Java
|
LionelBeato/weeksixspring
|
/src/main/java/com/example/weeksix/Service/DonutService.java
|
UTF-8
| 796
| 2.234375
| 2
|
[] |
no_license
|
package com.example.weeksix.Service;
import com.example.weeksix.Model.Donut;
import com.example.weeksix.Repo.DonutRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Optional;
@Service
public class DonutService {
@Autowired
DonutRepo donutRepo;
//get all method
public Iterable getAllDonuts(){
return donutRepo.findAll();
};
public Donut createDonut(Donut donut){
return donutRepo.save(donut);
};
public Optional<Donut> updateDonut(Long id){
return donutRepo.findById(id);
};
public Optional<Donut> getDonut(Long id){
return donutRepo.findById(id);
};
public void deleteDonut(Long id){
donutRepo.deleteById(id);
}
}
| true
|
857291e9c071a917ed5a1e5e21a042f183330fcd
|
Java
|
angel96/Design-Testing2
|
/D06 - Control Check/Control Check - Aleks/Item 3 - Project/Acme-Rookies/src/main/java/services/PositionDataService.java
|
UTF-8
| 4,010
| 2.28125
| 2
|
[] |
no_license
|
package services;
import java.util.Collection;
import java.util.Date;
import javax.transaction.Transactional;
import javax.validation.ValidationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.validation.BindingResult;
import org.springframework.validation.Validator;
import repositories.PositionDataRepository;
import security.LoginService;
import domain.Curricula;
import domain.PositionData;
import domain.Rookie;
@Service
@Transactional
public class PositionDataService extends AbstractService {
@Autowired
private PositionDataRepository repository;
@Autowired
private CurriculaService serviceCurricula;
@Autowired
private Validator validator;
public void flush() {
this.repository.flush();
}
public Collection<PositionData> saveIterable(final Collection<PositionData> save) {
return this.repository.save(save);
}
public Curricula findCurriculaByPositionDataId(final int id) {
return this.repository.findCurriculaByPositionDataId(id);
}
public PositionData findOne(final int id) {
return this.repository.findOne(id);
}
public PositionData create() {
PositionData result;
result = new PositionData();
result.setStartDate(new Date());
result.setEndDate(new Date());
result.setTitle("");
result.setDescription("");
return result;
}
public PositionData copyFactory(final PositionData copy) {
PositionData result;
result = new PositionData();
result.setStartDate(copy.getStartDate());
result.setEndDate(copy.getEndDate());
result.setTitle(copy.getTitle());
result.setDescription(copy.getDescription());
return result;
}
public PositionData save(final PositionData saveTo, final int curricula) {
Rookie h;
h = (Rookie) this.repository.findActorByUserAccountId(LoginService.getPrincipal().getId());
Curricula c;
c = this.serviceCurricula.findOne(curricula);
Assert.isTrue(h.equals(c.getRookie()));
PositionData result;
result = this.repository.save(saveTo);
Collection<PositionData> col;
col = c.getPositionsData();
if (!col.contains(result)) {
col.add(result);
c.setPositionsData(col);
}
return result;
}
public PositionData reconstruct(final PositionData reconsTo, final BindingResult binding) {
PositionData result;
if (reconsTo.getId() == 0)
result = reconsTo;
else {
result = this.repository.findOne(reconsTo.getId());
result.setStartDate(reconsTo.getStartDate());
result.setEndDate(reconsTo.getEndDate());
result.setTitle(reconsTo.getTitle());
result.setDescription(reconsTo.getDescription());
}
this.validator.validate(result, binding);
if (binding.hasErrors())
throw new ValidationException();
return result;
}
public void delete(final int id) {
PositionData deleteTo;
deleteTo = this.repository.findOne(id);
Curricula c;
c = this.repository.findCurriculaByPositionDataId(id);
Rookie h;
h = (Rookie) this.repository.findActorByUserAccountId(LoginService.getPrincipal().getId());
Assert.isTrue(c.getRookie().equals(h));
Collection<PositionData> col;
col = c.getPositionsData();
col.remove(deleteTo);
c.setPositionsData(col);
}
public void deleteAllPositionData(final Curricula c) {
Rookie h;
h = (Rookie) this.repository.findActorByUserAccountId(LoginService.getPrincipal().getId());
Assert.isTrue(c.getRookie().equals(h), "You don't have permission to do this");
this.repository.delete(c.getPositionsData());
}
public boolean checkDates(final Date begin, final Date end) {
boolean res = true;
if (begin == null)
res = false;
if (end == null)
res = true;
if (begin == null && end == null)
res = false;
if (begin != null && end != null)
res = begin.before(end) && end.after(begin);
return res;
}
public void delete(final Collection<PositionData> pos) {
this.repository.delete(pos);//Este delete es el delete(Iterable) del repo
}
}
| true
|
00c783cf830c587fd6c022cbebe2ac9d78c850b3
|
Java
|
moutainhigh/chdHRP
|
/src/com/chd/hrp/acc/service/books/auxiliaryaccount/AccProjAuxiliaryAccountService.java
|
UTF-8
| 2,332
| 1.875
| 2
|
[] |
no_license
|
package com.chd.hrp.acc.service.books.auxiliaryaccount;
import java.util.List;
import java.util.Map;
import org.springframework.dao.DataAccessException;
public interface AccProjAuxiliaryAccountService {
public String collectProjSubjGeneralLedger(Map<String,Object> entityMap)throws DataAccessException;
public String collectAccProjSubjDetailLedger(Map<String, Object> entityMap)throws DataAccessException;
public String collectAccSubjProjGeneralLedger(Map<String,Object> entityMap) throws DataAccessException;
public String collectAccSubjProjDetailLedger(Map<String,Object> entityMap) throws DataAccessException;
public String collectProjEndOs(Map<String,Object> entityMap) throws DataAccessException;
//项目科目总账 普通打印
public List<Map<String, Object>> collectProjSubjGeneralLedgerPrint(Map<String,Object> entityMap)throws DataAccessException;
//项目科目总账 模板打印
public Map<String, Object> collectProjSubjGeneralLedgerPrintDate(Map<String,Object> entityMap)throws DataAccessException;
//项目科目明细账 普通打印
public List<Map<String, Object>> collectAccProjSubjDetailLedgerPrint(Map<String, Object> entityMap)throws DataAccessException;
//项目科目明细账 模板打印
public Map<String, Object> collectAccProjSubjDetailLedgerPrintDate(Map<String, Object> entityMap)throws DataAccessException;
//科目项目总账 普通打印
public List<Map<String, Object>> collectAccSubjProjGeneralLedgerPrint(Map<String,Object> entityMap) throws DataAccessException;
//科目项目总账 模板打印
public Map<String, Object> collectAccSubjProjGeneralLedgerPrintDate(Map<String,Object> entityMap) throws DataAccessException;
//科目项目明细账 普通打印
public List<Map<String, Object>> collectAccSubjProjDetailLedgerPrint(Map<String,Object> entityMap) throws DataAccessException;
//科目项目明细账 模板打印
public Map<String, Object> collectAccSubjProjDetailLedgerPrintDate(Map<String,Object> entityMap) throws DataAccessException;
//项目余额表 普通打印
public List<Map<String, Object>> collectProjEndOsPrint(Map<String,Object> entityMap) throws DataAccessException;
//项目余额表 模板打印
public Map<String, Object> collectProjEndOsPrintDate(Map<String,Object> entityMap) throws DataAccessException;
}
| true
|
fb5aca221396264014b4cd3fd09c5bce925d4264
|
Java
|
mwl/sdm
|
/nsp/cpr-ws/src/main/java/dk/nsi/stamdata/cpr/mapping/MunicipalityMapper.java
|
UTF-8
| 6,126
| 2.265625
| 2
|
[] |
no_license
|
/**
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Contributor(s): Contributors are attributed in the source code
* where applicable.
*
* The Original Code is "Stamdata".
*
* The Initial Developer of the Original Code is Trifork Public A/S.
*
* Portions created for the Original Code are Copyright 2011,
* Lægemiddelstyrelsen. All Rights Reserved.
*
* Portions created for the FMKi Project are Copyright 2011,
* National Board of e-Health (NSI). All Rights Reserved.
*/
package dk.nsi.stamdata.cpr.mapping;
import java.util.Map;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.google.common.collect.Ordering;
public class MunicipalityMapper
{
public String toCountyCode(String municipalityCode)
{
String countyCode = municipalityToCounty.get(municipalityCode);
Preconditions.checkState(countyCode != null, "The municipality code '%s' is not associated with any county. There is an error in the registry or CPR-service.", municipalityCode);
return countyCode;
}
private static final Map<String, String> municipalityToCounty;
static
{
// Ordering the entries in a tree by name should be faster than
// a hash map.
municipalityToCounty = Maps.newTreeMap(Ordering.usingToString());
// Region Hovedstaden
municipalityToCounty.put("0101", "1084");
municipalityToCounty.put("0147", "1084");
municipalityToCounty.put("0151", "1084");
municipalityToCounty.put("0153", "1084");
municipalityToCounty.put("0155", "1084");
municipalityToCounty.put("0157", "1084");
municipalityToCounty.put("0159", "1084");
municipalityToCounty.put("0161", "1084");
municipalityToCounty.put("0163", "1084");
municipalityToCounty.put("0165", "1084");
municipalityToCounty.put("0167", "1084");
municipalityToCounty.put("0169", "1084");
municipalityToCounty.put("0173", "1084");
municipalityToCounty.put("0175", "1084");
municipalityToCounty.put("0230", "1084");
municipalityToCounty.put("0183", "1084");
municipalityToCounty.put("0185", "1084");
municipalityToCounty.put("0187", "1084");
municipalityToCounty.put("0201", "1084");
municipalityToCounty.put("0190", "1084");
municipalityToCounty.put("0210", "1084");
municipalityToCounty.put("0250", "1084");
municipalityToCounty.put("0260", "1084");
municipalityToCounty.put("0270", "1084");
municipalityToCounty.put("0217", "1084");
municipalityToCounty.put("0219", "1084");
municipalityToCounty.put("0223", "1084");
municipalityToCounty.put("0240", "1084");
municipalityToCounty.put("0400", "1084");
municipalityToCounty.put("0411", "1084");
// Region Sjælland
municipalityToCounty.put("0350", "1085");
municipalityToCounty.put("0253", "1085");
municipalityToCounty.put("0259", "1085");
municipalityToCounty.put("0265", "1085");
municipalityToCounty.put("0269", "1085");
municipalityToCounty.put("0306", "1085");
municipalityToCounty.put("0320", "1085");
municipalityToCounty.put("0316", "1085");
municipalityToCounty.put("0326", "1085");
municipalityToCounty.put("0329", "1085");
municipalityToCounty.put("0330", "1085");
municipalityToCounty.put("0340", "1085");
municipalityToCounty.put("0360", "1085");
municipalityToCounty.put("0376", "1085");
municipalityToCounty.put("0370", "1085");
municipalityToCounty.put("0336", "1085");
municipalityToCounty.put("0390", "1085");
// Region Syddanmark (1083)
municipalityToCounty.put("0420", "1083");
municipalityToCounty.put("0430", "1083");
municipalityToCounty.put("0440", "1083");
municipalityToCounty.put("0410", "1083");
municipalityToCounty.put("0450", "1083");
municipalityToCounty.put("0461", "1083");
municipalityToCounty.put("0479", "1083");
municipalityToCounty.put("0482", "1083");
municipalityToCounty.put("0480", "1083");
municipalityToCounty.put("0492", "1083");
municipalityToCounty.put("0510", "1083");
municipalityToCounty.put("0580", "1083");
municipalityToCounty.put("0561", "1083");
municipalityToCounty.put("0563", "1083");
municipalityToCounty.put("0530", "1083");
municipalityToCounty.put("0573", "1083");
municipalityToCounty.put("0575", "1083");
municipalityToCounty.put("0607", "1083");
municipalityToCounty.put("0621", "1083");
municipalityToCounty.put("0630", "1083");
municipalityToCounty.put("0766", "1083");
municipalityToCounty.put("0615", "1083");
municipalityToCounty.put("0657", "1083");
municipalityToCounty.put("0661", "1083");
municipalityToCounty.put("0756", "1083");
// Region Midtjylland (1082)
municipalityToCounty.put("0665", "1082");
municipalityToCounty.put("0760", "1082");
municipalityToCounty.put("0671", "1082");
municipalityToCounty.put("0706", "1082");
municipalityToCounty.put("0707", "1082");
municipalityToCounty.put("0710", "1082");
municipalityToCounty.put("0727", "1082");
municipalityToCounty.put("0730", "1082");
municipalityToCounty.put("0741", "1082");
municipalityToCounty.put("0740", "1082");
municipalityToCounty.put("0746", "1082");
municipalityToCounty.put("0751", "1082");
municipalityToCounty.put("0779", "1082");
municipalityToCounty.put("0791", "1082");
// Region Nordjylland (1081)
municipalityToCounty.put("0773", "1081");
municipalityToCounty.put("0787", "1081");
municipalityToCounty.put("0810", "1081");
municipalityToCounty.put("0813", "1081");
municipalityToCounty.put("0860", "1081");
municipalityToCounty.put("0846", "1081");
municipalityToCounty.put("0825", "1081");
municipalityToCounty.put("0840", "1081");
municipalityToCounty.put("0849", "1081");
municipalityToCounty.put("0851", "1081");
municipalityToCounty.put("0820", "1081");
}
}
| true
|
456a15b38291b5516afd35ee45b22b96544a4b6b
|
Java
|
saisandeep2218/My_Jenkins_Master_Branch
|
/src/PageObjects/UserMgmtPage.java
|
UTF-8
| 457
| 1.5625
| 2
|
[] |
no_license
|
package PageObjects;
import org.openqa.selenium.By;
public class UserMgmtPage {
public static By chkboxAll = By.id("ohrmList_chkSelectAll");
public static By drpdwnUsr = By.id("searchSystemUser_userType");
public static By userlabel = By.xpath("//*[@id='search_form']/fieldset/ol/li[2]/label");
public static String lnktxtString = "Admin";
public static By lnktxt = By.partialLinkText(lnktxtString);
}
| true
|
df80da978073d3468eb1c263a409c9f7670a1606
|
Java
|
102092/spring-study
|
/spring-framework/demospring51/src/main/java/com/donghwan/demospring51/MyEventHandler.java
|
UTF-8
| 975
| 2.4375
| 2
|
[] |
no_license
|
package com.donghwan.demospring51;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
@Component
public class MyEventHandler{
@EventListener
@Async
public void onApplicationEvent(MyEvent event) {
System.out.println(Thread.currentThread().toString());
System.out.println("이벤트를 받았다. 데이터는 "+ event.getData());
}
@EventListener
@Async
public void onApplicationEvent(ContextRefreshedEvent event) {
System.out.println(Thread.currentThread().toString());
System.out.println("ContextRefreshedEvent");
}
@EventListener
@Async
public void onApplicationEvent(ContextClosedEvent event) {
System.out.println(Thread.currentThread().toString());
System.out.println("ContextClosedEvent");
}
}
| true
|
78bfc20fdda288256b53d5a7a332c19a24d791a9
|
Java
|
rebornwhu/RetrofitExample
|
/app/src/main/java/com/andexert/retrofitexample/rest/RestApiDispenser.java
|
UTF-8
| 1,669
| 2.75
| 3
|
[] |
no_license
|
package com.andexert.retrofitexample.rest;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.HashMap;
import java.util.Map;
import retrofit.RestAdapter;
import retrofit.converter.GsonConverter;
/**
* Created by xiaolu on 4/30/15.
*/
/** Inspired by this post
* http://stackoverflow.com/questions/25275106/where-to-attach-the-reference-to-a-retrofit-adapter-in-android
*/
public class RestApiDispenser {
public static final String BASE_URL = "http://api.openweathermap.org/";
// put all API "interfaces" into a hash map so that every interface is created only once
private Map<String, Object> restApiInstances = new HashMap<String, Object>();
private RestAdapter restAdapter;
// restAdapter is treated as an argument for the constructor which implies that rest adater
// can be a singleton class and be shared by all API interfaces
public RestApiDispenser() {
Gson gson = new GsonBuilder()
.registerTypeAdapterFactory(new ItemTypeAdapterFactory())
.create();
this.restAdapter = new RestAdapter.Builder()
.setLogLevel(RestAdapter.LogLevel.FULL)
.setEndpoint(RestApiDispenser.BASE_URL)
.setConverter(new GsonConverter(gson))
.build();
}
public <T> T getRestApi(Class<T> apiClass) {
T client = null;
if ((client = (T) restApiInstances.get(apiClass.getCanonicalName())) != null) {
return client;
}
client = restAdapter.create(apiClass);
restApiInstances.put(apiClass.getCanonicalName(), client);
return client;
}
}
| true
|
1fb41aba9f3f65be36aa12f1cd47c923e4a23c12
|
Java
|
shaileshbhuvanendran/RestService_SpringBoot
|
/src/main/java/com/example/adcampaign/controller/AdCampaignController.java
|
UTF-8
| 2,317
| 2.375
| 2
|
[] |
no_license
|
package com.example.adcampaign.controller;
import java.util.Map;
import java.util.NoSuchElementException;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.example.adcampaign.AdCampaignDemoApplication;
import com.example.adcampaign.domain.CampaignBean;
@RestController
@RequestMapping(value = "/adcampaigns")
public class AdCampaignController {
// --------Retrieve all ADCampaigns----------
@RequestMapping(value = "/", method = RequestMethod.GET)
public Map<String, CampaignBean> fetchAllAds() {
return AdCampaignDemoApplication.campaignRepository;
}
// --------Create a ADCampaign----------
@RequestMapping(value = "/ad", method = RequestMethod.POST)
public CampaignBean createCampaign(@RequestParam(value = "partnerId") String partnerId,
@RequestParam(value = "duration") int duration, @RequestParam(value = "adContent") String adContent) {
CampaignBean campaign = new CampaignBean(partnerId, duration, adContent);
if (AdCampaignDemoApplication.campaignRepository.containsKey(new String(campaign.getPartnerId()))) {
AdCampaignDemoApplication.campaignRepository.put(new String(campaign.getPartnerId()), campaign);
} else {
throw new IllegalArgumentException("The partner id already exists");
}
return campaign;
}
// --------Fetch a ADCampaign----------
@RequestMapping(value = "/ad/{partnerId}", method = RequestMethod.GET)
public CampaignBean fetchAd(@PathVariable("partnerId") String partnerId) {
if (StringUtils.isEmpty(partnerId)) {
throw new NoSuchElementException("PartnerId " + partnerId + " does not exist");
}
return AdCampaignDemoApplication.campaignRepository.get(partnerId);
}
@ExceptionHandler(value = IllegalArgumentException.class)
public String handleNotFound(IllegalArgumentException e) {
return e.getMessage();
}
@ExceptionHandler(value = NoSuchElementException.class)
public String handleNotFound(NoSuchElementException e) {
return e.getMessage();
}
}
| true
|
147d055cd583ca32ae7c374336a0e69473f2adc7
|
Java
|
liufade/MyMole
|
/app/src/main/java/com/example/computer/mymole/Resp/mianResp/HomeJinXuanResp.java
|
UTF-8
| 468
| 1.945313
| 2
|
[] |
no_license
|
package com.example.computer.mymole.Resp.mianResp;
import com.example.computer.mymole.Resp.BaseResp;
import com.example.computer.mymole.Resp.mianResp.HomeJinXuanEntity;
/**
* Created by computer on 2016/7/22.
*/
public class HomeJinXuanResp extends BaseResp {
private HomeJinXuanEntity result;
public HomeJinXuanEntity getResult() {
return result;
}
public void setResult(HomeJinXuanEntity result) {
this.result = result;
}
}
| true
|
5b3aa615d0efd3aca9853640b4524950b7496d9e
|
Java
|
lucatsv/hermes
|
/microservices/webservice/src/main/java/com/hermes/webservice/models/Schedule.java
|
UTF-8
| 591
| 2.203125
| 2
|
[] |
no_license
|
package com.hermes.webservice.models;
import com.hermes.webservice.enums.Periodicity;
import java.time.LocalDateTime;
public class Schedule {
private LocalDateTime startDate;
public LocalDateTime getStartDate() {
return startDate;
}
public void setStartDate(LocalDateTime startDate) {
this.startDate = startDate;
}
private LocalDateTime endDate;
public LocalDateTime getEndDate() {
return endDate;
}
public void setEndDate(LocalDateTime endDate) {
this.endDate = endDate;
}
public Periodicity periodicity;
}
| true
|
354db16b35d565fbf6b9a3ca1034b3bebd5aaa1e
|
Java
|
NeillWhite/eBiomer
|
/PolyPeptideResidue.java
|
UTF-8
| 78,064
| 2.328125
| 2
|
[
"MIT"
] |
permissive
|
package com.goosebumpanalytics.biomer;
public class PolyPeptideResidue {
Residue residue;
Residue getResidue( String residueName ){
if ( residueName.equals( "Lace" ) ){
createResidue( "ACE", 6 );
residue.atom[ 0 ] = new Atom( "H1", 0.000f, 0.000f, 0.000f );
residue.atom[ 1 ] = new Atom( "CH3", 0.000f, 1.090f, 0.000f );
residue.atom[ 2 ] = new Atom( "H2", 1.028f, 1.453f, 0.000f );
residue.atom[ 3 ] = new Atom( "H3", -0.514f, 1.453f, -0.890f );
residue.atom[ 4 ] = new Atom( "C", -0.721f, 1.600f, 1.249f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.839f, 2.806f, 1.453f, -0.504f );
residue.atom[ 0 ].addBond( 1 );
residue.atom[ 1 ].addBond( 2, 3 );
residue.atom[ 1 ].addBond( 4 );
residue.atom[ 4 ].addBond( 5 );
}
else if ( residueName.equals( "Lala" ) ){
createResidue( "ALA", 10 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 1.580f, -1.780f, 1.205f, 0.036f );
residue.atom[ 8 ] = new Atom( "HB2", 3.077f, -0.816f, 1.241f, 0.036f );
residue.atom[ 9 ] = new Atom( "HB3", 1.638f, -0.260f, 2.131f, 0.036f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
}
else if ( residueName.equals( "Larg" ) ){
createResidue( "ARG", 24 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.080f );
residue.atom[ 7 ] = new Atom( "HB1", 3.077f, -0.816f, 1.241f, 0.056f );
residue.atom[ 8 ] = new Atom( "HB2", 1.638f, -0.260f, 2.131f, 0.056f );
residue.atom[ 9 ] = new Atom( "CG", 1.418f, -2.182f, 1.194f, -0.103f );
residue.atom[ 10 ] = new Atom( "HG1", 0.329f, -2.136f, 1.186f, 0.074f );
residue.atom[ 11 ] = new Atom( "HG2", 1.767f, -2.692f, 0.296f, 0.074f );
residue.atom[ 12 ] = new Atom( "CD", 1.884f, -2.951f, 2.427f, -0.228f );
residue.atom[ 13 ] = new Atom( "HD1", 2.973f, -2.984f, 2.445f, 0.133f );
residue.atom[ 14 ] = new Atom( "HD2", 1.511f, -2.438f, 3.314f, 0.133f );
residue.atom[ 15 ] = new Atom( "NE", 1.349f, -4.332f, 2.424f, -0.324f );
residue.atom[ 16 ] = new Atom( "HE", 0.761f, -4.619f, 1.655f, 0.269f );
residue.atom[ 17 ] = new Atom( "CZ", 1.606f, -5.209f, 3.389f, 0.760f );
residue.atom[ 18 ] = new Atom( "NH1", 2.372f, -4.905f, 4.434f, -0.624f );
residue.atom[ 19 ] = new Atom( "HH11", 2.774f, -3.982f, 4.509f, 0.361f );
residue.atom[ 20 ] = new Atom( "HH12", 2.546f, -5.597f, 5.148f, 0.361f );
residue.atom[ 21 ] = new Atom( "NH2", 1.074f, -6.424f, 3.287f, -0.624f );
residue.atom[ 22 ] = new Atom( "HH21", 0.494f, -6.653f, 2.493f, 0.361f );
residue.atom[ 23 ] = new Atom( "HH22", 1.252f, -7.113f, 4.004f, 0.361f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11, 12 );
residue.atom[ 12 ].addBond( 13, 14, 15 );
residue.atom[ 15 ].addBond( 16, 17 );
residue.atom[ 17 ].addBond( 18, 21 );
residue.atom[ 18 ].addBond( 19, 20 );
residue.atom[ 21 ].addBond( 22, 23 );
}
else if ( residueName.equals( "Lasn" ) ){
createResidue( "ASN", 14 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.086f );
residue.atom[ 7 ] = new Atom( "HB1", 3.077f, -0.800f, 1.251f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 1.613f, -0.256f, 2.118f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.439f, -2.188f, 1.232f, 0.675f );
residue.atom[ 10 ] = new Atom( "OD1", 0.720f, -2.579f, 0.315f, -0.470f );
residue.atom[ 11 ] = new Atom( "ND2", 1.780f, -2.961f, 2.266f, -0.867f );
residue.atom[ 12 ] = new Atom( "HD21", 2.374f, -2.591f, 2.995f, 0.344f );
residue.atom[ 13 ] = new Atom( "HD22", 1.443f, -3.912f, 2.315f, 0.344f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11 );
residue.atom[ 11 ].addBond( 12, 13 );
}
else if ( residueName.equals( "Lasp" ) ){
createResidue( "ASP", 12 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.398f );
residue.atom[ 7 ] = new Atom( "HB1", 3.077f, -0.816f, 1.241f, 0.071f );
residue.atom[ 8 ] = new Atom( "HB2", 1.638f, -0.260f, 2.131f, 0.071f );
residue.atom[ 9 ] = new Atom( "CG", 1.417f, -2.185f, 1.194f, 0.714f );
residue.atom[ 10 ] = new Atom( "OD1", 2.107f, -3.069f, 0.620f, -0.721f );
residue.atom[ 11 ] = new Atom( "OD2", 0.297f, -2.369f, 1.741f, -0.721f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11 );
}
else if ( residueName.equals( "Lcys" ) ){
createResidue( "CYS", 11 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.060f );
residue.atom[ 7 ] = new Atom( "HB1", 3.076f, -0.748f, 1.283f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 1.528f, -0.252f, 2.075f, 0.038f );
residue.atom[ 9 ] = new Atom( "SG", 1.409f, -2.479f, 1.367f, -0.135f );
residue.atom[ 10 ] = new Atom( "HG", 1.890f, -3.023f, 2.481f, 0.135f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10 );
}
else if ( residueName.equals( "Lcyx" ) ){
createResidue( "CYX", 10 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 3.076f, -0.748f, 1.283f, 0.0495f );
residue.atom[ 8 ] = new Atom( "HB2", 1.528f, -0.252f, 2.075f, 0.0495f );
residue.atom[ 9 ] = new Atom( "SG", 1.409f, -2.479f, 1.367f, 0.015f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
}
else if ( residueName.equals( "Lgln" ) ){
createResidue( "GLN", 17 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 3.077f, -0.816f, 1.241f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 1.638f, -0.260f, 2.131f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.418f, -2.182f, 1.194f, -0.102f );
residue.atom[ 10 ] = new Atom( "HG1", 0.330f, -2.135f, 1.168f, 0.057f );
residue.atom[ 11 ] = new Atom( "HG2", 1.792f, -2.681f, 0.300f, 0.057f );
residue.atom[ 12 ] = new Atom( "CD", 1.861f, -2.984f, 2.410f, 0.675f );
residue.atom[ 13 ] = new Atom( "OE1", 2.585f, -2.476f, 3.263f, -0.470f );
residue.atom[ 14 ] = new Atom( "NE2", 1.422f, -4.243f, 2.489f, -0.867f );
residue.atom[ 15 ] = new Atom( "HE21", 0.828f, -4.614f, 1.761f, 0.344f );
residue.atom[ 16 ] = new Atom( "HE22", 1.687f, -4.819f, 3.275f, 0.344f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11, 12 );
residue.atom[ 12 ].addBond( 13, 14 );
residue.atom[ 14 ].addBond( 15, 16 );
}
else if ( residueName.equals( "Lglu" ) ){
createResidue( "GLU", 15 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.184f );
residue.atom[ 7 ] = new Atom( "HB1", 3.077f, -0.816f, 1.241f, 0.092f );
residue.atom[ 8 ] = new Atom( "HB2", 1.638f, -0.260f, 2.131f, 0.092f );
residue.atom[ 9 ] = new Atom( "CG", 1.423f, -2.168f, 1.195f, -0.398f );
residue.atom[ 10 ] = new Atom( "HG1", 0.334f, -2.122f, 1.187f, 0.071f );
residue.atom[ 11 ] = new Atom( "HG2", 1.772f, -2.678f, 0.296f, 0.071f );
residue.atom[ 12 ] = new Atom( "CD", 1.890f, -2.939f, 2.429f, 0.714f );
residue.atom[ 13 ] = new Atom( "OE1", 1.161f, -2.878f, 3.455f, -0.721f );
residue.atom[ 14 ] = new Atom( "OE2", 2.971f, -3.578f, 2.334f, -0.721f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11, 12 );
residue.atom[ 12 ].addBond( 13, 14 );
}
else if ( residueName.equals( "Lgly" ) ){
createResidue( "GLY", 7 );
residue.atom[ 0 ] = new Atom( "N", 2.027f, 1.358f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.697f, 1.839f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA1", 1.886f, -0.523f, -0.885f, 0.032f );
residue.atom[ 4 ] = new Atom( "HA2", 1.874f, -0.506f, 0.899f, 0.032f);
residue.atom[ 5 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 6 ] = new Atom( "O", -0.624f, 1.058f, 0.000f, -0.504f );
addBackboneBonds();
residue.atom[ 2 ].addBond( 5 );
residue.atom[ 5 ].addBond( 6 );
}
else if ( residueName.equals( "Lhid" ) ){
createResidue( "HID", 17 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 3.076f, -0.759f, 1.276f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 1.547f, -0.251f, 2.084f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.492f, -2.192f, 1.321f, -0.032f );
residue.atom[ 10 ] = new Atom( "ND1", 1.829f, -3.024f, 2.383f, -0.146f );
residue.atom[ 11 ] = new Atom( "HD1", 2.411f, -2.777f, 3.169f, 0.228f );
residue.atom[ 12 ] = new Atom( "CD2", 0.698f, -2.921f, 0.493f, 0.195f );
residue.atom[ 13 ] = new Atom( "HD2", 0.306f, -2.473f, -0.421f, 0.018f );
residue.atom[ 14 ] = new Atom( "CE1", 1.252f, -4.194f, 2.183f, 0.241f );
residue.atom[ 15 ] = new Atom( "HE1", 1.387f, -5.000f, 2.905f, 0.036f );
residue.atom[ 16 ] = new Atom( "NE2", 0.576f, -4.150f, 1.061f, -0.502f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 12 );
residue.atom[ 10 ].addBond( 11, 14 );
residue.atom[ 12 ].addBond( 13, 16 );
residue.atom[ 14 ].addBond( 15, 16 );
}
else if ( residueName.equals( "Lhie" ) ){
createResidue( "HIE", 17 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 3.076f, -0.759f, 1.276f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 1.547f, -0.251f, 2.084f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.492f, -2.192f, 1.321f, 0.251f );
residue.atom[ 10 ] = new Atom( "ND1", 1.829f, -3.024f, 2.383f, -0.502f );
residue.atom[ 11 ] = new Atom( "CD2", 0.698f, -2.921f, 0.493f, -0.184f );
residue.atom[ 12 ] = new Atom( "HD2", 0.306f, -2.473f, -0.421f, 0.114f );
residue.atom[ 13 ] = new Atom( "CE1", 1.252f, -4.194f, 2.183f, 0.241f );
residue.atom[ 14 ] = new Atom( "HE1", 1.387f, -5.000f, 2.905f, 0.036f );
residue.atom[ 15 ] = new Atom( "NE2", 0.576f, -4.150f, 1.061f, -0.146f );
residue.atom[ 16 ] = new Atom( "HE2", 0.041f, -4.916f, 0.677f, 0.228f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11 );
residue.atom[ 10 ].addBond( 13 );
residue.atom[ 11 ].addBond( 12, 15 );
residue.atom[ 13 ].addBond( 14, 15 );
residue.atom[ 15 ].addBond( 16 );
}
else if ( residueName.equals( "Lhip" ) ){
createResidue( "HIP", 18 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 3.076f, -0.759f, 1.276f, 0.086f );
residue.atom[ 8 ] = new Atom( "HB2", 1.547f, -0.251f, 2.084f, 0.086f );
residue.atom[ 9 ] = new Atom( "CG", 1.492f, -2.192f, 1.321f, 0.058f );
residue.atom[ 10 ] = new Atom( "ND1", 1.829f, -3.024f, 2.383f, -0.058f );
residue.atom[ 11 ] = new Atom( "HD1", 2.411f, -2.777f, 3.169f, 0.306f );
residue.atom[ 12 ] = new Atom( "CD2", 0.698f, -2.921f, 0.493f, -0.037f );
residue.atom[ 13 ] = new Atom( "HD2", 0.306f, -2.473f, -0.421f, 0.153f );
residue.atom[ 14 ] = new Atom( "CE1", 1.252f, -4.194f, 2.183f, 0.114f );
residue.atom[ 15 ] = new Atom( "HE1", 1.387f, -5.000f, 2.905f, 0.158f );
residue.atom[ 16 ] = new Atom( "NE2", 0.576f, -4.150f, 1.061f, -0.058f );
residue.atom[ 17 ] = new Atom( "HE2", 0.041f, -4.916f, 0.677f, 0.306f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 12 );
residue.atom[ 10 ].addBond( 11, 14 );
residue.atom[ 12 ].addBond( 13, 16 );
residue.atom[ 14 ].addBond( 15, 16 );
residue.atom[ 16 ].addBond( 17 );
}
else if ( residueName.equals( "Lhis" ) ){
createResidue( "HIS", 18 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 3.076f, -0.759f, 1.276f, 0.086f );
residue.atom[ 8 ] = new Atom( "HB2", 1.547f, -0.251f, 2.084f, 0.086f );
residue.atom[ 9 ] = new Atom( "CG", 1.492f, -2.192f, 1.321f, 0.058f );
residue.atom[ 10 ] = new Atom( "ND1", 1.829f, -3.024f, 2.383f, -0.058f );
residue.atom[ 11 ] = new Atom( "HD1", 2.411f, -2.777f, 3.169f, 0.306f );
residue.atom[ 12 ] = new Atom( "CD2", 0.698f, -2.921f, 0.493f, -0.037f );
residue.atom[ 13 ] = new Atom( "HD2", 0.248f, -2.587f, -0.442f, 0.153f );
residue.atom[ 14 ] = new Atom( "CE1", 1.252f, -4.194f, 2.183f, 0.114f );
residue.atom[ 15 ] = new Atom( "HE1", 1.327f, -5.058f, 2.843f, 0.158f );
residue.atom[ 16 ] = new Atom( "NE2", 0.576f, -4.150f, 1.061f, -0.058f );
residue.atom[ 17 ] = new Atom( "HE2", 0.041f, -4.916f, 0.677f, 0.306f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 12 );
residue.atom[ 10 ].addBond( 11, 14 );
residue.atom[ 12 ].addBond( 13, 16 );
residue.atom[ 14 ].addBond( 15, 16 );
residue.atom[ 16 ].addBond( 17 );
}
else if ( residueName.equals( "Lile" ) ){
createResidue( "ILE", 19 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.875f, -0.500f, -0.902f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 2.009f, -0.733f, 1.245f, -0.012f );
residue.atom[ 7 ] = new Atom( "HB", 3.098f, -0.765f, 1.245f, 0.022f );
residue.atom[ 8 ] = new Atom( "CG1", 1.459f, -2.156f, 1.245f, -0.049f );
residue.atom[ 9 ] = new Atom( "HG11", 0.370f, -2.124f, 1.245f, 0.027f );
residue.atom[ 10 ] = new Atom( "HG12", 1.807f, -2.680f, 0.355f, 0.027f );
residue.atom[ 11 ] = new Atom( "CG2", 1.522f, 0.000f, 2.491f, -0.085f );
residue.atom[ 12 ] = new Atom( "HG21", 1.870f, -0.524f, 3.381f, 0.029f );
residue.atom[ 13 ] = new Atom( "HG22", 1.914f, 1.017f, 2.490f, 0.029f );
residue.atom[ 14 ] = new Atom( "HG23", 0.432f, 0.032f, 2.491f, 0.029f );
residue.atom[ 15 ] = new Atom( "CD1", 1.947f, -2.889f, 2.491f, -0.085f );
residue.atom[ 16 ] = new Atom( "HD11", 1.554f, -3.906f, 2.490f, 0.028f );
residue.atom[ 17 ] = new Atom( "HD12", 3.036f, -2.921f, 2.491f, 0.028f);
residue.atom[ 18 ] = new Atom( "HD13", 1.599f, -2.365f, 3.381f, 0.028f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 11 );
residue.atom[ 8 ].addBond( 9, 10, 15 );
residue.atom[ 11 ].addBond( 12, 13, 14 );
residue.atom[ 15 ].addBond( 16, 17, 18 );
}
else if ( residueName.equals( "Lleu" ) ){
createResidue( "LEU", 19 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.061f );
residue.atom[ 7 ] = new Atom( "HB1", 3.077f, -0.816f, 1.241f, 0.033f );
residue.atom[ 8 ] = new Atom( "HB2", 1.638f, -0.260f, 2.131f, 0.033f );
residue.atom[ 9 ] = new Atom( "CG", 1.418f, -2.182f, 1.194f, -0.010f );
residue.atom[ 10 ] = new Atom( "HG", 0.329f, -2.136f, 1.186f, 0.031f );
residue.atom[ 11 ] = new Atom( "CD1", 1.906f, -2.894f, -0.063f, -0.107f );
residue.atom[ 12 ] = new Atom( "HD11", 1.499f, -3.905f, -0.090f, 0.034f );
residue.atom[ 13 ] = new Atom( "HD12", 1.573f, -2.345f, -0.943f, 0.034f );
residue.atom[ 14 ] = new Atom( "HD13", 2.995f, -2.941f, -0.055f, 0.034f );
residue.atom[ 15 ] = new Atom( "CD2", 1.884f, -2.951f, 2.427f, -0.107f );
residue.atom[ 16 ] = new Atom( "HD21", 1.476f, -3.962f, 2.400f, 0.034f );
residue.atom[ 17 ] = new Atom( "HD22", 2.973f, -2.998f, 2.436f, 0.034f );
residue.atom[ 18 ] = new Atom( "HD23", 1.534f, -2.443f, 3.325f, 0.034f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11, 15 );
residue.atom[ 11 ].addBond( 12, 13, 14 );
residue.atom[ 15 ].addBond( 16, 17, 18 );
}
else if ( residueName.equals( "Llys" ) ){
createResidue( "LYS", 22 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 3.077f, -0.816f, 1.241f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 1.638f, -0.260f, 2.131f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.418f, -2.182f, 1.194f, -0.160f );
residue.atom[ 10 ] = new Atom( "HG1", 0.329f, -2.136f, 1.186f, 0.116f );
residue.atom[ 11 ] = new Atom( "HG2", 1.767f, -2.692f, 0.296f, 0.116f );
residue.atom[ 12 ] = new Atom( "CD", 1.884f, -2.951f, 2.427f, -0.180f );
residue.atom[ 13 ] = new Atom( "HD1", 2.973f, -2.998f, 2.436f, 0.122f );
residue.atom[ 14 ] = new Atom( "HD2", 1.534f, -2.443f, 3.325f, 0.122f );
residue.atom[ 15 ] = new Atom( "CE", 1.314f, -4.366f, 2.389f, -0.038f );
residue.atom[ 16 ] = new Atom( "HE1", 0.225f, -4.318f, 2.381f, 0.098f );
residue.atom[ 17 ] = new Atom( "HE2", 1.663f, -4.874f, 1.491f, 0.098f );
residue.atom[ 18 ] = new Atom( "NZ", 1.763f, -5.107f, 3.577f, -0.138f );
residue.atom[ 19 ] = new Atom( "HZ1", 1.385f, -6.042f, 3.552f, 0.294f );
residue.atom[ 20 ] = new Atom( "HZ2", 2.772f, -5.150f, 3.585f, 0.294f );
residue.atom[ 21 ] = new Atom( "HZ3", 1.440f, -4.635f, 4.409f, 0.294f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11, 12 );
residue.atom[ 12 ].addBond( 13, 14, 15 );
residue.atom[ 15 ].addBond( 16, 17, 18 );
residue.atom[ 18 ].addBond( 19, 20, 21 );
}
else if ( residueName.equals( "Lmet" ) ){
createResidue( "MET", 17 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.151f );
residue.atom[ 7 ] = new Atom( "HB1", 3.077f, -0.816f, 1.241f, 0.027f );
residue.atom[ 8 ] = new Atom( "HB2", 1.638f, -0.260f, 2.131f, 0.027f );
residue.atom[ 9 ] = new Atom( "CG", 1.418f, -2.182f, 1.194f, -0.054f );
residue.atom[ 10 ] = new Atom( "HG1", 0.329f, -2.135f, 1.179f, 0.0652f );
residue.atom[ 11 ] = new Atom( "HG2", 1.775f, -2.688f, 0.297f, 0.0652f );
residue.atom[ 12 ] = new Atom( "SD", 1.962f, -3.109f, 2.652f, -0.025f );
residue.atom[ 13 ] = new Atom( "CE", 1.167f, -4.670f, 2.341f, -0.134f );
residue.atom[ 14 ] = new Atom( "HE1", 1.399f, -5.364f, 3.149f, 0.0652f );
residue.atom[ 15 ] = new Atom( "HE2", 0.088f, -4.523f, 2.287f, 0.0652f );
residue.atom[ 16 ] = new Atom( "HE3", 1.525f, -5.079f, 1.396f, 0.0652f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11, 12 );
residue.atom[ 12 ].addBond( 13 );
residue.atom[ 13 ].addBond( 14, 15, 16 );
}
else if ( residueName.equals( "Lnme" ) ){
createResidue( "NME", 6 );
residue.atom[ 0 ] = new Atom( "N", -1.227f, 0.728f, 2.125f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", -1.124f, -0.261f, 1.947f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", -1.918f, 1.159f, 3.323f, 0.03502f );
residue.atom[ 3 ] = new Atom( "HA1", -1.939f, 2.249f, 3.358f, 0.0586f );
residue.atom[ 4 ] = new Atom( "HA2", -2.939f, 0.777f, 3.311f, 0.0586f );
residue.atom[ 5 ] = new Atom( "HA3", -1.398f, 0.777f, 4.201f, 0.0586f );
addBackboneBonds();
residue.atom[ 2 ].addBond( 5 );
}
else if ( residueName.equals( "Lphe" ) ){
createResidue( "PHE", 20 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.100f );
residue.atom[ 7 ] = new Atom( "HB1", 3.076f, -0.759f, 1.276f, 0.108f );
residue.atom[ 8 ] = new Atom( "HB2", 1.547f, -0.251f, 2.084f, 0.108f );
residue.atom[ 9 ] = new Atom( "CG", 1.492f, -2.192f, 1.321f, -0.100f );
residue.atom[ 10 ] = new Atom( "CD1", 1.856f, -2.993f, 2.410f, -0.150f );
residue.atom[ 11 ] = new Atom( "HD1", 2.497f, -2.589f, 3.194f, 0.150f );
residue.atom[ 12 ] = new Atom( "CD2", 0.669f, -2.712f, 0.315f, -0.150f );
residue.atom[ 13 ] = new Atom( "HD2", 0.385f, -2.087f, -0.533f, 0.150f );
residue.atom[ 14 ] = new Atom( "CE1", 1.398f, -4.313f, 2.492f, -0.150f );
residue.atom[ 15 ] = new Atom( "HE1", 1.681f, -4.937f, 3.340f, 0.150f );
residue.atom[ 16 ] = new Atom( "CE2", 0.210f, -4.031f, 0.397f, -0.150f );
residue.atom[ 17 ] = new Atom( "HE2", -0.431f, -4.435f, -0.386f, 0.150f );
residue.atom[ 18 ] = new Atom( "CZ", 0.575f, -4.833f, 1.486f, -0.150f );
residue.atom[ 19 ] = new Atom( "HZ", 0.217f, -5.860f, 1.550f, 0.150f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 12 );
residue.atom[ 10 ].addBond( 11, 14 );
residue.atom[ 12 ].addBond( 13, 16 );
residue.atom[ 14 ].addBond( 15, 18 );
residue.atom[ 16 ].addBond( 17, 18 );
residue.atom[ 18 ].addBond( 19 );
}
else if ( residueName.equals( "Lpro" ) ){
createResidue( "PRO", 14 );
residue.atom[ 0 ] = new Atom( "N", 2.068f, 1.413f, 0.000f, -0.229f );
residue.atom[ 1 ] = new Atom( "CA", 1.523f, 0.000f, 0.000f, 0.035f );
residue.atom[ 2 ] = new Atom( "HA", 2.373f, -0.566f, -0.381f, 0.048f );
residue.atom[ 3 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.526f );
residue.atom[ 4 ] = new Atom( "O", -0.623f, 1.059f, -0.001f, -0.500f );
residue.atom[ 5 ] = new Atom( "CB", 0.361f, 0.011f, 0.950f, -0.115f );
residue.atom[ 6 ] = new Atom( "HB1", -0.547f, -0.274f, 0.417f, 0.061f );
residue.atom[ 7 ] = new Atom( "HB2", 0.547f, -0.695f, 1.758f, 0.061f );
residue.atom[ 8 ] = new Atom( "CG", 0.192f, 1.398f, 1.523f, -0.121f );
residue.atom[ 9 ] = new Atom( "HG1", -0.781f, 1.794f, 1.235f, 0.063f );
residue.atom[ 10 ] = new Atom( "HG2", 0.257f, 1.396f, 2.611f, 0.063f );
residue.atom[ 11 ] = new Atom( "CD", 1.274f, 2.235f, 0.905f, -0.0012f );
residue.atom[ 12 ] = new Atom( "HD1", 1.916f, 2.636f, 1.689f, 0.060f );
residue.atom[ 13 ] = new Atom( "HD2", 0.824f, 3.057f, 0.349f, 0.060f );
residue.atom[ 0 ].addBond( 1, 11 );
residue.atom[ 1 ].addBond( 2, 3, 5 );
residue.atom[ 3 ].addBond( 4 );
residue.atom[ 5 ].addBond( 6, 7, 8 );
residue.atom[ 8 ].addBond( 9, 10, 11 );
residue.atom[ 11 ].addBond( 12, 13 );
}
else if ( residueName.equals( "Lser" ) ){
createResidue( "SER", 11 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, 0.018f );
residue.atom[ 7 ] = new Atom( "HB1", 3.077f, -0.816f, 1.241f, 0.119f );
residue.atom[ 8 ] = new Atom( "HB2", 1.638f, -0.260f, 2.131f, 0.119f );
residue.atom[ 9 ] = new Atom( "OG", 1.453f, -2.094f, 1.197f, -0.550f );
residue.atom[ 10 ] = new Atom( "HG", 1.746f, -2.579f, 1.973f, 0.310f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10 );
}
else if ( residueName.equals( "Lthr" ) ){
createResidue( "THR", 14 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, 0.170f );
residue.atom[ 7 ] = new Atom( "HB", 1.580f, -1.780f, 1.205f, 0.082f );
residue.atom[ 8 ] = new Atom( "OG1", 1.530f, -0.101f, 2.411f, -0.550f );
residue.atom[ 9 ] = new Atom( "HG1", 1.823f, -0.585f, 3.187f, 0.310f );
residue.atom[ 10 ] = new Atom( "CG2", 3.510f, -0.835f, 1.244f, -0.191f );
residue.atom[ 11 ] = new Atom( "HG21", 3.844f, -1.384f, 2.125f, 0.065f );
residue.atom[ 12 ] = new Atom( "HG22", 3.860f, -1.343f, 0.346f, 0.065f );
residue.atom[ 13 ] = new Atom( "HG23", 3.918f, 0.177f, 1.271f, 0.065f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 10 );
residue.atom[ 8 ].addBond( 9 );
residue.atom[ 10 ].addBond( 11, 12, 13 );
}
else if ( residueName.equals( "Ltrp" ) ){
createResidue( "TRP", 24 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 3.076f, -0.759f, 1.276f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 1.547f, -0.251f, 2.084f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.492f, -2.192f, 1.321f, -0.0135f );
residue.atom[ 10 ] = new Atom( "CD1", 1.752f, -3.078f, 2.293f, 0.044f );
residue.atom[ 11 ] = new Atom( "HD1", 2.365f, -2.906f, 3.178f, 0.093f );
residue.atom[ 12 ] = new Atom( "CD2", 0.669f, -2.868f, 0.412f, 0.146f );
residue.atom[ 13 ] = new Atom( "NE1", 1.072f, -4.288f, 1.950f, -0.352f );
residue.atom[ 14 ] = new Atom( "HE1", 1.079f, -5.139f, 2.493f, 0.271f );
residue.atom[ 15 ] = new Atom( "CE2", 0.438f, -4.113f, 0.817f, 0.154f );
residue.atom[ 16 ] = new Atom( "CE3", 0.103f, -2.412f, -0.785f, -0.173f );
residue.atom[ 17 ] = new Atom( "HE3", 0.273f, -1.397f, -1.145f, 0.086f );
residue.atom[ 18 ] = new Atom( "CZ2", -0.350f, -5.037f, 0.120f, -0.168f );
residue.atom[ 19 ] = new Atom( "HZ2", -0.515f, -6.050f, 0.487f, 0.084f );
residue.atom[ 20 ] = new Atom( "CZ3", -0.694f, -3.325f, -1.505f, -0.066f );
residue.atom[ 21 ] = new Atom( "HZ3", -1.150f, -3.005f, -2.442f, 0.057f );
residue.atom[ 22 ] = new Atom( "CH2", -0.912f, -4.584f, -1.069f, -0.077f );
residue.atom[ 23 ] = new Atom( "HH2", -1.535f, -5.257f, -1.658f, 0.074f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 12 );
residue.atom[ 10 ].addBond( 11, 13 );
residue.atom[ 13 ].addBond( 14, 15 );
residue.atom[ 15 ].addBond( 18 );
residue.atom[ 18 ].addBond( 19, 22 );
residue.atom[ 22 ].addBond( 23 );
residue.atom[ 12 ].addBond( 15, 16 );
residue.atom[ 16 ].addBond( 17, 20 );
residue.atom[ 20 ].addBond( 21, 22 );
residue.atom[ 22 ].addBond( 23 );
}
else if ( residueName.equals( "Ltyr" ) ){
createResidue( "TYR", 21 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 3.077f, -0.816f, 1.241f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 1.638f, -0.260f, 2.131f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.423f, -2.168f, 1.195f, -0.030f );
residue.atom[ 10 ] = new Atom( "CD1", 1.715f, -3.068f, 2.227f, -0.002f );
residue.atom[ 11 ] = new Atom( "HD1", 2.348f, -2.758f, 3.058f, 0.064f );
residue.atom[ 12 ] = new Atom( "CD2", 0.609f, -2.567f, 0.128f, -0.002f );
residue.atom[ 13 ] = new Atom( "HD2", 0.382f, -1.867f, -0.676f, 0.064f );
residue.atom[ 14 ] = new Atom( "CE1", 1.192f, -4.367f, 2.193f, -0.264f );
residue.atom[ 15 ] = new Atom( "HE1", 1.418f, -5.067f, 2.996f, 0.102f );
residue.atom[ 16 ] = new Atom( "CE2", 0.086f, -3.866f, 0.093f, -0.264f );
residue.atom[ 17 ] = new Atom( "HE2", -0.548f, -4.176f, -0.737f, 0.102f );
residue.atom[ 18 ] = new Atom( "CZ", 0.378f, -4.766f, 1.126f, 0.462f );
residue.atom[ 19 ] = new Atom( "OH", -0.131f, -6.026f, 1.092f, -0.528f );
residue.atom[ 20 ] = new Atom( "HH", 0.132f, -6.557f, 1.849f, 0.334f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 12 );
residue.atom[ 10 ].addBond( 11, 14 );
residue.atom[ 14 ].addBond( 15, 18 );
residue.atom[ 18 ].addBond( 19 );
residue.atom[ 19 ].addBond( 20 );
residue.atom[ 12 ].addBond( 13, 16 );
residue.atom[ 16 ].addBond( 17, 18 );
}
else if ( residueName.equals( "Lval" ) ){
createResidue( "VAL", 16 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, -0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, 1.233f, -0.012f );
residue.atom[ 7 ] = new Atom( "HB", 3.077f, -0.816f, 1.241f, 0.024f );
residue.atom[ 8 ] = new Atom( "CG1", 1.499f, -0.057f, 2.490f, -0.091f );
residue.atom[ 9 ] = new Atom( "HG11", 1.832f, -0.606f, 3.370f, 0.031f );
residue.atom[ 10 ] = new Atom( "HG12", 1.906f, 0.953f, 2.516f, 0.031f );
residue.atom[ 11 ] = new Atom( "HG13", 0.410f, -0.010f, 2.481f, 0.031f );
residue.atom[ 12 ] = new Atom( "CG2", 1.418f, -2.182f, 1.194f, -0.091f );
residue.atom[ 13 ] = new Atom( "HG21", 1.751f, -2.732f, 2.075f, 0.031f );
residue.atom[ 14 ] = new Atom( "HG22", 0.329f, -2.136f, 1.186f, 0.031f );
residue.atom[ 15 ] = new Atom( "HG23", 1.767f, -2.692f, 0.296f, 0.031f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 12 );
residue.atom[ 8 ].addBond( 9, 10, 11 );
residue.atom[ 12 ].addBond( 13, 14, 15 );
}
else if ( residueName.equals( "Dace" ) ){
createResidue( "ACE", 6 );
residue.atom[ 0 ] = new Atom( "H1", 0.000f, 0.000f, 0.000f );
residue.atom[ 1 ] = new Atom( "CH3", 0.000f, 1.090f, 0.000f );
residue.atom[ 2 ] = new Atom( "H2", 1.028f, 1.453f, 0.000f );
residue.atom[ 3 ] = new Atom( "H3", -0.514f, 1.453f, -0.890f );
residue.atom[ 4 ] = new Atom( "C", -0.721f, 1.600f, 1.249f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.839f, 2.806f, 1.453f, -0.504f );
residue.atom[ 0 ].addBond( 1 );
residue.atom[ 1 ].addBond( 2, 3 );
residue.atom[ 1 ].addBond( 4 );
residue.atom[ 4 ].addBond( 5 );
}
else if ( residueName.equals( "Dala" ) ){
createResidue( "ALA", 10 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 1.580f, -1.779f, -1.205f, 0.036f );
residue.atom[ 8 ] = new Atom( "HB2", 1.638f, -0.260f, -2.131f, 0.036f );
residue.atom[ 9 ] = new Atom( "HB3", 3.077f, -0.816f, -1.241f, 0.036f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
}
else if ( residueName.equals( "Darg" ) ){
createResidue( "ARG", 24 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.080f );
residue.atom[ 7 ] = new Atom( "HB1", 1.638f, -0.260f, -2.131f, 0.056f );
residue.atom[ 8 ] = new Atom( "HB2", 3.077f, -0.816f, -1.241f, 0.056f );
residue.atom[ 9 ] = new Atom( "CG", 1.418f, -2.183f, -1.195f, -0.103f );
residue.atom[ 10 ] = new Atom( "HG1", 1.767f, -2.692f, -0.296f, 0.074f );
residue.atom[ 11 ] = new Atom( "HG2", 0.328f, -2.136f, -1.186f, 0.074f );
residue.atom[ 12 ] = new Atom( "CD", 1.884f, -2.951f, -2.427f, -0.228f );
residue.atom[ 13 ] = new Atom( "HD1", 1.549f, -2.433f, -3.326f, 0.133f );
residue.atom[ 14 ] = new Atom( "HD2", 2.972f, -3.004f, -2.410f, 0.133f );
residue.atom[ 15 ] = new Atom( "NE", 1.348f, -4.332f, -2.424f, -0.324f );
residue.atom[ 16 ] = new Atom( "HE", 0.761f, -4.619f, -1.655f, 0.269f );
residue.atom[ 17 ] = new Atom( "CZ", 1.606f, -5.210f, -3.390f, 0.760f );
residue.atom[ 18 ] = new Atom( "NH1", 2.371f, -4.905f, -4.434f, -0.624f );
residue.atom[ 19 ] = new Atom( "HH11", 2.774f, -3.982f, -4.509f, 0.361f );
residue.atom[ 20 ] = new Atom( "HH12", 2.545f, -5.597f, -5.148f, 0.361f );
residue.atom[ 21 ] = new Atom( "NH2", 1.074f, -6.424f, -3.287f, -0.624f );
residue.atom[ 22 ] = new Atom( "HH21", 0.494f, -6.652f, -2.492f, 0.361f );
residue.atom[ 23 ] = new Atom( "HH22", 1.252f, -7.112f, -4.004f, 0.361f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11, 12 );
residue.atom[ 12 ].addBond( 13, 14, 15 );
residue.atom[ 15 ].addBond( 16, 17 );
residue.atom[ 17 ].addBond( 18, 21 );
residue.atom[ 18 ].addBond( 19, 20 );
residue.atom[ 21 ].addBond( 22, 23 );
}
else if ( residueName.equals( "Dasn" ) ){
createResidue( "ASN", 14 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.086f );
residue.atom[ 7 ] = new Atom( "HB1", 1.653f, -0.251f, -2.131f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 3.076f, -0.821f, -1.214f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.438f, -2.188f, -1.232f, 0.675f );
residue.atom[ 10 ] = new Atom( "OD1", 0.720f, -2.579f, -0.316f, -0.470f );
residue.atom[ 11 ] = new Atom( "ND2", 1.780f, -2.961f, -2.265f, -0.867f );
residue.atom[ 12 ] = new Atom( "HD21", 2.374f, -2.591f, -2.994f, 0.344f );
residue.atom[ 13 ] = new Atom( "HD22", 1.443f, -3.912f, -2.315f, 0.344f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11 );
residue.atom[ 11 ].addBond( 12, 13 );
}
else if ( residueName.equals( "Dasp" ) ){
createResidue( "ASP", 12 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.398f );
residue.atom[ 7 ] = new Atom( "HB1", 1.638f, -0.260f, -2.131f, 0.071f );
residue.atom[ 8 ] = new Atom( "HB2", 3.077f, -0.816f, -1.241f, 0.071f );
residue.atom[ 9 ] = new Atom( "CG", 1.417f, -2.184f, -1.195f, 0.714f );
residue.atom[ 10 ] = new Atom( "OD1", 0.297f, -2.369f, -1.741f, -0.721f );
residue.atom[ 11 ] = new Atom( "OD2", 2.107f, -3.069f, -0.620f, -0.721f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11 );
}
else if ( residueName.equals( "Dcys" ) ){
createResidue( "CYS", 11 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.060f );
residue.atom[ 7 ] = new Atom( "HB1", 1.707f, -0.219f, -2.130f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 3.069f, -0.846f, -1.122f, 0.038f );
residue.atom[ 9 ] = new Atom( "SG", 1.409f, -2.479f, -1.365f, -0.135f );
residue.atom[ 10 ] = new Atom( "HG", 1.889f, -3.023f, -2.481f, 0.135f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10 );
}
else if ( residueName.equals( "Dcyx" ) ){
createResidue( "CYX", 10 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 1.707f, -0.219f, -2.130f, 0.0495f );
residue.atom[ 8 ] = new Atom( "HB2", 3.069f, -0.846f, -1.122f, 0.0495f );
residue.atom[ 9 ] = new Atom( "SG", 1.409f, -2.479f, -1.365f, 0.015f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
}
else if ( residueName.equals( "Dgln" ) ){
createResidue( "GLN", 17 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 1.638f, -0.260f, -2.131f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 3.077f, -0.816f, -1.241f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.418f, -2.183f, -1.195f, -0.102f );
residue.atom[ 10 ] = new Atom( "HG1", 1.752f, -2.685f, -0.287f, 0.057f );
residue.atom[ 11 ] = new Atom( "HG2", 0.330f, -2.115f, -1.205f, 0.057f );
residue.atom[ 12 ] = new Atom( "CD", 1.861f, -2.984f, -2.410f, 0.675f );
residue.atom[ 13 ] = new Atom( "OE1", 2.585f, -2.476f, -3.263f, -0.470f );
residue.atom[ 14 ] = new Atom( "NE2", 1.422f, -4.243f, -2.489f, -0.867f );
residue.atom[ 15 ] = new Atom( "HE21", 0.828f, -4.613f, -1.760f, 0.344f );
residue.atom[ 16 ] = new Atom( "HE22", 1.687f, -4.819f, -3.275f, 0.344f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11, 12 );
residue.atom[ 12 ].addBond( 13, 14 );
residue.atom[ 14 ].addBond( 15, 16 );
}
else if ( residueName.equals( "Dglu" ) ){
createResidue( "GLU", 15 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.184f );
residue.atom[ 7 ] = new Atom( "HB1", 1.638f, -0.260f, -2.131f, 0.092f );
residue.atom[ 8 ] = new Atom( "HB2", 3.077f, -0.816f, -1.241f, 0.092f );
residue.atom[ 9 ] = new Atom( "CG", 1.423f, -2.168f, -1.195f, -0.398f );
residue.atom[ 10 ] = new Atom( "HG1", 1.772f, -2.677f, -0.296f, 0.071f );
residue.atom[ 11 ] = new Atom( "HG2", 0.334f, -2.122f, -1.186f, 0.071f );
residue.atom[ 12 ] = new Atom( "CD", 1.890f, -2.938f, -2.429f, 0.714f );
residue.atom[ 13 ] = new Atom( "OE1", 2.971f, -3.579f, -2.334f, -0.721f );
residue.atom[ 14 ] = new Atom( "OE2", 1.160f, -2.879f, -3.455f, -0.721f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11, 12 );
residue.atom[ 12 ].addBond( 13, 14 );
}
else if ( residueName.equals( "Dgly" ) ){
createResidue( "GLY", 7 );
residue.atom[ 0 ] = new Atom( "N", 2.027f, 1.358f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.697f, 1.839f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA1", 1.886f, -0.523f, -0.885f, 0.032f );
residue.atom[ 4 ] = new Atom( "HA2", 1.874f, -0.506f, 0.899f, 0.032f );
residue.atom[ 5 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 6 ] = new Atom( "O", -0.624f, 1.058f, 0.000f, -0.504f );
addBackboneBonds();
residue.atom[ 2 ].addBond( 5 );
residue.atom[ 5 ].addBond( 6 );
}
else if ( residueName.equals( "Dhid" ) ){
createResidue( "HID", 17 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 1.695f, -0.225f, -2.131f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 3.071f, -0.840f, -1.141f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.492f, -2.192f, -1.321f, -0.032f );
residue.atom[ 10 ] = new Atom( "ND1", 1.828f, -3.024f, -2.383f, -0.146f );
residue.atom[ 11 ] = new Atom( "HD1", 2.411f, -2.776f, -3.170f, 0.228f );
residue.atom[ 12 ] = new Atom( "CD2", 0.698f, -2.921f, -0.492f, 0.195f );
residue.atom[ 13 ] = new Atom( "HD2", 0.306f, -2.472f, 0.421f, 0.018f );
residue.atom[ 14 ] = new Atom( "CE1", 1.251f, -4.195f, -2.182f, 0.241f );
residue.atom[ 15 ] = new Atom( "HE1", 1.387f, -4.999f, -2.905f, 0.036f );
residue.atom[ 16 ] = new Atom( "NE2", 0.575f, -4.150f, -1.061f, -0.502f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 12 );
residue.atom[ 10 ].addBond( 11, 14 );
residue.atom[ 12 ].addBond( 13, 16 );
residue.atom[ 14 ].addBond( 15, 16 );
}
else if ( residueName.equals( "Dhie" ) ){
createResidue( "HIE", 17 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 1.695f, -0.225f, -2.131f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 3.071f, -0.840f, -1.141f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.492f, -2.192f, -1.321f, 0.251f );
residue.atom[ 10 ] = new Atom( "ND1", 1.828f, -3.024f, -2.383f, -0.502f );
residue.atom[ 11 ] = new Atom( "CD2", 0.698f, -2.921f, -0.492f, -0.184f );
residue.atom[ 12 ] = new Atom( "HD2", 0.306f, -2.472f, 0.421f, 0.114f );
residue.atom[ 13 ] = new Atom( "CE1", 1.251f, -4.195f, -2.182f, 0.241f );
residue.atom[ 14 ] = new Atom( "HE1", 1.387f, -4.999f, -2.905f, 0.036f );
residue.atom[ 15 ] = new Atom( "NE2", 0.575f, -4.150f, -1.061f, -0.146f );
residue.atom[ 16 ] = new Atom( "HE2", 0.041f, -4.917f, -0.677f, 0.228f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11 );
residue.atom[ 10 ].addBond( 13 );
residue.atom[ 11 ].addBond( 12, 15 );
residue.atom[ 13 ].addBond( 14, 15 );
residue.atom[ 15 ].addBond( 16 );
}
else if ( residueName.equals( "Dhip" ) ){
createResidue( "HIP", 18 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 1.695f, -0.225f, -2.131f, 0.086f );
residue.atom[ 8 ] = new Atom( "HB2", 3.071f, -0.840f, -1.141f, 0.086f );
residue.atom[ 9 ] = new Atom( "CG", 1.492f, -2.192f, -1.321f, 0.058f );
residue.atom[ 10 ] = new Atom( "ND1", 1.828f, -3.024f, -2.383f, -0.058f );
residue.atom[ 11 ] = new Atom( "HD1", 2.411f, -2.776f, -3.170f, 0.306f );
residue.atom[ 12 ] = new Atom( "CD2", 0.698f, -2.921f, -0.492f, -0.037f );
residue.atom[ 13 ] = new Atom( "HD2", 0.306f, -2.472f, 0.421f, 0.153f );
residue.atom[ 14 ] = new Atom( "CE1", 1.251f, -4.195f, -2.182f, 0.114f );
residue.atom[ 15 ] = new Atom( "HE1", 1.387f, -4.999f, -2.905f, 0.158f );
residue.atom[ 16 ] = new Atom( "NE2", 0.575f, -4.150f, -1.061f, -0.058f );
residue.atom[ 17 ] = new Atom( "HE2", 0.041f, -4.917f, -0.677f, 0.306f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 12 );
residue.atom[ 10 ].addBond( 11, 14 );
residue.atom[ 12 ].addBond( 13, 16 );
residue.atom[ 14 ].addBond( 15, 16 );
residue.atom[ 16 ].addBond( 17 );
}
else if ( residueName.equals( "Dhis" ) ){
createResidue( "HIS", 18 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 1.695f, -0.225f, -2.131f, 0.086f );
residue.atom[ 8 ] = new Atom( "HB2", 3.071f, -0.840f, -1.141f, 0.086f );
residue.atom[ 9 ] = new Atom( "CG", 1.492f, -2.192f, -1.321f, 0.058f );
residue.atom[ 10 ] = new Atom( "ND1", 1.828f, -3.024f, -2.383f, -0.058f );
residue.atom[ 11 ] = new Atom( "HD1", 2.411f, -2.776f, -3.170f, 0.306f );
residue.atom[ 12 ] = new Atom( "CD2", 0.698f, -2.921f, -0.492f, -0.037f );
residue.atom[ 13 ] = new Atom( "HD2", 0.248f, -2.586f, 0.442f, 0.153f );
residue.atom[ 14 ] = new Atom( "CE1", 1.251f, -4.195f, -2.182f, 0.114f );
residue.atom[ 15 ] = new Atom( "HE1", 1.326f, -5.058f, -2.843f, 0.158f );
residue.atom[ 16 ] = new Atom( "NE2", 0.575f, -4.150f, -1.061f, -0.058f );
residue.atom[ 17 ] = new Atom( "HE2", 0.041f, -4.917f, -0.677f, 0.306f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 12 );
residue.atom[ 10 ].addBond( 11, 14 );
residue.atom[ 12 ].addBond( 13, 16 );
residue.atom[ 14 ].addBond( 15, 16 );
residue.atom[ 16 ].addBond( 17 );
}
else if ( residueName.equals( "Dile" ) ){
createResidue( "ILE", 19 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.875f, -0.500f, 0.902f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 2.009f, -0.733f, -1.245f, -0.012f );
residue.atom[ 7 ] = new Atom( "HB", 1.661f, -0.209f, -2.135f, 0.022f );
residue.atom[ 8 ] = new Atom( "CG1", 1.459f, -2.156f, -1.246f, -0.049f );
residue.atom[ 9 ] = new Atom( "HG11", 1.807f, -2.680f, -0.355f, 0.027f );
residue.atom[ 10 ] = new Atom( "HG12", 0.370f, -2.124f, -1.246f, 0.027f );
residue.atom[ 11 ] = new Atom( "CG2", 3.533f, -0.777f, -1.245f, -0.085f );
residue.atom[ 12 ] = new Atom( "HG21", 3.882f, -1.301f, -2.135f, 0.029f );
residue.atom[ 13 ] = new Atom( "HG22", 3.927f, 0.239f, -1.245f, 0.029f );
residue.atom[ 14 ] = new Atom( "HG23", 3.882f, -1.301f, -0.355f, 0.029f );
residue.atom[ 15 ] = new Atom( "CD1", 1.946f, -2.889f, -2.490f, -0.085f );
residue.atom[ 16 ] = new Atom( "HD11", 1.554f, -3.905f, -2.490f, 0.028f );
residue.atom[ 17 ] = new Atom( "HD12", 1.598f, -2.365f, -3.380f, 0.028f );
residue.atom[ 18 ] = new Atom( "HD13", 3.036f, -2.920f, -2.490f, 0.028f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 11 );
residue.atom[ 8 ].addBond( 9, 10, 15 );
residue.atom[ 11 ].addBond( 12, 13, 14 );
residue.atom[ 15 ].addBond( 16, 17, 18 );
}
else if ( residueName.equals( "Dleu" ) ){
createResidue( "LEU", 19 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.061f );
residue.atom[ 7 ] = new Atom( "HB1", 1.638f, -0.260f, -2.131f, 0.033f );
residue.atom[ 8 ] = new Atom( "HB2", 3.077f, -0.816f, -1.241f, 0.033f );
residue.atom[ 9 ] = new Atom( "CG", 1.418f, -2.183f, -1.195f, -0.010f );
residue.atom[ 10 ] = new Atom( "HG", 1.766f, -2.692f, -0.296f, 0.031f );
residue.atom[ 11 ] = new Atom( "CD1", -0.106f, -2.117f, -1.182f, -0.107f );
residue.atom[ 12 ] = new Atom( "HD11", -0.513f, -3.128f, -1.155f, 0.034f );
residue.atom[ 13 ] = new Atom( "HD12", -0.438f, -1.567f, -0.302f, 0.034f );
residue.atom[ 14 ] = new Atom( "HD13", -0.455f, -1.608f, -2.081f, 0.034f );
residue.atom[ 15 ] = new Atom( "CD2", 1.884f, -2.951f, -2.427f, -0.107f );
residue.atom[ 16 ] = new Atom( "HD21", 1.476f, -3.962f, -2.400f, 0.034f );
residue.atom[ 17 ] = new Atom( "HD22", 1.534f, -2.443f, -3.326f, 0.034f );
residue.atom[ 18 ] = new Atom( "HD23", 2.973f, -2.999f, -2.436f, 0.034f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11, 15 );
residue.atom[ 11 ].addBond( 12, 13, 14 );
residue.atom[ 15 ].addBond( 16, 17, 18 );
}
else if ( residueName.equals( "Dlys" ) ){
createResidue( "LYS", 22 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 1.638f, -0.260f, -2.131f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 3.077f, -0.816f, -1.241f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.418f, -2.183f, -1.195f, -0.160f );
residue.atom[ 10 ] = new Atom( "HG1", 1.767f, -2.692f, -0.296f, 0.116f );
residue.atom[ 11 ] = new Atom( "HG2", 0.328f, -2.136f, -1.186f, 0.116f );
residue.atom[ 12 ] = new Atom( "CD", 1.884f, -2.951f, -2.427f, -0.180f );
residue.atom[ 13 ] = new Atom( "HD1", 1.534f, -2.443f, -3.326f, 0.122f );
residue.atom[ 14 ] = new Atom( "HD2", 2.973f, -2.999f, -2.436f, 0.122f );
residue.atom[ 15 ] = new Atom( "CE", 1.313f, -4.366f, -2.389f, -0.038f );
residue.atom[ 16 ] = new Atom( "HE1", 1.663f, -4.874f, -1.491f, 0.098f );
residue.atom[ 17 ] = new Atom( "HE2", 0.224f, -4.318f, -2.380f, 0.098f );
residue.atom[ 18 ] = new Atom( "NZ", 1.762f, -5.106f, -3.577f, -0.138f );
residue.atom[ 19 ] = new Atom( "HZ1", 1.385f, -6.042f, -3.552f, 0.294f );
residue.atom[ 20 ] = new Atom( "HZ2", 1.440f, -4.636f, -4.410f, 0.294f );
residue.atom[ 21 ] = new Atom( "HZ3", 2.771f, -5.149f, -3.585f, 0.294f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11, 12 );
residue.atom[ 12 ].addBond( 13, 14, 15 );
residue.atom[ 15 ].addBond( 16, 17, 18 );
residue.atom[ 18 ].addBond( 19, 20, 21 );
}
else if ( residueName.equals( "Dmet" ) ){
createResidue( "MET", 17 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.151f );
residue.atom[ 7 ] = new Atom( "HB1", 1.638f, -0.260f, -2.131f, 0.027f );
residue.atom[ 8 ] = new Atom( "HB2", 3.077f, -0.816f, -1.241f, 0.027f );
residue.atom[ 9 ] = new Atom( "CG", 1.418f, -2.183f, -1.195f, -0.054f );
residue.atom[ 10 ] = new Atom( "HG1", 1.762f, -2.690f, -0.292f, 0.0652f );
residue.atom[ 11 ] = new Atom( "HG2", 0.329f, -2.129f, -1.191f, 0.0652f );
residue.atom[ 12 ] = new Atom( "SD", 1.962f, -3.109f, -2.652f, -0.025f );
residue.atom[ 13 ] = new Atom( "CE", 1.167f, -4.670f, -2.341f, -0.134f );
residue.atom[ 14 ] = new Atom( "HE1", 1.399f, -5.363f, -3.150f, 0.0652f );
residue.atom[ 15 ] = new Atom( "HE2", 1.525f, -5.079f, -1.397f, 0.0652f );
residue.atom[ 16 ] = new Atom( "HE3", 0.087f, -4.523f, -2.287f, 0.0652f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 11, 12 );
residue.atom[ 12 ].addBond( 13 );
residue.atom[ 13 ].addBond( 14, 15, 16 );
}
else if ( residueName.equals( "Dnme" ) ){
createResidue( "NME", 6 );
residue.atom[ 0 ] = new Atom( "N", -1.227f, 0.728f, 2.125f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", -1.124f, -0.261f, 1.947f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", -1.918f, 1.159f, 3.323f, 0.03502f );
residue.atom[ 3 ] = new Atom( "HA1", -1.939f, 2.249f, 3.358f, 0.0586f );
residue.atom[ 4 ] = new Atom( "HA2", -2.939f, 0.777f, 3.311f, 0.0586f );
residue.atom[ 5 ] = new Atom( "HA3", -1.398f, 0.777f, 4.201f, 0.0586f );
addBackboneBonds();
residue.atom[ 2 ].addBond( 5 );
}
else if ( residueName.equals( "Dphe" ) ){
createResidue( "PHE", 20 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.100f );
residue.atom[ 7 ] = new Atom( "HB1", 1.695f, -0.225f, -2.131f, 0.108f );
residue.atom[ 8 ] = new Atom( "HB2", 3.071f, -0.840f, -1.141f, 0.108f );
residue.atom[ 9 ] = new Atom( "CG", 1.492f, -2.192f, -1.321f, -0.100f );
residue.atom[ 10 ] = new Atom( "CD1", 1.856f, -2.993f, -2.410f, -0.150f );
residue.atom[ 11 ] = new Atom( "HD1", 2.497f, -2.589f, -3.194f, 0.150f );
residue.atom[ 12 ] = new Atom( "CD2", 0.669f, -2.711f, -0.315f, -0.150f );
residue.atom[ 13 ] = new Atom( "HD2", 0.385f, -2.087f, 0.533f, 0.150f );
residue.atom[ 14 ] = new Atom( "CE1", 1.398f, -4.313f, -2.492f, -0.150f );
residue.atom[ 15 ] = new Atom( "HE1", 1.681f, -4.937f, -3.340f, 0.150f );
residue.atom[ 16 ] = new Atom( "CE2", 0.210f, -4.031f, -0.397f, -0.150f );
residue.atom[ 17 ] = new Atom( "HE2", -0.431f, -4.436f, 0.387f, 0.150f );
residue.atom[ 18 ] = new Atom( "CZ", 0.575f, -4.833f, -1.486f, -0.150f );
residue.atom[ 19 ] = new Atom( "HZ", 0.217f, -5.861f, -1.550f, 0.150f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 12 );
residue.atom[ 10 ].addBond( 11, 14 );
residue.atom[ 12 ].addBond( 13, 16 );
residue.atom[ 14 ].addBond( 15, 18 );
residue.atom[ 16 ].addBond( 17, 18 );
residue.atom[ 18 ].addBond( 19 );
}
else if ( residueName.equals( "Dpro" ) ){
createResidue( "PRO", 14 );
residue.atom[ 0 ] = new Atom( "N", 2.067f, 1.413f, 0.000f, -0.229f );
residue.atom[ 1 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 2 ] = new Atom( "HA", 1.308f, -0.765f, 0.745f, 0.048f );
residue.atom[ 3 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.526f );
residue.atom[ 4 ] = new Atom( "O", -0.624f, 1.059f, 0.000f, -0.500f );
residue.atom[ 5 ] = new Atom( "CB", 2.632f, -0.865f, -0.521f, -0.115f );
residue.atom[ 6 ] = new Atom( "HB1", 2.901f, -1.604f, 0.234f, 0.061f );
residue.atom[ 7 ] = new Atom( "HB2", 2.302f, -1.372f, -1.426f, 0.061f );
residue.atom[ 8 ] = new Atom( "CG", 3.834f, -0.007f, -0.835f, -0.121f );
residue.atom[ 9 ] = new Atom( "HG1", 4.671f, -0.309f, -0.206f, 0.063f );
residue.atom[ 10 ] = new Atom( "HG2", 4.135f, -0.100f, -1.878f, 0.063f );
residue.atom[ 11 ] = new Atom( "CD", 3.438f, 1.400f, -0.496f, -0.0012f );
residue.atom[ 12 ] = new Atom( "HD1", 3.507f, 2.022f, -1.389f, 0.060f );
residue.atom[ 13 ] = new Atom( "HD2", 4.105f, 1.791f, 0.271f, 0.060f );
residue.atom[ 0 ].addBond( 1, 11 );
residue.atom[ 1 ].addBond( 2, 3, 5 );
residue.atom[ 3 ].addBond( 4 );
residue.atom[ 5 ].addBond( 6, 7, 8 );
residue.atom[ 8 ].addBond( 9, 10, 11 );
residue.atom[ 11 ].addBond( 12, 13 );
}
else if ( residueName.equals( "Dser" ) ){
createResidue( "SER", 11 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, 0.018f );
residue.atom[ 7 ] = new Atom( "HB1", 1.638f, -0.260f, -2.131f, 0.119f );
residue.atom[ 8 ] = new Atom( "HB2", 3.077f, -0.816f, -1.241f, 0.119f );
residue.atom[ 9 ] = new Atom( "OG", 1.453f, -2.095f, -1.196f, -0.550f );
residue.atom[ 10 ] = new Atom( "HG", 1.746f, -2.578f, -1.973f, 0.310f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10 );
}
else if ( residueName.equals( "Dthr" ) ){
createResidue( "THR", 14 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, 0.170f );
residue.atom[ 7 ] = new Atom( "HB", 1.580f, -1.779f, -1.205f, 0.082f );
residue.atom[ 8 ] = new Atom( "OG1", 3.416f, -0.831f, -1.244f, -0.550f );
residue.atom[ 9 ] = new Atom( "HG1", 3.710f, -1.314f, -2.020f, 0.310f );
residue.atom[ 10 ] = new Atom( "CG2", 1.499f, -0.057f, -2.490f, -0.191f );
residue.atom[ 11 ] = new Atom( "HG21", 1.832f, -0.606f, -3.370f, 0.065f );
residue.atom[ 12 ] = new Atom( "HG22", 0.410f, -0.010f, -2.480f, 0.065f );
residue.atom[ 13 ] = new Atom( "HG23", 1.906f, 0.953f, -2.516f, 0.065f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 10 );
residue.atom[ 8 ].addBond( 9 );
residue.atom[ 10 ].addBond( 11, 12, 13 );
}
else if ( residueName.equals( "Dtrp" ) ){
createResidue( "TRP", 24 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 1.695f, -0.225f, -2.131f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 3.071f, -0.840f, -1.141f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.492f, -2.192f, -1.321f, -0.135f );
residue.atom[ 10 ] = new Atom( "CD1", 1.752f, -3.078f, -2.293f, 0.044f );
residue.atom[ 11 ] = new Atom( "HD1", 2.365f, -2.907f, -3.178f, 0.093f );
residue.atom[ 12 ] = new Atom( "CD2", 0.669f, -2.868f, -0.412f, 0.146f );
residue.atom[ 13 ] = new Atom( "NE1", 1.072f, -4.288f, -1.950f, -0.352f );
residue.atom[ 14 ] = new Atom( "HE1", 1.079f, -5.139f, -2.493f, 0.271f );
residue.atom[ 15 ] = new Atom( "CE2", 0.437f, -4.114f, -0.817f, 0.154f );
residue.atom[ 16 ] = new Atom( "CE3", 0.103f, -2.412f, 0.785f, -0.173f );
residue.atom[ 17 ] = new Atom( "HE3", 0.273f, -1.398f, 1.145f, 0.086f );
residue.atom[ 18 ] = new Atom( "CZ2", -0.350f, -5.037f, -0.120f, -0.168f );
residue.atom[ 19 ] = new Atom( "HZ2", -0.515f, -6.050f, -0.487f, 0.084f );
residue.atom[ 20 ] = new Atom( "CZ3", -0.694f, -3.326f, 1.506f, -0.066f );
residue.atom[ 21 ] = new Atom( "HZ3", -1.150f, -3.005f, 2.442f, 0.057f );
residue.atom[ 22 ] = new Atom( "CH2", -0.912f, -4.585f, 1.069f, -0.168f );
residue.atom[ 23 ] = new Atom( "HH2", -1.535f, -5.257f, 1.658f, 0.084f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 12 );
residue.atom[ 10 ].addBond( 11, 13 );
residue.atom[ 13 ].addBond( 14, 15 );
residue.atom[ 15 ].addBond( 18 );
residue.atom[ 18 ].addBond( 19, 22 );
residue.atom[ 22 ].addBond( 23 );
residue.atom[ 12 ].addBond( 15, 16 );
residue.atom[ 16 ].addBond( 17, 20 );
residue.atom[ 20 ].addBond( 21, 22 );
residue.atom[ 22 ].addBond( 23 );
}
else if ( residueName.equals( "Dtyr" ) ){
createResidue( "TYR", 21 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.098f );
residue.atom[ 7 ] = new Atom( "HB1", 1.638f, -0.260f, -2.131f, 0.038f );
residue.atom[ 8 ] = new Atom( "HB2", 3.077f, -0.816f, -1.241f, 0.038f );
residue.atom[ 9 ] = new Atom( "CG", 1.423f, -2.168f, -1.195f, -0.030f );
residue.atom[ 10 ] = new Atom( "CD1", 1.715f, -3.069f, -2.228f, -0.002f );
residue.atom[ 11 ] = new Atom( "HD1", 2.348f, -2.758f, -3.058f, 0.064f );
residue.atom[ 12 ] = new Atom( "CD2", 0.609f, -2.567f, -0.128f, -0.002f );
residue.atom[ 13 ] = new Atom( "HD2", 0.382f, -1.866f, 0.676f, 0.064f );
residue.atom[ 14 ] = new Atom( "CE1", 1.191f, -4.367f, -2.193f, -0.264f );
residue.atom[ 15 ] = new Atom( "HE1", 1.418f, -5.067f, -2.996f, 0.102f );
residue.atom[ 16 ] = new Atom( "CE2", 0.086f, -3.865f, -0.094f, -0.264f );
residue.atom[ 17 ] = new Atom( "HE2", -0.548f, -4.176f, 0.737f, 0.102f );
residue.atom[ 18 ] = new Atom( "CZ", 0.378f, -4.765f, -1.126f, 0.462f );
residue.atom[ 19 ] = new Atom( "OH", -0.131f, -6.027f, -1.093f, -0.528f );
residue.atom[ 20 ] = new Atom( "HH", 0.132f, -6.557f, -1.848f, 0.334f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 9 );
residue.atom[ 9 ].addBond( 10, 12 );
residue.atom[ 10 ].addBond( 11, 14 );
residue.atom[ 14 ].addBond( 15, 18 );
residue.atom[ 18 ].addBond( 19 );
residue.atom[ 19 ].addBond( 20 );
residue.atom[ 12 ].addBond( 13, 16 );
residue.atom[ 16 ].addBond( 17, 18 );
}
else if ( residueName.equals( "Dval" ) ){
createResidue( "VAL", 16 );
residue.atom[ 0 ] = new Atom( "N", 2.044f, 1.352f, 0.000f, -0.463f );
residue.atom[ 1 ] = new Atom( "H", 1.721f, 1.837f, 0.824f, 0.252f );
residue.atom[ 2 ] = new Atom( "CA", 1.522f, 0.000f, 0.000f, 0.035f );
residue.atom[ 3 ] = new Atom( "HA", 1.896f, -0.481f, 0.904f, 0.048f );
residue.atom[ 4 ] = new Atom( "C", 0.000f, 0.000f, 0.000f, 0.616f );
residue.atom[ 5 ] = new Atom( "O", -0.624f, 1.060f, 0.000f, -0.504f );
residue.atom[ 6 ] = new Atom( "CB", 1.988f, -0.769f, -1.232f, -0.012f );
residue.atom[ 7 ] = new Atom( "HB", 1.638f, -0.260f, -2.131f, 0.024f );
residue.atom[ 8 ] = new Atom( "CG1", 3.510f, -0.834f, -1.245f, -0.091f );
residue.atom[ 9 ] = new Atom( "HG11", 3.844f, -1.383f, -2.125f, 0.031f );
residue.atom[ 10 ] = new Atom( "HG12", 3.918f, 0.176f, -1.271f, 0.031f );
residue.atom[ 11 ] = new Atom( "HG13", 3.860f, -1.343f, -0.346f, 0.031f );
residue.atom[ 12 ] = new Atom( "CG2", 1.418f, -2.183f, -1.195f, -0.091f );
residue.atom[ 13 ] = new Atom( "HG21", 1.751f, -2.732f, -2.075f, 0.031f );
residue.atom[ 14 ] = new Atom( "HG22", 1.767f, -2.692f, -0.296f, 0.031f );
residue.atom[ 15 ] = new Atom( "HG23", 0.328f, -2.136f, -1.186f, 0.031f );
addBackboneBonds();
residue.atom[ 4 ].addBond( 5 );
residue.atom[ 2 ].addBond( 6 );
residue.atom[ 6 ].addBond( 7, 8, 12 );
residue.atom[ 8 ].addBond( 9, 10, 11 );
residue.atom[ 12 ].addBond( 13, 14, 15 );
}
for ( int ix3, i = 0; i < residue.numberOfAtoms; i++ ){
ix3 = i * 3;
residue.actualCoordinates[ ix3 ] = residue.atom[ i ].coord[ 0 ];
residue.actualCoordinates[ ix3 + 1 ] = residue.atom[ i ].coord[ 1 ];
residue.actualCoordinates[ ix3 + 2 ] = residue.atom[ i ].coord[ 2 ];
residue.atom[ i ].residueAtomNumber = i;
}
return( residue );
}
public void createResidue( String residueName, int numberOfResidueAtoms ){
residue = new Residue();
residue.name = residueName;
residue.numberOfAtoms = numberOfResidueAtoms;
residue.atom = new Atom[ numberOfResidueAtoms ];
residue.actualCoordinates = new float[ 3 * residue.numberOfAtoms ];
residue.mat = new Matrix3D();
}
public void addBackboneBonds(){
residue.atom[ 0 ].addBond( 1, 2 );
residue.atom[ 2 ].addBond( 3, 4 );
}
}
| true
|
3b10d217621f1d57421944549f14a64b30f036b5
|
Java
|
esteves67/plsat_gts_01
|
/src/org/opengts/extra/war/report/session/SessionStatusReport.java
|
UTF-8
| 7,891
| 1.96875
| 2
|
[
"Apache-2.0"
] |
permissive
|
// ----------------------------------------------------------------------------
// Copyright 2007-2014, OpenGTS
// All rights reserved
// ----------------------------------------------------------------------------
//
// This source module is PROPRIETARY and CONFIDENTIAL.
// NOT INTENDED FOR PUBLIC RELEASE.
//
// Use of this software is subject to the terms and conditions outlined in
// the 'Commercial' license provided with this software. If you did not obtain
// a copy of the license with this software please request a copy from the
// Software Provider.
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
package org.opengts.extra.war.report.session;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.opengts.util.*;
import org.opengts.dbtools.*;
import org.opengts.db.*;
import org.opengts.db.tables.*;
import org.opengts.war.tools.*;
import org.opengts.war.report.*;
import org.opengts.war.report.field.*;
public class SessionStatusReport
extends ReportData
{
// ------------------------------------------------------------------------
// Summary report
// 1 record per device
// ------------------------------------------------------------------------
private java.util.List<FieldData> rowData = null;
private SessionStatsFactory statsFactory = null;
// ------------------------------------------------------------------------
public SessionStatusReport(ReportEntry rptEntry, RequestProperties reqState, ReportDeviceList devList)
throws ReportException
{
super(rptEntry, reqState, devList);
if (this.getAccount() == null) {
throw new ReportException("Account must be specified");
}
//if (this.getDeviceCount() < 1) {
// throw new ReportException("At least 1 Device must be specified");
//}
// report on all authorized devices
//this.getReportDeviceList().addAllAuthorizedDevices();
// SessionStatsFactory
this.statsFactory = Device.getSessionStatsFactory();
}
// ------------------------------------------------------------------------
public void postInitialize()
{
//ReportConstraints rc = this.getReportConstraints();
//Print.logInfo("LimitType=" + rc.getSelectionLimitType() + ", Limit=" + rc.getSelectionLimit());
}
// ------------------------------------------------------------------------
/**
*** Gets the bound ReportLayout singleton instance for this report
*** @return The bound ReportLayout
**/
public static ReportLayout GetReportLayout()
{
// bind the report format to this data
return FieldLayout.getReportLayout();
}
/**
*** Gets the bound ReportLayout singleton instance for this report
*** @return The bound ReportLayout
**/
public ReportLayout getReportLayout()
{
// bind the report format to this data
return GetReportLayout();
}
// ------------------------------------------------------------------------
/* return an object that will iterate through the selected row object */
public DBDataIterator getBodyDataIterator()
{
/* init */
this.rowData = new Vector<FieldData>();
/* loop through devices */
String devID = "";
ReportDeviceList devList = this.getReportDeviceList();
for (Iterator i = devList.iterator(); i.hasNext();) {
devID = (String)i.next();
try {
Device device = devList.getDevice(devID);
if (device != null) {
long eventCount = this.countEventData(device);
long connCount[] = this.countConnections(device);
long byteCount[] = this.countDataBytes(device);
long connTotal = connCount[0] + connCount[1]; // TCP + UDP connections
long bytesRead = byteCount[0];
long bytesWritten = byteCount[1];
long bytesOverhead = byteCount[2];
long bytesTotal = bytesRead + bytesWritten + bytesOverhead;
long bytesRounded = byteCount[3];
FieldData fd = new FieldData();
fd.setDevice(device);
fd.setString(FieldLayout.DATA_DEVICE_ID , devID); // device
fd.setLong( FieldLayout.DATA_EVENTS_RECEIVED , eventCount); // event count
fd.setLong( FieldLayout.DATA_TCP_CONNECTIONS , connCount[0]); // TCP connect count
fd.setLong( FieldLayout.DATA_UDP_CONNECTIONS , connCount[1]); // UDP connect count
fd.setLong( FieldLayout.DATA_CONNECTIONS , connTotal); // TCP/UDP connect count
fd.setLong( FieldLayout.DATA_BYTES_READ , bytesRead); // bytesRead
fd.setLong( FieldLayout.DATA_BYTES_WRITTEN , bytesWritten); // bytesWritten
fd.setLong( FieldLayout.DATA_BYTES_OVERHEAD , bytesOverhead); // bytesOverhead
fd.setLong( FieldLayout.DATA_BYTES_TOTAL , bytesTotal); // bytesTotal
fd.setLong( FieldLayout.DATA_BYTES_ROUNDED , bytesRounded); // bytesRounded
this.rowData.add(fd);
} else {
// should never occur
Print.logError("Returned DeviceList 'Device' is null: " + devID);
}
} catch (DBException dbe) {
Print.logError("Error retrieving EventData count for Device: " + devID);
}
}
/* return data iterator */
FieldData.sortByDeviceDescription(this.rowData);
return new ListDataIterator(this.rowData);
}
/* return the totals data list */
public DBDataIterator getTotalsDataIterator()
{
return null;
}
// ------------------------------------------------------------------------
/* return bytes read/written */
private long[] countConnections(Device device)
{
try {
long timeStart = super.getTimeStart();
long timeEnd = super.getTimeEnd();
long connCounts[] = (this.statsFactory != null)?
this.statsFactory.getConnectionCounts(device,timeStart,timeEnd) :
null;
return (connCounts != null)? connCounts : new long[] { 0L, 0L };
} catch (DBException dbe) {
Print.logException("Counting Connections", dbe);
return new long[] { 0L, 0L };
}
}
/* return bytes read/written */
private long[] countDataBytes(Device device)
{
try {
long timeStart = super.getTimeStart();
long timeEnd = super.getTimeEnd();
long byteCounts[] = (this.statsFactory != null)?
this.statsFactory.getByteCounts(device,timeStart,timeEnd) :
null;
return (byteCounts != null)? byteCounts : new long[] { 0L, 0L, 0L, 0L };
} catch (DBException dbe) {
Print.logException("Counting Data Bytes", dbe);
return new long[] { 0L, 0L, 0L, 0L };
}
}
// ------------------------------------------------------------------------
}
| true
|
ac665bf0f53b2cffdbce408b3c1278bfbe361711
|
Java
|
lalwani1312/News-Outlinks
|
/app/src/main/java/com/codefather/inshortsoutlinks/browser/WebActivity.java
|
UTF-8
| 4,514
| 2.015625
| 2
|
[] |
no_license
|
package com.codefather.inshortsoutlinks.browser;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.codefather.inshortsoutlinks.BaseActivity;
import com.codefather.inshortsoutlinks.R;
import com.codefather.inshortsoutlinks.model.News;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class WebActivity extends BaseActivity {
public static final String EXTRA_NEWS = "news";
public static final String EXTRA_POSITION = "position";
private News mNews;
private int mPosition;
@BindView(R.id.web_view)
WebView mWebView;
@BindView(R.id.error_layout)
LinearLayout mErrorLayout;
@BindView(R.id.error)
TextView mError;
@BindView(R.id.fab_bookmark)
FloatingActionButton mFabBookmark;
@BindView(R.id.toolbar)
Toolbar mToolbar;
@BindView(R.id.progress_bar)
ProgressBar mProgressBar;
public static void launchForResult(Activity activity, int requestCode, int position, News news) {
Intent intent = new Intent(activity, WebActivity.class);
intent.putExtra(EXTRA_POSITION, position);
intent.putExtra(EXTRA_NEWS, news);
activity.startActivityForResult(intent, requestCode);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
ButterKnife.bind(this);
mNews = getIntent().getParcelableExtra(EXTRA_NEWS);
mPosition = getIntent().getIntExtra(EXTRA_POSITION, -1);
if (mNews == null || TextUtils.isEmpty(mNews.getUrl())) {
finish();
}
setupToolbar();
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.loadUrl(mNews.getUrl());
}
private void setupToolbar() {
setSupportActionBar(mToolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.ic_back);
}
}
@OnClick(R.id.fab_bookmark)
void onFabBookmarkClicked() {
if (mNews.getIsBookmarked() == 1) {
mNews.setIsBookmarked(0);
mNews.save();
mFabBookmark.setImageResource(R.drawable.ic_bookmark_unselected);
} else {
mNews.setIsBookmarked(1);
mNews.save();
mFabBookmark.setImageResource(R.drawable.ic_bookmark_selected);
}
}
@Override
public void onBackPressed() {
Intent data = new Intent();
data.putExtra(EXTRA_POSITION, mPosition);
data.putExtra(EXTRA_NEWS, mNews);
setResult(RESULT_OK, data);
super.onBackPressed();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
private class MyWebViewClient extends WebViewClient {
@Override
public void onPageFinished(WebView view, String url) {
mFabBookmark.show();
mProgressBar.setVisibility(View.GONE);
if (mNews.getIsBookmarked() == 1) {
mFabBookmark.setImageResource(R.drawable.ic_bookmark_selected);
} else {
mFabBookmark.setImageResource(R.drawable.ic_bookmark_unselected);
}
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
mWebView.setVisibility(View.GONE);
mFabBookmark.setVisibility(View.GONE);
mProgressBar.setVisibility(View.GONE);
mErrorLayout.setVisibility(View.VISIBLE);
mError.setText(errorCode + ": " + description);
}
}
}
| true
|
61cc73bffb457c503a90aed14e30a6cc6e650f1d
|
Java
|
coderczp/jzran-1
|
/src/net/jzran/FileSeekableInputStream.java
|
UTF-8
| 1,213
| 2.6875
| 3
|
[] |
no_license
|
package net.jzran;
import java.io.IOException;
import java.io.RandomAccessFile;
public class FileSeekableInputStream extends SeekableInputStream {
private final RandomAccessFile raf;
public FileSeekableInputStream(RandomAccessFile raf) {
this.raf = raf;
}
@Override
public int read() throws IOException {
return raf.read();
}
@Override
public int read(byte[] b) throws IOException {
return raf.read(b);
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
return raf.read(b, off, len);
}
@Override
public long skip(long n) throws IOException {
return n < 0 ? 0 : raf.skipBytes((int) Math.min(n, Integer.MAX_VALUE));
}
@Override
public int available() throws IOException {
return (int)Math.min(raf.length() - raf.getFilePointer(), Integer.MAX_VALUE);
}
@Override
public void close() throws IOException {
raf.close();
}
public void seek(long offset) throws IOException {
raf.seek(offset);
}
public long length() throws IOException {
return raf.length();
}
}
| true
|
04f47ae79a919cd3679d00b350eba4f825dbdd2d
|
Java
|
TKnudsen/ComplexDataObject
|
/src/main/java/com/github/TKnudsen/ComplexDataObject/model/io/parsers/objects/IntegerParser.java
|
UTF-8
| 1,062
| 3.265625
| 3
|
[
"Apache-2.0"
] |
permissive
|
package com.github.TKnudsen.ComplexDataObject.model.io.parsers.objects;
/**
*
* Interger parser that throws an exception when a number shall be parsed that
* is larger than an Integer's max value.
*
* <p>
* Copyright: Copyright (c) 2016-2020
* </p>
*
* @author Juergen Bernard
* @version 1.03
*/
public class IntegerParser implements IObjectParser<Integer> {
private LongParser LongParser = new LongParser();
@Override
public Integer apply(Object object) {
if (object == null)
return null;
if (object instanceof Integer)
return ((Integer) object).intValue();
Long l = LongParser.apply(object);
if (l == null)
return null;
else if (l > Integer.MAX_VALUE)
System.err.println("IntegerParser should never parse values of size: " + l + ". Value will be parsed to "
+ l.intValue());
return l.intValue();
}
@Override
public Class<Integer> getOutputClassType() {
return Integer.class;
}
@Override
public String toString() {
return this.getClass().getSimpleName();
}
}
| true
|
5de948df77d6c489ab05b82dee18ad44ade0f072
|
Java
|
PrachiEduBridge/AdvertisementManagementSystem
|
/AddvertiseManagmentSystem/src/com/adpoint/service/SearchDetails.java
|
UTF-8
| 2,797
| 2.453125
| 2
|
[] |
no_license
|
package com.adpoint.service;
//import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class SearchDetails extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out=response.getWriter();
String email = request.getParameter("email");
String[] details=new JdbcCustomerSearch().searchByEmail(email);
RequestDispatcher rd1 = request.getRequestDispatcher("/header.html");
rd1.include(request, response);
out.print("<html>");
out.print("<head>");
out.print("<style>");
out.print("input[type=submit] {\r\n" +
" border-radius: 5px;\r\n" +
" border: 0;\r\n" +
" width: 160px;\r\n" +
"margin:0% 43% 0%;"+
" height:40px;\r\n" +
" font-family: Tahoma;\r\n" +
" background: #800000;\r\n" +
" color:yellow;\r\n" +
" \r\n" +
"}");
out.print("</style>");
out.print("</head>");
out.println("<br><br><font size=\"5\" face=\"verdana\" color=\"red\"><center>AGENCY DETAILS ARE BELOW</center></font><br><br>");
out.print("<center>");
out.print("Name : ");out.print(details[0]);
out.print("</center><br>");
out.print("<center>");
out.print("Email : ");out.print(details[1]);
out.print("</center><br>");
out.print("<center>");
out.print("Mobile : ");out.print(details[2]);
out.print("</center><br>");
out.print("<center>");
out.print("City : ");out.print(details[3]);
out.print("</center><br>");
String [][] photodetail=new JdbcAgencyPostSearch().getAdPhoto(email);
out.print("<center>");
out.print("<hr>HOARDING IMAGES WITH PRICE AND LOCATION<br><hr><br>");
for(int i=0;i<photodetail.length;i++) {
//String s="image"+File.separator+photodetail[i][3];
String s="image/"+photodetail[i][3];
out.print("<img src=\""+s+"\" alt=\"Smiley face\" height=\"50%\" width=\"50%\"<br><br>");
out.print("PRICE : "+photodetail[i][0]+"<br>");
out.print("LOCATION : "+photodetail[i][1]+"<hr><br>");
}
out.print("</center><br>");
out.print("<div id=\"btn\">");
out.print(
"<form action=\"PlaceOrder\" method=\"post\"><input type=\"hidden\" value=\""
+ details[1]+"\" name=\"agencyemail\"> <input type=\"submit\" value=\"PLACE ORDER\"></form><br>"
);
out.print("</div>");
out.print("</html>");
RequestDispatcher rd3 = request.getRequestDispatcher("/footer.html");
rd3.include(request, response);
}
}
| true
|
5e24a445b7349e0522e97878321eff385f1b7d73
|
Java
|
justaddwater71/GroupAndSlice
|
/src/edu/nps/jody/GroupAndSlice/FileSizeComparator.java
|
UTF-8
| 419
| 3.109375
| 3
|
[] |
no_license
|
package edu.nps.jody.GroupAndSlice;
import java.io.File;
import java.util.Comparator;
public class FileSizeComparator<T> implements Comparator<T>
{
@Override
public int compare(T o1, T o2)
{
File file1;
File file2;
file1 = (File)o1;
file2 = (File)o2;
if (file1.length() < file2.length())
{
return -1;
}
if (file1.length() >file2.length())
{
return 1;
}
return 0;
}
}
| true
|
d6d844e0bbf96725050d20b3a0194a20715c819a
|
Java
|
angeldragon532/togetherClient
|
/Together/src/com/beijing/together/activity/UserManagerActivity.java
|
UTF-8
| 14,393
| 1.757813
| 2
|
[] |
no_license
|
//package com.beijing.together.activity;
//
//import java.io.ByteArrayOutputStream;
//import java.io.File;
//import java.util.HashMap;
//
//import android.annotation.SuppressLint;
//import android.app.Activity;
//import android.app.AlertDialog;
//import android.app.Dialog;
//import android.content.ActivityNotFoundException;
//import android.content.DialogInterface;
//import android.content.Intent;
//import android.graphics.Bitmap;
//import android.net.Uri;
//import android.os.Bundle;
//import android.os.Environment;
//import android.os.Handler;
//import android.os.Message;
//import android.provider.MediaStore;
//import android.view.View;
//import android.view.Window;
//import android.widget.EditText;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.TextView;
//import android.widget.Toast;
//
//import com.busonline.plamhall.PlamHallApplication;
//import com.busonline.plamhall.R;
//import com.busonline.plamhall.entity.AccountInfo;
//import com.busonline.plamhall.manager.LoginResourceManager;
//import com.busonline.plamhall.net.CallBackListenter;
//import com.busonline.plamhall.utils.FileUtil;
//import com.busonline.plamhall.utils.Utils;
//
///**
// * 用户管理界面的窗口
// *
// * @author chenlong
// */
//public class UserManagerActivity extends BaseActivity implements
// View.OnClickListener {
// private static final int PHOTO_GRAPH = 1;// 拍照
// private static final int PHOTO_ZOOM = 2; // 缩放
// private static final int PHOTO_RESOULT = 3;// 结果
// private static final String IMAGE_UNSPECIFIED = "image/*";
// /* 用来标识请求gallery的activity */
// private static final int PHOTO_PICKED_WITH_DATA = 3021;
//
// private static final int OPEN_DIALOG_INFO = 0;
//
// private ImageView title_back;// 返回按钮
// private TextView title_text;// 用户信息
// private TextView title_right_text;// 用户操作按钮
// private ImageView user_photo_info;// 用户头像信息
// private LinearLayout user_phonto_ll;// 用户头像
// private TextView user_name;// 用户名称
// private TextView user_phone;// 用户手机号
// private TextView user_belong;// 手机归属地
// private TextView user_time;// 入网时间
// private EditText user_address;// 用户联系地址
// private EditText user_postcode;// 邮编
// private EditText user_email;// 邮箱
// //private LinearLayout receive_adder;// 收货地址
// private LinearLayout modify_passwor;// 修改服务密码
//
// private static final int FAILURE_FINISHED = 0;// 失败
// private static final int SUCCESS_FINISHED = 1;// 成功
//
// private static final int UPLOAD_PHOTO = 4;// 上传用户头像
// private static final int DOWNLOAD_PHOTO = 5;// 下载用户头像
//
// private static final int CONTACT_COMMIT = 6;// 修改提交
//
// private static final int DOWN_LOAD_PHOTO_TYPE_VALUE = 0;// 需要上传的图片类型
//
// private Bitmap needSaveBitmap;// 需要保持的图片
//
// private boolean isClick = true;// 是否可以点击编辑
//
// private Dialog dialog = null;
// private Handler handler = new Handler() {
// @Override
// public void handleMessage(Message msg) {
// super.handleMessage(msg);
//// if (dialog != null && dialog.isShowing())
//// dialog.dismiss();
//// if (msg.what == FAILURE_FINISHED) {
//// if (DOWNLOAD_PHOTO != msg.arg1)
//// Toast.makeText(UserManagerActivity.this,
//// String.valueOf(msg.obj), Toast.LENGTH_SHORT).show();
//// } else if (msg.what == SUCCESS_FINISHED) {
//// switch (msg.arg1) {
//// case UPLOAD_PHOTO:// 用户头像上传
//// HashMap<String, Object> hashValue = (HashMap<String, Object>) msg.obj;
//// String uploadImageID = (String) hashValue.get("imageID");// 上传头像成功
//// // 返回头像ID
//// System.out.println("------uploadImageID-------"
//// + uploadImageID);
//// File saveFile = FileUtil.getUserPhotoImage(
//// UserManagerActivity.this, PlamHallApplication
//// .getInstance().getUserPhoneNo(), uploadImageID + ".png");
//// FileUtil.saveImageToDataCachDir(needSaveBitmap,
//// saveFile.getAbsolutePath());
//// PlamHallApplication.getInstance().setUserPhoto(
//// needSaveBitmap);
//// user_photo_info.setImageBitmap(needSaveBitmap);// 把图片显示在ImageView控件上
//// break;
//// case DOWNLOAD_PHOTO:// 图片下载
//// Bitmap map = (Bitmap) msg.obj;
//// if (map != null) {
//// File userPhoto = FileUtil.getUserPhotoImage(
//// UserManagerActivity.this, PlamHallApplication
//// .getInstance().getAccountInfo()
//// .getPhoneNumber(), PlamHallApplication
//// .getInstance().getAccountInfo()
//// .getHeadImage());
//// FileUtil.saveImageToDataCachDir(map,
//// userPhoto.getAbsolutePath());
//// PlamHallApplication.getInstance().setUserPhoto(map);
//// user_photo_info.setImageBitmap(map);
//// } else {
//// user_photo_info.setImageResource(R.drawable.my_name);
//// }
//// break;
//// case CONTACT_COMMIT://修改用户信息提交
//// title_right_text.setText("编辑");
//// isClick = true;
//// toggleEditeable(false);
//// Toast.makeText(UserManagerActivity.this, "你已修改用户信息成功",
//// Toast.LENGTH_SHORT).show();
//// PlamHallApplication.getInstance().updateAccountInfo(
//// user_address.getText().toString(),
//// user_postcode.getText().toString(),
//// user_email.getText().toString());
//// finish();
//// break;
//// default:
//// break;
//// }
//// }
//// }
// };
//
// private void toggleEditeable(boolean status){
// user_address.setEnabled(status);
// user_postcode.setEnabled(status);
// user_email.setEnabled(status);
//
// if(status)user_address.requestFocus();
//// if(!status){
//// user_address.setFocusable(false);
//// user_postcode.setFocusable(false);
//// user_email.setFocusable(false);
//// }else{
//// user_address.requestFocus();
//// user_postcode.requestFocus();
//// user_email.requestFocus();
//// }
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.user_manager);
// initView();
// initData();
// initListener();
// }
//
// public void initView() {
// title_back = (ImageView) findViewById(R.id.title_back_id);
// title_text = (TextView) findViewById(R.id.title_text_mid_id);
// title_right_text = (TextView) findViewById(R.id.title_right_text_id);
// user_photo_info = (ImageView) findViewById(R.id.user_phone_id);
// user_phonto_ll = (LinearLayout) findViewById(R.id.user_phone_ll_id);
// user_name = (TextView) findViewById(R.id.user_name_id);
// user_phone = (TextView) findViewById(R.id.user_number_id);
// user_belong = (TextView) findViewById(R.id.user_belong_id);
// user_time = (TextView) findViewById(R.id.user_net_time_id);
// user_address = (EditText) findViewById(R.id.user_manager_receive_address_id);
// user_postcode = (EditText) findViewById(R.id.user_manager_receive_postcode_id);
// user_email = (EditText) findViewById(R.id.user_manager_receive_email_id);
// //receive_adder = (LinearLayout) findViewById(R.id.user_manager_receive_address_id);
// modify_passwor = (LinearLayout) findViewById(R.id.user_manager_modify_password_id);
// title_text.setText("用户信息");
// title_right_text.setText("编辑");
// }
//
// /**
// * 初始化数据
// */
// private void initData() {
// AccountInfo info = PlamHallApplication.getInstance().getAccountInfo();
// user_name.setText(info.getAccountName());
// user_phone.setText(info.getPhoneNumber());
// user_belong.setText(info.getPhoneArea());
// user_time.setText(info.getStartTime());
// user_address.setText(info.getContactAddress());
// user_postcode.setText(info.getPostCode());
// user_email.setText(info.getEmail());
// Bitmap map = FileUtil.initUserPhoto(this, "0",
// user_photo_info,// 初始化用户头像
// PlamHallApplication.getInstance().getAccountInfo()
// .getHeadImage(), PlamHallApplication.getInstance()
// .getAccountInfo().getPhoneNumber(), DOWNLOAD_PHOTO,
// handler);
// if (map != null) {
// user_photo_info.setImageBitmap(map);
// }
// userInfoManager = new LoginResourceManager();
// }
//
// public void initListener() {
// title_back.setOnClickListener(this);
// user_phonto_ll.setOnClickListener(this);
// //receive_adder.setOnClickListener(this);
// title_right_text.setOnClickListener(this);
// modify_passwor.setOnClickListener(this);
// }
//
// public Dialog onCreateDialog(int id) {
// AlertDialog.Builder builder = new AlertDialog.Builder(this);
// final String[] person_items = { "相册", "拍照" };
// builder.setTitle("添加图片");
// builder.setItems(person_items, new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int item) {
// if (item == 0) {// 相册
// // Intent intent = new Intent(Intent.ACTION_PICK, null);
// // intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
// // IMAGE_UNSPECIFIED);
// // startActivityForResult(intent, PHOTO_ZOOM);
// try {
// final Intent intent = getPhotoPickIntent();
// startActivityForResult(intent, PHOTO_RESOULT);
// } catch (ActivityNotFoundException e) {
// Toast.makeText(UserManagerActivity.this,
// R.string.gallerynotfound, Toast.LENGTH_SHORT)
// .show();
// }
// } else {
// Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// intent.putExtra(
// MediaStore.EXTRA_OUTPUT,
// Uri.fromFile(new File(Environment
// .getExternalStorageDirectory(), "temp.jpg")));
// // intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(
// // FileUtil.getUserPhotoImage(this,Constants.PHOTO_IMAGE_DIRICTORY,Constants.PHOTO_IMAGE_NAME)));
// startActivityForResult(intent, PHOTO_GRAPH);
// }
// }
// });
// AlertDialog alert = builder.create();
// alert.show();
// ;
// return alert;
// }
//
// @Override
// protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// super.onActivityResult(requestCode, resultCode, data);
// if (resultCode == RESULT_OK) {
// if (requestCode == PHOTO_GRAPH) {
// // 设置文件保存路径
// File picture = new File(
// Environment.getExternalStorageDirectory() + "/temp.jpg");
// // File picture =
// // FileUtil.createDirectory(FileUtil.getDataAreaFile(this,"img"),"temp.jpg");
// startPhotoZoom(Uri.fromFile(picture));
// }
//
// if (requestCode == PHOTO_ZOOM) {// 缩放
// startPhotoZoom(data.getData());
// }
//
// if (data == null)
// return;
// // 处理结果
// if (requestCode == PHOTO_RESOULT) {
// Bundle extras = data.getExtras();
// if (extras != null) {
// Bitmap photo = extras.getParcelable("data");
// needSaveBitmap = photo;// 保存一份需要保持的图片
// ByteArrayOutputStream stream = new ByteArrayOutputStream();
// photo.compress(Bitmap.CompressFormat.JPEG, 75, stream);// (0-100)压缩文件
// if (dialog == null || !dialog.isShowing())
// dialog = Utils.createProgressDialog(this);
// new LoginResourceManager().uploadUserPhoto(this,
// stream,// 上传用户头像
// String.valueOf(DOWN_LOAD_PHOTO_TYPE_VALUE), null,
// new CallBackListenter(this, handler, UPLOAD_PHOTO));
// // File file =
// // FileUtil.getUserPhotoImage(this,Constants.PHOTO_IMAGE_DIRICTORY,Constants.PHOTO_IMAGE_NAME);
// // new
// // LoginResourceManager().uploadUserPhoto(this,Utils.Bitmap2InputStream(photo),//上传用户头像
// // String.valueOf(DOWN_LOAD_PHOTO_TYPE_VALUE),null,
// // new CallBackListenter(UPLOAD_PHOTO,this));
//
// // File saveFile = FileUtil.getUserPhotoImage(this,
// // Constants.PHOTO_IMAGE_DIRICTORY,PlamHallApplication.
// // getInstance().getAccountInfo().getPhoneNumber()+".png");
// // if(!saveFile.exists())saveFile.createNewFile();
// // FileOutputStream save = new FileOutputStream(saveFile);
// // photo.compress(Bitmap.CompressFormat.JPEG, 75, save);//
// // (0-100)压缩文件
//
// }
// }
// }
// }
//
// /**
// * 收缩图片
// *
// * @param uri
// */
// public void startPhotoZoom(Uri uri) {
// Intent intent = new Intent("com.android.camera.action.CROP");
// intent.setDataAndType(uri, IMAGE_UNSPECIFIED);
// intent.putExtra("crop", "true");
// // aspectX aspectY 是宽高的比例
// intent.putExtra("aspectX", 1);
// intent.putExtra("aspectY", 1);
// // outputX outputY 是裁剪图片宽高
// intent.putExtra("outputX", 100);
// intent.putExtra("outputY", 100);
// intent.putExtra("outputFormat", "JPEG");
// intent.putExtra("return-data", true);
// intent.putExtra("noFaceDetection", true);
// startActivityForResult(intent, PHOTO_RESOULT);
// }
//
// @Override
// public void onClick(View v) {
// switch (v.getId()) {
// case R.id.title_back_id:// 标题返回
// finish();
// break;
//// case R.id.user_manager_receive_address_id:// 到达收货地址
//// Intent receiveIntent = new Intent(this,
//// ReceiveAddressActivity.class);
//// startActivity(receiveIntent);
//// break;
// case R.id.title_right_text_id://点击右边
// if(isClick){
// toggleEditeable(true);
// title_right_text.setText(R.string.save);
// isClick = false;
// }else{//保存修改后的数据 提交到服务器
// if(dialog == null || !dialog.isShowing())
// dialog = Utils.createProgressDialog(this);
// //String area = user_area.getText().toString();
// String address = user_address.getText().toString();
// String postcode = user_postcode.getText().toString();
// String email = user_email.getText().toString();
// userInfoManager.modifyAccountInfo(this,email,address,postcode,
// new CallBackListenter(this,handler,CONTACT_COMMIT));
// }
// break;
// case R.id.user_manager_modify_password_id:// 修改服务密码
// Intent modifyIntent = new Intent(this,
// ModifyServerPasswordActivity.class);
// startActivity(modifyIntent);
// break;
// case R.id.user_phone_ll_id:// 添加用户头像
// showDialog(OPEN_DIALOG_INFO);
// break;
// default:
// break;
// }
//
// }
//}
//
| true
|
d9008516f0200927d987087e85fd0085f8f63c3d
|
Java
|
tiendv/detaitotnghiep
|
/Source code/dblp expert find/dblpdata/src/main/java/edu/ucdavis/cs/dblp/data/DblpKeywordDao.java
|
UTF-8
| 471
| 2.46875
| 2
|
[] |
no_license
|
/**
*
*/
package edu.ucdavis.cs.dblp.data;
import java.util.List;
import javax.persistence.EntityManager;
/**
* Data Access Object for DBLP {@link Keyword}s.
*
* @author pfishero
*/
public interface DblpKeywordDao {
Keyword findById(Long id);
Keyword findByName(String keyword);
List<Keyword> findAll();
void save(Keyword keyword);
void update(Keyword keyword);
void delete(Keyword keyword);
EntityManager getEm();
}
| true
|
27d790e167cfcdb24d46366da3997d1e112b73ef
|
Java
|
louism33/ChessCore
|
/src/test/java/com/github/louism33/chesscore/BoardConstantsTest.java
|
UTF-8
| 1,883
| 2.640625
| 3
|
[
"MIT"
] |
permissive
|
package com.github.louism33.chesscore;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import static com.github.louism33.chesscore.BitOperations.populationCount;
import static com.github.louism33.chesscore.BoardConstants.*;
class BoardConstantsTest {
@Test
void intialBoard(){
for (int i = 0; i < 8; i++) {
Assert.assertEquals(INITIAL_PIECE_SQUARES[i+8], WHITE_PAWN);
Assert.assertEquals(INITIAL_PIECE_SQUARES[64-9-i], BLACK_PAWN);
}
Assert.assertEquals(INITIAL_PIECE_SQUARES[0], WHITE_ROOK);
Assert.assertEquals(INITIAL_PIECE_SQUARES[1], WHITE_KNIGHT);
Assert.assertEquals(INITIAL_PIECE_SQUARES[2], WHITE_BISHOP);
Assert.assertEquals(INITIAL_PIECE_SQUARES[3], WHITE_KING);
Assert.assertEquals(INITIAL_PIECE_SQUARES[4], WHITE_QUEEN);
Assert.assertEquals(INITIAL_PIECE_SQUARES[5], WHITE_BISHOP);
Assert.assertEquals(INITIAL_PIECE_SQUARES[6], WHITE_KNIGHT);
Assert.assertEquals(INITIAL_PIECE_SQUARES[7], WHITE_ROOK);
Assert.assertEquals(INITIAL_PIECE_SQUARES[56], BLACK_ROOK);
Assert.assertEquals(INITIAL_PIECE_SQUARES[57], BLACK_KNIGHT);
Assert.assertEquals(INITIAL_PIECE_SQUARES[58], BLACK_BISHOP);
Assert.assertEquals(INITIAL_PIECE_SQUARES[59], BLACK_KING);
Assert.assertEquals(INITIAL_PIECE_SQUARES[60], BLACK_QUEEN);
Assert.assertEquals(INITIAL_PIECE_SQUARES[61], BLACK_BISHOP);
Assert.assertEquals(INITIAL_PIECE_SQUARES[62], BLACK_KNIGHT);
Assert.assertEquals(INITIAL_PIECE_SQUARES[63], BLACK_ROOK);
}
@Test
void colourTest() {
Assert.assertEquals(0, (WHITE_COLOURED_SQUARES & BLACK_COLOURED_SQUARES));
Assert.assertEquals(32, populationCount(WHITE_COLOURED_SQUARES));
Assert.assertEquals(32, populationCount(BLACK_COLOURED_SQUARES));
}
}
| true
|
10c8b8af9430c9994eaab94feaca3b34a2acd029
|
Java
|
daowoo/junit
|
/src/main/java/com/daowoo/bigdata/chap4/OtherStockMatcher.java
|
UTF-8
| 244
| 2.25
| 2
|
[] |
no_license
|
package com.daowoo.bigdata.chap4;
/**
* Created by apple on 24/08/2017.
*/
public class OtherStockMatcher extends BlueChipStockMatcher{
@Override
public boolean matches(Object symbol) {
return !super.matches(symbol);
}
}
| true
|
720e4544ee721b00d13cb3764ca8e1487d03d164
|
Java
|
srusso/twitter-statistics
|
/src/main/java/com/ssof/gui/ZScoreGraphPanel.java
|
UTF-8
| 8,199
| 2.515625
| 3
|
[] |
no_license
|
package com.ssof.gui;
import com.ssof.emotions.ZScoreForGraph;
import com.ssof.exceptions.NoSuchAttributeException;
import com.ssof.exceptions.NoSuchDayException;
import com.ssof.utils.comparators.DateComparator;
import org.joda.time.DateTime;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ZScoreGraphPanel extends JPanel implements MouseListener, MouseMotionListener, ComponentListener{
private static final long serialVersionUID = -1441820373172173708L;
private final ZScoreForGraph zscores;
private static final Color backgroundColor = Color.WHITE;
private static final Color axisColor = Color.BLACK;
private final List <Color> lineColors;
/**
* Coordinate del mouse.
*/
private int mouseX = 0, mouseY = 0;
private DateTime [] days;
private String [] selectedAttributes;
public ZScoreGraphPanel(ZScoreForGraph zscores){
this.zscores = zscores;
lineColors = new ArrayList<>();
lineColors.add(Color.RED);
lineColors.add(Color.BLUE);
lineColors.add(Color.CYAN);
lineColors.add(Color.GRAY);
lineColors.add(Color.GREEN);
lineColors.add(Color.MAGENTA);
lineColors.add(Color.ORANGE);
lineColors.add(Color.PINK);
lineColors.add(Color.YELLOW);
lineColors.add(Color.DARK_GRAY);
lineColors.add(Color.BLACK);
while(lineColors.size() < zscores.getValidAttributes().size()){
lineColors.addAll(lineColors);
}
setPreferredSize(getInitialSize());
setBackground(backgroundColor);
addMouseListener(this);
addMouseMotionListener(this);
addComponentListener(this);
List<DateTime> dayList = new ArrayList<>();
dayList.addAll(zscores.getValidDays());
Collections.sort(dayList, new DateComparator());
days = dayList.toArray(new DateTime[dayList.size()]);
selectedAttributes = null;
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2=(Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int width = getWidth();
int height = getHeight();
int originx; //origine degli assi
int endx; //fine asse orizzontale e verticale
int zeroLine = height /2;
int verticalHeight = height / 4;
int strwidth;
FontMetrics metrics = g2.getFontMetrics(getFont());
strwidth = metrics.stringWidth("-1.000");
originx = width / 100 + strwidth;
endx = width*99/100;
//disegno gli assi cartesiani
g2.setColor(axisColor);
g2.drawLine(originx, zeroLine, endx, zeroLine); //asse orizzontale centrale
g2.drawLine(originx, zeroLine+verticalHeight, endx, zeroLine+verticalHeight); //asse orizzontale inferiore
g2.drawLine(originx, zeroLine-verticalHeight, endx, zeroLine-verticalHeight); //asse orizzontale superiore
g2.drawLine(originx, zeroLine+verticalHeight, originx, zeroLine-verticalHeight); //asse verticale
if(days.length == 0){
g2.drawString("NO TWEETS", width/2, height/2);
return;
}
if(selectedAttributes == null){
g2.drawString("Selezionare un attributo", width/2, height/2);
return;
}
//ora disegno le linee sull'asse orizzontale [asse temporale]
int startTimex = originx ; //coordinata dell'inizio del periodo temporale sull'asse orizzontale [cioe' della riga del primo giorno]
int endTimex = endx - (width-endx)/2; //coordinata della fine del periodo temporale sull'asse orizzontale [cioe' della riga dell'ultimo giorno]
int dayLineDist; //distanza tra una linea e l'altra, in pixel
dayLineDist = (endTimex - startTimex) / days.length;
double max_y_draw = Double.MIN_VALUE;
for (String selectedAttribute : selectedAttributes) {
//passo al calcolo dei valori da disegnare
double[] values = new double[days.length];
double maxValue = Double.MIN_VALUE; //valore massimo sull'asse delle ordinate
//prendo i valori da disegnare sull'asse delle ordinate (cioe' la media dell'attributo selezionato per ogni giorno)
for (int j = 0; j < values.length; j++) {
try {
values[j] = zscores.getDayValue(days[j], selectedAttribute);
} catch (NoSuchDayException | NoSuchAttributeException e) {
System.out.println(e);
return;
}
if (values[j] >= 0) {
if (maxValue < values[j]) {
maxValue = values[j];
if (maxValue > max_y_draw)
max_y_draw = maxValue;
}
} else {
double temp = -values[j];
if (maxValue < temp) {
maxValue = temp;
if (maxValue > max_y_draw)
max_y_draw = maxValue;
}
}
}
}
for (String selectedAttribute : selectedAttributes) {
//passo al calcolo dei valori da disegnare
double[] values = new double[days.length];
//prendo i valori da disegnare sull'asse delle ordinate (cioe' la media dell'attributo selezionato per ogni giorno)
for (int j = 0; j < values.length; j++) {
try {
values[j] = zscores.getDayValue(days[j], selectedAttribute);
} catch (NoSuchDayException e) {
System.out.println(e);
return;
} catch (NoSuchAttributeException e) {
System.out.println(e);
return;
}
}
//finalmente, disegno il grafico
try {
g2.setColor(lineColors.get(zscores.getAttributePosition(selectedAttribute)));
} catch (RuntimeException e) {
JOptionPane.showMessageDialog(null, "Impossibile mostrare grafico di \'" + selectedAttribute + "\'.", "Errore " +
"interno", JOptionPane.ERROR_MESSAGE);
}
for (int j = 1; j < values.length; j++) {
int h1 = (int) (zeroLine - (values[j - 1] * verticalHeight / max_y_draw));
int h2 = (int) (zeroLine - (values[j] * verticalHeight / max_y_draw));
g2.drawLine(startTimex + (j - 1) * dayLineDist + dayLineDist / 2, h1, startTimex + j * dayLineDist + dayLineDist
/ 2, h2);
}
}
//disegno i valori sull'asse y
DecimalFormat df = new DecimalFormat("#.###");
g2.setColor(Color.BLACK);
int hgt = metrics.getHeight();
g2.drawString(" " + df.format(max_y_draw), (originx - strwidth)/2, zeroLine - verticalHeight + hgt/2);
g2.drawString(" 0.0", (originx - strwidth)/2, zeroLine + hgt/2);
g2.drawString("-" + df.format(max_y_draw), (originx - strwidth)/2, zeroLine + verticalHeight + hgt/2);
g2.setColor(axisColor);
//disegno la data vicino al puntatore del mouse
if(mouseX < endx){
int dayLenPx = (endx - originx) / days.length;
int d = (mouseX - originx) / dayLenPx;
if(d < days.length){
String dateToDraw = "Giorno " + days[d].getDayOfMonth()
+ "/" +
(days[d].getMonthOfYear())
+ "/" +
days[d].getYear();
int wdt = metrics.stringWidth(dateToDraw);
int tx = mouseX - wdt/2;
if(tx < originx){
tx = originx;
} else if(tx + wdt > endx){
tx = endx - wdt;
}
g2.drawString(dateToDraw, tx, mouseY - hgt);
}
}
}
public void setSelectedAttributes(String [] attrs){
selectedAttributes = attrs;
repaint();
}
private static Dimension getInitialSize() {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int size=(int)(screenSize.getHeight()*3)/4;
Dimension d=new Dimension(size, size);
return d;
}
public void mouseClicked(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
public void mouseDragged(MouseEvent e) {
}
public void mouseMoved(MouseEvent e) {
mouseX = e.getX();
mouseY = e.getY();
repaint();
}
public void componentHidden(ComponentEvent arg0) {
}
public void componentMoved(ComponentEvent arg0) {
}
public void componentResized(ComponentEvent arg0) {
repaint();
}
public void componentShown(ComponentEvent arg0) {
}
}
| true
|
a9b06a91f8d34f90a9a5401ae1813d2c81bb4534
|
Java
|
varsize/atlant-android
|
/app/src/main/java/com/frostchein/atlant/views/AtlToolbarView.java
|
UTF-8
| 1,466
| 2.28125
| 2
|
[
"MIT"
] |
permissive
|
package com.frostchein.atlant.views;
import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.TextView;
import butterknife.BindView;
import com.frostchein.atlant.R;
import com.frostchein.atlant.model.Balance;
import com.frostchein.atlant.utils.DigitsUtils;
import java.math.BigInteger;
public class AtlToolbarView extends BaseCustomView {
@BindView(R.id.toolbar_title)
TextView textTitle;
@BindView(R.id.toolbar_value)
TextView textValue;
public AtlToolbarView(Context context) {
super(context);
}
public AtlToolbarView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void initView() {
}
@Override
protected int getLayoutRes() {
return R.layout.view_toolbar;
}
/**
* Sets content on view
*
* @param objects List of wallet entities.
*/
@SuppressWarnings("unchecked")
@Override
public void setContent(Object... objects) {
if (objects != null && objects.length > 0) {
Balance balance = (Balance) objects[0];
String atl = "0";
if (balance != null) {
atl = balance.getResult();
}
textValue.setText(
DigitsUtils.ATLtoString(new BigInteger(atl)) + " " + getResources().getString(R.string.app_prefix_coin));
}
}
public void removeTitle() {
if (textTitle != null) {
((ViewGroup) textTitle.getParent()).removeView(textTitle);
}
}
}
| true
|
4535e3048cecb3f43d2111ddb44c29c0214d7b55
|
Java
|
hejxtom/microservicem
|
/springcloud_atguigu/microservicecloud/microservicecloud-api/src/main/java/com/atguigu/springcloud/service/DeptClientService.java
|
UTF-8
| 1,000
| 1.890625
| 2
|
[] |
no_license
|
package com.atguigu.springcloud.service;
import com.atguigu.springcloud.entities.DeptEntity;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;
/**
* @author GongXings
* @createTime 31 11:54
* @description
*/
@FeignClient(value = "MICROSERVICECLOUD-DEPT",fallbackFactory = DeptClientServiceFallBackFactory.class)
public interface DeptClientService {
@RequestMapping(value = "/dept/add",method = RequestMethod.GET)
public boolean add( DeptEntity deptEntity);
// boolean add(DeptEntity deptEntity);
@RequestMapping(value = "/dept/findById/{deptNo}",method = RequestMethod.GET)
public DeptEntity findById(@PathVariable("deptNo") Long deptNo);
@RequestMapping(value = "/dept/findAll",method = RequestMethod.GET)
public List<DeptEntity> findAll();
}
| true
|
eea8456113ab28bf5e79d3f18e96c55bc4aea305
|
Java
|
Debjyoti2/POC-Projetct
|
/Java Abstraction 2/src/com/Vehicle.java
|
UTF-8
| 110
| 2.234375
| 2
|
[] |
no_license
|
package com;
abstract class Vehicle {
abstract void start();
abstract void vehiCleName();
}
| true
|
39d439b9943ef202387de8b0b2fb9e814b3d7a03
|
Java
|
nileshborole/vertx-codegen
|
/src/test/java/io/vertx/test/codegen/converter/DataObjectTest.java
|
UTF-8
| 50,297
| 1.898438
| 2
|
[
"Apache-2.0"
] |
permissive
|
/*
* Copyright (c) 2011-2017 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*/
package io.vertx.test.codegen.converter;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
import java.net.URI;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
*/
public class DataObjectTest {
private static JsonObject toJson(Map<String, Object> map) {
JsonObject json = new JsonObject();
map.forEach(json::put);
return json;
}
@Test
public void testJsonToDataObject() throws Exception {
String key = TestUtils.randomAlphaString(10);
String stringValue = TestUtils.randomAlphaString(20);
boolean booleanValue = TestUtils.randomBoolean();
byte byteValue = TestUtils.randomByte();
short shortValue = TestUtils.randomShort();
int intValue = TestUtils.randomInt();
long longValue = TestUtils.randomLong();
float floatValue = TestUtils.randomFloat();
double doubleValue = TestUtils.randomDouble();
char charValue = TestUtils.randomChar();
Boolean boxedBooleanValue = TestUtils.randomBoolean();
Byte boxedByteValue = TestUtils.randomByte();
Short boxedShortValue = TestUtils.randomShort();
Integer boxedIntValue = TestUtils.randomInt();
Long boxedLongValue = TestUtils.randomLong();
Float boxedFloatValue = TestUtils.randomFloat();
Double boxedDoubleValue = TestUtils.randomDouble();
Character boxedCharValue = TestUtils.randomChar();
AggregatedDataObject aggregatedDataObject = new AggregatedDataObject().setValue(TestUtils.randomAlphaString(20));
Buffer buffer = TestUtils.randomBuffer(20);
JsonObject jsonObject = new JsonObject().put("wibble", TestUtils.randomAlphaString(20));
JsonArray jsonArray = new JsonArray().add(TestUtils.randomAlphaString(20));
TimeUnit httpMethod = TimeUnit.values()[TestUtils.randomPositiveInt() % TimeUnit.values().length];
ZonedDateTime methodMapped = ZonedDateTime.now();
Locale functionMapped = new Locale("en");
Map<String, Object> map = new HashMap<>();
map.put(TestUtils.randomAlphaString(10), TestUtils.randomAlphaString(20));
map.put(TestUtils.randomAlphaString(10), TestUtils.randomBoolean());
map.put(TestUtils.randomAlphaString(10), TestUtils.randomInt());
List<Object> list = new ArrayList<>();
list.add(TestUtils.randomAlphaString(20));
list.add(TestUtils.randomBoolean());
list.add(TestUtils.randomInt());
JsonObject json = new JsonObject();
json.put("stringValue", stringValue);
json.put("booleanValue", booleanValue);
json.put("byteValue", byteValue);
json.put("shortValue", shortValue);
json.put("intValue", intValue);
json.put("longValue", longValue);
json.put("floatValue", floatValue);
json.put("doubleValue", doubleValue);
json.put("charValue", Character.toString(charValue));
json.put("boxedBooleanValue", boxedBooleanValue);
json.put("boxedByteValue", boxedByteValue);
json.put("boxedShortValue", boxedShortValue);
json.put("boxedIntValue", boxedIntValue);
json.put("boxedLongValue", boxedLongValue);
json.put("boxedFloatValue", boxedFloatValue);
json.put("boxedDoubleValue", boxedDoubleValue);
json.put("boxedCharValue", Character.toString(boxedCharValue));
json.put("aggregatedDataObject", aggregatedDataObject.toJson());
json.put("buffer", toBase64(buffer));
json.put("jsonObject", jsonObject);
json.put("jsonArray", jsonArray);
json.put("httpMethod", httpMethod.toString());
json.put("methodMapped", methodMapped.toString());
json.put("functionMapped", functionMapped.toString());
json.put("stringValues", new JsonArray().add(stringValue));
json.put("boxedBooleanValues", new JsonArray().add(boxedBooleanValue));
json.put("boxedByteValues", new JsonArray().add(boxedByteValue));
json.put("boxedShortValues", new JsonArray().add(boxedShortValue));
json.put("boxedIntValues", new JsonArray().add(boxedIntValue));
json.put("boxedLongValues", new JsonArray().add(boxedLongValue));
json.put("boxedFloatValues", new JsonArray().add(boxedFloatValue));
json.put("boxedDoubleValues", new JsonArray().add(boxedDoubleValue));
json.put("boxedCharValues", new JsonArray().add(Character.toString(boxedCharValue)));
json.put("aggregatedDataObjects", new JsonArray().add(aggregatedDataObject.toJson()));
json.put("buffers", new JsonArray().add(toBase64(buffer)));
json.put("jsonObjects", new JsonArray().add(jsonObject));
json.put("jsonArrays", new JsonArray().add(jsonArray));
json.put("httpMethods", new JsonArray().add(httpMethod.toString()));
json.put("methodMappeds", new JsonArray().add(methodMapped.toString()));
json.put("functionMappeds", new JsonArray().add(functionMapped.toString()));
json.put("objects", new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2)));
json.put("stringSet", new JsonArray().add(stringValue));
json.put("boxedBooleanSet", new JsonArray().add(boxedBooleanValue));
json.put("boxedByteSet", new JsonArray().add(boxedByteValue));
json.put("boxedShortSet", new JsonArray().add(boxedShortValue));
json.put("boxedIntSet", new JsonArray().add(boxedIntValue));
json.put("boxedLongSet", new JsonArray().add(boxedLongValue));
json.put("boxedFloatSet", new JsonArray().add(boxedFloatValue));
json.put("boxedDoubleSet", new JsonArray().add(boxedDoubleValue));
json.put("boxedCharSet", new JsonArray().add(Character.toString(boxedCharValue)));
json.put("aggregatedDataObjectSet", new JsonArray().add(aggregatedDataObject.toJson()));
json.put("bufferSet", new JsonArray().add(toBase64(buffer)));
json.put("jsonObjectSet", new JsonArray().add(jsonObject));
json.put("jsonArraySet", new JsonArray().add(jsonArray));
json.put("httpMethodSet", new JsonArray().add(httpMethod.toString()));
json.put("methodMappedSet", new JsonArray().add(methodMapped.toString()));
json.put("functionMappedSet", new JsonArray().add(functionMapped.toString()));
json.put("objectSet", new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2)));
json.put("addedStringValues", new JsonArray().add(stringValue));
json.put("addedBooleanValues", new JsonArray().add(boxedBooleanValue));
json.put("addedByteValues", new JsonArray().add(boxedByteValue));
json.put("addedShortValues", new JsonArray().add(boxedShortValue));
json.put("addedIntValues", new JsonArray().add(boxedIntValue));
json.put("addedLongValues", new JsonArray().add(boxedLongValue));
json.put("addedFloatValues", new JsonArray().add(boxedFloatValue));
json.put("addedDoubleValues", new JsonArray().add(boxedDoubleValue));
json.put("addedCharValues", new JsonArray().add(Character.toString(boxedCharValue)));
json.put("addedBoxedBooleanValues", new JsonArray().add(boxedBooleanValue));
json.put("addedBoxedByteValues", new JsonArray().add(boxedByteValue));
json.put("addedBoxedShortValues", new JsonArray().add(boxedShortValue));
json.put("addedBoxedIntValues", new JsonArray().add(boxedIntValue));
json.put("addedBoxedLongValues", new JsonArray().add(boxedLongValue));
json.put("addedBoxedFloatValues", new JsonArray().add(boxedFloatValue));
json.put("addedBoxedDoubleValues", new JsonArray().add(boxedDoubleValue));
json.put("addedBoxedCharValues", new JsonArray().add(Character.toString(boxedCharValue)));
json.put("addedAggregatedDataObjects", new JsonArray().add(aggregatedDataObject.toJson()));
json.put("addedBuffers", new JsonArray().add(toBase64(buffer)));
json.put("addedJsonObjects", new JsonArray().add(jsonObject));
json.put("addedJsonArrays", new JsonArray().add(jsonArray));
json.put("addedHttpMethods", new JsonArray().add(httpMethod.toString()));
json.put("addedMethodMappeds", new JsonArray().add(methodMapped.toString()));
json.put("addedFunctionMappeds", new JsonArray().add(functionMapped.toString()));
json.put("addedObjects", new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2)));
json.put("stringValueMap", new JsonObject().put(key, stringValue));
json.put("boxedBooleanValueMap", new JsonObject().put(key, boxedBooleanValue));
json.put("boxedByteValueMap", new JsonObject().put(key, boxedByteValue));
json.put("boxedShortValueMap", new JsonObject().put(key, boxedShortValue));
json.put("boxedIntValueMap", new JsonObject().put(key, boxedIntValue));
json.put("boxedLongValueMap", new JsonObject().put(key, boxedLongValue));
json.put("boxedFloatValueMap", new JsonObject().put(key, boxedFloatValue));
json.put("boxedDoubleValueMap", new JsonObject().put(key, boxedDoubleValue));
json.put("boxedCharValueMap", new JsonObject().put(key, Character.toString(boxedCharValue)));
json.put("aggregatedDataObjectMap", new JsonObject().put(key, aggregatedDataObject.toJson()));
json.put("bufferMap", new JsonObject().put(key, toBase64(buffer)));
json.put("jsonObjectMap", new JsonObject().put(key, jsonObject));
json.put("jsonArrayMap", new JsonObject().put(key, jsonArray));
json.put("httpMethodMap", new JsonObject().put(key, httpMethod.toString()));
json.put("methodMappedMap", new JsonObject().put(key, methodMapped.toString()));
json.put("functionMappedMap", new JsonObject().put(key, functionMapped.toString()));
json.put("objectMap", toJson(map));
json.put("keyedStringValues", new JsonObject().put(key, stringValue));
json.put("keyedBoxedBooleanValues", new JsonObject().put(key, boxedBooleanValue));
json.put("keyedBoxedByteValues", new JsonObject().put(key, boxedByteValue));
json.put("keyedBoxedShortValues", new JsonObject().put(key, boxedShortValue));
json.put("keyedBoxedIntValues", new JsonObject().put(key, boxedIntValue));
json.put("keyedBoxedLongValues", new JsonObject().put(key, boxedLongValue));
json.put("keyedBoxedFloatValues", new JsonObject().put(key, boxedFloatValue));
json.put("keyedBoxedDoubleValues", new JsonObject().put(key, boxedDoubleValue));
json.put("keyedBoxedCharValues", new JsonObject().put(key, Character.toString(boxedCharValue)));
json.put("keyedDataObjectValues", new JsonObject().put(key, aggregatedDataObject.toJson()));
json.put("keyedBufferValues", new JsonObject().put(key, toBase64(buffer)));
json.put("keyedJsonObjectValues", new JsonObject().put(key, jsonObject));
json.put("keyedJsonArrayValues", new JsonObject().put(key, jsonArray));
json.put("keyedEnumValues", new JsonObject().put(key, httpMethod.name()));
json.put("keyedMethodMappedValues", new JsonObject().put(key, methodMapped.toString()));
json.put("keyedFunctionMappedValues", new JsonObject().put(key, functionMapped.toString()));
json.put("keyedObjectValues", toJson(map));
TestDataObject obj = new TestDataObject();
TestDataObjectConverter.fromJson(json, obj);
Assert.assertEquals(stringValue, obj.getStringValue());
Assert.assertEquals(booleanValue, obj.isBooleanValue());
Assert.assertEquals(byteValue, obj.getByteValue());
Assert.assertEquals(shortValue, obj.getShortValue());
Assert.assertEquals(intValue, obj.getIntValue());
Assert.assertEquals(longValue, obj.getLongValue());
Assert.assertEquals(floatValue, obj.getFloatValue(), 0);
Assert.assertEquals(doubleValue, obj.getDoubleValue(), 0);
Assert.assertEquals(charValue, obj.getCharValue());
Assert.assertEquals(boxedBooleanValue, obj.isBoxedBooleanValue());
Assert.assertEquals(boxedByteValue, obj.getBoxedByteValue());
Assert.assertEquals(boxedShortValue, obj.getBoxedShortValue());
Assert.assertEquals(boxedIntValue, obj.getBoxedIntValue());
Assert.assertEquals(boxedLongValue, obj.getBoxedLongValue());
Assert.assertEquals(boxedFloatValue, obj.getBoxedFloatValue(), 0);
Assert.assertEquals(boxedDoubleValue, obj.getBoxedDoubleValue(), 0);
Assert.assertEquals(boxedCharValue, obj.getBoxedCharValue());
assertEquals(aggregatedDataObject, obj.getAggregatedDataObject());
Assert.assertEquals(buffer, obj.getBuffer());
Assert.assertEquals(jsonObject, obj.getJsonObject());
Assert.assertEquals(jsonArray, obj.getJsonArray());
Assert.assertEquals(httpMethod, obj.getHttpMethod());
Assert.assertEquals(methodMapped, obj.getMethodMapped());
Assert.assertEquals(functionMapped, obj.getFunctionMapped());
Assert.assertEquals(Collections.singletonList(stringValue), obj.getStringValues());
Assert.assertEquals(Collections.singletonList(boxedBooleanValue), obj.getBoxedBooleanValues());
Assert.assertEquals(Collections.singletonList(boxedByteValue), obj.getBoxedByteValues());
Assert.assertEquals(Collections.singletonList(boxedShortValue), obj.getBoxedShortValues());
Assert.assertEquals(Collections.singletonList(boxedIntValue), obj.getBoxedIntValues());
Assert.assertEquals(Collections.singletonList(boxedLongValue), obj.getBoxedLongValues());
Assert.assertEquals(Collections.singletonList(boxedFloatValue), obj.getBoxedFloatValues());
Assert.assertEquals(Collections.singletonList(boxedDoubleValue), obj.getBoxedDoubleValues());
Assert.assertEquals(Collections.singletonList(boxedCharValue), obj.getBoxedCharValues());
Assert.assertEquals(Collections.singletonList(aggregatedDataObject), obj.getAggregatedDataObjects());
Assert.assertEquals(Collections.singletonList(buffer), obj.getBuffers());
Assert.assertEquals(Collections.singletonList(jsonObject), obj.getJsonObjects());
Assert.assertEquals(Collections.singletonList(jsonArray), obj.getJsonArrays());
Assert.assertEquals(Collections.singletonList(httpMethod), obj.getHttpMethods());
Assert.assertEquals(Collections.singletonList(methodMapped), obj.getMethodMappeds());
Assert.assertEquals(Collections.singletonList(functionMapped), obj.getFunctionMappeds());
Assert.assertEquals(list, obj.getObjects());
Assert.assertEquals(Collections.singleton(stringValue), obj.getStringSet());
Assert.assertEquals(Collections.singleton(boxedBooleanValue), obj.getBoxedBooleanSet());
Assert.assertEquals(Collections.singleton(boxedByteValue), obj.getBoxedByteSet());
Assert.assertEquals(Collections.singleton(boxedShortValue), obj.getBoxedShortSet());
Assert.assertEquals(Collections.singleton(boxedIntValue), obj.getBoxedIntSet());
Assert.assertEquals(Collections.singleton(boxedLongValue), obj.getBoxedLongSet());
Assert.assertEquals(Collections.singleton(boxedFloatValue), obj.getBoxedFloatSet());
Assert.assertEquals(Collections.singleton(boxedDoubleValue), obj.getBoxedDoubleSet());
Assert.assertEquals(Collections.singleton(boxedCharValue), obj.getBoxedCharSet());
Assert.assertEquals(Collections.singleton(aggregatedDataObject), obj.getAggregatedDataObjectSet());
Assert.assertEquals(Collections.singleton(buffer), obj.getBufferSet());
Assert.assertEquals(Collections.singleton(jsonObject), obj.getJsonObjectSet());
Assert.assertEquals(Collections.singleton(jsonArray), obj.getJsonArraySet());
Assert.assertEquals(Collections.singleton(httpMethod), obj.getHttpMethodSet());
Assert.assertEquals(Collections.singleton(methodMapped), obj.getMethodMappedSet());
Assert.assertEquals(Collections.singleton(functionMapped), obj.getFunctionMappedSet());
Assert.assertEquals(new LinkedHashSet<>(list), obj.getObjectSet());
Assert.assertEquals(Collections.singletonList(stringValue), obj.getAddedStringValues());
Assert.assertEquals(Collections.singletonList(boxedBooleanValue), obj.getAddedBoxedBooleanValues());
Assert.assertEquals(Collections.singletonList(boxedByteValue), obj.getAddedBoxedByteValues());
Assert.assertEquals(Collections.singletonList(boxedShortValue), obj.getAddedBoxedShortValues());
Assert.assertEquals(Collections.singletonList(boxedIntValue), obj.getAddedBoxedIntValues());
Assert.assertEquals(Collections.singletonList(boxedLongValue), obj.getAddedBoxedLongValues());
Assert.assertEquals(Collections.singletonList(boxedFloatValue), obj.getAddedBoxedFloatValues());
Assert.assertEquals(Collections.singletonList(boxedDoubleValue), obj.getAddedBoxedDoubleValues());
Assert.assertEquals(Collections.singletonList(boxedCharValue), obj.getAddedBoxedCharValues());
Assert.assertEquals(Collections.singletonList(aggregatedDataObject), obj.getAddedAggregatedDataObjects());
Assert.assertEquals(Collections.singletonList(buffer), obj.getAddedBuffers());
Assert.assertEquals(Collections.singletonList(jsonObject), obj.getAddedJsonObjects());
Assert.assertEquals(Collections.singletonList(jsonArray), obj.getAddedJsonArrays());
Assert.assertEquals(Collections.singletonList(httpMethod), obj.getAddedHttpMethods());
Assert.assertEquals(Collections.singletonList(methodMapped), obj.getAddedMethodMappeds());
Assert.assertEquals(Collections.singletonList(functionMapped), obj.getAddedFunctionMappeds());
Assert.assertEquals(list, obj.getAddedObjects());
Assert.assertEquals(Collections.singletonMap(key, stringValue), obj.getStringValueMap());
Assert.assertEquals(Collections.singletonMap(key, boxedBooleanValue), obj.getBoxedBooleanValueMap());
Assert.assertEquals(Collections.singletonMap(key, boxedByteValue), obj.getBoxedByteValueMap());
Assert.assertEquals(Collections.singletonMap(key, boxedShortValue), obj.getBoxedShortValueMap());
Assert.assertEquals(Collections.singletonMap(key, boxedIntValue), obj.getBoxedIntValueMap());
Assert.assertEquals(Collections.singletonMap(key, boxedLongValue), obj.getBoxedLongValueMap());
Assert.assertEquals(Collections.singletonMap(key, boxedFloatValue), obj.getBoxedFloatValueMap());
Assert.assertEquals(Collections.singletonMap(key, boxedDoubleValue), obj.getBoxedDoubleValueMap());
Assert.assertEquals(Collections.singletonMap(key, boxedCharValue), obj.getBoxedCharValueMap());
Assert.assertEquals(Collections.singletonMap(key, aggregatedDataObject), obj.getAggregatedDataObjectMap());
Assert.assertEquals(Collections.singletonMap(key, buffer), obj.getBufferMap());
Assert.assertEquals(Collections.singletonMap(key, jsonObject), obj.getJsonObjectMap());
Assert.assertEquals(Collections.singletonMap(key, jsonArray), obj.getJsonArrayMap());
Assert.assertEquals(Collections.singletonMap(key, httpMethod), obj.getHttpMethodMap());
Assert.assertEquals(Collections.singletonMap(key, methodMapped), obj.getMethodMappedMap());
Assert.assertEquals(Collections.singletonMap(key, functionMapped), obj.getFunctionMappedMap());
Assert.assertEquals(map, obj.getObjectMap());
Assert.assertEquals(Collections.singletonMap(key, stringValue), obj.getKeyedStringValues());
Assert.assertEquals(Collections.singletonMap(key, boxedBooleanValue), obj.getKeyedBoxedBooleanValues());
Assert.assertEquals(Collections.singletonMap(key, boxedByteValue), obj.getKeyedBoxedByteValues());
Assert.assertEquals(Collections.singletonMap(key, boxedShortValue), obj.getKeyedBoxedShortValues());
Assert.assertEquals(Collections.singletonMap(key, boxedIntValue), obj.getKeyedBoxedIntValues());
Assert.assertEquals(Collections.singletonMap(key, boxedLongValue), obj.getKeyedBoxedLongValues());
Assert.assertEquals(Collections.singletonMap(key, boxedFloatValue), obj.getKeyedBoxedFloatValues());
Assert.assertEquals(Collections.singletonMap(key, boxedDoubleValue), obj.getKeyedBoxedDoubleValues());
Assert.assertEquals(Collections.singletonMap(key, boxedCharValue), obj.getKeyedBoxedCharValues());
Assert.assertEquals(Collections.singletonMap(key, aggregatedDataObject), obj.getKeyedDataObjectValues());
Assert.assertEquals(Collections.singletonMap(key, buffer), obj.getKeyedBufferValues());
Assert.assertEquals(Collections.singletonMap(key, jsonObject), obj.getKeyedJsonObjectValues());
Assert.assertEquals(Collections.singletonMap(key, jsonArray), obj.getKeyedJsonArrayValues());
Assert.assertEquals(Collections.singletonMap(key, httpMethod), obj.getKeyedEnumValues());
Assert.assertEquals(Collections.singletonMap(key, methodMapped), obj.getKeyedMethodMappedValues());
Assert.assertEquals(Collections.singletonMap(key, functionMapped), obj.getKeyedFunctionMappedValues());
Assert.assertEquals(map, obj.getObjectMap());
// Sometimes json can use java collections so test it runs fine in this case
// json = new JsonObject();
// json.put("aggregatedDataObject", new JsonObject().put("value", aggregatedDataObject.getValue()).getMap());
// json.put("aggregatedDataObjects", new JsonArray().add(new JsonObject().put("value", aggregatedDataObject.getValue()).getMap()));
// json.put("addedAggregatedDataObjects", new JsonArray().add(new JsonObject().put("value", aggregatedDataObject.getValue()).getMap()));
// obj = new TestDataObject();
// TestDataObjectConverter.fromJson(json, obj);
// assertEquals(aggregatedDataObject, obj.getAggregatedDataObject());
// assertEquals(Collections.singletonList(aggregatedDataObject), obj.getAggregatedDataObjects());
// assertEquals(Collections.singletonList(aggregatedDataObject), obj.getAddedAggregatedDataObjects());
}
@Test
public void testEmptyJsonToDataObject() {
JsonObject json = new JsonObject();
TestDataObject obj = new TestDataObject();
TestDataObjectConverter.fromJson(json, obj);
Assert.assertEquals(null, obj.getStringValue());
Assert.assertEquals(false, obj.isBooleanValue());
Assert.assertEquals(0, obj.getByteValue());
Assert.assertEquals(0, obj.getShortValue());
Assert.assertEquals(0, obj.getIntValue());
Assert.assertEquals(0l, obj.getLongValue());
Assert.assertEquals(0f, obj.getFloatValue(), 0);
Assert.assertEquals(0d, obj.getDoubleValue(), 0);
Assert.assertEquals((char)0, obj.getCharValue());
Assert.assertEquals(null, obj.isBoxedBooleanValue());
Assert.assertEquals(null, obj.getBoxedByteValue());
Assert.assertEquals(null, obj.getBoxedShortValue());
Assert.assertEquals(null, obj.getBoxedIntValue());
Assert.assertEquals(null, obj.getBoxedLongValue());
Assert.assertEquals(null, obj.getBoxedFloatValue());
Assert.assertEquals(null, obj.getBoxedDoubleValue());
Assert.assertEquals(null, obj.getBoxedCharValue());
assertEquals(null, obj.getAggregatedDataObject());
Assert.assertEquals(null, obj.getBuffer());
Assert.assertEquals(null, obj.getJsonObject());
Assert.assertEquals(null, obj.getJsonArray());
Assert.assertEquals(null, obj.getMethodMapped());
Assert.assertEquals(null, obj.getFunctionMapped());
Assert.assertEquals(null, obj.getStringValues());
Assert.assertEquals(null, obj.getBoxedBooleanValues());
Assert.assertEquals(null, obj.getBoxedByteValues());
Assert.assertEquals(null, obj.getBoxedShortValues());
Assert.assertEquals(null, obj.getBoxedIntValues());
Assert.assertEquals(null, obj.getBoxedLongValues());
Assert.assertEquals(null, obj.getBoxedFloatValues());
Assert.assertEquals(null, obj.getBoxedDoubleValues());
Assert.assertEquals(null, obj.getBoxedCharValues());
Assert.assertEquals(null, obj.getAggregatedDataObjects());
Assert.assertEquals(null, obj.getBuffers());
Assert.assertEquals(null, obj.getJsonObjects());
Assert.assertEquals(null, obj.getJsonArrays());
Assert.assertEquals(null, obj.getHttpMethods());
Assert.assertEquals(null, obj.getMethodMappeds());
Assert.assertEquals(null, obj.getFunctionMappeds());
Assert.assertEquals(null, obj.getObjects());
Assert.assertEquals(null, obj.getStringSet());
Assert.assertEquals(null, obj.getBoxedBooleanSet());
Assert.assertEquals(null, obj.getBoxedByteSet());
Assert.assertEquals(null, obj.getBoxedShortSet());
Assert.assertEquals(null, obj.getBoxedIntSet());
Assert.assertEquals(null, obj.getBoxedLongSet());
Assert.assertEquals(null, obj.getBoxedFloatSet());
Assert.assertEquals(null, obj.getBoxedDoubleSet());
Assert.assertEquals(null, obj.getBoxedCharSet());
Assert.assertEquals(null, obj.getAggregatedDataObjectSet());
Assert.assertEquals(null, obj.getBufferSet());
Assert.assertEquals(null, obj.getJsonObjectSet());
Assert.assertEquals(null, obj.getJsonArraySet());
Assert.assertEquals(null, obj.getHttpMethodSet());
Assert.assertEquals(null, obj.getMethodMappedSet());
Assert.assertEquals(null, obj.getFunctionMappedSet());
Assert.assertEquals(null, obj.getObjectSet());
Assert.assertEquals(Collections.emptyList(), obj.getAddedStringValues());
Assert.assertEquals(Collections.emptyList(), obj.getAddedBoxedBooleanValues());
Assert.assertEquals(Collections.emptyList(), obj.getAddedBoxedByteValues());
Assert.assertEquals(Collections.emptyList(), obj.getAddedBoxedShortValues());
Assert.assertEquals(Collections.emptyList(), obj.getAddedBoxedIntValues());
Assert.assertEquals(Collections.emptyList(), obj.getAddedBoxedLongValues());
Assert.assertEquals(Collections.emptyList(), obj.getAddedBoxedFloatValues());
Assert.assertEquals(Collections.emptyList(), obj.getAddedBoxedDoubleValues());
Assert.assertEquals(Collections.emptyList(), obj.getAddedBoxedCharValues());
Assert.assertEquals(Collections.emptyList(), obj.getAddedAggregatedDataObjects());
Assert.assertEquals(Collections.emptyList(), obj.getAddedBuffers());
Assert.assertEquals(Collections.emptyList(), obj.getAddedJsonObjects());
Assert.assertEquals(Collections.emptyList(), obj.getAddedJsonArrays());
Assert.assertEquals(Collections.emptyList(), obj.getAddedHttpMethods());
Assert.assertEquals(Collections.emptyList(), obj.getAddedMethodMappeds());
Assert.assertEquals(Collections.emptyList(), obj.getAddedFunctionMappeds());
Assert.assertEquals(Collections.emptyList(), obj.getAddedObjects());
Assert.assertEquals(null, obj.getStringValueMap());
Assert.assertEquals(null, obj.getBoxedBooleanValueMap());
Assert.assertEquals(null, obj.getBoxedByteValueMap());
Assert.assertEquals(null, obj.getBoxedShortValueMap());
Assert.assertEquals(null, obj.getBoxedIntValueMap());
Assert.assertEquals(null, obj.getBoxedLongValueMap());
Assert.assertEquals(null, obj.getBoxedFloatValueMap());
Assert.assertEquals(null, obj.getBoxedDoubleValueMap());
Assert.assertEquals(null, obj.getBoxedCharValueMap());
Assert.assertEquals(null, obj.getAggregatedDataObjectMap());
Assert.assertEquals(null, obj.getBufferMap());
Assert.assertEquals(null, obj.getJsonObjectMap());
Assert.assertEquals(null, obj.getJsonArrayMap());
Assert.assertEquals(null, obj.getHttpMethodMap());
Assert.assertEquals(null, obj.getMethodMappedMap());
Assert.assertEquals(null, obj.getFunctionMappedMap());
Assert.assertEquals(null, obj.getObjectMap());
}
@Test
public void testDataObjectToJson() throws Exception {
String key = TestUtils.randomAlphaString(10);
String stringValue = TestUtils.randomAlphaString(20);
boolean booleanValue = TestUtils.randomBoolean();
byte byteValue = TestUtils.randomByte();
short shortValue = TestUtils.randomShort();
int intValue = TestUtils.randomInt();
long longValue = TestUtils.randomLong();
float floatValue = TestUtils.randomFloat();
double doubleValue = TestUtils.randomDouble();
char charValue = TestUtils.randomChar();
Boolean boxedBooleanValue = TestUtils.randomBoolean();
Byte boxedByteValue = TestUtils.randomByte();
Short boxedShortValue = TestUtils.randomShort();
Integer boxedIntValue = TestUtils.randomInt();
Long boxedLongValue = TestUtils.randomLong();
Float boxedFloatValue = TestUtils.randomFloat();
Double boxedDoubleValue = TestUtils.randomDouble();
Character boxedCharValue = TestUtils.randomChar();
AggregatedDataObject aggregatedDataObject = new AggregatedDataObject().setValue(TestUtils.randomAlphaString(20));
Buffer buffer = TestUtils.randomBuffer(20);
JsonObject jsonObject = new JsonObject().put("wibble", TestUtils.randomAlphaString(20));
JsonArray jsonArray = new JsonArray().add(TestUtils.randomAlphaString(20));
TimeUnit httpMethod = TimeUnit.values()[TestUtils.randomPositiveInt() % TimeUnit.values().length];
ZonedDateTime dateTime = ZonedDateTime.now();
Locale uri = new Locale("en");
Map<String, Object> map = new HashMap<>();
map.put(TestUtils.randomAlphaString(10), TestUtils.randomAlphaString(20));
map.put(TestUtils.randomAlphaString(10), TestUtils.randomBoolean());
map.put(TestUtils.randomAlphaString(10), TestUtils.randomInt());
List<Object> list = new ArrayList<>();
list.add(TestUtils.randomAlphaString(20));
list.add(TestUtils.randomBoolean());
list.add(TestUtils.randomInt());
TestDataObject obj = new TestDataObject();
obj.setStringValue(stringValue);
obj.setBooleanValue(booleanValue);
obj.setByteValue(byteValue);
obj.setShortValue(shortValue);
obj.setIntValue(intValue);
obj.setLongValue(longValue);
obj.setFloatValue(floatValue);
obj.setDoubleValue(doubleValue);
obj.setCharValue(charValue);
obj.setBoxedBooleanValue(boxedBooleanValue);
obj.setBoxedByteValue(boxedByteValue);
obj.setBoxedShortValue(boxedShortValue);
obj.setBoxedIntValue(boxedIntValue);
obj.setBoxedLongValue(boxedLongValue);
obj.setBoxedFloatValue(boxedFloatValue);
obj.setBoxedDoubleValue(boxedDoubleValue);
obj.setBoxedCharValue(boxedCharValue);
obj.setAggregatedDataObject(aggregatedDataObject);
obj.setBuffer(buffer);
obj.setJsonObject(jsonObject);
obj.setJsonArray(jsonArray);
obj.setHttpMethod(httpMethod);
obj.setMethodMapped(dateTime);
obj.setFunctionMapped(uri);
obj.setStringValues(Collections.singletonList(stringValue));
obj.setBoxedBooleanValues(Collections.singletonList(boxedBooleanValue));
obj.setBoxedByteValues(Collections.singletonList(boxedByteValue));
obj.setBoxedShortValues(Collections.singletonList(boxedShortValue));
obj.setBoxedIntValues(Collections.singletonList(boxedIntValue));
obj.setBoxedLongValues(Collections.singletonList(boxedLongValue));
obj.setBoxedFloatValues(Collections.singletonList(boxedFloatValue));
obj.setBoxedDoubleValues(Collections.singletonList(boxedDoubleValue));
obj.setBoxedCharValues(Collections.singletonList(boxedCharValue));
obj.setAggregatedDataObjects(Collections.singletonList(aggregatedDataObject));
obj.setBuffers(Collections.singletonList(buffer));
obj.setJsonObjects(Collections.singletonList(jsonObject));
obj.setJsonArrays(Collections.singletonList(jsonArray));
obj.setHttpMethods(Collections.singletonList(httpMethod));
obj.setMethodMappeds(Collections.singletonList(dateTime));
obj.setFunctionMappeds(Collections.singletonList(uri));
obj.setObjects(list);
obj.setStringValueMap(Collections.singletonMap(key, stringValue));
obj.setStringSet(Collections.singleton(stringValue));
obj.setBoxedBooleanSet(Collections.singleton(boxedBooleanValue));
obj.setBoxedByteSet(Collections.singleton(boxedByteValue));
obj.setBoxedShortSet(Collections.singleton(boxedShortValue));
obj.setBoxedIntSet(Collections.singleton(boxedIntValue));
obj.setBoxedLongSet(Collections.singleton(boxedLongValue));
obj.setBoxedFloatSet(Collections.singleton(boxedFloatValue));
obj.setBoxedDoubleSet(Collections.singleton(boxedDoubleValue));
obj.setBoxedCharSet(Collections.singleton(boxedCharValue));
obj.setAggregatedDataObjectSet(Collections.singleton(aggregatedDataObject));
obj.setBufferSet(Collections.singleton(buffer));
obj.setJsonObjectSet(Collections.singleton(jsonObject));
obj.setJsonArraySet(Collections.singleton(jsonArray));
obj.setHttpMethodSet(Collections.singleton(httpMethod));
obj.setMethodMappedSet(Collections.singleton(dateTime));
obj.setFunctionMappedSet(Collections.singleton(uri));
obj.setObjectSet(new LinkedHashSet<>(list));
obj.setBoxedBooleanValueMap(Collections.singletonMap(key, boxedBooleanValue));
obj.setBoxedByteValueMap(Collections.singletonMap(key, boxedByteValue));
obj.setBoxedShortValueMap(Collections.singletonMap(key, boxedShortValue));
obj.setBoxedIntValueMap(Collections.singletonMap(key, boxedIntValue));
obj.setBoxedLongValueMap(Collections.singletonMap(key, boxedLongValue));
obj.setBoxedFloatValueMap(Collections.singletonMap(key, boxedFloatValue));
obj.setBoxedDoubleValueMap(Collections.singletonMap(key, boxedDoubleValue));
obj.setBoxedCharValueMap(Collections.singletonMap(key, boxedCharValue));
obj.setAggregatedDataObjectMap(Collections.singletonMap(key, aggregatedDataObject));
obj.setBufferMap(Collections.singletonMap(key, buffer));
obj.setJsonObjectMap(Collections.singletonMap(key, jsonObject));
obj.setJsonArrayMap(Collections.singletonMap(key, jsonArray));
obj.setHttpMethodMap(Collections.singletonMap(key, httpMethod));
obj.setMethodMappedMap(Collections.singletonMap(key, dateTime));
obj.setFunctionMappedMap(Collections.singletonMap(key, uri));
obj.setObjectMap(map);
obj.addKeyedStringValue(key, stringValue);
obj.addKeyedBoxedBooleanValue(key, boxedBooleanValue);
obj.addKeyedBoxedByteValue(key, boxedByteValue);
obj.addKeyedBoxedShortValue(key, boxedShortValue);
obj.addKeyedBoxedIntValue(key, boxedIntValue);
obj.addKeyedBoxedLongValue(key, boxedLongValue);
obj.addKeyedBoxedFloatValue(key, boxedFloatValue);
obj.addKeyedBoxedDoubleValue(key, boxedDoubleValue);
obj.addKeyedBoxedCharValue(key, boxedCharValue);
obj.addKeyedDataObjectValue(key, aggregatedDataObject);
obj.addKeyedBufferValue(key, buffer);
obj.addKeyedJsonObjectValue(key, jsonObject);
obj.addKeyedJsonArrayValue(key, jsonArray);
obj.addKeyedEnumValue(key, httpMethod);
obj.addKeyedMethodMappedValue(key, dateTime);
obj.addKeyedFunctionMappedValue(key, uri);
map.forEach(obj::addKeyedObjectValue);
Map<String, Object> json = new HashMap<>();
TestDataObjectConverter.toJson(obj, json);
assertEquals(stringValue, json.get("stringValue"));
assertEquals(booleanValue, json.get("booleanValue"));
assertEquals(byteValue, (byte)json.get("byteValue"));
assertEquals(shortValue, (short)json.get("shortValue"));
assertEquals(intValue, (int)json.get("intValue"));
assertEquals(longValue, (long)json.get("longValue"));
assertEquals(floatValue, (float)json.get("floatValue"), 0.001);
assertEquals(doubleValue, (double)json.get("doubleValue"), 0.001);
assertEquals(Character.toString(charValue), json.get("charValue"));
assertEquals(boxedBooleanValue, json.get("boxedBooleanValue"));
assertEquals((byte)boxedByteValue, (byte)json.get("boxedByteValue"));
assertEquals((short)boxedShortValue, (short)json.get("boxedShortValue"));
assertEquals(boxedIntValue, json.get("boxedIntValue"));
assertEquals(boxedLongValue, json.get("boxedLongValue"));
assertEquals(boxedFloatValue, (float)json.get("boxedFloatValue"), 0.001);
assertEquals(boxedDoubleValue, (double) json.get("boxedDoubleValue"), 0.001);
assertEquals(Character.toString(boxedCharValue), json.get("boxedCharValue"));
assertEquals(aggregatedDataObject.toJson(), json.get("aggregatedDataObject"));
assertEquals(buffer, Buffer.buffer(Base64.getDecoder().decode((String)json.get("buffer"))));
assertEquals(jsonObject, json.get("jsonObject"));
assertEquals(jsonArray, json.get("jsonArray"));
assertEquals(httpMethod.name(), json.get("httpMethod"));
assertEquals(dateTime.toString(), json.get("methodMapped"));
assertEquals(uri.toString(), json.get("functionMapped"));
assertEquals(new JsonArray().add(stringValue), json.get("stringValues"));
assertEquals(new JsonArray().add(boxedBooleanValue), json.get("boxedBooleanValues"));
assertEquals(new JsonArray().add(boxedByteValue), json.get("boxedByteValues"));
assertEquals(new JsonArray().add(boxedShortValue), json.get("boxedShortValues"));
assertEquals(new JsonArray().add(boxedIntValue), json.get("boxedIntValues"));
assertEquals(new JsonArray().add(boxedLongValue), json.get("boxedLongValues"));
assertEquals(1, ((JsonArray)json.get("boxedFloatValues")).size());
assertEquals(boxedFloatValue, (float)((JsonArray)json.get("boxedFloatValues")).getValue(0), 0.001);
assertEquals(1, ((JsonArray)json.get("boxedDoubleValues")).size());
assertEquals(boxedDoubleValue, (double)((JsonArray)json.get("boxedDoubleValues")).getValue(0), 0.001);
assertEquals(new JsonArray().add(Character.toString(boxedCharValue)), json.get("boxedCharValues"));
assertEquals(new JsonArray().add(aggregatedDataObject.toJson()), json.get("aggregatedDataObjects"));
assertEquals(Base64.getEncoder().encodeToString(buffer.getBytes()), ((JsonArray)json.get("buffers")).getValue(0));
assertEquals(new JsonArray().add(jsonObject), json.get("jsonObjects"));
assertEquals(new JsonArray().add(jsonArray), json.get("jsonArrays"));
assertEquals(new JsonArray().add(httpMethod.name()), json.get("httpMethods"));
assertEquals(new JsonArray().add(dateTime.toString()), json.get("methodMappeds"));
assertEquals(new JsonArray().add(uri.toString()), json.get("functionMappeds"));
assertEquals(new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2)), json.get("objects"));
assertEquals(new JsonArray().add(stringValue), json.get("stringSet"));
assertEquals(new JsonArray().add(boxedBooleanValue), json.get("boxedBooleanSet"));
assertEquals(new JsonArray().add(boxedByteValue), json.get("boxedByteSet"));
assertEquals(new JsonArray().add(boxedShortValue), json.get("boxedShortSet"));
assertEquals(new JsonArray().add(boxedIntValue), json.get("boxedIntSet"));
assertEquals(new JsonArray().add(boxedLongValue), json.get("boxedLongSet"));
assertEquals(1, ((JsonArray)json.get("boxedFloatSet")).size());
assertEquals(boxedFloatValue, (float)((JsonArray)json.get("boxedFloatSet")).getValue(0), 0.001);
assertEquals(1, ((JsonArray)json.get("boxedDoubleSet")).size());
assertEquals(boxedDoubleValue, (double)((JsonArray)json.get("boxedDoubleSet")).getValue(0), 0.001);
assertEquals(new JsonArray().add(Character.toString(boxedCharValue)), json.get("boxedCharSet"));
assertEquals(new JsonArray().add(aggregatedDataObject.toJson()), json.get("aggregatedDataObjectSet"));
assertEquals(Base64.getEncoder().encodeToString(buffer.getBytes()), ((JsonArray)json.get("bufferSet")).getValue(0));
assertEquals(new JsonArray().add(jsonObject), json.get("jsonObjectSet"));
assertEquals(new JsonArray().add(jsonArray), json.get("jsonArraySet"));
assertEquals(new JsonArray().add(httpMethod.name()), json.get("httpMethodSet"));
assertEquals(new JsonArray().add(dateTime.toString()), json.get("methodMappedSet"));
assertEquals(new JsonArray().add(uri.toString()), json.get("functionMappedSet"));
assertEquals(new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2)), json.get("objectSet"));
assertEquals(new JsonObject().put(key, stringValue), json.get("stringValueMap"));
assertEquals(new JsonObject().put(key, boxedBooleanValue), json.get("boxedBooleanValueMap"));
assertEquals(new JsonObject().put(key, boxedByteValue), json.get("boxedByteValueMap"));
assertEquals(new JsonObject().put(key, boxedShortValue), json.get("boxedShortValueMap"));
assertEquals(new JsonObject().put(key, boxedIntValue), json.get("boxedIntValueMap"));
assertEquals(new JsonObject().put(key, boxedLongValue), json.get("boxedLongValueMap"));
assertEquals(1, ((JsonObject)json.get("boxedFloatValueMap")).size());
assertEquals(boxedFloatValue, (float)((JsonObject)json.get("boxedFloatValueMap")).getValue(key), 0.001);
assertEquals(1, ((JsonObject)json.get("boxedDoubleValueMap")).size());
assertEquals(boxedDoubleValue, (double)((JsonObject)json.get("boxedDoubleValueMap")).getValue(key), 0.001);
assertEquals(new JsonObject().put(key, Character.toString(boxedCharValue)), json.get("boxedCharValueMap"));
assertEquals(new JsonObject().put(key, aggregatedDataObject.toJson()), json.get("aggregatedDataObjectMap"));
assertEquals(Base64.getEncoder().encodeToString(buffer.getBytes()), ((JsonObject)json.get("bufferMap")).getValue(key));
assertEquals(new JsonObject().put(key, jsonObject), json.get("jsonObjectMap"));
assertEquals(new JsonObject().put(key, jsonArray), json.get("jsonArrayMap"));
assertEquals(new JsonObject().put(key, httpMethod.name()), json.get("httpMethodMap"));
assertEquals(new JsonObject().put(key, dateTime.toString()), json.get("methodMappedMap"));
assertEquals(new JsonObject().put(key, uri.toString()), json.get("functionMappedMap"));
assertEquals(toJson(map), json.get("objectMap"));
assertEquals(new JsonObject().put(key, stringValue), json.get("keyedStringValues"));
assertEquals(new JsonObject().put(key, boxedBooleanValue), json.get("keyedBoxedBooleanValues"));
assertEquals(new JsonObject().put(key, boxedByteValue), json.get("keyedBoxedByteValues"));
assertEquals(new JsonObject().put(key, boxedShortValue), json.get("keyedBoxedShortValues"));
assertEquals(new JsonObject().put(key, boxedIntValue), json.get("keyedBoxedIntValues"));
assertEquals(new JsonObject().put(key, boxedLongValue), json.get("keyedBoxedLongValues"));
assertEquals(1, ((JsonObject)json.get("keyedBoxedFloatValues")).size());
assertEquals(boxedFloatValue, (float)((JsonObject)json.get("keyedBoxedFloatValues")).getValue(key), 0.001);
assertEquals(1, ((JsonObject)json.get("keyedBoxedDoubleValues")).size());
assertEquals(boxedDoubleValue, (double)((JsonObject)json.get("keyedBoxedDoubleValues")).getValue(key), 0.001);
assertEquals(new JsonObject().put(key, Character.toString(boxedCharValue)), json.get("keyedBoxedCharValues"));
assertEquals(new JsonObject().put(key, aggregatedDataObject.toJson()), json.get("keyedDataObjectValues"));
assertEquals(Base64.getEncoder().encodeToString(buffer.getBytes()), ((JsonObject)json.get("keyedBufferValues")).getValue(key));
assertEquals(new JsonObject().put(key, jsonObject), json.get("keyedJsonObjectValues"));
assertEquals(new JsonObject().put(key, jsonArray), json.get("keyedJsonArrayValues"));
assertEquals(new JsonObject().put(key, httpMethod.name()), json.get("keyedEnumValues"));
assertEquals(new JsonObject().put(key, dateTime.toString()), json.get("keyedMethodMappedValues"));
assertEquals(new JsonObject().put(key, uri.toString()), json.get("keyedFunctionMappedValues"));
assertEquals(toJson(map), json.get("keyedObjectValues"));
}
@Test
public void testEmptyDataObjectToJson() {
TestDataObject obj = new TestDataObject();
Map<String, Object> json = new HashMap<>();
TestDataObjectConverter.toJson(obj, json);
assertEquals(null, json.get("stringValue"));
assertEquals(false, json.get("booleanValue"));
assertEquals(0, (byte)json.get("byteValue"));
assertEquals(0, (short)json.get("shortValue"));
assertEquals(0, (int)json.get("intValue"));
assertEquals(0L, (long) json.get("longValue"));
assertEquals(0f, (float) json.get("floatValue"), 0);
assertEquals(0d, (double) json.get("doubleValue"), 0);
assertEquals(Character.toString((char)0), json.get("charValue"));
assertEquals(null, json.get("boxedBooleanValue"));
assertEquals(null, json.get("boxedByteValue"));
assertEquals(null, json.get("boxedShortValue"));
assertEquals(null, json.get("boxedIntValue"));
assertEquals(null, json.get("boxedLongValue"));
assertEquals(null, json.get("boxedFloatValue"));
assertEquals(null, json.get("boxedDoubleValue"));
assertEquals(null, json.get("boxedCharValue"));
assertEquals(null, json.get("aggregatedDataObject"));
assertEquals(null, json.get("buffer"));
assertEquals(null, json.get("jsonObject"));
assertEquals(null, json.get("jsonArray"));
assertEquals(null, json.get("httpMethod"));
assertEquals(null, json.get("methodMapped"));
assertEquals(null, json.get("functionMapped"));
assertEquals(null, json.get("stringValues"));
assertEquals(null, json.get("boxedBooleanValues"));
assertEquals(null, json.get("boxedByteValues"));
assertEquals(null, json.get("boxedShortValues"));
assertEquals(null, json.get("boxedIntValues"));
assertEquals(null, json.get("boxedLongValues"));
assertEquals(null, json.get("boxedFloatValues"));
assertEquals(null, json.get("boxedDoubleValues"));
assertEquals(null, json.get("boxedCharValues"));
assertEquals(null, json.get("aggregatedDataObjects"));
assertEquals(null, json.get("buffers"));
assertEquals(null, json.get("jsonObjects"));
assertEquals(null, json.get("jsonArrays"));
assertEquals(null, json.get("httpMethods"));
assertEquals(null, json.get("methodMappeds"));
assertEquals(null, json.get("functionMappeds"));
assertEquals(null, json.get("objects"));
assertEquals(null, json.get("stringSet"));
assertEquals(null, json.get("boxedBooleanSet"));
assertEquals(null, json.get("boxedByteSet"));
assertEquals(null, json.get("boxedShortSet"));
assertEquals(null, json.get("boxedIntSet"));
assertEquals(null, json.get("boxedLongSet"));
assertEquals(null, json.get("boxedFloatSet"));
assertEquals(null, json.get("boxedDoubleSet"));
assertEquals(null, json.get("boxedCharSet"));
assertEquals(null, json.get("aggregatedDataObjectSet"));
assertEquals(null, json.get("bufferSet"));
assertEquals(null, json.get("jsonObjectSet"));
assertEquals(null, json.get("jsonArraySet"));
assertEquals(null, json.get("httpMethodSet"));
assertEquals(null, json.get("methodMappedSet"));
assertEquals(null, json.get("functionMappedSet"));
assertEquals(null, json.get("objectSet"));
assertEquals(new JsonArray(), json.get("addedStringValues"));
assertEquals(new JsonArray(), json.get("addedBoxedBooleanValues"));
assertEquals(new JsonArray(), json.get("addedBoxedByteValues"));
assertEquals(new JsonArray(), json.get("addedBoxedShortValues"));
assertEquals(new JsonArray(), json.get("addedBoxedIntValues"));
assertEquals(new JsonArray(), json.get("addedBoxedLongValues"));
assertEquals(new JsonArray(), json.get("addedBoxedFloatValues"));
assertEquals(new JsonArray(), json.get("addedBoxedDoubleValues"));
assertEquals(new JsonArray(), json.get("addedBoxedCharValues"));
assertEquals(new JsonArray(), json.get("addedAggregatedDataObjects"));
assertEquals(new JsonArray(), json.get("addedBuffers"));
assertEquals(new JsonArray(), json.get("addedJsonObjects"));
assertEquals(new JsonArray(), json.get("addedJsonArrays"));
assertEquals(new JsonArray(), json.get("addedHttpMethods"));
assertEquals(new JsonArray(), json.get("addedMethodMappeds"));
assertEquals(new JsonArray(), json.get("addedFunctionMappeds"));
assertEquals(new JsonArray(), json.get("addedObjects"));
assertEquals(null, json.get("stringValueMap"));
assertEquals(null, json.get("boxedBooleanValueMap"));
assertEquals(null, json.get("boxedByteValueMap"));
assertEquals(null, json.get("boxedShortValueMap"));
assertEquals(null, json.get("boxedIntValueMap"));
assertEquals(null, json.get("boxedLongValueMap"));
assertEquals(null, json.get("boxedFloatValueMap"));
assertEquals(null, json.get("boxedDoubleValueMap"));
assertEquals(null, json.get("boxedCharValueMap"));
assertEquals(null, json.get("aggregatedDataObjectMap"));
assertEquals(null, json.get("bufferMap"));
assertEquals(null, json.get("jsonObjectMap"));
assertEquals(null, json.get("jsonArrayMap"));
assertEquals(null, json.get("httpMethodMap"));
assertEquals(null, json.get("methodMappedMap"));
assertEquals(null, json.get("functionMappedMap"));
assertEquals(null, json.get("objectMap"));
}
@Test
public void testInherit() {
ChildInheritingDataObject obj = new ChildInheritingDataObject();
JsonObject expectedJson = new JsonObject();
expectedJson.put("childProperty", "childProperty_value");
expectedJson.put("parentProperty", "parentProperty_value");
ChildInheritingDataObjectConverter.fromJson(expectedJson, obj);
assertEquals("childProperty_value", obj.getChildProperty());
assertEquals("parentProperty_value", obj.getParentProperty());
JsonObject json = new JsonObject();
ChildInheritingDataObjectConverter.toJson(obj, json);
assertEquals(expectedJson, json);
}
@Test
public void testNotInherit() {
ChildNotInheritingDataObject obj = new ChildNotInheritingDataObject();
JsonObject expectedJson = new JsonObject();
expectedJson.put("childProperty", "childProperty_value");
expectedJson.put("parentProperty", "parentProperty_value");
ChildNotInheritingDataObjectConverter.fromJson(expectedJson, obj);
assertEquals("childProperty_value", obj.getChildProperty());
assertEquals(null, obj.getParentProperty());
JsonObject json = new JsonObject();
ChildNotInheritingDataObjectConverter.toJson(obj, json);
expectedJson.remove("parentProperty");
assertEquals(expectedJson, json);
}
private String toBase64(Buffer buffer) {
return Base64.getEncoder().encodeToString(buffer.getBytes());
}
@Test
public void testPreferSetterToAdder() {
SetterAdderDataObject obj = new SetterAdderDataObject();
SetterAdderDataObjectConverter.fromJson(new JsonObject().put("values", new JsonArray().add("first").add("second")), obj);
Assert.assertEquals(Arrays.asList("first", "second"), obj.getValues());
Assert.assertEquals(1, obj.sets);
Assert.assertEquals(0, obj.adds);
}
}
| true
|