text stringlengths 10 2.72M |
|---|
package pos.hurrybunny.appsmatic.com.hurrybunnypos.WebServiceUtils.ModelsPOJO.LoginResponse;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
/**
* Created by Eng Ali on 9/16/2018.
*/
public class ResLogin extends Error{
@SerializedName("branches")
@Expose
private List<Branch> branches = null;
public List<Branch> getBranches() {
return branches;
}
public void setBranches(List<Branch> branches) {
this.branches = branches;
}
}
|
package com.invillia.acme.persistence.entity;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
@Entity
@Table(name = "order_item", schema = "acme")
public class OrderItem implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
//Avoid bidirectional mapping of items and orders
@Column(name = "product_order")
private Long orderId;
@Column(name = "description")
private String description;
@Column(name = "unit_price")
private BigDecimal unitPrice;
@Column(name = "quantity")
private Integer quantity;
@Column(name = "refunded")
private boolean refunded;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getOrderId() {
return orderId;
}
public void setOrderId(Long orderId) {
this.orderId = orderId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public BigDecimal getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(BigDecimal unitPrice) {
this.unitPrice = unitPrice;
}
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
public boolean isRefunded() {
return refunded;
}
public void setRefunded(boolean refunded) {
this.refunded = refunded;
}
}
|
package codesquad.service;
import codesquad.domain.Product;
import codesquad.domain.ProductRepository;
import codesquad.dto.BasketDTO;
import codesquad.dto.BasketProductDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Service
public class ProductService {
@Autowired
private ProductRepository productRepository;
public List<Product> findAll() {
return productRepository.findAll();
}
public Product findById(long id) {
return productRepository.findById(id).orElseThrow(RuntimeException::new);
}
public List<BasketProductDTO> getBasketProduct(List<BasketDTO> basketDtoList) {
List<BasketProductDTO> basketProductDtos = new ArrayList<>();
basketDtoList.forEach(basketDTO -> basketProductDtos.add(BasketProductDTO.createBasketProductDto(productRepository.
findById(basketDTO.getId()).get(),basketDTO.getEa())));
return basketProductDtos;
}
}
|
package com.rebron.loginSession.action;
import java.util.List;
import java.util.Map;
import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.rebron.loginSession.domain.Message;
import com.rebron.loginSession.domain.User;
import com.rebron.loginSession.service.MessageService;
import com.rebron.loginSession.service.serviceImpl.MessageServiceImpl;
public class MessageAtion extends ActionSupport implements ModelDriven<Message>,SessionAware{
private static final long serialVersionUID = 1L;
public Map<String, Object> session;
private Message message = new Message();
public Message getModel() {
return message;
}
public void setSession(Map<String, Object> session) {
this.session=session;
}
public Map<String, Object> getSession() {
return session;
}
/**
* ๅฎ็ฐๅๅธๅ่ฝ
* @return
* @throws Exception
*/
public String addPost() throws Exception{
MessageService MessageService = new MessageServiceImpl();
User user = (User)this.session.get("LoginUser");
boolean flag = MessageService.addPost(user,message);
if(flag == true) {
System.out.println("ๅๅธๆๅ");
return SUCCESS;
}else {
System.out.println("ๅๅธๅคฑ่ดฅ");
return ERROR;
}
}
/**
* ้่ฟ็จๆทidๆฅ่ฏข่ฏฅ็จๆทๆๆ็ๅๅธ
* @return
* @throws Exception
*/
public String showMyPostById() throws Exception{
MessageService MessageService = new MessageServiceImpl();
User user = (User)session.get("LoginUser");
List<Object> messageList = MessageService.showMyPostById(user);
if(message != null) {
System.out.println("ๅๅธไฟกๆฏไธไธบ็ฉบ");
session.put("MessageList",messageList );
System.out.println(messageList.toString());
return SUCCESS;
}else {
System.out.println("ๅๅธไฟกๆฏไธบ็ฉบ");
return ERROR;
}
}
public String replyToPost() throws Exception{
return null;
}
}
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package librecatalog;
import java.util.Properties;
import javax.swing.JOptionPane;
/**
*
* @author van
*/
public class UserInterface
{
/**
* Provides for graphical error reporting.
* @param err error code generated by program section.
* 100 range - configuration class.
* 200 range - GUI errors.
*/
public static void Error(int err) {
int type;
String title;
String message;
switch(err) {
case 101:
message = "The configuration file was not found.";
title = "Configuration Info";
type = JOptionPane.WARNING_MESSAGE;
break;
case 102:
message = "Unexpected file input error.";
title = "Configuration Error";
type = JOptionPane.ERROR_MESSAGE;
break;
case 201:
message = "Error: Invalid Permission Level.";
title = "Access Denied";
type = JOptionPane.WARNING_MESSAGE;
break;
default:
message = "Error "+err+": undefined error code generated.";
title = "Warning";
type = JOptionPane.WARNING_MESSAGE;
}
JOptionPane.showMessageDialog(null,message,title,type);
}
/**
* Load up the real interface its time to play with the big guns.
*/
static void load()
{
throw new UnsupportedOperationException("Not yet implemented");
}
/**
* Allows for setup and reconfiguration of admin and librarian level passwords
* in the event of a config file misplacement.
* @return true if authentication succeeded false if it failed.
*/
static boolean productSetupKey()
{
String setupPass = JOptionPane.showInputDialog("Setup mode detected please enter the setup\n"
+ " password you recieved with this software.");
while (!setupPass.equals("Nova-Gamma-7even-d3lt4")) {
setupPass = JOptionPane.showInputDialog(
"Unrecognized Password: Please re-enter\nthe setup password"
+ " you recieved with this software."
);
if ("".equals(setupPass) )
return false;
}
System.out.println("Setup mode activated.");
return true;
}
}
|
package com.adv.pojo;
import java.util.Date;
public class TakesTables {
private Integer id;
private String materials;
private String takesName;
private Integer takesNumber;
private Long price;
private Date takesDate;
private String application;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getMaterials() {
return materials;
}
public void setMaterials(String materials) {
this.materials = materials == null ? null : materials.trim();
}
public String getTakesName() {
return takesName;
}
public void setTakesName(String takesName) {
this.takesName = takesName == null ? null : takesName.trim();
}
public Integer getTakesNumber() {
return takesNumber;
}
public void setTakesNumber(Integer takesNumber) {
this.takesNumber = takesNumber;
}
public Long getPrice() {
return price;
}
public void setPrice(Long price) {
this.price = price;
}
public Date getTakesDate() {
return takesDate;
}
public void setTakesDate(Date takesDate) {
this.takesDate = takesDate;
}
public String getApplication() {
return application;
}
public void setApplication(String application) {
this.application = application == null ? null : application.trim();
}
} |
package pp;
import pp.model.Glad;
import pp.model.IModel;
import pp.model.comparators.GladValueComparator;
import pp.service.GlRuService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author alexander.sokolovsky.a@gmail.com
*/
public class RecruitsActivity extends Activity {
public RecruitsActivity(final GlRuService service) {
super(service);
}
@Override
void doSome() {
try {
List<IModel> recruits = new ArrayList<IModel>();
service.getMerceneries().clear();
service.getSlaves().clear();
service.checkTavern();
service.checkSlaves();
recruits.addAll(service.getMerceneries().values());
recruits.addAll(service.getSlaves().values());
Collections.sort(recruits, new GladValueComparator());
//Utils.print(recruits);
System.out.println("Slots" + service.getFreeSlots());
System.out.println("Best recruit:");
Glad bestRecruit = (Glad) recruits.get(0);
System.out.println(bestRecruit);
System.out.println("----------------------------------------------------------");
service.visitMyGladiators();
Map<Long, Glad> myGlads = service.getMyGlads();
List<IModel> sortedGlads = new ArrayList<IModel>();
sortedGlads.addAll(myGlads.values());
Collections.sort(sortedGlads, new GladValueComparator());
Collections.reverse(sortedGlads);
Glad lastGlad = (Glad) sortedGlads.get(0);
if (service.getFreeSlots() > 0) {
if (bestRecruit.getValue() < 0) {
System.out.println("Buying...");
try {
service.buy(bestRecruit);
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
for (IModel iModel : sortedGlads) {
Glad glad = (Glad) iModel;
System.out.println("Worst glad:" + glad);
if (bestRecruit.getValue() < glad.getValue()) {
try {
System.out.println("Replacing...");
service.sell(glad);
service.buy(bestRecruit);
break;
} catch (Exception e) {
System.out.println("Problems with sell / buy" + e.getMessage());
e.printStackTrace();
}
} else {
break;
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
|
/*
* Merge HRIS API
* The unified API for building rich integrations with multiple HR Information System platforms.
*
* The version of the OpenAPI document: 1.0
* Contact: hello@merge.dev
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package merge_hris_client.model;
import java.util.Objects;
import java.util.Arrays;
import com.google.gson.annotations.SerializedName;
import java.io.IOException;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
/**
* Gets or Sets TypeEnum
*/
@JsonAdapter(TypeEnum.Adapter.class)
public enum TypeEnum {
SALARY("SALARY"),
REIMBURSEMENT("REIMBURSEMENT"),
OVERTIME("OVERTIME"),
BONUS("BONUS");
private String value;
TypeEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static TypeEnum fromValue(String value) {
for (TypeEnum b : TypeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter<TypeEnum> {
@Override
public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public TypeEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return TypeEnum.fromValue(value);
}
}
}
|
package com.fuzzy.metro.components;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Toolkit;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.plaf.basic.BasicScrollBarUI;
import com.fuzzy.metro.Singleton;
import com.jidesoft.plaf.basic.ThemePainter;
import com.jidesoft.swing.JideButton;
public class MyScrollBarUI extends BasicScrollBarUI{
private JideButton increaseButton, decreaseButton;
private MyScrollBar scrollBar;
@Override
protected ArrowButtonListener createArrowButtonListener() {
// TODO Auto-generated method stub
return super.createArrowButtonListener();
}
@Override
protected JButton createDecreaseButton(int orientation) {
// TODO Auto-generated method stub
return decreaseButton;
}
@Override
protected JButton createIncreaseButton(int orientation) {
// TODO Auto-generated method stub
return increaseButton;
}
@Override
protected void paintThumb(final java.awt.Graphics g, final javax.swing.JComponent c, final java.awt.Rectangle thumbBounds) {
if (thumbBounds.isEmpty() || !this.scrollbar.isEnabled()) {
return;
}
g.translate(thumbBounds.x, thumbBounds.y);
g.setColor(Singleton.defaultColor);
g.drawRect(2, 0, 12, thumbRect.height);
g.setColor(Singleton.defaultColor);
g.fillRect(2, 0, 12, thumbRect.height);
g.setColor(Singleton.defaultColor);
g.setColor(Singleton.defaultColor);
g.translate(-thumbBounds.x, -thumbBounds.y);
}
@Override
protected void paintTrack(final java.awt.Graphics g, final javax.swing.JComponent c, final java.awt.Rectangle thumbBounds){
g.setColor(Color.WHITE);
g.drawRect(0, 0, 12, scrollBar.getHeight());
g.fillRect(0, 0, 12, scrollBar.getHeight());
}
public MyScrollBarUI(MyScrollBar scrollBar){
ImageIcon increaseIcon = MyIcon.createImageIcon("./down.png");
ImageIcon decreaseIcon = MyIcon.createImageIcon("./up.png");
increaseButton = createJideButton(increaseIcon);
decreaseButton = createJideButton(decreaseIcon);
this.scrollBar = scrollBar;
}
public JideButton createJideButton(ImageIcon icon){
JideButton button = new JideButton(icon);
button.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.WHITE));
button.setBackgroundOfState(ThemePainter.STATE_PRESSED, Color.WHITE);
button.setBackgroundOfState(ThemePainter.STATE_ROLLOVER, Color.WHITE);
return button;
}
} |
package doc.online.net.servlet;
import doc.online.net.helper.SessionHelper;
import doc.online.net.response.CommonResponse;
import doc.online.net.response.ResponseCode;
import java.io.IOException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
/**
* Handles client logout requests
*/
public class ClientLogoutServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
SessionHelper.removeAllClientInfoFromSession(req.getSession());
resp.setContentType("application/json");
resp.getWriter().println(new CommonResponse(ResponseCode.OK, "logout success").toString());
}
}
|
package com.example.demo.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.example.demo.entity.Todo;
import com.example.demo.entity.Todo2;
import com.example.demo.service.Todo2XmlService;
import com.example.demo.service.TodoXmlService;
@RestController
public class TodoController {
@Autowired
TodoXmlService todoXmlService;
@Autowired
Todo2XmlService todo2XmlService;
//๏ผไปถๅๅพ ๅ
จไปถๅๅพใๆฟๅ
ฅใๆดๆฐใๅ้คใไปถๆฐๅๅพ
//myBatis
//โ
// ๏ผไปถๅๅพ (1)
//curl -X POST http://localhost:8000/todo2/one -H "Content-type: application/json" -d "{\"todoId\":\"1\"}"
@RequestMapping(path = "/todo2/one", method = RequestMethod.POST)
public Todo2 getTodo(@RequestBody @Validated Todo2 todo2, BindingResult result) {
if (result.hasErrors()) {
throw new RuntimeException();
}
return todo2XmlService.findOne(todo2);
}
// ๆฟๅ
ฅ
//curl -X POST http://localhost:8000/create -H "Content-type: application/json" -d "{\"todoId\":\"2\",\"todoTitle\":\"def\",\"finished\":\"true\"}"
@RequestMapping(path = "/create", method = RequestMethod.POST)
public void createTodo(@RequestBody Todo2 todo2) {
todo2XmlService.create(todo2);
}
//curl -X POST http://localhost:8000/todo/all -H "Content-type: application/json"
@RequestMapping(path = "/todo/all", method = RequestMethod.POST)
public List<Todo> getAllTodo() {
// ๅ
จไปถๅๅพ
return todoXmlService.findAll();
}
// ๆดๆฐ
//curl -X POST http://localhost:8000/update -H "Content-type: application/json" -d "{\"todoId\":\"2\",\"todoTitle\":\"ddd\",\"finished\":\"true\"}"
@RequestMapping(path = "/update", method = RequestMethod.POST)
public void updateTodo(@RequestBody Todo2 todo2) {
todo2XmlService.update(todo2);
}
// delete
//curl -X POST http://localhost:8000/delete -H "Content-type: application/json" -d "{\"todoId\":\"4\"}"
@RequestMapping(path = "/delete", method = RequestMethod.POST)
public void deleteTodo(@RequestBody Todo2 todo2) {
todo2XmlService.delete(todo2);
}
//count
//curl -X POST http://localhost:8000/count -H "Content-type: application/json"
@RequestMapping(path = "/count", method = RequestMethod.POST)
public long countTodo() {
return todo2XmlService.count();
}
//
//
//curl -X POST http://localhost:8000/todo/one -H "Content-type: application/json" -d "{\"todo_id\":\"1\"}"
@RequestMapping(path = "/todo/one", method = RequestMethod.POST)
public Todo getTodo(@RequestBody Todo todo) {
// ๏ผไปถๅๅพ (1)
return todoXmlService.findOne(todo);
}
}
|
package moe.tristan.easyfxml.model.system;
import java.net.URI;
import java.net.URL;
import java.util.function.Consumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javafx.application.HostServices;
import moe.tristan.easyfxml.model.exception.ExceptionHandler;
import io.vavr.control.Try;
/**
* This class contains some utility methods to open URLs with the default web browser of the user.
*/
@Component
public class BrowserSupport {
private final HostServices hostServices;
@Autowired
public BrowserSupport(HostServices hostServices) {
this.hostServices = hostServices;
}
/**
* Opens a given URL or a pop-up with the error if it could not do so.
*
* @param url The URL as a String. Does not have to conform to {@link URL#URL(String)}.
*
* @return a {@link Try} that can be either {@link Try.Success} (and empty) or {@link Try.Failure} and contain an
* exception.
*
* @see Try#onFailure(Consumer)
*/
public Try<Void> openUrl(final String url) {
return Try.run(() -> hostServices.showDocument(url))
.onFailure(cause -> onException(cause, url));
}
/**
* Opens a given URL or a pop-up with the error if it could not do so.
*
* @param url The URL as an {@link URL}.
*
* @return a {@link Try} that can be either {@link Try.Success} (and empty) or {@link Try.Failure} and contain an
* exception.
*
* @see Try#onFailure(Consumer)
*/
public Try<Void> openUrl(final URL url) {
return Try.of(() -> url)
.mapTry(URL::toURI)
.map(URI::toString)
.flatMap(this::openUrl);
}
private void onException(final Throwable cause, final String url) {
ExceptionHandler.displayExceptionPane(
"Browser error",
"We could not open the following url in the browser : " + url,
cause
);
}
}
|
/*
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.beans.factory.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation used at the field or method/constructor parameter level
* that indicates a default value expression for the annotated element.
*
* <p>Typically used for expression-driven or property-driven dependency injection.
* Also supported for dynamic resolution of handler method arguments — for
* example, in Spring MVC.
*
* <p>A common use case is to inject values using
* <code>#{systemProperties.myProp}</code> style SpEL (Spring Expression Language)
* expressions. Alternatively, values may be injected using
* <code>${my.app.myProp}</code> style property placeholders.
*
* <p>Note that actual processing of the {@code @Value} annotation is performed
* by a {@link org.springframework.beans.factory.config.BeanPostProcessor
* BeanPostProcessor} which in turn means that you <em>cannot</em> use
* {@code @Value} within
* {@link org.springframework.beans.factory.config.BeanPostProcessor
* BeanPostProcessor} or
* {@link org.springframework.beans.factory.config.BeanFactoryPostProcessor BeanFactoryPostProcessor}
* types. Please consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor}
* class (which, by default, checks for the presence of this annotation).
*
* @author Juergen Hoeller
* @since 3.0
* @see AutowiredAnnotationBeanPostProcessor
* @see Autowired
* @see org.springframework.beans.factory.config.BeanExpressionResolver
* @see org.springframework.beans.factory.support.AutowireCandidateResolver#getSuggestedValue
*/
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Value {
/**
* The actual value expression such as <code>#{systemProperties.myProp}</code>
* or property placeholder such as <code>${my.app.myProp}</code>.
*/
String value();
}
|
package com.cqut.service.impl;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.cqut.dao.RateManageMapperExtra;
import com.cqut.dto.LimitShowDTO;
import com.cqut.dto.RateManageDTO;
import com.cqut.service.IRateManageService.IRateManageService;
@Service
public class RateManageService implements IRateManageService {
@Resource(name = "rateManageMapperExtra")
private RateManageMapperExtra rateManageMapperExtra;
@Override
public boolean updateRateManage(RateManageDTO rateManageDTO) {
return rateManageMapperExtra.updateRateManage(rateManageDTO) > 0;
}
/**
* ๆน้ๅ ้ค
*/
@Override
public boolean batchDelete(String[] primaryKeys) {
return rateManageMapperExtra.deleteByPrimaryKeys(primaryKeys) > 0;
}
/**
* ๆ นๆฎๆกไปถ่ทๅๆฐๆฎ
*/
@Override
public List<Map<String, Object>> getLimitList(RateManageDTO rateManageDTO,LimitShowDTO limitShowDTO) {
return rateManageMapperExtra.getLimitList(rateManageDTO.getRateId(),
rateManageDTO.getRateName(),
limitShowDTO.getCurPage(),
limitShowDTO.getStartIndex(),
limitShowDTO.getLimit()
);
}
/**
* ๆฅๆพ็ฌฆๅๆกไปถ็ๆฐ็ฎ
*/
@Override
public long count(RateManageDTO rateManageDTO,LimitShowDTO limitShowDTO) {
return rateManageMapperExtra.count(
rateManageDTO.getRateId(),
rateManageDTO.getRateName()
);
}
@Override
public boolean addRateManage(RateManageDTO rateManageDTO) {
return rateManageMapperExtra.addRateManage(rateManageDTO) > 0;
}
}
|
package xhu.wncg.firesystem.modules.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import xhu.wncg.firesystem.modules.mapper.TaskMapper;
import xhu.wncg.firesystem.modules.service.TaskService;
import xhu.wncg.firesystem.modules.controller.vo.TaskVO;
import xhu.wncg.firesystem.modules.controller.qo.TaskQO;
/**
* @author zhaobo
* @email 15528330581@163.com
* @version 2017-11-02 15:58:16
*/
@Service("taskService")
public class TaskServiceImpl implements TaskService {
@Autowired
private TaskMapper taskMapper;
@Override
public TaskVO queryObject(Integer taskId){
return taskMapper.queryObject(taskId);
}
@Override
public List<TaskVO> queryList(Map<String, Object> map){
return taskMapper.queryList(map);
}
@Override
public int queryTotal(Map<String, Object> map){
return taskMapper.queryTotal(map);
}
@Override
public void save(TaskQO task){
taskMapper.save(task);
}
@Override
public void update(TaskQO task){
taskMapper.update(task);
}
@Override
public void delete(Integer taskId){
taskMapper.delete(taskId);
}
@Override
public void deleteBatch(Integer[] taskIds){
taskMapper.deleteBatch(taskIds);
}
}
|
package run.entity;
public class UserDTO {
String ID;
String name;
String userName;
String password;
String type;
float account;
public UserDTO() {
}
public String getID() {
return ID;
}
public void setID(String iD) {
ID = iD;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public float getAccount() {
return account;
}
public void setAccount(float account) {
this.account = account;
}
@Override
public String toString() {
return "UserObj [ID=" + ID + ", name=" + name + ", userName=" + userName + ", password=" + password + ", type="
+ type + ", account=" + account + "]";
}
public int hashCode() {
return Integer.parseInt(this.ID);
}
public boolean equals(Object obj) {
if(obj!=null && obj instanceof UserDTO) {
String id=((UserDTO) obj).getID();
if(id==this.getID()) {
return true;
}
}
return false;
}
}
|
package amery.entity;
import amery.jdk.lambda.PersonInterface;
import org.springframework.batch.sample.domain.Person;
import java.util.ArrayList;
import java.util.List;
public class People {
private List<Person> persons= new ArrayList<Person>();
public List<Person> getMaleList(PersonInterface filter) {
List<Person> res = new ArrayList<Person>();
persons.forEach(
(Person person) ->
{
if (filter.test(person)) {//่ฐ็จ PersonInterface ็ๆนๆณ
res.add(person);
}
}
);
return res;
}
}
|
package se.ju.student.android_mjecipes.MjepicesAPIHandler;
import java.net.HttpURLConnection;
public class Errors {
public static final String ACCOUNT_USERNAME_MISSING = "UserNameMissing";
public static final String ACCOUNT_INVALID_USERNAME = "InvalidUserName";
public static final String ACCOUNT_DUPLICATE_USERNAME = "DuplicateUserName";
public static final String ACCOUNT_PASSWORD_MISSING = "PasswordMissing";
public static final String ACCOUNT_PASSWORD_TOO_SHORT = "PasswordTooShort";
public static final String ACCOUNT_PASSWORD_REQUIRES_NON_ALPHANUM = "PasswordRequiresNonAlphanumeric";
public static final String ACCOUNT_PASSWORD_REQUIRES_DIGIT = "PasswordRequiresDigit";
public static final String ACCOUNT_PASSWORD_REQUIRES_LOWER = "PasswordRequiresLower";
public static final String ACCOUNT_PASSWORD_REQUIRES_UPPER = "PasswordRequiresUpper";
public static final String ACCOUNT_LATIDUTE_MISSING = "LongitudeMissing";
public static final String ACCOUNT_LONGITUDE_MISSING = "LatitudeMissing";
public static final String TOKEN_MISSING = "TokenMissing";
public static final String TOKEN_INVALID = "TokenInvalid";
public static final String RECIPE_ID_DOES_NOT_EXIST = "RecipeIdDoesNotExist";
public static final String TOKEN_INVALID_REQUEST = "invalid_request";
public static final String TOKEN_UNSUPPORTED_GRANT_TYPE = "unsupported_grant_type";
public static final String TOKEN_INVALID_CLIENT = "invalid_client";
public static final String RECIPE_NAME_MISSING = "NameMissing";
public static final String RECIPE_NAME_WRONG_LENGTH = "NameWrongLength";
public static final String RECIPE_DESCRIPTION_MISSING = "DescriptionMissing";
public static final String RECIPE_DESCRIPTION_WRONG_LENGTH = "DescriptionWrongLength";
public static final String RECIPE_DIRECTIONS_MISSING = "DirectionsMissing";
public static final String RECIPE_DIRECTIONS_TOO_FEW = "DirectionsTooFew";
public static final String RECIPE_DIRECTION_ORDER_MISSING = "DirectionOrderMissing";
public static final String RECIPE_DIRECTION_DESCRIPTION_MISSING = "DirectionDescriptionMissing";
public static final String RECIPE_DIRECTION_DESCRIPTION_WRONG_LENGTH = "DirectionDescriptionWrongLength";
public static final String COMMENT_TEXT_MISSING = "TextMissing";
public static final String COMMENT_TEXT_WRONG_LENGTH = "TextWrongLength";
public static final String COMMENT_GRADE_MISSING = "GradeMissing";
public static final String COMMENT_GRADE_INVALID = "GradeInvalid";
public static final String COMMENT_GRADE_WRONG_VALUE = "GradeWrongValue";
public static final String COMMENT_COMMENTER_ID_MISSING = "CommenterIdMissing";
public static final String COMMENT_COMMENTER_ALREDY_COMMENT = "CommenterAlreadyComment";
public static final String SEARCH_TERM_MISSING = "TermMissing";
public static final int HTTP_OK = HttpURLConnection.HTTP_OK;
public static final int HTTP_NO_CONTENT = HttpURLConnection.HTTP_NO_CONTENT;
public static final int HTTP_CREATED = HttpURLConnection.HTTP_CREATED;
public static final int HTTP_UNAUTHORIZED = HttpURLConnection.HTTP_UNAUTHORIZED;
public static final int HTTP_NOT_FOUND = HttpURLConnection.HTTP_NOT_FOUND;
public static final int HTTP_BAD_REQUEST = HttpURLConnection.HTTP_BAD_REQUEST;
public static final int HTTP_INTERNAL_SERVER_ERROR = HttpURLConnection.HTTP_INTERNAL_ERROR;
public String[] errors;
public String error;
public int HTTPCode;
public boolean hasError(String error) {
if(errors == null)
return this.error.equals(error);
for(String e: errors)
if(e.equals(error))
return true;
return false;
}
}
|
package com.amundi.tech.onsite.db;
import com.amundi.tech.onsite.db.model.Setting;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SettingRepository extends JpaRepository<Setting, String> {
}
|
import java.awt.event.*;
import java.util.ArrayList;
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {//RS
private Level level1; //Am
private Level level2; //Rith
private Level level3;//Rith
private Level level4;
private Level level5;
private Level level6;//Rith
private ArrayList<Level> levels;
private JPanel cardPanel;
public Main(String title){ //RS
super(title);
setBounds(100, 100, 640, 480);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
cardPanel = new JPanel();//RS
CardLayout cl = new CardLayout();
cardPanel.setLayout(cl);
levels = new ArrayList<Level>();
createLevel1();
createLevel2();
createLevel3();
createLevel4();
createLevel5();
createLevel6();
levels.add(level1);
levels.add(level2);
levels.add(level3);
levels.add(level4);
levels.add(level5);
levels.add(level6);
StartPanel panel1 = new StartPanel(this);
OptionPanel gamePanel = new OptionPanel(this, levels);
// this.add(gamePanel);
cardPanel.add(panel1,"1"); // Card is named "1"
//cardPanel.add(panel2,"2");
cardPanel.add(gamePanel,"2");
add(cardPanel);
addKeyListener(gamePanel);//RS
setVisible(true);
}
private void createLevel1(){
level1 = new Level (2000, 1200);
MovingImage img;
MovingImage imgHell;
Enemy imgE;
Portal imgP;
Powerup imgPow;
imgHell = new MovingImage("hell1.jpg",0,0,2000,1200, true, 3); // cloud //RS
level1.addDecoration(imgHell);
img = new MovingImage("PLATFORMCloud.png",0,550,500,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level1.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1530,1000,500,50, true, 0); // Rith (1600 to 1530)
level1.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",930,1100,500,50, true, 0); // Rith (1100 to 930)
level1.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",0,1200,500,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level1.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",150,700,500,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level1.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",300,1000,500,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level1.addPlatform(img);
//POWERUP
imgPow = new Powerup(1600,800, 1); //health
level1.addPowerup(imgPow);
//PORTAL
imgP = new Portal(1900,900); //RS
level1.addPortal(imgP);
//ENEMIES
imgE = new Enemy(925,1000 ,1200,1000, .01);
level1.addEnemy(imgE);
imgE = new Enemy(1000,1100 ,1000,700, .03);
level1.addEnemy(imgE);
//ARROWKEYS
img = new MovingImage("rightArrow.png",250, 300, 300, 150, true, 3); // cloud
level1.addDecoration(img);
img = new MovingImage("upArrow.png",650 + 100, 800, 300, 150, true, 3); // cloud
level1.addDecoration(img);
img = new MovingImage("rightArrow.png",650, 800, 300, 150, true, 3); // cloud
level1.addDecoration(img);
}
private void createLevel2(){ //RITH
level2 = new Level (2000, 1200);//Rith
MovingImage img;
Enemy imgE;
Portal imgP;
Powerup imgPow;
MovingImage imgHell;
imgHell = new MovingImage("hell2.jpg",0,0,2000,1200, true, 3); // cloud //RS
level2.addDecoration(imgHell);
//POWERUP
imgPow = new Powerup(1250,600,1); //health
level2.addPowerup(imgPow);
//PLATFORM
img = new MovingImage("PLATFORMCloud.png",0,320,500,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level2.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",570,260,500,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level2.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1070,1100,200,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level2.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1170,1000,100,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level2.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1270,900,100,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level2.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1370,800,100,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level2.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1570,900,100,50, true, 0); //
level2.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1670,1000,320,50, true, 0); //health
level2.addPlatform(img);
imgP = new Portal(1900,900); //RS
level2.addPortal(imgP);//RS
//ENEMIES
imgE = new Enemy(1000,300 ,1000,0, .02);
level2.addEnemy(imgE);
imgE = new Enemy(834,300 ,834,0, .02);
level2.addEnemy(imgE);
imgE = new Enemy(1000,680 ,1800,680, .01);
level2.addEnemy(imgE);
imgE = new Enemy(1100,850,1700,850, .01);
level2.addEnemy(imgE);
}
private void createLevel3(){//RS
level3 = new Level (2000, 1200);
MovingImage img;
Enemy imgE;
Portal imgP;
Powerup imgPow;//RS
MovingImage imgHell;
imgHell = new MovingImage("hell3.jpg",0,0,4000,1200, true, 3); //RS
level3.addDecoration(imgHell);
//Powerup
imgPow = new Powerup(1180,250,1); //health
level3.addPowerup(imgPow);
//PLATFORMS
img = new MovingImage("PLATFORMCloud.png",0,550,500,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level3.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",575,650,30,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level3.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",700,700,300,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level3.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1105,675,50,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level3.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1150,545,500,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level3.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1150,425,100,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level3.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1350,1150,300,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level3.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1800,800,200,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level3.addPlatform(img);
//Enemies
imgE = new Enemy(1000,700 ,1000,500, .02);
level3.addEnemy(imgE);
imgE = new Enemy(1050,375 ,1350,375, .02);
level3.addEnemy(imgE);
imgE = new Enemy(1600,730 ,1800,730, .03);
level3.addEnemy(imgE);
imgE = new Enemy(1675,1000 ,1675,1200, .04);
level3.addEnemy(imgE);
//Portal
imgP = new Portal(1750,1100); //RS
level3.addPortal(imgP);//RS*/
}
private void createLevel4(){
level4 = new Level (2000, 1200);
MovingImage img;
Enemy imgE;
Portal imgP;
Powerup imgPow;//RS
MovingImage imgHell;
imgHell = new MovingImage("hell4.jpg",0,0,2000,1200, true, 3); // cloud //RS
level4.addDecoration(imgHell);
//Powerup
imgPow = new Powerup(1180,250,1); //health
level4.addPowerup(imgPow);
//PLATFORMS
img = new MovingImage("PLATFORMCloud.png",300,900,500,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level4.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",900,800,500,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level4.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1000,700,100,80, true, 0); // cloud
level4.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1100,600,100,80, true, 0); // cloud
level4.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1200,500,70,70, true, 0); //health
level4.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1300,400,500,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level4.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1400,300,500,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level4.addPlatform(img);
img = new MovingImage("PLATFORMCloud.png",1500,200,500,50, true, 0); // textured = like infinity brik, false textured = mario (nonrepeated image)
level4.addPlatform(img);
//ENEMIES
/*
* imgE = new Enemy(800,830 ,300,830, .02);
level4.addEnemy(imgE);
*/
imgE = new Enemy(1220,250 ,1220,500, .02);
level4.addEnemy(imgE);
imgE = new Enemy(1650,250 ,1650,400, .02);
level4.addEnemy(imgE);
imgE = new Enemy(1600,730 ,1900,730, .03);
level4.addEnemy(imgE);
imgE = new Enemy(1900,930 ,1600,930, .03);
level4.addEnemy(imgE);
//PORTAL
imgP = new Portal(1750,1100); //RS
level4.addPortal(imgP);//RS*/
}
private void createLevel5(){
level5 = new Level (2000, 1200);
MovingImage img4;
Friend img;
Enemy imgE;
Portal imgP;
Powerup imgPow;
MovingImage imgHell;
imgHell = new MovingImage("hell5.jpg",0,0,2000,1200, true, 3); // cloud //RS
level5.addDecoration(imgHell);
//PLATFORMS
for(int i = 0; i <= 3; i++){
img4 = new MovingImage("PLATFORMCloud.png",500*(i),1160 ,400,50, true, 0);
level5.addPlatform(img4);
}
img4 = new MovingImage("PLATFORMCloud.png",1900,1100 ,100,50, true, 0);
level5.addPlatform(img4);
//FRIEND
img = new Friend(1900, 1020);
level5.addFriend(img);
//ENEMIES
imgE = new Enemy(200,5000,300,5000, 0.09);
level5.addEnemy(imgE);
imgE = new Enemy(370,1100 ,490,1100, .06);
level5.addEnemy(imgE);
imgE = new Enemy(870,1100 ,990,1100, .06);
level5.addEnemy(imgE);
imgE = new Enemy(1370,1100 ,1490,1100, .06);
level5.addEnemy(imgE);
imgE = new Enemy(1800,1000,2000,1000, .08);
level5.addEnemy(imgE);
}
private void createLevel6(){
level6 = new Level (2000, 1200);
MovingImage img4;
MovingImage img5;
MovingImage img6;
Friend img;
Enemy imgE;
Portal imgP;
Powerup imgPow;
for(int i = 0; i <= 3; i++){
img4 = new MovingImage("nothing.png",500*(i),1160 ,500, 50, true, 0);
level6.addPlatform(img4);
}
img = new Friend(1025, 1073); //RS
level6.addFriend(img);
img5 = new MovingImage("Heaven.jpg",0,0,2000,1200, true, 3); // cloud //RS
level6.addDecoration(img5);
img6 = new MovingImage("YouWon.png",100,100,1800,1000, true, 3); // cloud //RS
level6.addDecoration(img6);
}
public static void main(String[] args)
{
Main w = new Main("Heaven To Hell");
}
public void changePanel(String name) {
((CardLayout)cardPanel.getLayout()).show(cardPanel,name);
requestFocus();
}
} |
package com.itheima.rabbitmq.pubsub;
import com.itheima.util.ConnectionUtil;
import com.rabbitmq.client.*;
import java.io.IOException;
public class ConsumerB {
public static void main(String[] args) throws IOException {
//ๅๅปบ่ฟๆฅ
Connection connection = ConnectionUtil.getConnection();
//ๅๅปบChannel
Channel channel = connection.createChannel();
String queueB = "test_fanout_queueB";
/**
* ๅๆฐ๏ผ
* 1.queue๏ผ้ๅๅ็งฐ
* 2. autoAck: ๆฏๅฆ่ชๅจ็กฎ่ฎค
* 3. callback: ๅ่ฐๅฏน่ฑก
*/
DefaultConsumer consumer = new DefaultConsumer(channel){
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
System.out.println("Exchange:" + envelope.getExchange());
System.out.println("RoutingKey:" + envelope.getRoutingKey());
System.out.println("properties:" + properties);
System.out.println("body:" + new String(body));
System.out.println("ๆๅฐๆฅๅฟไฟกๆฏ่ณๆงๅถๅฐใใใ");
}
};
channel.basicConsume(queueB, true, consumer);
}
}
|
package view;
/**
* author {yhh1056}
* Create by {2020/07/13}
*/
public class ApplicationErrorMessage {
public static void isInvalid() {
System.out.println("์ ํจํ์ง ์์ ์
๋ ฅ์
๋๋ค. ์ฌ๋ฐ๋ฅธ ๊ฐ์ผ๋ก ์
๋ ฅํด์ฃผ์ธ์.");
}
public static void isExisted() {
System.out.println("์ด๋ฏธ ์กด์ฌ ํ๋ ๋ฉ๋ด์
๋๋ค.");
}
public static void isEmptyMenu() {
System.out.println("ํ์ฌ ๋ฉ๋ด๊ฐ ์์ต๋๋ค. ์ฒ์์ผ๋ก ๋์๊ฐ๋๋ค.");
}
public static void isNotFoundName() {
System.out.println("ํด๋น ๋ฉ๋ด๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.");
}
}
|
/**
*
*/
package com.lenovohit.hcp.odws.manager;
import com.lenovohit.hcp.base.model.HcpUser;
import com.lenovohit.hcp.odws.model.MedicalOrder;
/**
* @author duanyanshan
* @date 2018ๅนด1ๆ10ๆฅ ไธๅ5:34:29
*/
public interface OrderManager {
public MedicalOrder savItem(MedicalOrder model,HcpUser user);
}
|
package scenario_villa;
import java.io.Serializable;
import core.Ambiente;
import core.Stanza;
@SuppressWarnings("serial")
class PiccoloCaveau extends Ambiente implements Stanza, Serializable {
protected PiccoloCaveau() {
this.nomeAmbiente = "Piccolo Caveau";
this.setCoords(1, 0, 2);
}
@Override
public void decodifica(String comando) {
// TODO Auto-generated method stub
}
@Override
public void guarda() {
// TODO Auto-generated method stub
}
@Override
public void vaiNord() {
// TODO Auto-generated method stub
}
@Override
public void vaiEst() {
// TODO Auto-generated method stub
}
@Override
public void vaiSud() {
// TODO Auto-generated method stub
}
@Override
public void vaiOvest() {
// TODO Auto-generated method stub
}
}
|
package se.rtz.bindings.view.tree;
import java.awt.FlowLayout;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import se.rtz.bindings.view.SView;
import javax.swing.JTextField;
@SuppressWarnings("serial")
public class TestToDoItemPanel extends JPanel implements SView<TestToDoItemModel>
{
private TestToDoItemModel model;
private JCheckBox checkBox;
private JTextField descriptionTF;
/**
* Create the panel.
*/
public TestToDoItemPanel()
{
setBorder(new TitledBorder(null, "ToDo", TitledBorder.LEADING, TitledBorder.TOP, null, null));
setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
add(getCheckBox());
add(getDescriptionTF());
setSModel(new TestToDoItemModel());
}
@Override
public void setSModel(TestToDoItemModel model)
{
if (this.model != null)
{
this.model.disconnect();
}
this.model = model;
if (this.model != null)
{
connectToModel();
}
}
private void connectToModel()
{
getSModel().connect(getCheckBox().getModel(), getSModel().getDoneModel());
getSModel().connect(getDescriptionTF(), getSModel().getDescriptionModel());
getSModel().connectEnabled(getCheckBox(), getSModel().getHasValueModel());
getSModel().connectEnabled(getDescriptionTF(), getSModel().getHasValueModel());
}
@Override
public TestToDoItemModel getSModel()
{
return model;
}
private JCheckBox getCheckBox() {
if (checkBox == null) {
checkBox = new JCheckBox("");
}
return checkBox;
}
private JTextField getDescriptionTF() {
if (descriptionTF == null) {
descriptionTF = new JTextField();
descriptionTF.setColumns(10);
}
return descriptionTF;
}
}
|
package com.yuneec.flightmode15;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.os.Messenger;
import android.util.Log;
import com.yuneec.IPCameraManager.CameraParams;
import com.yuneec.IPCameraManager.IPCameraManager;
import com.yuneec.IPCameraManager.IPCameraManager.RecordStatus;
import com.yuneec.IPCameraManager.IPCameraManager.SDCardStatus;
import com.yuneec.IPCameraManager.IPCameraManager.ToneSetting;
import com.yuneec.flight_settings.FlightSettings;
public class CameraDaemon {
public static final int CONNECTION = 101;
private static final boolean DEBUG = true;
public static final int HTTP_DEAD = 104;
private static final int HTTP_DEAD_COUNT = 20;
private static final int RECORD_INTERVAL = 10000;
public static final int SDSTATUS = 100;
private static final int SDSTATUS_INTERVAL = 10000;
public static final int STATUS_CHANGE = 102;
private static final String TAG = "CameraDaemon";
public static final int TONE_SETTING = 103;
public static final int VIDEO_RESOLUTION = 105;
public static final String WIFI_STATE_INA = "invalid";
public static final String WIFI_STATE_NONE = "disconnectted";
public static final String WIFI_STATE_OK = "connectted";
private static final int WORKING_INTERVAL = 10000;
private Handler mHandler;
private int mHttpDeadCounter = 0;
private boolean mHttpDeadSent = false;
private WeakHandler<CameraDaemon> mHttpHandler = new WeakHandler<CameraDaemon>(this) {
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
Message toUI;
switch (msg.arg1) {
case 10:
if (msg.obj instanceof SDCardStatus) {
toUI = Message.obtain(msg);
toUI.what = 100;
CameraDaemon.this.mHandler.sendMessage(toUI);
CameraDaemon.this.mHttpDeadCounter = 0;
return;
}
Log.i(CameraDaemon.TAG, "request sdcard status:" + msg.obj.toString());
checkAndSendHttpDeadMessage();
return;
case 15:
if (msg.obj instanceof ToneSetting) {
toUI = Message.obtain(msg);
toUI.what = 103;
CameraDaemon.this.mHandler.sendMessage(toUI);
CameraDaemon.this.mHttpDeadCounter = 0;
return;
}
Log.i(CameraDaemon.TAG, "request tone setting:" + msg.obj.toString());
checkAndSendHttpDeadMessage();
return;
case 21:
Log.i(CameraDaemon.TAG, "REQUEST_IS_RECORDING:" + msg.obj);
if (msg.obj instanceof RecordStatus) {
toUI = Message.obtain(msg);
toUI.what = 102;
CameraDaemon.this.mHandler.sendMessage(toUI);
CameraDaemon.this.mHttpDeadCounter = 0;
return;
}
Log.i(CameraDaemon.TAG, "recording status:" + msg.obj.toString());
checkAndSendHttpDeadMessage();
return;
case 32:
if (msg.obj instanceof String) {
toUI = Message.obtain(msg);
toUI.what = 105;
CameraDaemon.this.mHandler.sendMessage(toUI);
CameraDaemon.this.mHttpDeadCounter = 0;
return;
}
return;
case IPCameraManager.REQUEST_GET_WORK_STATUS /*37*/:
Log.i(CameraDaemon.TAG, "REQUEST_GET_WORK_STATUS:" + msg.obj);
if ((msg.obj instanceof RecordStatus) || (msg.obj instanceof CameraParams)) {
toUI = Message.obtain(msg);
toUI.what = 102;
CameraDaemon.this.mHandler.sendMessage(toUI);
CameraDaemon.this.mHttpDeadCounter = 0;
return;
}
Log.i(CameraDaemon.TAG, "recording status:" + msg.obj.toString());
checkAndSendHttpDeadMessage();
return;
default:
Log.i(CameraDaemon.TAG, "response :" + msg.arg1);
return;
}
default:
return;
}
}
private void checkAndSendHttpDeadMessage() {
}
};
private Messenger mHttpMessenger = new Messenger(this.mHttpHandler);
private IPCameraManager mIPCameraManager;
private Runnable mRecordingDaemon = new Runnable() {
public void run() {
if (CameraDaemon.this.mIPCameraManager != null) {
CameraDaemon.this.mIPCameraManager.isRecording(CameraDaemon.this.mHttpMessenger);
CameraDaemon.this.mHandler.postDelayed(CameraDaemon.this.mRecordingDaemon, 10000);
}
}
};
private Runnable mSDStausDaemon = new Runnable() {
public void run() {
if (CameraDaemon.this.mIPCameraManager != null) {
CameraDaemon.this.mIPCameraManager.getSDCardStatus(CameraDaemon.this.mHttpMessenger);
CameraDaemon.this.mHandler.postDelayed(CameraDaemon.this.mSDStausDaemon, 10000);
}
}
};
private Runnable mWokingDaemon = new Runnable() {
public void run() {
if (CameraDaemon.this.mIPCameraManager != null) {
CameraDaemon.this.mIPCameraManager.getWorkStatus(CameraDaemon.this.mHttpMessenger);
CameraDaemon.this.mHandler.postDelayed(CameraDaemon.this.mWokingDaemon, 10000);
}
}
};
public CameraDaemon(Handler mHandler) {
this.mHandler = mHandler;
}
public void start(Context context) {
int camera_type = context.getSharedPreferences(FlightSettings.FLIGHT_SETTINGS_FILE, 0).getInt(FlightSettings.CAMERA_TYPE_VALUE, context.getResources().getInteger(R.integer.def_camera_type_value));
if ((camera_type & 1) == 1) {
this.mIPCameraManager = IPCameraManager.getIPCameraManager(context, 101);
} else if ((camera_type & 4) == 4) {
this.mIPCameraManager = IPCameraManager.getIPCameraManager(context, 102);
this.mSDStausDaemon.run();
this.mRecordingDaemon.run();
Log.d(TAG, "mSDStausDaemon--start");
} else if ((camera_type & 8) == 8 || (camera_type & 32) == 32) {
this.mIPCameraManager = IPCameraManager.getIPCameraManager(context, 104);
this.mWokingDaemon.run();
Log.d(TAG, "getworkingdaemon--start");
} else {
this.mIPCameraManager = IPCameraManager.getIPCameraManager(context, 100);
}
this.mHttpDeadCounter = 0;
this.mHttpDeadSent = false;
}
public void stop(Context context) {
this.mHandler.removeCallbacks(this.mSDStausDaemon);
this.mHandler.removeCallbacks(this.mRecordingDaemon);
this.mHandler.removeCallbacks(this.mWokingDaemon);
this.mIPCameraManager.finish();
this.mIPCameraManager = null;
}
public void updateSDStatusImediately() {
if (this.mIPCameraManager != null) {
this.mSDStausDaemon.run();
} else {
Log.i(TAG, "the daemon has not been started yet");
}
}
}
|
package com.syntax.class04;
public class Task2 {
public static void main(String[] args) {
/*
* 1. Write a program to store a boolean value of whether user has diploma or
* not. If user has a diploma, you should say congratulations, otherwise program
* should suggest to get a degree.
*
* Then if user has a degree program should check a gpa score. If gpa score is
* higher or equals to 3.5 โ output should say โYou are eligible for
* scholarshipโ, otherwise โ โYou should have studied harderโ .
*
* -----------------------------------------------------------------------------
* ---
*
* 2. Create a Java program and store values of mortgage rate and mortgage
* price. First, program should check if rate is higher than 4.5 user will not
* buy a house, otherwise user will consider buying.
*
* Once user decides to buy a house, if price of the house is larger than 200000
* than user will take a loan, otherwise user will pay cash.
*
*
*/
// boolean gpa = true;
boolean diploma = true;
double gpa = 3.8;
if (diploma) {
System.out.println("Congratulation, for your achivments!");
if (gpa >= 2.5) {
System.out.println("You are eligable for scholarship");
} else {
System.out.println("You should have studied harder");
}
} else {
System.out.println("You may consider getting degree");
}
System.out.println("------------------Task2-------------------------");
double rate = 3;
int price = 150000;
if (rate > 4.5) {
System.out.println("User will not buy a house.");
} else {
System.out.println("I may buy a house.");
if (price > 20000) {
System.out.println("User will take a loan");
} else {
System.out.println("I will pay cash");
}
}
}
}// already printed
|
public class Fgrep extends Sgrep implements Runnable
{
public Fgrep(String searchString, String searchFilename)
{
super(searchString, searchFilename);
}
public void run()
{
System.out.println(super.getFilename());
System.out.println(super.search());
}
public static void main(String[] args)
{
if (args.length < 2)
{
System.out.println("Usage: java Fgrep <string> <filename1> ... <filenameN>");
return;
}
for (int i = 1; i < args.length; i++)
{
Fgrep task = new Fgrep(args[0], args[i]);
Thread thd = new Thread(task);
thd.start();
try
{
thd.join();
}
catch (InterruptedException e)
{
System.out.println("Internal error has occurred.");
}
}
}
}
|
import java.util.Arrays;
public class State {
public int[] arr = new int[9];
public int blankIndex;
private int g, h;
private State previous;
public State(int[] input) {
this.arr = input;
this.blankIndex = getIndex(input, 0);
this.previous = null;
this.g = 0;
this.h = Puzzle.getHeuristic(this.arr);
}
public State(State previous, int blankIndex) {
this.arr = Arrays.copyOf(previous.arr, previous.arr.length);
this.arr[previous.blankIndex] = this.arr[blankIndex];
this.arr[blankIndex] = 0;
this.blankIndex = blankIndex;
this.g = previous.g + 1;
this.h = Puzzle.getHeuristic(this.arr);
this.previous = previous;
}
public static int getIndex(int[] arr, int value) {
for (int i=0; i< arr.length; i++) {
if (arr[i]==value) {
return i;
}
}
return -1;
}
public boolean isSolved() {
int[] arr1 = this.arr;
// for (int i=1; i<arr.length; i++) {
// if (arr1[i-1]>arr1[i]) {
// return false;
// }
// }
// return true;
for (int i = 0; i < arr.length; i++) {
if (arr[i]!=i) {
return false;
}
}
return true;
}
public String toString() {
int[] state = this.arr;
String s = "\n\n";
for(int i = 0; i < state.length; i++) {
if(i % 3 == 0 && i != 0) s += "\n";
s += (state[i] != 0) ? String.format("%d ", state[i]) : " ";
}
return s;
}
public String allSteps() {
StringBuilder sb = new StringBuilder();
if (this.previous != null) sb.append(previous.allSteps());
sb.append(this.toString());
return sb.toString();
}
public String solutionMessage(long startTime) {
long solveTime = System.currentTimeMillis() - startTime;
StringBuilder sb = new StringBuilder();
sb.append("Here are the steps to the goal state:");
sb.append(this.allSteps());
sb.append("\n\nGiven puzzle is SOLVED!");
sb.append("\nSolution took " + solveTime + "ms and " + this.g + " steps.\n");
return sb.toString();
}
public int g() {
return this.g;
}
public int h() {
return this.h;
}
public int f() {
return g() + h();
}
public State getPrevious() {
return this.previous;
}
}
|
package com.yifenqian;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.widget.ImageView;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
/**
* Created by wei on 05/12/15.
*/
public class MainLoadTask extends AsyncTask<Void, Void, List<Bitmap>> {
private String url;
private List<ImageView> imageViews;
public MainLoadTask (String url, List<ImageView> imageViews) {
this.url = url;
this.imageViews = imageViews;
}
@Override
protected List<Bitmap> doInBackground(Void... params) {
List<Bitmap> images = new ArrayList<>();
try {
URL urlConnection = new URL(url);
HttpURLConnection connection = (HttpURLConnection) urlConnection
.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(input));
String line = "";
String result = "";
while((line = bufferedReader.readLine()) != null)
result += line;
input.close();
connection.disconnect();
JSONObject jsonObject = new JSONObject(result);
JSONArray infoList = jsonObject.getJSONArray("infoList");
for (int i = 0; i < imageViews.size(); i++) {
JSONObject jo = infoList.getJSONObject(i);
images.add(ImageLoadHelper.loadImage(jo.get("coverImage").toString()));
}
} catch (Exception e) {
e.printStackTrace();
}
return images;
}
@Override
protected void onPostExecute(List<Bitmap> bitmaps) {
super.onPostExecute(bitmaps);
try {
for (int i = 0; i < bitmaps.size(); i++) {
imageViews.get(i).setImageBitmap(bitmaps.get(i));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
package com.twitterdataproducer.app;
import twitter4j.*;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.List;
import java.io.File;
public class Main
{
public static void main(String[] args) {
String TWITTER_OUTPUT_FILE = System.getenv("TWITTER_DATA_OUTPUT_PATH");
System.out.println("Writing to: " + TWITTER_OUTPUT_FILE);
Twitter twitter = new TwitterFactory().getInstance();
try {
// UK: 23424975
// London: 44418
// Paris: 615702S
// String path = "/Users/Sam/logs/twitter_data_producer/data_output.txt";
File file = new File(TWITTER_OUTPUT_FILE);
// if (!file.exists()) {
// file.createNewFile();
// }
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bfw = new BufferedWriter(fw);
// Trends trends = twitter.getPlaceTrends(44418);
// System.out.println("Showing location trends for woeid:" + 44418);
// System.out.println("As of : " + trends.getAsOf());
// for (Trend trend : trends.getTrends()) {
// System.out.println(" " + trend.getName());
//}
//System.out.println("done.");
//search
QueryResult result = twitter.search(new Query("corbyn"));
List<Status> tweets = result.getTweets();
for (Status tweet : tweets) {
bfw.write(tweet.toString() + "\n");
System.out.println(tweet.toString() + "\n");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
package com.taotao.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.taotao.common.pojo.AnswerResult;
import com.taotao.common.pojo.EasyUITreeNodePojo;
import com.taotao.common.utils.ConstantUtils;
import com.taotao.mapper.TbContentCategoryMapper;
import com.taotao.pojo.TbContentCategory;
import com.taotao.pojo.TbContentCategoryExample;
import com.taotao.pojo.TbContentCategoryExample.Criteria;
import com.taotao.pojo.TbContentExample;
import com.taotao.service.ContentCatgoryService;
/**
* ๅ
ๅฎนๅ็ฑปservice
* @author fenguriqi
* 2017ๅนด4ๆ23ๆฅ ไธๅ8:42:24
* ContentCatgoryServiceImpl
*/
@Service
public class ContentCatgoryServiceImpl implements ContentCatgoryService {
/**
* ๆณจๅ
ฅmap
*/
@Autowired
private TbContentCategoryMapper tbContentCategoryMapper;
/**
* ๆฅ่ฏข่็น
*/
@Override
public List<EasyUITreeNodePojo> getContentCatList(Long parentId) {
TbContentCategoryExample example=new TbContentCategoryExample();
Criteria criteria=example.createCriteria();
criteria.andParentIdEqualTo(parentId);
List<TbContentCategory> list=tbContentCategoryMapper.selectByExample(example);
List<EasyUITreeNodePojo> resulList=new ArrayList<>();
for(TbContentCategory node:list){
EasyUITreeNodePojo nodeList=new EasyUITreeNodePojo(node.getId(),node.getName(),node.getIsParent()?"closed":"open");
resulList.add(nodeList);
}
return resulList;
}
/**
* ๅขๅ ไธไธช่็น
*/
@Override
public AnswerResult addNode(Long parentId, String name) {
TbContentCategory bean=new TbContentCategory();
bean.setName(name);
bean.setIsParent(false);
bean.setParentId(parentId);
//ๆๅๅบๅท๏ผ่กจ็คบๅ็บง็ฑป็ฎ็ๅฑ็ฐๆฌกๅบ๏ผๅฆๆฐๅผ็ธ็ญๅๆๅ็งฐๆฌกๅบๆๅใๅๅผ่ๅด:ๅคงไบ้ถ็ๆดๆฐ
bean.setSortOrder(ConstantUtils.CONTENT_SORT_ORDER_FIRST);
bean.setStatus(ConstantUtils.CONTENT_STATUS_NORMAL);
bean.setUpdated(new Date());
bean.setCreated(new Date());
/**ๆๅบ*/
tbContentCategoryMapper.insert(bean);
TbContentCategory parentNode = tbContentCategoryMapper.selectByPrimaryKey(parentId);
if (!parentNode.getIsParent()) {
parentNode.setIsParent(true);
//ๆดๆฐ็ถ่็นisParentๅ
tbContentCategoryMapper.updateByPrimaryKey(parentNode);
}
Long id=bean.getId();
return AnswerResult.ok(id);
}
/**
* ๆ นๆฎ่็นidๅ ้คไฟกๆฏ
*/
@Override
public AnswerResult deleteNode(Long id,Long parentId) {
TbContentCategory bean=tbContentCategoryMapper.selectByPrimaryKey(id);
if(bean.getIsParent()){
TbContentCategoryExample example=new TbContentCategoryExample();
Criteria criteria=example.createCriteria();
criteria.andParentIdEqualTo(id);
tbContentCategoryMapper.deleteByExample(example);
}
tbContentCategoryMapper.deleteByPrimaryKey(id);
return AnswerResult.ok();
}
/**
* ้ๅฝๅ
*/
@Override
public AnswerResult updateName(Long id, String name) {
TbContentCategory bean=new TbContentCategory();
bean.setId(id);
bean.setName(name);
tbContentCategoryMapper.updateByPrimaryKeySelective(bean);
return AnswerResult.ok();
}
}
|
package nz.co.fendustries.whatstheweatherlike.interfaces;
/**
* Created by joshuafenemore on 6/12/16.
*/
public interface UpdateViewBroadcastReceiverListener
{
void onViewDataChanged();
} |
package com.leeheejin.pms;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.leeheejin.context.ApplicationContextListener;
import com.leeheejin.pms.domain.Board;
import com.leeheejin.pms.domain.Cat;
import com.leeheejin.pms.domain.Dog;
import com.leeheejin.pms.domain.Member;
import com.leeheejin.pms.domain.Other;
import com.leeheejin.pms.handler.BoardAddHandler;
import com.leeheejin.pms.handler.BoardListHandler;
import com.leeheejin.pms.handler.CatAddHandler;
import com.leeheejin.pms.handler.CatGeneralListHandler;
import com.leeheejin.pms.handler.CatManagerListHandler;
import com.leeheejin.pms.handler.Command;
import com.leeheejin.pms.handler.DogAddHandler;
import com.leeheejin.pms.handler.DogGeneralListHandler;
import com.leeheejin.pms.handler.DogManagerListHandler;
import com.leeheejin.pms.handler.MemberAddHandler;
import com.leeheejin.pms.handler.MemberLogInHandler;
import com.leeheejin.pms.handler.MemberUpdateHandler;
import com.leeheejin.pms.handler.OtherAddHandler;
import com.leeheejin.pms.handler.OtherGeneralListHandler;
import com.leeheejin.pms.handler.OtherManagerListHandler;
import com.leeheejin.pms.listener.AppListener;
import com.leeheejin.pms.listener.FileListener;
import com.leeheejin.util.Prompt;
public class App01 {
List<ApplicationContextListener> listeners = new ArrayList<>();
Map<String, Object> appContext = new HashMap<>();
public static void main(String[] args) {
App01 app = new App01();
app.addApplicationContextListener(new AppListener());
app.addApplicationContextListener(new FileListener());
app.service();
}
public void addApplicationContextListener(ApplicationContextListener listener) {
listeners.add(listener);
}
public void removeApplicationContextListener(ApplicationContextListener listener) {
listeners.remove(listener);
}
public void service() {
notifyOnServiceStarted();
loop:
while (true) {
try {
System.out.println("< ๋๋ฌผ ๋ณดํธ์ ๊ด๋ฆฌ ์์คํ
>");
System.out.println("[ ํ* ]");
System.out.println("(1) ํ์๊ฐ์
/ ๋ก๊ทธ์ธ");
System.out.println("(2) ๋นํ์ ๋๋ฌ๋ณด๊ธฐ");
System.out.println("(3) ์์คํ
์ข
๋ฃ");
int command = Prompt.inputInt(">> ");
switch (command) {
case 1:
logInMenu();
break;
case 2:
generalMenu();
break;
case 3:
System.out.println("- ์ข
๋ฃํฉ๋๋ค. ");
break loop;
default:
System.out.println("- ์๋ชป ์
๋ ฅํ์
จ์ต๋๋ค. ");
System.out.println();
break;
}
} catch (Exception e) {
System.out.println("---------------------");
System.out.println(" ์๋ชป๋ ์
๋ ฅ์
๋๋ค. ");
System.out.printf("๋ช
๋ น์ด ์คํ ์ค ์ค๋ฅ ๋ฐ์: %s - %s\n",
e.getClass().getName(), e.getMessage());
System.out.println("---------------------");
}
}
notifyOnServiceStopped();
}
private void notifyOnServiceStarted() {
for (ApplicationContextListener listener : listeners) {
listener.contextInitialized(appContext);
}
}
private void notifyOnServiceStopped() {
for (ApplicationContextListener listener : listeners) {
listener.contextDestroyed(appContext);
}
}
@SuppressWarnings("unchecked")
public void logInMenu() {
List<Member> memberList = (List<Member>) appContext.get("memberList");
HashMap<String, Command> commandMap = new HashMap<>();
commandMap.put("1", new MemberAddHandler(memberList));
MemberLogInHandler memberLogInHandler = new MemberLogInHandler(memberList);
System.out.println("[ ํ > ํ์๊ฐ์
/๋ก๊ทธ์ธ* ]");
System.out.println("(1) ํ์๊ฐ์
");
System.out.println("(2) ๋ก๊ทธ์ธ");
System.out.println("(3) ๋ค๋ก๊ฐ๊ธฐ");
String command = Prompt.inputString(">> ");
switch (command) {
case "2":
if (memberLogInHandler.logIn() == 1) {
managerMenu();
}
break;
case "3":
// ๋ค๋ก๊ฐ๊ธฐ return
return;
default:
Command commandHandler = commandMap.get(command);
if (commandHandler == null ) {
System.out.println("์คํํ ์ ์๋ ๋ช
๋ น์
๋๋ค.");
} else {
commandHandler.service();
}
break;
}
}
public void generalMenu() {
loop:
while (true) {
System.out.println("[ ํ > ๋ฉ๋ด* ]");
System.out.println("(1) ๊ตฌ์กฐ ๋๋ฌผ ๋ชฉ๋ก");
System.out.println("(2) ๊ฒ์ํ");
System.out.println("(3) ๋ณดํธ์ ํ์");
System.out.println("(4) ๋ค๋ก๊ฐ๊ธฐ");
int command = Prompt.inputInt(">> ");
try {
switch (command) {
case 1:
generalListMenu();
break;
case 2:
generalBoardMenu();
break;
case 3:
// ๋ณดํธ์ ํ์ํ์ด์ง ์์
case 4:
break loop;
default:
System.out.println("์คํํ ์ ์๋ ๋ช
๋ น์
๋๋ค.");
System.out.println();
break;
}
} catch (Exception e) {
System.out.println("---------------------");
System.out.println(" ์๋ชป๋ ์
๋ ฅ์
๋๋ค. ");
System.out.println("---------------------");
}
}
}
@SuppressWarnings("unchecked")
public void managerMenu() {
List<Member> memberList = (List<Member>) appContext.get("memberList");
HashMap<String, Command> commandMap = new HashMap<>();
loop:
while (true) {
commandMap.put("1", new MemberUpdateHandler(memberList));
System.out.println("[ ํ > ๊ด๋ฆฌ์ ๋ฉ๋ด* ]");
System.out.println("(1) ํ์์ ๋ณด์์ ");
System.out.println("(2) ๋ก๊ทธ์์");
System.out.println("(3) ๊ตฌ์กฐ ๋๋ฌผ ๋ชฉ๋ก");
System.out.println("(4) ๊ฒ์ํ");
System.out.println("(5) ๋ณดํธ์ ํ์");
String command = Prompt.inputString(">> ");
try {
switch (command) {
case "2":
System.out.println("- ๋ก๊ทธ์์ ๋์์ต๋๋ค. \n");
break loop;
case "3":
managerListMenu();
break;
case "4":
managerBoardMenu();
break;
case "5":
//๋ณดํธ์ ํ์ ๊ด๋ฆฌ ๋ฉ๋ด ์์
break;
default:
Command commandHandler = commandMap.get(command);
if (commandHandler == null) {
System.out.println("์คํํ ์ ์๋ ๋ช
๋ น์
๋๋ค.");
} else {
commandHandler.service();
if (command.equals("1")) {
if (MemberUpdateHandler.accountRemove == -1) {
break loop;
}
}
}
break;
}
} catch (Exception e) {
System.out.println("---------------------");
System.out.println(" ์๋ชป๋ ์
๋ ฅ์
๋๋ค. ");
System.out.println("---------------------");
}
}
}
@SuppressWarnings("unchecked")
public void generalListMenu() {
List<Cat> catList = (List<Cat>) appContext.get("catList");
List<Dog> dogList = (List<Dog>) appContext.get("dogList");
List<Other> otherList = (List<Other>) appContext.get("otherList");
HashMap<String, Command> commandMap = new HashMap<>();
loop:
while (true) {
commandMap.put("1", new CatGeneralListHandler(catList));
commandMap.put("2", new DogGeneralListHandler(dogList));
commandMap.put("3", new OtherGeneralListHandler(otherList));
System.out.println("[ ํ > ๋ฉ๋ด > ๊ตฌ์กฐ๋๋ฌผ๋ชฉ๋ก* ]");
System.out.println("(1) ๊ณ ์์ด ๋ชฉ๋ก ๋ณด๊ธฐ");
System.out.println("(2) ๊ฐ ๋ชฉ๋ก ๋ณด๊ธฐ");
System.out.println("(3) ๊ธฐํ ๋๋ฌผ ๋ชฉ๋ก ๋ณด๊ธฐ");
System.out.println("(4) ๋ค๋ก๊ฐ๊ธฐ");
String command = Prompt.inputString(">> ");
try {
switch (command) {
case "4":
break loop;
default:
Command commandHandler = commandMap.get(command);
if (commandHandler == null) {
System.out.println("์คํํ ์ ์๋ ๋ช
๋ น์
๋๋ค.");
} else {
commandHandler.service();
}
break;
}
} catch (Exception e) {
System.out.println("---------------------");
System.out.println(" ์๋ชป๋ ์
๋ ฅ์
๋๋ค. ");
System.out.println("---------------------");
}
}
}
@SuppressWarnings("unchecked")
public void managerListMenu() {
List<Cat> catList = (List<Cat>) appContext.get("catList");
List<Dog> dogList = (List<Dog>) appContext.get("dogList");
List<Other> otherList = (List<Other>) appContext.get("otherList");
HashMap<String, Command> commandMap = new HashMap<>();
loop:
while (true) {
commandMap.put("2", new CatManagerListHandler(catList));
commandMap.put("3", new DogManagerListHandler(dogList));
commandMap.put("4", new OtherManagerListHandler(otherList));
System.out.println("[ ํ > ๊ด๋ฆฌ์ ๋ฉ๋ด > ๊ตฌ์กฐ๋๋ฌผ๋ชฉ๋ก* ]");
System.out.println("(1) ์ ๊ท ๋ฑ๋ก");
System.out.println("(2) ๊ณ ์์ด ๋ชฉ๋ก ๋ณด๊ธฐ");
System.out.println("(3) ๊ฐ ๋ชฉ๋ก ๋ณด๊ธฐ");
System.out.println("(4) ๊ธฐํ ๋๋ฌผ ๋ชฉ๋ก ๋ณด๊ธฐ");
System.out.println("(5) ๋ค๋ก๊ฐ๊ธฐ");
String command = Prompt.inputString(">> ");
try {
switch (command) {
case "1":
addAnimalMenu();
break;
case "5":
break loop;
default:
Command commandHandler = commandMap.get(command);
if (commandHandler == null ) {
System.out.println("์คํํ ์ ์๋ ๋ช
๋ น์
๋๋ค.");
} else {
commandHandler.service();
}
break;
}
} catch (Exception e) {
System.out.println("---------------------");
System.out.println(" ์๋ชป๋ ์
๋ ฅ์
๋๋ค. ");
System.out.printf("๋ช
๋ น์ด ์คํ ์ค ์ค๋ฅ ๋ฐ์: %s - %s\n",
e.getClass().getName(), e.getMessage());
System.out.println("---------------------");
}
}
}
@SuppressWarnings("unchecked")
public void addAnimalMenu() {
List<Cat> catList = (List<Cat>) appContext.get("catList");
List<Dog> dogList = (List<Dog>) appContext.get("dogList");
List<Other> otherList = (List<Other>) appContext.get("otherList");
HashMap<String, Command> commandMap = new HashMap<>();
loop:
while (true) {
commandMap.put("1", new CatAddHandler(catList));
commandMap.put("2", new DogAddHandler(dogList));
commandMap.put("3", new OtherAddHandler(otherList));
System.out.println("[ ํ > ๊ด๋ฆฌ์ ๋ฉ๋ด > ๊ตฌ์กฐ๋๋ฌผ๋ชฉ๋ก > ์ ๊ท๋ฑ๋ก* ]");
System.out.println("(1) ์ ๊ท ๊ณ ์์ด ๋ฑ๋ก");
System.out.println("(2) ์ ๊ท ๊ฐ ๋ฑ๋ก");
System.out.println("(3) ์ ๊ท ๊ธฐํ๋๋ฌผ ๋ฑ๋ก");
System.out.println("(4) ๋ค๋ก๊ฐ๊ธฐ");
String command = Prompt.inputString(">> ");
try {
switch (command) {
case "4":
break loop;
default:
Command commandHandler = commandMap.get(command);
if (commandHandler == null) {
System.out.println("์คํํ ์ ์๋ ๋ช
๋ น์
๋๋ค.");
} else {
commandHandler.service();
}
break;
}
} catch (Exception e) {
System.out.println("---------------------");
System.out.println(" ์๋ชป๋ ์
๋ ฅ์
๋๋ค. ");
System.out.println("---------------------");
}
}
}
public void generalBoardMenu() {
loop:
while (true) {
System.out.println("[ ํ > ๋ฉ๋ด > ๊ฒ์ํ* ]");
System.out.println("(1) ์
์์ด์ผ๊ธฐ");
System.out.println("(2) ๊ตฌ์กฐ์ด์ผ๊ธฐ");
System.out.println("(3) ๋ค๋ก๊ฐ๊ธฐ");
int command = Prompt.inputInt(">> ");
try {
switch (command) {
case 1:
board1("๋ฉ๋ด");
break;
case 2:
board2("๋ฉ๋ด");
case 3:
break loop;
default:
System.out.println("์คํํ ์ ์๋ ๋ช
๋ น์
๋๋ค.");
System.out.println();
break;
}
} catch (Exception e) {
System.out.println("---------------------");
System.out.println(" ์๋ชป๋ ์
๋ ฅ์
๋๋ค. ");
System.out.printf("๋ช
๋ น์ด ์คํ ์ค ์ค๋ฅ ๋ฐ์: %s - %s\n",
e.getClass().getName(), e.getMessage());
System.out.println("---------------------");
}
}
}
public void managerBoardMenu() {
loop:
while (true) {
System.out.println("[ ํ > ๊ด๋ฆฌ์ ๋ฉ๋ด > ๊ฒ์ํ* ]");
System.out.println("(1) ์
์์ด์ผ๊ธฐ");
System.out.println("(2) ๊ตฌ์กฐ์ด์ผ๊ธฐ");
System.out.println("(3) ๋ค๋ก๊ฐ๊ธฐ");
int command = Prompt.inputInt(">> ");
try {
switch (command) {
case 1:
board1("๊ด๋ฆฌ์ ๋ฉ๋ด");
break;
case 2:
board2("๊ด๋ฆฌ์ ๋ฉ๋ด");
break;
case 3:
break loop;
default:
System.out.println("์คํํ ์ ์๋ ๋ช
๋ น์
๋๋ค.");
System.out.println();
break;
}
} catch (Exception e) {
System.out.println("---------------------");
System.out.println(" ์๋ชป๋ ์
๋ ฅ์
๋๋ค. ");
System.out.printf("๋ช
๋ น์ด ์คํ ์ค ์ค๋ฅ ๋ฐ์: %s - %s\n",
e.getClass().getName(), e.getMessage());
System.out.println("---------------------");
}
}
}
@SuppressWarnings("unchecked")
public void board1(String menuName) {
List<Board> boardList1 = (List<Board>) appContext.get("boardList1");
HashMap<String, Command> commandMap = new HashMap<>();
loop:
while (true) {
commandMap.put("1", new BoardAddHandler(boardList1));
commandMap.put("2", new BoardListHandler(boardList1));
System.out.printf("[ ํ > %s > ๊ฒ์ํ > ์
์์ด์ผ๊ธฐ* ]\n", menuName);
System.out.println("(1) ๊ฒ์๊ธ ๋ฑ๋ก");
System.out.println("(2) ๊ฒ์๊ธ ๋ชฉ๋ก");
System.out.println("(3) ๋ค๋ก๊ฐ๊ธฐ");
String command = Prompt.inputString(">> ");
try {
switch (command) {
case "3":
break loop;
default:
Command commandHandler = commandMap.get(command);
if (commandHandler == null) {
System.out.println("์คํํ ์ ์๋ ๋ช
๋ น์
๋๋ค.");
} else {
commandHandler.service(menuName, "์
์์ด์ผ๊ธฐ");
}
break;
}
} catch (Exception e) {
System.out.println("---------------------");
System.out.println(" ์๋ชป๋ ์
๋ ฅ์
๋๋ค. ");
System.out.printf("๋ช
๋ น์ด ์คํ ์ค ์ค๋ฅ ๋ฐ์: %s - %s\n",
e.getClass().getName(), e.getMessage());
System.out.println("---------------------");
}
}
}
@SuppressWarnings("unchecked")
public void board2(String menuName) {
List<Board> boardList2 = (List<Board>) appContext.get("boardLsit2");
HashMap<String, Command> commandMap = new HashMap<>();
loop:
while (true) {
commandMap.put("1", new BoardAddHandler(boardList2));
commandMap.put("2", new BoardListHandler(boardList2));
System.out.printf("[ ํ > %s > ๊ฒ์ํ > ๊ตฌ์กฐ์ด์ผ๊ธฐ* ]\n", menuName);
System.out.println("(1) ๊ฒ์๊ธ ๋ฑ๋ก");
System.out.println("(2) ๊ฒ์๊ธ ๋ชฉ๋ก");
System.out.println("(3) ๋ค๋ก๊ฐ๊ธฐ");
String command = Prompt.inputString(">> ");
try {
switch (command) {
case "3":
break loop;
default:
Command commandHandler = commandMap.get(command);
if (commandHandler == null) {
System.out.println("์คํํ ์ ์๋ ๋ช
๋ น์
๋๋ค.");
} else {
commandHandler.service(menuName, "๊ตฌ์กฐ์ด์ผ๊ธฐ");
}
break;
}
} catch (Exception e) {
System.out.println("---------------------");
System.out.println(" ์๋ชป๋ ์
๋ ฅ์
๋๋ค. ");
System.out.printf("๋ช
๋ น์ด ์คํ ์ค ์ค๋ฅ ๋ฐ์: %s - %s\n",
e.getClass().getName(), e.getMessage());
System.out.println("---------------------");
}
}
}
}
|
package servlets;
import java.io.IOException;
import java.sql.Connection;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Random;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import core.UserAccount;
import sqlutils.DBUtils;
import sqlutils.MailServerConnectionUtils;
import sqlutils.MyUtils;
@WebServlet(name = "forgotPassword", urlPatterns = { "/forgotPassword" })
public class ForgotPasswordServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public ForgotPasswordServlet() {
super();
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
RequestDispatcher dispatcher = this.getServletContext()
.getRequestDispatcher("/WEB-INF/views/forgotPasswordView.jsp");
dispatcher.forward(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
boolean hasError = false;
String errorString = null;
String errorType = null;
UserAccount user = null;
String userEmailAddress = request.getParameter("emailAddress");
Random rand = new Random();
int n = rand.nextInt(900000000) + 1;
String token = Integer.toString(n);
Timestamp timestamp = new Timestamp(new Date().getTime());
if (userEmailAddress.isEmpty()) {
hasError = true;
errorType = "Warning";
errorString = "A Valid Email Address is Required";
} else {
Connection conn = MyUtils.getStoredConnection(request);
try {
user = DBUtils.findUser(conn, userEmailAddress);
if (user == null) {
hasError = true;
errorType = "Warning";
errorString = "Invalid Account";
} else {
DBUtils.updateToken(conn, token, timestamp.toString(), userEmailAddress);
MailServerConnectionUtils.getMailServerSessoin(userEmailAddress, token, timestamp.toString());
}
} catch (Exception e) {
e.printStackTrace();
hasError = true;
errorString = e.getMessage();
}
}
if (hasError) {
user = new UserAccount();
user.setUserName(userEmailAddress);
;
// Store information in request attribute, before forward.
request.setAttribute("errorString", errorString);
request.setAttribute("errorType", errorType);
request.setAttribute("user", user);
request.setAttribute("showAlert",
" window.setTimeout(function() {\n" + " $(\".alert\").fadeTo(500, 0).slideUp(500, function(){\n"
+ " $(this).remove(); \n" + " });\n" + " }, 4000);");
RequestDispatcher dispatcher = this.getServletContext()
.getRequestDispatcher("/WEB-INF/views/forgotPasswordView.jsp");
dispatcher.forward(request, response);
} else {
errorType = "Success";
errorString = "Password Reset Email Has Been Sent";
request.setAttribute("errorType", errorType);
request.setAttribute("errorString", errorString);
request.setAttribute("showAlert",
" window.setTimeout(function() {\n" + " $(\".alert\").fadeTo(500, 0).slideUp(500, function(){\n"
+ " $(this).remove(); \n" + " });\n" + " }, 4000);");
RequestDispatcher dispatcher = this.getServletContext()
.getRequestDispatcher("/WEB-INF/views/forgotPasswordView.jsp");
dispatcher.forward(request, response);
}
}
}
|
package com.clinic.dentist.controllers;
import com.clinic.dentist.api.service.IPatientService;
import com.clinic.dentist.models.Dentist;
import com.clinic.dentist.models.Patient;
import com.clinic.dentist.models.Role;
import com.clinic.dentist.repositories.PatientRepository;
import com.clinic.dentist.services.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.Collections;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Controller
public class RegistrationController {
@Autowired
@Qualifier("patientService")
private IPatientService patientService;
@GetMapping("/registration")
public String registration(Model model) {
model.addAttribute("patient", new Patient());
model.addAttribute("success", "");
return "registration";
}
@PostMapping("/registration")
public String addPatient(@ModelAttribute(name = "patient") Patient patient, Model model) {
model.addAttribute("success", "");
if (patient.getFirstName().trim().equals("")) {
model.addAttribute("firstNameError", "ะะผั ะฝะต ะฒะฒะตะดะตะฝะพ");
return "registration";
}
if (patient.getLastName().trim().equals("")) {
model.addAttribute("lastNameError", "ะคะฐะผะธะปะธั ะฝะต ะฒะฒะตะดะตะฝะฐ");
return "registration";
}
if (patient.getUsername().trim().equals("")) {
model.addAttribute("phoneNumberError", "ะะพะผะตั ัะตะปะตัะพะฝะฐ ะฝะต ะฒะฒะตะดะตะฝ");
return "registration";
}
if (patient.getPassword().equals("")) {
model.addAttribute("passwordError", "ะะฐัะพะปั ะฝะต ะฒะฒะตะดะตะฝ");
return "registration";
}
if (patient.getPasswordConfirm().equals("")) {
model.addAttribute("passwordConfirmError", "ะะพะฒัะพัะฝะพ ะฟะฐัะพะปั ะฝะต ะฒะฒะตะดะตะฝ");
return "registration";
}
if (!patient.getPassword().equals(patient.getPasswordConfirm())) {
model.addAttribute("passwordConfirmError", "ะะฐัะพะปะธ ะฝะต ัะพะฒะฟะฐะดะฐัั");
return "registration";
}
Pattern pattern = Pattern.compile("^(375)[0-9]{9}$");
Matcher matcher = pattern.matcher(patient.getUsername());
if (!matcher.matches()) {
model.addAttribute("phoneNumberError", "ะะพะผะตั ัะตะปะตัะพะฝะฐ ะฒะฒะตะดะตะฝ ะฝะต ะบะพััะตะบัะฝะพ");
return "registration";
}
if (patientService.checkPatient(patient.getUsername())) {
model.addAttribute("phoneNumberError", "ะะฐะฝะฝัะน ะฝะพะผะตั ัะถะต ะทะฐัะตะณะธัััะธัะพะฒะฐะฝ");
return "registration";
}
patientService.addPatient(patientService.correctData(patient));
model.addAttribute("success", "ะะฐัะฐ ะทะฐัะฒะบะฐ ะฝะฐ ัะตะณะธัััะฐัะธั ะฑัะดะตั ัะฐััะผะพััะตะฝะฐ");
model.addAttribute("patient", new Patient());
return "registration";
}
}
|
package com.radauer.mathrix.example.at;
import com.radauer.mathrix.GroupType;
/**
* Created by Andreas on 08.01.2018.
*/
public enum PriceGroup {
LIST(GroupType.VALUE),
REBATE_PERCENTAGE(GroupType.PERCENTAGE),
REBATE_AMOUNT(GroupType.VALUE),
VK(GroupType.VALUE),
NOVA_PERCENTAGE(GroupType.PERCENTAGE),
NOVA_AMOUNT(GroupType.VALUE),
VAT_PERCENTAGE(GroupType.PERCENTAGE),
VAT_AMOUNT(GroupType.VALUE),
LIST_NOVA_AMOUNT(GroupType.VALUE),
LIST_TAX_AMOUNT(GroupType.VALUE),
LIST_NET_INKL_NOVA(GroupType.VALUE),
LIST_GROSS(GroupType.VALUE),
VK_NET_INKL_NOVA(GroupType.VALUE),
VK_GROSS(GroupType.VALUE);
PriceGroup(GroupType type) {
this.type = type;
}
GroupType type;
}
|
package cn.kgc.controller;
import cn.kgc.domain.Onclient;
import cn.kgc.service.OnclientService;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
//ๅจ็บฟๅฎขๆท
@Controller
@RequestMapping("/onclient")
@CrossOrigin
public class OnclientController {
@Autowired
OnclientService onclientService;
@RequestMapping("/getonclient")
public void getonclient(HttpServletRequest request, HttpServletResponse response){
//่ฐ็จdaoๅฑ็ๆนๆณๆฅ่ฏขๅฐ้ๅ
response.setCharacterEncoding("utf-8");
List<Onclient> all = onclientService.findAll();
Map<String,List>map=new HashMap<>();
//ๆlist้ๅๆพๅฐmap้ฎๅผๅฏน้
map.put("onclient",all);
String string = JSON.toJSONString(map,true);
PrintWriter writer =null;
try {
writer = response.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
writer.write(string);
writer.flush();
writer.close();
}
}
|
package edu.mit.cci.simulation.client;
import edu.mit.cci.simulation.client.model.impl.ClientScenario;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.Date;
import java.util.List;
@XmlJavaTypeAdapter(ClientScenario.Adapter.class)
public interface Scenario extends HasId {
public Long getId();
public String getAuthor();
public void setAuthor(String u);
public Date getCreation();
public void setCreation(Date d);
public Simulation getSimulation();
public void setSimulation(Simulation s);
public String getDescription();
public void setDescription(String desc);
public List<Variable> getInputSet();
public List<Variable> getOutputSet();
public List<Variable> getCombinedOutputs();
public void addToInput(Variable v);
public void addToOutput(Variable v);
public void setName(String name);
public String getName();
public void setState(EntityState name);
public EntityState getState();
} |
/**
* Sencha GXT 3.0.1 - Sencha for GWT
* Copyright(c) 2007-2012, Sencha, Inc.
* licensing@sencha.com
*
* http://www.sencha.com/products/gxt/license/
*/
package com.sencha.gxt.explorer.client.layout;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.core.client.util.Padding;
import com.sencha.gxt.core.client.util.ToggleGroup;
import com.sencha.gxt.explorer.client.model.Example.Detail;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.button.ToggleButton;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign;
@Detail(name = "VBoxLayout", icon = "vboxlayout", category = "Layouts")
public class VBoxLayoutExample implements IsWidget, EntryPoint {
private String button1Text = "Button 1";
private String button2Text = "Button 2";
private String button3Text = "Button 3";
private String button4Text = "Button Long 4";
private ContentPanel lccenter;
private ToggleGroup toggleGroup = new ToggleGroup();
@Override
public Widget asWidget() {
ScrollPanel con = new ScrollPanel();
con.getElement().getStyle().setMargin(10, Unit.PX);
ContentPanel panel = new ContentPanel();
panel.setHeadingText("VerticalBox Example");
panel.setPixelSize(600, 500);
BorderLayoutContainer border = new BorderLayoutContainer();
panel.setWidget(border);
VBoxLayoutContainer lcwest = new VBoxLayoutContainer();
lcwest.setPadding(new Padding(5));
lcwest.setVBoxLayoutAlign(VBoxLayoutAlign.STRETCH);
BorderLayoutData west = new BorderLayoutData(150);
west.setMargins(new Margins(5));
// west.setSplit(true);
border.setWestWidget(lcwest, west);
lccenter = new ContentPanel();
lccenter.setHeaderVisible(false);
lccenter.add(new HTML(
"<p style=\"padding:10px;color:#556677;font-size:11px;\">Select a configuration on the left</p>"));
MarginData center = new MarginData(new Margins(5));
border.setCenterWidget(lccenter, center);
BoxLayoutData vBoxData = new BoxLayoutData(new Margins(5, 5, 5, 5));
vBoxData.setFlex(1);
lcwest.add(createToggleButton("Spaced", new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
VBoxLayoutContainer c = new VBoxLayoutContainer();
c.setPadding(new Padding(5));
c.setVBoxLayoutAlign(VBoxLayoutAlign.LEFT);
c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
BoxLayoutData flex = new BoxLayoutData(new Margins(0, 0, 5, 0));
flex.setFlex(1);
c.add(new Label(), flex);
c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0)));
addToCenter(c);
}
}
}), vBoxData);
lcwest.add(createToggleButton("Multi-Spaced", new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
VBoxLayoutContainer c = new VBoxLayoutContainer();
c.setPadding(new Padding(5));
c.setVBoxLayoutAlign(VBoxLayoutAlign.LEFT);
c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
BoxLayoutData flex = new BoxLayoutData(new Margins(0, 0, 5, 0));
flex.setFlex(1);
c.add(new Label(), flex);
c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new Label(), flex);
c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new Label(), flex);
c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0)));
addToCenter(c);
}
}
}), vBoxData);
lcwest.add(createToggleButton("Align: left", new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
VBoxLayoutContainer c = new VBoxLayoutContainer();
c.setPadding(new Padding(5));
c.setVBoxLayoutAlign(VBoxLayoutAlign.LEFT);
c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0)));
addToCenter(c);
}
}
}), vBoxData);
lcwest.add(createToggleButton("Align: center", new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
VBoxLayoutContainer c = new VBoxLayoutContainer();
c.setPadding(new Padding(5));
c.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0)));
addToCenter(c);
}
}
}), vBoxData);
lcwest.add(createToggleButton("Align: right", new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
VBoxLayoutContainer c = new VBoxLayoutContainer();
c.setPadding(new Padding(5));
c.setVBoxLayoutAlign(VBoxLayoutAlign.RIGHT);
c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0)));
addToCenter(c);
}
}
}), vBoxData);
lcwest.add(createToggleButton("Align: stretch", new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
VBoxLayoutContainer c = new VBoxLayoutContainer();
c.setPadding(new Padding(5));
c.setVBoxLayoutAlign(VBoxLayoutAlign.STRETCH);
c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0)));
addToCenter(c);
}
}
}), vBoxData);
lcwest.add(createToggleButton("Align: stretchmax", new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
VBoxLayoutContainer c = new VBoxLayoutContainer();
c.setPadding(new Padding(5));
c.setVBoxLayoutAlign(VBoxLayoutAlign.STRETCHMAX);
c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0)));
c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0)));
addToCenter(c);
}
}
}), vBoxData);
lcwest.add(createToggleButton("Flex: All even", new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
VBoxLayoutContainer c = new VBoxLayoutContainer();
c.setPadding(new Padding(5));
c.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
BoxLayoutData flex = new BoxLayoutData(new Margins(0, 0, 5, 0));
flex.setFlex(1);
c.add(new TextButton(button1Text), flex);
c.add(new TextButton(button2Text), flex);
c.add(new TextButton(button3Text), flex);
BoxLayoutData flex2 = new BoxLayoutData(new Margins(0));
flex2.setFlex(1);
c.add(new TextButton(button4Text), flex2);
addToCenter(c);
}
}
}), vBoxData);
lcwest.add(createToggleButton("Flex: ratio", new ValueChangeHandler<Boolean>() {
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
VBoxLayoutContainer c = new VBoxLayoutContainer();
c.setPadding(new Padding(5));
c.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
BoxLayoutData flex = new BoxLayoutData(new Margins(0, 0, 5, 0));
flex.setFlex(1);
c.add(new TextButton(button1Text), flex);
c.add(new TextButton(button2Text), flex);
c.add(new TextButton(button3Text), flex);
BoxLayoutData flex2 = new BoxLayoutData(new Margins(0));
flex2.setFlex(3);
c.add(new TextButton(button4Text), flex2);
addToCenter(c);
}
}
}), vBoxData);
lcwest.add(createToggleButton("Flex + Stretch", new ValueChangeHandler<Boolean>() {
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
VBoxLayoutContainer c = new VBoxLayoutContainer();
c.setPadding(new Padding(5));
c.setVBoxLayoutAlign(VBoxLayoutAlign.STRETCH);
BoxLayoutData flex = new BoxLayoutData(new Margins(0, 0, 5, 0));
flex.setFlex(1);
c.add(new TextButton(button1Text), flex);
c.add(new TextButton(button2Text), flex);
c.add(new TextButton(button3Text), flex);
BoxLayoutData flex2 = new BoxLayoutData(new Margins(0));
flex2.setFlex(3);
c.add(new TextButton(button4Text), flex2);
addToCenter(c);
}
}
}), vBoxData);
lcwest.add(createToggleButton("Pack: start", new ValueChangeHandler<Boolean>() {
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
VBoxLayoutContainer c = new VBoxLayoutContainer();
c.setPadding(new Padding(5));
c.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
c.setPack(BoxLayoutPack.START);
BoxLayoutData layoutData = new BoxLayoutData(new Margins(0, 0, 5, 0));
c.add(new TextButton(button1Text), layoutData);
c.add(new TextButton(button2Text), layoutData);
c.add(new TextButton(button3Text), layoutData);
BoxLayoutData layoutData2 = new BoxLayoutData(new Margins(0));
c.add(new TextButton(button4Text), layoutData2);
addToCenter(c);
}
}
}), vBoxData);
lcwest.add(createToggleButton("Pack: center", new ValueChangeHandler<Boolean>() {
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
VBoxLayoutContainer c = new VBoxLayoutContainer();
c.setPadding(new Padding(5));
c.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
c.setPack(BoxLayoutPack.CENTER);
BoxLayoutData layoutData = new BoxLayoutData(new Margins(0, 0, 5, 0));
c.add(new TextButton(button1Text), layoutData);
c.add(new TextButton(button2Text), layoutData);
c.add(new TextButton(button3Text), layoutData);
BoxLayoutData layoutData2 = new BoxLayoutData(new Margins(0));
c.add(new TextButton(button4Text), layoutData2);
addToCenter(c);
}
}
}), vBoxData);
lcwest.add(createToggleButton("Pack: end", new ValueChangeHandler<Boolean>() {
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
VBoxLayoutContainer c = new VBoxLayoutContainer();
c.setPadding(new Padding(5));
c.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
c.setPack(BoxLayoutPack.END);
BoxLayoutData layoutData = new BoxLayoutData(new Margins(0, 0, 5, 0));
c.add(new TextButton(button1Text), layoutData);
c.add(new TextButton(button2Text), layoutData);
c.add(new TextButton(button3Text), layoutData);
BoxLayoutData layoutData2 = new BoxLayoutData(new Margins(0));
c.add(new TextButton(button4Text), layoutData2);
addToCenter(c);
}
}
}), vBoxData);
con.add(panel);
return con;
}
public void onModuleLoad() {
RootPanel.get().add(asWidget());
}
private void addToCenter(Widget c) {
lccenter.clear();
lccenter.add(c);
lccenter.forceLayout();
}
private ToggleButton createToggleButton(String name, ValueChangeHandler<Boolean> handler) {
ToggleButton button = new ToggleButton(name);
toggleGroup.add(button);
button.addValueChangeHandler(handler);
button.setAllowDepress(false);
return button;
}
}
|
package net.dark.entreprise.international.adhess.savedata.DataBase;
/**
* Created by adhess on 31/05/2018.
*/
public class Directory {
private long id;
private String url;
public Directory(long id, String url) {
this.id = id;
this.url = url;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
|
package net.acomputerdog.BlazeLoader.util;
import com.google.common.eventbus.EventBus;
import cpw.mods.fml.common.LoadController;
import cpw.mods.fml.common.MetadataCollection;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.versioning.ArtifactVersion;
import cpw.mods.fml.common.versioning.VersionRange;
import net.acomputerdog.BlazeLoader.main.Version;
import java.io.File;
import java.security.cert.Certificate;
import java.util.*;
public class BLModContainer implements ModContainer {
public static final BLModContainer instance = new BLModContainer();
private BLModContainer() {
}
private File source = identifySource();
private ModMetadata metadata = identifyMetadata();
private ArtifactVersion artifactVersion = identifyArtifactVersion();
private VersionRange versionRange = identifyVersionRange();
private File identifySource() {
try {
return new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
} catch (Exception e) {
return null;
}
}
private ModMetadata identifyMetadata() {
ModMetadata meta = new ModMetadata();
meta.version = Version.getStringVersion();
meta.authorList.add("acomputerdog");
meta.credits = "Big thanks to mumfrey, big_Xplosion, and all who contribute on github!";
meta.modId = getModId();
meta.name = getName();
meta.description = "The BlazeLoader mod API. BlazeLoader allows the creation of advanced and game-changing mods with minimal code changes. It also provides forge compatibility for other mods, saving developers the trouble of porting their mods.";
meta.url = "http://www.minecraftforum.net/topic/2007563-172-blazeloader-mod-loader-and-api-for-game-changing-mods/";
meta.logoFile = "/BlazeLoader/res/BLLogo.png";
return meta;
}
private ArtifactVersion identifyArtifactVersion() {
return new ArtifactVersion() {
@Override
public String getLabel() {
return "BlazeLoader";
}
@Override
public String getVersionString() {
return Version.getStringVersion();
}
@Override
public boolean containsVersion(ArtifactVersion source) {
return compareTo(source) >= 0;
}
@Override
public String getRangeString() {
return "";
}
@Override
public int compareTo(ArtifactVersion o) {
String[] strVersionsThis = getVersionString().split(".");
String[] strVersionsThat = o.getVersionString().split(".");
if (strVersionsThis.length != strVersionsThat.length) {
return 0;
}
for (int index = 0; index < strVersionsThis.length; index++) {
try {
int verThis = Integer.parseInt(strVersionsThis[index]);
int verThat = Integer.parseInt(strVersionsThat[index]);
if (verThis > verThat) {
return 1;
}
if (verThis < verThat) {
return -1;
}
} catch (NumberFormatException ignored) {
return 0;
}
}
return 0;
}
};
}
private VersionRange identifyVersionRange() {
return VersionRange.createFromVersion(Version.getStringVersion(), artifactVersion);
}
/**
* The globally unique modid for this mod
*/
@Override
public String getModId() {
return "BlazeLoader";
}
/**
* A human readable name
*/
@Override
public String getName() {
return "BlazeLoader";
}
/**
* A human readable version identifier
*/
@Override
public String getVersion() {
return Version.getStringVersion();
}
/**
* The location on the file system which this mod came from
*/
@Override
public File getSource() {
return source;
}
/**
* The metadata for this mod
*/
@Override
public ModMetadata getMetadata() {
return metadata;
}
/**
* Attach this mod to it's metadata from the supplied metadata collection
*
* @param mc
*/
@Override
public void bindMetadata(MetadataCollection mc) {
}
/**
* Set the enabled/disabled state of this mod
*
* @param enabled
*/
@Override
public void setEnabledState(boolean enabled) {
//You can't stop me!
}
/**
* A list of the modids that this mod requires loaded prior to loading
*/
@Override
public Set<ArtifactVersion> getRequirements() {
return new HashSet<ArtifactVersion>();
}
/**
* A list of modids that should be loaded prior to this one. The special
* value <strong>*</strong> indicates to load <em>after</em> any other mod.
*/
@Override
public List<ArtifactVersion> getDependencies() {
return new ArrayList<ArtifactVersion>();
}
/**
* A list of modids that should be loaded <em>after</em> this one. The
* special value <strong>*</strong> indicates to load <em>before</em> any
* other mod.
*/
@Override
public List<ArtifactVersion> getDependants() {
return new ArrayList<ArtifactVersion>();
}
/**
* A representative string encapsulating the sorting preferences for this
* mod
*/
@Override
public String getSortingRules() {
return null;
}
/**
* Register the event bus for the mod and the controller for error handling
* Returns if this bus was successfully registered - disabled mods and other
* mods that don't need real events should return false and avoid further
* processing
*
* @param bus
* @param controller
*/
@Override
public boolean registerBus(EventBus bus, LoadController controller) {
return false;
}
/**
* Does this mod match the supplied mod
*
* @param mod
*/
@Override
public boolean matches(Object mod) {
if (!(mod instanceof ModContainer)) return false;
ModContainer container = (ModContainer) mod;
return (getModId().equals(container.getModId()) && getVersion().equals(container.getVersion()));
}
/**
* Get the actual mod object
*/
@Override
public Object getMod() {
return null;
}
@Override
public ArtifactVersion getProcessedVersion() {
return artifactVersion;
}
@Override
public boolean isImmutable() {
return true;
}
@Override
public String getDisplayVersion() {
return Version.getStringVersion();
}
@Override
public VersionRange acceptableMinecraftVersionRange() {
return versionRange;
}
@Override
public Certificate getSigningCertificate() {
return null;
}
@Override
public Map<String, String> getCustomModProperties() {
return new HashMap<String, String>();
}
@Override
public Class<?> getCustomResourcePackClass() {
return null;
}
@Override
public Map<String, String> getSharedModDescriptor() {
return new HashMap<String, String>();
}
@Override
public Disableable canBeDisabled() {
return Disableable.NEVER;
}
@Override
public String getGuiClassName() {
return null;
}
@Override
public List<String> getOwnedPackages() {
List<String> packages = new ArrayList<String>();
packages.add("net.acomputerdog.Blazeloader");
return packages;
}
}
|
package homework3.calcs.additional;
import homework3.calcs.api.ICalculator;
import homework3.calcs.simple.CalculatorWithMathCopy;
/**
* 10.1 ะะฐะฝะฝัะน ะบะฐะปัะบัะปััะพั ะฟัะตะดะฝะฐะทะฝะฐัะตะฝ ะดะปั ัะพะณะพ ััะพะฑั ัะฐััะธัะธัั ะฒะพะทะผะพะถะฝะพััะธ ะบะฐะปัะบัะปััะพัะฐ ะธ ะพะฑะตัะฟะตัะธัั ะตะณะพ
* ะดะพะฟะพะปะฝะธัะตะปัะฝะพะน ััะฝะบัะธะตะน ะฟะฐะผััะธ. ะ ะฟัะธะฝัะธะฟะต ัะฐะฑะพัะฐะตั ะบะฐะบ ะบะฐะปัะบัะปััะพั ะธะท ัะตะฐะปัะฝะพะน ะถะธะทะฝะธ.
* 10.2 ะัะต ะผะตัะพะดั ะพะฑััะฒะปะตะฝะฝัะต ะฒ ะดะฐะฝะฝะพะผ ะบะปะฐััะต ะะ ััะฐัะธัะตัะบะธะต (ะฝะต ะธะผะตัั ะผะพะดะธัะธะบะฐัะพั static).
* 10.3 ะะฐะฝะฝัะน ะบะปะฐัั ะฝะฐะฟััะผัั ะฝะต ัะผะตะตั ััะธัะฐัั ะผะฐัะตะผะฐัะธะบั.
* 10.4 ะ ะบะปะฐััะต ะดะพะปะถะฝั ะฟัะธัััััะฒะพะฒะฐัั ะผะฐัะตะผะฐัะธัะตัะบะธะต ะผะตัะพะดั:
* 10.4.1 4 ะฑะฐะทะพะฒัั
ะผะฐัะตะผะฐัะธัะตัะบะธั
ะผะตัะพะดะฐ (ะดะตะปะตะฝะธะต, ัะผะฝะพะถะตะฝะธะต, ะฒััะธัะฐะฝะธะต, ัะปะพะถะตะฝะธะต).
* 10.4.2 3 ะผะตัะพะดะฐ (ะะพะทะฒะตะดะตะฝะธะต ะฒ ัะตะปัั ััะตะฟะตะฝั ะดัะพะฑะฝะพะณะพ ะฟะพะปะพะถะธัะตะปัะฝะพะณะพ ัะธัะปะฐ, ะะพะดัะปั ัะธัะปะฐ, ะะพัะตะฝั ะธะท ัะธัะปะฐ).
* 10.5 ะคัะฝะบัะธั ะฟะฐะผััะธ ัะฐะฑะพัะฐะตั ัะตัะตะท ะผะตัะพะดั:
* 10.5.1 ะะฐะฟะธัะฐัั ะฒ ะฟะฐะผััั ัะตะทัะปััะฐั ะฒัะฟะพะปะฝะตะฝะธั ะฟะพัะปะตะดะฝะตะณะพ ะฒัะทะฒะฐะฝะฝะพะณะพ ะผะตัะพะดะฐ. ะฃ ะดะฐะฝะฝะพะณะพ ะผะตัะพะดะฐ ะฝะต ะดะพะปะถะฝะพ ะฑััั ะฟะฐัะฐะผะตััะพะฒ.
* 10.5.2 ะะพะปััะธัั ะธะท ะฟะฐะผััะธ ะทะฐะฟะธัะฐะฝะฝะพะต ะทะฝะฐัะตะฝะธะต. ะัะธ ะฟะพะปััะตะฝะธะธ ะทะฐะฟะธัะธ ะธะท ะฟะฐะผััะธ ะฟะฐะผััั ััะธัะฐะตััั, ะฟัะธ ะทะฐะฟะธัะธ ะฝะพะฒะพะณะพ
* ะทะฝะฐัะตะฝะธั ะฟะฐะผััั ะฟะตัะตะทะฐะฟะธััะฒะฐะตััั.
* 10.6 ะกะพะทะดะฐัั ะบะปะฐัั CalculatorWithMemoryMain ะฒ ะบะพัะพัะพะผ ะฑัะดะตั ัะพัะบะฐ ะฒั
ะพะดะฐ (main ะผะตัะพะด). ะ main ะผะตัะพะดะต ััะตะฑัะตััั ัะพะทะดะฐัั
* ัะบะทะตะผะฟะปัั ะบะฐะปัะบัะปััะพัะฐ ะธ ะธัะฟะพะปัะทัั ะผะตัะพะดั ะธะท ะดะฐะฝะฝะพะณะพ ัะบะทะตะผะฟะปััะฐ ะฟะพััะธัะฐัั ะฒััะฐะถะตะฝะธั ะธะท ะทะฐะดะฐะฝะธั 1. ะัะฒะตััะธ ะฒ ะบะพะฝัะพะปั
* ัะตะทัะปััะฐั. ะ ะผัะนะฝะต ะทะฐะฟัะตัะฐะตััั ะธัะฟะพะปัะทะพะฒะฐะฝะธะต ะฟะตัะตะผะตะฝะฝัั
ะดะปั ั
ัะฐะฝะตะฝะธั ะทะฝะฐัะตะฝะธะน ััะฐััะฒัััะธั
ะฒ ะฟัะพััััะต, ะฐ ัะฐะบะถะต
* ัะตะทัะปััะฐัะพะฒ ัะฐะฑะพัั ะผะตัะพะดะพะฒ ะบะฐะปัะบัะปััะพัะฐ.
*/
public class CalculatorWithMemory extends CalculatorWithMathCopy {
private ICalculator calculator;
private double memoryNumber;
public CalculatorWithMemory(CalculatorWithMathCopy calculator) {
this.calculator = calculator;
}
@Override
public double plus(double a, double b) {
return memoryNumber = calculator.plus(a, b); // ะผะพะถะฝะพ ะฑัะปะพ ะพัะณะฐะฝะธะทะพะฒะฐัั ะทะฐะฟะธัั ะฒ ะฟะตัะตะผะตะฝะฝัั ัะตัะตะท ะพัะดะตะปัะฝัะน ะผะตัะพะด
// ะฝะพ ะบะฐะบ ะธ ะฒ ัะปััะฐะต ั ะผะตัะพะดะพะผ incrementCountOperation() - ะธะทะปะธัะฝะต
}
@Override
public double minus(double a, double b) {
return memoryNumber = calculator.minus(a, b);
}
@Override
public double mult(double a, double b) {
return memoryNumber = calculator.mult(a, b);
}
@Override
public double div(double a, double b) {
return memoryNumber = calculator.div(a, b);
}
@Override
public double abs(double a) {
return memoryNumber = calculator.abs(a);
}
@Override
public double sqrt(double a) {
return memoryNumber = calculator.sqrt(a);
}
@Override
public double pow(double a, int b) {
return memoryNumber = calculator.pow(a, b);
}
/**
* ะะฐะฟะธัะฐัั ะฒ ะฟะฐะผััั ัะตะทัะปััะฐั ะฒัะฟะพะปะฝะตะฝะธั ะฟะพัะปะตะดะฝะตะณะพ ะฒัะทะฒะฐะฝะฝะพะณะพ ะผะตัะพะดะฐ. ะฃ ะดะฐะฝะฝะพะณะพ ะผะตัะพะดะฐ ะฝะต ะดะพะปะถะฝะพ ะฑััั ะฟะฐัะฐะผะตััะพะฒ.
* ะะพะปััะธัั ะธะท ะฟะฐะผััะธ ะทะฐะฟะธัะฐะฝะฝะพะต ะทะฝะฐัะตะฝะธะต. ะัะธ ะฟะพะปััะตะฝะธะธ ะทะฐะฟะธัะธ ะธะท ะฟะฐะผััะธ ะฟะฐะผััั ััะธัะฐะตััั, ะฟัะธ ะทะฐะฟะธัะธ ะฝะพะฒะพะณะพ
* ะทะฝะฐัะตะฝะธั ะฟะฐะผััั ะฟะตัะตะทะฐะฟะธััะฒะฐะตััั.
* @return ะฟะพัะปะตะดะฝัั ะทะฐะฟะธัั ะฒ ะฟะตัะตะผะตะฝะฝัั memory
*/
public double getMemory(){
double temp = memoryNumber;
memoryNumber = 0;
return temp;
}
}
|
package Command;
import Logic.Controller;
import Logic.Game;
public class HelpCommand extends NoParamsCommand {
public final static String commandLetter = "h";
public final static String commandText = "help";
public final static String commandInfo = "[H]elp";
public final static String helpInfo = "Print this help message";
public HelpCommand() {
super(commandLetter, commandText, commandInfo, helpInfo);
}
public void execute(Game game, Controller controller) {
String texto = CommandParser.commandHelp();
System.out.println(texto);
controller.setNoPrintGameState();
}
}
|
package fonctionStatic;
import java.io.File;
import java.io.IOException;
import java.net.Socket;
/**
* Classe contenant quelques fonctions statiques utiles
* @author Rรฉmy Voet, Dorian Opsommer
*
*/
public class Static {
public static int nbImageMax = 100;
public static int nbImage = 0;
public static String[] listerImages(File file){
String [] listeFichiers;
String [] listeImages = new String [nbImageMax];
int i;
nbImage = 0;
listeFichiers=file.list();
for(i=0;i<listeFichiers.length;i++){
if(listeFichiers[i].endsWith(".png")==true){
listeImages[nbImage]=listeFichiers[i];
System.out.println(listeImages[nbImage]);
nbImage++;
}
}
return listeImages;
}
public static double pythagoreHC(double hyp, double cot){
return Math.sqrt(Math.pow(hyp, 2) - Math.pow(cot, 2));
}
public static double pythagoreCC(double cot1, double cot2){
return Math.sqrt(Math.pow(cot1, 2) + Math.pow(cot2, 2));
}
public static boolean hoteDisponible(int port,String ipAdd) {
try (Socket s = new Socket(ipAdd,port)) {
s.close();
return true;
} catch (IOException ex) {
return false;
}
}
}
|
package test;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.util.Collection;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
import chat.errors.CoreException;
import script.groovy.runtime.GroovyBeanFactory;
import script.groovy.runtime.GroovyObjectFactory;
import script.groovy.runtime.GroovyRuntime;
public class Main {
public static void main(String[] args) throws CoreException {
String path = "/Users/aplombchen/Dev/taineng/Server/workspace-ggts/MongoDBConnector/groovy/";
Collection<File> files = FileUtils.listFiles(new File(path),
FileFilterUtils.suffixFileFilter(".groovy"),
FileFilterUtils.directoryFileFilter());
// for(File file : files) {
// String key = file.getAbsolutePath().substring(path.length());
// int pos = key.lastIndexOf(".");
// if(pos >= 0) {
// key = key.substring(0, pos);
// }
// key = key.replace("/", ".");
// }
GroovyRuntime groovyRuntime = new GroovyRuntime();
groovyRuntime.setPath(path);
GroovyBeanFactory beanFactory = new GroovyBeanFactory();
// beanFactory.setGroovyRuntime(groovyRuntime);
groovyRuntime.addClassAnnotationHandler(beanFactory);
groovyRuntime.init();
GroovyObjectFactory factory = new GroovyObjectFactory();
factory.setGroovyRuntime(groovyRuntime);
// boolean bool = true;
// while(bool) {
// groovyRuntime.redeploy();
// GroovyObjectEx<Callable> c1 = factory.getObject(a.B.class);
//// String hello = c1.getObject().hello();
// c1.getObject().call();
// System.gc();
// System.out.println("used " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 + "K");
// }
while(true) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = null;
try {
str = br.readLine();
if(str != null && str.equals("a")) {
groovyRuntime.redeploy();
}
/*
new Thread(new Runnable() {
@Override
public void run() {
GroovyObjectEx<Callable> c1 = factory.getObject(a.B.class);
// String hello = c1.getObject().hello();
try {
c1.getObject().call();
} catch (Exception e) {
e.printStackTrace();
}
System.gc();
System.out.println("used " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 + "K");
}
}).start();*/
// GroovyObjectEx<Callable> c1 = factory.getObject(c.C.class);
// c1.getObject().call();
//
// GroovyObjectEx<Callable> d1 = factory.getObject(c.D.class);
// d1.getObject().call();
// c.C c = new c.C();
// c.hello();
} catch (Throwable e) {
e.printStackTrace();
}
}
}
}
|
/******************************************************************************
* __ *
* <-----/@@\-----> *
* <-< < \\// > >-> *
* <-<-\ __ /->-> *
* Data / \ Crow *
* ^ ^ *
* info@datacrow.net *
* *
* This file is part of Data Crow. *
* Data Crow 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 any later version. *
* *
* Data Crow is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public *
* License along with this program. If not, see http://www.gnu.org/licenses *
* *
******************************************************************************/
package net.datacrow.util.isbn;
public abstract class ISBN {
private static String CheckDigits = new String("0123456789X0");
static int CharToInt(char a) {
switch (a) {
case '0':
return 0;
case '1':
return 1;
case '2':
return 2;
case '3':
return 3;
case '4':
return 4;
case '5':
return 5;
case '6':
return 6;
case '7':
return 7;
case '8':
return 8;
case '9':
return 9;
default:
return -1;
}
}
public static String getISBN10(String ISBN) throws InvalidBarCodeException {
String s9;
int i, n, v;
s9 = ISBN.substring(3, 12);
n = 0;
for (i = 0; i < 9; i++) {
v = CharToInt(s9.charAt(i));
if (v == -1)
throw new InvalidBarCodeException();
else
n = n + (10 - i) * v;
}
n = 11 - (n % 11);
return s9 + CheckDigits.substring(n, n + 1);
}
public static String getISBN13(String ISBN10) throws InvalidBarCodeException {
String s12;
int i, n, v;
boolean ErrorOccurred;
ErrorOccurred = false;
s12 = "978" + ISBN10.substring(0, 9);
n = 0;
for (i = 0; i < 12; i++) {
if (!ErrorOccurred) {
v = CharToInt(s12.charAt(i));
if (v == -1)
throw new InvalidBarCodeException();
else {
if ((i % 2) == 0)
n = n + v;
else
n = n + 3 * v;
}
}
}
n = n % 10;
if (n != 0) n = 10 - n;
return s12 + CheckDigits.substring(n, n + 1);
}
// private static final int[] weight13 = {1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3};
// private static final int[] weight10 = {1, 2, 3, 4, 5, 6, 7, 8, 9};
//
// public static String getISBN13(String isbn10) throws InvalidBarCodeException {
// String s = "978";
// char[] chars = isbn10.toCharArray();
// for (int i = 0; i < chars.length; i++) {
// if (Character.isDigit(chars[i]))
// s += chars[i];
// }
//
// if (s.length() < 13)
// throw new InvalidBarCodeException();
//
// // remove the check digit
// int[] digits = new int[12];
// chars = s.toCharArray();
// for (int i = 0; i < digits.length; i++) {
// digits[i] = Integer.parseInt("" + chars[i]);
// }
//
// return convertToISBN13(digits);
// }
//
// public static String getISBN10(String isbn13) throws InvalidBarCodeException {
// char[] chars = isbn13.toCharArray();
// String s = "";
// for (int i = 0; i < chars.length; i++) {
// if (Character.isDigit(chars[i]))
// s += chars[i];
// }
//
//
// if (s.length() < 10)
// throw new InvalidBarCodeException();
//
// int[] digits = new int[9];
// chars = s.toCharArray();
// int counter = 0;
// for (int i = 3; i < chars.length - 1; i++) {
// digits[counter++] = Integer.parseInt("" + chars[i]);
// }
//
// return convertToISBN10(digits);
// }
public static boolean isISBN13(String isbn) {
String s = "";
if (isbn != null) {
char[] chars = isbn.toCharArray();
for (int i = 0; i < chars.length; i++) {
if ("1234567890".indexOf(chars[i]) > -1)
s += chars[i];
}
}
return s.length() == 13;
}
public static boolean isISBN10(String isbn) {
String s = "";
if (isbn != null) {
char[] chars = isbn.toCharArray();
for (int i = 0; i < chars.length; i++) {
if ("1234567890X".indexOf(chars[i]) > -1)
s += chars[i];
}
}
return s.length() == 10;
}
// private static String convertToISBN10(int[] isbn13) {
// String isbn10 = "";
//
// int sum = 0;
// for (int i = 0; i < isbn13.length; i++)
// sum += isbn13[i] * weight10[i];
//
// int checkdigit = sum % 11;
//
// for (int i = 0; i < isbn13.length; i++)
// isbn10 += "" + isbn13[i];
//
// isbn10 += "" + checkdigit;
// return isbn10;
// }
//
// private static String convertToISBN13(int[] isbn10) {
// String isbn13 = "";
//
// int sum = 0;
// for (int i = 0; i < isbn10.length; i++)
// sum += isbn10[i] * weight13[i];
//
// int remainder = sum % 10;
//
// int checkdigit = 0;
// if (remainder > 0)
// checkdigit = 10 - remainder;
//
// for (int i = 0; i < isbn10.length; i++)
// isbn13 += "" + isbn10[i];
//
// isbn13 += "" + checkdigit;
// return isbn13;
// }
} |
package logic;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
/**
* This scheduling algorithm is a smart type of brute-force algorithm that will
* generate all possible schedules based on the courses given.
*/
public final class BruteForceScheduleMaker {
/**
* Since the class is static for all intents and purposes there is no need to
* allow instantiation
*/
private BruteForceScheduleMaker() {
throw new UnsupportedOperationException("This is a static class and cannot be instantiated!");
}
/**
* This method will retrieve the Course from the given name and semester and add
* it to the global ArrayList
*
* @param courseName - The name of the course to be searched for
* @param semesterID - Semester to search in
*/
public static Set<Course> findCourses(String courseName, String semesterID) {
Set<Course> possibleCourses = new HashSet<>(); // Holds all courses at various times
try {
// add all the inputed course to possibleCourses
possibleCourses.addAll(Scraper.getAllClasses(semesterID).get(courseName));
} catch (IOException e) {
Globals.popupException().writeError(e);
}
return possibleCourses;
}
/**
* Returns a set of sets of courses that are valid possible schedules
*
* @param desiredCourses The courses that the user desires
* @param semesterID The semester ID to make a schedule of
* @return Returns all possible sets of schedules
*/
public static Set<Set<Course>> build(Set<String> desiredCourses, String semesterID) {
/*
* a list of schedules ( list of lists )
*
* for each desired course: for each section in the desired course: for each
* schedule in the list: for each course in the schedule: if there is a
* conflict, remove the schedule from the list of schedules, and break twice add
* the section to the current schedule
*
*/
Set<Course> possibleCourses = new HashSet<>();
Set<Set<Course>> validSchedules = new HashSet<>(); // contains a list of schedules ( each "schedule" is a list of courses that do not conflict )
Set<Course> tempSchedule = new HashSet<>();
Set<Set<Course>> toAdd;
Set<Set<Course>> toRemove;
boolean conflict;
int courseAdditionCount = 0;
for (String courseCode : desiredCourses) {
possibleCourses = findCourses(courseCode, semesterID);
// if there are no pre-existing schedules
if (validSchedules.isEmpty()) {
for (Course possibleCourse : possibleCourses) {
tempSchedule = new HashSet<>();
tempSchedule.add(possibleCourse);
validSchedules.add(tempSchedule);
}
} else {
toAdd = new HashSet<>();
toRemove = new HashSet<>();
for (Course possibleCourse : possibleCourses) {
for (Set<Course> schedule : validSchedules) {
if (schedule.size() != courseAdditionCount) {
toRemove.add(schedule);
}
tempSchedule = new HashSet<>();
conflict = false;
for (Course existingCourse : schedule) {
if (possibleCourse.conflicts(existingCourse)) {
conflict = true;
break;
}
}
if (conflict) {
continue;
}
tempSchedule.addAll(schedule);
tempSchedule.add(possibleCourse);
toAdd.add(tempSchedule);
}
}
validSchedules.removeAll(toRemove);
validSchedules.addAll(toAdd);
}
courseAdditionCount++;
}
Set<Set<Course>> finalSchedules = new HashSet<>();
for (Set<Course> schedule : validSchedules) {
if (schedule.size() == desiredCourses.size()) {
finalSchedules.add(schedule);
}
}
return finalSchedules;
}
}
|
/**
*
*ๅคงๆบๆ
ง่กไปฝๆ้ๅ
ฌๅธ
* Copyright (c) 2006-2014 DZH,Inc.All Rights Reserved.
*/
package com.gw.steel.steel.util;
import com.gw.steel.steel.util.httpclient.HttpsClient;
/**
*
* @author log.yin
* @version $Id: TestHttpsClientSSL.java, v 0.1 2014ๅนด11ๆ26ๆฅ ไธๅ2:18:49 log.yin Exp $
*/
public class TestHttpsClientSSL {
/**
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
check();
bind();
}
/**
* @throws Exception
*
*/
private static void check() throws Exception {
String url = "https://10.15.108.5:8440/AccService-xc/checkuser";
String truststorepath = "d:/tester.truststore";
String p12path = "d:/tester.p12";
String passwd = "123456";
String requestBody = "{\"uname\":\"ๆต่ฏ\"}";
String result = HttpsClient.post(url, truststorepath, p12path, passwd, requestBody);
System.out.println("result: " + result);
}
private static void bind() throws Exception {
String url = "https://10.15.108.5:8440/AccService/xcscbind";
String truststorepath = "d:/tester.truststore";
String p12path = "d:/tester.p12";
String passwd = "123456";
String requestBody = "{\"uname\":\"ๆต่ฏ\",\"mobile\":\"15921866000\",\"xcid\":\"888888\",\"truename\":\"่็ฝ\", \"idcard\":\"436950321596315745\",\"opendate\":\"2014-11-26\",\"opentype\":\"1\",\"source\":\"1\"}";
String result = HttpsClient.post(url, truststorepath, p12path, passwd, requestBody);
System.out.println("result: " + result);
}
}
|
package cn.vaf714.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.vaf714.entity.Commodity;
import cn.vaf714.service.ManagerService;
/***
* ๆทปๅ ๅๅ
* @author vaf714
*
*/
public class AddCommodityServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// 1.่ทๅ็ฎก็ๅ่พๅ
ฅ็ไฟกๆฏๅนถๅฐ่ฃ
ๆ entity
String id = request.getParameter("id");
String name = request.getParameter("name");
String price = request.getParameter("price");
int num = Integer.parseInt(request.getParameter("num"));
Commodity commdity = new Commodity(id, name, price, num);
// 2.่ฐ็จ service ๅฑๅค็ไธๅก้ป่พ
boolean isSuccess = new ManagerService().addCommdity(commdity);
// 3.ๆ นๆฎๅค็็ปๆ๏ผ่ฝฌๅๅฐ็ธๅบไฝ็ฝฎ
if (isSuccess) {
System.out.println("็ฎก็ๅๆทปๅ ไบไธไธชๅๅ:" + name + ",id:" + id + ",price:" + price + ",num:" + num);
// ๆทปๅ ๆๅ
response.getWriter().println("<script charset=\"utf-8\">alert('ๆทปๅ ๆๅ');window.open('queryCommodityServlet?type=2&id=','_self');</script>");
} else {
// ๆทปๅ ๅคฑ่ดฅ
response.getWriter()
.println("<script charset=\"utf-8\">alert('ๆทปๅ ๅคฑ่ดฅ(่ฏทๆฃๆฅๅๅไฟกๆฏๆฏๅฆๆญฃ็กฎ)');window.open(add_commodity.jsp ,'_self');</script>");
}
}
}
|
package com.gxtc.huchuan.http;
import android.graphics.Bitmap;
import android.media.session.MediaSession;
import android.text.TextUtils;
import com.gxtc.commlibrary.utils.FileStorage;
import com.gxtc.commlibrary.utils.GsonUtil;
import com.gxtc.commlibrary.utils.LogUtil;
import com.gxtc.huchuan.Constant;
import com.gxtc.huchuan.bean.UploadFileBean;
import com.gxtc.huchuan.bean.UploadResult;
import com.gxtc.huchuan.bean.UpyunBean;
import com.gxtc.huchuan.data.UserManager;
import com.gxtc.huchuan.http.service.AllApi;
import com.gxtc.huchuan.http.service.LiveApi;
import com.gxtc.huchuan.http.service.MineApi;
import com.gxtc.huchuan.utils.ImageUtils;
import com.gxtc.huchuan.utils.SystemUtil;
import com.upyun.library.common.Params;
import com.upyun.library.common.ResumeUploader;
import com.upyun.library.common.UpConfig;
import com.upyun.library.common.UploadEngine;
import com.upyun.library.listener.UpCompleteListener;
import com.upyun.library.listener.UpProgressListener;
import com.upyun.library.utils.UpYunUtils;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.edu.zafu.coreprogress.helper.ProgressHelper;
import cn.edu.zafu.coreprogress.listener.impl.UIProgressListener;
import cn.edu.zafu.coreprogress.progress.ProgressRequestBody;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import rx.Observable;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
/**
* Created by Gubr on 2017/5/12.
* ไธไผ ๆไปถๅทฅๅ
ท็ฑป
*/
public class LoadHelper {
public static final String TYPE_IMAGE = "image/png";
public static final String TYPE_VIDEO_MP4 = "video/mp4";
public static final String TYPE_OTHER = "other";
public static final String UP_TYPE_IMAGE = "/image";
public static final String UP_TYPE_VIDEO = "/video";
public static final String UP_TYPE_OTHER = "/other";
public static final String bucketName = "xmzjvip";
public static final String operatorName = "xmzj";
public static final String password = "caisen123";
//่ฟไธชไธ่ฝๅ https
private static final String notifyUrl = "http://app.xinmei6.com/publish/file/upYunNotify.do";
/**
* ไฝฟ็จๅๆไบไธไผ ๅๆไปถ
*
* @param type {@link #UP_TYPE_IMAGE}
*/
public static void uploadFile(String type, final UploadCallback callback, final UIProgressListener listener, File file) {
String userCode = UserManager.getInstance().getUserCode();
final UploadResult uploadResult = new UploadResult();
final String name = "/{year}/{mon}/{day}/android_{random32}{.suffix}";
Map<String, Object> map = new HashMap<>();
map.put(Params.BUCKET, bucketName);
map.put(Params.NOTIFY_URL, notifyUrl);
if (TextUtils.isEmpty(userCode)) {
map.put(Params.SAVE_KEY, name);
} else {
map.put(Params.SAVE_KEY, "/{year}/{mon}/{day}/" + userCode + "upload_android_{random32}{.suffix}");
}
UploadEngine.getInstance().formUpload(file, map, operatorName, UpYunUtils.md5(password),
new UpCompleteListener() {
@Override
public void onComplete(boolean isSuccess, String result) {
LogUtil.i("onComplete result : " + result);
try {
double code = (double) GsonUtil.getJsonValue(result, "code");
String msg = (String) GsonUtil.getJsonValue(result, "message");
if (isSuccess) {
//ไธไผ ๆๅ
if (code == 200) {
String baseUrl = (String) GsonUtil.getJsonValue(result, "url");
String url = "https://" + bucketName + ".b0.upaiyun.com" + baseUrl;
LogUtil.i("url : " + url);
uploadResult.setUrl(url);
if (callback != null) {
callback.onUploadSuccess(uploadResult);
}
//ไธไผ ๅบ้
} else {
if (callback != null) {
callback.onUploadFailed(code + "", msg);
}
}
//ไธไผ ๅบ้
} else {
if (callback != null) {
callback.onUploadFailed(code + "", msg);
}
}
//ไธไผ ๅบ้
} catch (Exception e) {
e.printStackTrace();
if (callback != null) {
callback.onUploadFailed("404", "ไธไผ ๅพ็ๅคฑ่ดฅ");
}
}
}
},
new UpProgressListener() {
@Override
public void onRequestProgress(long bytesWrite, long contentLength) {
if (listener != null) {
listener.onUIProgress(bytesWrite, contentLength, bytesWrite == contentLength, 1);
}
}
});
}
/**
* ไฝฟ็จๅๆไบไธไผ ๅคๆไปถ
*
* @param type {@link #UP_TYPE_IMAGE}
*/
public static void uploadFiles(String type, final UploadCallback callback, final UIProgressListener listener, final File... files) {
String userCode = UserManager.getInstance().getUserCode();
final UploadResult uploadResult = new UploadResult(files.length);
for (int i = 0; i < files.length; i++) {
final String name = "/{year}/{mon}/{day}/android_{random32}{.suffix}";
final File file = files[i];
Map<String, Object> map = new HashMap<>();
map.put(Params.BUCKET, bucketName);
map.put(Params.NOTIFY_URL, notifyUrl);
if (TextUtils.isEmpty(userCode)) {
map.put(Params.SAVE_KEY, name);
} else {
map.put(Params.SAVE_KEY, "/{year}/{mon}/{day}/" + userCode + "upload_android_{random32}{.suffix}");
}
final int index = i;
UploadEngine.getInstance().formUpload(file, map, operatorName, UpYunUtils.md5(password),
new UpCompleteListener() {
@Override
public void onComplete(boolean isSuccess, String result) {
LogUtil.i("onComplete result : " + result);
try {
double code = (double) GsonUtil.getJsonValue(result, "code");
String msg = (String) GsonUtil.getJsonValue(result, "message");
if (isSuccess) {
//ไธไผ ๆๅ
if (code == 200) {
String baseUrl = (String) GsonUtil.getJsonValue(result, "url");
String url = "https://" + bucketName + ".b0.upaiyun.com" + baseUrl;
LogUtil.i("url : " + url);
uploadResult.addResult(index, url);
if (uploadResult.isFinish()) {
if (callback != null) {
callback.onUploadSuccess(uploadResult);
}
}
//ไธไผ ๅบ้
} else {
if (callback != null) {
callback.onUploadFailed(code + "", msg);
}
}
//ไธไผ ๅบ้
} else {
if (callback != null) {
callback.onUploadFailed(code + "", msg);
}
}
//ไธไผ ๅบ้
} catch (Exception e) {
if (callback != null) {
callback.onUploadFailed("404", "ไธไผ ๅพ็ๅคฑ่ดฅ");
}
}
}
},
new UpProgressListener() {
@Override
public void onRequestProgress(long bytesWrite, long contentLength) {
if (listener != null) {
listener.onUIProgress(bytesWrite, contentLength, bytesWrite == contentLength, uploadResult.getCurrIndex());
}
}
});
}
}
/**
* ไฝฟ็จๅๆไบไธไผ ่ง้ข
* ็นๅซ็ไธไผ ็ปๆไฟๅญ็ urls ้้ข ็ฌฌไบไฝurlๆฏ่ง้ข็ๅฐ้ขๅฐๅ
*/
public static void UpyunUploadVideo(File file, final UploadCallback callback, final UIProgressListener progressListener) {
final int[] frameSize = new int[2]; //่ง้ข็ฌฌไธๅธง็ๅฐบๅฏธ
final File videoFile = file;
Observable.just(file)
.subscribeOn(Schedulers.io())
.map(new Func1<File, Bitmap>() { //ๅ
ๅฐ่ง้ข็็ฌฌไธๅธงๆๅๅบๆฅ
@Override
public Bitmap call(File file) {
Bitmap bitmap = ImageUtils.getVideoFirstFrame(file.getPath());
frameSize[0] = bitmap.getWidth();
frameSize[1] = bitmap.getHeight();
return bitmap;
}
})
.map(new Func1<Bitmap, File>() { //ๅฐๅพ็ไฟๅญๅฐๆฌๅฐ
@Override
public File call(Bitmap bitmap) {
if (bitmap == null) {
if (callback != null) {
callback.onUploadFailed("", "่ง้ขๅพ็ๆๅๅคฑ่ดฅ");
}
return null;
}
File frameFile = new File(FileStorage.getImgCacheFile().getPath() + "/" + FileStorage.getImageTempName());//ๅฐ่ฆไฟๅญๅพ็็่ทฏๅพ
BufferedOutputStream bos = null;
try {
bos = new BufferedOutputStream(new FileOutputStream(frameFile));
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
bitmap.recycle();
bitmap = null;
} catch (IOException e) {
if (callback != null) {
callback.onUploadFailed("", "ๅ็ๆช็ฅ้่ฏฏ, ไธไผ ๅคฑ่ดฅ");
}
if (bos != null) {
try {
bos.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
e.printStackTrace();
} finally {
if (bitmap != null && !bitmap.isRecycled()) {
bitmap.recycle();
bitmap = null;
}
}
LogUtil.i("ๆๅๅ็่ง้ข็ฌฌไธๅธงๅพ็ๅฐๅ: " + frameFile.getPath());
return frameFile;
}
})
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<File>() {
@Override
public void call(File frameFile) {
//่ฟ้ไธไผ ๅฐๅๆไบๆๅกๅจ๏ผ ่ฎฐๅพๅพ็ๅฐๅ่ฆๅ ๅฎฝ้ซ ?width*height
uploadVideo(new UploadCallback() {
@Override
public void onUploadSuccess(UploadResult result) {
if (result.getUrls().size() >= 2) {
String picUrl = result.getUrls().get(1);
picUrl = picUrl + "?" + frameSize[0] + "*" + frameSize[1];
result.getUrls().set(1, picUrl);
}
if (callback != null) {
callback.onUploadSuccess(result);
}
}
@Override
public void onUploadFailed(String errorCode, String msg) {
if (callback != null) {
callback.onUploadFailed(errorCode, msg);
}
}
}, progressListener, videoFile, frameFile);
}
});
}
/**
* ไธไผ ่ง้ข่ทๅฐ้ขไธ็จ
*/
public static void uploadVideo(final UploadCallback callback, final UIProgressListener listener, final File... files) {
String userCode = UserManager.getInstance().getUserCode();
String videoPath = "/{year}/{mon}/{day}/" + userCode + "android_" + System.currentTimeMillis() + "{.suffix}";
final UploadResult uploadResult = new UploadResult(files.length);
for (int i = 0; i < files.length; i++) {
final String name = videoPath;
final File file = files[i];
Map<String, Object> map = new HashMap<>();
map.put(Params.BUCKET, bucketName);
map.put(Params.NOTIFY_URL, notifyUrl);
map.put(Params.SAVE_KEY, name);
final int index = i;
UploadEngine.getInstance().formUpload(file, map, operatorName, UpYunUtils.md5(password),
new UpCompleteListener() {
@Override
public void onComplete(boolean isSuccess, String result) {
LogUtil.i("onComplete result : " + result);
try {
double code = (double) GsonUtil.getJsonValue(result, "code");
String msg = (String) GsonUtil.getJsonValue(result, "message");
if (isSuccess) {
//ไธไผ ๆๅ
if (code == 200) {
String baseUrl = (String) GsonUtil.getJsonValue(result, "url");
String url = "https://" + bucketName + ".b0.upaiyun.com" + baseUrl;
LogUtil.i("url : " + url);
uploadResult.addResult(index, url);
if (uploadResult.isFinish()) {
if (callback != null) {
callback.onUploadSuccess(uploadResult);
}
}
//ไธไผ ๅบ้
} else {
if (callback != null) {
callback.onUploadFailed(code + "", msg);
}
}
//ไธไผ ๅบ้
} else {
if (callback != null) {
callback.onUploadFailed(code + "", msg);
}
}
//ไธไผ ๅบ้
} catch (Exception e) {
if (callback != null) {
callback.onUploadFailed("404", "ไธไผ ๅพ็ๅคฑ่ดฅ");
}
}
}
},
new UpProgressListener() {
@Override
public void onRequestProgress(long bytesWrite, long contentLength) {
if (listener != null) {
listener.onUIProgress(bytesWrite, contentLength, bytesWrite == contentLength, uploadResult.getCurrIndex());
}
}
});
}
}
/**
* ไธไผ IMๆไปถ
*
* @param map ่ฏทๆฑๅๆฐ
* @param mediType ๆไปถ็ฑปๅ
* @param listener ่ฟๅบฆ็ๅฌๅจ
* @param files ๅพ
ไธไผ ๆไปถ่ทฏๅพ
*/
public static Observable<ApiResponseBean<List<String>>> loadImFile(Map<String, String> map, String mediType, UIProgressListener listener, File... files) {
MultipartBody.Builder builder = new MultipartBody.Builder();
builder.setType(MultipartBody.FORM);
if (map != null && !map.isEmpty()) {
for (String key : map.keySet()) {
builder.addFormDataPart(key, map.get(key));
}
}
for (File file : files) {
builder.addFormDataPart("file", file.getName(),
RequestBody.create(MediaType.parse(mediType), file));
}
ProgressRequestBody progressRequestBody = ProgressHelper.addProgressRequestListener(builder.build(), listener);
return LiveApi.getInstance().uploadIMFile(progressRequestBody).subscribeOn(
Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
}
/**
* ๆททๅๅค็ฑปๅๆไปถไธไผ
*/
public static Observable<ApiResponseBean<List<String>>> loadMultiTypeFile(Map<String, String> map, List<String> types, List<File> files, UIProgressListener listener) {
MultipartBody.Builder builder = new MultipartBody.Builder();
builder.setType(MultipartBody.FORM);
if (map != null && !map.isEmpty()) {
for (String key : map.keySet()) {
builder.addFormDataPart(key, map.get(key));
}
}
for (int i = 0; i < files.size(); i++) {
File file = files.get(i);
builder.addFormDataPart("file", file.getName(), RequestBody.create(MediaType.parse(types.get(i)), file));
}
ProgressRequestBody progressRequestBody = ProgressHelper.addProgressRequestListener(builder.build(), listener);
return LiveApi.getInstance()
.uploadIMFile(progressRequestBody)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
/**
* ๅคๆไปถไธไผ
*
* @param map ่ฏทๆฑๅๆฐ
* @param mediType ๆไปถ็ฑปๅ
* @param listener ่ฟๅบฆ็ๅฌๅจ
* @param files ๅพ
ไธไผ ๆไปถ่ทฏๅพ
*/
@Deprecated
public static Observable<ApiResponseBean<List<String>>> loadFiles(Map<String, String> map, String mediType, UIProgressListener listener, File... files) {
MultipartBody.Builder builder = new MultipartBody.Builder();
builder.setType(MultipartBody.FORM);
if (map != null && !map.isEmpty()) {
for (String key : map.keySet()) {
builder.addFormDataPart(key, map.get(key));
}
}
for (File file : files) {
builder.addFormDataPart("file", file.getName(),
RequestBody.create(MediaType.parse(mediType), file));
}
ProgressRequestBody progressRequestBody = ProgressHelper.addProgressRequestListener(builder.build(), listener);
return AllApi.getInstance().uploadFiles(progressRequestBody)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
/**
* ไธไผ ๅ
ถๅฎๆไปถ
*
* @param map ใๅ
ถๅฎๅๆฐ
* @param mediType ใใๆไปถ็ฑปๅ
* @param file ใใๆไปถ
* @param listener ่ฟๅบฆ็ๅฌ
*/
@Deprecated
public static Observable<ApiResponseBean<UploadFileBean>> loadFile(Map<String, String> map, String mediType, File file, UIProgressListener listener) {
MultipartBody.Builder builder = new MultipartBody.Builder();
builder.setType(MultipartBody.FORM);
if (map != null && !map.isEmpty()) {
for (String key : map.keySet()) {
builder.addFormDataPart(key, map.get(key));
}
}
builder.addFormDataPart("file", file.getName(), RequestBody.create(MediaType.parse(mediType), file));
ProgressRequestBody progressRequestBody = ProgressHelper.addProgressRequestListener(builder.build(), listener);
return MineApi.getInstance()
.uploadFile(progressRequestBody)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public interface UploadCallback {
void onUploadSuccess(UploadResult result);
void onUploadFailed(String errorCode, String msg);
}
}
|
package co.sblock.events.listeners.plugin;
import org.bukkit.event.EventHandler;
import com.nitnelave.CreeperHeal.events.CHBlockHealEvent;
import co.sblock.Sblock;
import co.sblock.events.listeners.SblockListener;
import co.sblock.machines.Machines;
import co.sblock.module.Dependency;
/**
* Listener for CHBlockHealEvents.
*
* @author Jikoo
*/
@Dependency("CreeperHeal")
public class CHBlockHealListener extends SblockListener {
private final Machines machines;
public CHBlockHealListener(Sblock plugin) {
super(plugin);
this.machines = plugin.getModule(Machines.class);
}
/**
* EventHandler for CHBlockHealEvents.
*
* @param event the CHBlockHealEvent
*/
@EventHandler
public void onCHBlockHeal(CHBlockHealEvent event) {
if (!machines.shouldRestore(event.getBlock().getBlock())) {
machines.setRestored(event.getBlock().getBlock());
event.setCancelled(true);
}
if (machines.isExploded(event.getBlock().getBlock())) {
machines.setRestored(event.getBlock().getBlock());
return;
}
if (machines.isMachine(event.getBlock().getBlock())) {
if (event.shouldDrop()) {
event.getBlock().drop(true);
}
event.setCancelled(true);
}
}
}
|
/* Class for pieces in a Checkers game for Proj0, Spring 2015 CS61B
* @author Kevin Chen
*/
public class Piece {
private int xPosition;
private int yPosition;
private String type;
private boolean isFire;
private boolean hasCaptured;
private Board b;
private boolean crowned;
public Piece(boolean isFire, Board b, int x, int y, String type) {
this.xPosition = x;
this.yPosition = y;
this.type = type;
this.isFire = isFire;
this.hasCaptured = false;
this.b = b;
this.crowned = false; }
public boolean isFire() {
return isFire;
}
public int side() {
if (isFire()) {
return 0;
}
else {
return 1;
}
}
public boolean isKing() {
return crowned;
}
public boolean isBomb() {
return this.type.equals("bomb");
}
public boolean isShield() {
return this.type.equals("shield");
}
public void move(int x, int y) {
int deltaX = x - xPosition;
int deltaY = y - yPosition;
if (Math.abs(deltaX) == 2 && Math.abs(deltaY) == 2) {
if (deltaX == 2 && deltaY == 2 && x != 0 && y != 0 && b.pieceAt(x-1, y-1) != null && b.pieceAt(x-1, y-1).side() != side()) {
b.remove(x-1,y-1);
}
else if (deltaX == -2 && deltaY == 2 && y != 0 && b.pieceAt(x+1, y-1) != null && b.pieceAt(x+1, y-1).side() != this.side()) {
b.remove(x+1,y-1);
}
else if (deltaX == -2 && deltaY == -2 && b.pieceAt(x+1, y+1) != null && b.pieceAt(x+1, y+1).side() != this.side()) {
b.remove(x+1,y+1);
}
else if (deltaX == 2 && deltaY == -2 && x != 0 && b.pieceAt(x-1, y+1) != null && b.pieceAt(x-1, y+1).side() != this.side()) {
b.remove(x-1,y+1);
}
hasCaptured = true;
}
if ((isFire() && y == 7) || (!isFire() && y == 0)) {
crowned = true;
}
b.remove(xPosition, yPosition);
b.place(this, x, y);
xPosition = x;
yPosition = y;
if (isBomb() && hasCaptured()) {
bombExplosion(x,y);
}
}
private boolean intervalContains(int low, int high, int n) {
return n >= low && n < high;
}
private void bombExplosion(int x,int y) {
int left = x-1;
int right = x+1;
int above = y+1;
int below = y-1;
if (intervalContains(0,8,left) && intervalContains(0,8,above)) {
if (b.pieceAt(left,above) != null && !b.pieceAt(left,above).isShield()) {
b.remove(left, above);
}
}
if (intervalContains(0,8,right) && intervalContains(0,8,above)) {
if (b.pieceAt(right,above) != null && !b.pieceAt(right,above).isShield()) {
b.remove(right, above);
}
}
if (intervalContains(0,8,left) && intervalContains(0,8,below)) {
if (b.pieceAt(left,below) != null && !b.pieceAt(left,below).isShield()) {
b.remove(left, below);
}
}
if (intervalContains(0,8,right) && intervalContains(0,8,below)) {
if (b.pieceAt(right,below) != null && !b.pieceAt(right,below).isShield()) {
b.remove(right, below);
}
}
b.remove(x,y);
}
public boolean hasCaptured() {
return hasCaptured;
}
public void doneCapturing() {
hasCaptured = false;
}
} |
package tool;
public class FunctionPoint {
private String element;
private Integer l;
private Integer a;
private Integer h;
private Integer s;
Integer f1 = 0, f2 = 0, f3 = 0;
private int total;
public FunctionPoint() {
super();
}
public FunctionPoint(String element, int l, int a, int h) {
super();
this.element = element;
this.l = l;
this.a = a;
this.h = h;
}
public String getEle() {
return element;
}
public void setEle(String ele) {
this.element = ele;
}
public Integer getA() {
if (a == null)
return 0;
return a;
}
public void setA(int a) {
this.a = a;
}
public Integer getL() {
if (l == null)
return 0;
return l;
}
public void setL(int l) {
this.l = l;
}
public Integer getH() {
if (h == null)
return 0;
return h;
}
public void setH(int h) {
this.h = h;
}
public void setS(int s) {
this.s = s;
}
public Integer getF1() {
return f1;
}
public void setF1(int f1) {
this.f1 = f1;
}
public Integer getF2() {
return f2;
}
public void setF2(int f2) {
this.f2 = f2;
}
public Integer getF3() {
return f3;
}
public void setF3(int f3) {
this.f3 = f3;
}
@Override
public String toString() {
return "Element" + element + ", l=" + l + ", a=" + a + ", h=" + h + ", sum=" + total + "]";
}
}
|
package practice.leetcode.algorithm;
import org.junit.Test;
import static org.junit.Assert.*;
public class ZigZagConversionTest {
@Test
public void testConvert() {
ZigZagConversion zigZagConversion = new ZigZagConversion();
String input = "PAYPALISHIRING";
String result = zigZagConversion.convert(input, 3);
assertEquals("PAHNAPLSIIGYIR", result);
assertEquals("PINALSIGYAHRPI", zigZagConversion.convert(input, 4));
}
@Test
public void testBoundaryConvert() {
ZigZagConversion zigZagConversion = new ZigZagConversion();
String input = "PAYPALISHIRING";
assertEquals("PAYPALISHIRIGN", zigZagConversion.convert(input, input.length() - 1));
}
@Test
public void testBoundary4Convert() {
ZigZagConversion zigZagConversion = new ZigZagConversion();
String input = "PAYPALISHIRING";
assertEquals(input, zigZagConversion.convert(input, 1));
assertEquals(input, zigZagConversion.convert(input, input.length()));
}
} |
/**
*
* @author Kaczyลski Jakub S11688
*
*/
package zad2;
import javax.swing.JFrame;
import com.sun.prism.paint.Color;
public class Main {
public static void main(String[] args){
Lista1 okno = new Lista1();
okno.setSize(600,600);
okno.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
okno.pack();
okno.setVisible(true);
}
} |
package com.kaka.blog.dao;
import com.kaka.blog.po.Type;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @author Kaka
*/
public interface TypeRepository extends JpaRepository<Type,Long> {
Type findTypeByTypeName(String typeName);
}
|
package hiring.model;
import java.util.UUID;
public class TokenPassword {
private UUID token;
private String password;
public TokenPassword(UUID token, String password){
this.password = password;
this.token = token;
}
public String getPassword() {
return this.password;
}
public UUID getToken() {
return this.token;
}
public void setPassword(String password) {
this.password = password;
}
public void setToken(UUID token) {
this.token = token;
}
}
|
package com.restapi.repository;
import com.restapi.model.Emotions;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface EmotionsRepository extends MongoRepository<Emotions, String> {
public Emotions findByAutor(String autor);
public List<Emotions> findAllByFamilyId(String familyId);
public List<Emotions> findAllByAutor(List<String> autor);
}
|
package com.sobin.yuvrecorder;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
/**
* ็ณป็ป็ธๅ
ณๅทฅๅ
ท
*
*/
public class PhoneUtils {
/**
* ่ทๅๅฑๅนๅ่พจ็
*
* @param mContext
*
* @return
*/
/**
* ่ทๅๅฑๅนๅ่พจ็
*
* @param ctx
* @return [0]height [1]width
*/
public static int[] getScreenSizeArray(Context ctx) {
Display display = ((WindowManager) ctx
.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
DisplayMetrics dm = new DisplayMetrics();
display.getMetrics(dm);
return new int[] { dm.heightPixels, dm.widthPixels };
}
// byte[] ่ฝฌ 16่ฟๅถ
public static String bytesToHexString(byte[] src) {
StringBuilder stringBuilder = new StringBuilder("");
if (src == null || src.length <= 0) {
return null;
}
for (int i = 0; i < src.length; i++) {
int v = src[i] & 0xFF;
String hv = Integer.toHexString(v);
if (hv.length() < 2) {
stringBuilder.append(0);
}
stringBuilder.append(hv);
}
return stringBuilder.toString();
}
//// 16่ฟๅถ ่ฝฌ byte[]
public static byte[] hexStringToBytes(String hexString) {
if (hexString == null || hexString.equals("")) {
return null;
}
hexString = hexString.toUpperCase();
int length = hexString.length() / 2;
char[] hexChars = hexString.toCharArray();
byte[] d = new byte[length];
for (int i = 0; i < length; i++) {
int pos = i * 2;
d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
}
return d;
}
/**
* Convert char to byte
*
* @param c
* char
* @return byte
*/
private static byte charToByte(char c) {
return (byte) "0123456789ABCDEF".indexOf(c);
}
public static void rotateYUV240SP_Clockwise(byte[] src,byte[] des,int width,int height)
{
int wh = width * height;
//ๆ่ฝฌY
int k = 0;
for(int i=0;i<width;i++) {
for(int j=0;j<height;j++)
{
des[k] = src[width*(height-j-1) + i];
k++;
}
}
for(int i=0;i<width;i+=2) {
for(int j=0;j<height/2;j++)
{
des[k] = src[wh+ width*(height/2-j-1) + i];
des[k+1]=src[wh + width*(height/2-j-1) + i+1];
k+=2;
}
}
}
public static void rotateYUV240SP_AntiClockwise(byte[] src,byte[] des,int width,int height)
{
int wh = width * height;
//ๆ่ฝฌY
int k = 0;
for(int i=0;i<width;i++) {
for(int j=0;j<height;j++)
{
des[k] = src[width*j + width-i-1];
k++;
}
}
for(int i=0;i<width;i+=2) {
for(int j=0;j<height/2;j++)
{
des[k+1] = src[wh+ width*j + width-i-1];
des[k]=src[wh + width*j + width-(i+1)-1];
k+=2;
}
}
}
//it works becuase in YCbCr_420_SP and YCbCr_422_SP, the Y channel is planar and appears first
public static void rotateYuvData(byte[] rotatedData, byte[] data, int width, int height,int nCase)
{
if( nCase == 0)
{
rotateYUV240SP_Clockwise(data,rotatedData,width,height);
}else
{
rotateYUV240SP_AntiClockwise(data,rotatedData,width,height);
}
}
}
|
package commands.client.game;
import java.util.Map;
import java.util.Set;
import cards.Card;
import commands.server.ingame.InGameServerCommand;
import commands.server.ingame.PlayerCardSelectionInGameServerCommand;
import core.client.GamePanel;
import core.client.game.operations.Operation;
import core.client.game.operations.instants.HarvestCardSelectionOperation;
import core.player.PlayerInfo;
import ui.game.custom.HarvestSelectionPane;
public class ShowHarvestCardSelectionPaneUIClientCommand extends AbstractSingleTargetOperationGameClientCommand {
private static final long serialVersionUID = 1L;
private final Map<Card, Boolean> selectableCards;
public ShowHarvestCardSelectionPaneUIClientCommand(PlayerInfo target, Map<Card, Boolean> selectableCards) {
super(target);
this.selectableCards = selectableCards;
}
@Override
protected Operation getOperation() {
return new HarvestCardSelectionOperation(this.target, this.selectableCards);
}
@Override
public Set<Class<? extends InGameServerCommand>> getAllowedResponseTypes() {
return Set.of(PlayerCardSelectionInGameServerCommand.class);
}
@Override
protected boolean shouldClearGamePanel() {
return true;
}
@Override
protected void updateForOtherPlayer(GamePanel panel) {
panel.getGameUI().displayCustomizedSelectionPaneAtCenter(new HarvestSelectionPane(this.selectableCards, this.target.getName(), null));
}
@Override
public InGameServerCommand getDefaultResponse() {
for (Map.Entry<Card, Boolean> entry : selectableCards.entrySet()) {
if (!entry.getValue()) {
return new PlayerCardSelectionInGameServerCommand(entry.getKey(), null);
}
}
// by design we should not reach here
throw new RuntimeException("Harvest has no valid card to select");
}
@Override
protected String getMessageForOthers() {
return "Waiting on " + target.getName() + " to select a card from Harvest";
}
}
|
package com.tidestorm.blog;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.sql.DataSource;
@SpringBootTest
//@RunWith(SpringRunner.class)
@RunWith(SpringRunner.class)
class BlogApplicationTests {
@Autowired
private DataSource dataSource;
@Test
void contextLoads() {
}
@Test
public void t(){
System.err.println(dataSource.getClass());
}
}
|
package optimization.models;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import ilog.concert.IloException;
import ilog.concert.IloIntVar;
import ilog.concert.IloLinearNumExpr;
import ilog.concert.IloNumVar;
import ilog.cplex.IloCplex;
import parameters.Parameters;
import stockmarket.Portfolio;
/**
*
* @author hugo
*/
public abstract class BaseOptimization {
protected Portfolio portfolio;
protected Parameters params;
protected IloCplex model;
protected IloNumVar[] w; // positive weights variables for portfolio
protected IloIntVar[] y; // integer variables representing the limit of total number of assets
public static final double SMALL = 0.0;
public static final double BIG = 99.0;
public BaseOptimization(Portfolio portfolio, Parameters params) throws IloException {
this.portfolio = portfolio;
this.params = params;
this.model = new IloCplex();
this.model.setParam(IloCplex.IntParam.RandomSeed, 1996);
this.model.setParam(IloCplex.IntParam.TimeLimit, params.getOptimizationTimeLimit());
}
public abstract void createDecisionVariables() throws IloException;
public abstract void setObjectiveFunction() throws IloException;
public abstract void setConstraints() throws IloException;
public abstract void printAtEnd() throws IloException;
public void prepare() throws IloException {
createDecisionVariables();
setObjectiveFunction();
setConstraints();
if (params.getMaxNumberOfAssets() > 0) {
createIntegerDeciosionVariablesToLimitTotalAssets();
setLimitTotalAssetsConstraints();
}
}
public boolean solve() throws IloException {
if (model.solve()) {
assignWeightsToPortfolio();
printAtEnd();
System.out.println("-----------------------------------------");
System.out.println("Solution status = " + model.getStatus());
System.out.println("O.F. mean value = " + model.getObjValue());
System.out.println("-----------------------------------------");
return true;
}
System.out.println("-----------------------------------------");
System.out.println("Solution status = " + model.getStatus());
System.out.println("-----------------------------------------");
return false;
}
protected void createBasicDecisionVariables() throws IloException {
w = new IloNumVar[portfolio.getN()];
for (int i = 0; i < portfolio.getN(); i++) {
w[i] = model.numVar(0.0, 1.0);
}
}
protected void setWeightsConstraints() throws IloException {
IloLinearNumExpr expr = model.linearNumExpr();
for (int i = 0; i < portfolio.getN(); i++) {
expr.addTerm(1.0, w[i]);
}
model.addEq(expr, 1.0);
}
protected void createIntegerDeciosionVariablesToLimitTotalAssets() throws IloException {
y = new IloIntVar[portfolio.getN()];
for (int i = 0; i < portfolio.getN(); i++) {
y[i] = model.boolVar();
}
}
protected void setLimitTotalAssetsConstraints() throws IloException {
IloLinearNumExpr expr = model.linearNumExpr();
for (int i = 0; i < portfolio.getN(); i++) {
expr.addTerm(1.0, y[i]);
model.addLe(model.prod(0.05, y[i]), w[i]);
model.addLe(w[i], y[i]);
}
// model.addLe(expr, params.getMaxNumberOfAssets());
model.addEq(expr, params.getMaxNumberOfAssets());
}
private void assignWeightsToPortfolio() throws IloException {
for (int i = 0; i < portfolio.getN(); i++) {
if (model.getValue(w[i]) > 0) {
portfolio.setAssetWeight(i, model.getValue(w[i]));
} else {
portfolio.setAssetWeight(i, 0.0);
}
}
}
protected void printPortfoliosWeights() throws IloException {
System.out.println("-----------------------------------------");
System.out.println("PORTFOLIO:");
int count = 0;
double sum_weights = 0.0;
for (int i = 0; i < portfolio.getN(); i++) {
if (model.getValue(w[i]) > 0) {
System.out.format("%10s -> %5s%%\n", portfolio.getAssetName(i), portfolio.getAssetWeight(i));
sum_weights += portfolio.getAssetWeight(i);
count++;
}
}
System.out.println("Total assets: " + count + ";\tTotal weight: " + sum_weights);
}
public Portfolio getPortfolio() {
return portfolio;
}
public Parameters getParameters() {
return params;
}
public IloCplex getModel() {
return model;
}
public IloNumVar getW(int i) {
return w[i];
}
}
|
package com.zjf.myself.codebase.activity.AlgorithmList;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.zjf.myself.codebase.R;
import com.zjf.myself.codebase.activity.BaseAct;
import com.zjf.myself.codebase.util.AppLog;
import java.util.ArrayList;
import java.util.List;
/**
* <pre>
* author : ZouJianFeng
* e-mail :
* time : 2017/05/16
* desc :
* version: 1.0
* </pre>
*/
//ๅฆๆไฝ ๆฏๆ็้ๅดๆไธไธชๅๅ็1000ๅๅฃซๅ
ตไธญ็ไธไธช๏ผๆฏไธคไธชๆๆไธไธช๏ผๅฐๆๆไบบไธคไธคๅ็ป๏ผ็ถๅๆๆๆฏ็ป็ฌฌไธไธช๏ผ็ดๅฐๅฉไธๆๅไธไธช๏ผ้ฃไนไฝ ๅฟ
้กปๅจๅชไธชไฝ็ฝฎๆๅฏไปฅๆดปไธๆฅ
public class Person1000Act extends BaseAct implements View.OnClickListener{
private Button btnStart;
private TextView txtResult;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.act_person_1000);
btnStart = (Button)findViewById(R.id.btnStart);
btnStart.setOnClickListener(this);
txtResult = (TextView)findViewById(R.id.txtResult);
}
@Override
public void onClick(View v){
switch (v.getId()){
case R.id.btnStart:
algorithmStart();
break;
default:
break;
}
}
private void algorithmStart(){
List<Integer> list = new ArrayList<Integer>();
for(int j = 0;j < 1000;j++){
list.add(j+1);
}
//ๅ้1-1000
// for(int i = 0 ; i < list.size() ; i++) {
// AppLog.d(list.get(i)+"");
// }
//ๆญค็ฎๆณๆๅๅๅบๆฅ็็ดๆฅๆๆ ==512
// while(true){
// AppLog.d("้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้");
// if(list.size() == 1){
// break;
// }
// for (int i = 0; i<list.size();i=i+1){
// list.remove(i);
// }
// //ๅฐๆฏๆฌกๆไบไนๅ็ๆๅฐๅบๆฅ
// for(int i = 0 ; i < list.size() ; i++) {
// AppLog.d(list.get(i)+"aaaaaa");
// }
// }
//ๆญค็ฎๆณๆๅๅๅบๆฅ็็ดๆฅ็ฎไป่ตฐ่ฟไธๆ ==1000
// while(true){
// AppLog.d("้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้");
// if(list.size() == 1){
// break;
// }
// if(list.size()%2==0){
// for (int i = 0; i<list.size();i=i+1){
// list.remove(i);
// }
// }else{
// for (int i = 0; i<list.size()-1;i=i+1){
// list.remove(i);
// }
// }
//
// //ๅฐๆฏๆฌกๆไบไนๅ็ๆๅฐๅบๆฅ
// for(int i = 0 ; i < list.size() ; i++) {
// AppLog.d(list.get(i)+"aaaaaa");
// }
// }
//ๆญค็ฎๆณๆๅๅๅบๆฅ็ปง็ปญๅๆดปไธๆฅ็ฌฌไธไธช็็ป้ ==976
while(true){
AppLog.d("้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้้ด้");
if(list.size() == 1){
break;
}
if(list.size()%2==0){
for (int i = 0; i<list.size();i=i+1){
list.remove(i);
}
}else{
for (int i = 0; i<list.size()-1;i=i+1){
list.remove(i);
}
int last = list.get(list.size()-1);
list.remove(list.size()-1);
list.add(0,last);
}
//ๅฐๆฏๆฌกๆไบไนๅ็ๆๅฐๅบๆฅ
for(int i = 0 ; i < list.size() ; i++) {
AppLog.d(list.get(i)+"aaaaaa");
}
}
//็ปๆ
AppLog.d("็ปๆ="+list.get(0));
txtResult.setText(list.get(0)+"");
}
//ๅ ้คๆฐ็ปไธญ็0
public static int[] removeZero(int[] a) {
int j = 0;
// ่ฟไธชforๅพช็ฏ่ฎก็ฎๅบไฝ ไผ ๅ
ฅ็่ฟไธชๆฐ็ปๅปๆ0ๅ็้ฟๅบฆ
for (int i = 0; i < a.length; i++) {
if (a[i] != 0) {
j++;
}
}
// ๅฎไนๆฐ็ป็้ฟๅบฆ
int[] newarr = new int[j];
j = 0;
// ๅฐไธไธบ้ถ็copyๅฐๆฐๆฐ็ปไธญๅป
for (int i = 0; i < a.length; i++) {
if (a[i] != 0) {
newarr[j] = a[i];
j++;
}
}
// ๅพช็ฏๆๅฐ
for (int i = 0; i < newarr.length; i++) {
AppLog.d(newarr[i]+"");
}
return newarr;
}
}
|
package security;
import java.util.HashMap;
import java.util.Map;
import domain.Customer;
import domain.Manager;
import domain.Receptionist;
@SuppressWarnings("rawtypes")
public class AuthorisationProvider {
/**
* Initialize the permission settings
* Those settings can be finished in XML configure file, which can be
* improved in future.
*/
public static Map<String, Class[]> permission = new HashMap<String, Class[]>();
static {
Class[] cancelOrder = {Customer.class, Manager.class, Receptionist.class};
permission.put("CancelOrder", cancelOrder);
Class[] checkOrder = {Customer.class, Manager.class, Receptionist.class};
permission.put("CheckOrder", checkOrder);
Class[] getAvailableRooms = null;
permission.put("GetAvailableRooms", getAvailableRooms);
Class[] homePage = null;
permission.put("HomePage", homePage);
Class[] login = null;
permission.put("Login", login);
Class[] placeOrder = {Customer.class, Manager.class, Receptionist.class};
permission.put("PlaceOrder", placeOrder);
Class[] viewCustomer = {Customer.class, Manager.class, Receptionist.class};
permission.put("ViewCustomer", viewCustomer);
Class[] viewRooms = null;
permission.put("ViewRooms", viewRooms);
Class[] logout = null;
permission.put("LogOut", logout);
Class[] staffIndex = null;
permission.put("StaffIndex", staffIndex);
Class[] staffChooseCustomer = {Manager.class, Receptionist.class};
permission.put("StaffChooseCustomer", staffChooseCustomer);
Class[] staffCreateCustomer = {Manager.class, Receptionist.class};
permission.put("StaffCreateCustomer", staffCreateCustomer);
Class[] staffSearchCustomer = {Manager.class, Receptionist.class};
permission.put("StaffSearchCustomer", staffSearchCustomer);
Class[] staffViewPlaceOrder = {Manager.class, Receptionist.class};
permission.put("StaffViewPlaceOrder", staffViewPlaceOrder);
Class[] staffPlaceOrder = {Manager.class, Receptionist.class};
permission.put("StaffPlaceOrder", staffPlaceOrder);
Class[] staffCheckOrder = {Manager.class, Receptionist.class};
permission.put("StaffCheckOrder", staffCheckOrder);
Class[] staffBuilding = {Manager.class};
permission.put("StaffBuildings", staffBuilding);
Class[] staffManageBuilding = {Manager.class};
permission.put("StaffManageBuilding", staffManageBuilding);
permission.put("StaffNewBuilding", staffManageBuilding);
permission.put("StaffEditBuilding", staffManageBuilding);
Class[] staffRooms = {Manager.class};
permission.put("StaffRooms", staffRooms);
Class[] staffManageRooms = {Manager.class};
permission.put("StaffManageRoom", staffManageRooms);
permission.put("StaffNewRoom", staffManageRooms);
permission.put("StaffEditRoom", staffManageRooms);
Class[] staffOrderRooms = {Manager.class, Receptionist.class};
permission.put("StaffOrderRooms", staffOrderRooms);
Class[] staffManageCurrentOrders = {Manager.class, Receptionist.class};
permission.put("StaffManageCurrentOrders", staffManageCurrentOrders);
Class[] staffEditOrder = {Manager.class, Receptionist.class};
permission.put("StaffEditOrder", staffEditOrder);
}
/**
* based on logged user and type of command to check authorisation
* @param attribute 'command' in the request
* @param attribute 'loggedUser' saved in session
* @return
*/
public static boolean checkAuthorisation(String command, Object user) {
Class userClass = null;
if (user != null)
userClass = user.getClass();
// if the command is invalid
if (!permission.containsKey(command)) {
return false;
}
Class[] permissionList = permission.get(command);
// no authentication necessary
if (permissionList == null) {
return true;
}
else {
for (int i=0; i<permissionList.length; i++) {
// if user is authenticated
if (permissionList[i] == userClass) {
return true;
}
}
return false;
}
}
}
|
package model;
// default package
// Generated 2017/2/24 ไธๅ 02:20:27 by Hibernate Tools 5.2.0.CR1
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* MinorCategory generated by hbm2java
*/
@Entity
@Table(name = "minorCategory", schema = "RedLine")
public class MinorCategoryBean implements java.io.Serializable {
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
private String category;
private String item;
public MinorCategoryBean() {
}
public MinorCategoryBean(String category, String item) {
this.category = category;
this.item = item;
}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCategory() {
return this.category;
}
public void setCategory(String category) {
this.category = category;
}
public String getItem() {
return this.item;
}
public void setItem(String item) {
this.item = item;
}
@Override
public String toString() {
return "MinorCategoryBean [id=" + id + ", category=" + category + ", item=" + item + "]";
}
}
|
/**
* Spring social configuration.
*/
package com.helpfull.security.social;
|
package com.test;
import java.util.Arrays;
import com.test.base.Solution;
public class SolutionA implements Solution
{
/**
* ๅฆไธ็ฌฆๅท๏ผ๏ผฉใ๏ผถใ๏ผธใ๏ผฌใ๏ผฃใ๏ผคๅ๏ผญ๏ผๅๅซ่กจ็คบ๏ผใ๏ผใ๏ผ๏ผใ๏ผ๏ผใ๏ผ๏ผ๏ผใ๏ผ๏ผ๏ผๅ๏ผ๏ผ๏ผ๏ผ๏ผ
* @param num
* @return
*/
@Override
public String intToRoman(int num)
{
if (num <= 0 || num > 3999)
{
return null;
}
StringBuffer result = new StringBuffer();
int[] array = getIntArray(num);
System.out.println(Arrays.toString(array));
// ๅไฝ
for (int i = 0; i < array[0]; i++)
{
result.append("M");
}
// ็พไฝ
if (9 == array[1])
{
result.append("CM");
}
else if (array[1] >= 5)
{
result.append("D");
for (int i = 0; i < array[1] - 5; i++)
{
result.append("C");
}
}
else if (4 == array[1])
{
result.append("CD");
}
else
{
for (int i = 0; i < array[1]; i++)
{
result.append("C");
}
}
// ๅไฝ
if (9 == array[2])
{
result.append("XC");
}
else if (array[2] >= 5)
{
result.append("L");
for (int i = 0; i < array[2] - 5; i++)
{
result.append("X");
}
}
else if (4 == array[2])
{
result.append("XL");
}
else
{
for (int i = 0; i < array[2]; i++)
{
result.append("X");
}
}
// ไธชไฝ
if (9 == array[3])
{
result.append("IX");
}
else if (array[3] >= 5)
{
result.append("V");
for (int i = 0; i < array[3] - 5; i++)
{
result.append("I");
}
}
else if (4 == array[3])
{
result.append("IV");
}
else
{
for (int i = 0; i < array[3]; i++)
{
result.append("I");
}
}
return result.toString();
}
private int[] getIntArray(int num)
{
int[] result = new int[4];
result[0] = num / 1000; // M D
num %= 1000;
result[1] = num / 100; // C L
num %= 100;
result[2] = num / 10; // X V
num %= 10;
result[3] = num % 10; // V I
return result;
}
}
|
package cs3500.animator.view.dialogs;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JOptionPane;
/**
* Pop-up dialog for allowing the user to export animation to SVG file.
*/
public class ExportSVGDialog extends JPanel {
private String result = "";
/**
* Constructor the pop-up for ExportSVGDialog.
*/
public ExportSVGDialog() {
JFrame frame = new JFrame();
frame.setPreferredSize(new Dimension(300, 200));
result = (String)JOptionPane.showInputDialog(
frame, "Enter in the desired name of the SVG file, not including .svg: \n",
"Export to SVG",
JOptionPane.PLAIN_MESSAGE,
null,
null,
"Type here");
}
/**
* The result from the user's input in the dialog.
* @return The result
*/
public String getResult() {
return result;
}
}
|
/******************************************************************************
* __ *
* <-----/@@\-----> *
* <-< < \\// > >-> *
* <-<-\ __ /->-> *
* Data / \ Crow *
* ^ ^ *
* info@datacrow.net *
* *
* This file is part of Data Crow. *
* Data Crow 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 any later version. *
* *
* Data Crow is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public *
* License along with this program. If not, see http://www.gnu.org/licenses *
* *
******************************************************************************/
package net.datacrow.core.modules;
import java.util.ArrayList;
import java.util.Collection;
import net.datacrow.console.components.tables.DcTable;
import net.datacrow.console.views.CachedChildView;
import net.datacrow.console.views.MasterView;
import net.datacrow.console.views.View;
import net.datacrow.console.windows.itemforms.ChildForm;
import net.datacrow.console.windows.itemforms.DcMinimalisticItemView;
import net.datacrow.core.DcRepository;
import net.datacrow.core.modules.xml.XmlModule;
import net.datacrow.core.objects.DcField;
import net.datacrow.core.objects.DcObject;
/**
* Items belonging to a child module are dependent on the existence of a parent item.
* Parent items always belong to another module, represented by the {@link DcParentModule} class.
*
* @author Robert Jan van der Waals
*/
public class DcChildModule extends DcModule implements IChildModule {
private static final long serialVersionUID = 1388069555942936534L;
/**
* Creates a new instances of this module based on a XML definition.
* @param xmlModule
*/
public DcChildModule(XmlModule xmlModule) {
super(xmlModule);
}
/**
* Creates a new instance.
* @param index The module index.
* @param topModule Indicates if the module is a top module. Top modules are allowed
* to be displayed in the module bar and can be enabled or disabled.
* @param name The internal unique name of the module.
* @param description The module description
* @param objectName The name of the items belonging to this module.
* @param objectNamePlural The plural name of the items belonging to this module.
* @param tableName The database table name for this module.
* @param tableShortName The database table short name for this module.
*/
public DcChildModule(int index,
boolean topModule,
String name,
String description,
String objectName,
String objectNamePlural,
String tableName,
String tableShortName) {
super(index, topModule, name, description, objectName, objectNamePlural,
tableName, tableShortName);
}
/**
* Creates a new item view.
*/
@Override
public DcMinimalisticItemView getItemView(DcObject parent, int module, boolean readonly) {
return new ChildForm(parent, module, readonly);
}
@Override
public int[] getSupportedViews() {
return new int[] {MasterView._TABLE_VIEW};
}
@Override
public int[] getMinimalFields(Collection<Integer> include) {
Collection<Integer> fields = new ArrayList<Integer>();
int valueType;
for (DcField field : getFields()) {
valueType = field.getValueType();
if (valueType != DcRepository.ValueTypes._DCOBJECTCOLLECTION &&
valueType != DcRepository.ValueTypes._DCOBJECTREFERENCE &&
valueType != DcRepository.ValueTypes._PICTURE) {
fields.add(Integer.valueOf(field.getIndex()));
}
}
if (include != null)
for (Integer i : include)
if (!fields.contains(include))
fields.add(i);
int[] minimalFields = new int[fields.size()];
int idx = 0;
for (Integer index : fields)
minimalFields[idx++] = index.intValue();
return minimalFields;
}
/**
* Initializes the various views.
*/
@Override
protected void initializeUI() {
if (insertView == null && hasInsertView()) {
insertView = new MasterView(getIndex());
DcTable table = new DcTable(this, false, true);
table.setDynamicLoading(false);
View view = new CachedChildView(insertView, View._TYPE_INSERT, table, MasterView._TABLE_VIEW);
table.setView(view);
insertView.addView(MasterView._TABLE_VIEW, view);
}
if (searchView == null && hasSearchView()) {
searchView = new MasterView(getIndex());
searchView.setTreePanel(this);
DcTable table = new DcTable(this, false, true);
View view = new View(searchView, View._TYPE_SEARCH, table, MasterView._TABLE_VIEW);
table.setView(view);
searchView.addView(MasterView._TABLE_VIEW, view);
}
}
/**
* Indicates if this module is a child module.
*/
@Override
public boolean isChildModule() {
return true;
}
/**
* Indicates if this module is a top module. Top modules are allowed
* to be displayed in the module bar and can be enabled or disabled.
*/
@Override
public boolean isTopModule() {
return false;
}
@Override
public boolean equals(Object o) {
return (o instanceof DcChildModule ? ((DcChildModule) o).getIndex() == getIndex() : false);
}
} |
package irix.measurement.structure;
import irix.measurement.service.ValueAttributesImp;
public class ValueAttributes extends Value implements ValueAttributesImp {
private String unit;
public ValueAttributes() {
}
public ValueAttributes(String unit) {
this.unit = unit;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
@Override
public String toString() {
return "unit=" + unit;
}
}
|
package by.htp.book09.main;
import java.util.List;
import java.util.ArrayList;
public class BookListLogic {
public static List<Book> listBookAuthor(String authorUser, BookList bookList) {
List<Book> bookAuthor = new ArrayList<Book>();
for (Book b : bookList.getBooks()) {
if (b.getAuthor().compareTo(authorUser) == 0) {
bookAuthor.add(b);
}
}
return bookAuthor;
}
public static List<Book> listBookPublishingHouse(String publishingHouseUser, BookList bookList) {
List<Book> bookPublishingHouse = new ArrayList<Book>();
for (Book b : bookList.getBooks()) {
if (b.getPublishingHouse().compareTo(publishingHouseUser) == 0) {
bookPublishingHouse.add(b);
}
}
return bookPublishingHouse;
}
public static List<Book> listBookYear(int yearUser, BookList bookList) {
List<Book> bookYear = new ArrayList<Book>();
for (Book b : bookList.getBooks()) {
if (b.getTheYearOfPublishing()>yearUser) {
bookYear.add(b);
}
}
return bookYear;
}
}
|
package com.arwizon.service;
import com.arwizon.model.Product;
public interface AdminInterface {
public Product addProduct(String name,String description,int price,String manufacturerName,int discount,String imgUrl,int noOfUnits,String category);
public Product[] search(String name,Product[] arr);
}
|
/**Copyright (c) 2018 Paraskevas Louka
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 atm;
/**
*
* @author vas
*
*/
public class BalanceOnly extends StatementType {
/**
* Determines the informations that will be printed in statement for balance only statements
*/
@Override
public String print() {
return "Balance: " + Accounts.getObj().getBalance() + "\n";
}
}
|
package com.jgw.supercodeplatform.trace.dao.mapper1.storedprocedure;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.StatementType;
import java.util.Map;
@Mapper
public interface DataSyncMapper {
@Select({ "call p_datasync(#{startdate,mode=IN,jdbcType=DATE})" })
@Options(statementType= StatementType.CALLABLE)
void execute(Map<String,String> params);
}
|
package com.thoughtworks.shoppingweb.persistence;
import com.thoughtworks.shoppingweb.domain.Orders;
import com.thoughtworks.shoppingweb.domain.OrdersProduct;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
public interface OrderProductMapper {
public int insertProductToOrder(OrdersProduct ordersProduct);
}
|
/*
* Author: RINEARN (Fumihiro Matsui), 2022
* License: CC0
* Interface Specification:
* https://www.vcssl.org/en-us/doc/connect/ExternalFunctionConnectorInterface1_SPEC_ENGLISH
*/
package org.vcssl.nano.plugin.system.xfci1;
import org.vcssl.nano.plugin.system.file.FileIOHub;
import org.vcssl.connect.ConnectorException;
/**
* A function plug-in providing "System.writeln(int fileId, string content)" function.
*/
public class WritelnXfci1Plugin extends WriteXfci1Plugin {
/**
* Create a new instance of this plug-in.
*
* @param fileIOHub The file I/O hub, through which the file I/O will be performed.
*/
public WritelnXfci1Plugin(FileIOHub fileIOHub) {
super(fileIOHub);
}
@Override
public String getFunctionName() {
return "writeln";
}
/**
* Write the specified contents to the specified file, and go to the next line.
* (This method called from WriteXfci1Plugin.invoke(...) method.)
*
* @param fileId The ID of the file.
* @param contents The contents to be written to the file.
* @throws ConnectorException Thrown when any error has occurred when it writing the contents to file.
*/
@Override
protected void performIO(int fileId, String[] contents) throws ConnectorException{
this.fileIOHub.writeln(fileId, contents);
}
}
|
package com.github.dockerjava.api.model.metric;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class MemoryStats {
@JsonProperty("usage")
private long usage;
@JsonProperty("max_usage")
private long maxUsage;
@JsonProperty("stats")
private Map<String, Long> stats;
@JsonProperty("failcnt")
private long failcnt;
public long getUsage() {
return usage;
}
public long getMaxUsage() {
return maxUsage;
}
public Map<String, Long> getStats() {
return stats;
}
public long getFailcnt() {
return failcnt;
}
@Override
public String toString() {
return "MemoryStats [usage=" + usage + ", maxUsage=" + maxUsage
+ ", stats=" + stats + ", failcnt=" + failcnt + "]";
}
}
|
package com.Idao;
import model.Guitar;
public interface GuitarIDao {
public boolean addGuitar(Guitar guitar) throws Exception;
public boolean updateGuitar(Guitar guitar) throws Exception;
public boolean deleteGuitar(int id) throws Exception;
}
|
package apascualco.blog.springboot.persistence.repositorio;
import apascualco.blog.springboot.persistence.entidades.MotorEntidad;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface MotorREPO extends JpaRepository<MotorEntidad, Long> {
}
|
package com.alpha.toy.message.mapper;
import java.util.ArrayList;
import org.apache.ibatis.annotations.Param;
import com.alpha.toy.vo.MemberVo;
import com.alpha.toy.vo.MessageVo;
public interface MessageSQLMapper {
public int createMessagePK();
//write
public void writeMessage(MessageVo vo);
//read(select)
public ArrayList<MessageVo> getmessage(
@Param("member_name") String member_name,
@Param("member_receive_name") String member_receive_name,
@Param("page_num") int page_num
);
//์นด์ดํธ
public int getContentCount(String member_id);
public ArrayList<MessageVo> getsendmessage(
@Param("member_name") String member_name,
@Param("member_send_name") String member_send_name,
@Param("page_num") int page_num
);
//ํ์ด์ง
public int getsendContentCount(
@Param("member_name") String member_name,
@Param("member_send_name") String member_send_name,
@Param("page_num") int page_num
);
public MessageVo getContentByNo(int message_no);
//DB์ญ์
public void deleteMessage(int message_no);
//์ฝ์ํ์ธ
public void increaseReadCount(int message_no);
//๋ณด๋ธ ๋ฉ์์ง ์ญ์
public void increasesendMessage(int message_no);
//๋ฐ์ ๋ฉ์์ง ์ญ์
public void increasereceiveMessage(int message_no);
public MemberVo messageName(String member_receive_name);
}
|
package com.esum.framework.security.pki.manager;
import java.io.File;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.esum.framework.FrameworkSystemVariables;
import com.esum.framework.common.sql.Record;
import com.esum.framework.common.sql.SQLUtil;
import com.esum.framework.common.util.SysUtil;
import com.esum.framework.core.config.Configurator;
import com.esum.framework.security.SecurityUtil;
import com.esum.framework.security.pki.manager.info.PKIJKSInfo;
import com.esum.framework.security.pki.manager.info.PKIPKCS12Info;
import com.esum.framework.security.pki.manager.info.PKIPKCS78Info;
import com.esum.framework.security.pki.manager.info.PKIPKCS7Info;
import com.esum.framework.security.pki.manager.info.PKIStoreInfo;
import com.esum.framework.security.pki.manager.info.PKITypeConstants;
public class PKIStoreManager {
private Logger log = LoggerFactory.getLogger(PKIStoreManager.class);
public static final String PKI_STORE_TABLE_ID = "pki_store_id";
private static PKIStoreManager instance = null;
protected Map<String, PKIStoreInfo> pkiStoreMap = null;
protected Map<String, PKIStoreInfo > mPKIStoreWithIssuerSerial = null;
public static synchronized PKIStoreManager getInstance() throws PKIException {
if (instance == null)
instance = new PKIStoreManager(Configurator.DEFAULT_DB_PROPERTIES_ID);
return instance;
}
private String currentNodeId;
private PKIStoreManager(String configId) throws PKIException {
pkiStoreMap = new HashMap<String, PKIStoreInfo>();
mPKIStoreWithIssuerSerial = new HashMap<String, PKIStoreInfo>();
currentNodeId = System.getProperty(FrameworkSystemVariables.NODE_ID, "");
init(configId);
}
private void init(String configId) throws PKIException {
StringBuffer buffer = new StringBuffer();
buffer.append("SELECT * FROM PKI_STORE ");
try {
List<Record> recordList = SQLUtil.multiQuery(configId, buffer.toString());
if (recordList != null && recordList.size() !=0) {
for(int i = 0; i < recordList.size(); i++) {
Record record = recordList.get(i);
if(containsNodeId(currentNodeId, record.getString("NODE_ID", null)));
addPKIStoreInfo(record);
}
}
} catch (SQLException e) {
log.error("SQLException while init PKIStoreManager", e);
throw new PKIException("init()", e);
} catch (Exception e) {
log.error("Exception while init PKIStoreManager", e);
throw new PKIException("init()", e);
}
}
private boolean containsNodeId(String currentNodeId, String nodeIds) {
if(nodeIds==null || StringUtils.isEmpty(nodeIds))
return true;
String[] ids = nodeIds.split(",");
for(int i=0;i<ids.length;i++){
if(currentNodeId.equals(ids[i].trim()))
return true;
}
return false;
}
private void addPKIStoreInfo(Record record) throws Exception {
String pkiStoreId = record.getString("PKI_ALIAS");
String pkiType = record.getString("PKI_TYPE");
String alias = record.getString("ALIAS");
log.debug("Adding " + pkiStoreId + " PKI Store(" + pkiType + ") to PKIStoreManager...");
PKIStoreInfo pkiStoreInfo = null;
if (pkiType.equals(PKITypeConstants.PKCS7_8)) {
String privateKeyPath = SysUtil.replacePropertyToValue(record.getString("KEY_PATH"));
String privateKeyPassword = new String(SecurityUtil.decryptData(record.getString("KEY_PASSWORD")));
String certPath = SysUtil.replacePropertyToValue(record.getString("CERT_PATH"));
if(new File(privateKeyPath).exists() && new File(certPath).exists()) {
String trustStorePath = SysUtil.replacePropertyToValue(record.getString("TRUST_STORE_PATH"));
if (record.getString("TRUST_STORE_PATH") != null && trustStorePath.trim().length()> 0
&& new File(trustStorePath).exists()) {
String trustStorePassword = new String(SecurityUtil.decryptData(record.getString("TRUST_STORE_PASSWORD")));
String trustStoreType = SysUtil.replacePropertyToValue(record.getString("TRUST_STORE_TYPE"));
pkiStoreInfo = new PKIPKCS78Info(privateKeyPath, privateKeyPassword, certPath,
trustStorePath, trustStorePassword, trustStoreType);
} else {
pkiStoreInfo = new PKIPKCS78Info(privateKeyPath, privateKeyPassword, certPath);
}
addPKIStoreInfo(pkiStoreId, pkiStoreInfo);
log.debug("Added " + pkiStoreId + " PKI Store(" + pkiType + ") to PKIInfoManager..");
}
} else if (pkiType.equals(PKITypeConstants.JKS)) {
String jksPath = SysUtil.replacePropertyToValue(record.getString("KEY_PATH"));
String jksPassword = new String(SecurityUtil.decryptData(record.getString("KEY_PASSWORD")));
if(new File(jksPath).exists()) {
pkiStoreInfo = new PKIJKSInfo(jksPath, alias, jksPassword);
addPKIStoreInfo(pkiStoreId, pkiStoreInfo);
log.debug("Added " + pkiStoreId + " PKI Store(" + pkiType + ") to PKIInfoManager..");
}
} else if (pkiType.equals(PKITypeConstants.PKCS12)) {
String pkcs12Path = SysUtil.replacePropertyToValue(record.getString("KEY_PATH"));
String pkcs12Password = new String(SecurityUtil.decryptData(record.getString("KEY_PASSWORD")));
if(new File(pkcs12Path).exists()) {
pkiStoreInfo = new PKIPKCS12Info(pkcs12Path, pkcs12Password);
addPKIStoreInfo(pkiStoreId, pkiStoreInfo);
log.debug("Added " + pkiStoreId + " PKI Store(" + pkiType + ") to PKIInfoManager..");
}
} else if (pkiType.equals(PKITypeConstants.PKCS7)) {
String certPath = SysUtil.replacePropertyToValue(record.getString("CERT_PATH"));
if(new File(certPath).exists()) {
pkiStoreInfo = new PKIPKCS7Info(certPath);
addPKIStoreInfo(pkiStoreId, pkiStoreInfo);
log.debug("Added " + pkiStoreId + " PKI Store(" + pkiType + ") to PKIInfoManager..");
}
} else {
throw new PKIException("addPKIStoreInfo()", "Don't support " + pkiType + " PKI type.");
}
}
public void reloadPkiInfo(String[] ids) throws PKIException {
reloadPkiInfo(Configurator.DEFAULT_DB_PROPERTIES_ID, ids);
}
public void reloadPkiInfo(String dbConfigId, String[] ids) throws PKIException {
Record record = null;
StringBuffer query = new StringBuffer();
query.append("SELECT * \n");
query.append(" FROM PKI_STORE \n");
query.append(" WHERE PKI_ALIAS = ? \n");
List<String> params = new ArrayList<String>();
params.add(ids[0]);
try {
record = SQLUtil.singleQuery(dbConfigId, query.toString(), params);
} catch (SQLException e) {
throw new PKIException("reloadPkiInfo()", e);
}
removePKIStoreInfo(ids[0]);
try {
if(record!=null && containsNodeId(currentNodeId, record.getString("NODE_ID", null))) {
addPKIStoreInfo(record);
}
} catch (Exception e) {
throw new PKIException("reloadHTTPAuthInfo()", e);
}
}
public void addPKIStoreInfo(String pkiAlias, PKIStoreInfo pkiStoreInfo) {
pkiStoreMap.put(pkiAlias, pkiStoreInfo);
String key = pkiStoreInfo.getCertificate().getIssuerDN() + ":" + pkiStoreInfo.getCertificate().getSerialNumber().longValue();
mPKIStoreWithIssuerSerial.put(key, pkiStoreInfo);
}
public PKIStoreInfo getPKIStoreInfo(String pkiAlias) {
if (pkiStoreMap.containsKey(pkiAlias))
return (PKIStoreInfo)pkiStoreMap.get(pkiAlias);
else
return null;
}
public PKIStoreInfo getPKIStoreInfo(String issuerDN, String serialNumber) {
String key = issuerDN + ":" + serialNumber;
if (mPKIStoreWithIssuerSerial.containsKey(key))
return (PKIStoreInfo)mPKIStoreWithIssuerSerial.get(key);
else
return null;
}
public boolean removePKIStoreInfo(String pkiAlias) {
return pkiStoreMap.remove(pkiAlias) == null ? false : true;
}
public boolean reload(String pkiAlias) throws Exception{
if (pkiStoreMap.containsKey(pkiAlias))
return ((PKIStoreInfo)pkiStoreMap.get(pkiAlias)).reload();
else
throw new Exception("Not exist " + pkiAlias + " alias.");
}
}
|
package ์ ๋ณ๋ฏผ_201702068_์ค์ต10;
import java.util.Scanner;
public class Main {
private static Scanner myScanner = new Scanner(System.in);
private static int inputScore(){
return myScanner.nextInt();
}
public static void main(String[] args) {
Student myStudent = new Student();
GPACounter myCounter = new GPACounter();
System.out.print("> ์ธ ๊ณผ๋ชฉ (๊ตญ์ด, ์์ด, ์ปดํจํฐ)์ ์ ์๋ฅผ ์ฐจ๋ก๋ก ์
๋ ฅํฉ๋๋ค : ");
int korScore, engScore, comScore ;
korScore = inputScore();
engScore = inputScore();
comScore = inputScore();
System.out.println();
while (korScore > 0 && engScore > 0 && comScore > 0) {
myStudent.setScoreKor(korScore);
myStudent.setScoreEng(engScore);
myStudent.setScoreCom(comScore);
if ( korScore > 100 || engScore > 100 || comScore > 100 ) {
System.out.println("์ค๋ฅ : 100์ด ๋์ด์, ์ ์์ ์ธ ์ ์๊ฐ ์๋๋๋ค.");
}
else {
System.out.println("[๊ตญ ์ด] ์ ์ : " + korScore + ", ํ์ : " + myStudent.gradeKor() + ", ํ์ : " + myStudent.pointKor());
System.out.println("[์ ์ด] ์ ์ : " + engScore + ", ํ์ : " + myStudent.gradeEng() + ", ํ์ : " + myStudent.pointEng());
System.out.println("[์ปดํจํฐ] ์ ์ : " + comScore + ", ํ์ : " + myStudent.gradeCom() + ", ํ์ : " + myStudent.pointCom());
System.out.println("์ด ํ์์ ํ๊ท ํ์ ์ " + myStudent.gpa() + "์
๋๋ค.");
myCounter.count(myStudent.gpa());
}
System.out.println();
System.out.print("์ธ ๊ณผ๋ชฉ (๊ตญ์ด, ์์ด, ์ปดํจํฐ)์ ์ ์๋ฅผ ์ฐจ๋ก๋ก ์
๋ ฅํฉ๋๋ค : ");
korScore = inputScore();
engScore = inputScore();
comScore = inputScore();
}
System.out.println("์์ ์ ์๊ฐ ์
๋ ฅ๋์ด ์
๋ ฅ์ ์ข
๋ฃํฉ๋๋ค.");
System.out.println();
System.out.println("ํ๊ท ํ์ ์ด 3.0 ์ด์์ธ ํ์์ " + myCounter.numberOfGPA3() + "๋ช
์
๋๋ค.");
System.out.println("ํ๊ท ํ์ ์ด 2.0 ์ด์ 3.0 ๋ฏธ๋ง์ธ ํ์์ " + myCounter.numberOfGPA2() + "๋ช
์
๋๋ค.");
System.out.println("ํ๊ท ํ์ ์ด 1.0 ์ด์ 2.0 ๋ฏธ๋ง์ธ ํ์์ " + myCounter.numberOfGPA1() + "๋ช
์
๋๋ค.");
System.out.println("ํ๊ท ํ์ ์ด 1.0 ๋ฏธ๋ง์ธ ํ์์ " + myCounter.numberOfGPA0() + "๋ช
์
๋๋ค.");
System.out.println("ํ๋ก๊ทธ๋จ์ ์ข
๋ฃํฉ๋๋ค.");
}
}
|
package DesignPatternBuilders;
import DesignPatternCodeGenerator.CodeBuilder;
import DesignPatterns.Builder.*;
import org.apache.commons.io.FileUtils;
import org.eclipse.jface.text.BadLocationException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
/**
* Builder for Builder design pattern
*
*/
public class BuilderBuilder implements CodeBuilder {
String directorClass, builderClass, complexObjectClass, productInterface, productAClass, productBClass;
String directoryPath;
private Logger logger;
public BuilderBuilder(String directoryPath, String directorClass, String builderClass, String complexObjectClass,
String productInterface, String productAClass, String productBClass) {
this.logger = LoggerFactory.getLogger("DesignPatternBuilders.BuilderBuilder");
this.directoryPath = directoryPath;
this.directorClass = directorClass;
this.builderClass = builderClass;
this.complexObjectClass = complexObjectClass;
this.productInterface = productInterface;
this.productAClass = productAClass;
this.productBClass = productBClass;
}
public void writeFile() throws BadLocationException, IOException {
// create file objects
Director directorObject = new Director(this.directorClass, this.complexObjectClass, this.builderClass);
Builder builderObject = new Builder(this.builderClass, this.complexObjectClass, this.productAClass,
this.productBClass);
ComplexObject complexObjectObject = new ComplexObject(this.complexObjectClass, this.productInterface);
Product productObject = new Product(this.productInterface);
ProductA productAObject = new ProductA(this.productAClass, this.productInterface);
ProductB productBObject = new ProductB(this.productBClass, this.productInterface);
// write the generated code
String directorFilename = this.directoryPath + directorObject.fileName + ".java";
String builderFilename = this.directoryPath + builderObject.fileName + ".java";
String complexObjectFilename = this.directoryPath + complexObjectObject.fileName + ".java";
String productFilename = this.directoryPath + productObject.fileName + ".java";
String productAFilename = this.directoryPath + productAObject.fileName + ".java";
String productBFilename = this.directoryPath + productBObject.fileName + ".java";
logger.debug("Creating Director file");
FileUtils.writeStringToFile(new File(directorFilename),
directorObject.buildCode().get(), StandardCharsets.UTF_8);
logger.debug("Creating Builder file");
FileUtils.writeStringToFile(new File(builderFilename), builderObject.buildCode().get(), StandardCharsets.UTF_8);
logger.debug("Creating ComplexObject file");
FileUtils.writeStringToFile(new File(complexObjectFilename),
complexObjectObject.buildCode().get(), StandardCharsets.UTF_8);
logger.debug("Creating Product file");
FileUtils.writeStringToFile(new File(productFilename), productObject.buildCode().get(), StandardCharsets.UTF_8);
logger.debug("Creating ProductA file");
FileUtils.writeStringToFile(new File(productAFilename),
productAObject.buildCode().get(), StandardCharsets.UTF_8);
logger.debug("Creating ProductB file");
FileUtils.writeStringToFile(new File(productBFilename),
productBObject.buildCode().get(), StandardCharsets.UTF_8);
}
}
|
package testinggame.Controladores;
import testinggame.Modelos.Usuario;
import testinggame.Modelos.UsuarioDAO;
import testinggame.utils.Context;
import testinggame.utils.Error;
import testinggame.utils.Respuesta;
import animatefx.animation.Pulse;
import java.io.IOException;
import java.net.URL;
import java.sql.SQLException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
public class ConfiguracionesController implements Initializable {
@FXML
private TextField tfUsuario;
@FXML
private TextField tfNombre_Apellido;
@FXML
private ComboBox<String> cbxSexo;
@FXML
private AnchorPane PanelE;
@FXML
private Button bttnVolver;
@FXML
private Button bttnActualizar;
@FXML
private Label lbError;
@Override
public void initialize(URL url, ResourceBundle rb) {
lbError.setVisible(false);
cbxSexo.getItems().addAll(
"F",
"M"
);
Usuario usuario = Context.getUsuario();
tfUsuario.setText(usuario.getUsername());
tfNombre_Apellido.setText(usuario.getNombreApellido());
cbxSexo.setValue(usuario.getSexo());
Volver();
Actualizar();
}
private void Volver(){
bttnVolver.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent event) {
try {
Parent root= FXMLLoader.load(getClass().getResource("/testinggame/Vistas/VentanaDeSeleccion.fxml"));
Scene SCENE=new Scene(root);
PanelE.getChildren().clear();
PanelE.getChildren().add(root);
}catch (IOException ex) {
Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
bttnVolver.setOnMouseEntered(new EventHandler<MouseEvent>(){
@Override
public void handle(MouseEvent event) {
new Pulse(bttnVolver).play();
}
});
}
public void Actualizar() {
bttnActualizar.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent event) {
Usuario usuario = Context.getUsuario();
String nuevoUsername = tfUsuario.getText();
String nuevoNombreApellido = tfNombre_Apellido.getText();
String nuevoSexo = cbxSexo.getValue();
try {
Respuesta r = UsuarioDAO.actualizar(usuario.getId().toString(), nuevoUsername, nuevoNombreApellido, nuevoSexo);
if (r.getStatus() == 2) {
lbError.setText("El nombre de usuario ya existe.");
lbError.setVisible(true);
return;
}
usuario = UsuarioDAO.mostrar(nuevoUsername);
Context.setUsuario(usuario);
Parent root= FXMLLoader.load(getClass().getResource("/testinggame/Vistas/VentanaDeSeleccion.fxml"));
Scene SCENE=new Scene(root);
PanelE.getChildren().clear();
PanelE.getChildren().add(root);
} catch (SQLException ex) {
Logger.getLogger(ConfiguracionesController.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(ConfiguracionesController.class.getName()).log(Level.SEVERE, null, ex);
} catch (Error ex) {
Logger.getLogger(ConfiguracionesController.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(ConfiguracionesController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
}
|
package com.yhkx.core.storage.dao.entity;
import org.hibernate.validator.constraints.Length;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
/**
*service ่กจ็ๆฐๆฎๅฏน่ฑก
*
* @author uniqu
*/
@Table(name = "service")
public class Service implements Serializable {
@Length(max=32,message="service_category_id ้ฟๅบฆไธ่ฝ่ถ
่ฟ32")
@Column(name = "service_category_id")
private String serviceCategoryId;
@Length(max=100,message="image_url ้ฟๅบฆไธ่ฝ่ถ
่ฟ100")
@Column(name = "image_url")
private String imageUrl;
@Column(name = "default_price")
private BigDecimal defaultPrice;
@Length(max=100,message="name ้ฟๅบฆไธ่ฝ่ถ
่ฟ100")
@Column(name = "name")
private String name;
@Length(max=32,message="guid ้ฟๅบฆไธ่ฝ่ถ
่ฟ32")
@NotNull(message = "guid not allow null")
@Id
@Column(name = "guid")
private String guid;
@Length(max=200,message="description ้ฟๅบฆไธ่ฝ่ถ
่ฟ200")
@Column(name = "description")
private String description;
public String getServiceCategoryId() {
return serviceCategoryId;
}
public void setServiceCategoryId(String serviceCategoryId) {
this.serviceCategoryId = serviceCategoryId;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public BigDecimal getDefaultPrice() {
return defaultPrice;
}
public void setDefaultPrice(BigDecimal defaultPrice) {
this.defaultPrice = defaultPrice;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGuid() {
return guid;
}
public void setGuid(String guid) {
this.guid = guid;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
} |
import api.API;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import dao.ProductDetailsContentDao;
import dao.impl.PriceServiceDaoImpl;
import dao.impl.ProductDetailsContentDaoImpl;
import org.glassfish.jersey.server.ResourceConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import server.Server;
import server.ServerException;
import service.impl.ProductDetailsServiceImpl;
/**
* Created by i303874 on 3/18/15.
*/
public class ProductDetailsServiceServer {
private final static Logger logger = LoggerFactory.getLogger(ProductDetailsServiceServer.class);
private static ResourceConfig resourceConfig() {
try {
ResourceConfig resourceConfig = new ResourceConfig();
ObjectMapper om = new ObjectMapper();
om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
om.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
provider.setMapper(om);
resourceConfig.register(provider);
ProductDetailsContentDao productDetailsContentDao = new ProductDetailsContentDaoImpl(new PriceServiceDaoImpl("http://localhost:10001/priceservice"));
resourceConfig.register(new API(new ProductDetailsServiceImpl(productDetailsContentDao)));
return resourceConfig;
} catch (Exception e) {
throw new ServerException(e);
}
}
public static void main(String[] args) {
try {
new Server().run(Server.getPortFromEnv(), resourceConfig()).join();
} catch (Exception e) {
logger.error("running server failed", e);
}
}
}
|
package com.redislabs.research.text;
/**
* Created by dvirsky on 08/02/16.
*/
public interface TextNormalizer {
String normalize(String s);
}
|
package Lector9.Task9_1;
public class Pair <K, V> {
private K Id;
private V Name;
public Pair(){}
public Pair(K Id , V Name){
this.Id = Id;
this.Name = Name;
}
public K getId() {
return Id;
}
public void setId(K id) {
Id = id;
}
public V getName() {
return Name;
}
public void setName(V name) {
Name = name;
}
}
|
import java.io.*;
import java.util.*;
import java.util.stream.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
static double poisson(double mean, long k)
{
return ((Math.pow(Math.E, -mean) * Math.pow(mean, k)) / LongStream.rangeClosed(1, k).reduce((a, b) -> a * b).orElse(1));
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double mean = in.nextDouble();
long n = in.nextLong();
DecimalFormat df = new DecimalFormat("#0.000");
System.out.println(df.format(poisson(mean, n)));
in.close();
}
}
|
package Enum;
public enum DiaSemana {
SEGUNDA,TERCA,QUARTA,QUINTA,SEXTA,SABADO,DOMINGO;
}
|
package simplefactory2;
public class HairFactory {
@SuppressWarnings("static-access")
public Hair getHair(String className){
Hair hair = null ;
try {
hair = (Hair) getClass().forName(className).newInstance();
} catch (Exception e) {
e.printStackTrace();
}
return hair;
}
}
|
package selenium.basics.webdriver;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.chrome.ChromeOptions;
public class IFrameExample {
public static void main(String[] args) {
// Radio button
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY,
System.getProperty("user.dir") + "\\drivers\\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
WebDriver driver = new ChromeDriver(chromeOptions);
driver.navigate().to("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_checkbox");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
System.out.println("Title " + driver.getTitle());
List<WebElement> totalFrames = driver.findElements(By.tagName("iframe"));
System.out.println("Total Frames: " + totalFrames.size());
for (int i = 0; i < totalFrames.size(); i++) {
System.out.println(i + " - " + totalFrames.get(i).getAttribute("name"));
}
//switch frame using index
// driver.switchTo().frame(0);
// WebElement headerTitle = driver.findElement(By.xpath("/html/body/h1"));
// System.out.println(headerTitle.getText());
// driver.switchTo().parentFrame();
// switch to frame using webelement
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@id='iframeResult']")));
WebElement submitBtn = driver.findElement(By.xpath("/html/body/form/input[4]"));
System.out.println("within frame - submit button displayed: " + submitBtn.isDisplayed());
}
}
|
package Bai2;
public class QuanLy extends NhanVien{
public String chucVu;
public String getChucVu() {
return chucVu;
}
public void setChucVu(String chucVu) {
this.chucVu = chucVu;
}
public QuanLy() {
super();
}
public QuanLy(String hoTen, double luong, int namSinh, String chucVu) {
super(hoTen, luong, namSinh);
this.chucVu = chucVu;
}
public void nhap() {
super.nhap();
System.out.println("Nhap chuc vu: ");
chucVu = sc.nextLine();
}
public void xuat() {
super.xuat();
System.out.println("Chuc vu: "+chucVu);
}
}
|
package com.pastelstudios.spring.zookeeper.discovery.http;
import org.springframework.web.client.RestClientException;
public class RestClientServiceDependencyException extends RestClientException {
private static final long serialVersionUID = -2413067908785218043L;
public RestClientServiceDependencyException(String msg) {
super(msg);
}
public RestClientServiceDependencyException(String msg, Throwable ex) {
super(msg, ex);
}
}
|
package com.baiwang.custom.common.entity;
import com.baiwang.custom.common.base.BaseWebServiceInfo;
import com.baiwang.custom.common.model.WSResponseParamModel;
import com.thoughtworks.xstream.XStream;
/**
* @Author: gankunjian
* @Description:
* @Date: Created in 19:58 2018/6/4
* @Modified By:
*/
public abstract class BaseEntity {
public abstract String requestParamCheck(XStream xStream);
protected String getErrorResult(XStream xStream, String msg) {
return BaseWebServiceInfo.RESPONSE_HEADER +
xStream.toXML(new WSResponseParamModel("-1", false, msg, null));
}
}
|
package com.proyectogrado.alternativahorario.alternativahorario.negocio;
import com.proyectogrado.alternativahorario.entidades.Clase;
import com.proyectogrado.alternativahorario.entidades.Horario;
import com.proyectogrado.alternativahorario.persistencia.FachadaPersistenciaHorarioLocal;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
/**
*
* @author Steven
*/
@Stateless
public class AdministracionHorario implements AdministracionHorarioLocal {
@EJB
private FachadaPersistenciaHorarioLocal fachadaPersistenciaHorario;
@Override
public List<Horario> getHorarios() {
return fachadaPersistenciaHorario.findAll();
}
@Override
public List<Horario> getHorariosPorClase(Clase clase){
return fachadaPersistenciaHorario.findByClase(clase);
}
@Override
public boolean eliminarHorario(Horario horario) {
try {
Horario horarioEliminar = fachadaPersistenciaHorario.find(horario.getId());
fachadaPersistenciaHorario.remove(horarioEliminar);
} catch (Exception e) {
System.out.println("Ocurrio un error eliminando la Horario " + horario.getId());
return false;
}
return true;
}
@Override
public List<Horario> eliminarHorarios(List<Horario> horarios) {
for (Horario horario : horarios) {
eliminarHorario(horario);
}
return null;
}
@Override
public boolean agregarHorario(Horario horario) {
try {
fachadaPersistenciaHorario.create(horario);
} catch (Exception e) {
System.out.println("Ocurrio un error creacion la horario " + horario.getId());
return false;
}
return true;
}
}
|
/*
* ServiceBus inter-component communication bus
*
* Copyright (c) 2021- Rob Ruchte, rob@thirdpartylabs.com
*
* Licensed under the License specified in file LICENSE, included with the source code.
* You may not use this file except in compliance with the License.
*
* 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.thirdpartylabs.servicebus;
/**
* Singleton to hold instances of the three communication busses
*/
public class ServiceBus
{
public final CommandBus commands = CommandBus.getInstance();
public final EventBus events = EventBus.getInstance();
public final RequestResponseBus reqRes = RequestResponseBus.getInstance();
private static final ServiceBus instance = new ServiceBus();
private ServiceBus()
{
}
/**
* Return the single instance of the ServiceBus
*
* @return ServiceBus instance
*/
public static ServiceBus getInstance()
{
return instance;
}
/**
* Shut down the thread executors
*/
public void shutdown()
{
commands.shutdown();
events.shutdown();
reqRes.shutdown();
}
}
|
package org.mytvstream.converter;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import com.xuggle.xuggler.ICodec.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.xuggle.xuggler.*;
import com.xuggle.xuggler.IAudioSamples.Format;
/**
* Convert any input stream to flv for rtmp streaming.
* @author cbrunner
*
*/
public class XugglerConverter extends Converter {
// input variables
IContainer icontainer;
IContainerFormat icontainerFormat;
IPacket iPacket;
IAudioSamples iAudioSamples;
IVideoPicture iPicture;
// input streams index
int iAudioStreamIndex = -1;
int iVideoStreamIndex = -1;
// output variables
IContainer ocontainer;
IContainerFormat ocontainerFormat;
IPacket oAudioPacket;
IPacket oVideoPacket;
IAudioSamples oTranscodedSamples;
IAudioSamples oAudioSamples;
int audioConsumed = 0;
IVideoPicture oConvertedPicture;
// output streams index
int oAudioStreamIndex = -1;
int oVideoStreamIndex = -1;
int audioPacketWritten = 0;
// audio resampler
IAudioResampler audioResampler;
// video resampler
IVideoResampler videoResampler;
// static attributes
static int VIDEO_WIDTH = 480;
static int VIDEO_HEIGHT = 270;
static final Logger logger = LoggerFactory.getLogger(XugglerConverter.class);
/**
* Print informations about xuggler
*/
/*
static {
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(os);
Configuration.printSupportedContainerFormats(ps);
Configuration.printSupportedCodecs(ps);
String output;
try {
output = os.toString("UTF8");
logger.debug(output);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
*/
/**
* Open media let's set the url of the reading media
* @param mediaFile : url of the media files from the following formats (http, file)
* @param inputFormat : Set the format of the media (avi, mov, flv, mkv, ts ...)
*/
public boolean openMedia(String mediaFile, ConverterFormatEnum inputFormat) throws ConverterException
{
icontainer = IContainer.make();
icontainerFormat = IContainerFormat.make();
int i = icontainerFormat.setInputFormat(getConverterFormat(inputFormat));
if (i<0) {
throw new ConverterException("failed to set input format " + inputFormat);
}
i = icontainer.open(mediaFile, IContainer.Type.READ, icontainerFormat);
if (i < 0) {
throw new ConverterException("could not open input media");
}
logger.debug(icontainer.toString());
//System.out.println(icontainer.toString());
return true;
}
/**
* openOutput : define the converter's output file
* @param mediaFile : url of the media file to be created
* @param outputFormat : Force the output format.
*/
public boolean openOutput(String mediaFile, ConverterFormatEnum outputFormat) throws ConverterException
{
ocontainer = IContainer.make();
ocontainerFormat = IContainerFormat.make();
ocontainerFormat.setOutputFormat(getConverterFormat(outputFormat), null, null);
int i = ocontainer.open(mediaFile, IContainer.Type.WRITE, ocontainerFormat);
if (i < 0 ) {
throw new ConverterException("could not open output media");
}
logger.debug(ocontainer.toString());
return true;
}
/**
* open converter output using an output stream
* @param stream : Output stream for writing
* @param outputFormat : Output format to produce
* @return success / false
* @throws ConverterException
*/
public boolean openOutput(OutputStream stream, ConverterFormatEnum outputFormat) throws ConverterException {
ocontainer = IContainer.make();
ocontainerFormat = IContainerFormat.make();
ocontainerFormat.setOutputFormat(getConverterFormat(outputFormat), null, null);
//avoid crash with OutputStream
ocontainer.setFormat(ocontainerFormat);
int i = ocontainer.open(stream, ocontainerFormat);
if (i < 0 ) {
throw new ConverterException("could not open output media");
}
logger.debug(ocontainer.toString());
return true;
}
/**
* Helper reading streams from
* @param audioLanguage : Preferred audio language to use in the conversion (only one audio language will be transcoded).
*/
public void setupReadStreams(String audioLanguage)
{
for (int i = 0 ; i < icontainer.getNumStreams(); i++) {
IStream stream = icontainer.getStream(i);
IStreamCoder coder = stream.getStreamCoder();
if (coder.getCodecType() == Type.CODEC_TYPE_VIDEO) {
iVideoStreamIndex = i;
}
if (coder.getCodecType() == Type.CODEC_TYPE_AUDIO) {
if (iAudioStreamIndex == -1)
{
iAudioStreamIndex = i;
}
if (stream.getLanguage() != null && stream.getLanguage().equals(audioLanguage)) {
iAudioStreamIndex = i;
}
}
}
logger.debug("Found video stream at " + iVideoStreamIndex);
logger.debug("Found audio stream at " + iAudioStreamIndex);
}
/**
* Writes the streams to the output container created by openOutput call
* @param videoCodecName : Preferred video codec name, for FLV use either flv1 or libx264
* @param videoBitrate : Desired bitrate for the video
* @param audioCodecName : Preferred audio codec name, for FLV use either libmp3lame or libvo_aacenc
* @param audioBitrate : Desired bitrate for the audio (64000 may be ok).
* @throws Exception
*/
public void setupWriteStreams(ConverterCodecEnum videoEncoder, int videoBitrate, ConverterCodecEnum audioEncoder, int audioBitrate) throws ConverterException
{
// setup the output video stream
ICodec videoCodec = ICodec.findEncodingCodecByName(getEncoderName(videoEncoder));
if (videoCodec == null) {
throw new ConverterException("could not find video encoder codec");
}
IStream videoStream = ocontainer.addNewStream(videoCodec);
IStreamCoder videoCoder = videoStream.getStreamCoder();
videoCoder.setBitRate(videoBitrate);
// fps 25
videoCoder.setTimeBase(IRational.make(1, 25));
videoCoder.setPixelType(IPixelFormat.Type.YUV420P);
// height and width from input container
videoCoder.setHeight(VIDEO_HEIGHT);
videoCoder.setWidth(VIDEO_WIDTH);
logger.debug("video height = " + videoCoder.getHeight() + ", width =" + videoCoder.getWidth());
oVideoStreamIndex = videoStream.getIndex();
// setup the output audio stream
ICodec audioCodec = ICodec.findEncodingCodecByName(getEncoderName(audioEncoder));
if (audioCodec == null)
{
throw new ConverterException("could not find audio encoder codec");
}
IStream audioStream = ocontainer.addNewStream(audioCodec);
IStreamCoder audioCoder = audioStream.getStreamCoder();
audioCoder.setSampleRate(44100);
audioCoder.setTimeBase(IRational.make(1, 44100));
audioCoder.setChannels(2);
audioCoder.setBitRate(audioBitrate);
if (audioEncoder == ConverterCodecEnum.VORBIS) {
audioCoder.setSampleFormat(Format.FMT_FLT);
}
else {
audioCoder.setSampleFormat(Format.FMT_S16);
}
oAudioStreamIndex = audioStream.getIndex();
// once finished write header
}
protected boolean CanHandle(String inputUrl, ConverterFormatEnum inputFormat, String outputUrl, ConverterFormatEnum outputFormat)
{
logger.debug("Calling canHandle from xugglerconverter");
return true;
}
/**
* Process a video packet:
* - Decode the video packet from input container
* - Encode the video packet into output container
* - Write the packet to output stream
* @throws Exception
*/
protected void processVideo() throws ConverterException
{
int rv = icontainer.getStream(iVideoStreamIndex).getStreamCoder().decodeVideo(iPicture, iPacket, 0);
if (rv < 0)
throw new ConverterException("error decoding video " + rv);
// if this is a complete picture, dispatch the picture
if (iPicture.isComplete()) {
videoResampler.resample(oConvertedPicture, iPicture);
if (oConvertedPicture.isComplete()) {
if (ocontainer.getStream(oVideoStreamIndex).getStreamCoder().encodeVideo(oVideoPacket, oConvertedPicture, 0) < 0)
throw new ConverterException("failed to encode video");
if (oVideoPacket.isComplete()) {
int result = ocontainer.writePacket(oVideoPacket, true);
if (result < 0 ) {
throw new ConverterException("Failed to write video to output");
}
oVideoPacket.delete();
oVideoPacket = IPacket.make();
}
}
}
}
/**
* Process a audio packet:
* - Decode the audio packet from input container
* - Encode the audio packet into output container
* - Write the packet to output stream
* @throws Exception
*/
protected void processAudio() throws ConverterException
{
// packet may contain multiple audio frames, decode audio until
// all audio frames are extracted from the packet
int offset = 0;
while (offset < iPacket.getSize())
{
// decode audio
int bytesDecoded = icontainer.getStream(iAudioStreamIndex).getStreamCoder().decodeAudio(iAudioSamples, iPacket, offset);
if (bytesDecoded < 0)
throw new ConverterException("error " + bytesDecoded + " decoding audio");
offset += bytesDecoded;
audioResampler.resample(oTranscodedSamples, iAudioSamples, iAudioSamples.getNumSamples());
//oTranscodedSamples.setTimeStamp(iAudioSamples.getTimeStamp());
for (;audioConsumed < oTranscodedSamples.getNumSamples(); /* in loop */)
{
// encode audio
int result = ocontainer.getStream(oAudioStreamIndex).getStreamCoder().encodeAudio(oAudioPacket, oTranscodedSamples, audioConsumed);
if (result < 0)
throw new ConverterException("failed to encode audio");
// update total consumed
audioConsumed += result;
// if a complete packed was produced write it out
if (oAudioPacket.isComplete()) {
audioPacketWritten++;
if (audioPacketWritten % 20 == 0) {
logger.trace("writing audio packet");
ocontainer.flushPackets();
}
result = ocontainer.writePacket(oAudioPacket, true);
if (result < 0 ) {
throw new ConverterException("Failed to write to output");
}
oAudioPacket.delete();
oAudioPacket = IPacket.make();
}
}
if (audioConsumed >= oTranscodedSamples.getNumSamples()) {
audioConsumed = 0;
}
}
}
/**
* Main processing loop, reading packet from input container and processing that packet.
* @throws Exception
*/
@Override
protected void mainLoop() throws ConverterException
{
final String orgName = Thread.currentThread().getName();
Thread.currentThread().setName(orgName + " - Xuggler Thread");
closed = false;
iPacket = IPacket.make();
oAudioPacket = IPacket.make();
oVideoPacket = IPacket.make();
iAudioSamples = IAudioSamples.make(4096, 2);
oTranscodedSamples = IAudioSamples.make(4096,2);
iPicture = IVideoPicture.make(icontainer.getStream(iVideoStreamIndex).getStreamCoder().getPixelType(),
icontainer.getStream(iVideoStreamIndex).getStreamCoder().getWidth(),
icontainer.getStream(iVideoStreamIndex).getStreamCoder().getHeight()
);
oConvertedPicture = IVideoPicture.make(ocontainer.getStream(oVideoStreamIndex).getStreamCoder().getPixelType(),
ocontainer.getStream(oVideoStreamIndex).getStreamCoder().getWidth(),
ocontainer.getStream(oVideoStreamIndex).getStreamCoder().getHeight()
);
icontainer.getStream(iAudioStreamIndex).getStreamCoder().open(null,null);
ocontainer.getStream(oAudioStreamIndex).getStreamCoder().open(null,null);
icontainer.getStream(iVideoStreamIndex).getStreamCoder().open(null,null);
ocontainer.getStream(oVideoStreamIndex).getStreamCoder().open(null,null);
audioResampler = IAudioResampler.make(2, 2, 44100, icontainer.getStream(iAudioStreamIndex).getStreamCoder().getSampleRate());
if (audioResampler == null)
{
throw new ConverterException("can't setup audio resampler");
}
videoResampler = IVideoResampler.make(VIDEO_WIDTH, VIDEO_HEIGHT, IPixelFormat.Type.YUV420P,
icontainer.getStream(iVideoStreamIndex).getStreamCoder().getWidth(),
icontainer.getStream(iVideoStreamIndex).getStreamCoder().getHeight(),
icontainer.getStream(iVideoStreamIndex).getStreamCoder().getPixelType()
);
if (videoResampler == null)
{
throw new ConverterException("can't setup video resampler");
}
ocontainer.writeHeader();
while (icontainer.readNextPacket(iPacket) >= 0 && !closed) {
if (iPacket.getStreamIndex() == iAudioStreamIndex)
{
processAudio();
}
if (iPacket.getStreamIndex() == iVideoStreamIndex)
{
processVideo();
}
}
iPacket.delete();
oAudioPacket.delete();
oVideoPacket.delete();
iAudioSamples.delete();
oTranscodedSamples.delete();
iPicture.delete();
oConvertedPicture.delete();
ocontainer.writeTrailer();
ocontainer.getStream(oAudioStreamIndex).getStreamCoder().close();
ocontainer.getStream(oVideoStreamIndex).getStreamCoder().close();
ocontainer.close();
icontainer.getStream(iAudioStreamIndex).getStreamCoder().close();
icontainer.getStream(iVideoStreamIndex).getStreamCoder().close();
icontainer.close();
}
protected String getEncoderName(ConverterCodecEnum codec) {
if (codec.equals(ConverterCodecEnum.H264)) {
return "libx264";
}
if (codec.equals(ConverterCodecEnum.AAC)) {
//return "libvo_aacenc";
return "aac";
}
if (codec.equals(ConverterCodecEnum.MP3)) {
return "libmp3lame";
}
if (codec.equals(ConverterCodecEnum.FLV1)) {
return "flv";
}
if (codec.equals(ConverterCodecEnum.VORBIS)) {
return "libvorbis";
}
if (codec.equals(ConverterCodecEnum.THEORA)) {
return "libtheora";
}
if (codec.equals(ConverterCodecEnum.VP8)) {
return "libvpx";
}
return null;
}
protected String getConverterFormat(ConverterFormatEnum format) {
if (format.equals(ConverterFormatEnum.FLV))
return "flv";
if (format.equals(ConverterFormatEnum.OGG))
return "ogg";
if (format.equals(ConverterFormatEnum.MKV))
return "matroska";
if (format.equals(ConverterFormatEnum.HLS))
return "applehttp";
if (format.equals(ConverterFormatEnum.WEBM))
return "webm";
return "";
}
}
|
/*
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.reactive.result.method.annotation;
import java.util.Map;
import org.springframework.core.MethodParameter;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.ui.Model;
import org.springframework.web.reactive.BindingContext;
import org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport;
import org.springframework.web.reactive.result.method.SyncHandlerMethodArgumentResolver;
import org.springframework.web.server.ServerWebExchange;
/**
* Resolver for a controller method argument of type {@link Model} that can
* also be resolved as a {@link java.util.Map}.
*
* <p>A Map return value can be interpreted in more than one way depending
* on the presence of annotations like {@code @ModelAttribute} or
* {@code @ResponseBody}. As of 5.2 this resolver returns false if a
* parameter of type {@code Map} is also annotated.
*
* @author Rossen Stoyanchev
* @since 5.2
*/
public class ModelMethodArgumentResolver extends HandlerMethodArgumentResolverSupport
implements SyncHandlerMethodArgumentResolver {
public ModelMethodArgumentResolver(ReactiveAdapterRegistry adapterRegistry) {
super(adapterRegistry);
}
@Override
public boolean supportsParameter(MethodParameter param) {
return checkParameterTypeNoReactiveWrapper(param, type ->
Model.class.isAssignableFrom(type) ||
(Map.class.isAssignableFrom(type) && param.getParameterAnnotations().length == 0));
}
@Override
public Object resolveArgumentValue(
MethodParameter parameter, BindingContext context, ServerWebExchange exchange) {
Class<?> type = parameter.getParameterType();
if (Model.class.isAssignableFrom(type)) {
return context.getModel();
}
else if (Map.class.isAssignableFrom(type)) {
return context.getModel().asMap();
}
else {
// Should never happen..
throw new IllegalStateException("Unexpected method parameter type: " + type);
}
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.