text
stringlengths 10
2.72M
|
|---|
package shangguigu;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* Condition:可指定唤醒线程,效率较notifyAll高
* @param <T>
*/
public class Thread21<T> {
List<T> list = new ArrayList<>();
Lock lock = new ReentrantLock();
private Condition producer = lock.newCondition();
private Condition consumer = lock.newCondition();
public void set(T t) {
while (true) {
try {
lock.lock();
if (list.size() == 10) {
try {
System.out.println("产品已满,请通知消费者消费");
producer.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
list.add(t);
System.out.println("生产者生产" + t);
consumer.signalAll();
} finally {
lock.unlock();
}
}
}
public T get() {
while (true) {
try {
lock.lock();
if (list.size() == 0) {
try {
System.out.println("产品为空,请通知生产者生产");
consumer.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
T t = list.remove(0);
producer.signalAll();
System.out.println(Thread.currentThread().getName() + "得到" + t);
} finally {
lock.unlock();
}
}
}
public static void main(String[] args) {
Thread20<String> thread20 = new Thread20<>();
new Thread(() -> thread20.get()).start();
new Thread(() -> thread20.set("苹果")).start();
}
}
|
package net.julisapp.riesenkrabbe;
import android.content.Context;
import junit.framework.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import net.julisapp.riesenkrabbe.background.utilities.DateStringUtility;
import static org.mockito.Mockito.when;
/**
* Created by antonio on 17.11.16.
* Used for Testingpurposes for methods in DateStringUtility.
* <p>
* Because testing is good.
*/
@RunWith(MockitoJUnitRunner.class)
public class testDateStringUtilities {
// https://developer.android.com/training/testing/unit-testing/local-unit-tests.html#build
@Mock
Context mMockContext;
@Test
public void testSingleDateString() {
long date = 1479764349L; //21.11.2016
String dateString = DateStringUtility.getSingleDateString(date);
Assert.assertEquals("Unexpected return from getSingleDateString", "21.11.2016", dateString);
}
@Test
public void testDurationString() {
when(mMockContext.getString(R.string.yesteryesterday))
.thenReturn("Vorgestern");
when(mMockContext.getString(R.string.yesterday))
.thenReturn("Gestern");
when(mMockContext.getString(R.string.today))
.thenReturn("Heute");
when(mMockContext.getString(R.string.tomorrow))
.thenReturn("Morgen");
when(mMockContext.getString(R.string.tomorrowmorrow))
.thenReturn("Übermorgen");
when(mMockContext.getString(R.string.list_item_date_sameday))
.thenReturn("%1$s, %2$s – %3$s");
when(mMockContext.getString(
R.string.list_item_date_diffday)).thenReturn("%1$s, %2$s – %3$s, %4$s");
long timestampNow = Calendar.getInstance().getTime().getTime();
String todayString = DateStringUtility.callGetDateRelationalText(timestampNow, mMockContext);
Assert.assertEquals("Unexpected answer in DateStringUtility.getDateRelationalText", "Heute", todayString);
long timestampTomorrow = timestampNow + 86400000;// Milliseconds in a day
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm", Locale.GERMANY);
// Convert milliseconds back to seconds because now we call methods which expect those.
String startTimeString = formatter.format(new Date(timestampNow));
String endTimeString = formatter.format(new Date(timestampTomorrow));
String expectedAnswer = String.format(mMockContext.getString(
R.string.list_item_date_diffday),
"Heute",
startTimeString,
"Morgen",
endTimeString);
String actualAnswer = DateStringUtility.buildDateDurationString(timestampNow / 1000, timestampTomorrow / 1000, mMockContext);
Assert.assertEquals("Unexpected answer in DateStringUtility.buildDateDurationString", expectedAnswer, actualAnswer);
}
}
|
package com.techelevator;
import com.techelevator.VolunteerWorker;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
public class VolunteerWorkerTest {
@Test
public void volunteers_make_no_money () {
VolunteerWorker test = new VolunteerWorker("Jacob","Peralta");
Assert.assertEquals(0, (int)test.calculateWeeklyPay(100));
}
}
|
package org.wltea.analyzer.util;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
/**
* 字符工具类
*
* @author shouyilin
*
*/
public class CharsetUtil {
public static boolean isSupported(String charsetName) {
if (StringUtil.isEmpty(charsetName)) {
return false;
}
try {
return Charset.isSupported(charsetName);
} catch (IllegalCharsetNameException e) {
}
return false;
}
public static Charset forName(String charsetName) {
if (StringUtil.isEmpty(charsetName)) {
return null;
}
try {
return Charset.forName(charsetName);
} catch (Exception e) {
}
return null;
}
}
|
package com.superman.multichannel;
import android.app.Application;
import com.umeng.commonsdk.UMConfigure;
/**
* 作者 Superman
* 日期 2018/12/28 10:51.
* 文件 AndroidMultiChannelPackage
* 描述
*/
public class MyApplication extends Application {
/**
* 参数1:上下文,必须的参数,不能为空
* 参数2:友盟 app key,非必须参数,如果Manifest文件中已配置app key,该参数可以传空,则使用Manifest中配置的app key,否则该参数必须传入
* 参数3:友盟 channel,非必须参数,如果Manifest文件中已配置channel,该参数可以传空,则使用Manifest中配置的channel,否则该参数必须传入,channel命名请详见channel渠道命名规范
* 参数4:设备类型,必须参数,传参数为UMConfigure.DEVICE_TYPE_PHONE则表示手机;传参数为UMConfigure.DEVICE_TYPE_BOX则表示盒子;默认为手机
* 参数5:Push推送业务的secret,需要集成Push功能时必须传入Push的secret,否则传空
*/
@Override
public void onCreate() {
super.onCreate();
// UMConfigure.init(this,);
}
}
|
package br.inf.ufg.mddsm.broker.resource;
import base.common.Signal;
import br.inf.ufg.mddsm.broker.manager.SignalInstance;
public interface Effector {
Object execute(SignalInstance signal);
}
|
public class Work {
public static void main(String[] args) {
IDriver xiaoMing = new Driver();
ICar volkswagen = new Volkswagen();
ICar bmw = new BMW();
//小明开他自己的大众车上班
xiaoMing.drive(volkswagen);
//小明开他父亲的宝马车上班
xiaoMing.drive(bmw);
}
}
|
package org.livingdoc.fixture.api.converter;
import java.lang.reflect.AnnotatedElement;
public interface TypeConverter<T> {
default T convert(String value) throws ConversionException {
return convert(value, null);
}
T convert(String value, AnnotatedElement element) throws ConversionException;
}
|
package fileTransPack;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class ReceiverFrame extends JFrame{
/**
* Server GUI Frame
*/
private static final long serialVersionUID = -6908010068571328476L;
private final JTextArea textArea = new JTextArea();
private final JPanel panel = new JPanel();
private final Label label = new Label("Port");
private final JTextField textField = new JTextField();
private final JButton btnStartListening = new JButton("Start Listening");
private final JButton btnStopListening = new JButton("Stop Listening");
private Boolean breakflag = false;
private ReceiverThread rt;
private final JButton btnPaste = new JButton("Paste");
public ReceiverFrame(final JTextArea txtArea) {
textField.setText("10086");
textField.setColumns(10);
setTitle("Text Receiver");
getContentPane().add(textArea, BorderLayout.CENTER);
getContentPane().add(panel, BorderLayout.SOUTH);
panel.add(label);
panel.add(textField);
panel.add(btnStartListening);
panel.add(btnStopListening);
btnStopListening.setEnabled(false);
//Add event of clicking paste button
btnPaste.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
String text = textArea.getText();
if(txtArea.getText().equals(""))
txtArea.setText(text);
else
txtArea.append("\n" + text);
}
});
panel.add(btnPaste);
//Add event of clicking start receiver
btnStartListening.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
breakflag = false;
btnStartListening.setEnabled(false);
btnStopListening.setEnabled(true);
rt = new ReceiverThread(textArea, Integer.parseInt(textField.getText()), breakflag);
rt.start();
}
});
//Add event of clicking halt receiver
btnStopListening.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if(!rt.serversocket.isClosed()) {
try {
rt.serversocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
breakflag = true;
btnStopListening.setEnabled(false);
btnStartListening.setEnabled(true);
}
});
}
}
//Uses a thread to host a server, in order to receive text from the sender.
class ReceiverThread extends Thread {
private Boolean breakflag;
private JTextArea textField;
private int port;
public ServerSocket serversocket;
private Socket client;
public ReceiverThread(JTextArea textField, int port, Boolean breakflag) {
super();
this.textField = textField;
this.port = port;
this.breakflag = breakflag;
}
//Start receiver thread
@Override
public void run() {
try {
serversocket = new ServerSocket(port);
} catch (IOException e1) {
JOptionPane.showMessageDialog(null, "Failed to run serversocket.", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
while (breakflag == false) {
try {
client = serversocket.accept();
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream()));
PrintWriter writer = new PrintWriter(client.getOutputStream(), true);
//String line = reader.readLine();
//textField.append(line + "\r\n");
String line = reader.readLine();
while(line != null) {
textField.append(line + "\r\n");
line = reader.readLine();
}
writer.close();
reader.close();
client.close();
} catch (IOException e1) {
JOptionPane.showMessageDialog(null, "Server closed.", "Alert", JOptionPane.WARNING_MESSAGE);
return;
}
}
breakflag = false;
try {
serversocket.close();
} catch (IOException e) {
JOptionPane.showMessageDialog(null, "Failed to stop serversocket.", "Error", JOptionPane.ERROR_MESSAGE);
}
JOptionPane.showMessageDialog(null, "Break.", "Alert", JOptionPane.WARNING_MESSAGE);
return;
}
}
|
package com.example.android.mediaplayer;
/**
* Created by jaydutt on 14/01/2018.
*/
public class Song
{
private String name;
private int songReference;
private String Details="No Detail Available";
public Song(String s,int reference)
{
name=s;
songReference=reference;
}
public Song(String s,String detail,int reference)
{
name=s;
Details=detail;
songReference=reference;
}
String getName()
{
return name;
}
int getSongReference()
{
return songReference;
}
String getDetails()
{
return Details;
}
}
|
package com.tencent.d.b.c;
class a$2 implements Runnable {
final /* synthetic */ a vlT;
a$2(a aVar) {
this.vlT = aVar;
}
public final void run() {
this.vlT.vlR.cancel();
}
}
|
package org.bashemera.openfarm.service;
import java.util.List;
import java.util.Optional;
import org.bashemera.openfarm.model.AnimalType;
import org.bashemera.openfarm.repository.AnimalTypeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class AnimalTypeManager implements AnimalTypeService {
@Autowired
private AnimalTypeRepository animalTypeRepository;
@Override
public AnimalType getAnimalById(String id) {
Optional<AnimalType> optionalEntity = animalTypeRepository.findById(id);
if (optionalEntity.isPresent()) {
return optionalEntity.get();
}
return null;
}
@Override
public List<AnimalType> getAnimalTypes(){
return animalTypeRepository.findAll();
}
}
|
/*
* Copyright (C) 2015 Raphael P. Barazzutti
*
* 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 ch.fever.insomnia;
import java.util.Optional;
/**
* Insomnia class
*
* Subclasses of this one are targeting various operating systems (up to now, Microsoft Windows and Apple OSX). Obviously
* these methods might behave in a weird manner if accessed in a concurrent way.
*
* Insomnia subclasses give no guarantee in term of synchronization, it's up to the developer to handle this. We expect that
* in normal usage of Insomnia, the application does not face such issues. This framework does not address concurrency,
* if your software might access under some circumstances concurrently Insomnia, please use the appropriate synchronization
* mechanism to avoid any issue.
*/
public interface Insomnia {
/**
* Change the standby behavior of the machine
*
* @param insomniaMode mode to be requested
* @return true if the request has been properly processed by the operating system
*/
default boolean apply(InsomniaMode insomniaMode) {
return apply(insomniaMode, "No reason given");
}
/**
* Change the standby behavior of the machine
*
* @param insomniaMode mode to be requested
* @param reason reason invoked
* @return true if the request has been properly processed by the operating system
*/
boolean apply(InsomniaMode insomniaMode, String reason);
/**
* @return a singleton of the insomnia
* @throws UnsupportedArchitectureException if no support is available on the current architecture
*/
static Insomnia getInstance() throws UnsupportedArchitectureException {
return InsomniaHelper.getNonNullInstance();
}
/**
* @return a optional containing the singleton of the insomnia
*/
static Optional<Insomnia> getOptInstance() {
return Optional.ofNullable(InsomniaHelper.getInstance());
}
}
|
/**
*
* @author Nathan
*/
public class Character
{
private String name;
private final Item[] bag;
private int nextFreeSpace;
private String notebook;
private Area location;
public Character(String name, Area start)
{
this.name = name;
this.bag = new Item[10];
this.nextFreeSpace = 0;
this.notebook = "";
location = start;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getBagContents()
{
return bag.toString();
}
public void pickUp(Item item)
{
bag[nextFreeSpace] = item;
bag[nextFreeSpace].setBagIndex(nextFreeSpace);
nextFreeSpace++;
}
public void drop(Item item)
{
bag[item.getBagIndex()] = null;
nextFreeSpace--;
}
public String getNotebook()
{
return notebook;
}
public void setNotebook(String notebook)
{
this.notebook = notebook;
}
public void setLocation(Area location)
{
this.location = location;
}
public Area getLocation()
{
return this.location;
}
}
|
package io;
/**
* Enumeration to represent RGB color channel
*/
public enum RGB {
RED(16), GREEN(8), BLUE(0);
private int numVal;
RGB(int numVal) {
this.numVal = numVal;
}
private int getNumVal() {
return numVal;
}
/**
* Get color channel value from int representation of pixel
* <pre>
* AAAAAAAA RRRRRRRR GGGGGGGG BBBBBBBB
* ^Alpha ^Red ^Green ^Blue
* </pre>
*
* @param rgb Pixel as RGB int representation
* @param channel Color channel as io.RGB
* @return Color channel of the pixel as integer
*/
public static int getChannelValue(int rgb, RGB channel) {
return rgb >> channel.getNumVal() & 0xff;
}
/**
* Parse a string representation of the enumeration
* @param name Name of the color (RED, GREEN, BLUE)
* @return An enum corresponding to the name
*/
public static RGB parse(String name) {
switch (name) {
case "RED":
return RGB.RED;
case "GREEN":
return RGB.GREEN;
case "BLUE":
return RGB.BLUE;
default:
throw new IllegalArgumentException("Name couldn't be parsed " + name);
}
}
}
|
package com.sunzequn.sdfs.test;
import com.sunzequn.sdfs.node.DataNode;
import com.sunzequn.sdfs.node.NodeInfo;
import java.io.File;
/**
* Created by Sloriac on 2016/12/18.
*/
public class SockClient2Test {
public static void main(String[] args) {
NodeInfo selfInfo = new NodeInfo("2", "localhost", 2222);
NodeInfo leader = new NodeInfo("0", "localhost", 1111);
DataNode dataNode = new DataNode(selfInfo, leader, "/home/sloriac/data/2/");
dataNode.start(true);
}
}
|
/*
* created 03.06.2005
*
* Copyright 2009, ByteRefinery
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* $Id: ParserErrors.java 148 2006-01-30 20:40:59Z csell $
*/
package com.byterefinery.rmbench.util.xml;
import java.text.MessageFormat;
import org.eclipse.osgi.util.NLS;
/**
* @author cse
*/
public class ParserErrors {
private static final String BUNDLE_NAME = ParserErrors.class.getName();
public static String messagePrefix;
public static String startTagExpected;
public static String endTagExpected;
public static String tagExpected;
public static String errorUndefinedDbInfo;
public static String errorUndefinedType;
public static String errorUndefinedSchema;
public static String warnUndefinedSchemaInDiagram;
public static String errorUndefinedTable;
public static String errorUndefinedGenerator;
public static String message(String fileName, int lineNumber, String message, Object[] args) {
Object[] prefixArgs = new Object[]{fileName, new Integer(lineNumber)};
String prefix = MessageFormat.format(messagePrefix, prefixArgs);
return args != null ?
prefix + " "+MessageFormat.format(message, args) :
prefix + " "+message;
}
static {
NLS.initializeMessages(BUNDLE_NAME, ParserErrors.class);
}
}
|
import java.util.Scanner;
public class ProsteDodawanie {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int ileRazy = in.nextInt();
int suma=0;
int ileLiczb= 3;
int tabWyn[] = new int[ileRazy];
for (int i=0; i<ileRazy;i++){
ileLiczb = in.nextInt();
suma = 0;
for ( int j=0; j<ileLiczb;j++){
suma= suma+in.nextInt();
}
//
tabWyn[i]=suma;
// for (i=0; i<ileRazy; i++){
// tabWyn[i]=suma;
//
// }
}
for (int k=0; k<ileRazy;k++){
System.out.println(tabWyn[k]);
suma=0;
}
}
}
|
package com.tencent.tencentmap.mapsdk.a;
import java.util.List;
public class my {
private oe a = null;
public my(oe oeVar) {
this.a = oeVar;
}
public void a() {
if (this.a != null) {
this.a = null;
}
}
public final pd a(pe peVar) {
if (this.a == null) {
return null;
}
return this.a.a(peVar, this);
}
public final void a(String str) {
if (this.a != null) {
this.a.a(str);
}
}
public final void a(String str, int i) {
if (this.a != null) {
this.a.a(str, i);
}
}
public final void a(String str, List<ox> list) {
if (this.a != null) {
this.a.a(str, (List) list);
}
}
public final void b(String str, int i) {
if (this.a != null) {
this.a.b(str, i);
}
}
public final void a(String str, float f) {
if (this.a != null) {
this.a.a(str, f);
}
}
public final void a(String str, boolean z) {
if (this.a != null) {
this.a.a(str, z);
}
}
public final void b(String str, float f) {
if (this.a != null) {
this.a.b(str, f);
}
}
public final void b() {
if (this.a != null) {
this.a.b();
}
}
}
|
package com.classcheck.gen;
import java.util.Map;
public class MessagesReplace extends Replace{
private Map<String, String> messagesMap;
public MessagesReplace(String base, Map<String, String> messagesMap) {
super(base);
this.messagesMap = messagesMap;
}
public void changeMessages(){
String aftMessage = null;
for(String befMessage : messagesMap.keySet()){
aftMessage = messagesMap.get(befMessage);
super.setBefore(befMessage);
super.setAfter(aftMessage);
super.replace();
}
}
@Override
public boolean canChange() {
return line.contains(before) && !lineNumList.contains(new Integer(lineNum));
}
}
|
package shared.model;
import com.thoughtworks.xstream.annotations.XStreamAlias;
@XStreamAlias("field")
public class Field
{
private int id;
@XStreamAlias("title")
private String title;
@XStreamAlias("xcoord")
private int xcoord;
@XStreamAlias("width")
private int width;
@XStreamAlias("helphtml")
private String helphtml;
@XStreamAlias("knowndata")
private String knowndata;
private int project_id;
/**
* @param id
* @param title
* @param xcoord
* @param width
* @param helphtml
* @param knowndata
* @param project_id
*/
public Field(int id, String title, int xcoord, int width, String helphtml,
String knowndata, int project_id)
{
this.id = id;
this.title = title;
this.xcoord = xcoord;
this.width = width;
this.helphtml = helphtml;
this.knowndata = knowndata;
this.project_id = project_id;
}
public Field(int id, String title, int project_id)
{
this.id = id;
this.title = title;
this.project_id = project_id;
}
/**
* @return the id
*/
public int getId()
{
return id;
}
/**
* @param id the id to set
*/
public void setId(int id)
{
this.id = id;
}
/**
* @return the title
*/
public String getTitle()
{
return title;
}
/**
* @param title the title to set
*/
public void setTitle(String title)
{
this.title = title;
}
/**
* @return the xcoord
*/
public int getXcoord()
{
return xcoord;
}
/**
* @param xcoord the xcoord to set
*/
public void setXcoord(int xcoord)
{
this.xcoord = xcoord;
}
/**
* @return the width
*/
public int getWidth()
{
return width;
}
/**
* @param width the width to set
*/
public void setWidth(int width)
{
this.width = width;
}
/**
* @return the helphtml
*/
public String getHelphtml()
{
return helphtml;
}
/**
* @param helphtml the helphtml to set
*/
public void setHelphtml(String helphtml)
{
this.helphtml = helphtml;
}
/**
* @return the knowndata
*/
public String getKnowndata()
{
return knowndata;
}
/**
* @param knowndata the knowndata to set
*/
public void setKnowndata(String knowndata)
{
this.knowndata = knowndata;
}
/**
* @return the project_id
*/
public int getProject_id()
{
return project_id;
}
/**
* @param project_id the project_id to set
*/
public void setProject_id(int project_id)
{
this.project_id = project_id;
}
}
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package fr.aurelien.swingDB.DAO;
import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import fr.aurelien.swingDB.entity.Student;
/**
*
* @author formation
*/
public class StudentDAO implements DAOInterface<Student, StudentDAO> {
private Connection dbConnection;
private PreparedStatement pstm;
private ResultSet resultSet;
public StudentDAO(Connection dbConnection) {
this.dbConnection = dbConnection;
}
// un objet de type Student
/**
* Persistance de l'entité Student
*
* @param entity
* @return
* @throws java.sql.SQLException
*/
@Override
public int save(Student entity) throws SQLException {
int affectedRows;
if (entity.getId() == null) {
//insertion
affectedRows = this.insert(entity);
} else {
//mise a jour
affectedRows = this.update(entity);
}
return 1;
}
/**
*
* @param entity
* @return
* @throws SQLException
*/
private int insert(Student entity) throws SQLException {
String sql = "INSERT INTO students ( name, firstName, sexe) VALUES (?,?,?)";
pstm = dbConnection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
pstm.setString(1, entity.getName());
pstm.setString(2, entity.getFirstName());
pstm.setString(3, String.valueOf(entity.getSexe()));
// Récupération de la clef auto incrémentée
ResultSet keyRs = pstm.getGeneratedKeys();
if(keyRs.next()){
entity.setId(keyRs.getInt("id"));
}
return pstm.executeUpdate();
}
/**
*
* @param entity
* @return
* @throws SQLException
*/
private int update(Student entity) throws SQLException {
String sql = "UPDATE students SET name=?, firstname=?, sexe=? WHERE id = ?";
pstm = dbConnection.prepareStatement(sql);
pstm.setString(1, entity.getName());
pstm.setString(2, entity.getFirstName());
pstm.setString(3, String.valueOf(entity.getSexe()));
pstm.setInt(4, entity.getId());
return pstm.executeUpdate();
}
@Override
public void deleteOneById(Student entity) throws SQLException {
if (entity.getId() != null) {
String sql = "DELETE FROM students WHERE id=?";
pstm = dbConnection.prepareStatement(sql);
pstm.setInt(1, entity.getId());
pstm.executeUpdate();
}
}
public StudentDAO findOneById(int id) throws SQLException {
String sql = "SELECT * FROM students WHERE id=?";
pstm = dbConnection.prepareStatement(sql);
pstm.setInt(1,id);
pstm.executeUpdate();
return this;
}
/**
* Récupération d'une ligne de la table
* @return
* @throws SQLException
*/
public Student getOne() throws SQLException {
Student entity = new Student();
if (resultSet.next()) {
entity.setName(resultSet.getString("name"));
entity.setFirstName(resultSet.getString("firstName"));
entity.setSexe(resultSet.getString("sexe").charAt(0));
}
return entity;
}
/**
* Récupération des rsultats d'ne requette sous la forme d'un tableau assiocatif
* @return
* @throws SQLException
*/
public Map<String, String> getOneAsMap() throws SQLException{
Map<String, String> studentData = new HashMap<>();
if (resultSet.next()) {
studentData.put("name", resultSet.getString("name"));
studentData.put("firstName", resultSet.getString("firstName"));
studentData.put("sexe", resultSet.getString("sexe"));
}
return studentData;
}
public StudentDAO findAll() throws SQLException {
String sql = "SELECT * FROM students ";
pstm = dbConnection.prepareStatement(sql);
resultSet = pstm.executeQuery();
return this;
}
public List<Student> getAll() throws SQLException{
List<Student> studentList = new ArrayList<>();
if (resultSet.isBeforeFirst()) {
while (! resultSet.isLast()) {
studentList.add(this.getOne());
}
}
return studentList;
}
public List<Map<String, String>> getAllAsArray() throws SQLException{
List<Map<String, String>> studentList = new ArrayList<>();
if (resultSet.isBeforeFirst()) {
while (! resultSet.isLast()) {
studentList.add(this.getOneAsMap());
}
}
return studentList;
}
}
|
package vn.m2m.config;
import play.Configuration;
import play.Logger;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Singleton
public class IpRequestConfig {
public class IpRequestMethodConfig{
// ex: 600/1 minutes, lock in 900 seconds
private long limit;
private int times;
private TimeUnit unit; // DAYS, HOURS, MINUTES, SECONDS, MILLISECONDS
private boolean islock;
private long timelock;
public IpRequestMethodConfig(long limit, int times, TimeUnit unit, boolean islock, long timelock) {
this.limit = limit;
this.times = times;
this.unit = unit;
this.islock = islock;
this.timelock = timelock;
}
public long getLimit() {
return limit;
}
public void setLimit(long limit) {
this.limit = limit;
}
public int getTimes() {
return times;
}
public void setTimes(int times) {
this.times = times;
}
public TimeUnit getUnit() {
return unit;
}
public void setUnit(TimeUnit unit) {
this.unit = unit;
}
public boolean islock() {
return islock;
}
public void setIslock(boolean islock) {
this.islock = islock;
}
public long getTimelock() {
return timelock;
}
public void setTimelock(long timelock) {
this.timelock = timelock;
}
}
private HashMap<String, IpRequestMethodConfig> mapIpRequestConfig;
public HashMap<String, IpRequestMethodConfig> getMapIpRequestConfig() {
return mapIpRequestConfig;
}
@Inject
public IpRequestConfig(Configuration configuration) throws Exception{
mapIpRequestConfig = new HashMap<String, IpRequestMethodConfig>();
List<String> listConfig = configuration.underlying().getStringList("iprequest.list");
for(String key: listConfig){
String keyLimit = "iprequest." + key + ".limit";
String keyTimes = "iprequest." + key + ".times";
String keyUnit = "iprequest." + key + ".unit";
String keyIslock = "iprequest." + key + ".islock";
String keyTimelock = "iprequest." + key + ".timelock";
long limit = configuration.underlying().getLong(keyLimit);
int times = configuration.underlying().getInt(keyTimes);
TimeUnit unit = TimeUnit.valueOf(configuration.underlying().getString(keyUnit));
boolean islock = configuration.underlying().getBoolean(keyIslock);
long timelock = configuration.underlying().getLong(keyTimelock);
IpRequestMethodConfig methodConfig = new IpRequestMethodConfig(limit, times, unit, islock, timelock);
Logger.debug("mapIpRequestConfig.put {}",key);
mapIpRequestConfig.put(key, methodConfig);
}
}
}
|
package api;
import com.github.motoki317.traq4j.ApiClient;
import com.github.motoki317.traq4j.ApiException;
import com.github.motoki317.traq4j.api.*;
import com.github.motoki317.traq4j.model.*;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class TraqApiImpl implements TraqApi {
private final MessageApi messageApi;
private final ChannelApi channelApi;
private final UserApi userApi;
private final WebrtcApi webrtcApi;
private Map<UUID, User> usersCache;
/**
* Creates new traQ API client.
* @param basePath Base path. e.g. "http://q.trap.jp/api/v3"
* @param accessToken Bot access token.
*/
public TraqApiImpl(@Nullable String basePath, String accessToken) {
ApiClient client = new ApiClient();
if (basePath != null) {
client.setBasePath(basePath);
}
client.addDefaultHeader("Authorization", "Bearer " + accessToken);
this.messageApi = new MessageApi(client);
this.channelApi = new ChannelApi(client);
this.userApi = new UserApi(client);
this.webrtcApi = new WebrtcApi(client);
}
private static void handleError(ApiException e) {
e.printStackTrace();
System.out.printf("code: %s, body: %s\n", e.getCode(), e.getResponseBody());
}
@Nullable
@Override
public Message sendMessage(UUID channelId, String message, boolean embed) {
try {
return messageApi.postMessage(
channelId,
new PostMessageRequest().content(message).embed(embed)
);
} catch (ApiException e) {
handleError(e);
return null;
}
}
@Override
public void editMessage(UUID messageId, String message) {
try {
messageApi.editMessage(
messageId,
new PostMessageRequest().content(message).embed(true)
);
} catch (ApiException e) {
handleError(e);
}
}
@Nullable
@Override
public Channel getChannelByID(UUID id) {
// TODO: maybe cache
try {
return channelApi.getChannel(id);
} catch (ApiException e) {
handleError(e);
return null;
}
}
@Nullable
@Override
public User getUserByID(UUID id) {
if (this.usersCache == null) {
List<User> users;
try {
users = userApi.getUsers(false);
} catch (ApiException e) {
handleError(e);
return null;
}
this.usersCache = new HashMap<>();
for (User user : users) {
this.usersCache.put(user.getId(), user);
}
}
return this.usersCache.get(id);
}
@Nullable
@Override
public List<WebRTCUserState> getWebRTCState() {
try {
return webrtcApi.getWebRTCState();
} catch (ApiException e) {
handleError(e);
return null;
}
}
@Nullable
@Override
public WebRTCAuthenticateResult authenticateWebRTC(String peerId) {
try {
return webrtcApi.postWebRTCAuthenticate(
new PostWebRTCAuthenticateRequest().peerId(peerId)
);
} catch (ApiException e) {
handleError(e);
return null;
}
}
}
|
package com.uvaysss.queuemanager.ui.common;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
import com.uvaysss.queuemanager.R;
public class VectorTextView extends AppCompatTextView {
private static final int NO_RESOURCE_ID = -1;
public VectorTextView(Context context) {
this(context, null);
}
public VectorTextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public VectorTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs);
}
@SuppressLint("CustomViewStyleable")
private void init(Context context, AttributeSet attrs) {
if (attrs == null) return;
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.VectorTextView);
Drawable left;
Drawable right;
Drawable bottom;
Drawable top;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
left = array.getDrawable(R.styleable.VectorTextView_drawableLeftCompat);
right = array.getDrawable(R.styleable.VectorTextView_drawableRightCompat);
bottom = array.getDrawable(R.styleable.VectorTextView_drawableBottomCompat);
top = array.getDrawable(R.styleable.VectorTextView_drawableTopCompat);
} else {
left = getDrawableCompat(array, R.styleable.VectorTextView_drawableLeftCompat);
right = getDrawableCompat(array, R.styleable.VectorTextView_drawableRightCompat);
bottom = getDrawableCompat(array, R.styleable.VectorTextView_drawableBottomCompat);
top = getDrawableCompat(array, R.styleable.VectorTextView_drawableTopCompat);
}
setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
array.recycle();
}
private Drawable getDrawableCompat(TypedArray array, int styleableResId) {
int resourceId = array.getResourceId(styleableResId, NO_RESOURCE_ID);
if (resourceId == NO_RESOURCE_ID) return null;
else return VectorDrawableCompat.create(getContext().getResources(), resourceId, null);
}
}
|
package com.pan.commlib.request;
import com.google.gson.Gson;
import com.pan.commlib.core.Request;
import java.util.Map;
public class JsonRequest extends Request {
public JsonRequest(Object payload) {
super(null);
mapRequestHeaders.put("Accept", "application/json");
mapRequestHeaders.put("Content-type", "application/json");
if (payload == null) {
fillBody(null);
} else {
String json = new Gson().toJson(payload);
fillBody(json.getBytes());
}
}
public static JsonRequest build(Method method, String host, String command,
Map<String, String> params, Map<String, String> headers, Object payload) {
JsonRequest jsonrequest = new JsonRequest(payload);
jsonrequest.requestMethod = method;
if (host != null) jsonrequest.strRequestHost = host;
if (command != null) jsonrequest.strRequestCmd = command;
if (params != null) jsonrequest.mapRequestParams.putAll(params);
if (headers != null) jsonrequest.mapRequestHeaders.putAll(headers);
return jsonrequest;
}
}
|
/*
Copyright (C) 2009, Bioingenium Research Group
http://www.bioingenium.unal.edu.co
Author: Alexander Pinzon Fernandez
JNukak3D is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
JNukak3D 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 JNukak3D; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA,
or see http://www.gnu.org/copyleft/gpl.html
*/
package edu.co.unal.bioing.jnukak3d.event;
/**
*
* @author Alexander Pinzon Fernandez
*/
public interface nkEventGenerator {
void addnkEventListener( nkEventListener l);
void removenkEventListener( nkEventListener l);
}
|
package com.example.myapplication;
public class GlobalVariables {
static final String ADDRESS = "http://192.168.99.1/projectone/";
}
|
package com.tencent.mm.ui;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import com.tencent.mm.plugin.report.service.h;
import com.tencent.mm.plugin.setting.ui.setting.SelfQRCodeUI;
class ab$4 implements OnClickListener {
final /* synthetic */ ab toE;
ab$4(ab abVar) {
this.toE = abVar;
}
public final void onClick(View view) {
h.mEJ.h(11264, new Object[]{Integer.valueOf(1)});
this.toE.startActivity(new Intent(this.toE.getContext(), SelfQRCodeUI.class));
}
}
|
package com.dimple.maintenance.domain;
import com.dimple.common.core.domain.BaseEntity;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* @className Policy
* @description 策略表(Policy)实体类
* @auther Dimple
* @date 2019/4/17
* @Version 1.0
*/
public class Policy extends BaseEntity {
private static final long serialVersionUID = -90823424565735713L;
private Long polId;
/**
* 策略的名称
**/
private String polName;
/**
* 祖级路径
**/
private String ancestors;
/**
* 上级
**/
private Long parentId;
/**
* 排序标识
**/
private Integer orderNum;
/**
* 分数,可以为小数
**/
private Double score;
/**
* 状态
*/
private String status;
/**
* 备注
**/
private String remark;
/**
* 上级菜单的名称
*/
private String parentName;
/**
* 是否需要输入
*/
private String input;
/**
* 指定需要检查该策略的部门id
*/
private Long deptId;
/**
* =============
* 子策略
*/
private List<Policy> children = new ArrayList<>();
/**
* 需要检查该策略的部门的名称
*/
private String deptName;
/**
* 部门数组
*/
private Long[] deptIds;
private Object record;
public Long getPolId() {
return polId;
}
public void setPolId(Long polId) {
this.polId = polId;
}
public String getPolName() {
return polName;
}
public void setPolName(String polName) {
this.polName = polName;
}
public String getAncestors() {
return ancestors;
}
public void setAncestors(String ancestors) {
this.ancestors = ancestors;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public Integer getOrderNum() {
return orderNum;
}
public void setOrderNum(Integer orderNum) {
this.orderNum = orderNum;
}
public Double getScore() {
return score;
}
public void setScore(Double score) {
this.score = score;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public List<Policy> getChildren() {
return children;
}
public void setChildren(List<Policy> children) {
this.children = children;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public Long[] getDeptIds() {
return deptIds;
}
public void setDeptIds(Long[] deptIds) {
this.deptIds = deptIds;
}
public Object getRecord() {
return record;
}
public void setRecord(Object record) {
this.record = record;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}
|
package com.tencent.mm.g.c;
import android.content.ContentValues;
import android.database.Cursor;
import com.tencent.mm.sdk.e.c;
public abstract class al extends c {
public static final String[] ciG = new String[0];
private static final int ciP = "rowid".hashCode();
private static final int ctt = "labelId".hashCode();
private static final int ctu = "contactName".hashCode();
private boolean ctr;
private boolean cts;
public String field_contactName;
public String field_labelId;
public final void d(Cursor cursor) {
String[] columnNames = cursor.getColumnNames();
if (columnNames != null) {
int length = columnNames.length;
for (int i = 0; i < length; i++) {
int hashCode = columnNames[i].hashCode();
if (ctt == hashCode) {
this.field_labelId = cursor.getString(i);
} else if (ctu == hashCode) {
this.field_contactName = cursor.getString(i);
} else if (ciP == hashCode) {
this.sKx = cursor.getLong(i);
}
}
}
}
public final ContentValues wH() {
ContentValues contentValues = new ContentValues();
if (this.ctr) {
contentValues.put("labelId", this.field_labelId);
}
if (this.cts) {
contentValues.put("contactName", this.field_contactName);
}
if (this.sKx > 0) {
contentValues.put("rowid", Long.valueOf(this.sKx));
}
return contentValues;
}
}
|
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class ArrayIntListTest
{
@Test
void test()
{
int[] data = {6,4,5,6,5,4};
ArrayIntList list = new ArrayIntList();
for (int n : data)
{
list.add(n);
}
assertEquals(4, list.get(5));
assertEquals(5, list.lastIndexOf(4));
assertEquals(-1, list.lastIndexOf(22));
}
@Test
void test2()
{
int[] data = {6,4,5,6,5,4};
ArrayIntList list = new ArrayIntList();
for (int n : data)
{
list.add(n);
}
int[] data2 = {6,4,333,6,333,4};
ArrayIntList list2 = new ArrayIntList();
for (int n : data2)
{
list2.add(n);
}
System.out.println(list2);
list.replaceAll(5,333);
System.out.println(list);
assertEquals(0, list.get(2) ^ list.get(4));
assertEquals(list.toString(), list2.toString());
assertTrue(list.toString().compareTo(list2.toString()) == 0);
}
}
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Lab05A;
/**
*
* @author Aliaksiej Protas
*/
public class headCalc {
public static int headCount(int age){
final int firstPeriod = 200;
final int secondPeriod = 300;
int numberOfhead = 0;
if (age >= 0 && age < firstPeriod) {
numberOfhead = age * 3;
} else if (age >= firstPeriod && age < secondPeriod) {
numberOfhead = firstPeriod * 3 + (age - firstPeriod) * 2;
}
else if (age >= secondPeriod) {
numberOfhead = firstPeriod * 3 + (secondPeriod - firstPeriod) * 2 + (age - secondPeriod);
}
return numberOfhead;
}
public static int eyesCount(int age) {
return 2 * headCount(age);
}
}
|
package com.alibaba.dubbo.rpc;
import com.alibaba.dubbo.common.Node;
/**
* 服务的执行体
*/
public interface Invoker<T> extends Node {
/**
* 获取服务的类型
*/
Class<T> getInterface();
/**
* 执行本次服务调用过程
* @param invocation--本次服务调用的相关信息
* @return 调用执行结果
*/
Result invoke(Invocation invocation) throws RpcException;
}
|
package day57_abstraction_polymorphism.abst_VS_inter;
public abstract class AbstractA {
int num1;
private double price;
public static int count;
public final String TYPE = "abstract";
public static final String LANGUAGE = "java";
public AbstractA(){ //Abst.class have CONSTRUCTOR
System.out.println("AbstractA class constructor");
}
public abstract void absMethodA();
public void methodB(){ //non-abstract
System.out.println("methodB is called");
}
public static void staticMethodC(){
System.out.println("Static methodC is called");
}
}
|
package jp.co.tau.web7.admin.supplier.mappers;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import jp.co.tau.web7.admin.supplier.dto.InfoAirbagDTO;
import jp.co.tau.web7.admin.supplier.dto.InfoEquipmentDTO;
import jp.co.tau.web7.admin.supplier.entity.TStkMbdOptEntity;
import jp.co.tau.web7.admin.supplier.mappers.common.BaseMapper;
/**
*
* <p>ファイル名 : TStkMbdOptMapper </p>
* <p>説明 : STK_MBD_OPT</p>
* @author :
* @since : 2018/03/13
*/
@Mapper
public interface TStkMbdOptMapper extends BaseMapper<TStkMbdOptEntity> {
/**
* <p>説明 : findInfoEquipment</p>
* @author hung.pd
* @param stkNo Stock no
* @return InfoEquipmentDTO
*/
List<InfoEquipmentDTO> findInfoEquipment(@Param("stkNo") String stkNo);
List<InfoAirbagDTO> findInfoAirbag(@Param("stkNo") String stkNo);
}
|
package com.tencent.mm.plugin.fts.ui.a;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.tencent.mm.plugin.fts.a.d.a.a.b;
import com.tencent.mm.plugin.fts.ui.a.b.a;
import com.tencent.mm.plugin.fts.ui.m;
import com.tencent.mm.plugin.fts.ui.n.d;
import com.tencent.mm.plugin.fts.ui.n.e;
public abstract class b$b extends b {
final /* synthetic */ b jxD;
public b$b(b bVar) {
this.jxD = bVar;
super(bVar);
}
public final View a(Context context, ViewGroup viewGroup) {
View inflate = LayoutInflater.from(context).inflate(e.fts_contact_item, viewGroup, false);
a aVar = this.jxD.jxB;
aVar.eCl = (ImageView) inflate.findViewById(d.avatar_iv);
aVar.eCm = (TextView) inflate.findViewById(d.title_tv);
aVar.eCn = (TextView) inflate.findViewById(d.desc_tv);
aVar.jxC = (TextView) inflate.findViewById(d.item_desc_tv);
aVar.contentView = inflate.findViewById(d.search_item_content_layout);
inflate.setTag(aVar);
return inflate;
}
public final void a(Context context, com.tencent.mm.plugin.fts.a.d.a.a.a aVar, com.tencent.mm.plugin.fts.a.d.a.a aVar2, Object... objArr) {
a aVar3 = (a) aVar;
b bVar = (b) aVar2;
m.h(aVar3.contentView, this.jxD.jtj);
com.tencent.mm.pluginsdk.ui.a.b.a(aVar3.eCl, bVar.username);
m.a(bVar.hqx, aVar3.eCm);
m.a(bVar.hqy, aVar3.eCn);
m.a(bVar.jxA, aVar3.jxC);
}
}
|
package com.pro.mongo.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import com.pro.mongo.mapper.MongoMapper;
import com.pro.mongo.service.UserService;
import com.pro.mongo.vo.MongoUserVO;
import com.pro.mongo.vo.UserProVO;
import com.pro.mongo.vo.UserRoleVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Service
@RequiredArgsConstructor
@Slf4j
public class UserServiceImpl implements UserService {
private final MongoTemplate mongo;
private final MongoMapper mapper;
private final PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
@Override
public int register(Map<String, Object> params) {
MongoUserVO regUser = new MongoUserVO();
regUser.setUser_email((String)params.get("reg_email"));
regUser.setUser_id((String)params.get("reg_id"));
regUser.setUser_name((String)params.get("reg_name"));
// 비밀번호 암호화
String encryptPassword = passwordEncoder.encode((String)params.get("reg_pwd"));
regUser.setUser_pwd(encryptPassword);
// user_no을 주기 위한 최대값 구하기
Query query = new Query();
query.limit(1);
query.with(Sort.by(Sort.Direction.DESC, "user_no"));
int maxUserNo = ((MongoUserVO)mongo.findOne(query, MongoUserVO.class, "users")).getUser_no() + 1;
regUser.setUser_no(maxUserNo);
// 사용자 권한 설정(따로 설정하면 impl클래스가 같이 안 들어감)
UserRoleVO role = new UserRoleVO();
role.setRole("ROLE_USER");
List<UserRoleVO> rolesList = new ArrayList<UserRoleVO>(){{ add(role); }};
regUser.setUser_role(rolesList);
// 사용자 프로젝트 범위 설정(따로 설정하면 impl클래스가 같이 안 들어감)
UserProVO pro = new UserProVO();
pro.setPro("MONGO_START");
List<UserProVO> ProsList = new ArrayList<UserProVO>(){{ add(pro); }};
regUser.setWith_pro(ProsList);
log.debug("{}", mongo.insert(regUser, "users"));
return 0;
}
@Override
public int idCheck(String reg_id) {
Query query = new Query(Criteria.where("user_id").is(reg_id));
List<MongoUserVO> userIdList = mongo.find(query, MongoUserVO.class, "users");
return userIdList.size();
}
}
|
package com.itheima.ssm.service.impl;
import com.itheima.ssm.dao.IUserDao;
import com.itheima.ssm.domain.Role;
import com.itheima.ssm.domain.UserInfo;
import com.itheima.ssm.service.IUserService;
import com.itheima.ssm.utils.BCryptPasswordEncoderUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@Service("userService")
@Transactional
public class UserService implements IUserService {
@Autowired
private IUserDao userDao;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
UserInfo userInfo = null;
try {
userInfo = userDao.findByUsername(username);
} catch (Exception e) {
e.printStackTrace();
}
// 处理自己的用户对象封装成UserDetails
// User user = new User(userInfo.getUsername(),userInfo.getPassword(),getAuthority(userInfo.getRoles()));
User user = new User(userInfo.getUsername(),userInfo.getPassword(),userInfo.getStatus() == 0?false:true,true,true,true,getAuthority(userInfo.getRoles()));
BCryptPasswordEncoder bce = new BCryptPasswordEncoder();
System.out.println(bce.matches("123",user.getPassword()));
return user;
}
private Collection<? extends GrantedAuthority> getAuthority(List<Role> roles) {
List<SimpleGrantedAuthority> list = new ArrayList<>();
for(Role role:roles){
list.add(new SimpleGrantedAuthority("ROLE_" + role.getRoleName()));
}
return list;
}
@Override
public List<UserInfo> findAll() throws Exception{
return userDao.findAll();
}
@Override
public void save(UserInfo userInfo) throws Exception {
// 加密类
BCryptPasswordEncoderUtils bceu = new BCryptPasswordEncoderUtils();
// 加密
userInfo.setPassword(bceu.encodePassword(userInfo.getPassword()));
userDao.save(userInfo);
}
@Override
public UserInfo findById(String id) throws Exception {
return userDao.findById(id);
}
@Override
public List<Role> findOtherRole(String userId) throws Exception {
return userDao.findOtherRole(userId);
}
@Override
public void addRoleToUser(String userId, String[] roleIds) {
for (String roleId:roleIds) {
userDao.addRoleToUser(userId,roleId);
}
}
}
|
package com.accp.pub.mapper;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.accp.pub.pojo.Gradeorganizationuser;
public interface GradeorganizationuserMapper {
int insert(Gradeorganizationuser record);
int insertSelective(Gradeorganizationuser record);
int selectStudentCount(@Param("roleid") Integer roleid, @Param("jurisdiction") Integer jurisdiction,
@Param("graderid") String graderid);
List<Gradeorganizationuser> selectGradeZengBanZhuRenJiaoYuan(@Param("roleid") Integer roleid,
@Param("jurisdiction") Integer jurisdiction, @Param("graderid") String graderid);
List<Gradeorganizationuser> selectGradeXianBanZhuRenJiaoYuan(@Param("roleid") Integer roleid,
@Param("jurisdiction") Integer jurisdiction, @Param("graderid") String graderid);
List<Gradeorganizationuser> selectGradeXianBanWei(@Param("roleid") Integer roleid,
@Param("jurisdiction") Integer jurisdiction, @Param("graderid") String graderid);
List<Gradeorganizationuser> selectGradeShuSeQuYu(@Param("roleid") Integer roleid,
@Param("jurisdiction") Integer jurisdiction, @Param("graderid") String graderid,
@Param("isStay") String isStay);
Gradeorganizationuser selectStudentGradeBuFenXinXi(@Param("roleid") Integer roleid,
@Param("jurisdiction") Integer jurisdiction, @Param("stuid") Integer stuid);
List<Gradeorganizationuser> selectGradeXianBanWeiAllInfoDeleteKey(@Param("roleid") Integer roleid,
@Param("jurisdiction") Integer jurisdiction, @Param("graderid") String graderid);
List<Gradeorganizationuser> selectGradeBanWeiUserNameXuanZe(@Param("roleid") Integer roleid,
@Param("jurisdiction") Integer jurisdiction, @Param("graderid") String graderid);
int updateByPGraderidAndUserid(@Param("studuty") String studuty,
@Param("operator") String operator,@Param("operatdate") Date operatdate,@Param("userid") Integer userid, @Param("graderid") String graderid);
List<Gradeorganizationuser> selectGradeXiangMuZuKaiTongStudentInfo(@Param("roleid") Integer roleid,
@Param("jurisdiction") Integer jurisdiction, @Param("cmmid") Integer cmmid);
int updateByClassmanagementmodel(@Param("jurisdiction") String jurisdiction,
@Param("operator") String operator,@Param("operatdate") Date operatdate,@Param("cmmid") Integer cmmid);
List<Gradeorganizationuser> selectGradeXieRiZhiMoRenShouJianRen(@Param("jurisdiction") Integer jurisdiction, @Param("userid") Integer userid);
List<Gradeorganizationuser> selectGradeXieRiZhiSuoYouZuZhiChengYuan(@Param("userid") Integer userid,@Param("cmmpid") Integer cmmpid,@Param("useridkey") Integer useridkey);
List<Gradeorganizationuser> selectByUserClassAllStudentKey(@Param("userid")Integer userid,@Param("cmmid")Integer cmmid);
}
|
package com.shiro.mapper;
public class ModuleMapperProvider
{
public String select()
{
String sql = "select * from module_p";
return sql;
}
}
|
package com.example.demo.services;
import com.example.demo.data_transfer_objects.InteresseDTO;
import com.example.demo.entities.Interesse;
import com.example.demo.repositories.InteresseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@Service
public class InteresseService {
@Autowired
private InteresseRepository interesseRepository;
public Page<Interesse> listInteresses(Pageable page) {
return interesseRepository.findAll(page);
}
public void demonstrarInteresse(Interesse interesse){
interesseRepository.save(interesse);
System.out.println("interesse salvo");
}
}
|
package org.opentosca.containerapi.instancedata;
import java.net.URI;
import java.util.List;
import javax.ws.rs.core.Response.Status;
import org.opentosca.containerapi.instancedata.exception.GenericRestException;
import org.opentosca.instancedata.service.IInstanceDataService;
import org.opentosca.model.instancedata.IdConverter;
import org.opentosca.model.instancedata.NodeInstance;
import org.opentosca.model.instancedata.ServiceInstance;
/**
* This class checks for Existence of ServiceInstances and NodeInstances by calling the given InstanceDataService
* @author Marcus Eisele - marcus.eisele@gmail.com
*
*/
public class ExistenceChecker {
public static boolean existsServiceInstance(URI serviceInstanceID, IInstanceDataService service) {
List<ServiceInstance> serviceInstances = service.getServiceInstances(serviceInstanceID, null, null);
//check if only one instance was returned - we dont verify because we assume the get Method returns the correct one!
//we got really bad problems if this wouldnt work anyway
if (serviceInstances != null && serviceInstances.size() == 1 && serviceInstances.get(0) != null) {
return true;
}
//if the instance wasnt returned => it was not found = it doesnt exist
return false;
}
public static boolean existsNodeInstance(URI nodeInstanceID, IInstanceDataService service) {
List<NodeInstance> nodeInstances = service.getNodeInstances(nodeInstanceID, null, null, null);
//check if only one instance was returned - we dont verify because we assume the get Method returns the correct one!
//we got really bad problems if this wouldnt work anyway
if (nodeInstances != null && nodeInstances.size() == 1 && nodeInstances.get(0) != null) {
return true;
}
//if the instance wasnt returned => it was not found = it doesnt exist
return false;
}
/**
* @param nodeInstanceID
* the id given (int) by the rest-service
* @param service
* initialized InstanceDataService
* @return the specified nodeInstance
*
* @throws GenericRestException
* when specified nodeInstance doesn't exist
*/
public static NodeInstance checkNodeInstanceWithException(int nodeInstanceID, IInstanceDataService service) throws GenericRestException {
List<NodeInstance> nodeInstances = service.getNodeInstances(IdConverter.nodeInstanceIDtoURI(nodeInstanceID), null, null, null);
//check if only one instance was returned - we dont verify because we assume the get Method returns the correct one!
//we got really bad problems if this wouldnt work anyway
if (nodeInstances != null && nodeInstances.size() == 1 && nodeInstances.get(0) != null) {
return nodeInstances.get(0);
} else {
throw new GenericRestException(Status.NOT_FOUND, "Specified nodeInstance with id: " + nodeInstanceID + " doesn't exist");
}
}
public static ServiceInstance checkServiceInstanceWithException(int serviceInstanceID, IInstanceDataService service) throws GenericRestException {
List<ServiceInstance> serviceInstances = service.getServiceInstances(IdConverter.serviceInstanceIDtoURI(serviceInstanceID), null, null);
//check if only one instance was returned - we dont verify because we assume the get Method returns the correct one!
//we got really bad problems if this wouldnt work anyway
if (serviceInstances != null && serviceInstances.size() == 1 && serviceInstances.get(0) != null) {
return serviceInstances.get(0);
} else {
throw new GenericRestException(Status.NOT_FOUND, "Specified serviceInstance with id: " + serviceInstanceID + " doesn't exist");
}
}
}
|
package polling;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonView;
import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
public class Poll{
@JsonView(View.excludemoderator.class)
int mid;
@JsonView(View.results.class)
String id ;
@JsonView(View.results.class)
String question;
@JsonView(View.results.class)
String started_at;
@JsonView(View.results.class)
String expired_at;
@JsonView(View.results.class)
ArrayList<String> choice;
@JsonView(View.viewwithresults.class)
ArrayList<Integer> results;
public Boolean getMsgFlag() {
return msgFlag;
}
public void setMsgFlag(Boolean msgFlag) {
this.msgFlag = msgFlag;
}
@JsonView(View.excludemoderator.class)
Boolean msgFlag;
//AtomicInteger count = new AtomicInteger(100000);
public Poll()
{
this.results = new ArrayList<Integer>(Collections.nCopies(2,0));
}
/*public void initializeArray()
{
Arrays.fill(results,0);
}*/
public void setMid(int id)
{
this.mid= id;
}
public int getMid()
{
return mid;
}
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
public String getQuestion()
{
return question;
}
public void setQuestion(String question)
{
this.question = question;
}
public void setChoice(ArrayList<String> choice)
{
this.choice = choice;
}
public ArrayList<String> getChoice()
{
return choice;
}
public ArrayList<Integer> getResults()
{
return results;
}
public void setresults(ArrayList<Integer> results)
{
this.results = results;
}
public void setStarted_at(String date)
{
this.started_at = date;
}
public String getstarted_at()
{
return started_at;
}
public void setExpired_at(String expired_at)
{
this.expired_at = expired_at;
}
public String getExpired_at()
{
return expired_at;
}
}
|
/*
* Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hazelcast.client.executor;
import com.hazelcast.client.HazelcastClient;
import com.hazelcast.client.executor.tasks.*;
import com.hazelcast.core.*;
import com.hazelcast.test.AssertTask;
import com.hazelcast.test.HazelcastParallelClassRunner;
import com.hazelcast.test.annotation.ProblematicTest;
import com.hazelcast.test.annotation.QuickTest;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicReference;
import static com.hazelcast.test.HazelcastTestSupport.*;
import static org.junit.Assert.*;
@RunWith(HazelcastParallelClassRunner.class)
@Category(QuickTest.class)
public class ClientExecutorServiceInvokeTest {
static HazelcastInstance instance1;
static HazelcastInstance client;
@BeforeClass
public static void init() {
instance1 = Hazelcast.newHazelcastInstance();
client = HazelcastClient.newHazelcastClient();
}
@AfterClass
public static void destroy() {
HazelcastClient.shutdownAll();
Hazelcast.shutdownAll();
}
@Test
public void testInvokeAll() throws Throwable {
IExecutorService service = client.getExecutorService(randomString());
String msg = randomString();
Collection c = new ArrayList();
c.add(new AppendCallable(msg));
c.add(new AppendCallable(msg));
List<Future> results = service.invokeAll(c);
for(Future result : results){
assertEquals(msg + AppendCallable.APPENDAGE, result.get() );
}
}
@Test(expected = UnsupportedOperationException.class)
public void testInvokeAll_withTimeOut() throws Throwable {
IExecutorService service = client.getExecutorService(randomString());
Collection c = new ArrayList();
c.add(new AppendCallable());
c.add(new AppendCallable());
service.invokeAll(c, 1, TimeUnit.MINUTES);
}
@Test(expected = UnsupportedOperationException.class)
public void testInvokeAny() throws Throwable, InterruptedException {
IExecutorService service = client.getExecutorService(randomString());
Collection c = new ArrayList();
c.add(new AppendCallable());
c.add(new AppendCallable());
service.invokeAny(c);
}
@Test(expected = UnsupportedOperationException.class)
public void testInvokeAnyTimeOut() throws Throwable, InterruptedException {
IExecutorService service = client.getExecutorService(randomString());
Collection c = new ArrayList();
c.add(new AppendCallable());
c.add(new AppendCallable());
service.invokeAny(c, 1, TimeUnit.MINUTES);
}
}
|
package setexer;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.TreeSet;
import org.junit.Test;
public class TestTreeSet {
public static void main(String[] args) {
Comparator<Employee> com = new Comparator<Employee>(){
@Override
public int compare(Employee o1, Employee o2) {
MyDate m1 = o1.getBirthday();
MyDate m2 = o2.getBirthday();
return m1.compareTo(m2);
}
};
TreeSet set = new TreeSet(com);
Employee e1 = new Employee("liudehua",23,new MyDate(1991,1,5));
Employee e2 = new Employee("zhangxueyou",26,new MyDate(1993,4,23));
Employee e3 = new Employee("liming",25,new MyDate(1997,8,10));
Employee e4 = new Employee("guofucheng",22,new MyDate(1999,5,17));
Employee e5 = new Employee("liangchengwei",29,new MyDate(1990,6,20));
set.add(e1);
set.add(e2);
set.add(e3);
set.add(e4);
set.add(e5);
Iterator iterator = set.iterator();
while(iterator.hasNext()){
System.out.println(iterator.next());
}
}
@Test
public void test(){
Employee e1 = new Employee("liudehua",23,new MyDate(1990,1,5));
Employee e2 = new Employee("zhangxueyou",26,new MyDate(1993,4,23));
Employee e3 = new Employee("liming",25,new MyDate(1997,8,10));
Employee e4 = new Employee("guofucheng",22,new MyDate(1999,5,17));
Employee e5 = new Employee("liangchengwei",29,new MyDate(1990,6,20));
TreeSet<Employee> ts = new TreeSet<Employee>();
ts.add(e1);
ts.add(e2);
ts.add(e3);
ts.add(e4);
ts.add(e5);
for (Employee em : ts) {
System.out.println(em);
}
}
@Test
public void test1(){
Employee e1 = new Employee("liudehua",23,new MyDate(1990,6,20));
Employee e2 = new Employee("zhangxueyou",26,new MyDate(1993,4,23));
Employee e3 = new Employee("liming",25,new MyDate(1997,8,10));
Employee e4 = new Employee("guofucheng",22,new MyDate(1999,5,17));
Employee e5 = new Employee("liangchengwei",29,new MyDate(1990,6,20));
TreeSet<Employee> ts = new TreeSet<Employee>(new Comparator<Employee>(){
@Override
public int compare(Employee o1, Employee o2) {
int year = o1.getBirthday().getYear() - o2.getBirthday().getYear();
int month = o1.getBirthday().getMonth() - o2.getBirthday().getMonth();
int day = o1.getBirthday().getDay() - o2.getBirthday().getDay();
if(year != 0){
return year;
}else if(month != 0){
return month;
}else if(day != 0){
return day;
}
return o1.getName().length() - o2.getName().length();
}
});
Collections.addAll(ts, e1, e2, e3, e4, e5);
for (Employee em : ts) {
System.out.println(em);
}
}
}
|
package ru.usu.cs.fun.lang;
import java.util.HashMap;
import java.util.Map;
import ru.usu.cs.fun.back.Scope;
import ru.usu.cs.fun.back.Term;
import ru.usu.cs.fun.lang.number_operations.Add;
import ru.usu.cs.fun.lang.number_operations.Div;
import ru.usu.cs.fun.lang.number_operations.Eq;
import ru.usu.cs.fun.lang.number_operations.Less;
import ru.usu.cs.fun.lang.number_operations.LessOrEq;
import ru.usu.cs.fun.lang.number_operations.Mod;
import ru.usu.cs.fun.lang.number_operations.More;
import ru.usu.cs.fun.lang.number_operations.MoreOrEq;
import ru.usu.cs.fun.lang.number_operations.Mult;
import ru.usu.cs.fun.lang.number_operations.NotEq;
import ru.usu.cs.fun.lang.reader_operations.CloseReader;
import ru.usu.cs.fun.lang.reader_operations.FunConsole;
import ru.usu.cs.fun.lang.reader_operations.IsEnd;
import ru.usu.cs.fun.lang.reader_operations.OpenReader;
import ru.usu.cs.fun.lang.reader_operations.OpenString;
import ru.usu.cs.fun.lang.reader_operations.ReadInt;
import ru.usu.cs.fun.lang.reader_operations.ReadLine;
import ru.usu.cs.fun.lang.string_operations.CharAt;
import ru.usu.cs.fun.lang.string_operations.Concat;
import ru.usu.cs.fun.lang.string_operations.Insert;
import ru.usu.cs.fun.lang.string_operations.Len;
import ru.usu.cs.fun.lang.string_operations.Remove;
import ru.usu.cs.fun.lang.string_operations.Substr;
import ru.usu.cs.fun.lang.string_operations.Subtract;
public class FunScope implements Scope {
private final Map<String, Term> items = new HashMap<String, Term>();
public void add(String name, Term term) {
if (find(name) != null)
throw new RuntimeException("Symbol '" + name
+ "' has beed already defined");
items.put(name, term);
}
@Override
public Term get(String name) {
Term result = find(name);
if (result == null)
throw new RuntimeException("Symbol '" + name + "' in undefined");
return result;
}
// can be null
public Term find(String name) {
Term result = resolveConstant(name);
if (result != null)
return result;
if (name.equals("="))
return new Eq();
if (name.equals("!="))
return new NotEq();
if (name.equals("<="))
return new LessOrEq();
if (name.equals(">="))
return new MoreOrEq();
if (name.equals(">"))
return new More();
if (name.equals("<"))
return new Less();
if (name.equals("+"))
return new Add();
if (name.equals("-"))
return new Subtract();
if (name.equals("*"))
return new Mult();
if (name.equals("/"))
return new Div();
if (name.equals("%"))
return new Mod();
if (name.equals("print"))
return new Print();
if (name.equals("concat"))
return new Concat();
if (name.equals("len"))
return new Len();
if (name.equals("substr"))
return new Substr();
if (name.equals("charAt"))
return new CharAt();
if (name.equals("remove"))
return new Remove();
if (name.equals("insert"))
return new Insert();
if (name.equals("openReader"))
return new OpenReader();
if (name.equals("readInt"))
return new ReadInt();
if (name.equals("readLine"))
return new ReadLine();
if (name.equals("isEnd"))
return new IsEnd();
if (name.equals("closeReader"))
return new CloseReader();
if (name.equals("openString"))
return new OpenString();
if (name.equals("console"))
return FunConsole.getInstance();
return items.get(name);
}
private Term resolveConstant(String name) {
return resolveBool(name);
}
private Term resolveBool(String name) {
if (name.equals("true"))
return Bool.TRUE;
else if (name.equals("false"))
return Bool.FALSE;
else
return null;
}
}
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.forsrc.springmvc.restful.login.validator;
import com.forsrc.constant.KeyConstants;
import com.forsrc.constant.MyToken;
import com.forsrc.pojo.User;
import com.forsrc.springmvc.restful.base.validator.Validator;
import com.forsrc.utils.MyStringUtils;
import org.springframework.context.MessageSource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
* The type Login validator.
*/
public class LoginValidator extends Validator {
private User user;
private String loginToken;
/**
* Instantiates a new Login validator.
*
* @param request the request
* @param messageSource the message source
*/
public LoginValidator(HttpServletRequest request, MessageSource messageSource) {
super(request, messageSource);
}
/**
* Instantiates a new Login validator.
*
* @param user the user
* @param loginToken the login token
* @param request the request
* @param messageSource the message source
*/
public LoginValidator(User user, String loginToken,
HttpServletRequest request, MessageSource messageSource) {
super(request, messageSource);
this.user = user;
this.loginToken = loginToken;
}
/**
* Validate boolean.
*
* @return the boolean
*/
public boolean validate() {
String msg = "";
this.message.put("status", "400");
if (user == null) {
this.message.put("message", "No login info.");
return false;
}
if (MyStringUtils.isBlank(user.getUsername())) {
this.message.put("message", getText("msg.username.or.password.is.blank"));
return false;
}
if (MyStringUtils.isBlank(user.getPassword())) {
msg = getText("msg.no.such.user.exception", new String[]{user.getPassword()});
this.message.put("message", msg);
return false;
}
if (MyStringUtils.isBlank(loginToken)) {
this.message.put("message", getText("msg.no.login.token"));
return false;
}
this.message.put("status", "401");
HttpSession session = request.getSession();
MyToken myToken = (MyToken) session.getAttribute(KeyConstants.TOKEN.getKey());
if (myToken == null) {
this.message.put("message", getText("msg.no.login.token"));
return false;
}
if (!loginToken.equals(myToken.getLoginToken())) {
this.message.put("message", getText("msg.login.token.not.match"));
return false;
}
this.message.put("status", "200");
return true;
}
/**
* Validate already login boolean.
*
* @return the boolean
*/
public boolean validateAlreadyLogin() {
String token = request.getParameter("token");
if (MyStringUtils.isBlank(token)) {
this.message.put("message", getText("msg.no.operation.token"));
this.message.put("status", "401");
return false;
}
HttpSession session = request.getSession();
MyToken myToken = (MyToken) session.getAttribute(KeyConstants.TOKEN.getKey());
if (myToken == null) {
this.message.put("message", getText("msg.no.login.token"));
this.message.put("status", "401");
return false;
}
return token.equals(myToken.getToken());
}
}
|
// Alexander Bratyshkin
// 260684228
import java.sql.Date;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.util.Scanner;
public class Demo {
private static final int TWO_DECIMALS = 100;
public static void main(String[] args) {
double rate, threshold, max_points, purchase_total;
String client_name, points_type;
boolean run_program = true;
// FORMATTING USED FOR DISPLAY THE PURCHASE TOTAL LATER ON
DecimalFormat f = new DecimalFormat("##.00");
System.out.println("Welcome to the Strategy Design Pattern Demo!");
while (run_program) {
AbstractPoints Points = null;
Scanner scan = new Scanner(System.in);
System.out.println("\nPlease enter your desired rate per points: ");
try {
rate = scan.nextDouble();
} catch (Exception e) {
printError();
continue;
}
System.out.println("Please enter the desired maximum amount of points: ");
try {
max_points = scan.nextDouble();
} catch (Exception e) {
printError();
continue;
}
System.out.println("Please enter the client's name: ");
scan.nextLine();
client_name = scan.nextLine();
System.out.println("Please enter F for flat rate, P for per-dollar, "
+ "and T for threshold: ");
points_type = null;
points_type = scan.nextLine();
if (points_type.equalsIgnoreCase("F")) {
Points = new FlatRatePoints(max_points, rate);
} else if (points_type.equalsIgnoreCase("P")) {
Points = new PerDollarPoints(max_points, rate);
} else if (points_type.equalsIgnoreCase("T")) {
System.out.println("Please enter your desired threshold: ");
threshold = scan.nextDouble();
Points = new ThresholdPoints(max_points, threshold, rate);
} else {
printError();
continue;
}
System.out.println("Please enter the total of the purchase: ");
try {
purchase_total = scan.nextDouble();
} catch (Exception e) {
printError();
continue;
}
Purchase purchase = new Purchase(client_name, Date.valueOf(LocalDate.now()), purchase_total);
System.out.println("Hello, " + purchase.getClient_name() + "\nYou have made a transaction on "
+ String.valueOf(purchase.getPurchase_date()) + " for a total of $"
+ f.format(purchase.getPurchase_total()) + " \nYou have earned a total of "
+ Math.round(Points.pointsEarned(purchase)) + " points\n");
System.out.println("Do you want to run the code again? (Y/N)");
String run = scan.next();
run_program = (run.equalsIgnoreCase("N")) ? (false) : (true);
}
System.exit(0);
}
public static void printError() {
System.out.println("You have entered an invalid input! Restarting the program");
}
}
|
package HealthMonitorMng.service.background;
import java.util.List;
import HealthMonitorMng.hbm.base.background.DetectObject;
import HealthMonitorMng.hbm.base.background.BasicData.Area;
import HealthMonitorMng.hbm.base.background.BasicData.BasicData;
import HealthMonitorMng.hbm.base.background.BasicData.City;
import HealthMonitorMng.hbm.base.background.BasicData.Province;
import HealthMonitorMng.model.DataGrid;
import HealthMonitorMng.model.DataGridJson;
import HealthMonitorMng.model.Location;
import HealthMonitorMng.service.BaseServiceI;
/**
* @ClassName: BasicDataServiceI
* @Description: 基础数据维护接口
* @author WuHoushuang
* @date 2015年2月3日 下午3:34:20
* @changelog 更改日志:增加了省市区的查询
*/
public interface BasicDataServiceI extends BaseServiceI{
/**
* @Title: addBasicData
* @Description: 增加基础数据维护
* @param @param basicData 基础数据类
* @param @return 设定文件
* @return BasicData 返回类型 基础数据类
* @throws
*/
public BasicData addBasicData(BasicData basicData);
/**
* @Title: datagrid
* @Description: 展示基础数据维护
* @param @param dg 供后台传递参数的model
* @param @param basicData 基础数据维护类
* @param @return 设定文件
* @return DataGridJson 返回类型 供jsp页面展示的json字符串
* @throws
*/
public DataGridJson datagrid(DataGrid dg, BasicData basicData);
/**
* @Title: edit
* @Description: 编辑或修改基础数据维护
* @param @param basicData 基础数据维护类
* @param @return 设定文件
* @return BasicData 返回类型 基础数据维护类
* @throws
*/
public BasicData edit(BasicData basicData);
/**
* @Title: delete
* @Description: 删除一个或者多个基础数据
* @param @param ids 一个或多个基础数据的id
* @return void 返回类型
* @throws
*/
public void delete(String ids);
/**
* @Title: getDetectName
* @Description: 获取检测对象类型名称
* @param @return 检测对象类型名称集合
* @return List<DetectObject> 返回类型
*/
public List<DetectObject> getDetectName();
/**
* @Title: getProvinces
* @Description: 获取所有省份
* @param @return 省份集合
* @return List<Province> 返回类型
*/
public List<Province> getProvinces();
/**
* @Title: getCities
* @Description: 获取所有城市
* @param @param provinceid 根据省份Id获取
* @param @return 所有城市的集合
* @return List<City> 返回类型
*/
public List<City> getCities(String provinceid);
/**
* @Title: getAreas
* @Description: 获取所有地区
* @param @param cityid 根据城市Id获取地区
* @param @return 所有地区集合
* @return List<Area> 返回类型
*/
public List<Area> getAreas(String cityid);
/**
* @Title: getProvince
* @Description: 获取某个省份
* @param @param provinceid 省份ID
* @param @return 某个省份
* @return Province 返回类型
*/
public Province getProvince(String provinceid);
/**
* @Title: getCity
* @Description: 获取某个城市
* @param @param cityid 城市ID
* @param @return 某个城市
* @return City 返回类型
*/
public City getCity(String cityid);
/**
* @Title: getArea
* @Description: 获取某个地区
* @param @param areaid 地区ID
* @param @return 某个地区
* @return Area 返回类型
*/
public Area getArea(String areaid);
public BasicData getData(String rowId);
}
|
package com.yinghai.a24divine_user.module.setting;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;
import com.example.fansonlib.function.imagepicker.ImagePicker;
import com.example.fansonlib.function.imagepicker.bean.ImageItem;
import com.example.fansonlib.function.imagepicker.ui.ImageGridActivity;
import com.example.fansonlib.function.imagepicker.view.CropImageView;
import com.example.fansonlib.image.ImageLoaderUtils;
import com.example.fansonlib.utils.SharePreferenceHelper;
import com.example.fansonlib.utils.ShowToast;
import com.example.fansonlib.widget.dialogfragment.DoubleDialog;
import com.example.fansonlib.widget.dialogfragment.base.IConfirmListener;
import com.yinghai.a24divine_user.Impl.UILImageLoader;
import com.yinghai.a24divine_user.R;
import com.yinghai.a24divine_user.base.MyBaseMvpFragment;
import com.yinghai.a24divine_user.bean.PersonInfoBean;
import com.yinghai.a24divine_user.bean.UploadPictureBean;
import com.yinghai.a24divine_user.constant.ConFragment;
import com.yinghai.a24divine_user.constant.ConHttp;
import com.yinghai.a24divine_user.constant.ConstantPreference;
import com.yinghai.a24divine_user.databinding.FragmentSettingBinding;
import com.yinghai.a24divine_user.module.address.AddressManagerActivity;
import com.yinghai.a24divine_user.module.login.LoginActivity;
import com.yinghai.a24divine_user.module.login.state.LoginStateManager;
import com.yinghai.a24divine_user.module.login.state.LogoutState;
import com.yinghai.a24divine_user.module.setting.person.ContractEditPerson;
import com.yinghai.a24divine_user.module.setting.person.EditPersonPresenter;
import com.yinghai.a24divine_user.rongIm.IMLogin;
import com.yinghai.a24divine_user.utils.ConstellationUtils;
import com.yinghai.a24divine_user.widget.ConstellationWindow;
import com.yinghai.a24divine_user.widget.EditWindow;
import com.yinghai.a24divine_user.widget.PickDatePopuWindow;
import java.util.ArrayList;
/**
* @author Created by:fanson
* Created Time: 2017/10/25 18:21
* Describe:个人设置Fragment
*/
public class SettingFragment extends MyBaseMvpFragment<EditPersonPresenter> implements PickDatePopuWindow.IPickTimeListener, ConstellationWindow.IConstellationListener,
ContractEditPerson.IView {
private static final String TAG = SettingFragment.class.getSimpleName();
private FragmentSettingBinding mBinding;
/**
* 打开图片选择界面requestCode
*/
public static final int IMAGE_PICKER = 100;
private PickDatePopuWindow mPickDatePopuWindow;
private boolean mSex;
private String mPhotoUrl = null;
private EditWindow mEditWindow;
@Override
protected int getLayoutId() {
return R.layout.fragment_setting;
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_setting, container, false);
return mBinding.getRoot();
}
@Override
protected void initToolbarTitle() {
setToolbarTitle(getString(R.string.setting));
}
@Override
protected void initData() {
mBinding.tvUserName.setText(SharePreferenceHelper.getString(ConstantPreference.S_USER_NAME, null));
mBinding.tvTel.setText(SharePreferenceHelper.getString(ConstantPreference.S_PHONE, getString(R.string.not_set)));
ImageLoaderUtils.loadCircleImage(hostActivity, mBinding.ivUserPhoto, ConHttp.BASE_URL + SharePreferenceHelper.getString(ConstantPreference.S_USER_PHOTO, null));
setSex();
setBirthDay();
setConstellation();
}
private void setSex() {
if (SharePreferenceHelper.getBoolean(ConstantPreference.B_USER_SEX, true)) {
mBinding.rbSexBoy.setChecked(true);
mSex = true;
} else {
mBinding.rbSexGirl.setChecked(true);
mSex = false;
}
}
private void setBirthDay() {
String birthday;
if (SharePreferenceHelper.getString(ConstantPreference.S_USER_BIRTHDAY, null) == null) {
birthday = getString(R.string.not_set);
} else {
birthday = SharePreferenceHelper.getString(ConstantPreference.S_USER_BIRTHDAY, null);
}
mBinding.tvBirthday.setText(birthday.split(" ")[0]);
}
private void setConstellation() {
String constellation;
if (SharePreferenceHelper.getInt(ConstantPreference.I_USER_CONSTELLATION, 0) == 0) {
constellation = getString(R.string.not_set);
} else {
constellation = ConstellationUtils.getString(SharePreferenceHelper.getInt(ConstantPreference.I_USER_CONSTELLATION, 0));
}
mBinding.tvConstellation.setText(constellation);
}
@Override
protected void listenEvent() {
super.listenEvent();
mBinding.rgUserSex.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, @IdRes int checkedId) {
switch (checkedId) {
case R.id.rb_sex_boy:
mSex = true;
break;
case R.id.rb_sex_girl:
mSex = false;
break;
default:
break;
}
}
});
mBinding.linearBirthday.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mPickDatePopuWindow = new PickDatePopuWindow(hostActivity);
mPickDatePopuWindow.setPickTimeListener(SettingFragment.this);
mPickDatePopuWindow.showPopupWindow();
}
});
mBinding.tvUserName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mEditWindow == null) {
mEditWindow = new EditWindow();
}
mEditWindow.setListener(new EditWindow.IEditListener() {
@Override
public void getEditContent(String content) {
mBinding.tvUserName.setText(content);
mEditWindow.dismiss();
}
});
mEditWindow.setEtContent(mBinding.tvUserName.getText().toString());
mEditWindow.setOutCancel(true).show(getFragmentManager());
}
});
mBinding.linearAddress.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startMyActivity(AddressManagerActivity.class);
}
});
mBinding.tvConstellation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new ConstellationWindow(hostActivity, SettingFragment.this).showPopupWindow();
}
});
mBinding.linearHeader.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DoubleDialog.newInstance(getString(R.string.whether_to_replace_head)).setConfirmListener(new IConfirmListener() {
@Override
public void onConfirm() {
initImagePicker();
Intent intent = new Intent(hostActivity, ImageGridActivity.class);
startActivityForResult(intent, IMAGE_PICKER);
}
}).show(getFragmentManager());
}
});
mBinding.llLogout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DoubleDialog.newInstance(getString(R.string.sure_logout)).setConfirmListener(new IConfirmListener() {
@Override
public void onConfirm() {
showLoading();
mPresenter.logout();
}
}).show(getFragmentManager());
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (resultCode) {
case ImagePicker.RESULT_CODE_ITEMS:
showPicture(data);
break;
default:
break;
}
}
/**
* 选择好图片后显示
*/
private void showPicture(Intent data) {
if (data != null) {
ArrayList<ImageItem> images = (ArrayList<ImageItem>) data.getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS);
for (int i = 0; i < images.size(); i++) {
ImageItem imageItem = images.get(i);
if (imageItem != null) {
showLoading();
mPhotoUrl = imageItem.path;
mPresenter.uploadPicture(2, mPhotoUrl);
}
}
}
}
/**
* 初始化控件ImagePicker
*/
private void initImagePicker() {
ImagePicker imagePicker = ImagePicker.getInstance();
imagePicker.setImageLoader(new UILImageLoader()); //设置图片加载器
imagePicker.setShowCamera(true); //显示拍照按钮
imagePicker.setCrop(true); //允许裁剪(单选才有效)
imagePicker.setSaveRectangle(true); //是否按矩形区域保存
imagePicker.setSelectLimit(1); //选中数量限制
imagePicker.setStyle(CropImageView.Style.RECTANGLE); //裁剪框的形状
imagePicker.setFocusWidth(800); //裁剪框的宽度。单位像素(圆形自动取宽高最小值)
imagePicker.setFocusHeight(800); //裁剪框的高度。单位像素(圆形自动取宽高最小值)
imagePicker.setOutPutX(1000);//保存文件的宽度。单位像素
imagePicker.setOutPutY(1000);//保存文件的高度。单位像素
}
/**
* 选择生日后,回调数据返回
*/
@Override
public void onPickTime(String year, String month, String day) {
mBinding.tvBirthday.setText(year + "-" + month + "-" + day);
}
@Override
public void getConstellation(String constellation) {
mBinding.tvConstellation.setText(constellation);
}
@Override
protected EditPersonPresenter createPresenter() {
return new EditPersonPresenter(this);
}
/**
* 更新个人信息
*/
public void updatePersonInfo() {
showLoading();
mPresenter.editPerson(mBinding.tvUserName.getText().toString(), mBinding.tvBirthday.getText().toString(),
ConstellationUtils.getCode(mBinding.tvConstellation.getText().toString()),
mSex, mPhotoUrl);
}
@Override
public void showEditPersonSuccess(PersonInfoBean.DataBean bean) {
ShowToast.singleShort(getString(R.string.update_success));
mMultiFragmentListener.onMultiFragment(ConFragment.INFO_CHANGE, bean.getTfUser().getUNick());
hideLoading();
}
@Override
public void showEditPersonFailure(String errMsg) {
ShowToast.singleShort(errMsg);
hideLoading();
}
@Override
public void showUploadSuccess(UploadPictureBean.DataBean bean) {
ImageLoaderUtils.loadCircleImage(hostActivity, mBinding.ivUserPhoto, mPhotoUrl);
mMultiFragmentListener.onMultiFragment(ConFragment.PHOTO_CHANGE, bean.getImgUrl());
hideLoading();
}
@Override
public void showUploadFailure(String errMsg) {
ShowToast.singleShort(errMsg);
hideLoading();
}
@Override
public void showLogoutSuccess() {
//状态模式,设置为已登出
LoginStateManager.getInstance().setState(new LogoutState());
SharePreferenceHelper.clear();
// IM 设置登出
IMLogin.logout();
hideLoading();
startMyActivity(LoginActivity.class);
hostActivity.finish();
}
@Override
public void showLogoutFailure(String errMsg) {
ShowToast.singleShort(errMsg);
hideLoading();
}
@Override
public void onDestroyView() {
super.onDestroyView();
if (mPickDatePopuWindow != null) {
mPickDatePopuWindow.dismiss();
mPickDatePopuWindow = null;
}
}
}
|
package api.validator.helper;
import api.arq.util.AutenticacaoUtil;
import api.model.Aerogerador;
import api.model.ParqueEolico;
import api.model.Usuario;
import api.repository.AerogeradorRepository;
import api.repository.ParqueEolicoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Optional;
@Component
public class AerogeradorValidatorHelper{
@Autowired
private AerogeradorRepository aerogeradorRepository;
@Autowired
private ParqueEolicoRepository parqueEolicoRepository ;
AutenticacaoUtil autenticacaoUtil = new AutenticacaoUtil();
public Boolean existeAerogeradorComNomeInformado(Aerogerador aerogerador) {
Optional<Aerogerador> aerogeradorCadastrado = aerogeradorRepository.findByNome(aerogerador.getNome());
return aerogeradorCadastrado.isPresent() && aerogerador.getId() != aerogeradorCadastrado.get().getId();
}
public Boolean parqueEolicoNaoExiste(Aerogerador aerogerador) {
Optional<Usuario> usuarioAutenticado = autenticacaoUtil.getUsuarioAutenticado();
Optional<ParqueEolico> parqueEolico = parqueEolicoRepository.findById(aerogerador.getParqueEolico().getId());
return !parqueEolico.isPresent();
}
}
|
package structuralPatterns.proxyPattern.forceProxy;
public class GamePlayerProxy implements IGamerPlayer {
private IGamerPlayer gamerPlayer = null;
private String name = "";
public GamePlayerProxy(GamePlayer gamePlayer, String name) {
this.gamerPlayer = gamePlayer;
this.name = name;
}
@Override
public void login(String name) {
this.gamerPlayer.login(name);
}
@Override
public void kill() {
this.gamerPlayer.kill();
}
@Override
public void upgrade() {
this.gamerPlayer.upgrade();
}
@Override
public IGamerPlayer getProxy() {
return null;
}
}
|
package com.example.notebookapp.adapter;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import com.example.notebookapp.R;
import com.example.notebookapp.Models.NoteUserModel;
import java.util.ArrayList;
import java.util.List;
public class NoteBookAdapter extends RecyclerView.Adapter<NoteBookAdapter.NoteBookViewHolder> {
Context context;
List<NoteUserModel> noteUserModels;
public NoteBookAdapter(Context context, List<NoteUserModel> noteUserModels) {
this.context = context;
this.noteUserModels = noteUserModels;
}
@NonNull
@Override
public NoteBookViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
View view = inflater.inflate(R.layout.nootbook_list_item, parent, false);
return new NoteBookViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull NoteBookViewHolder holder, int position) {
holder.txtTitle.setText(noteUserModels.get(position).getTitle());
holder.txtDes.setText(noteUserModels.get(position).getDescription());
}
@Override
public int getItemCount() {
return noteUserModels.size();
}
public class NoteBookViewHolder extends RecyclerView.ViewHolder {
TextView txtTitle,txtDes;
public NoteBookViewHolder(@NonNull View itemView) {
super(itemView);
txtTitle= (TextView) itemView.findViewById(R.id.txtTitle);
txtDes= (TextView) itemView.findViewById(R.id.txtNoteBook);
}
}
}
|
package com.example.demo;
//public interface QuoteRepository extends JpaRepository<Quote, Long> {
//
// Optional<Quote> findByWord(String word);
//}
|
package ru.ermakovis.simpleStorage.common;
public class FileListMessage extends Message {
private final String root;
public FileListMessage(String root) {
this.root = root;
}
public String getRoot() {
return root;
}
}
|
package com.fujitsu.fs.java.pg.swing.layouts;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
public class GridBagLayoutDemo extends JFrame {
public GridBagLayoutDemo() {
initGUI();
}
private void initGUI() {
setTitle("GridBagLayout");
JPanel container = new JPanel();
container.setLayout(new GridBagLayout());
container.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets.right = 12; // JLabel <-> JTextField
gbc.insets.top = 6; // between fields
gbc.gridx = 0;
gbc.gridy = 0;
container.add(new JLabel("First Name"), gbc);
gbc.gridy = 1;
container.add(new JLabel("Last Name"), gbc);
gbc.gridx = 1;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1.0;
container.add(new JTextField(10), gbc);
gbc.gridy = 1;
container.add(new JTextField(10), gbc);
gbc.weightx = 0;
gbc.insets.top = 18; // between form fileds and buttons
gbc.gridx = 0;
gbc.gridy = 2;
gbc.gridwidth = 2;
gbc.fill = GridBagConstraints.HORIZONTAL;
container.add(new JButton("Save"), gbc);
getContentPane().add(container);
pack();
}
public static void main(String[] args) {
JFrame.setDefaultLookAndFeelDecorated(true);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new GridBagLayoutDemo().setVisible(true);
}
});
}
}
|
package interviews.amazon.oa1;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
public class LRUCache {
public static void main(String[] args) {
LRUCache cache = new LRUCache(2);
cache.put(1, 1);
cache.put(2, 2);
System.out.println(cache.get(1));
cache.put(3, 3);
System.out.println(cache.get(2));
cache.put(4, 4);
System.out.println(cache.get(1));
System.out.println(cache.get(3));
System.out.println(cache.get(4));
}
int cap;
Map<Integer, DoubleNode> map;
DoubleNode head;
DoubleNode tail;
public LRUCache(int capacity) {
this.cap = capacity;
head = new DoubleNode(-1, -1);
tail = new DoubleNode(-1, -1);
head.next = tail;
tail.prev = head;
map = new HashMap<Integer, DoubleNode>();
}
public int get(int key) {
if(map.containsKey(key)) moveToHead(map.get(key));
return map.getOrDefault(key, new DoubleNode(-1, -1)).value;
}
public void put(int key, int value) {
DoubleNode node = map.get(key);
if (node == null) {
node = new DoubleNode(key, value);
addToHead(node);
map.put(key, node);
} else {
moveToHead(node);
}
if (map.size() > cap)
removeTail();
}
public void addToHead(DoubleNode node) {
DoubleNode next = head.next;
head.next = node;
node.prev = head;
node.next = next;
next.prev = node;
}
public void removeTail() {
DoubleNode prev = tail.prev;
map.remove(prev.key);
prev.next = null;
tail.prev = null;
tail = prev;
}
public void moveToHead(DoubleNode node) {
node.prev.next = node.next;
node.next.prev = node.prev;
node.prev = null;
node.next = null;
addToHead(node);
}
class DoubleNode {
int key;
int value;
DoubleNode next;
DoubleNode prev;
public DoubleNode(int key, int value) {
this.key = key;
this.value = value;
}
}
class Solution2 {
private LinkedHashMap<Integer, Integer> map;
private int CAPACITY;
public Solution2(int capacity) {
CAPACITY = capacity;
map = new LinkedHashMap<Integer, Integer>(capacity, 0.75f, true){
private static final long serialVersionUID = 1L;
protected boolean removeEldestEntry(Map.Entry<Integer, Integer> eldest) {
return size() > CAPACITY;
}
};
}
public int get(int key) {
return map.getOrDefault(key, -1);
}
public void set(int key, int value) {
map.put(key, value);
}
}
}
|
package com.example.v2.thread.unsafe.lock;
/*
* 为了更清楚的让我们知道是如何加锁和释放锁的,JDK5以后就提供了一个接口:Lock锁。
* Lock
* public void lock():加锁
* public void unlock():释放锁
* 实现类对象
* public ReentrantLock()
*/
public class LockTicketTest {
public static void main(String[] args) {
LockTicket ticket = new LockTicket();
new Thread(ticket, "窗口1").start();
new Thread(ticket, "窗口2").start();
new Thread(ticket, "窗口3").start();
}
}
|
public class Estrella {
private String identificador;
private double campoMagnetico;
private int indiceColor;
public Estrella(String identificador,double campoMagnetico,int indiceColor){
this.identificador=identificador;
this.campoMagnetico=campoMagnetico;
this.indiceColor=indiceColor;
}
public String getIdentificador(){
return identificador;
}
public double getCampoMagnetico(){
return campoMagnetico;
}
public int getIndiceColor(){
return indiceColor;
}
public void desplazar(){
this.campoMagnetico=campoMagnetico-5.5;
this.indiceColor=indiceColor-1;
}
public boolean equals(Estrella estrella){
return this.identificador.equals(estrella.identificador);
}
}
|
package BattleShipTCP;
import java.io.Serializable;
public class OutputView implements Serializable {
public void outputChar(String string){
System.out.print(string);
}
public void outputValue(String string){
System.out.println(string);
}
}
|
package com.tefper.daas.parque.business;
import java.util.List;
import com.tefper.daas.parque.model.ProductInstanceType;
public interface ProductBusiness {
public List<ProductInstanceType> getProductById(String productId);
public List<ProductInstanceType> getProductByPublicIdAndProductType(String publicId, String productType);
}
|
package Lab01.Zad4;
public class DecoyDuck extends Duck {
public DecoyDuck(){
this.quack_behavior = new MuteQuack();
this.fly_behavior = new FlyNoWay();
}
public void display(){
System.out.println("Decoy duck");
}
}
|
package hirondelle.web4j.database;
import java.util.logging.*;
import java.sql.Connection;
import java.sql.SQLException;
import hirondelle.web4j.util.Util;
/**
Type-safe enumeration for transaction isolation levels.
<P>For more information on transaction isolation levels, see {@link Connection} and the
<a href="http://en.wikipedia.org/wiki/Isolation_%28computer_science%29">wikipedia<a/>
article.
<P>See {@link TxTemplate}, which is closely related to this class.
<a name="PermittedValues"></a><h3>Permitted Values</h3>
<P>In order of decreasing strictness (and increasing performance), the levels are :
<ul>
<li><tt>SERIALIZABLE</tt> (most strict, slowest)
<li><tt>REPEATABLE_READ</tt>
<li><tt>READ_COMMITTED</tt>
<li><tt>READ_UNCOMMITTED</tt> (least strict, fastest)
</ul>
<P>In addition, this class includes another item called <tt>DATABASE_DEFAULT</tt>. It
indicates to the WEB4J data layer that, unless instructed otherwise,
the default isolation level defined by the database instance is to be used.
<h3>Differences In The Top 3 Levels</h3>
It is important to understand that the top 3 levels
listed above differ only in one principal respect : behavior for any
<em>re</em>-SELECTs performed in a transaction. <span class="highlight">If no re-SELECT is
performed in a given transaction, then the there is no difference in the
behavior of the top three levels</span> (except for performance).
<P>If a SELECT is repeated in a given transaction, it may see a different
<tt>ResultSet</tt>, since some second transaction may have committed changes
to the underlying data. Three questions can be asked of the second <tt>ResultSet</tt>,
and each isolation level responds to these three questions in a different way :
<P><table border=1 cellspacing="0" cellpadding="3" width="75%">
<tr valign="top">
<th>Level</th>
<th>1. Can a new record appear?</th>
<th>2. Can an old record disappear?</th>
<th>3. Can an old record change?</th>
</tr>
<tr><td><tt>SERIALIZABLE</tt></td><td>Never</td><td>Never</td><td>Never</td></tr>
<tr><td><tt>REPEATABLE_READ</tt></td><td>Possibly</td><td>Never</td><td>Never</td></tr>
<tr><td><tt>READ_COMMITTED</tt></td><td>Possibly</td><td>Possibly</td><td>Possibly</td></tr>
</table>
<P>(Note : 1 is called a <em>phantom read</em>, while both 2 and 3 are called a
<em>non-repeatable read</em>.)
<h3>Configuration In <tt>web.xml</tt></h3>
<em>When no external <tt>Connection</tt> is passed by the application</em>, then
the WEB4J data layer will use an internal <tt>Connection</tt>
set to the isolation level configured in <tt>web.xml</tt>.
<h3>General Guidelines</h3>
<ul>
<li>consult both your database administrator and your database documentation
for guidance regarding these levels
<li><span class="highlight">since support for these levels is highly variable,
setting the transaction isolation level explicitly has low portability</span>
(see {@link #set} for some help in this regard). The <tt>DATABASE_DEFAULT</tt>
setting is an attempt to hide these variations in support
<li>for a WEB4J application, it is likely a good choice to use the
<tt>DATABASE_DEFAULT</tt>, and to alter that level only under special circumstances
<li>selecting a specific level is always a trade-off between level of data
integrity and execution speed
</ul>
<h3>Support For Some Popular Databases</h3>
(Taken from <em>
<a href="http://www.amazon.com/exec/obidos/ASIN/0596004818/ref=nosim/javapractices-20">SQL
in a Nutshell</a></em>, by Kline, 2004. <span class="highlight">Please confirm with
your database documentation</span>).<P>
<table border=1 cellspacing="0" cellpadding="3" width="60%">
<tr valign="top">
<td> </td>
<td>DB2</td>
<td>MySQL</td>
<td>Oracle</td>
<td>PostgreSQL</td>
<td>SQL Server</td>
</tr>
<tr>
<td><tt>SERIALIZABLE</tt></td>
<td>Y</td>
<td>Y</td>
<td>Y</td>
<td>Y</td>
<td>Y</td>
</tr>
<tr>
<td><tt>REPEATABLE_READ</tt></td>
<td>Y</td>
<td>Y*</td>
<td>N</td>
<td>N</td>
<td>Y</td>
</tr>
<tr>
<td><tt>READ_COMMITTED</tt></td>
<td>Y</td>
<td>Y</td>
<td>Y*</td>
<td>Y*</td>
<td>Y*</td>
</tr>
<tr>
<td><tt>READ_UNCOMMITTED</tt></td>
<td>Y</td>
<td>Y</td>
<td>N</td>
<td>N</td>
<td>Y</td>
</tr>
</table>
∗ Database Default<br>
*/
public enum TxIsolationLevel {
SERIALIZABLE("SERIALIZABLE", Connection.TRANSACTION_SERIALIZABLE),
REPEATABLE_READ("REPEATABLE_READ", Connection.TRANSACTION_REPEATABLE_READ),
READ_COMMITTED("READ_COMMITTED", Connection.TRANSACTION_READ_COMMITTED),
READ_UNCOMMITTED("READ_UNCOMMITTED", Connection.TRANSACTION_READ_UNCOMMITTED),
DATABASE_DEFAULT ("DATABASE_DEFAULT", -1);
/**
Return the same underlying <tt>int</tt> value used by {@link Connection} to identify the isolation level.
<P>For {@link #DATABASE_DEFAULT}, return <tt>-1</tt>.
*/
public int getInt(){
return fIntValue;
}
/** Return one of the <a href="#PermittedValues">permitted values</a>, including <tt>'DATABASE_DEFAULT'</tt>. */
public String toString(){
return fText;
}
/**
Set a particular isolation level for <tt>aConnection</tt>.
<P>This method exists because database support for isolation levels varies
widely.<span class="highlight"> If any error occurs because <tt>aLevel</tt> is not supported, then
the error will be logged at a <tt>SEVERE</tt> level, but
the application will continue to run</span>. This policy treats isolation levels
as important, but non-critical. Porting an application to a database which
does not support all levels will not cause an application to fail. The transaction
will simply execute at the database's default isolation level.
<P>Passing in the special value {@link #DATABASE_DEFAULT} will cause a no-operation.
*/
public static void set(TxIsolationLevel aLevel, Connection aConnection){
if( aLevel != DATABASE_DEFAULT ) {
try {
aConnection.setTransactionIsolation(aLevel.getInt());
}
catch (SQLException ex) {
fLogger.severe(
"Cannot set transaction isolation level. Database does " +
"not apparently support '" + aLevel +
"'. You will likely need to choose a different isolation level. " +
"Please see your database documentation, and the javadoc for TxIsolationLevel."
);
}
}
}
// PRIVATE //
private TxIsolationLevel(String aText, int aIntValue){
fText = aText;
fIntValue = aIntValue;
}
private String fText;
private int fIntValue;
private static final Logger fLogger = Util.getLogger(TxIsolationLevel.class);
}
|
package com.codemine.talk2me;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class MySQLiteOpenHelper extends SQLiteOpenHelper {
public static final String CREATE_CONTRACTS = "create table CONTRACTS ("
+ "id integer primary key autoincrement, "
+ "name text, "
+ "time text, "
+ "msg text)";
public static final String CREATE_CHAT = "create table CHAT ("
+ "id integer primary key autoincrement, "
+ "from text, "
+ "to text, "
+ "msg text, "
+ "time text)";
public MySQLiteOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL(CREATE_CONTRACTS);
sqLiteDatabase.execSQL(CREATE_CHAT);
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
}
}
|
package controller;
import dao.puanlarDAO;
import entity.puanlar;
import java.io.Serializable;
import java.util.List;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
@Named
@SessionScoped
public class puanlarController implements Serializable {
private List<puanlar> plist;
private puanlarDAO pdao;
private puanlar puanlar;
private String bul = "";
private int page = 1;
private int pageSize = 5;
private int pageCount;
public void next() {
if (this.page == this.getPageCount()) {
this.page = 1;
} else {
this.page++;
}
}
public void previous() {
if (this.page == 1) {
this.page = this.getPageCount();
} else {
this.page--;
}
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPageCount() {
this.pageCount = (int) Math.ceil(this.getPdao().count() / (double) pageSize);
return pageCount;
}
public void setPageCount(int pageCount) {
this.pageCount = pageCount;
}
@Inject
private filmlerController filmlerController;
@Inject
private uyelerController uyelerController;
public void updateForm(puanlar puan) {
this.puanlar = puan;
}
public void clearForm() {
this.puanlar = new puanlar();
}
public void update() {
this.getPdao().update(this.puanlar);
this.clearForm();
}
public void delete() {
this.getPdao().delete(puanlar);
this.clearForm();
}
public void create() {
this.getPdao().create(this.puanlar);
this.clearForm();
}
public void deleteConfirm(puanlar puan) {
this.puanlar = puan;
}
public List<puanlar> getPlist() {
this.plist = this.getPdao().getPuanlar(this.bul, this.page, this.pageSize);
return plist;
}
public void setPlist(List<puanlar> plist) {
this.plist = plist;
}
public puanlarDAO getPdao() {
if (this.pdao == null) {
this.pdao = new puanlarDAO();
}
return pdao;
}
public void setPdao(puanlarDAO pdao) {
this.pdao = pdao;
}
public puanlar getPuanlar() {
if (this.puanlar == null) {
this.puanlar = new puanlar();
}
return puanlar;
}
public void setPuanlar(puanlar puanlar) {
this.puanlar = puanlar;
}
public filmlerController getFilmlerController() {
return filmlerController;
}
public void setFilmlerController(filmlerController filmlerController) {
this.filmlerController = filmlerController;
}
public uyelerController getUyelerController() {
return uyelerController;
}
public void setUyelerController(uyelerController uyelerController) {
this.uyelerController = uyelerController;
}
public String getBul() {
return bul;
}
public void setBul(String bul) {
this.bul = bul;
}
}
|
package com.fixit.rest.requests;
/**
* Created by Kostyantin on 3/20/2017.
*/
public class APIRequestHeader {
private String userId;
private String installationId;
private String latestScreen;
public APIRequestHeader() { }
public APIRequestHeader(String userId, String installationId, String latestScreen) {
this.userId = userId;
this.installationId = installationId;
this.latestScreen = latestScreen;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getInstallationId() {
return installationId;
}
public void setInstallationId(String installationId) {
this.installationId = installationId;
}
public String getLatestScreen() {
return latestScreen;
}
public void setLatestScreen(String latestScreen) {
this.latestScreen = latestScreen;
}
@Override
public String toString() {
return "APIRequestHeader{" +
"userId='" + userId + '\'' +
", installationId='" + installationId + '\'' +
", latestScreen='" + latestScreen + '\'' +
'}';
}
}
|
package engine.physics;
import org.lwjgl.util.vector.Vector3f;
public interface AABBEntity extends PhysicEntity{
public Vector3f getSize();
public Vector3f getCenter();
}
|
/*연습문제2.다음 조건을 만족하며 클래스 JFrame을 상속받는 클래스를 구현하여 테스트하는 프로그램을 작성하시오.
- 윈도우의 가로와 세로가 각각 300, 150으로, 윈도우의 콘텐트패인 색상을 Color.lightGray로
- 윈도우의 캡션 제목을 "프로그래밍 연습 2"로
- 윈도우의 종료 버튼으로 프로그램도 함께 종료하도록
- 상단에 "OK" 버튼과 하단에 "Cancel" 버튼 추가, BorderLayout의 "North", "South"이용
- 메소드 setDefaultLookAndFeelDecorated(boolean)의 인자를 true, false로 하여 결과를 비교*/
package practice9;
import javax.swing.*;
import java.awt.*;
public class Swing2 extends JFrame{
private JButton btn1, btn2;
public Swing2(String title) {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,150);
setTitle(title);
setBackground(Color.lightGray);
setLayout(new BorderLayout()); // 레이아웃을 보더레이아웃으로설정
btn1 = new JButton("OK"); //버튼내용 OK
btn2 = new JButton("Cancel"); //버튼내용 Cancle
add(btn1, BorderLayout.NORTH); //add(버튼객체,BorderLayout.상수 위치설정
add(btn2, BorderLayout.SOUTH);
setDefaultLookAndFeelDecorated(true); //스윙의 화면이 나옴
//setDefaultLookAndFeelDecorated(false); false값할시 기본윈도우플랫폼이나옴
setVisible(true);
}
public static void main(String[] args) {
Swing2 sw2 = new Swing2("프로그래밍 연습 2");
}
}
|
package com.CollectionQueue;
/**
* Created by Mallika Aruva on 2/16/2018.
*/
public enum Category {
PHONE,
COMPUTER,
IPAD,
}
|
package com.example.zealience.oneiromancy.mvp.contract;
import com.example.zealience.oneiromancy.entity.DreamTypeEntity;
import com.example.zealience.oneiromancy.entity.HomeRecommendEntity;
import com.steven.base.mvp.BaseModel;
import com.steven.base.mvp.BasePresenter;
import com.steven.base.mvp.BaseView;
import java.util.List;
import java.util.Map;
import io.reactivex.Observable;
/**
* @user steven
* @createDate 2019/2/20 11:15
* @description 自定义
*/
public interface HomeContract {
interface View extends BaseView {
void setDreamTypeData(List<DreamTypeEntity> dreamTypeEntityList);
void setBannerDdata(List<Integer> images);
void setHotSearchData(String[] hotSearchData);
void setRecommendData(List<HomeRecommendEntity> homeRecommendEntities);
void showAppAdv(String url,String functionUrl);
}
interface Model extends BaseModel {
Observable<List<DreamTypeEntity>> getDreamType(Map<String, Object> objectMap);
}
abstract class Presenter extends BasePresenter<View, Model> {
public abstract void getHomeDreamTypeData();
public abstract void getHomeBannerData();
public abstract void getHotSearchData();
public abstract void getHomeRecommendData();
public abstract void getAppActivityData();
}
}
|
package com.wb.bot.wbbot.utils;
import com.wb.bot.wbbot.controller.GroupController;
import com.wb.bot.wbbot.controller.MessageController;
import org.apache.commons.beanutils.ConvertUtils;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ReflectUtils {
/**
* 通过反射类获取方法参数名
*
* @param destinationObject 目标对象
* @param methodName 方法名
*/
public static Object invoke(Object destinationObject, String methodName, Map<String, List<String>> parameters) {
Class<?> destinationClass = destinationObject.getClass();
Method[] methods = destinationClass.getMethods();
for (Method method : methods) {
if (methodName.equals(method.getName())) {
Parameter[] params = method.getParameters();
List<Object> args = getParameterValue(params, parameters);
try {
if (args.size() > 0) {
return method.invoke(destinationObject, args.toArray());
} else {
return method.invoke(destinationObject);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return null;
}
private static List<Object> getParameterValue(Parameter[] params, Map<String, List<String>> parameters) {
List<Object> args = new ArrayList<>();
for (Parameter parameter : params) {
Type type = parameter.getParameterizedType();
List<String> list = parameters.get(parameter.getName());
if (list != null) {
try {
args.add(ConvertUtils.convert(list.get(0), Class.forName(type.getTypeName())));
} catch (ClassNotFoundException e) {
args.add(null);
}
} else {
args.add(null);
}
}
return args;
}
}
|
package ch.epfl.tchu.game;
import ch.epfl.tchu.Preconditions;
import ch.epfl.tchu.SortedBag;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static ch.epfl.tchu.game.Constants.MAX_ROUTE_LENGTH;
import static ch.epfl.tchu.game.Constants.MIN_ROUTE_LENGTH;
/**
* Route Class
* Class that allows us to represent a road connecting two neighboring towns
*
* @author Martin Sanchez Lopez (313238)
*/
public final class Route {
/**
* A level (~elevation).
*/
public enum Level {
OVERGROUND, UNDERGROUND
}
private final String id;
private final Station station1, station2;
private final int length;
private final Level level;
private final Color color;
/**
* Constructs a Route with and id, 2 different stations, a length, a level and a color (or none).
*
* @param id id of the route
* @param station1 station 1
* @param station2 station 2
* @param length length of the route
* @param level level of the route
* @param color color of the route
* can be null
* @throws IllegalArgumentException if station1 is equal to station2
* @throws IllegalArgumentException if length is smaller than MIN_ROUTE_LENGTH
* or length is bigger than MAX_ROUTE_LENGTH
* @throws NullPointerException if id, station1, station2 or level is null
*/
public Route(String id, Station station1, Station station2, int length, Level level, Color color) {
Preconditions.checkArgument(!station1.equals(station2));
Preconditions.checkArgument(length >= MIN_ROUTE_LENGTH && length <= MAX_ROUTE_LENGTH);
this.id = Objects.requireNonNull(id);
this.station1 = Objects.requireNonNull(station1);
this.station2 = Objects.requireNonNull(station2);
this.level = Objects.requireNonNull(level);
this.length = length;
this.color = color;
}
/**
* Returns the id of the route.
*
* @return the id of the route
*/
public String id() {
return id;
}
/**
* Returns the station 1 of this route.
*
* @return the station 1 of this route
*/
public Station station1() {
return station1;
}
/**
* Returns the station 2 of this route.
*
* @return the station 2 of this route
*/
public Station station2() {
return station2;
}
/**
* Returns the a list with both stations of this route.
*
* @return the a list with both stations of this route
*/
public List<Station> stations() {
return List.of(station1, station2);
}
/**
* Returns the opposite station of this route to the station given.
*
* @param station station opposite of the station to be returned
* @return the opposite station of this route to the station given
* @throws IllegalArgumentException if the station given is not one of the stations of this Route
*/
public Station stationOpposite(Station station) {
Preconditions.checkArgument(station.equals(station1) || station.equals(station2));
return (station == station1) ? station2 : station1;
}
/**
* Returns a list of card combinations that are possible to play to claim this route.
*
* @return a list of card combinations that are possible to play to claim this route
*/
public List<SortedBag<Card>> possibleClaimCards() {
List<SortedBag<Card>> cardCombinations = new ArrayList<>();
List<Color> colors;
boolean isUnderground = level == Level.UNDERGROUND;
if (color == null) {
colors = Color.ALL;
} else {
colors = List.of(color);
}
if (isUnderground) {
for (int i = 0; i < length; i++) {
for (Color c : colors) {
cardCombinations.add(SortedBag.of(length - i, Card.of(c), i, Card.LOCOMOTIVE));
}
}
//add all locomotive combination at end
cardCombinations.add(SortedBag.of(length, Card.LOCOMOTIVE));
}
if (!isUnderground) {
for (Color c : colors) {
cardCombinations.add(SortedBag.of(length, Card.of(c)));
}
}
return cardCombinations;
}
/**
* Returns the number of additional card a players has to play to claim an underground road.
*
* @param claimCards cards the player played to initiate the claim on road
* @param drawnCards cards the player drew after playing his cards to claim the road
* @return the number of additional card a players has to play to claim an underground road
* @throws IllegalArgumentException if this road is not UNDERGROUND
* if the number of <code>drawnCards</code> is not equal to the number of cards to draw
* for tunnel acquisition by <code>Constant</code>
*/
public int additionalClaimCardsCount(SortedBag<Card> claimCards, SortedBag<Card> drawnCards) {
int nbOfCards = drawnCards.size();
Preconditions.checkArgument(level == Level.UNDERGROUND);
Preconditions.checkArgument(nbOfCards == Constants.ADDITIONAL_TUNNEL_CARDS);
int cardCount = 0;
boolean hasLocomotive = false;
ArrayList<Color> colors = new ArrayList<>();
if (claimCards.contains(Card.LOCOMOTIVE)) {
hasLocomotive = true;
}
//add colors that players played
for (Card c : claimCards) {
if (!c.equals(Card.LOCOMOTIVE) && !colors.contains(c.color())) {
colors.add(c.color());
}
}
//counts additional cards to play
for (Card card : drawnCards) {
if ((hasLocomotive && colors.isEmpty() && card.equals(Card.LOCOMOTIVE))
|| colors.contains(card.color())
|| card.equals(Card.LOCOMOTIVE)) {
cardCount += 1;
}
}
return cardCount;
}
/**
* Returns the number of points that the construction of this road rewards.
*
* @return the number of points that the construction of this road rewards
*/
public int claimPoints() {
return Constants.ROUTE_CLAIM_POINTS.get(length);
}
/**
* Returns the length of this Route.
*
* @return the length of this Route
*/
public int length() {
return length;
}
/**
* Retuns the level of this Route.
*
* @return the level of this Route
*/
public Level level() {
return level;
}
/**
* Returns the color of this Route.
*
* @return the color of this Route
*/
public Color color() {
return color;
}
}
|
package main;
import java.util.ArrayList;
import java.util.Iterator;
interface Observer{
public void update(Gishe gishe);
}
public class ObserverPattern {
ArrayList<Observer> observers = new ArrayList<Observer>();
public void registerObserver(Observer o)
{
observers.add(o);
}
public void unregisterObserver(Observer o)
{
observers.remove(observers.indexOf(o));
}
public void notifyObservers(Gishe gishe)
{
for(Iterator<Observer> it = observers.iterator(); it.hasNext();)
{
Observer o = it.next();
o.update(gishe);
}
}
}
|
package com.company;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
public class Main {
public static void main(String[] args) {
Digit digit = new Digit();
String GetPath = new File("").getAbsolutePath() + "/src/Inputs/Inputfile.txt";
Path file = Paths.get(GetPath);
AccountReader reader = new AccountReader(file);
System.out.println(reader.GetAllAccounts());
}
}
|
package com.ydl.iec.iec104.server.slave;
import com.ydl.iec.iec104.common.BasicInstruction104;
import com.ydl.iec.iec104.message.MessageDetail;
import com.ydl.iec.iec104.server.handler.ChannelHandler;
import com.ydl.iec.iec104.server.handler.DataHandler;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class SysDataHandler implements DataHandler {
@Override
public void handlerAdded(ChannelHandler ctx) throws Exception {
ctx.writeAndFlush(BasicInstruction104.getEndGeneralCallRuleDetail104());
}
@Override
public void channelRead(ChannelHandler ctx, MessageDetail ruleDetail104) throws Exception {
// log.info("启动字符:" + ruleDetail104.getStart());
// log.info("字节长度:" + ruleDetail104.getApuuLength());
// log.info("控制域:" + ruleDetail104.getControl());
// log.info("类型标识:" + ruleDetail104.getTypeIdentifier().getValue());
// log.info("可变结构限定词:" + ruleDetail104.isContinuous());
// log.info("数据长度:" + ruleDetail104.getMeasgLength());
// log.info("传输原因:" + ruleDetail104.getTransferReason());
// log.info("终端地址:" + ruleDetail104.getTerminalAddress());
// log.info("消息地址:" + ruleDetail104.getMessageAddress());
// log.info("消息结构:" + ruleDetail104.getMessages());
// log.info("是否有消息元素:" + ruleDetail104.isMessage());
// log.info("判断是否有限定词:" + ruleDetail104.isQualifiers());
// log.info("判断是否有时标:" + ruleDetail104.isTimeScaleExit());
// log.info("判断消息是否连续:" + ruleDetail104.isContinuous());
// if(ruleDetail104.getMeasgLength()>0){
// for (int i = 0; i<ruleDetail104.getMeasgLength();i++) {
// log.info(String.valueOf(ruleDetail104.getMessages().get(i)));
// }
// }
// try {
// log.info("是否有消息元素:" + ruleDetail104.getQualifiers().getValue());
// }catch (Exception e){}
//
// log.info("限定词:" + ruleDetail104.getQualifiers().getValue());
// log.info("时标:" + ruleDetail104.getTimeScale());
// log.info("限定词:" + ruleDetail104.getHexString());
//
// System.out.println(ruleDetail104);
// System.err.print("收到消息");
}
}
|
package com.douane.entities;
import java.io.Serializable;
import javax.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.sql.Timestamp;
import java.util.Date;
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
@NamedQuery(name="Contrevisite.findAll", query="SELECT c FROM Contrevisite c")
public class Contrevisite implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Long id ;
@Column(name="flag")
private boolean flag ;
@Column(name="num_bl")
private String numBl;
@Column(name="date_enr")
@Temporal(TemporalType.DATE)
private Date dateEnr;
@Column(name="num_cts")
private String numCts;
@Column(name="code_bur")
private short codeBur;
@Column(name="an_manif")
@Temporal(TemporalType.DATE)
private Date anManif;
@Column(name="num_manif")
private int numManif;
@Column(name="num_ligne")
private short numLigne;
@Column(name="num_group")
private short numGroup;
@Column(name="type_controle")
private String typeControle;
@Column(name="wuser")
private String user;
}
|
package com.github.repo;
import com.github.model.VotePerson;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface VotePersonRepository extends JpaRepository<VotePerson, String> {
@Query("select v from VotePerson v")
Page<VotePerson> findAll(Pageable pageable);
@Query(value = "select * from VOTE_PERSON v where v.ST_PERSON_NAME = ?1",nativeQuery = true)
Page<VotePerson> findVotePeopleByStPersonName(String stPersonName, Pageable pageable);
@Query(value = "select * from VOTE_PERSON v where v.ST_PERSON_NAME = :stPersonName",nativeQuery = true)
Page<VotePerson> findVotePeopleByStPersonName2(@Param("stPersonName")String stPersonName, Pageable pageable);
}
|
package JogoDaVelha;
public class Jogadores {
String simbolo;
public void representa(String simbolo) {
this.simbolo = simbolo;
}
}
|
package com.fleet.properties.controller;
import com.fleet.properties.property.UserProperties;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("/user")
public class UserController {
@Resource
UserProperties userProperties;
@RequestMapping("/get")
public Object get() {
return userProperties;
}
}
|
package com.example.fincost.Adapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.example.fincost.Model.Movimentacao;
import com.example.fincost.R;
import com.example.fincost.help.Preferencias;
import java.util.ArrayList;
public class MovimentoAdapter extends ArrayAdapter<Movimentacao> {
private Context context;
private ArrayList <Movimentacao> movimentacao;
public MovimentoAdapter(@NonNull Context c, ArrayList<Movimentacao> objects) {
super(c, 0, objects);
this.context = c;
this.movimentacao = objects;
}
@SuppressLint("ResourceAsColor")
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
View view = null;
if(movimentacao != null){
//Recuperar Usuário
Preferencias preferencias = new Preferencias(context);
String idUsuario = preferencias.getIdentificador();
//Iniciar montagem do layout
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
Movimentacao movimento = movimentacao.get(position);
view = layoutInflater.inflate(R.layout.movimentacao_list, parent, false);
//Recuperar elementos
TextView tipoTexto = view.findViewById(R.id.tipoMovimento);
TextView descricao = view.findViewById(R.id.descricaoMovimento);
TextView dataMovimento = view.findViewById(R.id.dataMovimento);
TextView valorMovimento = view.findViewById(R.id.valorMovimento);
tipoTexto.setText(movimento.getTipo());
descricao.setText(movimento.getDescricao());
dataMovimento.setText(movimento.getData());
if(movimento.getCategoria().equals("Despesa")) {
valorMovimento.setText("-" + movimento.getValor().toString());
valorMovimento.setTextColor(Color.rgb(178,34,34));
} else if (movimento.getCategoria().equals("Receita")){
valorMovimento.setText(movimento.getValor().toString());
valorMovimento.setTextColor(Color.rgb(0,255,127));
}else {
valorMovimento.setText(movimento.getValor().toString());
valorMovimento.setTextColor(Color.rgb(135,206,235));
}
}
return view;
}
}
|
package com.eugenesokolov.dict.service.impl;
import com.eugenesokolov.dict.model.TranslationWord;
import com.eugenesokolov.dict.service.GoogleSheetMapperService;
import com.eugenesokolov.dict.service.GoogleSheetsService;
import com.eugenesokolov.dict.service.SpreadSheetService;
import com.google.api.services.sheets.v4.Sheets;
import com.google.api.services.sheets.v4.model.ValueRange;
import io.reactivex.Observable;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
@Component
class SpreadSheetServiceImpl implements SpreadSheetService {
private static final String CELLS_RANGE = "A:D";
@Resource
private GoogleSheetsService googleSheetsService;
@Resource
private GoogleSheetMapperService googleSheetMapperService;
@Override
public Observable<TranslationWord> fromSpreadSheet(String documentId) {
return Observable.fromCallable(googleSheetsService::getSheetsService)
.map(gService -> extraValueRange(documentId, gService))
.map(ValueRange::getValues)
.map(googleSheetMapperService::mapResults)
.flatMap(this::toObservableArray);
}
private ValueRange extraValueRange(String documentId, Sheets gService) throws java.io.IOException {
return gService.spreadsheets().values().get(documentId, CELLS_RANGE).execute();
}
private Observable<TranslationWord> toObservableArray(List<TranslationWord> translationWords) {
return Observable.fromArray(translationWords.toArray(new TranslationWord[0]));
}
}
|
package com.tencent.mm.plugin.freewifi.d;
import android.os.Build;
import com.tencent.mm.ab.b.a;
import com.tencent.mm.protocal.c.ast;
import com.tencent.mm.protocal.c.asu;
import com.tencent.mm.protocal.c.asv;
import java.util.LinkedList;
public final class j extends c {
protected final void aOR() {
a aVar = new a();
aVar.dIG = new ast();
aVar.dIH = new asu();
aVar.uri = "/cgi-bin/mmo2o-bin/manufacturerapinfo";
aVar.dIF = 1707;
aVar.dII = 0;
aVar.dIJ = 0;
this.diG = aVar.KT();
}
public final int getType() {
return 1707;
}
public j(LinkedList<asv> linkedList, int i) {
aOR();
ast ast = (ast) this.diG.dID.dIL;
ast.rVc = Build.BRAND;
ast.rVb = i;
ast.rVa = linkedList;
}
public final asu aPe() {
return (asu) this.diG.dIE.dIL;
}
}
|
package com.itfdms.auth.util;
import com.itfdms.common.constant.CommonConstant;
import com.itfdms.common.constant.SecurityConstants;
import com.itfdms.common.vo.SysRole;
import com.itfdms.common.vo.UserVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* java类简单作用描述
*
* @ProjectName: itfdms_blog
* @Package: com.itfdms.auth.util
* @ClassName: ${CLASS_NAME}
* @Description: java类作用描述
* @Author: lxr
* @CreateDate: 2018-08-22 21:21
* @UpdateUser: lxr
* @UpdateDate: 2018-08-22 21:21
* @UpdateRemark: The modified content
* @Version: 1.0
**/
public class UserDetailsImpl implements UserDetails {
private static final long serialVersionUID = 1L;
private String username;
private String password;
private String status;
private List<SysRole> roleList = new ArrayList<>();
public UserDetailsImpl(UserVO userVO) {
this.username = userVO.getUserName();
this.password = userVO.getPassWord();
this.status = userVO.getDelFlag();
roleList = userVO.getRoleList();
}
/**
* Returns the authorities granted to the user. Cannot return <code>null</code>.
*
* @return the authorities, sorted by natural key (never <code>null</code>)
*/
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
List<GrantedAuthority> authorityList = new ArrayList<>();
for (SysRole role : roleList) {
authorityList.add(new SimpleGrantedAuthority(role.getRoleCode()));
}
authorityList.add(new SimpleGrantedAuthority(SecurityConstants.BASE_ROLE));
return authorityList;
}
/**
* Returns the password used to authenticate the user.
*
* @return the password
*/
@Override
public String getPassword() {
return this.password;
}
/**
* Returns the username used to authenticate the user. Cannot return <code>null</code>.
*
* @return the username (never <code>null</code>)
*/
@Override
public String getUsername() {
return this.username;
}
/**
* Indicates whether the user's account has expired. An expired account cannot be
* authenticated.
*
* @return <code>true</code> if the user's account is valid (ie non-expired),
* <code>false</code> if no longer valid (ie expired)
*/
@Override
public boolean isAccountNonExpired() {
return false;
}
/**
* Indicates whether the user is locked or unlocked. A locked user cannot be
* authenticated.
*
* @return <code>true</code> if the user is not locked, <code>false</code> otherwise
*/
@Override
public boolean isAccountNonLocked() {
return StringUtils.equals(CommonConstant.STATUS_LOCK, status);
}
/**
* Indicates whether the user's credentials (password) has expired. Expired
* credentials prevent authentication.
*
* @return <code>true</code> if the user's credentials are valid (ie non-expired),
* <code>false</code> if no longer valid (ie expired)
*/
@Override
public boolean isCredentialsNonExpired() {
return true;
}
/**
* Indicates whether the user is enabled or disabled. A disabled user cannot be
* authenticated.
*
* @return <code>true</code> if the user is enabled, <code>false</code> otherwise
*/
@Override
public boolean isEnabled() {
return StringUtils.equals(CommonConstant.STATUS_NORMAL, status);
}
public void setUsername(String username) {
this.username = username;
}
public void setPassword(String password) {
this.password = password;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public List<SysRole> getRoleList() {
return roleList;
}
public void setRoleList(List<SysRole> roleList) {
this.roleList = roleList;
}
}
|
package ars.ramsey.interviewhelper.model.local;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Callable;
import ars.ramsey.interviewhelper.model.TasksSource;
import ars.ramsey.interviewhelper.model.bean.Task;
import ars.ramsey.interviewhelper.model.bean.TodoTask;
import ars.ramsey.interviewhelper.model.local.TasksPersistenceContract.TaskEntry;
import ars.ramsey.interviewhelper.model.local.TodoTasksPersistenceContract.TodoTasksEntry;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Scheduler;
import io.reactivex.annotations.NonNull;
import io.reactivex.schedulers.Schedulers;
/**
* Created by Ramsey on 2017/4/7.
*/
public class TasksLocalSource implements TasksSource {
private DbHelper dbHelper;
private static TasksLocalSource instance;
private static final int PAGE_SIZE = 10;
private TasksLocalSource(Context context)
{
dbHelper = new DbHelper(context);
}
public static TasksLocalSource getInstance(Context context)
{
if(instance == null)
{
synchronized (TasksLocalSource.class)
{
if(instance == null)
instance = new TasksLocalSource(context);
}
}
return instance;
}
@Override
public Observable<List<Task>> getTasks(final int page)
{
return makeObservable(new Callable<List<Task>>() {
@Override
public List<Task> call() throws Exception {
List<Task> tasks = new ArrayList<>();
SQLiteDatabase db = dbHelper.getReadableDatabase();
String[] projection = {
TaskEntry.COLUMN_NAME_ID,
TaskEntry.COLUMN_NAME_COMPANY_NAME,
TaskEntry.COLUMN_NAME_JOB_NAME,
TaskEntry.COLUMN_NAME_STATUS,
TaskEntry.COLUMN_NAME_NEXT_DATE,
TaskEntry.COLUMN_NAME_ADDRESS
};
int offset = (page - 1) * PAGE_SIZE;
String limit = String.valueOf(offset)+"," + PAGE_SIZE;
Cursor c = db.query(TaskEntry.TABLE_NAME,projection,"completed = ?",new String[]{"0"},null,null,"id asc",limit);
if(c != null && c.getCount() > 0)
{
while(c.moveToNext())
{
int id = c.getInt(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_ID));
String companyName = c.getString(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_COMPANY_NAME));
String jobName = c.getString(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_JOB_NAME));
String status = c.getString(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_STATUS));
String nextDate = c.getString(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_NEXT_DATE));
String address = c.getString(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_ADDRESS));
Task task = new Task(id,companyName,jobName,status,nextDate,address);
tasks.add(task);
}
}
if(c != null)
c.close();
db.close();
return tasks;
}
}).subscribeOn(Schedulers.computation());
}
@Override
public Observable<Task> getTask(final int taskId)
{
return makeObservable(new Callable<Task>() {
@Override
public Task call() throws Exception {
Task task = null;
SQLiteDatabase db = dbHelper.getReadableDatabase();
Cursor c = db.query(TaskEntry.TABLE_NAME,null,"id=?",new String[]{String.valueOf(taskId)},null,null,null);
if(c != null && c.getCount() == 1)
{
while(c.moveToNext())
{
int id = c.getInt(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_ID));
String companyName = c.getString(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_COMPANY_NAME));
String jobName = c.getString(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_JOB_NAME));
String status = c.getString(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_STATUS));
String createDate = c.getString(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_CREATE_DATE));
String nextDate = c.getString(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_NEXT_DATE));
String finishDate = c.getString(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_FINISHED_DATE));
String address = c.getString(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_ADDRESS));
int offer = c.getInt(c.getColumnIndexOrThrow(TaskEntry.COLUMN_NAME_OFFER));
task = new Task(id,companyName,jobName,status,createDate,nextDate,finishDate,offer == 1?true:false,address);
}
}
if(c != null)
c.close();
db.close();
return task;
}
}).subscribeOn(Schedulers.computation());
}
@Override
public Observable saveTask(final Task task)
{
return makeObservable(new Callable() {
@Override
public Object call() throws Exception {
Log.i("RAMSEY","Save Task!");
SQLiteDatabase db = dbHelper.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(TaskEntry.COLUMN_NAME_COMPANY_NAME,task.getCompanyName());
contentValues.put(TaskEntry.COLUMN_NAME_JOB_NAME,task.getJobName());
contentValues.put(TaskEntry.COLUMN_NAME_STATUS,task.getStatus());
contentValues.put(TaskEntry.COLUMN_NAME_CREATE_DATE,task.getCreateDate());
contentValues.put(TaskEntry.COLUMN_NAME_NEXT_DATE,task.getNextDate());
contentValues.put(TaskEntry.COLUMN_NAME_FINISHED_DATE,task.getFinishedDate());
contentValues.put(TaskEntry.COLUMN_NAME_COMPLETED,task.isCompleted());
contentValues.put(TaskEntry.COLUMN_NAME_OFFER,task.isOffer());
contentValues.put(TaskEntry.COLUMN_NAME_ADDRESS,task.getAddress());
long id = db.insert(TaskEntry.TABLE_NAME,null,contentValues);
if(!task.getNextDate().equals("")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
try {
Date date = sdf.parse(task.getNextDate());
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
ContentValues todoValues = new ContentValues();
todoValues.put(TodoTasksEntry.COLUMN_NAME_ID, id);
todoValues.put(TodoTasksEntry.COLUMN_NAME_COMPANY_NAME, task.getCompanyName());
todoValues.put(TodoTasksEntry.COLUMN_NAME_YEAR, calendar.get(Calendar.YEAR));
todoValues.put(TodoTasksEntry.COLUMN_NAME_MONTH, calendar.get(Calendar.MONTH)+1);
todoValues.put(TodoTasksEntry.COLUMN_NAME_DAY, calendar.get(Calendar.DAY_OF_MONTH));
db.insert(TodoTasksEntry.TABLE_NAME, null, todoValues);
} catch (ParseException e) {
Log.e("RAMSEY", "SAVE TO DO TASK ERROR!");
e.printStackTrace();
}
}
db.close();
return "";
}
}).subscribeOn(Schedulers.computation());
}
@Override
public Observable updateTask(final Task task)
{
return makeObservable(new Callable() {
@Override
public Object call() throws Exception {
try{
SQLiteDatabase db = dbHelper.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(TaskEntry.COLUMN_NAME_COMPANY_NAME,task.getCompanyName());
contentValues.put(TaskEntry.COLUMN_NAME_JOB_NAME,task.getJobName());
contentValues.put(TaskEntry.COLUMN_NAME_STATUS,task.getStatus());
contentValues.put(TaskEntry.COLUMN_NAME_CREATE_DATE,task.getCreateDate());
contentValues.put(TaskEntry.COLUMN_NAME_NEXT_DATE,task.getNextDate());
contentValues.put(TaskEntry.COLUMN_NAME_FINISHED_DATE,task.getFinishedDate());
contentValues.put(TaskEntry.COLUMN_NAME_COMPLETED,task.isCompleted());
contentValues.put(TaskEntry.COLUMN_NAME_OFFER,task.isOffer());
contentValues.put(TaskEntry.COLUMN_NAME_ADDRESS,task.getAddress());
db.update(TaskEntry.TABLE_NAME,contentValues,"id=?",new String[]{String.valueOf(task.getId())});
if(!task.getNextDate().equals("")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
try {
Date date = sdf.parse(task.getNextDate());
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
ContentValues todoValues = new ContentValues();
todoValues.put(TodoTasksEntry.COLUMN_NAME_COMPANY_NAME, task.getCompanyName());
todoValues.put(TodoTasksEntry.COLUMN_NAME_YEAR, calendar.get(Calendar.YEAR));
todoValues.put(TodoTasksEntry.COLUMN_NAME_MONTH, calendar.get(Calendar.MONTH)+1);
todoValues.put(TodoTasksEntry.COLUMN_NAME_DAY, calendar.get(Calendar.DAY_OF_MONTH));
Cursor c = db.query(TodoTasksEntry.TABLE_NAME,null,"id=?",new String[]{String.valueOf(task.getId())},null,null,null);
if(c == null || c.getCount() == 0)
{
todoValues.put(TodoTasksEntry.COLUMN_NAME_ID,task.getId());
db.insert(TodoTasksEntry.TABLE_NAME,null,todoValues);
Log.i("RAMSEY","new to do task");
}else{
db.update(TodoTasksEntry.TABLE_NAME, todoValues,"id=?",new String[]{String.valueOf(task.getId())});
Log.i("RAMSEY","update to do task");
}
} catch (ParseException e) {
Log.e("RAMSEY", "SAVE TO DO TASK ERROR!");
e.printStackTrace();
throw e;
}
}
db.close();
}catch (Exception e)
{
Log.i("RAMSEY","exception");
throw e;
}
return "";
}
}).subscribeOn(Schedulers.computation());
}
@Override
public Observable<List<TodoTask>> getTasksByMonth(final Date date)
{
return makeObservable(new Callable<List<TodoTask>>() {
@Override
public List<TodoTask> call() throws Exception {
List<TodoTask> tasks = new ArrayList<>();
SQLiteDatabase db = dbHelper.getReadableDatabase();
String[] projection = {
TodoTasksEntry.COLUMN_NAME_ID,
TodoTasksEntry.COLUMN_NAME_COMPANY_NAME,
TodoTasksEntry.COLUMN_NAME_YEAR,
TodoTasksEntry.COLUMN_NAME_MONTH,
TodoTasksEntry.COLUMN_NAME_DAY,
};
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int queryYear = calendar.get(Calendar.YEAR);
int queryMonth = calendar.get(Calendar.MONTH)+1;
Log.i("RAMSEY","query:"+queryYear+":"+queryMonth);
Cursor c = db.query(TodoTasksEntry.TABLE_NAME,projection,"year = ? and month = ?",new String[]{String.valueOf(queryYear),String.valueOf(queryMonth)},null,null,"id asc");
if(c != null && c.getCount() > 0)
{
while(c.moveToNext())
{
int id = c.getInt(c.getColumnIndexOrThrow(TodoTasksEntry.COLUMN_NAME_ID));
String companyName = c.getString(c.getColumnIndexOrThrow(TodoTasksEntry.COLUMN_NAME_COMPANY_NAME));
int year = c.getInt(c.getColumnIndexOrThrow(TodoTasksEntry.COLUMN_NAME_YEAR));
int month = c.getInt(c.getColumnIndexOrThrow(TodoTasksEntry.COLUMN_NAME_MONTH));
int day = c.getInt(c.getColumnIndexOrThrow(TodoTasksEntry.COLUMN_NAME_DAY));
TodoTask task = new TodoTask(id,companyName,year,month,day);
tasks.add(task);
}
}
if(c != null)
c.close();
db.close();
return tasks;
}
}).subscribeOn(Schedulers.computation());
}
@Override
public void completeTask(Task task) {
}
@Override
public void completeTask(String taskId) {
}
@Override
public void activateTask(Task task) {
}
@Override
public void activateTask(String taskId) {
}
@Override
public void clearCompletedTasks() {
}
@Override
public void refreshTasks() {
}
@Override
public void deleteAllTasks() {
}
@Override
public Observable deleteTask(final int taskId)
{
return makeObservable(new Callable() {
@Override
public Object call() throws Exception {
SQLiteDatabase db = dbHelper.getWritableDatabase();
try
{
db.delete(TaskEntry.TABLE_NAME,"id=?",new String[]{String.valueOf(taskId)});
}catch (Exception e)
{
Log.e("RAMSEY","delete failed");
throw e;
}
return "";
}
}).subscribeOn(Schedulers.computation());
}
private <T> Observable<T> makeObservable(final Callable<T> func)
{
return Observable.create(new ObservableOnSubscribe<T>() {
@Override
public void subscribe(@NonNull ObservableEmitter<T> emitter) throws Exception {
try{
emitter.onNext(func.call());
}catch (Exception e)
{
Log.e("RAMSEY","Error in processing database");
emitter.onError(e);
}finally {
emitter.onComplete();
}
}
});
}
}
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Stack;
/**
*
* @author asus
*/
public class Test {
public static void main(String[] args) {
Stack<Integer> intStack = new Stack<>();
intStack.pop();
intStack.print();
System.out.println("size : " + intStack.size());
intStack.push(5);
intStack.push(7);
System.out.println("peek : " + intStack.peek());
intStack.push(3);
intStack.print();
System.out.println("size : " + intStack.size());
Node<Integer> pop1 = intStack.pop();
Node<Integer> pop2 = intStack.pop();
intStack.push(pop1);
intStack.push(pop2);
intStack.print();
System.out.println("size : " + intStack.size());
System.out.print("15 to binary : ");
decToBinary(15);
System.out.println("kek - isPalindrome : " + isPalindrome("kek"));
System.out.println("fsm - isPalindrome : " + isPalindrome("fsm"));
System.out.println("202 - isPalindrome : " + isPalindrome("202"));
System.out.println("kelime : " + reverseRecursive("kelime"));
}
static void decToBinary(int number) {
Stack<Integer> intStack = new Stack<>();
while (number > 0) {
intStack.push(number % 2);
number /= 2;
}
while (intStack.peek() != null) {
System.out.print(intStack.pop());
}
System.out.println();
}
static boolean isPalindrome(String text) {
boolean isPalindrome = true;
Stack<Character> charStack = new Stack<>();
for (int i = 0; i < text.length(); i++) {
charStack.push(text.charAt(i));
}
for (int i = 0; i < text.length(); i++) {
if (charStack.pop().data != text.charAt(i)) {
isPalindrome = false;
break;
}
}
return isPalindrome;
}
// kelime - emilek
static String reverseRecursive(String word) {
if (word.isEmpty()) {
return "";
} else {
char c = word.charAt(0);
return reverseRecursive(word.substring(1)) + c;
}
}
}
|
package services;
import entity.User;
import play.db.jpa.Transactional;
import play.mvc.Controller;
import play.mvc.Result;
import repositories.UserRepository;
/**
* Created by Manuel on 24.10.17.
*/
public class LoginService extends Controller {
//POST
//Use body for parameters
@Transactional
public Result login(String email, String password) {
User u1 = UserRepository.findByEmail(email);
if(u1 != null) {
String userPw = u1.getPassword();
if(userPw.equals(password)) {
u1.setRandomString();
return ok(u1.getRandomString());
} else {
return status(FORBIDDEN);
}
} else {
return status(NOT_FOUND);
}
}
}
|
package com.jim.multipos.ui.product_class_new.model;
import com.jim.multipos.data.db.model.ProductClass;
import com.jim.multipos.ui.product_class_new.adapters.ProductsClassListAdapter;
/**
* Created by developer on 01.11.2017.
*/
public class ProductsClassAdapterDetials {
ProductClass object;
ProductsClassListAdapter.ProductClassItemTypes type;
ProductClass changedObject;
public boolean setNewName(String newName){
if(!object.getName().equals(newName) || changedObject!=null){
getChangedObject().setName(newName);
}
return isChanged();
}
public boolean setNewActive(boolean newActive){
if(object.getActive()!=newActive || changedObject !=null){
getChangedObject().setActive(newActive);
}
return isChanged();
}
public String getActualName(){
return (isChanged())?changedObject.getName():object.getName();
}
public boolean getActualActive(){
return (isChanged())?changedObject.getActive():object.getActive();
}
public void setType(ProductsClassListAdapter.ProductClassItemTypes type){
this.type = type;
}
public ProductsClassListAdapter.ProductClassItemTypes getType(){
return type;
}
public ProductClass getObject(){
return object;
}
public ProductClass getChangedObject(){
if(changedObject==null && object!=null)
changedObject = object.copy();
return changedObject;
}
public boolean isChanged(){
return changedObject!=null;
}
public void setChangedObject(ProductClass changedObject){
this.changedObject = changedObject;
}
public void setObject(ProductClass object){
this.object = object;
}
public void contanierMode(){
object = new ProductClass();
object.setActive(true);
object.setName("");
}
}
|
package org.abigballofmud.flink.practice.app.constansts;
/**
* <p>
* description
* </p>
*
* @author isacc 2020/02/27 12:35
* @since 1.0
*/
public interface CommonConstant {
String INSERT = "INSERT";
String UPDATE = "UPDATE";
String UPSERT = "UPSERT";
String DELETE = "DELETE";
String KAFKA_INIT_OFFSET_LATEST = "latest";
String KAFKA_INIT_OFFSET_EARLIEST = "earliest";
}
|
package com.hesoyam.pharmacy.storage.controller;
import com.hesoyam.pharmacy.medicine.model.Medicine;
import com.hesoyam.pharmacy.storage.dto.AddStorageItemDTO;
import com.hesoyam.pharmacy.storage.dto.UpdateStorageItemDTO;
import com.hesoyam.pharmacy.storage.exceptions.InvalidAddInventoryItemException;
import com.hesoyam.pharmacy.storage.exceptions.InvalidDeleteStorageItemRequestException;
import com.hesoyam.pharmacy.storage.exceptions.InvalidUpdateStorageItemRequestException;
import com.hesoyam.pharmacy.storage.model.StorageItem;
import com.hesoyam.pharmacy.storage.service.IStorageItemService;
import com.hesoyam.pharmacy.storage.service.IStorageService;
import com.hesoyam.pharmacy.user.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import javax.persistence.EntityNotFoundException;
import java.util.List;
@RestController
@RequestMapping(value="/storage", produces = MediaType.APPLICATION_JSON_VALUE)
public class StorageController {
@Autowired
private IStorageService storageService;
@Autowired
private IStorageItemService storageItemService;
@GetMapping("/my")
@Secured("ROLE_SUPPLIER")
public ResponseEntity<List<StorageItem>> getStorageItemsByStorageId(@RequestParam(required = false) Integer page, @AuthenticationPrincipal User user){
try{
if(page == null || page < 1) page = 1;
return ResponseEntity.ok(storageItemService.getStorageItemsByUserId(user.getId(), page));
}catch (EntityNotFoundException entityNotFoundException){
return ResponseEntity.notFound().build();
}
}
@PostMapping("/my/update")
@Secured("ROLE_SUPPLIER")
public ResponseEntity<StorageItem> updateItemStock(@RequestBody UpdateStorageItemDTO updateStorageItemDTO, @AuthenticationPrincipal User user){
updateStorageItemDTO.setLoggedUser(user);
try{
return ResponseEntity.ok(storageItemService.update(updateStorageItemDTO));
}catch (InvalidUpdateStorageItemRequestException e){
return ResponseEntity.badRequest().build();
}catch (EntityNotFoundException e){
return ResponseEntity.notFound().build();
}
}
@DeleteMapping("/my/delete/{id}")
@Secured("ROLE_SUPPLIER")
public ResponseEntity deleteStorageItem(@PathVariable("id")Long itemId, @AuthenticationPrincipal User user){
try{
storageItemService.delete(itemId, user);
return ResponseEntity.ok().build();
}catch (InvalidDeleteStorageItemRequestException e){
return ResponseEntity.badRequest().build();
}catch (EntityNotFoundException e){
return ResponseEntity.notFound().build();
}
}
@PostMapping("/my/add")
@Secured("ROLE_SUPPLIER")
public ResponseEntity<StorageItem> addStorageItem(@RequestBody AddStorageItemDTO addStorageItemDTO, @AuthenticationPrincipal User user){
try{
return ResponseEntity.ok(storageItemService.add(addStorageItemDTO.getMedicine(), user));
}catch (EntityNotFoundException e){
return ResponseEntity.notFound().build();
}catch (InvalidAddInventoryItemException e){
return ResponseEntity.badRequest().build();
}
}
@GetMapping("/my/unadded")
@Secured("ROLE_SUPPLIER")
public ResponseEntity<List<Medicine>> getUnaddedMedicines(@RequestParam Integer page, @AuthenticationPrincipal User user){
if(page == null || page < 1) page = 1;
return ResponseEntity.ok(storageItemService.getUnaddedMedicines(page, user));
}
}
|
package com.testyantra.stockmanagement.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.testyantra.stockmanagement.dao.InvestorDAO;
import com.testyantra.stockmanagement.dao.UserDAO;
import com.testyantra.stockmanagement.dto.UserDTO;
import com.testyantra.stockmanagement.entities.User;
import com.testyantra.stockmanagement.exceptions.StockException;
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserDAO dao;
@Autowired
private InvestorDAO investordao;
@Override
public User addUser(User user) {
User user1 = dao.addUser(user);
if(user.getRole().equals("Investor")) {
investordao.addInvestor(user);
}
if (user1 != null) {
return user1;
} else {
throw new StockException("Failed to add user");
}
}
@Override
public User removeUser(int userId) {
User user1 = dao.removeUser(userId);
if (user1 != null) {
return user1;
} else {
throw new StockException("Failed to remove user");
}
}
@Override
public User updateUser(User user) {
User user1 = dao.updateUser(user);
if (user1 != null) {
return user1;
} else {
throw new StockException("Failed to update user");
}
}
@Override
public List<User> getUser(String userName) {
List<User> user1 = dao.getUser(userName);
if (!user1.isEmpty()) {
return user1;
} else {
throw new StockException("user not found");
}
}
@Override
public User authenticateUser(UserDTO dto) {
User user = dao.authenticateUser(dto);
if (user != null) {
return user;
} else {
return null;
}
}
}
|
/*
* Copyright (c) 2010-2012 by Bjoern Kolbeck,
* Zuse Institute Berlin
*
* Licensed under the BSD License, see LICENSE file for details.
*
*/
package org.xtreemfs.osd.rwre;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.xtreemfs.common.uuids.ServiceUUID;
import org.xtreemfs.foundation.buffer.BufferPool;
import org.xtreemfs.foundation.flease.Flease;
import org.xtreemfs.foundation.flease.comm.FleaseMessage;
import org.xtreemfs.foundation.logging.Logging;
import org.xtreemfs.foundation.logging.Logging.Category;
import org.xtreemfs.foundation.pbrpc.client.RPCAuthentication;
import org.xtreemfs.foundation.pbrpc.client.RPCResponse;
import org.xtreemfs.foundation.pbrpc.client.RPCResponseAvailableListener;
import org.xtreemfs.foundation.pbrpc.generatedinterfaces.RPC.ErrorType;
import org.xtreemfs.foundation.pbrpc.generatedinterfaces.RPC.POSIXErrno;
import org.xtreemfs.foundation.pbrpc.utils.ErrorUtils;
import org.xtreemfs.osd.InternalObjectData;
import org.xtreemfs.osd.rwre.RWReplicationStage.Operation;
import org.xtreemfs.osd.rwre.ReplicatedFileState.ReplicaState;
import org.xtreemfs.pbrpc.generatedinterfaces.GlobalTypes.FileCredentials;
import org.xtreemfs.pbrpc.generatedinterfaces.OSD.AuthoritativeReplicaState;
import org.xtreemfs.pbrpc.generatedinterfaces.OSD.ObjectVersion;
import org.xtreemfs.pbrpc.generatedinterfaces.OSD.ObjectVersionMapping;
import org.xtreemfs.pbrpc.generatedinterfaces.OSD.ReplicaStatus;
import org.xtreemfs.pbrpc.generatedinterfaces.OSD.TruncateLog;
import org.xtreemfs.pbrpc.generatedinterfaces.OSD.TruncateRecord;
import org.xtreemfs.pbrpc.generatedinterfaces.OSDServiceClient;
/**
*
* @author bjko
*/
public abstract class CoordinatedReplicaUpdatePolicy extends ReplicaUpdatePolicy {
private final OSDServiceClient client;
public CoordinatedReplicaUpdatePolicy(List<ServiceUUID> remoteOSDUUIDs, String localUUID, String fileId, OSDServiceClient client) throws IOException {
super(remoteOSDUUIDs, fileId, localUUID);
this.client = client;
if (Logging.isDebug())
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"(R:%s) created %s for %s",localUUID,this.getClass().getSimpleName(),cellId);
}
/**
*
* @param operation
* @return number of external acks required for an operation (majority minus local replica).
*/
protected abstract int getNumRequiredAcks(Operation operation);
protected abstract boolean backupCanRead();
@Override
public void closeFile() {
if (Logging.isDebug())
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"(R:%s) closed %s for %s",localUUID,this.getClass().getSimpleName(),cellId);
}
@Override
public boolean requiresLease() {
return true;
}
@Override
public void executeReset(final FileCredentials credentials, final ReplicaStatus localReplicaState, final ExecuteResetCallback callback) {
final String fileId = credentials.getXcap().getFileId();
final int numAcksRequired = getNumRequiredAcks(Operation.INTERNAL_UPDATE);
final int numRequests = remoteOSDUUIDs.size();
final int maxErrors = numRequests - numAcksRequired;
if (Logging.isDebug()) {
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"(R:%s) fetching replica state for %s from %d replicas (majority: %d), local max: %d",
localUUID, fileId, numRequests, numAcksRequired, this.localObjVersion);
}
final RPCResponse[] responses = new RPCResponse[remoteOSDUUIDs.size()];
try {
for (int i = 0; i < responses.length; i++) {
responses[i] = client.xtreemfs_rwr_status(remoteOSDUUIDs.get(i).getAddress(), RPCAuthentication.authNone, RPCAuthentication.userService,
credentials, credentials.getXcap().getFileId(),
0); // maxObjVer = 0 => let the remote OSD assume that we don't have any objects yet. Important to detect wholes (writes not seen by this replica).
}
} catch (IOException ex) {
callback.failed(ErrorUtils.getErrorResponse(ErrorType.ERRNO, POSIXErrno.POSIX_ERROR_EIO, ex.toString(),ex));
return;
}
RPCResponseAvailableListener listener = new RPCResponseAvailableListener() {
int numResponses = 0;
int numErrors = 0;
boolean exceptionSent = false;
ReplicaStatus[] states = new ReplicaStatus[remoteOSDUUIDs.size() + 1];
@Override
public void responseAvailable(RPCResponse r) {
if (numResponses < numAcksRequired) {
int osdNum = -1;
for (int i = 0; i < numRequests; i++) {
if (responses[i] == r) {
osdNum = i;
break;
}
}
assert(osdNum > -1);
try {
states[osdNum] = (ReplicaStatus)r.get();
if (Logging.isDebug()) {
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"(R:%s) received status response for %s from %s", localUUID, fileId, remoteOSDUUIDs.get(osdNum));
}
numResponses++;
} catch (Exception ex) {
numErrors++;
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"no status response from %s fro %s due to exception: %s (acks: %d, errs: %d, maxErrs: %d)",
remoteOSDUUIDs.get(osdNum), fileId, ex.toString(), numResponses, numErrors, maxErrors);
if (numErrors > maxErrors) {
if (!exceptionSent) {
exceptionSent = true;
String errorMessage = String.format("(R:%s) read status FAILED for %s on %s (this is request #%d out of %d which failed)", localUUID, fileId, remoteOSDUUIDs.get(osdNum), numErrors, remoteOSDUUIDs.size());
if (Logging.isDebug()) {
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this, errorMessage);
}
callback.failed(ErrorUtils.getInternalServerError(ex, errorMessage));
}
}
return;
} finally {
r.freeBuffers();
}
} else {
try {
r.get();
} catch (Exception e) {
// ignore.
}
r.freeBuffers();
return;
}
if (numResponses == numAcksRequired) {
states[states.length - 1] = localReplicaState;
if (Logging.isDebug()) {
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"(R:%s) received enough status responses for %s",localUUID, fileId);
}
AuthoritativeReplicaState auth = CalculateAuthoritativeState(states, fileId);
final RPCResponseAvailableListener listener2 = new RPCResponseAvailableListener() {
@Override
public void responseAvailable(RPCResponse r) {
r.freeBuffers();
}
};
// TODO(mberlin): Send auth state only to those backups which don't have the latest state.
for (int i = 0; i < remoteOSDUUIDs.size(); i++) {
try {
RPCResponse r2 = client.xtreemfs_rwr_auth_state(remoteOSDUUIDs.get(i).getAddress(), RPCAuthentication.authNone, RPCAuthentication.userService,
credentials, credentials.getXcap().getFileId(), auth);
r2.registerListener(listener2);
if (Logging.isDebug()) {
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"sent auth state to backup %s for file %s",remoteOSDUUIDs.get(i), fileId);
}
} catch (Exception ex) {
Logging.logMessage(Logging.LEVEL_WARN, Category.replication, this,"(R:%s) cannot send auth state to backup: %s",localUUID, ex.toString());
}
}
callback.finished(auth);
}
}
};
for (int i = 0; i < responses.length; i++) {
responses[i].registerListener(listener);
}
//callback.writeUpdateCompleted(null, null, null);
}
private static final class ObjectMapRecord {
public long version;
public List<InetSocketAddress> osds;
}
public AuthoritativeReplicaState CalculateAuthoritativeState(ReplicaStatus[] states, String fileId) {
StringBuilder stateStr = new StringBuilder();
Map<Long,TruncateRecord> truncateLog = new HashMap();
Map<Long,ObjectVersionMapping.Builder> all_objects = new HashMap();
long maxTruncateEpoch = 0;
long maxObjectVersion = 0;
for (int i = 0; i < states.length; i++) {
final ReplicaStatus state = states[i];
if (state == null) {
// Skip null entries, server did not respond.
continue;
}
if (state.getTruncateEpoch() > maxTruncateEpoch) {
maxTruncateEpoch = state.getTruncateEpoch();
}
for (TruncateRecord trec : state.getTruncateLog().getRecordsList()) {
truncateLog.put(trec.getVersion(), trec);
}
for (ObjectVersion over : state.getObjectVersionsList()) {
final long onum = over.getObjectNumber();
if (over.getObjectVersion() > maxObjectVersion) {
maxObjectVersion = over.getObjectVersion();
}
ObjectVersionMapping.Builder omr = all_objects.get(onum);
if ((omr == null) || (omr.getObjectVersion() < over.getObjectVersion())) {
omr = ObjectVersionMapping.newBuilder();
omr.setObjectVersion(over.getObjectVersion());
omr.setObjectNumber(onum);
all_objects.put(onum, omr);
}
if (omr.getObjectVersion() == over.getObjectVersion()) {
if (i < states.length - 1) {
omr.addOsdUuids(remoteOSDUUIDs.get(i).toString());
} else {
omr.addOsdUuids(localUUID);
// Last state is the local state, i.e. local OSD.
}
}
}
}
for (TruncateRecord trec : truncateLog.values()) {
Iterator<Entry<Long, ObjectVersionMapping.Builder>> iter = all_objects.entrySet().iterator();
while (iter.hasNext()) {
final Entry<Long, ObjectVersionMapping.Builder> e = iter.next();
if (e.getKey() > trec.getLastObjectNumber() &&
e.getValue().getObjectVersion() < trec.getVersion()) {
iter.remove();
}
}
}
if (Logging.isDebug()) {
stateStr.append("tlog={");
for (TruncateRecord trec : truncateLog.values()) {
stateStr.append("(");
stateStr.append(trec.getVersion());
stateStr.append(",");
stateStr.append(trec.getLastObjectNumber());
stateStr.append("),");
}
stateStr.append("} ");
stateStr.append("objs={");
for (Entry<Long, ObjectVersionMapping.Builder> obj : all_objects.entrySet()) {
stateStr.append("(");
stateStr.append(obj.getKey());
stateStr.append(",");
stateStr.append(obj.getValue().getObjectVersion());
stateStr.append("),");
}
stateStr.append("} maxV=");
stateStr.append(maxObjectVersion);
stateStr.append(" maxTE=");
stateStr.append(maxTruncateEpoch);
if (Logging.isDebug()) {
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"(R:%s) AUTH state for %s: %s",localUUID, fileId, stateStr.toString());
}
}
AuthoritativeReplicaState.Builder auth = AuthoritativeReplicaState.newBuilder();
auth.setTruncateEpoch(0);
TruncateLog.Builder tlogBuilder = TruncateLog.newBuilder();
tlogBuilder.addAllRecords(truncateLog.values());
auth.setTruncateLog(tlogBuilder);
auth.setTruncateEpoch(maxTruncateEpoch);
auth.setMaxObjVersion(maxObjectVersion);
for (ObjectVersionMapping.Builder obj : all_objects.values()) {
auth.addObjectVersions(obj);
}
return auth.build();
}
@Override
public void executeWrite(FileCredentials credentials, long objNo, long objVersion, InternalObjectData data, final ClientOperationCallback callback) {
final String fileId = credentials.getXcap().getFileId();
final int numAcksRequired = getNumRequiredAcks(Operation.WRITE);
final int numRequests = remoteOSDUUIDs.size();
final int maxErrors = numRequests - numAcksRequired;
final RPCResponse[] responses = new RPCResponse[remoteOSDUUIDs.size()];
final RPCResponseAvailableListener l = getResponseListener(callback, maxErrors, numAcksRequired, fileId, Operation.WRITE);
try {
for (int i = 0; i < responses.length; i++) {
responses[i] = client.xtreemfs_rwr_update(remoteOSDUUIDs.get(i).getAddress(),
RPCAuthentication.authNone, RPCAuthentication.userService,
credentials, credentials.getXcap().getFileId(), 0,
objNo, objVersion, 0, data.getMetadata(), data.getData().createViewBuffer());
responses[i].registerListener(l);
}
} catch (IOException ex) {
callback.failed(ErrorUtils.getInternalServerError(ex));
} finally {
BufferPool.free(data.getData());
}
//callback.writeUpdateCompleted(null, null, null);
if (Logging.isDebug())
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"(R:%s) sent update for %s", localUUID, fileId);
}
@Override
public void executeTruncate(FileCredentials credentials, long newFileSize, long newObjectVersion, final ClientOperationCallback callback) {
final String fileId = credentials.getXcap().getFileId();
final int numAcksRequired = getNumRequiredAcks(Operation.TRUNCATE);
final int numRequests = remoteOSDUUIDs.size();
final int maxErrors = numRequests - numAcksRequired;
final RPCResponseAvailableListener l = getResponseListener(callback, maxErrors, numAcksRequired, fileId, Operation.TRUNCATE);
final RPCResponse[] responses = new RPCResponse[remoteOSDUUIDs.size()];
try {
for (int i = 0; i < responses.length; i++) {
responses[i] = client.xtreemfs_rwr_truncate(remoteOSDUUIDs.get(i).getAddress(), RPCAuthentication.authNone, RPCAuthentication.userService,
credentials, credentials.getXcap().getFileId(), newFileSize, newObjectVersion);
responses[i].registerListener(l);
}
} catch (IOException ex) {
callback.failed(ErrorUtils.getInternalServerError(ex));
}
//callback.writeUpdateCompleted(null, null, null);
if (Logging.isDebug())
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"(R:%s) sent truncate update for %s", localUUID, fileId);
}
protected RPCResponseAvailableListener getResponseListener(final ClientOperationCallback callback,
final int maxErrors, final int numAcksRequired, final String fileId, final Operation operation) {
assert(numAcksRequired <= this.remoteOSDUUIDs.size());
if (Logging.isDebug())
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"(R:%s) new response listener for %s (acks %d, errs %d)",localUUID,fileId,numAcksRequired,maxErrors);
assert(maxErrors >= 0);
RPCResponseAvailableListener listener = new RPCResponseAvailableListener() {
int numAcks = 0;
int numErrors = 0;
boolean responseSent = false;
@Override
public void responseAvailable(RPCResponse r) {
try {
r.get();
numAcks++;
} catch (Exception ex) {
numErrors++;
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"exception for %s/%s (acks: %d, errs: %d, maxErrs: %d)",
operation, fileId, numAcks, numErrors, maxErrors);
if (numErrors > maxErrors) {
if (!responseSent) {
responseSent = true;
Logging.logMessage(Logging.LEVEL_INFO, Category.replication, this,"replicated %s FAILED for %s (acks: %d, errs: %d, maxErrs: %d)",
operation, fileId, numAcks, numErrors, maxErrors);
callback.failed(ErrorUtils.getInternalServerError(ex));
}
}
return;
} finally {
r.freeBuffers();
}
if (numAcks == numAcksRequired) {
responseSent = true;
if (Logging.isDebug()) {
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"replicated %s successfull for %s",operation,fileId);
}
callback.finsihed();
}
}
};
return listener;
}
@Override
public long onClientOperation(Operation operation, long objVersion, ReplicaState currentState, Flease lease) throws RedirectToMasterException, IOException {
if (currentState == ReplicaState.PRIMARY) {
long tmpObjVer;
if (operation != Operation.READ) {
if (this.localObjVersion == -1) {
this.localObjVersion = 0;
}
assert(this.localObjVersion > -1);
tmpObjVer = ++this.localObjVersion;
} else {
tmpObjVer = localObjVersion;
}
final long nextObjVer = tmpObjVer;
if (Logging.isDebug())
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this,"(R:%s) prepared op for %s with objVer %d",localUUID, cellId,nextObjVer);
return nextObjVer;
} else if (currentState == ReplicaState.BACKUP) {
if (backupCanRead() && (operation == Operation.READ)) {
return this.localObjVersion;
} else {
if ((lease == null) || (lease.isEmptyLease())) {
Logging.logMessage(Logging.LEVEL_WARN, Category.replication, this,"unknown lease state for %s: %s",this.cellId,lease);
throw new RetryException("unknown lease state for cell "+this.cellId+", can't redirect to master. Please retry.");
} else
Logging.logMessage(Logging.LEVEL_DEBUG, Category.replication, this, "(R:%s) local is backup, redirecting for fileid %s to %s",
localUUID, this.cellId,lease.getLeaseHolder().toString());
throw new RedirectToMasterException(lease.getLeaseHolder().toString());
}
} else {
throw new IOException("invalid state: "+currentState);
}
}
@Override
public boolean onRemoteUpdate(long objVersion, ReplicaState state) throws IOException {
//apply everything...
if (state == ReplicaState.PRIMARY) {
throw new IOException("no accepting updates in PRIMARY mode");
}
if ((objVersion == 1) && (localObjVersion == -1)) {
localObjVersion = 1;
return false;
}
if (objVersion <= localObjVersion) {
Logging.logMessage(Logging.LEVEL_WARN, Category.replication, this,
"Received object version %d, local is %d for file %s",
objVersion, localObjVersion, cellId.toString());
}
if (objVersion > localObjVersion) {
localObjVersion = objVersion;
}
return false;
}
@Override
public boolean acceptRemoteUpdate(long objVersion) throws IOException {
return objVersion >= localObjVersion;
}
@Override
public boolean onPrimary(int masterEpoch) throws IOException {
//no need to catch up on primary
if (masterEpoch != FleaseMessage.IGNORE_MASTER_EPOCH) {
this.localObjVersion = (long)masterEpoch << 32;
}
return true;
}
@Override
public boolean onBackup() throws IOException {
return false;
}
@Override
public void onFailed() throws IOException {
//don't care
}
}
|
package hii;
import java.io.FileReader;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Scanner;
import org.json.simple.JSONValue;
import org.json.simple.parser.JSONParser;
import org.json.JSONArray;
import org.json.JSONObject;
public class Json {
public static void main(String[] args) throws IOException {
System.out.println("enter the location" );
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://api.weatherapi.com/v1/current.json?key=42917cab93094f7fa9b61017210408&q="+str+"&aqi=no")).build();
client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
.thenApply(HttpResponse::body)
.thenAccept(System.out::println)
.join();
}
|
/**
* \file OnlineResource.java
* This class represents the OnlineResource node of the XML.
*/
package br.org.funcate.glue.model.xml;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
*
* \brief This class represents the OnlineResource node of the XML.
*
* @author Emerson Leite de Moraes
* @author Willyan Aleksander
*
* Version 1.0
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "OnlineResource")
public class OnlineResource {
@XmlAttribute(namespace = "http://www.w3.org/1999/xlink")
protected String _href;
@XmlAttribute(namespace = "http://www.w3.org/1999/xlink")
protected String _type;
/**
* \brief Gets the value of the href property.
*
* @return possible object is {@link String }
*
*/
public String getHref() {
return _href;
}
/**
* \brief Sets the value of the href property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setHref(String value) {
this._href = value;
}
/**
* \brief Gets the value of the type property.
*
* @return possible object is {@link String }
*
*/
public String getType() {
return _type;
}
/**
* \brief Sets the value of the type property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setType(String value) {
this._type = value;
}
}
|
package com.tencent.mm.plugin.topstory.ui.a;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.support.v7.widget.RecyclerView$t;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.TextView;
import com.tencent.mm.ak.o;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.topstory.a.b;
import com.tencent.mm.plugin.topstory.ui.b.d;
import com.tencent.mm.plugin.topstory.ui.video.a;
import com.tencent.mm.plugin.topstory.ui.video.k;
import com.tencent.mm.plugin.topstory.ui.video.n;
import com.tencent.mm.plugin.topstory.ui.video.p;
import com.tencent.mm.plugin.websearch.api.q;
import com.tencent.mm.protocal.c.bth;
import com.tencent.mm.protocal.c.bti;
import com.tencent.mm.protocal.c.cfn;
import com.tencent.mm.sdk.platformtools.bi;
import com.tencent.mm.sdk.platformtools.x;
import com.tencent.mm.ui.ak;
import com.tencent.mm.ui.base.l;
import com.tencent.mm.ui.base.n$d;
import com.tencent.mm.ui.base.s;
public class c extends RecyclerView$t implements p {
public static com.tencent.mm.ak.a.a.c oCI;
public TextView eBO;
public View ivV;
public TextView mKZ;
protected OnClickListener mtE = new OnClickListener() {
public final void onClick(View view) {
c.this.cY(view);
}
};
public Point nqm;
public a oAb;
public n oCJ;
public FrameLayout oCK;
public View oCL;
public ImageView oCM;
public ImageView oCN;
public TextView oCO;
public View oCP;
public View oCQ;
public View oCR;
public int oCS;
public bti ozj;
public int position;
static {
com.tencent.mm.ak.a.a.c.a aVar = new com.tencent.mm.ak.a.a.c.a();
aVar.dXy = true;
aVar.dXx = true;
aVar.dXW = true;
aVar.dXN = com.tencent.mm.plugin.topstory.ui.b.c.default_avatar;
oCI = aVar.Pt();
}
public c(View view, a aVar) {
Point point;
super(view);
this.oAb = aVar;
this.nqm = ak.gu(aVar.baA());
if (ak.gt(aVar.baA())) {
point = this.nqm;
point.y -= ak.gs(aVar.baA());
}
point = this.nqm;
point.y -= s.gJ(aVar.baA());
this.oCS = com.tencent.mm.bp.a.fromDPToPix(aVar.baA(), 24);
cX(view);
}
public void cX(View view) {
this.oCK = (FrameLayout) view.findViewById(d.video_view_container);
this.oCL = view.findViewById(d.source_layout);
this.oCM = (ImageView) view.findViewById(d.source_iv);
this.mKZ = (TextView) view.findViewById(d.source_tv);
this.eBO = (TextView) view.findViewById(d.title_tv);
this.oCO = (TextView) view.findViewById(d.play_count_tv);
this.ivV = view.findViewById(d.share_icon_iv);
this.oCP = view.findViewById(d.body_mask);
this.oCQ = view.findViewById(d.header_mask);
this.oCR = view.findViewById(d.footer_mask);
this.oCN = (ImageView) view.findViewById(d.feedback_iv);
}
public final void bII() {
x.d("MicroMsg.TopStory.TopStoryBaseVideoItemHolder", "showMaskView %d", new Object[]{Integer.valueOf(hashCode())});
this.oCR.animate().cancel();
this.oCQ.animate().cancel();
this.oCP.animate().cancel();
this.oCP.setAlpha(0.8f);
this.oCR.setAlpha(0.8f);
this.oCQ.setAlpha(0.8f);
}
public final void bIJ() {
x.d("MicroMsg.TopStory.TopStoryBaseVideoItemHolder", "hideMaskView %d", new Object[]{Integer.valueOf(hashCode())});
this.oCR.animate().cancel();
this.oCQ.animate().cancel();
this.oCP.animate().cancel();
this.oCP.setAlpha(0.0f);
this.oCR.setAlpha(0.0f);
this.oCQ.setAlpha(0.0f);
}
public final void bHL() {
this.oCR.animate().cancel();
this.oCQ.animate().cancel();
this.oCR.setAlpha(0.0f);
this.oCQ.setAlpha(0.0f);
this.oAb.bHL();
}
public final void bHK() {
this.oCR.animate().cancel();
this.oCQ.animate().cancel();
this.oCR.animate().alpha(0.8f).setDuration(200).setStartDelay(3000).start();
this.oCQ.animate().alpha(0.8f).setDuration(200).setStartDelay(3000).start();
this.oAb.bHK();
}
public final void a(bti bti, int i) {
this.ozj = bti;
this.position = i;
aL();
}
public final void iE(boolean z) {
bIJ();
this.oAb.yg(this.position);
if (this.oCJ.iB(z)) {
bHL();
bHK();
}
}
protected void aL() {
if (bi.oW(this.ozj.title)) {
this.eBO.setVisibility(8);
} else {
this.eBO.setText(this.ozj.title);
this.eBO.setVisibility(0);
this.eBO.requestLayout();
}
this.eBO.setOnClickListener(this.mtE);
this.mKZ.setText(this.ozj.bhd);
if (bi.oW(this.ozj.pLz)) {
this.oCO.setVisibility(8);
} else {
this.oCO.setText(this.ozj.pLz);
this.oCO.setVisibility(0);
}
this.oCO.setOnClickListener(this.mtE);
if (bi.oW(this.ozj.sqY)) {
this.oCM.setVisibility(8);
} else {
o.Pj().a(this.ozj.sqY, this.oCM, oCI);
this.oCM.setVisibility(0);
}
if (this.oAb.bHX()) {
this.ivV.setVisibility(0);
this.ivV.setOnClickListener(this.mtE);
} else {
this.ivV.setVisibility(8);
}
this.oCN.setTag(this.ozj);
this.oCN.setOnClickListener(this.mtE);
this.oCP.setVisibility(0);
this.oCQ.setVisibility(0);
this.oCR.setVisibility(0);
this.oCL.setOnClickListener(this.mtE);
if (this.oCJ == null) {
this.oCJ = new n(this.oAb.baA());
this.oCK.removeAllViews();
this.oCK.addView(this.oCJ);
}
this.oCJ.setStreamUIComponent(this.oAb);
this.oCJ.setVideoItemUIComponent(this);
n nVar = this.oCJ;
bti bti = this.ozj;
nVar.position = this.position;
nVar.ozj = bti;
nVar.aL();
if (this.oAb.bHP() != this.position) {
bII();
} else {
bHK();
}
}
private void bIK() {
if (this.oAb.bHS().oCg) {
this.oCJ.bIr();
this.oAb.bHS().bAf();
}
}
protected void cY(View view) {
if (this.oAb.bHP() != this.position) {
this.oAb.bHU().oAl = 2;
this.oAb.ye(this.position);
com.tencent.mm.plugin.websearch.api.a.a.kB(4);
this.oAb.bHU().b(this.ozj);
((b) g.n(b.class)).getReporter().a(this.oAb.bHT(), this.ozj, this.position, 2, "");
return;
}
Object obj = (this.oCR.getAlpha() == 0.0f || this.oCQ.getAlpha() == 0.0f) ? null : 1;
if (obj != null) {
bHL();
this.oAb.bHL();
bHK();
this.oAb.bHK();
} else if (view.getId() == this.oCL.getId()) {
if (!bi.oW(this.ozj.lRt)) {
Oy(this.ozj.lRt);
bIK();
this.oAb.bHU().b(this.ozj);
((b) g.n(b.class)).getReporter().a(this.oAb.bHT(), this.ozj, this.position, 3, this.ozj.bhd);
}
} else if (view.getId() == this.eBO.getId()) {
if (this.ozj != null && !bi.oW(this.ozj.pLA)) {
Oy(this.ozj.pLA);
bIK();
this.oAb.bHU().b(this.ozj);
((b) g.n(b.class)).getReporter().a(this.oAb.bHT(), this.ozj, this.position, 1, "");
}
} else if (view.getId() == this.ivV.getId()) {
com.tencent.mm.plugin.websearch.api.a.a.kB(8);
a(this.oAb, this.oAb.baA(), this.oCJ, this.position);
} else if (view.getId() == this.oCN.getId()) {
this.oAb.onFeedBackItemClick(this.oCN);
}
}
public static void a(final a aVar, final Context context, final n nVar, int i) {
final bti bti = (bti) aVar.bHO().get(i);
if (bti != null) {
com.tencent.mm.ui.widget.c cVar = new com.tencent.mm.ui.widget.c(context, 1, false);
cVar.ofp = new com.tencent.mm.ui.base.n.c() {
public final void a(l lVar) {
lVar.eR(0, com.tencent.mm.plugin.topstory.ui.b.g.video_share_to_sns);
lVar.eR(1, com.tencent.mm.plugin.topstory.ui.b.g.video_share_to_friend);
}
};
cVar.ofq = new n$d() {
public final void onMMMenuItemSelected(MenuItem menuItem, int i) {
k kVar;
Context context;
bti bti;
bth bHT;
if (menuItem.getItemId() == 0) {
nVar.bIr();
kVar = k.oAn;
context = context;
bti = bti;
bHT = aVar.bHT();
if (bti != null && bHT != null) {
byte[] toByteArray;
kVar.oAo = bti;
Intent intent = new Intent();
intent.putExtra("Ksnsupload_title", bti.ixz);
intent.putExtra("Ksnsupload_imgurl", bti.pLw);
intent.putExtra("Ksnsupload_link", bti.ixy);
intent.putExtra("KContentObjDesc", bi.oW(bti.nzH) ? context.getString(com.tencent.mm.plugin.topstory.ui.b.g.recommend_video_share_desc_default) : bti.nzH);
intent.putExtra("KlinkThumb_url", bti.pLw);
intent.putExtra("Ksnsupload_source", 1);
intent.putExtra("Ksnsupload_type", 16);
intent.putExtra("need_result", true);
cfn cfn = new cfn();
cfn.pLr = bti.sqS;
cfn.pLs = bti.sqV;
cfn.pLt = bHT.sqJ;
cfn.pLu = bti.sqU;
cfn.pLv = bHT.sqO;
cfn.ixy = bti.ixy;
cfn.ixz = bti.ixz;
cfn.nzH = bti.nzH;
cfn.pLw = bti.pLw;
cfn.pLx = bti.pLx;
cfn.pLy = bti.pLy;
cfn.bhd = bti.bhd;
cfn.lRt = bti.lRt;
cfn.pLz = bti.pLz;
cfn.pLA = bti.pLA;
cfn.pLB = k.cB(bHT.pKZ).toString();
cfn.pLC = com.tencent.mm.plugin.topstory.a.g.cA(bti.rBV).toString();
try {
toByteArray = cfn.toByteArray();
} catch (Throwable e) {
x.printErrStackTrace("MicroMsg.TopStory.TopStoryVideoShareMgr", e, "", new Object[0]);
toByteArray = null;
}
if (toByteArray != null) {
intent.putExtra("KWebSearchInfo", toByteArray);
}
com.tencent.mm.bg.d.b(context, "sns", ".ui.SnsUploadUI", intent, 1024);
}
} else if (menuItem.getItemId() == 1) {
nVar.bIr();
kVar = k.oAn;
context = context;
bti = bti;
bHT = aVar.bHT();
kVar.oAo = bti;
com.tencent.mm.y.g.a aVar = new com.tencent.mm.y.g.a();
aVar.type = 5;
aVar.title = bti.ixz;
aVar.description = bi.oW(bti.nzH) ? context.getString(com.tencent.mm.plugin.topstory.ui.b.g.recommend_video_share_desc_default) : bti.nzH;
aVar.url = bti.ixy;
aVar.thumburl = bti.pLw;
q qVar = new q();
qVar.pLr = bti.sqS;
qVar.pLs = bti.sqV;
qVar.pLt = bHT.sqJ;
qVar.pLu = bti.sqU;
qVar.pLv = bHT.sqO;
qVar.ixy = bti.ixy;
qVar.ixz = bti.ixz;
qVar.nzH = bti.nzH;
qVar.pLw = bti.pLw;
qVar.pLx = bti.pLx;
qVar.pLy = bti.pLy;
qVar.bhd = bti.bhd;
qVar.lRt = bti.lRt;
qVar.pLz = bti.pLz;
qVar.pLA = bti.pLA;
qVar.pLB = k.cB(bHT.pKZ).toString();
qVar.pLC = com.tencent.mm.plugin.topstory.a.g.cA(bti.rBV).toString();
aVar.a(qVar);
String a = com.tencent.mm.y.g.a.a(aVar, null, null);
Intent intent2 = new Intent();
intent2.putExtra("Retr_Msg_Type", 2);
intent2.putExtra("Retr_Msg_content", a);
intent2.putExtra("Multi_Retr", true);
intent2.putExtra("Retr_go_to_chattingUI", false);
intent2.putExtra("Retr_show_success_tips", true);
com.tencent.mm.bg.d.b(context, ".ui.transmit.MsgRetransmitUI", intent2, 2048);
}
}
};
cVar.uJQ = new 4(aVar);
cVar.bXO();
}
}
private void Oy(String str) {
Intent intent = new Intent();
intent.putExtra("rawUrl", str);
com.tencent.mm.bg.d.b(this.oAb.baA(), "webview", "com.tencent.mm.plugin.webview.ui.tools.WebViewUI", intent);
}
public void z(n nVar) {
this.ozj = nVar.getVideoInfo();
String str = "MicroMsg.TopStory.TopStoryBaseVideoItemHolder";
String str2 = "setVideoInfoFromResumeFullScreenView, videoInfo: %s, videoViewPosition: %s, position: %s";
Object[] objArr = new Object[3];
objArr[0] = this.ozj != null ? this.ozj.title : "";
objArr[1] = Integer.valueOf(nVar.getPosition());
objArr[2] = Integer.valueOf(this.position);
x.i(str, str2, objArr);
if (this.ozj != null) {
if (bi.oW(this.ozj.title)) {
this.eBO.setVisibility(8);
} else {
this.eBO.setText(this.ozj.title);
this.eBO.setVisibility(0);
}
this.mKZ.setText(this.ozj.bhd);
if (bi.oW(this.ozj.pLz)) {
this.oCO.setVisibility(8);
} else {
this.oCO.setText(this.ozj.pLz);
this.oCO.setVisibility(0);
}
this.oCK.removeAllViews();
if (nVar.getParent() != null) {
((ViewGroup) nVar.getParent()).removeView(nVar);
}
FrameLayout frameLayout = this.oCK;
bti bti = this.ozj;
int min = Math.min(this.nqm.x, this.nqm.y);
frameLayout.addView(nVar, new LayoutParams(min, (bti.dwI * min) / bti.dwJ));
this.oCJ = nVar;
nVar.setVideoItemUIComponent(this);
if (this.oAb.bHS().oCg) {
nVar.bIm();
} else {
nVar.bIn();
}
bIJ();
bHL();
bHK();
this.position = nVar.getPosition();
this.oAb.yg(this.position);
}
}
public final void bID() {
this.oCJ = null;
this.oAb.yg(0);
aL();
}
public final int bIE() {
return this.position;
}
}
|
package so.ego.space.domains.task.application.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
@Getter
@Builder
@AllArgsConstructor
public class TaskSearchRequest {
private String search;
}
|
package com.sommy.android.med_manager;
import android.support.annotation.NonNull;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.IdlingResource;
import android.support.test.espresso.matcher.BoundedMatcher;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.sommy.android.med_manager.ui.MainActivity;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.intent.Checks.checkNotNull;
import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
/**
* Created by somto on 4/16/18.
*/
@RunWith(AndroidJUnit4.class)
public class IdlingResourceMainActivityTest {
/**
* The ActivityTestRule is a rule provided by Android used for functional testing of a single
* activity. The activity that will be tested, MainActivity in this case, will be launched
* before each test that's annotated with @Test and before methods annotated with @Before.
*
* The activity will be terminated after the test and methods annotated with @After are
* complete. This rule allows you to directly access the activity during the test.
*/
@Rule
public ActivityTestRule<MainActivity> mActivityTestRule =
new ActivityTestRule<>(MainActivity.class);
private IdlingResource mIdlingResource;
// Registers any resource that needs to be synchronized with Espresso before the test is run.
@Before
public void registerIdlingResource() {
mIdlingResource = mActivityTestRule.getActivity().getIdlingResource();
// To prove that the test fails, omit this call:
Espresso.registerIdlingResources(mIdlingResource);
}
public static Matcher<View> atPosition(final int position, @NonNull final Matcher<View> itemMatcher) {
checkNotNull(itemMatcher);
return new BoundedMatcher<View, RecyclerView>(RecyclerView.class) {
@Override
public void describeTo(Description description) {
description.appendText("has item at position " + position + ": ");
itemMatcher.describeTo(description);
}
@Override
protected boolean matchesSafely(final RecyclerView view) {
RecyclerView.ViewHolder viewHolder = view.findViewHolderForAdapterPosition(position);
if (viewHolder == null) {
// has no item on such position
return false;
}
return itemMatcher.matches(viewHolder.itemView);
}
};
}
@Test
public void idlingResourceTest() {
// Uses {@link Espresso#onData(org.hamcrest.Matcher)} to get a reference to a specific
// recyclerview item and clicks it.
// Checks that the MedicationDetailsActivity opens with the correct title name displayed
onView(withId(R.id.medication_recyclerView))
.check(matches(atPosition(0, hasDescendant(withText("ggy")))))
.perform(click());
}
// unregister resources when not needed to avoid malfunction.
@After
public void unregisterIdlingResource() {
if (mIdlingResource != null) {
Espresso.unregisterIdlingResources(mIdlingResource);
}
}
}
|
//### This file created by BYACC 1.8(/Java extension 1.13)
//### Java capabilities added 7 Jan 97, Bob Jamison
//### Updated : 27 Nov 97 -- Bob Jamison, Joe Nieten
//### 01 Jan 98 -- Bob Jamison -- fixed generic semantic constructor
//### 01 Jun 99 -- Bob Jamison -- added Runnable support
//### 06 Aug 00 -- Bob Jamison -- made state variables class-global
//### 03 Jan 01 -- Bob Jamison -- improved flags, tracing
//### 16 May 01 -- Bob Jamison -- added custom stack sizing
//### 04 Mar 02 -- Yuval Oren -- improved java performance, added options
//### 14 Mar 02 -- Tomas Hurka -- -d support, static initializer workaround
//### 14 Sep 06 -- Keltin Leung-- ReduceListener support, eliminate underflow report in error recovery
//### Please send bug reports to tom@hukatronic.cz
//### static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
//#line 11 "Parser.y"
package decaf.frontend;
import decaf.tree.Tree;
import decaf.tree.Tree.*;
import decaf.error.*;
import java.util.*;
//#line 25 "Parser.java"
interface ReduceListener {
public boolean onReduce(String rule);
}
public class Parser
extends BaseParser
implements ReduceListener
{
boolean yydebug; //do I want debug output?
int yynerrs; //number of errors so far
int yyerrflag; //was there an error?
int yychar; //the current working character
ReduceListener reduceListener = null;
void yyclearin () {yychar = (-1);}
void yyerrok () {yyerrflag=0;}
void addReduceListener(ReduceListener l) {
reduceListener = l;}
//########## MESSAGES ##########
//###############################################################
// method: debug
//###############################################################
void debug(String msg)
{
if (yydebug)
System.out.println(msg);
}
//########## STATE STACK ##########
final static int YYSTACKSIZE = 500; //maximum stack size
int statestk[] = new int[YYSTACKSIZE]; //state stack
int stateptr;
int stateptrmax; //highest index of stackptr
int statemax; //state when highest index reached
//###############################################################
// methods: state stack push,pop,drop,peek
//###############################################################
final void state_push(int state)
{
try {
stateptr++;
statestk[stateptr]=state;
}
catch (ArrayIndexOutOfBoundsException e) {
int oldsize = statestk.length;
int newsize = oldsize * 2;
int[] newstack = new int[newsize];
System.arraycopy(statestk,0,newstack,0,oldsize);
statestk = newstack;
statestk[stateptr]=state;
}
}
final int state_pop()
{
return statestk[stateptr--];
}
final void state_drop(int cnt)
{
stateptr -= cnt;
}
final int state_peek(int relative)
{
return statestk[stateptr-relative];
}
//###############################################################
// method: init_stacks : allocate and prepare stacks
//###############################################################
final boolean init_stacks()
{
stateptr = -1;
val_init();
return true;
}
//###############################################################
// method: dump_stacks : show n levels of the stacks
//###############################################################
void dump_stacks(int count)
{
int i;
System.out.println("=index==state====value= s:"+stateptr+" v:"+valptr);
for (i=0;i<count;i++)
System.out.println(" "+i+" "+statestk[i]+" "+valstk[i]);
System.out.println("======================");
}
//########## SEMANTIC VALUES ##########
//## **user defined:SemValue
String yytext;//user variable to return contextual strings
SemValue yyval; //used to return semantic vals from action routines
SemValue yylval;//the 'lval' (result) I got from yylex()
SemValue valstk[] = new SemValue[YYSTACKSIZE];
int valptr;
//###############################################################
// methods: value stack push,pop,drop,peek.
//###############################################################
final void val_init()
{
yyval=new SemValue();
yylval=new SemValue();
valptr=-1;
}
final void val_push(SemValue val)
{
try {
valptr++;
valstk[valptr]=val;
}
catch (ArrayIndexOutOfBoundsException e) {
int oldsize = valstk.length;
int newsize = oldsize*2;
SemValue[] newstack = new SemValue[newsize];
System.arraycopy(valstk,0,newstack,0,oldsize);
valstk = newstack;
valstk[valptr]=val;
}
}
final SemValue val_pop()
{
return valstk[valptr--];
}
final void val_drop(int cnt)
{
valptr -= cnt;
}
final SemValue val_peek(int relative)
{
return valstk[valptr-relative];
}
//#### end semantic value section ####
public final static short VOID=257;
public final static short BOOL=258;
public final static short INT=259;
public final static short STRING=260;
public final static short CLASS=261;
public final static short NULL=262;
public final static short EXTENDS=263;
public final static short THIS=264;
public final static short WHILE=265;
public final static short FOR=266;
public final static short IF=267;
public final static short ELSE=268;
public final static short RETURN=269;
public final static short BREAK=270;
public final static short NEW=271;
public final static short PRINT=272;
public final static short READ_INTEGER=273;
public final static short READ_LINE=274;
public final static short LITERAL=275;
public final static short IDENTIFIER=276;
public final static short AND=277;
public final static short OR=278;
public final static short STATIC=279;
public final static short INSTANCEOF=280;
public final static short LESS_EQUAL=281;
public final static short GREATER_EQUAL=282;
public final static short EQUAL=283;
public final static short NOT_EQUAL=284;
public final static short SCOPY=285;
public final static short VAR=286;
public final static short SEALED=287;
public final static short DIVIDER=288;
public final static short ARRAY_REPEAT=289;
public final static short ARRAY_CONCAT=290;
public final static short DEFAULT=291;
public final static short IN=292;
public final static short FOREACH=293;
public final static short LISTFORR=294;
public final static short LISTFORL=295;
public final static short UMINUS=296;
public final static short EMPTY=297;
public final static short YYERRCODE=256;
final static short yylhs[] = { -1,
0, 1, 1, 3, 4, 5, 5, 5, 5, 5,
5, 2, 2, 6, 6, 7, 7, 7, 9, 9,
10, 10, 8, 8, 11, 12, 12, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 14,
14, 24, 24, 16, 16, 26, 26, 27, 15, 17,
17, 17, 17, 30, 30, 28, 28, 31, 31, 31,
29, 33, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 34, 34, 34, 35, 35, 36,
36, 32, 32, 37, 37, 19, 20, 23, 18, 38,
38, 21, 21, 22,
};
final static short yylen[] = { 2,
1, 2, 1, 2, 2, 1, 1, 1, 1, 2,
3, 7, 6, 2, 0, 2, 2, 0, 1, 0,
3, 1, 7, 6, 3, 2, 0, 1, 2, 1,
1, 2, 1, 1, 1, 2, 2, 2, 1, 7,
9, 2, 2, 5, 3, 3, 0, 3, 6, 3,
4, 1, 0, 2, 0, 2, 4, 2, 2, 4,
5, 1, 7, 9, 6, 6, 1, 1, 1, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 2, 2, 3, 3, 1,
4, 5, 6, 5, 1, 1, 1, 2, 3, 3,
1, 1, 0, 3, 1, 5, 9, 1, 6, 2,
0, 2, 1, 4,
};
final static short yydefred[] = { 0,
0, 0, 0, 0, 3, 0, 0, 2, 0, 0,
0, 14, 18, 0, 0, 18, 7, 8, 6, 9,
0, 0, 13, 16, 0, 0, 17, 0, 10, 0,
4, 0, 0, 12, 0, 0, 11, 0, 22, 0,
0, 0, 0, 5, 0, 0, 0, 27, 24, 21,
23, 0, 97, 90, 0, 0, 0, 0, 108, 0,
0, 0, 0, 96, 0, 0, 0, 0, 0, 25,
0, 0, 0, 31, 39, 26, 28, 0, 30, 0,
33, 34, 35, 0, 0, 0, 0, 0, 0, 0,
67, 69, 95, 0, 0, 0, 0, 0, 0, 68,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 98, 0, 0, 0, 0, 0, 0, 29, 32,
36, 37, 38, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 54, 0, 0, 0,
0, 0, 0, 0, 0, 45, 0, 58, 0, 0,
0, 0, 0, 0, 88, 89, 0, 0, 85, 0,
0, 99, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 91, 0, 0, 114, 0, 0, 0, 0, 100,
0, 0, 42, 43, 0, 0, 0, 0, 0, 106,
0, 0, 0, 44, 46, 0, 92, 0, 0, 94,
0, 101, 0, 0, 0, 0, 61, 0, 0, 109,
48, 93, 0, 49, 0, 0, 66, 65, 0, 110,
0, 63, 0, 40, 0, 0, 0, 0, 107, 64,
41,
};
final static short yydgoto[] = { 3,
4, 5, 74, 25, 40, 10, 15, 27, 41, 42,
75, 52, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 167, 87, 147, 190, 88, 100, 101,
91, 208, 247, 92, 93, 115, 154, 230,
};
final static short yysindex[] = { -232,
-231, -215, 0, -232, 0, -216, -225, 0, -220, -66,
-216, 0, 0, -48, 131, 0, 0, 0, 0, 0,
-211, 162, 0, 0, 29, -87, 0, 279, 0, -85,
0, 66, 3, 0, 70, 162, 0, 162, 0, -74,
76, 78, 79, 0, -4, 162, -4, 0, 0, 0,
0, 4, 0, 0, 83, 84, -19, 1419, 0, -189,
86, 88, 91, 0, 92, 1419, 1419, 1228, 1375, 0,
101, -143, 105, 0, 0, 0, 0, 87, 0, 89,
0, 0, 0, 95, 99, 100, 1194, 104, 0, -109,
0, 0, 0, 1419, 1455, 1419, 43, -107, 1253, 0,
-106, 132, 82, 1419, 134, 135, 1419, -13, -13, -96,
711, 0, 768, 0, -10, -94, 122, -197, 0, 0,
0, 0, 0, 1419, 1419, 1419, 1419, 1419, 1419, 1419,
1419, 1419, 1419, 1419, 1419, 1419, 0, 1419, 1419, 1419,
1419, 145, 840, 138, 866, 0, 1419, 0, 1419, 145,
149, 1394, 1253, -1, 0, 0, 890, 158, 0, -76,
-88, 0, 157, 1419, -72, -73, -84, 1352, 1341, 681,
681, -32, -32, -15, -15, -13, -13, -13, 681, 681,
485, 464, -32, 1253, 1419, 34, 1419, 34, 916, -117,
517, 0, 968, 1419, 0, -71, 1419, -78, -55, 0,
1419, 1253, 0, 0, 1419, -75, 1419, 165, 171, 0,
994, -51, 34, 0, 0, -75, 0, 1253, 180, 0,
1419, 0, 1028, 556, 1419, 1049, 0, 1455, 34, 0,
0, 0, 580, 0, 1419, 34, 0, 0, 181, 0,
1419, 0, 1091, 0, 34, 1253, 130, 34, 0, 0,
0,
};
final static short yyrindex[] = { 0,
0, 0, 0, 230, 0, 112, 0, 0, 0, 0,
112, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 186, 0, 0, 0, 205, 0, 205, 0, 0,
0, 207, 0, 0, 0, 0, 0, 0, 0, 0,
0, -58, 0, 0, 0, 0, 0, -57, 0, 0,
0, 0, 0, 0, 0, -9, -9, -9, -9, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 615, 0,
0, 0, 0, -9, -58, -9, 1402, 0, 200, 0,
0, 0, 0, -9, 0, 0, -9, 119, 151, 0,
0, 0, 0, 453, 0, 0, 1300, 0, 0, 0,
0, 0, 0, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, 0, -9, -9, -9,
-9, 1141, 0, 0, 0, 0, -9, 0, -9, 56,
0, -9, 36, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, -9, 0, 0, 0, 421, 50, 354,
1512, 1663, 1679, 1504, 1550, 306, 401, 427, 1558, 1613,
0, 1643, 1480, -17, -25, -58, -9, -58, 0, 0,
0, 0, 0, -9, 0, 0, -9, 0, 0, 0,
-9, -6, 0, 0, -9, 1173, -9, 0, 231, 0,
0, -33, -58, 0, 0, 93, 0, 40, 0, 0,
-9, 0, 0, 0, -9, 0, 0, -22, -58, 0,
0, 0, 0, 0, -9, -58, 0, 0, 0, 0,
-9, 0, 0, 0, -58, 187, 0, -58, 0, 0,
0,
};
final static short yygindex[] = { 0,
0, 277, 24, 75, 26, 271, 267, 0, 247, 0,
60, 0, -163, 0, 0, 0, -86, 0, 0, 0,
0, 0, 0, 0, 1856, 0, 0, 0, 643, 1503,
0, 0, 0, -49, 0, 0, 102, 0,
};
final static int YYTABLESIZE=2097;
static short yytable[];
static { yytable();}
static void yytable(){
yytable = new short[]{ 111,
53, 113, 199, 33, 134, 33, 111, 214, 144, 132,
130, 111, 131, 137, 133, 103, 33, 33, 53, 114,
96, 134, 210, 50, 212, 111, 132, 136, 1, 135,
137, 133, 137, 161, 51, 199, 67, 112, 24, 195,
26, 50, 194, 68, 6, 7, 9, 30, 66, 231,
11, 24, 51, 26, 2, 12, 13, 111, 149, 17,
18, 19, 20, 21, 29, 240, 67, 17, 18, 19,
20, 21, 244, 68, 16, 149, 105, 149, 66, 105,
104, 249, 162, 104, 251, 103, 102, 31, 165, 111,
84, 111, 59, 84, 69, 37, 59, 59, 59, 59,
59, 59, 59, 97, 49, 36, 51, 84, 84, 38,
39, 200, 39, 59, 59, 59, 45, 59, 48, 47,
50, 46, 94, 95, 69, 104, 48, 105, 70, 60,
106, 107, 117, 60, 60, 60, 60, 60, 60, 60,
116, 239, 84, 166, 118, 119, 59, 120, 59, 222,
60, 60, 60, 121, 60, 86, 48, 122, 123, 86,
86, 86, 86, 86, 141, 86, 142, 146, 148, 150,
215, 151, 152, 53, 155, 156, 86, 86, 86, 158,
86, 163, 164, 60, 185, 60, 64, 87, 32, 192,
35, 87, 87, 87, 87, 87, 187, 87, 197, 198,
201, 44, 204, 203, 219, 227, 53, 205, 87, 87,
87, 86, 87, 221, 194, 225, 229, 55, 55, 64,
232, 245, 250, 111, 111, 111, 111, 111, 111, 1,
111, 111, 111, 111, 15, 111, 111, 111, 111, 111,
111, 111, 111, 87, 5, 20, 111, 19, 126, 127,
55, 111, 111, 55, 111, 23, 139, 140, 112, 111,
17, 18, 19, 20, 21, 53, 55, 54, 55, 56,
57, 102, 58, 59, 60, 61, 62, 63, 64, 62,
8, 14, 28, 65, 43, 0, 209, 0, 71, 72,
17, 18, 19, 20, 21, 53, 73, 54, 55, 56,
57, 0, 58, 59, 60, 61, 62, 63, 64, 0,
0, 0, 0, 65, 84, 84, 84, 0, 71, 72,
59, 59, 59, 0, 0, 0, 73, 84, 0, 0,
0, 0, 59, 59, 0, 0, 59, 59, 59, 59,
0, 0, 72, 0, 59, 59, 72, 72, 72, 72,
72, 0, 72, 0, 0, 0, 0, 60, 60, 60,
0, 0, 0, 72, 72, 72, 0, 72, 0, 60,
60, 0, 0, 60, 60, 60, 60, 0, 0, 0,
0, 60, 60, 86, 86, 86, 0, 17, 18, 19,
20, 21, 0, 0, 81, 86, 86, 81, 72, 86,
86, 86, 86, 34, 0, 0, 0, 86, 86, 22,
0, 81, 81, 0, 0, 87, 87, 87, 17, 18,
19, 20, 21, 0, 0, 0, 0, 87, 87, 0,
0, 87, 87, 87, 87, 0, 0, 73, 0, 87,
87, 73, 73, 73, 73, 73, 81, 73, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 73, 73,
73, 83, 73, 74, 83, 0, 0, 74, 74, 74,
74, 74, 0, 74, 0, 0, 0, 0, 83, 83,
0, 0, 0, 0, 74, 74, 74, 0, 74, 69,
0, 0, 0, 73, 69, 69, 101, 69, 69, 69,
134, 0, 0, 0, 0, 132, 130, 0, 131, 137,
133, 0, 69, 83, 69, 0, 0, 0, 0, 74,
0, 134, 0, 136, 0, 135, 132, 130, 0, 131,
137, 133, 0, 0, 0, 17, 18, 19, 20, 21,
0, 0, 207, 69, 136, 101, 135, 0, 0, 0,
0, 0, 0, 134, 149, 0, 0, 22, 132, 130,
0, 131, 137, 133, 0, 0, 0, 0, 0, 0,
72, 72, 72, 0, 207, 149, 136, 206, 135, 0,
0, 0, 72, 72, 0, 0, 72, 72, 72, 72,
0, 0, 134, 0, 72, 72, 236, 132, 130, 0,
131, 137, 133, 0, 0, 0, 0, 149, 0, 216,
0, 0, 0, 0, 0, 136, 134, 135, 81, 81,
81, 132, 130, 0, 131, 137, 133, 0, 0, 0,
81, 81, 0, 0, 0, 0, 81, 81, 0, 136,
0, 135, 81, 81, 0, 0, 149, 0, 0, 0,
0, 68, 0, 0, 0, 52, 68, 68, 0, 68,
68, 68, 0, 0, 0, 73, 73, 73, 0, 0,
149, 0, 242, 52, 68, 0, 68, 73, 73, 0,
0, 73, 73, 73, 73, 83, 83, 83, 0, 73,
73, 74, 74, 74, 89, 0, 0, 83, 83, 0,
0, 0, 0, 74, 74, 68, 0, 74, 74, 74,
74, 0, 0, 0, 0, 74, 74, 134, 69, 0,
0, 0, 132, 130, 0, 131, 137, 133, 0, 69,
69, 0, 0, 69, 69, 69, 69, 89, 0, 0,
0, 69, 69, 0, 126, 127, 0, 134, 0, 0,
0, 159, 132, 130, 0, 131, 137, 133, 0, 0,
0, 124, 125, 0, 0, 126, 127, 128, 129, 0,
136, 149, 135, 139, 140, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 124, 125, 0, 0, 126, 127, 128,
129, 149, 0, 0, 134, 139, 140, 0, 0, 132,
130, 0, 131, 137, 133, 0, 0, 0, 0, 0,
235, 0, 0, 0, 0, 0, 0, 136, 89, 135,
89, 0, 124, 125, 0, 0, 126, 127, 128, 129,
0, 0, 0, 0, 139, 140, 241, 0, 0, 0,
0, 0, 0, 0, 0, 89, 124, 125, 149, 0,
126, 127, 128, 129, 0, 0, 0, 0, 139, 140,
89, 89, 0, 0, 0, 0, 134, 0, 89, 0,
186, 132, 130, 0, 131, 137, 133, 89, 0, 0,
89, 68, 68, 0, 0, 68, 68, 68, 68, 136,
0, 135, 134, 68, 68, 0, 188, 132, 130, 0,
131, 137, 133, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 136, 134, 135, 0, 0,
149, 132, 130, 196, 131, 137, 133, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 136,
0, 135, 134, 0, 0, 0, 149, 132, 130, 0,
131, 137, 133, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 213, 0, 136, 0, 135, 0, 0,
149, 0, 0, 0, 0, 0, 0, 124, 125, 0,
0, 126, 127, 128, 129, 0, 0, 0, 0, 139,
140, 0, 0, 0, 134, 0, 149, 0, 0, 132,
130, 0, 131, 137, 133, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 136, 0, 135,
134, 0, 0, 160, 0, 132, 130, 0, 131, 137,
133, 0, 0, 0, 124, 125, 0, 0, 126, 127,
128, 129, 228, 136, 0, 135, 139, 140, 149, 0,
217, 0, 0, 0, 134, 0, 0, 0, 234, 132,
130, 0, 131, 137, 133, 0, 0, 0, 0, 0,
0, 0, 0, 0, 149, 134, 0, 136, 0, 135,
132, 130, 0, 131, 137, 133, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 136, 0,
135, 0, 0, 0, 0, 0, 124, 125, 149, 0,
126, 127, 128, 129, 0, 0, 0, 134, 139, 140,
0, 248, 132, 130, 0, 131, 137, 133, 0, 149,
0, 238, 124, 125, 0, 0, 126, 127, 128, 129,
136, 0, 135, 0, 139, 140, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 124, 125, 0, 0,
126, 127, 128, 129, 0, 0, 0, 59, 139, 140,
0, 149, 59, 59, 0, 59, 59, 59, 0, 0,
0, 0, 124, 125, 0, 0, 126, 127, 128, 129,
59, 56, 59, 0, 139, 140, 0, 0, 0, 60,
0, 0, 0, 0, 60, 60, 0, 60, 60, 60,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
134, 59, 60, 57, 60, 132, 130, 0, 131, 137,
133, 0, 0, 0, 124, 125, 0, 0, 126, 127,
128, 129, 0, 136, 0, 135, 139, 140, 0, 0,
67, 0, 0, 60, 0, 0, 0, 68, 0, 0,
124, 125, 66, 0, 126, 127, 128, 129, 0, 0,
0, 0, 139, 140, 138, 0, 0, 0, 0, 134,
0, 0, 0, 0, 132, 130, 0, 131, 137, 133,
0, 0, 0, 0, 124, 125, 0, 0, 126, 127,
128, 129, 136, 0, 135, 0, 139, 140, 69, 0,
0, 0, 0, 0, 0, 124, 125, 0, 0, 126,
127, 128, 129, 0, 0, 0, 58, 139, 140, 0,
0, 58, 58, 149, 58, 58, 58, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 58,
0, 58, 0, 0, 0, 0, 0, 124, 125, 0,
0, 126, 127, 128, 129, 0, 0, 134, 0, 139,
140, 0, 132, 130, 0, 131, 137, 133, 134, 0,
58, 0, 0, 132, 130, 0, 131, 137, 133, 0,
136, 0, 135, 0, 0, 0, 0, 67, 0, 0,
0, 136, 0, 135, 68, 0, 0, 59, 59, 66,
0, 59, 59, 59, 59, 0, 67, 0, 0, 59,
59, 149, 0, 68, 47, 0, 0, 0, 66, 0,
0, 47, 149, 0, 0, 0, 47, 0, 0, 60,
60, 67, 0, 60, 60, 60, 60, 0, 68, 0,
0, 60, 60, 66, 0, 69, 0, 112, 0, 0,
124, 125, 0, 0, 126, 127, 128, 129, 0, 0,
0, 0, 139, 140, 69, 0, 37, 67, 110, 53,
0, 54, 47, 0, 68, 0, 0, 0, 60, 66,
62, 63, 64, 0, 0, 0, 0, 65, 0, 69,
0, 0, 0, 98, 0, 0, 0, 0, 0, 0,
78, 0, 0, 78, 0, 0, 0, 0, 0, 124,
125, 0, 0, 126, 127, 128, 129, 78, 78, 0,
0, 139, 140, 0, 70, 69, 70, 70, 70, 0,
0, 0, 82, 0, 90, 82, 0, 0, 0, 0,
0, 70, 70, 70, 0, 70, 0, 0, 0, 82,
82, 0, 78, 0, 0, 0, 58, 58, 0, 0,
58, 58, 58, 58, 0, 0, 0, 0, 58, 58,
71, 0, 71, 71, 71, 0, 70, 90, 80, 0,
0, 80, 0, 0, 82, 0, 0, 71, 71, 71,
0, 71, 0, 0, 0, 80, 80, 124, 0, 0,
0, 126, 127, 128, 129, 0, 0, 0, 0, 139,
140, 0, 126, 127, 128, 129, 53, 0, 54, 0,
139, 140, 71, 0, 0, 60, 0, 62, 63, 64,
80, 0, 0, 79, 65, 53, 79, 54, 0, 0,
98, 0, 0, 47, 60, 47, 62, 63, 64, 0,
79, 79, 47, 65, 47, 47, 47, 47, 0, 98,
53, 47, 54, 77, 0, 0, 77, 47, 90, 60,
90, 62, 63, 64, 0, 0, 0, 0, 65, 0,
77, 77, 0, 75, 98, 79, 75, 0, 0, 0,
0, 0, 0, 0, 0, 90, 53, 0, 54, 76,
75, 75, 76, 0, 0, 60, 0, 62, 63, 64,
90, 90, 0, 0, 65, 77, 76, 76, 90, 0,
72, 0, 0, 0, 78, 78, 78, 90, 0, 0,
90, 0, 0, 0, 0, 75, 78, 78, 0, 0,
0, 0, 78, 78, 0, 0, 0, 0, 70, 70,
70, 76, 0, 0, 0, 0, 82, 82, 82, 0,
70, 70, 0, 0, 70, 70, 70, 70, 82, 82,
0, 0, 70, 70, 82, 82, 0, 0, 0, 0,
82, 82, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 71, 71, 71, 0, 0, 0,
0, 0, 80, 80, 80, 0, 71, 71, 0, 0,
71, 71, 71, 71, 80, 80, 0, 0, 71, 71,
80, 80, 0, 0, 0, 0, 80, 80, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 79, 79, 79,
0, 0, 0, 0, 0, 0, 0, 0, 0, 79,
79, 0, 0, 0, 0, 79, 79, 0, 0, 0,
0, 79, 79, 0, 0, 0, 0, 77, 77, 77,
0, 0, 0, 99, 0, 0, 0, 0, 0, 77,
77, 108, 109, 111, 113, 77, 77, 75, 75, 75,
0, 77, 77, 0, 0, 0, 0, 0, 0, 75,
75, 0, 0, 76, 76, 76, 0, 0, 0, 143,
0, 145, 0, 0, 0, 76, 76, 0, 0, 153,
0, 0, 157, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 168,
169, 170, 171, 172, 173, 174, 175, 176, 177, 178,
179, 180, 0, 181, 182, 183, 184, 0, 0, 0,
0, 0, 189, 0, 191, 0, 0, 193, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 202,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
153, 0, 211, 0, 0, 0, 0, 0, 0, 218,
0, 0, 220, 0, 0, 0, 223, 0, 0, 0,
224, 0, 226, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 233, 0, 0, 0,
237, 0, 0, 0, 0, 0, 0, 0, 0, 0,
243, 0, 0, 0, 0, 0, 246,
};
}
static short yycheck[];
static { yycheck(); }
static void yycheck() {
yycheck = new short[] { 33,
59, 59, 91, 91, 37, 91, 40, 125, 95, 42,
43, 45, 45, 46, 47, 41, 91, 91, 41, 69,
40, 37, 186, 41, 188, 59, 42, 60, 261, 62,
46, 47, 46, 44, 41, 91, 33, 93, 15, 41,
15, 59, 44, 40, 276, 261, 263, 22, 45, 213,
276, 28, 59, 28, 287, 276, 123, 91, 91, 257,
258, 259, 260, 261, 276, 229, 33, 257, 258, 259,
260, 261, 236, 40, 123, 91, 41, 91, 45, 44,
41, 245, 93, 44, 248, 60, 276, 59, 286, 123,
41, 125, 37, 44, 91, 93, 41, 42, 43, 44,
45, 46, 47, 123, 45, 40, 47, 58, 59, 40,
36, 161, 38, 58, 59, 60, 41, 62, 123, 41,
46, 44, 40, 40, 91, 40, 123, 40, 125, 37,
40, 40, 276, 41, 42, 43, 44, 45, 46, 47,
40, 228, 93, 118, 40, 59, 91, 59, 93, 199,
58, 59, 60, 59, 62, 37, 123, 59, 59, 41,
42, 43, 44, 45, 61, 47, 276, 125, 276, 276,
288, 40, 91, 262, 41, 41, 58, 59, 60, 276,
62, 276, 61, 91, 40, 93, 275, 37, 276, 41,
276, 41, 42, 43, 44, 45, 59, 47, 41, 276,
44, 276, 276, 276, 276, 41, 262, 292, 58, 59,
60, 93, 62, 292, 44, 291, 268, 276, 276, 275,
41, 41, 93, 257, 258, 259, 260, 261, 262, 0,
264, 265, 266, 267, 123, 269, 270, 271, 272, 273,
274, 275, 276, 93, 59, 41, 280, 41, 281, 282,
276, 285, 286, 276, 288, 125, 289, 290, 59, 293,
257, 258, 259, 260, 261, 262, 276, 264, 265, 266,
267, 41, 269, 270, 271, 272, 273, 274, 275, 93,
4, 11, 16, 280, 38, -1, 185, -1, 285, 286,
257, 258, 259, 260, 261, 262, 293, 264, 265, 266,
267, -1, 269, 270, 271, 272, 273, 274, 275, -1,
-1, -1, -1, 280, 265, 266, 267, -1, 285, 286,
265, 266, 267, -1, -1, -1, 293, 278, -1, -1,
-1, -1, 277, 278, -1, -1, 281, 282, 283, 284,
-1, -1, 37, -1, 289, 290, 41, 42, 43, 44,
45, -1, 47, -1, -1, -1, -1, 265, 266, 267,
-1, -1, -1, 58, 59, 60, -1, 62, -1, 277,
278, -1, -1, 281, 282, 283, 284, -1, -1, -1,
-1, 289, 290, 265, 266, 267, -1, 257, 258, 259,
260, 261, -1, -1, 41, 277, 278, 44, 93, 281,
282, 283, 284, 125, -1, -1, -1, 289, 290, 279,
-1, 58, 59, -1, -1, 265, 266, 267, 257, 258,
259, 260, 261, -1, -1, -1, -1, 277, 278, -1,
-1, 281, 282, 283, 284, -1, -1, 37, -1, 289,
290, 41, 42, 43, 44, 45, 93, 47, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 58, 59,
60, 41, 62, 37, 44, -1, -1, 41, 42, 43,
44, 45, -1, 47, -1, -1, -1, -1, 58, 59,
-1, -1, -1, -1, 58, 59, 60, -1, 62, 37,
-1, -1, -1, 93, 42, 43, 44, 45, 46, 47,
37, -1, -1, -1, -1, 42, 43, -1, 45, 46,
47, -1, 60, 93, 62, -1, -1, -1, -1, 93,
-1, 37, -1, 60, -1, 62, 42, 43, -1, 45,
46, 47, -1, -1, -1, 257, 258, 259, 260, 261,
-1, -1, 58, 91, 60, 93, 62, -1, -1, -1,
-1, -1, -1, 37, 91, -1, -1, 279, 42, 43,
-1, 45, 46, 47, -1, -1, -1, -1, -1, -1,
265, 266, 267, -1, 58, 91, 60, 93, 62, -1,
-1, -1, 277, 278, -1, -1, 281, 282, 283, 284,
-1, -1, 37, -1, 289, 290, 41, 42, 43, -1,
45, 46, 47, -1, -1, -1, -1, 91, -1, 93,
-1, -1, -1, -1, -1, 60, 37, 62, 265, 266,
267, 42, 43, -1, 45, 46, 47, -1, -1, -1,
277, 278, -1, -1, -1, -1, 283, 284, -1, 60,
-1, 62, 289, 290, -1, -1, 91, -1, -1, -1,
-1, 37, -1, -1, -1, 41, 42, 43, -1, 45,
46, 47, -1, -1, -1, 265, 266, 267, -1, -1,
91, -1, 93, 59, 60, -1, 62, 277, 278, -1,
-1, 281, 282, 283, 284, 265, 266, 267, -1, 289,
290, 265, 266, 267, 52, -1, -1, 277, 278, -1,
-1, -1, -1, 277, 278, 91, -1, 281, 282, 283,
284, -1, -1, -1, -1, 289, 290, 37, 266, -1,
-1, -1, 42, 43, -1, 45, 46, 47, -1, 277,
278, -1, -1, 281, 282, 283, 284, 95, -1, -1,
-1, 289, 290, -1, 281, 282, -1, 37, -1, -1,
-1, 41, 42, 43, -1, 45, 46, 47, -1, -1,
-1, 277, 278, -1, -1, 281, 282, 283, 284, -1,
60, 91, 62, 289, 290, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 277, 278, -1, -1, 281, 282, 283,
284, 91, -1, -1, 37, 289, 290, -1, -1, 42,
43, -1, 45, 46, 47, -1, -1, -1, -1, -1,
265, -1, -1, -1, -1, -1, -1, 60, 186, 62,
188, -1, 277, 278, -1, -1, 281, 282, 283, 284,
-1, -1, -1, -1, 289, 290, 267, -1, -1, -1,
-1, -1, -1, -1, -1, 213, 277, 278, 91, -1,
281, 282, 283, 284, -1, -1, -1, -1, 289, 290,
228, 229, -1, -1, -1, -1, 37, -1, 236, -1,
41, 42, 43, -1, 45, 46, 47, 245, -1, -1,
248, 277, 278, -1, -1, 281, 282, 283, 284, 60,
-1, 62, 37, 289, 290, -1, 41, 42, 43, -1,
45, 46, 47, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 60, 37, 62, -1, -1,
91, 42, 43, 44, 45, 46, 47, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 60,
-1, 62, 37, -1, -1, -1, 91, 42, 43, -1,
45, 46, 47, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 58, -1, 60, -1, 62, -1, -1,
91, -1, -1, -1, -1, -1, -1, 277, 278, -1,
-1, 281, 282, 283, 284, -1, -1, -1, -1, 289,
290, -1, -1, -1, 37, -1, 91, -1, -1, 42,
43, -1, 45, 46, 47, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 60, -1, 62,
37, -1, -1, 266, -1, 42, 43, -1, 45, 46,
47, -1, -1, -1, 277, 278, -1, -1, 281, 282,
283, 284, 59, 60, -1, 62, 289, 290, 91, -1,
93, -1, -1, -1, 37, -1, -1, -1, 41, 42,
43, -1, 45, 46, 47, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 91, 37, -1, 60, -1, 62,
42, 43, -1, 45, 46, 47, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 60, -1,
62, -1, -1, -1, -1, -1, 277, 278, 91, -1,
281, 282, 283, 284, -1, -1, -1, 37, 289, 290,
-1, 41, 42, 43, -1, 45, 46, 47, -1, 91,
-1, 93, 277, 278, -1, -1, 281, 282, 283, 284,
60, -1, 62, -1, 289, 290, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 277, 278, -1, -1,
281, 282, 283, 284, -1, -1, -1, 37, 289, 290,
-1, 91, 42, 43, -1, 45, 46, 47, -1, -1,
-1, -1, 277, 278, -1, -1, 281, 282, 283, 284,
60, 61, 62, -1, 289, 290, -1, -1, -1, 37,
-1, -1, -1, -1, 42, 43, -1, 45, 46, 47,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
37, 91, 60, 61, 62, 42, 43, -1, 45, 46,
47, -1, -1, -1, 277, 278, -1, -1, 281, 282,
283, 284, -1, 60, -1, 62, 289, 290, -1, -1,
33, -1, -1, 91, -1, -1, -1, 40, -1, -1,
277, 278, 45, -1, 281, 282, 283, 284, -1, -1,
-1, -1, 289, 290, 91, -1, -1, -1, -1, 37,
-1, -1, -1, -1, 42, 43, -1, 45, 46, 47,
-1, -1, -1, -1, 277, 278, -1, -1, 281, 282,
283, 284, 60, -1, 62, -1, 289, 290, 91, -1,
-1, -1, -1, -1, -1, 277, 278, -1, -1, 281,
282, 283, 284, -1, -1, -1, 37, 289, 290, -1,
-1, 42, 43, 91, 45, 46, 47, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 60,
-1, 62, -1, -1, -1, -1, -1, 277, 278, -1,
-1, 281, 282, 283, 284, -1, -1, 37, -1, 289,
290, -1, 42, 43, -1, 45, 46, 47, 37, -1,
91, -1, -1, 42, 43, -1, 45, 46, 47, -1,
60, -1, 62, -1, -1, -1, -1, 33, -1, -1,
-1, 60, -1, 62, 40, -1, -1, 277, 278, 45,
-1, 281, 282, 283, 284, -1, 33, -1, -1, 289,
290, 91, -1, 40, 33, -1, -1, -1, 45, -1,
-1, 40, 91, -1, -1, -1, 45, -1, -1, 277,
278, 33, -1, 281, 282, 283, 284, -1, 40, -1,
-1, 289, 290, 45, -1, 91, -1, 93, -1, -1,
277, 278, -1, -1, 281, 282, 283, 284, -1, -1,
-1, -1, 289, 290, 91, -1, 93, 33, 261, 262,
-1, 264, 91, -1, 40, -1, -1, -1, 271, 45,
273, 274, 275, -1, -1, -1, -1, 280, -1, 91,
-1, -1, -1, 286, -1, -1, -1, -1, -1, -1,
41, -1, -1, 44, -1, -1, -1, -1, -1, 277,
278, -1, -1, 281, 282, 283, 284, 58, 59, -1,
-1, 289, 290, -1, 41, 91, 43, 44, 45, -1,
-1, -1, 41, -1, 52, 44, -1, -1, -1, -1,
-1, 58, 59, 60, -1, 62, -1, -1, -1, 58,
59, -1, 93, -1, -1, -1, 277, 278, -1, -1,
281, 282, 283, 284, -1, -1, -1, -1, 289, 290,
41, -1, 43, 44, 45, -1, 93, 95, 41, -1,
-1, 44, -1, -1, 93, -1, -1, 58, 59, 60,
-1, 62, -1, -1, -1, 58, 59, 277, -1, -1,
-1, 281, 282, 283, 284, -1, -1, -1, -1, 289,
290, -1, 281, 282, 283, 284, 262, -1, 264, -1,
289, 290, 93, -1, -1, 271, -1, 273, 274, 275,
93, -1, -1, 41, 280, 262, 44, 264, -1, -1,
286, -1, -1, 262, 271, 264, 273, 274, 275, -1,
58, 59, 271, 280, 273, 274, 275, 276, -1, 286,
262, 280, 264, 41, -1, -1, 44, 286, 186, 271,
188, 273, 274, 275, -1, -1, -1, -1, 280, -1,
58, 59, -1, 41, 286, 93, 44, -1, -1, -1,
-1, -1, -1, -1, -1, 213, 262, -1, 264, 41,
58, 59, 44, -1, -1, 271, -1, 273, 274, 275,
228, 229, -1, -1, 280, 93, 58, 59, 236, -1,
286, -1, -1, -1, 265, 266, 267, 245, -1, -1,
248, -1, -1, -1, -1, 93, 277, 278, -1, -1,
-1, -1, 283, 284, -1, -1, -1, -1, 265, 266,
267, 93, -1, -1, -1, -1, 265, 266, 267, -1,
277, 278, -1, -1, 281, 282, 283, 284, 277, 278,
-1, -1, 289, 290, 283, 284, -1, -1, -1, -1,
289, 290, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 265, 266, 267, -1, -1, -1,
-1, -1, 265, 266, 267, -1, 277, 278, -1, -1,
281, 282, 283, 284, 277, 278, -1, -1, 289, 290,
283, 284, -1, -1, -1, -1, 289, 290, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 265, 266, 267,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 277,
278, -1, -1, -1, -1, 283, 284, -1, -1, -1,
-1, 289, 290, -1, -1, -1, -1, 265, 266, 267,
-1, -1, -1, 58, -1, -1, -1, -1, -1, 277,
278, 66, 67, 68, 69, 283, 284, 265, 266, 267,
-1, 289, 290, -1, -1, -1, -1, -1, -1, 277,
278, -1, -1, 265, 266, 267, -1, -1, -1, 94,
-1, 96, -1, -1, -1, 277, 278, -1, -1, 104,
-1, -1, 107, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 124,
125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
135, 136, -1, 138, 139, 140, 141, -1, -1, -1,
-1, -1, 147, -1, 149, -1, -1, 152, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 164,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
185, -1, 187, -1, -1, -1, -1, -1, -1, 194,
-1, -1, 197, -1, -1, -1, 201, -1, -1, -1,
205, -1, 207, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 221, -1, -1, -1,
225, -1, -1, -1, -1, -1, -1, -1, -1, -1,
235, -1, -1, -1, -1, -1, 241,
};
}
final static short YYFINAL=3;
final static short YYMAXTOKEN=297;
final static String yyname[] = {
"end-of-file",null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,"'!'",null,null,null,"'%'",null,null,"'('","')'","'*'","'+'",
"','","'-'","'.'","'/'",null,null,null,null,null,null,null,null,null,null,"':'",
"';'","'<'","'='","'>'",null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,"'['",null,"']'",null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,"'{'",null,"'}'",null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,"VOID","BOOL","INT","STRING",
"CLASS","NULL","EXTENDS","THIS","WHILE","FOR","IF","ELSE","RETURN","BREAK",
"NEW","PRINT","READ_INTEGER","READ_LINE","LITERAL","IDENTIFIER","AND","OR",
"STATIC","INSTANCEOF","LESS_EQUAL","GREATER_EQUAL","EQUAL","NOT_EQUAL","SCOPY",
"VAR","SEALED","DIVIDER","ARRAY_REPEAT","ARRAY_CONCAT","DEFAULT","IN","FOREACH",
"LISTFORR","LISTFORL","UMINUS","EMPTY",
};
final static String yyrule[] = {
"$accept : Program",
"Program : ClassList",
"ClassList : ClassList ClassDef",
"ClassList : ClassDef",
"VariableDef : Variable ';'",
"Variable : Type IDENTIFIER",
"Type : INT",
"Type : VOID",
"Type : BOOL",
"Type : STRING",
"Type : CLASS IDENTIFIER",
"Type : Type '[' ']'",
"ClassDef : SEALED CLASS IDENTIFIER ExtendsClause '{' FieldList '}'",
"ClassDef : CLASS IDENTIFIER ExtendsClause '{' FieldList '}'",
"ExtendsClause : EXTENDS IDENTIFIER",
"ExtendsClause :",
"FieldList : FieldList VariableDef",
"FieldList : FieldList FunctionDef",
"FieldList :",
"Formals : VariableList",
"Formals :",
"VariableList : VariableList ',' Variable",
"VariableList : Variable",
"FunctionDef : STATIC Type IDENTIFIER '(' Formals ')' StmtBlock",
"FunctionDef : Type IDENTIFIER '(' Formals ')' StmtBlock",
"StmtBlock : '{' StmtList '}'",
"StmtList : StmtList Stmt",
"StmtList :",
"Stmt : ForeachStmt",
"Stmt : OCStmt ';'",
"Stmt : GuardedStmt",
"Stmt : VariableDef",
"Stmt : SimpleStmt ';'",
"Stmt : IfStmt",
"Stmt : WhileStmt",
"Stmt : ForStmt",
"Stmt : ReturnStmt ';'",
"Stmt : PrintStmt ';'",
"Stmt : BreakStmt ';'",
"Stmt : StmtBlock",
"ForeachStmt : FOREACH '(' BoundVariable IN Expr ')' Stmt",
"ForeachStmt : FOREACH '(' BoundVariable IN Expr WHILE Expr ')' Stmt",
"BoundVariable : VAR IDENTIFIER",
"BoundVariable : Type IDENTIFIER",
"GuardedStmt : IF '{' IfBranchG IfStmtG '}'",
"GuardedStmt : IF '{' '}'",
"IfBranchG : IfBranchG IfStmtG DIVIDER",
"IfBranchG :",
"IfStmtG : Expr ':' Stmt",
"OCStmt : SCOPY '(' IDENTIFIER ',' Expr ')'",
"SimpleStmt : LValuel '=' Expr",
"SimpleStmt : VAR IDENTIFIER '=' Expr",
"SimpleStmt : Call",
"SimpleStmt :",
"Receiver : Expr '.'",
"Receiver :",
"LValuel : Receiver IDENTIFIER",
"LValuel : Expr '[' Expr ']'",
"LValue : VAR IDENTIFIER",
"LValue : Receiver IDENTIFIER",
"LValue : Expr '[' Expr ']'",
"Call : Receiver IDENTIFIER '(' Actuals ')'",
"BoolExpr : Expr",
"Expr : '[' Expr FOR IDENTIFIER IN Expr ']'",
"Expr : '[' Expr FOR IDENTIFIER IN Expr IF BoolExpr ']'",
"Expr : Expr '[' Expr ':' Expr ']'",
"Expr : Expr '[' Expr ']' DEFAULT Expr",
"Expr : LValue",
"Expr : Call",
"Expr : Constant",
"Expr : Expr '+' Expr",
"Expr : Expr '-' Expr",
"Expr : Expr '*' Expr",
"Expr : Expr '/' Expr",
"Expr : Expr '%' Expr",
"Expr : Expr EQUAL Expr",
"Expr : Expr NOT_EQUAL Expr",
"Expr : Expr ARRAY_REPEAT Expr",
"Expr : Expr ARRAY_CONCAT Expr",
"Expr : Expr '<' Expr",
"Expr : Expr '>' Expr",
"Expr : Expr LESS_EQUAL Expr",
"Expr : Expr GREATER_EQUAL Expr",
"Expr : Expr AND Expr",
"Expr : Expr OR Expr",
"Expr : '(' Expr ')'",
"Expr : '-' Expr",
"Expr : '!' Expr",
"Expr : READ_INTEGER '(' ')'",
"Expr : READ_LINE '(' ')'",
"Expr : THIS",
"Expr : NEW IDENTIFIER '(' ')'",
"Expr : NEW Type '[' Expr ']'",
"Expr : INSTANCEOF '(' Expr ',' IDENTIFIER ')'",
"Expr : '(' CLASS IDENTIFIER ')' Expr",
"Constant : ArrayConstant",
"Constant : LITERAL",
"Constant : NULL",
"ArrayConstant : '[' ']'",
"ArrayConstant : '[' ArrayInsider ']'",
"ArrayInsider : ArrayInsider ',' Constant",
"ArrayInsider : Constant",
"Actuals : ExprList",
"Actuals :",
"ExprList : ExprList ',' Expr",
"ExprList : Expr",
"WhileStmt : WHILE '(' Expr ')' Stmt",
"ForStmt : FOR '(' SimpleStmt ';' Expr ';' SimpleStmt ')' Stmt",
"BreakStmt : BREAK",
"IfStmt : IF '(' Expr ')' Stmt ElseClause",
"ElseClause : ELSE Stmt",
"ElseClause :",
"ReturnStmt : RETURN Expr",
"ReturnStmt : RETURN",
"PrintStmt : PRINT '(' ExprList ')'",
};
//#line 571 "Parser.y"
/**
* 打印当前归约所用的语法规则<br>
* 请勿修改。
*/
public boolean onReduce(String rule) {
if (rule.startsWith("$$"))
return false;
else
rule = rule.replaceAll(" \\$\\$\\d+", "");
if (rule.endsWith(":"))
System.out.println(rule + " <empty>");
else
System.out.println(rule);
return false;
}
public void diagnose() {
addReduceListener(this);
yyparse();
}
//#line 870 "Parser.java"
//###############################################################
// method: yylexdebug : check lexer state
//###############################################################
void yylexdebug(int state,int ch)
{
String s=null;
if (ch < 0) ch=0;
if (ch <= YYMAXTOKEN) //check index bounds
s = yyname[ch]; //now get it
if (s==null)
s = "illegal-symbol";
debug("state "+state+", reading "+ch+" ("+s+")");
}
//The following are now global, to aid in error reporting
int yyn; //next next thing to do
int yym; //
int yystate; //current parsing state from state table
String yys; //current token string
//###############################################################
// method: yyparse : parse input and execute indicated items
//###############################################################
int yyparse()
{
boolean doaction;
init_stacks();
yynerrs = 0;
yyerrflag = 0;
yychar = -1; //impossible char forces a read
yystate=0; //initial state
state_push(yystate); //save it
while (true) //until parsing is done, either correctly, or w/error
{
doaction=true;
//if (yydebug) debug("loop");
//#### NEXT ACTION (from reduction table)
for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate])
{
//if (yydebug) debug("yyn:"+yyn+" state:"+yystate+" yychar:"+yychar);
if (yychar < 0) //we want a char?
{
yychar = yylex(); //get next token
//if (yydebug) debug(" next yychar:"+yychar);
//#### ERROR CHECK ####
//if (yychar < 0) //it it didn't work/error
// {
// yychar = 0; //change it to default string (no -1!)
//if (yydebug)
// yylexdebug(yystate,yychar);
// }
}//yychar<0
yyn = yysindex[yystate]; //get amount to shift by (shift index)
if ((yyn != 0) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
//if (yydebug)
//debug("state "+yystate+", shifting to state "+yytable[yyn]);
//#### NEXT STATE ####
yystate = yytable[yyn];//we are in a new state
state_push(yystate); //save it
val_push(yylval); //push our lval as the input for next rule
yychar = -1; //since we have 'eaten' a token, say we need another
if (yyerrflag > 0) //have we recovered an error?
--yyerrflag; //give ourselves credit
doaction=false; //but don't process yet
break; //quit the yyn=0 loop
}
yyn = yyrindex[yystate]; //reduce
if ((yyn !=0 ) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{ //we reduced!
//if (yydebug) debug("reduce");
yyn = yytable[yyn];
doaction=true; //get ready to execute
break; //drop down to actions
}
else //ERROR RECOVERY
{
if (yyerrflag==0)
{
yyerror("syntax error");
yynerrs++;
}
if (yyerrflag < 3) //low error count?
{
yyerrflag = 3;
while (true) //do until break
{
if (stateptr<0 || valptr<0) //check for under & overflow here
{
return 1;
}
yyn = yysindex[state_peek(0)];
if ((yyn != 0) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
//if (yydebug)
//debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" ");
yystate = yytable[yyn];
state_push(yystate);
val_push(yylval);
doaction=false;
break;
}
else
{
//if (yydebug)
//debug("error recovery discarding state "+state_peek(0)+" ");
if (stateptr<0 || valptr<0) //check for under & overflow here
{
return 1;
}
state_pop();
val_pop();
}
}
}
else //discard this token
{
if (yychar == 0)
return 1; //yyabort
//if (yydebug)
//{
//yys = null;
//if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
//if (yys == null) yys = "illegal-symbol";
//debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")");
//}
yychar = -1; //read another
}
}//end error recovery
}//yyn=0 loop
if (!doaction) //any reason not to proceed?
continue; //skip action
yym = yylen[yyn]; //get count of terminals on rhs
//if (yydebug)
//debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")");
if (yym>0) //if count of rhs not 'nil'
yyval = val_peek(yym-1); //get current semantic value
if (reduceListener == null || reduceListener.onReduce(yyrule[yyn])) // if intercepted!
switch(yyn)
{
//########## USER-SUPPLIED ACTIONS ##########
case 1:
//#line 61 "Parser.y"
{
tree = new Tree.TopLevel(val_peek(0).clist, val_peek(0).loc);
}
break;
case 2:
//#line 67 "Parser.y"
{
yyval.clist.add(val_peek(0).cdef);
}
break;
case 3:
//#line 71 "Parser.y"
{
yyval.clist = new ArrayList<Tree.ClassDef>();
yyval.clist.add(val_peek(0).cdef);
}
break;
case 5:
//#line 81 "Parser.y"
{
yyval.vdef = new Tree.VarDef(val_peek(0).ident, val_peek(1).type, val_peek(0).loc);
}
break;
case 6:
//#line 87 "Parser.y"
{
yyval.type = new Tree.TypeIdent(Tree.INT, val_peek(0).loc);
}
break;
case 7:
//#line 91 "Parser.y"
{
yyval.type = new Tree.TypeIdent(Tree.VOID, val_peek(0).loc);
}
break;
case 8:
//#line 95 "Parser.y"
{
yyval.type = new Tree.TypeIdent(Tree.BOOL, val_peek(0).loc);
}
break;
case 9:
//#line 99 "Parser.y"
{
yyval.type = new Tree.TypeIdent(Tree.STRING, val_peek(0).loc);
}
break;
case 10:
//#line 103 "Parser.y"
{
yyval.type = new Tree.TypeClass(val_peek(0).ident, val_peek(1).loc);
}
break;
case 11:
//#line 107 "Parser.y"
{
yyval.type = new Tree.TypeArray(val_peek(2).type, val_peek(2).loc);
}
break;
case 12:
//#line 113 "Parser.y"
{
yyval.cdef = new Tree.ClassDef(true, val_peek(4).ident, val_peek(3).ident, val_peek(1).flist, val_peek(6).loc);
}
break;
case 13:
//#line 117 "Parser.y"
{
yyval.cdef = new Tree.ClassDef(false, val_peek(4).ident, val_peek(3).ident, val_peek(1).flist, val_peek(5).loc);
}
break;
case 14:
//#line 123 "Parser.y"
{
yyval.ident = val_peek(0).ident;
}
break;
case 15:
//#line 127 "Parser.y"
{
yyval = new SemValue();
}
break;
case 16:
//#line 133 "Parser.y"
{
yyval.flist.add(val_peek(0).vdef);
}
break;
case 17:
//#line 137 "Parser.y"
{
yyval.flist.add(val_peek(0).fdef);
}
break;
case 18:
//#line 141 "Parser.y"
{
yyval = new SemValue();
yyval.flist = new ArrayList<Tree>();
}
break;
case 20:
//#line 149 "Parser.y"
{
yyval = new SemValue();
yyval.vlist = new ArrayList<Tree.VarDef>();
}
break;
case 21:
//#line 156 "Parser.y"
{
yyval.vlist.add(val_peek(0).vdef);
}
break;
case 22:
//#line 160 "Parser.y"
{
yyval.vlist = new ArrayList<Tree.VarDef>();
yyval.vlist.add(val_peek(0).vdef);
}
break;
case 23:
//#line 168 "Parser.y"
{
yyval.fdef = new MethodDef(true, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc);
}
break;
case 24:
//#line 172 "Parser.y"
{
yyval.fdef = new MethodDef(false, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc);
}
break;
case 25:
//#line 178 "Parser.y"
{
yyval.stmt = new Block(val_peek(1).slist, val_peek(2).loc);
}
break;
case 26:
//#line 184 "Parser.y"
{
yyval.slist.add(val_peek(0).stmt);
}
break;
case 27:
//#line 188 "Parser.y"
{
yyval = new SemValue();
yyval.slist = new ArrayList<Tree>();
}
break;
case 31:
//#line 198 "Parser.y"
{
yyval.stmt = val_peek(0).vdef;
}
break;
case 32:
//#line 203 "Parser.y"
{
if (yyval.stmt == null) {
yyval.stmt = new Tree.Skip(val_peek(0).loc);
}
}
break;
case 40:
//#line 218 "Parser.y"
{
yyval.stmt = new Tree.ArrayFor(false, val_peek(4).lvalue, val_peek(2).expr, val_peek(0).stmt, null, val_peek(6).loc);
}
break;
case 41:
//#line 222 "Parser.y"
{
yyval.stmt = new Tree.ArrayFor(true, val_peek(6).lvalue, val_peek(4).expr, val_peek(0).stmt, val_peek(2).expr, val_peek(8).loc);
}
break;
case 42:
//#line 228 "Parser.y"
{
yyval.lvalue = new LValue.BoundVar(null, val_peek(0).ident, val_peek(1).loc);
}
break;
case 43:
//#line 232 "Parser.y"
{
yyval.lvalue = new LValue.BoundVar(val_peek(1).type, val_peek(0).ident, val_peek(1).loc);
}
break;
case 44:
//#line 239 "Parser.y"
{
val_peek(2).slist.add(val_peek(1).stmt);
yyval.stmt = new Tree.Guard(val_peek(2).slist, val_peek(4).loc);
}
break;
case 45:
//#line 245 "Parser.y"
{
yyval.stmt = new Tree.Guard(null, val_peek(2).loc);
}
break;
case 46:
//#line 251 "Parser.y"
{
yyval.slist.add(val_peek(1).stmt);
}
break;
case 47:
//#line 255 "Parser.y"
{
yyval = new SemValue();
yyval.slist = new ArrayList<Tree>();
}
break;
case 48:
//#line 262 "Parser.y"
{
yyval.stmt = new Tree.IfG(val_peek(2).expr, val_peek(0).stmt, val_peek(2).loc);
}
break;
case 49:
//#line 269 "Parser.y"
{
yyval.stmt = new Tree.Scopy(val_peek(3).ident, val_peek(1).expr, val_peek(3).loc);
}
break;
case 50:
//#line 275 "Parser.y"
{
yyval.stmt = new Tree.Assign(val_peek(2).lvalue, val_peek(0).expr, val_peek(1).loc);
}
break;
case 51:
//#line 279 "Parser.y"
{
yyval.lvalue = new Tree.IdentVar(val_peek(2).ident, val_peek(2).loc);
yyval.stmt = new Tree.VarAssign(val_peek(0).expr, val_peek(2).loc, val_peek(2).ident);
}
break;
case 52:
//#line 284 "Parser.y"
{
yyval.stmt = new Tree.Exec(val_peek(0).expr, val_peek(0).loc);
}
break;
case 53:
//#line 288 "Parser.y"
{
yyval = new SemValue();
}
break;
case 55:
//#line 295 "Parser.y"
{
yyval = new SemValue();
}
break;
case 56:
//#line 301 "Parser.y"
{
yyval.lvalue = new Tree.Ident(val_peek(1).expr, val_peek(0).ident, val_peek(0).loc);
if (val_peek(1).loc == null) {
yyval.loc = val_peek(0).loc;
}
}
break;
case 57:
//#line 308 "Parser.y"
{
yyval.lvalue = new Tree.Indexed(val_peek(3).expr, val_peek(1).expr, val_peek(3).loc);
}
break;
case 58:
//#line 314 "Parser.y"
{
yyval.lvalue = new Tree.IdentVar(val_peek(0).ident, val_peek(0).loc);
if (val_peek(1).loc == null) {
yyval.loc = val_peek(0).loc;
}
}
break;
case 59:
//#line 321 "Parser.y"
{
yyval.lvalue = new Tree.Ident(val_peek(1).expr, val_peek(0).ident, val_peek(0).loc);
if (val_peek(1).loc == null) {
yyval.loc = val_peek(0).loc;
}
}
break;
case 60:
//#line 328 "Parser.y"
{
yyval.lvalue = new Tree.Indexed(val_peek(3).expr, val_peek(1).expr, val_peek(3).loc);
}
break;
case 61:
//#line 334 "Parser.y"
{
yyval.expr = new Tree.CallExpr(val_peek(4).expr, val_peek(3).ident, val_peek(1).elist, val_peek(3).loc);
if (val_peek(4).loc == null) {
yyval.loc = val_peek(3).loc;
}
}
break;
case 63:
//#line 346 "Parser.y"
{
yyval.expr = new Tree.ArrayComp(false, val_peek(5).expr, val_peek(3).ident, val_peek(1).expr, null, val_peek(6).loc);
}
break;
case 64:
//#line 350 "Parser.y"
{
yyval.expr = new Tree.ArrayComp(true, val_peek(7).expr, val_peek(5).ident, val_peek(3).expr, val_peek(1).expr, val_peek(8).loc);
}
break;
case 65:
//#line 354 "Parser.y"
{
yyval.expr = new Tree.ArrayRef(val_peek(5).expr, val_peek(3).expr, val_peek(1).expr, val_peek(5).loc);
}
break;
case 66:
//#line 358 "Parser.y"
{
yyval.expr = new Tree.ArrayDefault(val_peek(5).expr, val_peek(3).expr, val_peek(0).expr, val_peek(5).loc);
}
break;
case 67:
//#line 362 "Parser.y"
{
yyval.expr = val_peek(0).lvalue;
}
break;
case 70:
//#line 368 "Parser.y"
{
yyval.expr = new Tree.Binary(Tree.PLUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc);
}
break;
case 71:
//#line 372 "Parser.y"
{
yyval.expr = new Tree.Binary(Tree.MINUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc);
}
break;
case 72:
//#line 376 "Parser.y"
{
yyval.expr = new Tree.Binary(Tree.MUL, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc);
}
break;
case 73:
//#line 380 "Parser.y"
{
yyval.expr = new Tree.Binary(Tree.DIV, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc);
}
break;
case 74:
//#line 384 "Parser.y"
{
yyval.expr = new Tree.Binary(Tree.MOD, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc);
}
break;
case 75:
//#line 388 "Parser.y"
{
yyval.expr = new Tree.Binary(Tree.EQ, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc);
}
break;
case 76:
//#line 392 "Parser.y"
{
yyval.expr = new Tree.Binary(Tree.NE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc);
}
break;
case 77:
//#line 396 "Parser.y"
{
yyval.expr = new Tree.ArrayInit(val_peek(2).expr, val_peek(0).expr, val_peek(2).loc);
}
break;
case 78:
//#line 400 "Parser.y"
{
yyval.expr = new Tree.ArrayConcat(val_peek(2).expr, val_peek(0).expr, val_peek(2).loc);
}
break;
case 79:
//#line 404 "Parser.y"
{
yyval.expr = new Tree.Binary(Tree.LT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc);
}
break;
case 80:
//#line 408 "Parser.y"
{
yyval.expr = new Tree.Binary(Tree.GT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc);
}
break;
case 81:
//#line 412 "Parser.y"
{
yyval.expr = new Tree.Binary(Tree.LE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc);
}
break;
case 82:
//#line 416 "Parser.y"
{
yyval.expr = new Tree.Binary(Tree.GE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc);
}
break;
case 83:
//#line 420 "Parser.y"
{
yyval.expr = new Tree.Binary(Tree.AND, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc);
}
break;
case 84:
//#line 424 "Parser.y"
{
yyval.expr = new Tree.Binary(Tree.OR, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc);
}
break;
case 85:
//#line 428 "Parser.y"
{
yyval = val_peek(1);
}
break;
case 86:
//#line 432 "Parser.y"
{
yyval.expr = new Tree.Unary(Tree.NEG, val_peek(0).expr, val_peek(1).loc);
}
break;
case 87:
//#line 436 "Parser.y"
{
yyval.expr = new Tree.Unary(Tree.NOT, val_peek(0).expr, val_peek(1).loc);
}
break;
case 88:
//#line 440 "Parser.y"
{
yyval.expr = new Tree.ReadIntExpr(val_peek(2).loc);
}
break;
case 89:
//#line 444 "Parser.y"
{
yyval.expr = new Tree.ReadLineExpr(val_peek(2).loc);
}
break;
case 90:
//#line 448 "Parser.y"
{
yyval.expr = new Tree.ThisExpr(val_peek(0).loc);
}
break;
case 91:
//#line 452 "Parser.y"
{
yyval.expr = new Tree.NewClass(val_peek(2).ident, val_peek(3).loc);
}
break;
case 92:
//#line 456 "Parser.y"
{
yyval.expr = new Tree.NewArray(val_peek(3).type, val_peek(1).expr, val_peek(4).loc);
}
break;
case 93:
//#line 460 "Parser.y"
{
yyval.expr = new Tree.TypeTest(val_peek(3).expr, val_peek(1).ident, val_peek(5).loc);
}
break;
case 94:
//#line 464 "Parser.y"
{
yyval.expr = new Tree.TypeCast(val_peek(2).ident, val_peek(0).expr, val_peek(0).loc);
}
break;
case 96:
//#line 471 "Parser.y"
{
yyval.expr = new Tree.Literal(val_peek(0).typeTag, val_peek(0).literal, val_peek(0).loc);
}
break;
case 97:
//#line 475 "Parser.y"
{
yyval.expr = new Null(val_peek(0).loc);
}
break;
case 98:
//#line 481 "Parser.y"
{
yyval.expr = new Tree.Array(null, val_peek(1).loc);
}
break;
case 99:
//#line 485 "Parser.y"
{
yyval.expr = new Tree.Array(val_peek(1).elist, val_peek(2).loc);
}
break;
case 100:
//#line 491 "Parser.y"
{
yyval.elist.add(val_peek(0).expr);
}
break;
case 101:
//#line 495 "Parser.y"
{
yyval.elist = new ArrayList<Tree.Expr>();
yyval.elist.add(val_peek(0).expr);
}
break;
case 103:
//#line 503 "Parser.y"
{
yyval = new SemValue();
yyval.elist = new ArrayList<Tree.Expr>();
}
break;
case 104:
//#line 510 "Parser.y"
{
yyval.elist.add(val_peek(0).expr);
}
break;
case 105:
//#line 514 "Parser.y"
{
yyval.elist = new ArrayList<Tree.Expr>();
yyval.elist.add(val_peek(0).expr);
}
break;
case 106:
//#line 521 "Parser.y"
{
yyval.stmt = new Tree.WhileLoop(val_peek(2).expr, val_peek(0).stmt, val_peek(4).loc);
}
break;
case 107:
//#line 527 "Parser.y"
{
yyval.stmt = new Tree.ForLoop(val_peek(6).stmt, val_peek(4).expr, val_peek(2).stmt, val_peek(0).stmt, val_peek(8).loc);
}
break;
case 108:
//#line 533 "Parser.y"
{
yyval.stmt = new Tree.Break(val_peek(0).loc);
}
break;
case 109:
//#line 539 "Parser.y"
{
yyval.stmt = new Tree.If(val_peek(3).expr, val_peek(1).stmt, val_peek(0).stmt, val_peek(5).loc);
}
break;
case 110:
//#line 545 "Parser.y"
{
yyval.stmt = val_peek(0).stmt;
}
break;
case 111:
//#line 549 "Parser.y"
{
yyval = new SemValue();
}
break;
case 112:
//#line 555 "Parser.y"
{
yyval.stmt = new Tree.Return(val_peek(0).expr, val_peek(1).loc);
}
break;
case 113:
//#line 559 "Parser.y"
{
yyval.stmt = new Tree.Return(null, val_peek(0).loc);
}
break;
case 114:
//#line 565 "Parser.y"
{
yyval.stmt = new Print(val_peek(1).elist, val_peek(3).loc);
}
break;
//#line 1618 "Parser.java"
//########## END OF USER-SUPPLIED ACTIONS ##########
}//switch
//#### Now let's reduce... ####
//if (yydebug) debug("reduce");
state_drop(yym); //we just reduced yylen states
yystate = state_peek(0); //get new state
val_drop(yym); //corresponding value drop
yym = yylhs[yyn]; //select next TERMINAL(on lhs)
if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL
{
//if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+"");
yystate = YYFINAL; //explicitly say we're done
state_push(YYFINAL); //and save it
val_push(yyval); //also save the semantic value of parsing
if (yychar < 0) //we want another character?
{
yychar = yylex(); //get next character
//if (yychar<0) yychar=0; //clean, if necessary
//if (yydebug)
//yylexdebug(yystate,yychar);
}
if (yychar == 0) //Good exit (if lex returns 0 ;-)
break; //quit the loop--all DONE
}//if yystate
else //else not done yet
{ //get next state and push, for next yydefred[]
yyn = yygindex[yym]; //find out where to go
if ((yyn != 0) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn]; //get new state
else
yystate = yydgoto[yym]; //else go to new defred
//if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+"");
state_push(yystate); //going again, so push state & val...
val_push(yyval); //for next action
}
}//main loop
return 0;//yyaccept!!
}
//## end of method parse() ######################################
//## run() --- for Thread #######################################
//## The -Jnorun option was used ##
//## end of method run() ########################################
//## Constructors ###############################################
//## The -Jnoconstruct option was used ##
//###############################################################
}
//################### END OF CLASS ##############################
|
package com.ota.ibeacon4android.fw;
import java.util.List;
import com.ota.ibeacon4android.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
public class BeaconAdapter extends ArrayAdapter<BeaconData> {
private LayoutInflater _layoutInflater;
private Context _context;
private int mLastAnimationPosition = 0;
public BeaconAdapter(Context context, int textViewResourceId, List<BeaconData> objects) {
super(context, textViewResourceId, objects);
_layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
_context = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
System.out.println("Position:" + position);
// convertViewは使い回しされている可能性があるのでnullの時だけ新しく作る
if (null == convertView) {
convertView = _layoutInflater.inflate(R.layout.beacon_listdata, null);
}
// 特定の行(position)のデータを得る
BeaconData item = (BeaconData) getItem(position);
if (item != null) {
// BeaconDataのデータをViewの各Widgetにセットする
Button beaconNumButton;
beaconNumButton = (Button)convertView.findViewById(R.id.beacon_num_btn);
beaconNumButton.setText(Integer.toString(position + 1));
if (!item.isIBeacon()) {
beaconNumButton.setBackground(convertView.getResources().getDrawable(R.drawable.circle_number_notbeacon));
}
ImageView beaconImg;
beaconImg = (ImageView) convertView.findViewById(R.id.ibeaconImgView);
if (!item.isIBeacon()) {
beaconImg.setVisibility(ImageView.INVISIBLE);
}
TextView beaconNametext;
beaconNametext = (TextView)convertView.findViewById(R.id.beacon_name);
beaconNametext.setText(item.getBeaconName());
TextView uuidtext;
uuidtext = (TextView)convertView.findViewById(R.id.beacon_uuid);
uuidtext.setText(item.getUuid());
TextView majortext;
majortext = (TextView)convertView.findViewById(R.id.beacon_major);
if (item.isIBeacon()) {
majortext.setText(item.getMajor());
} else {
majortext.setText("-");
}
TextView minortext;
minortext = (TextView)convertView.findViewById(R.id.beacon_minor);
if (item.isIBeacon()) {
minortext.setText(item.getMinor());
} else {
minortext.setText("-");
}
TextView rssitext;
rssitext = (TextView)convertView.findViewById(R.id.rssi_num);
rssitext.setText(Integer.toString(item.getRssi()));
long ldistance = item.getDistance();
TextView distancenumtext;
distancenumtext = (TextView)convertView.findViewById(R.id.distance_num);
TextView distanceunittext;
distanceunittext = (TextView)convertView.findViewById(R.id.distance_unit);
if (!item.isIBeacon()) {
distancenumtext.setText("- ");
distanceunittext.setText("m");
} else if (ldistance <= 100) {
distancenumtext.setText(Long.toString(ldistance));
distanceunittext.setText("cm");
} else {
distancenumtext.setText(Long.toString(Math.round(ldistance / 100)));
distanceunittext.setText("m");
}
}
// if (mLastAnimationPosition < position) {
// Animation animation = AnimationUtils.loadAnimation(_context, R.anim.list_motion);
// convertView.startAnimation(animation);
// mLastAnimationPosition = position;
// }
return convertView;
}
}
|
package com.zking.ssm.mapper;
import com.zking.ssm.model.Book;
import com.zking.ssm.model.MyFile;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Repository
public interface BookMapper {
int deleteByPrimaryKey(Integer bookId);
int insert(Book record);
int insertSelective(Book record);
Book selectByPrimaryKey(Integer bookId);
int updateByPrimaryKeySelective(Book record);
int updateByPrimaryKey(Book record);
List<Book> listBookByPager();
int updImg(Book book);
List<Map> listListMap();
Map listMap(Integer bookId);
Book listSingerBook(Integer bookId);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.