text
stringlengths 10
2.72M
|
|---|
package com.example.codebind.linkingactivities;
import android.app.AlertDialog;
import android.content.Intent;
import android.database.Cursor;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.util.Random;
public class MainActivity extends AppCompatActivity {
private Button createButton;
Button btnViewRandomWorkout;
DatabaseHelper myDb;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myDb = new DatabaseHelper(this);
//navigate to view all workouts
Button viewAllButton =(Button) findViewById(R.id.btnViewAllWorkouts);
viewAllButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
openViewAll();
}
});
//navigate to add move page
Button addMoveButton =(Button) findViewById(R.id.btnAddMove);
addMoveButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
openAddMove();
}
});
//navigate to edit move page
Button editMoveButton =(Button) findViewById(R.id.btnEditAMove);
editMoveButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
openEditMove();
}
});
//navigate to delete move
Button deleteMoveButton =(Button) findViewById(R.id.btnDeleteMove);
deleteMoveButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
openDeleteAMove();
}
});
//button to view random workouts
btnViewRandomWorkout=(Button)findViewById(R.id.btnViewRandomWorkout);
//view random workout instantiate function
viewRandom();
}
public void openViewAll() {
Intent intent = new Intent(this, viewAllWorkouts.class);
startActivity(intent);
}
public void openEditMove() {
Intent intent = new Intent(this, editAMove.class);
startActivity(intent);
}
public void openAddMove() {
Intent intent = new Intent(this, addAMove.class);
startActivity(intent);
}
public void openDeleteAMove() {
Intent intent = new Intent(this, deleteAMove.class);
startActivity(intent);
}
public void viewRandom() {
btnViewRandomWorkout.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
//get record count from moves table to set upper random number limit
Cursor recordCount=myDb.getRecordCount();
//get random number using new upper limit
Random rand = new Random();
int newLow = recordCount.getCount();
int low = newLow;
int high = 17;
//first move
int n = rand.nextInt(high-low) + low;
String rand1=String.valueOf(n);
Cursor move1=myDb.getRandom(rand1);
//second move
int n2 = rand.nextInt(high-low) + low;
String rand2=String.valueOf(n2);
Cursor move2=myDb.getRandom(rand2);
//third move
int n3 = rand.nextInt(high-low) + low;
String rand3=String.valueOf(n3);
Cursor move3=myDb.getRandom(rand3);
//fourth move
int n4 = rand.nextInt(high-low) + low;
String rand4=String.valueOf(n4);
Cursor move4=myDb.getRandom(rand4);
//fifth move
int n5 = rand.nextInt(high-low) + low;
String rand5=String.valueOf(n5);
Cursor move5=myDb.getRandom(rand5);
//sixth move
int n6 = rand.nextInt(high-low) + low;
String rand6=String.valueOf(n6);
Cursor move6=myDb.getRandom(rand6);
StringBuffer buffer = new StringBuffer();
//append move 1 to buffer
if( move1 != null && move1.moveToFirst() ){
buffer.append("Type :"+ move1.getString(1)+"\n");
buffer.append("Name :"+ move1.getString(2)+"\n");
buffer.append("Move Description :"+ move1.getString(3)+"\n\n");
}
//append move 2 to buffer
if( move2 != null && move2.moveToFirst() ){
buffer.append("Type :"+ move2.getString(1)+"\n");
buffer.append("Name :"+ move2.getString(2)+"\n");
buffer.append("Move Description :"+ move2.getString(3)+"\n\n");
}
//append move 3 to buffer
if( move3 != null && move3.moveToFirst() ){
buffer.append("Type :"+ move3.getString(1)+"\n");
buffer.append("Name :"+ move3.getString(2)+"\n");
buffer.append("Move Description :"+ move3.getString(3)+"\n\n");
}
//append move 4 to buffer
if( move4 != null && move4.moveToFirst() ){
buffer.append("Type :"+ move4.getString(1)+"\n");
buffer.append("Name :"+ move4.getString(2)+"\n");
buffer.append("Move Description :"+ move4.getString(3)+"\n\n");
}
//append move 5 to buffer
if( move5 != null && move5.moveToFirst() ){
buffer.append("Type :"+ move5.getString(1)+"\n");
buffer.append("Name :"+ move5.getString(2)+"\n");
buffer.append("Move Description :"+ move5.getString(3)+"\n\n");
}
//append move 6 to buffer
if( move6 != null && move6.moveToFirst() ){
buffer.append("Type :"+ move6.getString(1)+"\n");
buffer.append("Name :"+ move6.getString(2)+"\n");
buffer.append("Move Description :"+ move6.getString(3)+"\n\n");
}
showMessage("Your Random Workout",buffer.toString());
/* while (res.moveToNext()) {
buffer.append("Id :"+ res.getString(0)+"\n");
buffer.append("Type :"+ res.getString(1)+"\n");
buffer.append("Name :"+ res.getString(2)+"\n");
buffer.append("Move Description :"+ res.getString(3)+"\n\n");
}*/
// Show all data
//showMessage("Random Number",buffer.toString());
}
}
);
}
public void showMessage(String title,String Message){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setTitle(title);
builder.setMessage(Message);
builder.show();
}
}
|
package com.tencent.mm.plugin.appbrand.game.cgipkg;
import com.tencent.mm.ab.b;
import com.tencent.mm.ab.l;
import com.tencent.mm.by.f;
import com.tencent.mm.plugin.appbrand.ipc.d;
import com.tencent.mm.protocal.c.ady;
import com.tencent.mm.protocal.c.adz;
import com.tencent.mm.protocal.c.bhp;
import com.tencent.mm.sdk.platformtools.bi;
import com.tencent.mm.sdk.platformtools.x;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public final class a extends com.tencent.mm.ab.a<adz> {
private static final Map<String, adz> fAz = new ConcurrentHashMap();
private final b fmB;
protected final /* synthetic */ void a(int i, int i2, String str, bhp bhp, l lVar) {
adz adz = (adz) bhp;
x.i("MicroMsg.AppBrand.CgiGetGameMenu", "onCgiBack, req [appid %s]resp [errType %s, errCode %s, errMsg %s, resp %s]", new Object[]{getAppId(), Integer.valueOf(i), Integer.valueOf(i2), str, adz});
if (i == 0 && i2 == 0 && adz != null) {
GameMenuParcel gameMenuParcel = new GameMenuParcel();
gameMenuParcel.appId = getAppId();
gameMenuParcel.fAA = adz;
d.c(gameMenuParcel);
fAz.put(getAppId(), adz);
}
}
private String getAppId() {
return ((ady) this.fmB.dID.dIL).bPS;
}
public final synchronized f<com.tencent.mm.ab.a.a<adz>> KM() {
fAz.remove(getAppId());
return super.KM();
}
public static adz sN(String str) {
return bi.oW(str) ? null : (adz) fAz.get(str);
}
}
|
package pl.wenusix.familiada.controller;
import org.springframework.web.bind.annotation.*;
import pl.wenusix.familiada.entity.AnswerEntity;
import pl.wenusix.familiada.entity.QuestionEntity;
import pl.wenusix.familiada.model.QuestionModel;
import pl.wenusix.familiada.repository.QuestionRepository;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@CrossOrigin
@RequestMapping("database")
public class DatabaseController {
private final QuestionRepository questionRepository;
public DatabaseController(QuestionRepository questionRepository) {
this.questionRepository = questionRepository;
}
@PostMapping
public void fillDatabaseQuestions(@RequestBody Questions questions, @RequestParam String password){
if(!password.equals("fghmktrklrnhiteng5io5en5uiogr"))return;
questions.getQuestions().forEach(model ->{
List<AnswerEntity> list = model.getAnswers().stream().map(v -> new AnswerEntity(v.getPoints(), v.getText(), v.getSynonyms())).collect(Collectors.toList());
QuestionEntity questionEntity = new QuestionEntity(model.getQuestion(), model.getLevel(), list);
questionRepository.save(questionEntity);
});
}
}
class Questions{
private List<QuestionModel> questions;
public List<QuestionModel> getQuestions() {
return questions;
}
}
|
package com.project.common;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.project.dto.User;
public class LoginChecker extends HandlerInterceptorAdapter {
private static final Logger logger = LoggerFactory.getLogger(LoginChecker.class);
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
HttpSession session = request.getSession(false);
if (session == null) {
response.sendRedirect(RootConstants.Pages.LOGIN_PAGE);
return false;
}
session.setAttribute("loginInterceptedPage", request.getRequestURI());
User user = (User) session.getAttribute("user");
if (user == null) {
response.sendRedirect(RootConstants.Pages.LOGIN_PAGE);
return false;
}
return true;
}
}
|
package com.kashu.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class CartController {
@RequestMapping(value="/cart/add")
public String addToCart(@RequestParam(value="productId",required = false) Long id,
@RequestParam(value="amount",required=false) Integer amount,Model model){
model.addAttribute("productId", id);
model.addAttribute("amount", amount);
return "cart/add_success";
}
}
|
package generateRandomMovies;
public class Draw {
private static final int times = 6000000;
public static void main(String[] args) {
RandomCollection<Movie> rc = new RandomCollection<>();
Movie[] filmes = {
new Movie("Vingadores"),
new Movie("Simplesmente Acontece"),
new Movie("Como Treinar o seu Dragão", 2)
};
for (Movie filme : filmes) {
rc.add(filme);
}
Movie filme = null;
for (int roll = 1; roll <= times; roll++) {
filme = rc.next();
filme.setFrequency(filme.getFrequency() + 1);
}
System.out.println("Último sorteado: " + filme.getName());
System.out.println();
System.out.println("Votos\tFrequency\tNome");
for (Movie f : rc.getData()) {
System.out.println(
f.getVotos() + "\t" +
f.getFrequency() + "\t\t" +
f.getName());
}
}
}
|
package com.xzj.lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
public class ReentrantReadWriteLockTest {
private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
public static void main(String[] args) {
test1();
//test2();
}
public static void test1() {
Thread t1 = new Thread(new Runnable() {
@Override
public void run() {
read();
}
});
t1.setName("t1");
Thread t2 = new Thread(new Runnable() {
@Override
public void run() {
read();
}
});
t2.setName("t2");
t1.start();
t2.start();
}
public static void test2() {
Thread t1 = new Thread(new Runnable() {
@Override
public void run() {
read();
}
});
t1.setName("t1");
Thread t2 = new Thread(new Runnable() {
@Override
public void run() {
write();
}
});
t2.setName("t2");
t1.start();
t2.start();
}
public static void read() {
try {
lock.readLock().lock();
System.out.println(Thread.currentThread().getName() + " start");
Thread.sleep(10000);
System.out.println(Thread.currentThread().getName() + " end");
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
lock.readLock().unlock();
}
}
public static void write() {
try {
lock.writeLock().lock();
System.out.println(Thread.currentThread().getName() + " start");
Thread.sleep(10000);
System.out.println(Thread.currentThread().getName() + " end");
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
lock.readLock().unlock();
}
}
}
|
package com.kdp.wanandroidclient.ui.core.model;
import com.kdp.wanandroidclient.bean.Chapter;
import com.kdp.wanandroidclient.net.callback.RxObserver;
import java.util.List;
/***
* @author kdp
* @date 2019/3/25 16:34
* @description
*/
public interface IChapterModel {
/**
* 获取公众号
* @param rxObserver
*/
void getChapters(RxObserver<List<Chapter>> rxObserver);
}
|
package sci.ml.logit.train;
import sci.ml.logit.io.DataframeReader;
import sci.ml.logit.utils.Activation;
import sci.ml.logit.utils.SciException;
import javax.management.RuntimeErrorException;
import java.io.File;
import java.util.Arrays;
/**
* Created by hok on 8/18/16.
*/
@Deprecated
public class GradientDescent {
private File dataFrameFile;
private DataframeReader dataframeReader;
private int labelCol;
private int[] featureCols;
private int maxIter = 1000;
private double learningRate = 0.01;
private double tolFraction = 0.001;
public GradientDescent(File dataframeFile, int labelCol, int[] featureCols) {
this.dataFrameFile = dataframeFile;
this.labelCol = labelCol;
this.featureCols = featureCols;
this.dataframeReader = new DataframeReader(this.dataFrameFile, this.labelCol, this.featureCols);
}
public double[] train() {
int iter = 0;
double[] oldCoef = new double[featureCols.length+1];
Arrays.fill(oldCoef, 1.0);
boolean closeEnough = false;
do {
iter++;
System.out.println("Iteration "+iter);
dataframeReader.startReading();
double[] sumVector = new double[featureCols.length+1];
Arrays.fill(sumVector, 0.0);
while (dataframeReader.isReading()) {
DataframeReader.DataPoint dataPoint = dataframeReader.next();
if (dataPoint!=null) {
double z = thetaDotX(oldCoef, dataPoint.getFeatureValues());
double diff = dataPoint.getLabel() - Activation.Sigmoid(z);
sumVector[0] += diff;
for (int elemId=1; elemId<sumVector.length; elemId++) {
sumVector[elemId] += diff*dataPoint.getFeatureValues()[elemId-1];
}
}
}
int numLines = dataframeReader.getNumLines();
double[] newCoef = new double[featureCols.length+1];
for (int elemId=0; elemId<sumVector.length; elemId++) {
newCoef[elemId] = oldCoef[elemId] - learningRate / numLines * sumVector[elemId];
}
closeEnough = isCloseEnough(oldCoef, newCoef);
oldCoef = newCoef;
} while ((iter <= maxIter) && (!closeEnough));
return oldCoef;
}
protected double thetaDotX(double[] theta, double[] x) {
if (theta.length != (x.length+1)) {
throw new SciException("Arrays size inappropriate!");
}
double dotprod = theta[0];
for (int i=0; i<x.length; i++) {
dotprod += theta[i+1]*x[i];
}
return dotprod;
}
protected boolean isCloseEnough(double[] coef1, double[] coef2) {
if (coef1.length!=coef2.length) {
throw new SciException("Arrays unequal sizes!");
}
for (int i=0; i<coef1.length; i++) {
if (Math.abs(coef1[i]-coef2[i])/Math.max(Math.abs(coef1[i]), Math.abs(coef2[i])) > tolFraction) return false;
}
return true;
}
public static void main(String[] args) {
String filePath = args[0];
File dataframe = new File(filePath);
GradientDescent trainer = new GradientDescent(dataframe, 0, new int[]{1, 2});
double[] coef = trainer.train();
for (int i=0; i<coef.length; i++) {
System.out.println("coef "+i+" = "+coef[i]);
}
}
}
|
package com.accp.pub.pojo;
import java.util.Date;
public class Kaoqingyichang {
private Integer did;
private Integer kid;
private Integer uid;
private String uname;
private Integer gradeid;
private String gradename;
private Integer state;
private String makeprople;
private Integer makeid;
private Date maketime;
private Integer b1;
private String b2;
private String b3;
private Integer state1;
public Integer getDid() {
return did;
}
public void setDid(Integer did) {
this.did = did;
}
public Integer getKid() {
return kid;
}
public void setKid(Integer kid) {
this.kid = kid;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname == null ? null : uname.trim();
}
public Integer getGradeid() {
return gradeid;
}
public void setGradeid(Integer gradeid) {
this.gradeid = gradeid;
}
public String getGradename() {
return gradename;
}
public void setGradename(String gradename) {
this.gradename = gradename == null ? null : gradename.trim();
}
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
public String getMakeprople() {
return makeprople;
}
public void setMakeprople(String makeprople) {
this.makeprople = makeprople == null ? null : makeprople.trim();
}
public Integer getMakeid() {
return makeid;
}
public void setMakeid(Integer makeid) {
this.makeid = makeid;
}
public Date getMaketime() {
return maketime;
}
public void setMaketime(Date maketime) {
this.maketime = maketime;
}
public Integer getB1() {
return b1;
}
public void setB1(Integer b1) {
this.b1 = b1;
}
public String getB2() {
return b2;
}
public void setB2(String b2) {
this.b2 = b2 == null ? null : b2.trim();
}
public String getB3() {
return b3;
}
public void setB3(String b3) {
this.b3 = b3 == null ? null : b3.trim();
}
public Integer getState1() {
return state1;
}
public void setState1(Integer state1) {
this.state1 = state1;
}
}
|
package com.smxknife.jmh.demo01;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@State(Scope.Thread)
public class FirstBenchMark {
@Benchmark
public String strPlus() {
String str = "";
for (int i = 0; i < 10000; i++) {
str += i;
}
return str;
}
public static void main(String[] args) throws RunnerException {
Options options = new OptionsBuilder()
.include(FirstBenchMark.class.getSimpleName())
.forks(1)
.warmupIterations(5)
.measurementIterations(5)
.build();
new Runner(options).run();
}
}
|
package org.mvirtual.persistence.dao;
import org.mvirtual.persistence.entity.relation.UserHeritageReview;
import org.mvirtual.persistence.entity.relation.embedded.UserHeritageReviewId;
/**
* DAO interface definition for domain model class UserHeritageReview.
* @author Kiyoshi Murata <kbmurata@gmail.com>
*/
public interface UserHeritageReviewDAO
extends GenericDAO<UserHeritageReview, UserHeritageReviewId>
{
// This interface intentionally left blank
}
|
package javafeatures.module;
public class Customer {
private String name;
private String genre;
public Customer(String name){
this.name = name;
}
}
|
package com.tencent.mm.plugin.sns.ui;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.support.design.widget.BottomSheetBehavior;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager.e;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Base64;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.tencent.mm.c.f;
import com.tencent.mm.model.u;
import com.tencent.mm.plugin.fav.a.v;
import com.tencent.mm.plugin.report.service.h;
import com.tencent.mm.plugin.sns.model.AdLandingPagesProxy;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.i;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.j;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.j.4;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.j.5;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.o;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.AdlandingDummyViewPager;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b$a;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.s;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.z;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.c;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.g;
import com.tencent.mm.plugin.sns.storage.n;
import com.tencent.mm.protocal.c.bqw;
import com.tencent.mm.protocal.c.bqx;
import com.tencent.mm.remoteservice.d;
import com.tencent.mm.sdk.platformtools.ad;
import com.tencent.mm.sdk.platformtools.ag;
import com.tencent.mm.sdk.platformtools.bi;
import com.tencent.mm.sdk.platformtools.x;
import com.tencent.mm.ui.MMActivity;
import com.tencent.mm.ui.ak;
import com.tencent.mm.ui.aq;
import com.tencent.mm.ui.base.p;
import com.tencent.mm.ui.widget.snackbar.a.b;
import com.tencent.mm.ui.y;
import com.tencent.smtt.sdk.TbsMediaPlayer$TbsMediaPlayerListener;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class SnsAdNativeLandingPagesUI extends MMActivity {
public static boolean nSm = false;
String bSZ;
private long cYb = 0;
int egL;
public String fxE;
private boolean gUi = false;
private long grJ = 0;
private int hDj = 0;
private int hDk = 0;
private int hDl = 0;
private int hDm = 0;
private int hmV;
private int hmW;
private ImageView hml;
private d iMQ = new d(ad.getContext());
String ixy;
String ixz;
protected b jKu = new 6(this);
private ImageView jdG;
private int nBk;
int nBm;
private int nEs = 1000;
private int nEt = TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_VIDEO_TRACK_LAGGING;
private int nEu = 250;
private View nHH;
z nHm;
public LinkedList<c> nRW = new LinkedList();
private ImageView nRX;
private ImageView nRY;
private TextView nRZ;
private View nSA;
private LinkedList<View> nSB;
private boolean nSC = true;
private View nSD;
n nSE;
private volatile int nSF = 2;
private BroadcastReceiver nSG = new 1(this);
private BroadcastReceiver nSH = new 9(this);
private b$a nSI = new 12(this);
private e nSJ = new 13(this);
private com.tencent.mm.plugin.sns.model.AdLandingPagesProxy.a nSK = new com.tencent.mm.plugin.sns.model.AdLandingPagesProxy.a() {
public final void at(Object obj) {
SnsAdNativeLandingPagesUI.this.nSz.removeCallbacksAndMessages(null);
SnsAdNativeLandingPagesUI.this.nSz.post(new 1(this, obj));
}
public final void e(int i, int i2, Object obj) {
}
};
private Map<Integer, Fragment> nSL = new HashMap();
private boolean nSM = true;
private boolean nSN = true;
private BroadcastReceiver nSO = new BroadcastReceiver() {
public final void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.intent.action.SCREEN_OFF")) {
x.d("MicroMsg.SnsAdNativeLandingPagesUI", "android.intent.action.SCREEN_OFF");
} else if (intent.getAction().equals("android.intent.action.SCREEN_ON")) {
x.d("MicroMsg.SnsAdNativeLandingPagesUI", "android.intent.action.SCREEN_ON");
SnsAdNativeLandingPagesUI.this.bCI();
}
}
};
private j nSP = null;
private p nSQ = null;
Bundle nSa;
b nSb;
private boolean nSc = false;
String nSd;
String nSe;
private String nSf;
String nSg;
String nSh;
String nSi;
private ImageView nSj;
String nSk;
String nSl;
public Map<String, String> nSn = new HashMap();
g nSo = new g();
boolean nSp = false;
private int nSq = 0;
private boolean nSr = false;
String nSs;
String nSt;
String nSu;
String nSv;
private AdlandingDummyViewPager nSw;
int nSx;
int nSy;
private ag nSz = new ag();
String ntU;
private int nyY;
public String nyk;
String nyl;
String nzH;
int source;
private long startTime;
String uin;
Map<String, String> values;
private class a {
public String ixz;
public String nzH;
public String nzI;
private a() {
this.ixz = "";
this.nzH = "";
this.nzI = "";
}
/* synthetic */ a(SnsAdNativeLandingPagesUI snsAdNativeLandingPagesUI, byte b) {
this();
}
}
static /* synthetic */ void A(SnsAdNativeLandingPagesUI snsAdNativeLandingPagesUI) {
g gVar = snsAdNativeLandingPagesUI.nSo;
gVar.jzg++;
x.i("MicroMsg.SnsAdNativeLandingPagesUI", "doFav snsAdNativeLadingPagesUI");
long j = snsAdNativeLandingPagesUI.getIntent().getExtras().getLong("msg_id", -2147483648L);
String str = null;
if (!bi.oW(snsAdNativeLandingPagesUI.bSZ)) {
str = AdLandingPagesProxy.getInstance().getSnsInfo(snsAdNativeLandingPagesUI.bSZ).bBe();
}
String oV = bi.oV(snsAdNativeLandingPagesUI.getIntent().getStringExtra("prePublishId"));
a bCP = snsAdNativeLandingPagesUI.bCP();
String bCQ = snsAdNativeLandingPagesUI.bCQ();
String bCR = snsAdNativeLandingPagesUI.bCR();
if (bCP != null) {
AdLandingPagesProxy.getInstance().doFavAdlanding(j, str, snsAdNativeLandingPagesUI.source, snsAdNativeLandingPagesUI.ixy, oV, bCP.ixz, bCP.nzH, bCR, 34, snsAdNativeLandingPagesUI.NV(bCP.nzI), bCQ);
} else {
AdLandingPagesProxy.getInstance().doFavAdlanding(j, str, snsAdNativeLandingPagesUI.source, snsAdNativeLandingPagesUI.ixy, oV, snsAdNativeLandingPagesUI.ixz, snsAdNativeLandingPagesUI.nzH, bCR, 34, snsAdNativeLandingPagesUI.NV(snsAdNativeLandingPagesUI.nSk), bCQ);
}
((v) com.tencent.mm.kernel.g.l(v.class)).a(0, snsAdNativeLandingPagesUI, snsAdNativeLandingPagesUI.jKu);
}
static /* synthetic */ void M(SnsAdNativeLandingPagesUI snsAdNativeLandingPagesUI) {
if (snsAdNativeLandingPagesUI.nRW != null) {
Iterator it = snsAdNativeLandingPagesUI.nRW.iterator();
while (it.hasNext()) {
com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b bVar = (com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b) snsAdNativeLandingPagesUI.nSL.get(Integer.valueOf(((c) it.next()).id));
if (bVar != null) {
bVar.nHp = true;
}
}
((com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b) snsAdNativeLandingPagesUI.nSL.get(Integer.valueOf(((c) snsAdNativeLandingPagesUI.nRW.getFirst()).id))).bAw();
}
}
static /* synthetic */ void O(SnsAdNativeLandingPagesUI snsAdNativeLandingPagesUI) {
for (i iVar : snsAdNativeLandingPagesUI.bCH()) {
if (iVar instanceof com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.a) {
((com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.a) iVar).bzy();
}
}
}
static /* synthetic */ void bCS() {
}
static /* synthetic */ void f(SnsAdNativeLandingPagesUI snsAdNativeLandingPagesUI) {
if (snsAdNativeLandingPagesUI.nSF == 0) {
try {
Map hashMap = new HashMap();
hashMap.put("startIndex", Integer.valueOf(snsAdNativeLandingPagesUI.nSq));
((i) snsAdNativeLandingPagesUI.bCH().get(0)).N(hashMap);
} catch (Exception e) {
}
snsAdNativeLandingPagesUI.bCO();
if (snsAdNativeLandingPagesUI.nSC && snsAdNativeLandingPagesUI.nSD != null && snsAdNativeLandingPagesUI.nSc) {
snsAdNativeLandingPagesUI.nSC = false;
snsAdNativeLandingPagesUI.hDj = snsAdNativeLandingPagesUI.getIntent().getIntExtra("img_gallery_top", 0);
snsAdNativeLandingPagesUI.hDk = snsAdNativeLandingPagesUI.getIntent().getIntExtra("img_gallery_left", 0);
snsAdNativeLandingPagesUI.hDl = snsAdNativeLandingPagesUI.getIntent().getIntExtra("img_gallery_width", 0);
snsAdNativeLandingPagesUI.hDm = snsAdNativeLandingPagesUI.getIntent().getIntExtra("img_gallery_height", 0);
snsAdNativeLandingPagesUI.nSb.u(snsAdNativeLandingPagesUI.hDk, snsAdNativeLandingPagesUI.hDj, snsAdNativeLandingPagesUI.hDl, snsAdNativeLandingPagesUI.hDm);
snsAdNativeLandingPagesUI.hml.setVisibility(8);
snsAdNativeLandingPagesUI.nRX.setVisibility(8);
b bVar = snsAdNativeLandingPagesUI.nSb;
View view = snsAdNativeLandingPagesUI.nSD;
LinkedList linkedList = snsAdNativeLandingPagesUI.nSB;
View view2 = snsAdNativeLandingPagesUI.jdG;
snsAdNativeLandingPagesUI.isFullScreen();
bVar.a(view, linkedList, view2, new 3(snsAdNativeLandingPagesUI));
return;
}
snsAdNativeLandingPagesUI.nHH.post(new 4(snsAdNativeLandingPagesUI));
}
}
static /* synthetic */ void n(SnsAdNativeLandingPagesUI snsAdNativeLandingPagesUI) {
com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.c cVar;
snsAdNativeLandingPagesUI.bCF();
com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.c cVar2 = (com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.c) snsAdNativeLandingPagesUI.nSw.getAdapter();
if (cVar2 == null) {
cVar2 = new com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.c(snsAdNativeLandingPagesUI.getSupportFragmentManager(), new ArrayList());
snsAdNativeLandingPagesUI.nSw.setAdapter(cVar2);
cVar = cVar2;
} else {
cVar = cVar2;
}
int i = 0;
while (i < snsAdNativeLandingPagesUI.nRW.size()) {
c cVar3 = (c) snsAdNativeLandingPagesUI.nRW.get(i);
if (cVar3.nBi) {
x.i("MicroMsg.SnsAdNativeLandingPagesUI", "loadLandingPages load %d", new Object[]{Integer.valueOf(i)});
Fragment fragment = (Fragment) snsAdNativeLandingPagesUI.nSL.get(Integer.valueOf(cVar3.id));
if (fragment == null) {
fragment = com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b.a(cVar3, snsAdNativeLandingPagesUI.nSw, snsAdNativeLandingPagesUI.nHm, i == snsAdNativeLandingPagesUI.nRW.size() + -1, i == 0 ? snsAdNativeLandingPagesUI.nSI : null, snsAdNativeLandingPagesUI.nSc, snsAdNativeLandingPagesUI.bCK());
snsAdNativeLandingPagesUI.nSL.put(Integer.valueOf(cVar3.id), fragment);
} else {
((com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b) fragment).a(cVar3);
}
if (fragment != null) {
cVar.a(fragment, i);
}
}
i++;
}
cVar.notifyDataSetChanged();
snsAdNativeLandingPagesUI.nSw.setOffscreenPageLimit(snsAdNativeLandingPagesUI.nRW.size());
}
static /* synthetic */ void o(SnsAdNativeLandingPagesUI snsAdNativeLandingPagesUI) {
if (snsAdNativeLandingPagesUI.nyY != 2) {
h hVar = h.mEJ;
Object[] objArr = new Object[7];
objArr[0] = com.tencent.mm.plugin.sns.data.i.eF(com.tencent.mm.plugin.sns.data.i.LP(snsAdNativeLandingPagesUI.nSo.bSZ));
objArr[1] = snsAdNativeLandingPagesUI.ntU == null ? "" : snsAdNativeLandingPagesUI.ntU;
objArr[2] = Integer.valueOf(snsAdNativeLandingPagesUI.nSo.nIF);
objArr[3] = Integer.valueOf(snsAdNativeLandingPagesUI.nSo.nIG);
objArr[4] = Long.valueOf(snsAdNativeLandingPagesUI.cYb);
objArr[5] = Integer.valueOf(snsAdNativeLandingPagesUI.nBk);
objArr[6] = snsAdNativeLandingPagesUI.nSo.nIP;
hVar.h(14655, objArr);
}
}
static /* synthetic */ void y(SnsAdNativeLandingPagesUI snsAdNativeLandingPagesUI) {
x.i("MicroMsg.SnsAdNativeLandingPagesUI", "doTransimt snsAdNativeLadingPagesUI");
g gVar = snsAdNativeLandingPagesUI.nSo;
gVar.iVN++;
String bCQ = snsAdNativeLandingPagesUI.bCQ();
String bCR = snsAdNativeLandingPagesUI.bCR();
a bCP = snsAdNativeLandingPagesUI.bCP();
if (bCP != null) {
AdLandingPagesProxy.getInstance().doTransimt(snsAdNativeLandingPagesUI, bCR, bCP.ixz, snsAdNativeLandingPagesUI.NV(bCP.nzI), bCP.nzH, snsAdNativeLandingPagesUI.ixy, bCQ);
return;
}
AdLandingPagesProxy.getInstance().doTransimt(snsAdNativeLandingPagesUI, bCR, snsAdNativeLandingPagesUI.ixz, snsAdNativeLandingPagesUI.NV(snsAdNativeLandingPagesUI.nSk), snsAdNativeLandingPagesUI.nzH, snsAdNativeLandingPagesUI.ixy, bCQ);
}
static /* synthetic */ void z(SnsAdNativeLandingPagesUI snsAdNativeLandingPagesUI) {
x.i("MicroMsg.SnsAdNativeLandingPagesUI", "doShareToTimeline snsAdNativeLadingPagesUI");
g gVar = snsAdNativeLandingPagesUI.nSo;
gVar.iVO++;
String str = snsAdNativeLandingPagesUI.ixy;
a bCP = snsAdNativeLandingPagesUI.bCP();
if (str == null || str.length() == 0) {
x.e("MicroMsg.SnsAdNativeLandingPagesUI", "doTimeline fail, link is null");
return;
}
int i = snsAdNativeLandingPagesUI.hDl;
x.i("MicroMsg.SnsAdNativeLandingPagesUI", "doTimeline, init intent");
Intent intent = new Intent();
intent.putExtra("Ksnsupload_width", i);
intent.putExtra("Ksnsupload_height", i);
intent.putExtra("Ksnsupload_link", snsAdNativeLandingPagesUI.ixy);
if (bCP != null) {
intent.putExtra("Ksnsupload_title", bCP.ixz);
intent.putExtra("Ksnsupload_imgurl", snsAdNativeLandingPagesUI.NV(bCP.nzI));
} else {
intent.putExtra("Ksnsupload_title", snsAdNativeLandingPagesUI.ixz);
intent.putExtra("Ksnsupload_imgurl", snsAdNativeLandingPagesUI.NV(snsAdNativeLandingPagesUI.nSk));
}
intent.putExtra("Ksnsupload_canvas_info", snsAdNativeLandingPagesUI.bCR());
intent.putExtra("Ksnsupload_contentattribute", 0);
intent.putExtra("Ksnsupload_source", 1);
intent.putExtra("Ksnsupload_type", 1);
str = snsAdNativeLandingPagesUI.bCQ();
if (!bi.oW(str)) {
intent.putExtra("key_snsad_statextstr", str);
}
x.i("MicroMsg.SnsAdNativeLandingPagesUI", "doTimeline, start activity");
intent.putExtra("need_result", true);
str = "sns_";
if (snsAdNativeLandingPagesUI.source == 1 || snsAdNativeLandingPagesUI.source == 2 || snsAdNativeLandingPagesUI.source == 3 || snsAdNativeLandingPagesUI.source == 4 || snsAdNativeLandingPagesUI.source == 9 || snsAdNativeLandingPagesUI.source == 10 || snsAdNativeLandingPagesUI.source == 11) {
str = "sns_" + snsAdNativeLandingPagesUI.bSZ;
} else if (snsAdNativeLandingPagesUI.source == 5 || snsAdNativeLandingPagesUI.source == 6) {
str = "msg_" + snsAdNativeLandingPagesUI.getIntent().getExtras().getLong("msg_id", -2147483648L);
} else if (snsAdNativeLandingPagesUI.source == 7) {
str = "fav_" + snsAdNativeLandingPagesUI.getIntent().getExtras().getString("sns_landing_favid");
}
String ic = u.ic(str);
u.Hx().v(ic, true).p("prePublishId", str);
intent.putExtra("reportSessionId", ic);
com.tencent.mm.bg.d.a(snsAdNativeLandingPagesUI.mController.tml, "sns", ".ui.SnsUploadUI", intent, 1, false);
}
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
this.startTime = System.currentTimeMillis();
this.cYb = System.currentTimeMillis();
this.nSo.cYb = this.cYb;
com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.b.a aVar = new com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.b.a(this);
bCI();
int[] ee = com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.ad.ee(this);
this.hmV = ee[0];
this.hmW = ee[1];
this.nSa = bundle;
this.mController.hideTitleView();
getWindow().addFlags(128);
AdLandingPagesProxy.create(this.iMQ);
this.iMQ.K(new 15(this));
this.source = getIntent().getIntExtra("sns_landig_pages_from_source", 1);
this.nBk = getIntent().getIntExtra("sns_landig_pages_origin_from_source", 0);
this.nSd = getIntent().getStringExtra("sns_landing_pages_xml");
String stringExtra = getIntent().getStringExtra("sns_landing_pages_too_large_xml_path");
if (bi.oW(this.nSd) && !bi.oW(stringExtra)) {
this.nSd = com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.ad.Nd(stringExtra);
}
if (bi.oW(this.nSd)) {
finish();
return;
}
this.nSd = this.nSd.replaceAll("</*RecXml[\\s|\\S]*?>", "");
this.nSo.ntX = getIntent().getStringExtra("sns_landing_pages_expid");
this.nSe = getIntent().getStringExtra("sns_landing_pages_xml_prefix");
this.bSZ = getIntent().getStringExtra("sns_landing_pages_share_sns_id");
this.nSl = getIntent().getStringExtra("sns_landing_pages_rawSnsId");
this.ntU = getIntent().getStringExtra("sns_landing_pages_ux_info");
this.nyk = getIntent().getStringExtra("sns_landing_pages_aid");
this.fxE = getIntent().getStringExtra("sns_landing_pages_traceid");
Object stringExtra2 = getIntent().getStringExtra("sns_landing_pages_search_extra");
g gVar = this.nSo;
if (!TextUtils.isEmpty(stringExtra2)) {
if (gVar.extra.length() > 0) {
gVar.extra += "&";
}
gVar.extra += "searchextra=" + URLEncoder.encode(stringExtra2);
}
stringExtra2 = getIntent().getStringExtra("sns_landing_pages_extra");
gVar = this.nSo;
if (!TextUtils.isEmpty(stringExtra2)) {
gVar.extra += "&extra1=" + URLEncoder.encode(stringExtra2);
}
nSm = getIntent().getBooleanExtra("sns_landing_is_native_sight_ad", false);
this.nyY = getIntent().getIntExtra("sns_landing_pages_rec_src", 0);
this.nSq = getIntent().getIntExtra("sns_landing_pages_from_outer_index", 0);
this.nSf = getIntent().getStringExtra("sns_landing_pages_ad_info");
this.nSc = getIntent().getBooleanExtra("sns_landing_pages_need_enter_and_exit_animation", false);
if (this.nSc) {
this.nSo.nIF = 0;
this.nSo.cXB = 0;
} else {
this.nSo.nIF = 1;
this.nSo.cXB = 1;
}
this.nSo.nIG = this.source;
this.nSo.nIH = 0;
this.nSo.nII = 0;
this.nSo.nIJ = 1;
this.nSo.nIK = 0;
this.nSo.nBk = this.nBk;
if (this.nSe == null || "".equals(this.nSd)) {
this.nSe = "adxml";
}
if (bi.oW(this.nSd) || bi.oW(this.nSe)) {
x.e("MicroMsg.SnsAdNativeLandingPagesUI", "landingPagesXml is " + this.nSd + ",landingPagesXmlPrex is " + this.nSe);
return;
}
this.values = f.z(this.nSd, this.nSe);
this.nSo.nIP = bi.aG((String) this.values.get("." + this.nSe + ".adCanvasInfo.canvasId"), "");
}
protected final int getForceOrientation() {
return 1;
}
protected void onDestroy() {
getWindow().clearFlags(128);
if (this.gUi) {
x.i("MicroMsg.SnsAdNativeLandingPagesUI", "the SnsAdNativeLadingPagesUI is destroy");
if (!this.nSp) {
bCD();
xP();
}
}
unregisterReceiver(this.nSO);
super.onDestroy();
}
private void bCD() {
for (Fragment fragment : ((com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.c) this.nSw.getAdapter()).nB) {
com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b bVar = (com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b) fragment;
if (bVar.nHl != null && bVar.getUserVisibleHint()) {
bVar.nHl.bAo();
}
}
}
private void xP() {
int i;
Iterator it;
List<i> bCG = bCG();
this.grJ += System.currentTimeMillis() - this.startTime;
this.nSo.nIM = (int) this.grJ;
g gVar = this.nSo;
if (this.nRW == null) {
i = 0;
} else {
it = this.nRW.iterator();
i = 0;
while (it.hasNext()) {
i = ((c) it.next()).nIi.size() + i;
}
}
gVar.nIL = i;
g gVar2 = this.nSo;
JSONArray jSONArray = new JSONArray();
for (i iVar : bCG) {
if (!iVar.bzT().nBj) {
JSONObject jSONObject = new JSONObject();
if (!iVar.r(jSONArray)) {
if (iVar.aa(jSONObject)) {
jSONArray.put(jSONObject);
}
if (iVar instanceof o) {
it = ((o) iVar).bAe().iterator();
while (it.hasNext()) {
jSONArray.put((JSONObject) it.next());
}
}
}
}
}
gVar2.nIN = jSONArray.toString();
x.d("MicroMsg.AdLandingPagesReportInfo", "componentsStatStr:%s", new Object[]{gVar2.nIN});
if (!bi.oW(gVar2.nIN)) {
try {
gVar2.nIN = URLEncoder.encode(gVar2.nIN, "UTF-8");
} catch (UnsupportedEncodingException e) {
x.e("MicroMsg.AdLandingPagesReportInfo", "not support encode " + e.toString());
}
}
String bAC = this.nSo.bAC();
if (this.nBm == 2) {
AdLandingPagesProxy.getInstance().doCgiReportCanvasBrowseInfo(15041, bAC);
x.i("MicroMsg.SnsAdNativeLandingPagesUI", "post cgi stat 15041 data: " + bAC);
} else if (AdLandingPagesProxy.getInstance().isRecExpAd(this.nSo.bSZ)) {
h.mEJ.k(14650, bAC);
x.i("MicroMsg.SnsAdNativeLandingPagesUI", "post kv stat 14650 data: " + bAC);
} else {
h.mEJ.k(13387, bAC);
x.i("MicroMsg.SnsAdNativeLandingPagesUI", "post kv stat 13387 data: " + bAC);
}
}
protected void onResume() {
super.onResume();
x.i("MicroMsg.SnsAdNativeLandingPagesUI", "onResume");
bCI();
android.support.v4.content.d.O(this).a(this.nSG, new IntentFilter("com.tencent.mm.adlanding.video_progressbar_change"));
android.support.v4.content.d.O(this).a(this.nSH, new IntentFilter("com.tencent.mm.adlanding.set_uioption"));
if (this.gUi) {
this.startTime = System.currentTimeMillis();
}
registerReceiver(this.nSO, new IntentFilter("android.intent.action.SCREEN_ON"));
if (this.nSr) {
io(false);
}
}
protected void onPause() {
super.onPause();
if (this.gUi) {
this.grJ += System.currentTimeMillis() - this.startTime;
}
android.support.v4.content.d.O(this).unregisterReceiver(this.nSG);
android.support.v4.content.d.O(this).unregisterReceiver(this.nSH);
if (this.nSP != null) {
this.nSP.bzW();
}
}
public void onSwipeBack() {
this.nSo.cXB = 2;
g gVar = this.nSo;
gVar.nIK++;
super.onSwipeBack();
}
final void bCE() {
if (bi.oW(this.nSf) && !bi.oW(this.nyl)) {
this.nSf = String.format("<ADInfo><adCanvasExt>%s</adCanvasExt></ADInfo>", new Object[]{this.nyl});
}
if (!bi.oW(this.nSf)) {
String aG;
String str = "ADInfo";
Map z = f.z(this.nSf, str);
this.ntU = bi.aG((String) z.get("." + str + ".uxInfo"), "");
this.nSo.ntU = this.ntU;
this.nyk = bi.aG((String) z.get("." + str + ".session_data.aid"), "");
this.fxE = bi.aG((String) z.get("." + str + ".session_data.trace_id"), "");
Map hashMap = new HashMap();
str = "." + str + ".adCanvasExt.adCardItemList.cardItem";
int i = 0;
while (true) {
String str2;
if (i > 0) {
str2 = str + i;
} else {
str2 = str;
}
if (!z.containsKey(str2 + ".cardTpId")) {
break;
}
String aG2 = bi.aG((String) z.get(str2 + ".cardTpId"), "");
aG = bi.aG((String) z.get(str2 + ".cardExt"), "");
if (!(bi.oW(aG2) || bi.oW(aG))) {
hashMap.put(aG2, aG);
}
i++;
}
this.nSn = hashMap;
aG = com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.e.o(this.nSd, hashMap);
if (!bi.oW(aG)) {
this.nSd = aG;
}
if (!bi.oW(this.nyk)) {
if (this.nSd.contains("<originAid>")) {
this.nSd = this.nSd.replaceFirst("<originAid>[\\s\\S]*</originAid>", "<originAid>" + this.nyk + "</originAid>");
} else {
this.nSd = this.nSd.replace("<" + this.nSe + ">", "<" + this.nSe + "><originAid>" + this.nyk + "</originAid>");
}
}
if (!bi.oW(this.fxE)) {
if (this.nSd.contains("<originTraceId>")) {
this.nSd = this.nSd.replaceFirst("<originTraceId>[\\s\\S]*</originTraceId>", "<originTraceId>" + this.fxE + "</originTraceId>");
} else {
this.nSd = this.nSd.replace("<" + this.nSe + ">", "<" + this.nSe + "><originTraceId>" + this.fxE + "</originTraceId>");
}
}
if (!bi.oW(this.ntU)) {
if (this.nSd.contains("<originUxInfo>")) {
this.nSd = this.nSd.replaceFirst("<originUxInfo>[\\s\\S]*</originUxInfo>", "<originUxInfo>" + this.ntU + "</originUxInfo>");
} else {
this.nSd = this.nSd.replace("<" + this.nSe + ">", "<" + this.nSe + "><originUxInfo>" + this.ntU + "</originUxInfo>");
}
}
}
}
private void bCF() {
if (this.nRW != null) {
Iterator it = this.nRW.iterator();
while (it.hasNext()) {
List<s> list = ((c) it.next()).nIi;
if (list != null) {
for (s sVar : list) {
sVar.wL(this.nBk == 0 ? this.source : this.nBk);
sVar.ii(nSm);
sVar.MV(this.ntU);
sVar.MW(this.uin);
sVar.wM(this.nBm);
}
}
}
}
}
private List<i> bCG() {
List<i> arrayList = new ArrayList();
for (Fragment fragment : ((com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.c) this.nSw.getAdapter()).nB) {
arrayList.addAll(((com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b) fragment).bAu());
}
return arrayList;
}
private List<i> bCH() {
List<i> arrayList = new ArrayList();
arrayList.addAll(((com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b) this.nSL.get(Integer.valueOf(((c) this.nRW.getFirst()).id))).bAu());
return arrayList;
}
@TargetApi(16)
protected final void initView() {
LayoutParams layoutParams;
boolean z = false;
super.initView();
this.nHH = findViewById(com.tencent.mm.plugin.sns.i.f.root);
this.nSw = (AdlandingDummyViewPager) findViewById(com.tencent.mm.plugin.sns.i.f.vertical_viewpager);
this.nSA = findViewById(com.tencent.mm.plugin.sns.i.f.menu_container);
this.nSw.nHa.add(this.nSJ);
if (this.nBm == 2 && !bCL()) {
layoutParams = (LayoutParams) this.nSw.getLayoutParams();
layoutParams.setMargins(0, 0, 0, aq.gs(this));
this.nSw.setLayoutParams(layoutParams);
}
if (ak.gw(this.mController.tml)) {
layoutParams = (LayoutParams) this.nSA.getLayoutParams();
layoutParams.setMargins(layoutParams.leftMargin, layoutParams.topMargin + ak.gv(this.mController.tml), layoutParams.rightMargin, layoutParams.bottomMargin);
this.nSA.setLayoutParams(layoutParams);
layoutParams = (LayoutParams) this.nSw.getLayoutParams();
layoutParams.setMargins(layoutParams.leftMargin, layoutParams.topMargin + ak.gv(this.mController.tml), layoutParams.rightMargin, layoutParams.bottomMargin);
this.nSw.setLayoutParams(layoutParams);
}
this.jdG = (ImageView) findViewById(com.tencent.mm.plugin.sns.i.f.gallery_bg);
this.nRY = (ImageView) findViewById(com.tencent.mm.plugin.sns.i.f.sns_ad_native_landing_pages_close_mask_img);
this.hml = (ImageView) findViewById(com.tencent.mm.plugin.sns.i.f.sns_ad_native_landing_pages_close_img);
this.hml.setOnClickListener(new OnClickListener() {
public final void onClick(View view) {
if (SnsAdNativeLandingPagesUI.this.mController.tmG == 1) {
SnsAdNativeLandingPagesUI.this.YC();
}
SnsAdNativeLandingPagesUI.this.ayH();
}
});
this.nRX = (ImageView) findViewById(com.tencent.mm.plugin.sns.i.f.sns_ad_native_landing_pages_more_img);
int i = com.tencent.mm.plugin.sns.i.c.white;
if (!bCL()) {
int color = getResources().getColor(com.tencent.mm.plugin.sns.i.c.black);
if (this.nRW == null || this.nRW.size() <= 0 || bi.oW(((c) this.nRW.getFirst()).fpc)) {
i = color;
} else {
i = Color.parseColor(((c) this.nRW.getFirst()).fpc);
}
this.nRY.setBackgroundColor(i);
i = com.tencent.mm.plugin.sns.i.c.black;
}
Drawable drawable = this.hml.getDrawable();
if (drawable != null) {
android.support.v4.b.a.a.a(drawable, android.support.v4.content.a.g(this, i));
this.hml.setImageDrawable(drawable);
}
drawable = this.nRX.getDrawable();
if (drawable != null) {
android.support.v4.b.a.a.a(drawable, android.support.v4.content.a.g(this, i));
this.nRX.setImageDrawable(drawable);
}
this.nRZ = (TextView) findViewById(com.tencent.mm.plugin.sns.i.f.sns_ad_native_landing_pages_right_bar_title);
if (bCM() && !bCN() && this.nBm == 2) {
this.nRX.setVisibility(8);
this.nRZ.setVisibility(0);
this.nRZ.setText(this.nSg);
this.nRZ.setOnClickListener(new 17(this));
} else if (bCJ()) {
this.nRX.setOnClickListener(new 18(this));
} else {
this.nRX.setVisibility(8);
}
this.nSj = (ImageView) findViewById(com.tencent.mm.plugin.sns.i.f.sns_native_landing_first_screen_next_img);
if (this.nRW == null || this.nRW.size() == 0) {
x.e("MicroMsg.SnsAdNativeLandingPagesUI", "landingPages is null");
return;
}
com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.c cVar;
bCF();
com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.c cVar2 = (com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.c) this.nSw.getAdapter();
if (cVar2 == null) {
cVar2 = new com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.c(getSupportFragmentManager(), new ArrayList());
this.nSw.setAdapter(cVar2);
cVar = cVar2;
} else {
cVar = cVar2;
}
int i2 = 0;
while (i2 < this.nRW.size()) {
c cVar3 = (c) this.nRW.get(i2);
if (cVar3.nBi) {
x.i("MicroMsg.SnsAdNativeLandingPagesUI", "loadFirstPage load %d", new Object[]{Integer.valueOf(i2)});
Fragment fragment = (Fragment) this.nSL.get(Integer.valueOf(cVar3.id));
if (fragment == null) {
AdlandingDummyViewPager adlandingDummyViewPager = this.nSw;
z zVar = this.nHm;
if (i2 == this.nRW.size() - 1) {
z = true;
}
fragment = com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b.a(cVar3, adlandingDummyViewPager, zVar, z, i2 == 0 ? this.nSI : null, this.nSc, bCK());
this.nSL.put(Integer.valueOf(cVar3.id), fragment);
} else {
((com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b) fragment).a(cVar3);
}
if (fragment != null) {
cVar.a(fragment, i2);
}
cVar.notifyDataSetChanged();
this.nSw.setOffscreenPageLimit(this.nRW.size());
this.nSb = new b(this.mController.tml);
this.nHH.addOnLayoutChangeListener(new 2(this));
}
i2++;
}
cVar.notifyDataSetChanged();
this.nSw.setOffscreenPageLimit(this.nRW.size());
this.nSb = new b(this.mController.tml);
this.nHH.addOnLayoutChangeListener(new 2(this));
}
private boolean isFullScreen() {
boolean z;
if (this.nRW != null) {
Iterator it = this.nRW.iterator();
z = false;
while (it.hasNext()) {
Iterator it2 = ((c) it.next()).nIi.iterator();
while (it2.hasNext()) {
if (((s) it2.next()).type == 82) {
z = true;
break;
}
}
}
}
z = false;
if (z) {
return false;
}
return true;
}
private void bCI() {
if (bCL()) {
com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.ad.I(this);
return;
}
int i;
if (VERSION.SDK_INT >= 21) {
int color = getResources().getColor(com.tencent.mm.plugin.sns.i.c.white);
if (this.nRW == null || this.nRW.size() <= 0 || bi.oW(((c) this.nRW.getFirst()).fpc)) {
i = color;
} else {
i = Color.parseColor(((c) this.nRW.getFirst()).fpc);
}
getWindow().addFlags(Integer.MIN_VALUE);
getWindow().setStatusBarColor(i);
}
i = getWindow().getDecorView().getSystemUiVisibility();
if (VERSION.SDK_INT >= 16) {
i &= -1543;
}
if (VERSION.SDK_INT >= 23) {
i |= 8192;
}
getWindow().getDecorView().setSystemUiVisibility(i);
}
protected final int getLayoutId() {
return com.tencent.mm.plugin.sns.i.g.sns_ad_native_landing_pages_ui;
}
private boolean bCJ() {
if (this.nSx == 0 || (this.nSx & 4) == 0 || (this.nSx & 2) == 0) {
return true;
}
if ((bCN() && this.nBm == 2) || (this.nSx & 1) == 0) {
return true;
}
return false;
}
private boolean bCK() {
return (this.nSx & 8) == 0;
}
private boolean bCL() {
return this.nSy == 0;
}
private boolean bCM() {
return (bi.oW(this.nSg) || bi.oW(this.nSh)) ? false : true;
}
private boolean bCN() {
return (this.nSx & 16) == 0;
}
private void bCO() {
Iterator it;
List<i> bCH = bCH();
LinkedList linkedList = new LinkedList();
for (i view : bCH) {
linkedList.add((View) view.getView().getParent());
}
this.nSD = null;
if (this.nSB != null) {
this.nSB.clear();
}
if (!linkedList.isEmpty()) {
this.nSD = (View) linkedList.removeFirst();
if (this.nSB == null) {
this.nSB = new LinkedList();
}
this.nSB.clear();
int height = this.nSD.getHeight();
it = linkedList.iterator();
int i = height;
while (it.hasNext()) {
View view2 = (View) it.next();
i += view2.getHeight();
this.nSB.add(view2);
if (i >= this.hmW) {
return;
}
}
}
}
public final void ayH() {
bCD();
xP();
this.nSp = true;
if (this.nSc) {
try {
((i) bCH().get(0)).bzV();
} catch (Exception e) {
}
this.nSw.k(0, false);
RecyclerView bAt = ((com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b) this.nSL.get(Integer.valueOf(((c) this.nRW.getFirst()).id))).bAt();
if (bAt != null) {
((LinearLayoutManager) bAt.getLayoutManager()).Q(0, 0);
}
bCD();
if (this.nSD != null) {
this.nSD.postDelayed(new 5(this), 10);
return;
}
finish();
overridePendingTransition(0, 0);
return;
}
finish();
}
public void onBackPressed() {
ayH();
}
private a bCP() {
com.tencent.mm.plugin.sns.storage.b bVar = new com.tencent.mm.plugin.sns.storage.b(this.nSd);
if (bVar.bzt()) {
int adVoteIndex = AdLandingPagesProxy.getInstance().getAdVoteIndex(bVar.nzy.nzF, this.ntU, this.uin);
if (adVoteIndex > 0 && adVoteIndex <= bVar.nzy.nzG.size()) {
com.tencent.mm.plugin.sns.storage.b.f fVar = (com.tencent.mm.plugin.sns.storage.b.f) bVar.nzy.nzG.get(adVoteIndex - 1);
a aVar = new a(this, (byte) 0);
if (bi.oW(fVar.ixz)) {
aVar.ixz = this.ixz;
} else {
aVar.ixz = fVar.ixz;
}
if (bi.oW(fVar.nzH)) {
aVar.nzH = this.nzH;
} else {
aVar.nzH = fVar.nzH;
}
if (bi.oW(fVar.nzI)) {
aVar.nzI = this.nSk;
} else {
aVar.nzI = fVar.nzI;
}
return aVar;
}
}
return null;
}
private String NV(String str) {
String aG = bi.aG((String) this.values.get("." + this.nSe + ".adCanvasInfo.shareThumbUrl"), "");
if (bi.oW(aG)) {
return str;
}
return aG;
}
private String bCQ() {
bqw bqw = new bqw();
bqw.soW = new bqx();
bqw.soW.spa = this.nSo.ntU;
bqw.soW.soZ = this.nSo.bSZ;
bqw.soW.egL = this.egL;
try {
return Base64.encodeToString(bqw.toByteArray(), 2);
} catch (Exception e) {
return "";
}
}
private String bCR() {
return this.nSd.replaceAll("(?s)<adCanvasInfoLeft[^>]*>.*?</adCanvasInfoLeft>", "").replaceAll("(?s)<adCanvasInfoRight[^>]*>.*?</adCanvasInfoRight>", "");
}
protected void onActivityResult(int i, int i2, Intent intent) {
if (i == 1) {
if (i2 == -1) {
com.tencent.mm.ui.base.h.bA(this.mController.tml, this.mController.tml.getString(com.tencent.mm.plugin.sns.i.j.app_shared));
}
} else if (i == 2) {
if (intent.getBooleanExtra("kfavorite", false)) {
((v) com.tencent.mm.kernel.g.l(v.class)).a(AdLandingPagesProxy.getInstance().doFav(intent, 42), this, this.jKu);
}
} else if (i == com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.x.nFJ) {
try {
String stringExtra = intent.getStringExtra("KComponentCid");
for (i iVar : bCG()) {
if (iVar.bzU().equals(stringExtra)) {
com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.x xVar = (com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.x) iVar;
int intExtra = intent.getIntExtra("KStreamVideoPlayCount", 0);
int intExtra2 = intent.getIntExtra("KStreamVideoPlayCompleteCount", 0);
int intExtra3 = intent.getIntExtra("KStreamVideoTotalPlayTimeInMs", 0);
xVar.njo = intExtra + xVar.njo;
xVar.njp += intExtra2;
xVar.njq += intExtra3;
break;
}
}
} catch (Exception e) {
}
}
super.onActivityResult(i, i2, intent);
}
public final void onKeyboardStateChanged() {
super.onKeyboardStateChanged();
if (this.nSw != null) {
this.nSw.postDelayed(new Runnable() {
public final void run() {
if (SnsAdNativeLandingPagesUI.this.mController.tmG != 1) {
SnsAdNativeLandingPagesUI.this.bCI();
} else {
com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.ad.J(SnsAdNativeLandingPagesUI.this);
}
ArrayList arrayList = new ArrayList();
for (Fragment fragment : ((com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.c) SnsAdNativeLandingPagesUI.this.nSw.getAdapter()).nB) {
com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b bVar = (com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.a.b) fragment;
int i = SnsAdNativeLandingPagesUI.this.mController.tmG;
bVar.bAq();
}
}
}, 500);
}
}
public final void io(boolean z) {
if (z && this.nBm == 1) {
AdLandingPagesProxy.getInstance().doDynamicUpdateScene(this.nSs, this.nSt, this.nSu, this.nSK);
}
if (this.nBm == 2 && !bi.oW(this.nSv)) {
AdLandingPagesProxy.getInstance().doSearchDynamicUpdateScene(this.nSv, this.nSK);
}
this.nSr = true;
}
public final void a(s sVar, String str, String str2, String str3, boolean z, boolean z2, boolean z3) {
if (this.nSP == null || z3) {
final boolean z4 = z3;
AnonymousClass10 anonymousClass10 = new com.tencent.mm.plugin.sns.model.AdLandingPagesProxy.a() {
public final void at(Object obj) {
}
public final void e(int i, int i2, Object obj) {
SnsAdNativeLandingPagesUI.this.io(false);
if (z4) {
if (SnsAdNativeLandingPagesUI.this.nSP != null) {
SnsAdNativeLandingPagesUI.this.nSP.bzW();
}
if (SnsAdNativeLandingPagesUI.this.nSQ != null) {
SnsAdNativeLandingPagesUI.this.nSQ.dismiss();
SnsAdNativeLandingPagesUI.this.nSQ = null;
}
}
}
};
if (!z3) {
int i;
ActionBarActivity actionBarActivity = this.mController.tml;
ViewGroup linearLayout = new LinearLayout(this.mController.tml);
y.gq(this.mController.tml);
if (bi.oW(sVar.nBf)) {
i = -1;
} else {
i = Color.parseColor(sVar.nBf);
}
i a = am.a(actionBarActivity, sVar, linearLayout, i);
this.nSP = new j(this.mController.tml, a, str, str2, str3, z, z2);
View view = a.getView();
this.nSP.nDD = new 11(this, view);
j jVar = this.nSP;
if (!(jVar.hyK == null || jVar.nDy == null)) {
jVar.nDy.getWindow().setFlags(8, 8);
jVar.nDy.getWindow().addFlags(131200);
if (jVar.nDD != null) {
jVar.nDy.setOnDismissListener(new 4(jVar));
jVar.nDy.setOnCancelListener(new 5(jVar));
}
jVar.nDy.setContentView(jVar.hyK);
BottomSheetBehavior.h((View) jVar.hyK.getParent()).q(com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.ad.ee(jVar.mContext)[1]);
jVar.nDy.show();
}
}
if (!bi.oW(str)) {
AdLandingPagesProxy.getInstance().doFavOfficialItemScene(str, anonymousClass10);
if (z3) {
this.nSQ = com.tencent.mm.ui.base.h.a(this, getString(com.tencent.mm.plugin.sns.i.j.sns_loading), false, null);
return;
}
return;
}
return;
}
x.w("MicroMsg.SnsAdNativeLandingPagesUI", "bottom sheet appear several times");
this.nSP.bzW();
if (this.nSQ != null) {
this.nSQ.dismiss();
this.nSQ = null;
}
}
public final void u(Context context, String str, String str2) {
Intent intent = new Intent();
intent.putExtra("sns_landig_pages_from_source", 14);
intent.putExtra("sns_landig_pages_origin_from_source", this.nBk == 0 ? this.source : this.nBk);
intent.putExtra("sns_landing_pages_canvasid", str);
intent.putExtra("sns_landing_pages_canvas_ext", str2);
intent.putExtra("sns_landing_pages_need_enter_and_exit_animation", false);
intent.putExtra("sns_landing_pages_no_store", 1);
String stringExtra = ((Activity) context).getIntent().getStringExtra("sns_landing_pages_sessionId");
String stringExtra2 = ((Activity) context).getIntent().getStringExtra("sns_landing_pages_ad_buffer");
if (!bi.oW(stringExtra)) {
String valueOf = String.valueOf(System.currentTimeMillis() / 1000);
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("sessionId", valueOf);
jSONObject.put("cid", "");
jSONObject.put("adBuffer", !bi.oW(stringExtra2) ? stringExtra2 : "");
jSONObject.put("preSessionId", stringExtra);
} catch (Exception e) {
}
intent.putExtra("sns_landing_pages_search_extra", jSONObject.toString());
intent.putExtra("sns_landing_pages_sessionId", valueOf);
intent.putExtra("sns_landing_pages_ad_buffer", stringExtra2);
}
com.tencent.mm.bg.d.b(context, "sns", ".ui.SnsAdNativeLandingPagesPreviewUI", intent);
}
}
|
package mop.test.java.database.model;
import java.util.ArrayList;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import mop.main.java.database.model.queryable.Movie;
import mop.main.java.database.model.queryable.Genre;
import mop.main.java.database.model.queryable.Actor;
public class MovieTest {
@Test
public void testPlaylistId() {
Movie sut = new Movie();
sut.setPlaylistId(2);
assertEquals(2, sut.getPlaylistId());
}
@Test
public void testMovieId() {
Movie sut = new Movie();
sut.setMovieId(26);
assertEquals(26, sut.getMovieId());
}
@Test
public void testTitle() {
Movie sut = new Movie();
sut.setTitle("Test Title");
assertEquals("Test Title", sut.getTitle());
}
@Test
public void testYear() {
Movie sut = new Movie();
sut.setYear((short) 2001);
assertEquals(2001, sut.getYear());
}
@Test
public void testDirector() {
Movie sut = new Movie();
sut.setDirector("Richard Kelly");
assertEquals("Richard Kelly", sut.getDirector());
}
@Test
public void testLength() {
Movie sut = new Movie();
sut.setLength(137);
assertEquals(2, sut.getLength().getHours());
assertEquals(17, sut.getLength().getMinutes());
}
@Test
public void testDescription() {
Movie sut = new Movie();
sut.setDescription("My favourite movie.");
assertEquals("My favourite movie.", sut.getDescription());
}
@Test
public void testImageLocation() {
Movie sut = new Movie();
sut.setImageLocation("C:\\FakeFolder/Images");
assertEquals("C:\\FakeFolder/Images", sut.getImageLocation());
}
@Test
public void testFileLocation() {
Movie sut = new Movie();
sut.setFileLocation("C:\\FakeFolder/Movies");
assertEquals("C:\\FakeFolder/Movies", sut.getFileLocation());
}
@Test
public void testIsHighDefinition() {
Movie sut = new Movie();
sut.setIsHighDefinition(true);
assertTrue(sut.getIsHighDefinition());
}
@Test
public void testGenres() {
Movie sut = new Movie();
Genre genre1 = new Genre();
genre1.setName("genre1");
Genre genre2 = new Genre();
genre2.setName("genre2");
sut.addGenre(genre1);
sut.addGenre(genre2);
ArrayList<Genre> result = sut.getGenres();
assertEquals("genre1", result.get(0).getName());
assertEquals("genre2", result.get(1).getName());
}
@Test
public void testActors() {
Movie sut = new Movie();
Actor actor1 = new Actor();
actor1.setName("actor1");
Actor actor2 = new Actor();
actor2.setName("actor2");
sut.addActor(actor1);
sut.addActor(actor2);
ArrayList<Actor> result = sut.getActors();
assertEquals("actor1", result.get(0).getName());
assertEquals("actor2", result.get(1).getName());
}
@Test
public void testRelatedMovieIds() {
Movie sut = new Movie();
sut.addRelatedMovieId(1);
sut.addRelatedMovieId(2);
ArrayList<Integer> result = sut.getRelatedMovieIds();
assertEquals(1, (int) result.get(0));
assertEquals(2, (int) result.get(1));
}
}
|
package Source;
public class Nodo {
public Song song;
public Nodo next;
public Nodo previous;
public Nodo() {
}
public Nodo(Song song) {
this.song = song;
this.next = null;
this.previous = null;
}
public boolean isEmpty(){
return song == null;
}
}
|
package com.tencent.mm.ui.chatting;
import com.tencent.mm.pluginsdk.model.app.f;
import com.tencent.mm.pluginsdk.model.app.g;
import com.tencent.mm.ui.chatting.ChattingSendDataToDeviceUI.3;
class ChattingSendDataToDeviceUI$3$1 implements Runnable {
final /* synthetic */ f jLD;
final /* synthetic */ 3 tLH;
ChattingSendDataToDeviceUI$3$1(3 3, f fVar) {
this.tLH = 3;
this.jLD = fVar;
}
public final void run() {
g.a(this.tLH.tLG.getBaseContext(), this.jLD.field_packageName, this.tLH.tLG.tLD, this.jLD.field_appId, this.jLD.field_openId, 0, null, null);
}
}
|
/*
* 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 utn.resumiderobilletes.repositorios;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
/**
*
* @author Luciano Ybañez
*/
public class Archivo {
private static final String RESUMIDERO_FILE = "..\\Resumidero.jdb";
private static Datos datos;
public static Datos getDatos() {
if (datos == null) {
cargarDatos();
}
return datos;
}
public static void cargarDatos() {
File f = new File(RESUMIDERO_FILE);
if (f.exists()) {
try {
FileInputStream fi = new FileInputStream(f);
ObjectInputStream oi = new ObjectInputStream(fi);
datos = (Datos) oi.readObject();
oi.close();
fi.close();
} catch (IOException iOException) {
iOException.printStackTrace();
System.exit(1);
} catch (ClassNotFoundException classNotFoundException) {
classNotFoundException.printStackTrace();
System.exit(2);
}
}else{
datos = new Datos();
}
}
public static void guardar() {
File f = new File(RESUMIDERO_FILE);
try {
FileOutputStream fo = new FileOutputStream(f);
ObjectOutputStream oo = new ObjectOutputStream(fo);
oo.writeObject(getDatos());
oo.close();
fo.close();
} catch (IOException iOException) {
System.out.println("No se pudo Guardar...");
}
}
}
|
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.*;
/**
* The size of database is set by me. If you would like to add products to database you need to
* increase variable sizeOfList and add correct lines in "products database.txt"
*/
public class ProductDatabase {
private int sizeOfList=5;
Map<Integer, Product> productsMap = new HashMap<>();
ArrayList boughtProducts = new ArrayList();
private float totalCost=0;
public ProductDatabase(){
}
/**
* databaseUpdate reads barcode and information about products from file and connect them together in a map
*/
public void databaseUpdate (){
FileReader file;
BufferedReader reader;
try {
file = new FileReader("product database.txt");
reader = new BufferedReader(file);
for (int i = 0; i <sizeOfList ; i++) {
int codeTMP;
Product productTMP=new Product();
codeTMP=Integer.parseInt(reader.readLine());
productTMP.getData(reader);
productsMap.put(codeTMP,productTMP);
}
} catch (java.io.IOException e) {
e.printStackTrace();
}
}
/**
* checkProduct is checking the given barcode. If it is in the database and it's available,
* we are purchasing the product. Purchased products are put in boughtProducts list.
*/
public void checkProduct(int key){
if(productsMap.containsKey(key)){
if(productsMap.get(key).getProduct()) {
boughtProducts.add(key);
}
}else{
System.out.println("Invalid bar-code");
}
}
/**
* showReceipt is preparing the receipt basing on boughtProducts list. The products contained in this
* list are displayed and the totalCost is calculated.
*/
public void showReceipt(){
for (int i = 0; i <boughtProducts.size() ; i++) {
totalCost=totalCost+productsMap.get(boughtProducts.get(i)).countProducts();
}
System.out.println("Total sum: "+totalCost);
}
}
|
package database.manager;
import database.entity.IEntity;
import java.util.List;
/**
* Created by csvanefalk on 18/11/14.
*/
public interface IDAO<T extends IEntity> {
void persist(T t);
void remove(int id);
void update(T t);
T find(int id);
List<T> range(int maxResults, int firstResult);
List<T> all();
int count();
}
|
package com.mercadolibre.desafioquality.DAO.HotelRoomDAO.Impl;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mercadolibre.desafioquality.DAO.HotelRoomDAO.BookingDao;
import com.mercadolibre.desafioquality.DTO.AvailabilityHotelRoomDTOs.HotelDTO;
import org.springframework.stereotype.Repository;
import org.springframework.util.ResourceUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Repository
public class BookingDaoImpl implements BookingDao {
private List<HotelDTO> database;
public BookingDaoImpl() {
database = this.loadDatabase();
}
@Override
public List<HotelDTO> getAllHotels()
{
return new ArrayList<>(this.database);
}
public List<HotelDTO> loadDatabase() {
File file= null;
try {
file = ResourceUtils.getFile("src/main/resources/hotels.json");
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
ObjectMapper objectMapper = new ObjectMapper();
TypeReference<List<HotelDTO>> typeRef = new TypeReference<>() {};
List<HotelDTO> HotelDTOS = null;
try {
HotelDTOS = objectMapper.readValue(file, typeRef);
} catch (IOException e) {
e.printStackTrace();
}
return HotelDTOS;
}
}
|
/*
* Copyright (c) 2017. Universidad Politecnica de Madrid
*
* @author Badenes Olmedo, Carlos <cbadenes@fi.upm.es>
*
*/
package org.librairy.modeler.lda.models;
import lombok.Data;
import org.librairy.computing.cluster.ComputingContext;
/**
* @author Badenes Olmedo, Carlos <cbadenes@fi.upm.es>
*/
@Data
public class ComputingKey {
ComputingContext context;
String id;
public ComputingKey(ComputingContext context , String id){
this.context = context;
this.id = id;
}
}
|
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
Grains[] mv = new Grains[4];
for(int i=0;i<4;i++)
{
int a = sc.nextInt();sc.nextLine();
String b = sc.nextLine();
String c = sc.nextLine();
int d = sc.nextInt();
mv[i] = new Grains(a,b,c,d);
}
sc.nextLine();
String nm = sc.nextLine();
String m=sc.nextLine();
int res = findTotalGrainsForGivenState(mv, nm);
if (res>0)
System.out.println(res);
else
System.out.println("No Grains available for the given state");
Grains temp = getGrainsForGivenName(mv,m);
if(temp == null)
System.out.println("No Grains with matching names are found");
else
System.out.println(temp.id+"-"+m+"-"+temp.rt);
}
public static int findTotalGrainsForGivenState (Grains[] mv, String nm)
{
int avg,s=0,j=0;
for(int i=0;i<4;i++)
{
if(nm.equalsIgnoreCase(mv[i].rt))
{
s = s+mv[i].bt;
j++;
}
}
if(j>0)
{
return s;
}
else
return 0;
}
public static Grains getGrainsForGivenName(Grains[] mv,String budget)
{
Grains temp = new Grains();
for(int i=0;i<4;i++)
{
if(budget.equalsIgnoreCase(mv[i].dt))
{
temp= mv[i];
return temp;
}
}
return null;
}
}
class Grains
{
int id,bt;
String dt,rt;
Grains()
{
}
Grains(int id, String dt,String rt, int bt)
{
this.id = id;
this.dt = dt;
this.rt = rt;
this.bt = bt;
}
}
|
package com.globalrelay.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.globalrelay.service.ServiceHealthMonitor;
import com.globalrelay.checker.Protocol;
import com.globalrelay.exception.HealthCheckConfigurationAlreadyExistsException;
import com.globalrelay.exception.NoHealthCheckConfigurationFound;
import com.globalrelay.model.Connection;
import com.globalrelay.model.HealthCheckConfiguration;
import com.globalrelay.notification.NotifierType;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import java.util.ArrayList;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@RunWith(SpringJUnit4ClassRunner.class)
public class HealthCheckControllerTest {
private MockMvc mockMvc;
@Mock
private ServiceHealthMonitor serviceHealthMonitor;
private String url = "/configuration";
private String outageUrl = "/configuration/1/2";
private ObjectMapper objectMapper = new ObjectMapper();
@InjectMocks
private HealthCheckController controller;
@Before
public void setup() {
mockMvc = MockMvcBuilders.standaloneSetup(controller).build();
}
@Test
public void testAddConfiguration() throws Exception{
String content = objectMapper.writeValueAsString(createHealthConfiguration());
doNothing().when(serviceHealthMonitor).addRegistration(any());
mockMvc.perform(post(url)
.content(content)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
}
@Test
public void testAddConfiguration_failForMissingHost() throws Exception{
HealthCheckConfiguration configuration = createHealthConfiguration();
configuration.getConnection().setHost("");
String content = objectMapper.writeValueAsString(configuration);
doNothing().when(serviceHealthMonitor).addRegistration(any());
mockMvc.perform(post(url)
.content(content)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}
@Test
public void testAddConfiguration_failForMissingPort() throws Exception{
HealthCheckConfiguration configuration = createHealthConfiguration();
configuration.getConnection().setPort(0);
String content = objectMapper.writeValueAsString(configuration);
doNothing().when(serviceHealthMonitor).addRegistration(any());
mockMvc.perform(post(url)
.content(content)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}
@Test
public void testAddConfiguration_failForInvalidPort() throws Exception{
HealthCheckConfiguration configuration = createHealthConfiguration();
configuration.getConnection().setPort(233423423);
String content = objectMapper.writeValueAsString(configuration);
doNothing().when(serviceHealthMonitor).addRegistration(any());
mockMvc.perform(post(url)
.content(content)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}
@Test
public void testAddConfiguration_failForDuplicateConfiguration() throws Exception{
HealthCheckConfiguration configuration = createHealthConfiguration();
String content = objectMapper.writeValueAsString(configuration);
doThrow(HealthCheckConfigurationAlreadyExistsException.class).when(serviceHealthMonitor).addRegistration(any());
mockMvc.perform(post(url)
.content(content)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}
//outage
@Test
public void testAddOutage() throws Exception{
String content = objectMapper.writeValueAsString(createConnection());
doNothing().when(serviceHealthMonitor).registerOutageFor(any(), anyLong(), anyLong());
mockMvc.perform(put(outageUrl)
.content(content)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
}
@Test
public void testAddOutage_FailForEmptyHost() throws Exception{
Connection connection = createConnection();
connection.setHost("");
String content = objectMapper.writeValueAsString(connection);
doNothing().when(serviceHealthMonitor).registerOutageFor(any(), anyLong(), anyLong());
mockMvc.perform(put(outageUrl)
.content(content)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}
@Test
public void testAddOutage_FailForInvalidPort() throws Exception{
Connection connection = createConnection();
connection.setPort(0);
String content = objectMapper.writeValueAsString(connection);
doNothing().when(serviceHealthMonitor).registerOutageFor(any(), anyLong(), anyLong());
mockMvc.perform(put(outageUrl)
.content(content)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}
@Test
public void testAddOutage_FailForHighPort() throws Exception{
Connection connection = createConnection();
connection.setPort(2312222);
String content = objectMapper.writeValueAsString(connection);
doNothing().when(serviceHealthMonitor).registerOutageFor(any(), anyLong(), anyLong());
mockMvc.perform(put(outageUrl)
.content(content)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}
@Test
public void testAddOutage_failForNonExistingConfiguration() throws Exception{
Connection connection = createConnection();
String content = objectMapper.writeValueAsString(connection);
doThrow(NoHealthCheckConfigurationFound.class).when(serviceHealthMonitor).registerOutageFor(any(), anyLong(), anyLong());
mockMvc.perform(put(outageUrl)
.content(content)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}
//remove
@Test
public void testRemoveConfiguration() throws Exception{
String content = objectMapper.writeValueAsString(new Connection());
doNothing().when(serviceHealthMonitor).removeRegistration(any());
mockMvc.perform(delete(url)
.content(content)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
}
//get
@Test
public void testGetConfiguration() throws Exception{
when(serviceHealthMonitor.getServiceCongfigurations()).thenReturn(new ArrayList<>());
mockMvc.perform(get(url)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
}
private HealthCheckConfiguration createHealthConfiguration(){
Connection connection = new Connection(Protocol.TCP, "localhost",5000);
HealthCheckConfiguration configuration = new HealthCheckConfiguration();
configuration.setGraceTime(10);
configuration.setFrequency(5);
configuration.setServiceOutage(false);
configuration.setConnection(connection);
configuration.setNotifierType(NotifierType.CONSOLE);
return configuration;
}
private Connection createConnection(){
Connection connection = new Connection();
connection.setPort(5000);
connection.setHost("localhost");
connection.setProtocol(Protocol.TCP);
return connection;
}
}
|
package com.revolut.repository;
import com.revolut.model.Account;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
public class AccountRepository {
private Map<String,LockedAccount> accountNumberAccount = new ConcurrentHashMap<>();
public List<Account> create(List<Account> accounts) {
List<Account> created = new ArrayList<>();
for(Account original : accounts){
LockedAccount lockedAccount = new LockedAccount(original);
accountNumberAccount.put(lockedAccount.getAccountNumber(),lockedAccount);
created.add(lockedAccount.copy());
}
return created;
}
public List<Account> all() {
return accountNumberAccount.values().stream().map(LockedAccount::copy).collect(Collectors.toList());
}
public Map<String,Account> getAccounts(List<String> accounts, boolean lock){
String threadName = Thread.currentThread().getName();
System.out.printf("Getting accounts %s lock = %s by thread %s\n", accounts, lock,threadName);
if(!lock){
return getAccountsWithoutLock(accounts);
}
return getAccountsWithLock(accounts);
}
private Map<String, Account> getAccountsWithLock(List<String> accounts) {
String threadName = Thread.currentThread().getName();
Map<String,Account> foundAccounts = new HashMap<>();
List<LockedAccount> lockedAccounts = new ArrayList<>();
Collections.sort(accounts);
boolean allSuccessful = true;
for(String accountNumber : accounts){
LockedAccount actualAccount = accountNumberAccount.get(accountNumber);
if(actualAccount != null && lockAccount(actualAccount)){
System.out.printf("Getting account %s with lock by thread %s\n", accountNumber, threadName);
foundAccounts.put(accountNumber,actualAccount.copy());
lockedAccounts.add(actualAccount);
}else{
System.out.printf("Couldn't get account %s with lock by thread %s\n", accountNumber, threadName);
allSuccessful = false;
break;
}
}
if (!allSuccessful) {
for (LockedAccount lockedAccount : lockedAccounts) {
unlockAccount(lockedAccount);
}
return new HashMap<>();
}
return foundAccounts;
}
private Map<String, Account> getAccountsWithoutLock(List<String> accounts) {
String threadName = Thread.currentThread().getName();
Map<String,Account> foundAccounts = new HashMap<>();
for(String accountNumber : accounts) {
LockedAccount actualAccount = accountNumberAccount.get(accountNumber);
if(actualAccount != null) {
System.out.printf("Getting account %s without lock by thread %s\n", accountNumber, threadName);
foundAccounts.put(accountNumber, actualAccount.copy());
}
}
return foundAccounts;
}
public boolean updateAccounts(List<Account> accounts){
String threadName = Thread.currentThread().getName();
Map<Account,LockedAccount> foundAccounts = new HashMap<>();
for(Account account : accounts){
LockedAccount actualAccount = accountNumberAccount.get(account.getAccountNumber());
if(actualAccount != null && isLocked(actualAccount)){
foundAccounts.put(account,actualAccount);
} else{
System.out.printf("Unable to update account %s by thread %s\n", account.getAccountNumber(), threadName);
return false;
}
}
for(Map.Entry<Account, LockedAccount> accountPair : foundAccounts.entrySet()){
System.out.printf("Updating account %s by thread %s\n", accountPair.getKey().getAccountNumber(), threadName);
Account account = accountPair.getKey();
LockedAccount actualAccount = accountPair.getValue();
actualAccount.copyFrom(account);
}
return true;
}
public void unlockAccounts(List<Account> accounts){
for(Account account : accounts){
LockedAccount actualAccount = accountNumberAccount.get(account.getAccountNumber());
unlockAccount(actualAccount);
}
}
private boolean lockAccount(LockedAccount account){
return account.getIsBeingUpdated().compareAndSet(false,true);
}
private boolean unlockAccount(LockedAccount account){
return account.getIsBeingUpdated().compareAndSet(true,false);
}
private boolean isLocked(LockedAccount account){
return account.getIsBeingUpdated().get();
}
private class LockedAccount extends Account{
private AtomicBoolean isBeingUpdated = new AtomicBoolean(false);
private LockedAccount(){
this.setAccountNumber(UUID.randomUUID().toString());
this.setBalance(BigDecimal.ZERO);
}
private LockedAccount(Account account){
this();
this.copyFrom(account);
this.setBalance(BigDecimal.ZERO);
}
private Account copy(){
Account clone = new Account();
clone.setBalance(getBalance());
clone.setAccountNumber(getAccountNumber());
clone.setName(getName());
clone.setEmail(getEmail());
return clone;
}
private void copyFrom(Account account) {
this.setBalance(account.getBalance());
this.setName(account.getName());
this.setEmail(account.getEmail());
}
private AtomicBoolean getIsBeingUpdated() {
return isBeingUpdated;
}
}
}
|
package academy.devdojo.estruturascondicionais.ifselse;
/*
Dado um detemrinado numero inteiro
Imprima se ele é impar ou par
Resto da divisao por 2 se for par sempre vai ser 0
senao vai ser impar
*/
public class ParOuImpar {
public static void main(String[] args) {
int numero = 15;
// +, -, /, *, %
if ( (numero % 2) == 0) {
System.out.println("PAR: "+ (numero % 2));
} else {
System.out.println("IMPAR: " + (numero % 2));
}
}
}
|
/*
* Copyright (C) 2020-2023 Hedera Hashgraph, LLC
*
* 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.hedera.services.txn.token;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_ID;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK;
import com.hedera.mirror.web3.evm.store.Store;
import com.hedera.services.store.models.Id;
import com.hederahashgraph.api.proto.java.ResponseCodeEnum;
import com.hederahashgraph.api.proto.java.TokenPauseTransactionBody;
import com.hederahashgraph.api.proto.java.TransactionBody;
/**
* Copied Logic type from hedera-services.
* <p>
* Differences with the original:
* 1. Use abstraction for the state by introducing {@link Store} interface
* 2. Used token.setPaused instead of token.changePauseStatus (like in services)
* 3. Used store.updateToken(token)
* instead of tokenStore.commitToken(token) (like in services)
*/
public class PauseLogic {
public void pause(final Id targetTokenId, final Store store) {
/* --- Load the model objects --- */
var token = store.loadPossiblyPausedToken(targetTokenId.asEvmAddress());
/* --- Do the business logic --- */
var pausedToken = token.setPaused(true);
/* --- Persist the updated models --- */
store.updateToken(pausedToken);
}
public ResponseCodeEnum validateSyntax(final TransactionBody txnBody) {
TokenPauseTransactionBody op = txnBody.getTokenPause();
if (!op.hasToken()) {
return INVALID_TOKEN_ID;
}
return OK;
}
}
|
package java_Exception;
public class myexception extends Exception{
private int idnumber;
public myexception(String message,int id){
super(message);
this.idnumber = id;
}
public int getid(){
return idnumber;
}
}
|
package com.tencent.mm.plugin.profile.ui;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.tencent.mm.R;
import com.tencent.mm.aa.k;
import com.tencent.mm.aa.q;
import com.tencent.mm.ab.e;
import com.tencent.mm.ab.l;
import com.tencent.mm.ac.a.j;
import com.tencent.mm.ac.d;
import com.tencent.mm.ac.d.b;
import com.tencent.mm.ac.g;
import com.tencent.mm.ac.h.a;
import com.tencent.mm.ac.n;
import com.tencent.mm.ac.y;
import com.tencent.mm.ac.z;
import com.tencent.mm.g.a.cv;
import com.tencent.mm.g.a.cz;
import com.tencent.mm.g.a.ng;
import com.tencent.mm.model.am;
import com.tencent.mm.model.au;
import com.tencent.mm.model.i;
import com.tencent.mm.model.r;
import com.tencent.mm.model.s;
import com.tencent.mm.modelsns.SnsAdClick;
import com.tencent.mm.plugin.appbrand.config.WxaAttributes.WxaEntryInfo;
import com.tencent.mm.plugin.report.service.h;
import com.tencent.mm.plugin.wxpay.a$k;
import com.tencent.mm.protocal.c.atx;
import com.tencent.mm.protocal.c.bls;
import com.tencent.mm.protocal.c.blt;
import com.tencent.mm.protocal.c.brs;
import com.tencent.mm.protocal.c.brt;
import com.tencent.mm.protocal.c.cgc;
import com.tencent.mm.protocal.c.qt;
import com.tencent.mm.sdk.platformtools.BackwardSupportUtil;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.bi;
import com.tencent.mm.sdk.platformtools.x;
import com.tencent.mm.storage.ab;
import com.tencent.mm.storage.ai;
import com.tencent.mm.storage.bd;
import com.tencent.mm.ui.MMActivity;
import com.tencent.mm.ui.base.p;
import com.tencent.mm.ui.base.preference.CheckBoxPreference;
import com.tencent.mm.ui.base.preference.KeyValuePreference;
import com.tencent.mm.ui.base.preference.Preference;
import com.tencent.mm.ui.base.preference.PreferenceSmallCategory;
import com.tencent.mm.ui.base.preference.f;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import junit.framework.Assert;
public final class c implements e, a, n, com.tencent.mm.pluginsdk.b.a {
MMActivity bGc;
private List<d.a> dKO;
private b dKP;
private boolean dKW;
private String dKY;
private SharedPreferences duR;
private int eLK;
f eOE;
ab guS;
private boolean hEj;
private CheckBoxPreference hLs;
boolean isDeleteCancel;
String juZ;
private boolean lUD;
private String lUI;
d lUs;
private j lVG;
private List<WxaEntryInfo> lVH;
private qt lVI;
private boolean lVJ;
private boolean lVK;
boolean lVL;
private int lVM;
private String lVN;
private boolean lVO;
com.tencent.mm.ui.widget.a.c lVP;
private Bundle lVQ;
SnsAdClick lVR;
private String lVS;
p tipDialog;
static /* synthetic */ void a(c cVar) {
com.tencent.mm.ui.widget.a.d dVar = new com.tencent.mm.ui.widget.a.d(cVar.bGc, 1, false);
dVar.ofp = new 19(cVar);
dVar.ofq = new 2(cVar);
dVar.bXO();
}
private c(MMActivity mMActivity) {
this.lVI = null;
this.lVJ = false;
this.lVK = false;
this.dKW = false;
this.lVL = false;
this.lVM = 0;
this.lVP = null;
this.duR = null;
this.lVR = null;
this.lVS = null;
this.tipDialog = null;
this.isDeleteCancel = false;
this.bGc = mMActivity;
}
public c(MMActivity mMActivity, String str, qt qtVar) {
this(mMActivity);
this.lUI = str;
this.lVI = qtVar;
}
public final boolean wX(String str) {
int i = 4;
if (str == null) {
return false;
}
Intent intent;
String Mg;
if (str.equals("contact_info_verifyuser_weibo")) {
new com.tencent.mm.plugin.profile.ui.a.a(this.bGc).ef(this.guS.csO, this.guS.field_username);
return true;
} else if ("contact_info_biz_go_chatting".endsWith(str)) {
if (this.lVR != null) {
ng ngVar = new ng();
this.lVR.egJ = 5;
ngVar.bYk.bYl = this.lVR;
com.tencent.mm.sdk.b.a.sFg.m(ngVar);
}
if (this.lUs == null || !(this.lUs.LY() || this.lUs.Ma())) {
intent = new Intent();
if (this.bGc.getIntent().getBooleanExtra("key_start_biz_profile_from_app_brand_profile", false)) {
intent.setFlags(268435456);
}
if (this.lUD) {
intent.putExtra("Chat_User", this.guS.field_username);
intent.putExtra("Chat_Mode", 1);
this.bGc.setResult(-1, intent);
} else {
intent.putExtra("Chat_User", this.guS.field_username);
intent.putExtra("Chat_Mode", 1);
intent.putExtra("finish_direct", true);
com.tencent.mm.plugin.profile.a.ezn.e(intent, this.bGc);
}
} else {
intent = new Intent();
if (this.lUs.Ma()) {
Mg = this.lUs.Mg();
if (bi.oW(Mg)) {
x.w("MicroMsg.ContactWidgetBizInfo", "contact_info_biz_go_chatting fatherUserName is empty");
return false;
}
intent.putExtra("enterprise_biz_name", Mg);
intent.putExtra("enterprise_biz_display_name", r.gT(Mg));
} else {
intent.putExtra("enterprise_biz_name", this.guS.field_username);
intent.putExtra("enterprise_biz_display_name", r.gT(this.guS.field_username));
}
intent.addFlags(67108864);
com.tencent.mm.bg.d.e(this.bGc, ".ui.conversation.EnterpriseConversationUI", intent);
this.bGc.finish();
}
ay(5, null);
return true;
} else if ("contact_info_biz_add".endsWith(str)) {
if (com.tencent.mm.model.gdpr.c.Jm()) {
com.tencent.mm.model.gdpr.c.a(this.bGc, com.tencent.mm.model.gdpr.a.dEc, this.guS.field_username, new 4(this));
} else {
bnr();
}
if (this.lVM == 0) {
return true;
}
h.mEJ.h(11263, new Object[]{Integer.valueOf(this.lVM), this.guS.field_username});
return true;
} else if ("contact_info_biz_read_msg_online".endsWith(str)) {
return true;
} else {
if (!"contact_info_stick_biz".equals(str)) {
int i2;
String str2;
if (!(!"contact_info_guarantee_info".equals(str) || this.dKP.Mr() == null || bi.oW(this.dKP.Mr().dLQ))) {
intent = new Intent();
intent.putExtra("rawUrl", this.dKP.Mr().dLQ);
intent.putExtra("useJs", true);
intent.putExtra("vertical_scroll", true);
intent.putExtra("geta8key_scene", 3);
com.tencent.mm.bg.d.b(this.bGc, "webview", ".ui.tools.WebViewUI", intent);
}
if (str.startsWith("contact_info_bizinfo_external#")) {
i2 = bi.getInt(str.replace("contact_info_bizinfo_external#", ""), -1);
if (i2 >= 0 && i2 < this.dKO.size()) {
d.a aVar = (d.a) this.dKO.get(i2);
Mg = aVar.url;
Intent intent2 = new Intent();
intent2.putExtra("rawUrl", Mg);
intent2.putExtra("useJs", true);
intent2.putExtra("vertical_scroll", true);
intent2.putExtra("geta8key_scene", 3);
intent2.putExtra("KPublisherId", "brand_profile");
intent2.putExtra("prePublishId", "brand_profile");
if ((this.lVQ != null && (this.eLK == 39 || this.eLK == 56 || this.eLK == 35)) || this.eLK == 87 || this.eLK == 89 || this.eLK == 85 || this.eLK == 88) {
x.d("MicroMsg.ContactWidgetBizInfo", "from biz search.");
Bundle bundle = new Bundle();
bundle.putBoolean("KFromBizSearch", true);
bundle.putBundle("KBizSearchExtArgs", this.lVQ);
intent2.putExtra("jsapiargs", bundle);
i = com.tencent.mm.l.a.gd(this.guS.field_type) ? 7 : 6;
int identifier = this.bGc.getResources().getIdentifier(aVar.dKS, "string", this.bGc.getPackageName());
str2 = aVar.title;
if (identifier > 0) {
str2 = this.bGc.getString(identifier);
}
ay(i, str2);
}
com.tencent.mm.bg.d.b(this.bGc, "webview", ".ui.tools.WebViewUI", intent2);
return true;
}
}
d dVar;
Intent intent3;
if ("contact_info_subscribe_bizinfo".endsWith(str) || "contact_info_show_brand".endsWith(str) || "contact_info_locate".endsWith(str)) {
d dVar2 = this.lUs;
if (dVar2 == null) {
return true;
}
if ("contact_info_subscribe_bizinfo".endsWith(str)) {
if (!dVar2.LX()) {
if (dVar2.LQ()) {
dVar2.field_brandFlag |= 1;
if (this.dKP == null && dVar2 != null) {
this.dKP = dVar2.bG(false);
}
if (this.dKP != null && this.dKP.Mk() && com.tencent.mm.bg.d.QS("brandservice")) {
this.eOE.bw("contact_info_template_recv", false);
} else {
this.eOE.bw("contact_info_template_recv", true);
}
} else {
dVar2.field_brandFlag &= -2;
this.eOE.bw("contact_info_template_recv", true);
}
h hVar = h.mEJ;
Object[] objArr = new Object[4];
objArr[0] = dVar2.field_username;
objArr[1] = Integer.valueOf(1);
if (dVar2.LQ()) {
i = 3;
}
objArr[2] = Integer.valueOf(i);
objArr[3] = Integer.valueOf(0);
hVar.h(13307, objArr);
} else if (dVar2 != null) {
if (dVar2.Ma()) {
au.DF().a(1363, this);
if (((CheckBoxPreference) this.eOE.ZZ("contact_info_subscribe_bizinfo")).isChecked()) {
i2 = 0;
} else {
i2 = 4;
}
final com.tencent.mm.plugin.profile.a.b bVar = new com.tencent.mm.plugin.profile.a.b(dVar2.field_username, i2);
au.DF().a(bVar, 0);
MMActivity mMActivity = this.bGc;
this.bGc.getString(R.l.app_tip);
this.tipDialog = com.tencent.mm.ui.base.h.a(mMActivity, this.bGc.getString(R.l.app_waiting), true, new OnCancelListener() {
public final void onCancel(DialogInterface dialogInterface) {
au.DF().c(bVar);
au.DF().b(1363, c.this);
}
});
} else if (dVar2.LY()) {
CheckBoxPreference checkBoxPreference = (CheckBoxPreference) this.eOE.ZZ("contact_info_subscribe_bizinfo");
z.Nh();
y a = com.tencent.mm.ac.c.a(dVar2.field_username, !checkBoxPreference.isChecked(), this);
MMActivity mMActivity2 = this.bGc;
this.bGc.getString(R.l.app_tip);
this.tipDialog = com.tencent.mm.ui.base.h.a(mMActivity2, this.bGc.getString(R.l.app_waiting), true, new 16(this, a));
}
}
} else if ("contact_info_show_brand".endsWith(str)) {
boolean z;
if ((dVar2.field_brandFlag & 2) == 0) {
z = true;
} else {
z = false;
}
if (z) {
dVar2.field_brandFlag |= 2;
} else {
dVar2.field_brandFlag &= -3;
}
} else if ("contact_info_locate".endsWith(str)) {
if (dVar2.LR()) {
dVar2.field_brandFlag &= -5;
} else {
this.lVP = com.tencent.mm.ui.base.h.a(this.bGc, this.bGc.getString(R.l.chatting_biz_report_location_confirm, new Object[]{this.guS.BL()}), this.bGc.getString(R.l.app_tip), new 1(this, dVar2), new 12(this, dVar2));
}
}
if (dVar2.Ma() || dVar2.LY()) {
return true;
}
a(dVar2, false);
return true;
} else if ("contact_info_verifyuser".endsWith(str)) {
dVar = this.lUs;
if (dVar == null) {
return true;
}
b bG = dVar.bG(false);
if (bG == null) {
return true;
}
str2 = null;
if (bG.Mt() != null && !bi.oW(bG.Mt().dLL)) {
str2 = bG.Mt().dLL;
} else if (!(bG.Mu() == null || bi.oW(bG.Mu().dLT))) {
str2 = bG.Mu().dLT;
}
if (bi.oW(str2)) {
return true;
}
intent3 = new Intent();
intent3.putExtra("rawUrl", str2);
intent3.putExtra("useJs", true);
intent3.putExtra("vertical_scroll", true);
intent3.putExtra("geta8key_scene", 3);
com.tencent.mm.bg.d.b(this.bGc, "webview", ".ui.tools.WebViewUI", intent3);
return true;
} else if ("contact_info_trademark".endsWith(str)) {
dVar = this.lUs;
if (dVar == null || dVar.bG(false) == null || bi.oW(dVar.bG(false).Mm())) {
return true;
}
intent3 = new Intent();
intent3.putExtra("rawUrl", dVar.bG(false).Mm());
intent3.putExtra("useJs", true);
intent3.putExtra("vertical_scroll", true);
intent3.putExtra("geta8key_scene", 3);
com.tencent.mm.bg.d.b(this.bGc, "webview", ".ui.tools.WebViewUI", intent3);
return true;
} else {
if ("contact_is_mute".endsWith(str)) {
this.hEj = !this.hEj;
if (this.hEj) {
s.n(this.guS);
} else {
s.o(this.guS);
}
ha(this.hEj);
}
if ("enterprise_contact_info_enter".equals(str)) {
if (this.bGc == null) {
x.e("MicroMsg.ContactWidgetBizInfo", "EnterEnterprise context is null");
} else if (this.lUs == null) {
x.e("MicroMsg.ContactWidgetBizInfo", "EnterEnterprise bizInfo is null");
} else {
intent = new Intent();
intent.putExtra("enterprise_biz_name", this.lUs.field_username);
intent.addFlags(67108864);
com.tencent.mm.bg.d.b(this.bGc, "brandservice", ".ui.EnterpriseBizContactListUI", intent);
}
}
if ("contact_info_biz_disable".equals(str)) {
com.tencent.mm.ui.base.h.a(this.bGc, this.bGc.getString(R.l.enterprise_contact_info_disable_sub_confirm), "", this.bGc.getString(R.l.enterprise_contact_info_disable_sub), this.bGc.getString(R.l.app_cancel), new OnClickListener() {
public final void onClick(DialogInterface dialogInterface, int i) {
c.this.gZ(false);
}
}, null);
}
if ("contact_info_biz_enable".equals(str)) {
gZ(true);
}
if ("contact_info_template_recv".equals(str)) {
intent = new Intent();
intent.putExtra("enterprise_biz_name", this.lUs.field_username);
com.tencent.mm.bg.d.b(this.bGc, "brandservice", ".ui.ReceiveTemplateMsgMgrUI", intent);
}
if ("contact_info_service_phone".equals(str)) {
Preference ZZ = this.eOE.ZZ("contact_info_service_phone");
if (!(ZZ == null || ZZ.getSummary() == null || bi.oW(ZZ.getSummary().toString()))) {
String charSequence = ZZ.getSummary().toString();
com.tencent.mm.ui.base.h.a(this.bGc, true, charSequence, "", this.bGc.getString(R.l.contact_info_dial), this.bGc.getString(R.l.app_cancel), new 7(this, charSequence), null);
}
}
if ("contact_info_expose_btn".equals(str)) {
bnt();
}
if (!str.equals("biz_placed_to_the_top")) {
return true;
}
x.d("MicroMsg.ContactWidgetBizInfo", "changePlacedTop");
if (this.duR == null) {
this.duR = this.bGc.getSharedPreferences(this.bGc.getPackageName() + "_preferences", 0);
}
if (this.guS == null) {
return true;
}
if (this.guS.BG()) {
x.d("MicroMsg.ContactWidgetBizInfo", "unSetPlaceTop:%s", new Object[]{this.guS.field_username});
s.u(this.guS.field_username, true);
this.duR.edit().putBoolean("biz_placed_to_the_top", false).commit();
return true;
}
i.gy(this.guS.field_username);
x.d("MicroMsg.ContactWidgetBizInfo", "setPlaceTop:%s", new Object[]{this.guS.field_username});
this.duR.edit().putBoolean("biz_placed_to_the_top", true).commit();
return true;
}
} else if (((CheckBoxPreference) this.eOE.ZZ("contact_info_stick_biz")).isChecked()) {
h.mEJ.h(13307, new Object[]{this.guS.field_username, Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(0)});
i.gy(this.guS.field_username);
return true;
} else {
s.u(this.guS.field_username, true);
h.mEJ.h(13307, new Object[]{this.guS.field_username, Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(0)});
return true;
}
}
}
final void gZ(boolean z) {
com.tencent.mm.plugin.profile.a.c cVar = new com.tencent.mm.plugin.profile.a.c(this.lUs.field_username, !z);
au.DF().a(1394, this);
au.DF().a(cVar, 0);
MMActivity mMActivity = this.bGc;
this.bGc.getString(R.l.app_tip);
this.tipDialog = com.tencent.mm.ui.base.h.a(mMActivity, this.bGc.getString(R.l.app_waiting), true, new 14(this, cVar));
}
final void a(d dVar, boolean z) {
CheckBoxPreference checkBoxPreference = (CheckBoxPreference) this.eOE.ZZ("contact_info_subscribe_bizinfo");
CheckBoxPreference checkBoxPreference2 = (CheckBoxPreference) this.eOE.ZZ("contact_info_locate");
atx atx = new atx();
atx.eJV = dVar.field_brandFlag;
atx.hbL = this.guS.field_username;
if (uK(this.eLK)) {
au.HU();
com.tencent.mm.model.c.FQ().b(new com.tencent.mm.plugin.messenger.foundation.a.a.h.a(58, atx));
} else {
au.HU();
com.tencent.mm.model.c.FQ().b(new com.tencent.mm.plugin.messenger.foundation.a.a.h.a(47, atx));
}
z.MY().c(dVar, new String[0]);
checkBoxPreference.qpJ = dVar.LQ();
if (checkBoxPreference2 != null) {
checkBoxPreference2.qpJ = dVar.LR();
}
if (z) {
bnp();
}
}
public final boolean a(f fVar, ab abVar, boolean z, int i) {
boolean z2;
Assert.assertTrue(abVar != null);
if (bi.oV(abVar.field_username).length() > 0) {
z2 = true;
} else {
z2 = false;
}
Assert.assertTrue(z2);
if (fVar != null) {
z2 = true;
} else {
z2 = false;
}
Assert.assertTrue(z2);
this.eOE = fVar;
this.guS = abVar;
this.lUD = z;
this.eLK = i;
this.lVM = this.bGc.getIntent().getIntExtra("add_more_friend_search_scene", 0);
this.lVR = (SnsAdClick) this.bGc.getIntent().getParcelableExtra("KSnsAdTag");
this.lVQ = this.bGc.getIntent().getBundleExtra("Contact_Ext_Args");
this.lVS = this.bGc.getIntent().getStringExtra("key_add_contact_report_info");
bnp();
String stringExtra = this.bGc.getIntent().getStringExtra("Contact_BIZ_PopupInfoMsg");
if (!bi.oW(stringExtra)) {
this.bGc.getIntent().putExtra("Contact_BIZ_PopupInfoMsg", "");
com.tencent.mm.ui.base.h.a(this.bGc, stringExtra, "", this.bGc.getString(R.l.app_ok), null);
}
if (abVar != null) {
z.Nk().km(abVar.field_username);
if (com.tencent.mm.ac.f.kK(abVar.field_username)) {
stringExtra = abVar.field_username;
if (com.tencent.mm.ac.f.eZ(stringExtra)) {
z.Ng();
com.tencent.mm.ac.a.h.a(stringExtra, this);
stringExtra = com.tencent.mm.ac.f.kH(stringExtra).Mg();
if (stringExtra != null) {
z.Nk().km(stringExtra);
}
} else if (com.tencent.mm.ac.f.kM(stringExtra)) {
z.Nh();
com.tencent.mm.ac.c.a(stringExtra, this);
z.MY();
stringExtra = com.tencent.mm.ac.e.kD(stringExtra);
if (stringExtra != null) {
z.Nk().km(stringExtra);
}
}
}
}
return true;
}
private void bnp() {
d dVar;
CheckBoxPreference checkBoxPreference;
boolean z;
Preference ZZ;
KeyValuePreference keyValuePreference;
Bitmap e;
String str;
String str2;
Object[] objArr;
boolean z2;
Drawable bitmapDrawable;
String string;
Bitmap e2;
CharSequence charSequence;
IndexOutOfBoundsException e3;
int indexOf;
CheckBoxPreference checkBoxPreference2;
String BL;
int identifier;
auw();
this.eOE.removeAll();
this.eOE.addPreferencesFromResource(R.o.contact_info_pref_bizinfo);
if (this.lVL) {
this.eOE.bw("contact_info_time_expired", true);
}
d kH = com.tencent.mm.ac.f.kH(this.guS.field_username);
this.dKO = null;
this.dKP = null;
this.lVH = null;
if ((kH == null || kH.bG(false) == null) && this.lVI != null) {
kH = new d();
kH.field_username = this.guS.field_username;
kH.field_brandFlag = this.lVI.eJV;
kH.field_brandIconURL = this.lVI.eJY;
kH.field_brandInfo = this.lVI.eJX;
kH.field_extInfo = this.lVI.eJW;
dVar = kH;
} else {
dVar = kH;
}
if (dVar != null && dVar.field_brandInfo == null && dVar.field_extInfo == null && this.lVI != null) {
dVar.field_username = this.guS.field_username;
dVar.field_brandFlag = this.lVI.eJV;
dVar.field_brandIconURL = this.lVI.eJY;
dVar.field_brandInfo = this.lVI.eJX;
dVar.field_extInfo = this.lVI.eJW;
}
BizInfoHeaderPreference bizInfoHeaderPreference = (BizInfoHeaderPreference) this.eOE.ZZ("contact_info_header_bizinfo");
if (bizInfoHeaderPreference == null || bi.oW(this.guS.field_username)) {
x.w("MicroMsg.ContactWidgetBizInfo", "head pref is null");
this.eOE.bw("contact_info_header_bizinfo", true);
} else {
ab abVar = this.guS;
bizInfoHeaderPreference.lUr = this.lUI;
bizInfoHeaderPreference.lUs = dVar;
bizInfoHeaderPreference.onDetach();
au.HU();
com.tencent.mm.model.c.FR().a(bizInfoHeaderPreference);
q.Kp().d(bizInfoHeaderPreference);
z.Ni().a(bizInfoHeaderPreference);
bizInfoHeaderPreference.guS = abVar;
Assert.assertTrue("initView: contact username is null", bi.oV(abVar.field_username).length() > 0);
bizInfoHeaderPreference.initView();
}
this.eOE.bw("biz_placed_to_the_top", true);
this.eOE.bw("contact_info_biz_enable", true);
this.eOE.bw("contact_info_biz_disable", true);
this.eOE.bw("contact_info_stick_biz", true);
if (dVar != null) {
if (dVar.LZ()) {
this.eOE.bw("contact_info_biz_add", true);
this.eOE.bw("contact_info_expose_btn", true);
this.eOE.bw("contact_is_mute", false);
this.hEj = this.guS.BD();
if (dVar.Ma()) {
this.eOE.bw("contact_info_biz_go_chatting", true);
this.eOE.bw("contact_info_stick_biz", !com.tencent.mm.l.a.gd(this.guS.field_type));
checkBoxPreference = (CheckBoxPreference) this.eOE.ZZ("contact_info_stick_biz");
checkBoxPreference.qpJ = this.guS.BG();
checkBoxPreference.setTitle(R.l.enterprise_chat_placetop);
bnu();
} else {
this.eOE.bw("contact_info_subscribe_bizinfo", true);
this.eOE.bw("contact_info_biz_go_chatting", true);
if (dVar.LQ()) {
this.eOE.bw("contact_info_biz_enable", true);
this.eOE.bw("contact_info_biz_disable", false);
this.eOE.ZZ("contact_info_biz_disable").setTitle(R.l.enterprise_contact_info_disable_sub);
this.eOE.bw("contact_is_mute", false);
this.eOE.bw("biz_placed_to_the_top", false);
this.hLs = (CheckBoxPreference) this.eOE.ZZ("biz_placed_to_the_top");
this.hLs.setTitle(R.l.enterprise_sub_placetop);
bnu();
if (dVar.Mb()) {
this.eOE.bw("contact_info_locate", true);
}
} else {
this.eOE.bw("contact_info_biz_enable", false);
this.eOE.bw("contact_info_biz_disable", true);
this.eOE.ZZ("contact_info_biz_enable").setTitle(R.l.enterprise_contact_info_enable_sub);
this.eOE.bw("contact_is_mute", true);
this.eOE.bw("biz_placed_to_the_top", true);
this.eOE.bw("contact_info_locate", true);
}
}
ha(this.hEj);
} else if (dVar.LY()) {
this.eOE.bw("contact_info_locate", true);
this.eOE.bw("contact_info_subscribe_bizinfo", false);
this.eOE.bw("enterprise_contact_info_enter", false);
this.eOE.ZZ("contact_info_biz_go_chatting").setTitle(R.l.enterprise_contact_info_enter);
this.eOE.bw("contact_info_stick_biz", !com.tencent.mm.l.a.gd(this.guS.field_type));
checkBoxPreference = (CheckBoxPreference) this.eOE.ZZ("contact_info_stick_biz");
checkBoxPreference.qpJ = this.guS.BG();
checkBoxPreference.setTitle(R.l.enterprise_father_placetop);
bnu();
this.eOE.bw("contact_is_mute", true);
this.hEj = this.guS.BD();
ha(this.hEj);
this.eOE.ZZ("contact_is_mute").setSummary(R.l.contact_info_enterprise_father_mute_tips);
} else {
f fVar = this.eOE;
String str3 = "contact_info_stick_biz";
z = s.hr(this.guS.field_username) || !com.tencent.mm.l.a.gd(this.guS.field_type);
fVar.bw(str3, z);
((CheckBoxPreference) this.eOE.ZZ("contact_info_stick_biz")).qpJ = this.guS.BG();
this.eOE.bw("contact_is_mute", true);
this.hEj = false;
}
this.lUs = dVar;
this.dKO = dVar.Mh();
this.dKP = dVar.bG(false);
this.lVH = this.dKP.getWxaEntryInfoList();
if (this.dKP.Mi()) {
this.eOE.ZZ("near_field_service").setSummary(R.l.weixin_connect_wifi);
} else {
this.eOE.bw("near_field_service", true);
}
if (this.dKP.Mo() != null) {
this.lVK = true;
if (JE(this.dKP.Mo())) {
this.lVJ = true;
if (!com.tencent.mm.l.a.gd(this.guS.field_type)) {
x.w("MicroMsg.ContactWidgetBizInfo", "expireTime not null, and %s is not my contact", new Object[]{this.guS.field_username});
bnq();
if (s.hM(this.guS.field_username) || s.hW(this.guS.field_username)) {
bnq();
}
}
}
this.eOE.bw("contact_info_time_expired", true);
bnq();
} else {
this.eOE.bw("contact_info_time_expired", true);
}
if (this.dKP.Ml() != null && this.dKP.Ml().length() > 0) {
this.dKY = this.dKP.Ml();
}
this.dKW = this.dKP.Mj();
if (bi.oW(this.dKP.Mz())) {
this.eOE.bw("contact_info_service_phone", true);
} else {
this.eOE.bw("contact_info_service_phone", false);
ZZ = this.eOE.ZZ("contact_info_service_phone");
if (ZZ != null) {
ZZ.setSummary(this.dKP.Mz());
ZZ.hIZ = this.bGc.getResources().getColor(R.e.link_color);
}
}
} else {
this.eOE.bw("contact_info_time_expired", true);
x.e("MicroMsg.ContactWidgetBizInfo", "get biz info from storage, but return null");
}
if (bi.oW(this.guS.signature)) {
x.w("MicroMsg.ContactWidgetBizInfo", "has not desc info");
this.eOE.bw("contact_info_user_desc", true);
if (!this.lVJ) {
this.eOE.bw("contact_info_time_expired", true);
}
} else {
keyValuePreference = (KeyValuePreference) this.eOE.ZZ("contact_info_user_desc");
if (keyValuePreference != null) {
if (bi.oV(this.guS.signature).trim().length() <= 0) {
this.eOE.bw("contact_info_user_desc", true);
} else {
keyValuePreference.csl();
keyValuePreference.tCA = false;
keyValuePreference.tmc = this.bGc.getString(R.l.contact_info_isnot_verify_user_title);
keyValuePreference.setSummary(com.tencent.mm.pluginsdk.ui.d.j.a(this.bGc, this.guS.signature));
keyValuePreference.lO(false);
if (am.a.dBt != null) {
e = BackwardSupportUtil.b.e(am.a.dBt.gX(this.guS.field_verifyFlag), 2.0f);
} else {
e = null;
}
str = "MicroMsg.ContactWidgetBizInfo";
str2 = "verify bmp is null ? %B";
objArr = new Object[1];
if (e == null) {
z2 = true;
} else {
z2 = false;
}
objArr[0] = Boolean.valueOf(z2);
x.i(str, str2, objArr);
if (e != null) {
bitmapDrawable = new BitmapDrawable(this.bGc.getResources(), e);
} else {
bitmapDrawable = null;
}
keyValuePreference.tCI = bitmapDrawable;
keyValuePreference.tCG = 8;
}
}
}
if (this.dKP != null && this.dKP.Mt() != null && !bi.oW(this.dKP.Mt().dLJ)) {
b.d Mt = this.dKP.Mt();
keyValuePreference = (KeyValuePreference) this.eOE.ZZ("contact_info_verifyuser");
if (keyValuePreference != null) {
keyValuePreference.csl();
keyValuePreference.tCA = false;
if (bi.oW(Mt.dLK)) {
switch (Mt.dLI) {
case 0:
string = this.bGc.getResources().getString(R.l.contact_info_verify_user_title);
break;
case 1:
string = this.bGc.getResources().getString(R.l.brandservice_sweibo_verify);
break;
case 2:
string = this.bGc.getResources().getString(R.l.brandservice_tweibo_verify);
break;
default:
x.w("MicroMsg.ContactWidgetBizInfo", "getVerifyStr, error type %d", new Object[]{Integer.valueOf(Mt.dLI)});
string = this.bGc.getResources().getString(R.l.contact_info_isnot_verify_user_title);
break;
}
keyValuePreference.tmc = string;
} else {
keyValuePreference.tmc = Mt.dLK;
}
if (am.a.dBt != null) {
e2 = BackwardSupportUtil.b.e(am.a.dBt.gX(this.guS.field_verifyFlag), 2.0f);
} else {
e2 = null;
}
if (e2 != null) {
bitmapDrawable = new BitmapDrawable(this.bGc.getResources(), e2);
} else {
bitmapDrawable = null;
}
str2 = "MicroMsg.ContactWidgetBizInfo";
String str4 = "verify bmp is null ? %B";
Object[] objArr2 = new Object[1];
if (e2 == null) {
z2 = true;
} else {
z2 = false;
}
objArr2[0] = Boolean.valueOf(z2);
x.i(str2, str4, objArr2);
keyValuePreference.tCI = bitmapDrawable;
if (Mt.dLJ != null) {
str2 = Mt.dLM;
CharSequence a = com.tencent.mm.pluginsdk.ui.d.j.a(this.bGc, Mt.dLJ.trim());
if (bi.oW(str2)) {
charSequence = a;
} else {
try {
charSequence = new SpannableString(str2 + " " + a);
try {
charSequence.setSpan(new ForegroundColorSpan(-36352), 0, str2.length(), 17);
} catch (IndexOutOfBoundsException e4) {
e3 = e4;
x.e("MicroMsg.ContactWidgetBizInfo", "verifySummary setSpan error: %s", new Object[]{e3.getMessage()});
keyValuePreference.setSummary(charSequence);
if (this.dKP != null) {
}
x.w("MicroMsg.ContactWidgetBizInfo", "has not trademark info");
this.eOE.bw("contact_info_trademark", true);
if (this.dKP != null) {
}
this.eOE.bw("contact_info_privilege", true);
indexOf = this.eOE.indexOf("contact_info_category2");
if (indexOf >= 0) {
}
x.d("MicroMsg.ContactWidgetBizInfo", "pos no more");
if (!this.lVJ) {
}
this.eOE.bw("contact_info_verifyuser_weibo", true);
if (this.dKP != null) {
}
this.eOE.bw("contact_info_reputation", true);
this.eOE.bw("contact_info_guarantee_info", true);
this.eOE.bw("contact_info_scope_of_business", true);
if (this.lVH != null) {
}
this.eOE.bw("contact_info_bindwxainfo", true);
string = this.bGc.getIntent().getStringExtra("Contact_BIZ_KF_WORKER_ID");
x.d("MicroMsg.ContactWidgetBizInfo", "updateKF %s, %b", new Object[]{string, Boolean.valueOf(this.lVO)});
if (!this.lVO) {
this.lVN = string;
g kR;
IconWidgetPreference iconWidgetPreference;
if (this.dKP == null || !this.dKP.MA() || this.guS == null) {
this.eOE.bw("contact_info_kf_worker", true);
} else if (bi.oW(string)) {
kR = z.MX().kR(this.guS.field_username);
if (kR == null) {
this.eOE.bw("contact_info_kf_worker", true);
z.MZ().a(this);
z.MZ().ag(this.guS.field_username, com.tencent.mm.model.q.GF());
this.lVO = true;
} else {
x.d("MicroMsg.ContactWidgetBizInfo", "has default kf %s", new Object[]{kR.field_openId});
this.eOE.bw("contact_info_kf_worker", false);
iconWidgetPreference = (IconWidgetPreference) this.eOE.ZZ("contact_info_kf_worker");
iconWidgetPreference.setSummary(kR.field_nickname);
e2 = com.tencent.mm.aa.c.a(kR.field_openId, false, -1);
if (e2 == null) {
c(kR);
JF(kR.field_openId);
} else {
iconWidgetPreference.C(e2);
}
}
} else {
com.tencent.mm.ac.i MX = z.MX();
g kQ = MX.kQ(string);
if (kQ == null || com.tencent.mm.ac.i.a(kQ)) {
z.MZ().a(this);
z.MZ().ah(this.guS.field_username, string);
this.lVO = true;
}
if (kQ == null) {
x.d("MicroMsg.ContactWidgetBizInfo", "no such kf, get default kf");
kR = MX.kR(this.guS.field_username);
} else {
kR = kQ;
}
if (kR == null) {
this.eOE.bw("contact_info_kf_worker", true);
} else {
this.eOE.bw("contact_info_kf_worker", false);
iconWidgetPreference = (IconWidgetPreference) this.eOE.ZZ("contact_info_kf_worker");
iconWidgetPreference.setSummary(kR.field_nickname);
e2 = com.tencent.mm.aa.c.a(kR.field_openId, false, -1);
if (e2 == null) {
c(kR);
JF(kR.field_openId);
} else {
iconWidgetPreference.C(e2);
}
x.d("MicroMsg.ContactWidgetBizInfo", "kf worker %s, %s", new Object[]{kR.field_openId, kR.field_nickname});
}
}
}
x.d("MicroMsg.ContactWidgetBizInfo", "KIsardDevice(%b)", new Object[]{Boolean.valueOf(this.bGc.getIntent().getBooleanExtra("KIsHardDevice", false))});
if (this.bGc.getIntent() == null) {
}
if (com.tencent.mm.l.a.gd(this.guS.field_type)) {
if (dVar != null) {
checkBoxPreference = (CheckBoxPreference) this.eOE.ZZ("contact_info_subscribe_bizinfo");
checkBoxPreference2 = (CheckBoxPreference) this.eOE.ZZ("contact_info_locate");
if (dVar.Ma()) {
checkBoxPreference.setTitle(R.l.enterprise_chat_receive_msg);
this.lVG = z.Nc().cz(z.Nc().cA(dVar.field_username));
if (this.lVG != null) {
if (this.lVG.hu(4)) {
z2 = false;
} else {
z2 = true;
}
checkBoxPreference.qpJ = z2;
} else {
x.w("MicroMsg.ContactWidgetBizInfo", "bizChatMyuser bizChatUserInfo is null");
}
} else if (dVar.LY()) {
checkBoxPreference.setTitle(R.l.enterprise_brand_receive_msg);
checkBoxPreference.qpJ = !z.Nh().kr(dVar.field_username);
} else {
checkBoxPreference.qpJ = dVar.LQ();
}
if (dVar.LQ()) {
if (this.dKP == null && dVar != null) {
this.dKP = dVar.bG(false);
}
if (this.dKP != null && this.dKP.Mk() && com.tencent.mm.bg.d.QS("brandservice")) {
this.eOE.bw("contact_info_template_recv", false);
} else {
this.eOE.bw("contact_info_template_recv", true);
}
} else {
this.eOE.bw("contact_info_template_recv", true);
}
if (dVar.bG(false).LU()) {
checkBoxPreference2.qpJ = dVar.LR();
} else {
this.eOE.bw("contact_info_locate", true);
checkBoxPreference2.qpJ = dVar.LR();
}
} else {
this.eOE.bw("contact_info_subscribe_bizinfo", true);
this.eOE.bw("contact_info_locate", true);
this.eOE.bw("contact_info_template_recv", true);
}
this.eOE.bw("contact_info_biz_read_msg_online", true);
this.eOE.bw("contact_info_biz_add", true);
BL = this.guS.BL();
if (BL != null) {
this.bGc.setMMTitle(BL);
}
if (s.hr(this.guS.field_username)) {
this.eOE.ZZ("contact_info_biz_go_chatting").setTitle(R.l.contact_info_send);
this.bGc.setMMTitle(R.l.contact_info_title);
}
if (!s.hM(this.guS.field_username) && this.lUs != null) {
this.bGc.addIconOptionMenu(0, R.g.mm_title_btn_menu, new 18(this));
}
}
x.w("MicroMsg.ContactWidgetBizInfo", "%s is not my contact", new Object[]{this.guS.field_username});
bnq();
ZZ = this.eOE.ZZ("contact_info_biz_add");
if (ZZ != null && this.lVK) {
ZZ.setTitle(R.l.contact_info_biz_join);
}
if (uK(this.eLK)) {
if (dVar == null) {
x.e("MicroMsg.ContactWidgetBizInfo", "bizinfo is null in temp session");
} else {
((CheckBoxPreference) this.eOE.ZZ("contact_info_subscribe_bizinfo")).qpJ = dVar.LQ();
this.eOE.bw("contact_info_subscribe_bizinfo", false);
}
}
this.bGc.showOptionMenu(false);
}
} catch (IndexOutOfBoundsException e5) {
e3 = e5;
charSequence = a;
x.e("MicroMsg.ContactWidgetBizInfo", "verifySummary setSpan error: %s", new Object[]{e3.getMessage()});
keyValuePreference.setSummary(charSequence);
if (this.dKP != null) {
}
x.w("MicroMsg.ContactWidgetBizInfo", "has not trademark info");
this.eOE.bw("contact_info_trademark", true);
if (this.dKP != null) {
}
this.eOE.bw("contact_info_privilege", true);
indexOf = this.eOE.indexOf("contact_info_category2");
if (indexOf >= 0) {
}
x.d("MicroMsg.ContactWidgetBizInfo", "pos no more");
if (this.lVJ) {
}
this.eOE.bw("contact_info_verifyuser_weibo", true);
if (this.dKP != null) {
}
this.eOE.bw("contact_info_reputation", true);
this.eOE.bw("contact_info_guarantee_info", true);
this.eOE.bw("contact_info_scope_of_business", true);
if (this.lVH != null) {
}
this.eOE.bw("contact_info_bindwxainfo", true);
string = this.bGc.getIntent().getStringExtra("Contact_BIZ_KF_WORKER_ID");
x.d("MicroMsg.ContactWidgetBizInfo", "updateKF %s, %b", new Object[]{string, Boolean.valueOf(this.lVO)});
if (this.lVO) {
this.lVN = string;
g kR2;
IconWidgetPreference iconWidgetPreference2;
if (this.dKP == null || !this.dKP.MA() || this.guS == null) {
this.eOE.bw("contact_info_kf_worker", true);
} else if (bi.oW(string)) {
kR2 = z.MX().kR(this.guS.field_username);
if (kR2 == null) {
this.eOE.bw("contact_info_kf_worker", true);
z.MZ().a(this);
z.MZ().ag(this.guS.field_username, com.tencent.mm.model.q.GF());
this.lVO = true;
} else {
x.d("MicroMsg.ContactWidgetBizInfo", "has default kf %s", new Object[]{kR2.field_openId});
this.eOE.bw("contact_info_kf_worker", false);
iconWidgetPreference2 = (IconWidgetPreference) this.eOE.ZZ("contact_info_kf_worker");
iconWidgetPreference2.setSummary(kR2.field_nickname);
e2 = com.tencent.mm.aa.c.a(kR2.field_openId, false, -1);
if (e2 == null) {
c(kR2);
JF(kR2.field_openId);
} else {
iconWidgetPreference2.C(e2);
}
}
} else {
com.tencent.mm.ac.i MX2 = z.MX();
g kQ2 = MX2.kQ(string);
if (kQ2 == null || com.tencent.mm.ac.i.a(kQ2)) {
z.MZ().a(this);
z.MZ().ah(this.guS.field_username, string);
this.lVO = true;
}
if (kQ2 == null) {
x.d("MicroMsg.ContactWidgetBizInfo", "no such kf, get default kf");
kR2 = MX2.kR(this.guS.field_username);
} else {
kR2 = kQ2;
}
if (kR2 == null) {
this.eOE.bw("contact_info_kf_worker", true);
} else {
this.eOE.bw("contact_info_kf_worker", false);
iconWidgetPreference2 = (IconWidgetPreference) this.eOE.ZZ("contact_info_kf_worker");
iconWidgetPreference2.setSummary(kR2.field_nickname);
e2 = com.tencent.mm.aa.c.a(kR2.field_openId, false, -1);
if (e2 == null) {
c(kR2);
JF(kR2.field_openId);
} else {
iconWidgetPreference2.C(e2);
}
x.d("MicroMsg.ContactWidgetBizInfo", "kf worker %s, %s", new Object[]{kR2.field_openId, kR2.field_nickname});
}
}
}
x.d("MicroMsg.ContactWidgetBizInfo", "KIsardDevice(%b)", new Object[]{Boolean.valueOf(this.bGc.getIntent().getBooleanExtra("KIsHardDevice", false))});
if (this.bGc.getIntent() == null) {
}
if (com.tencent.mm.l.a.gd(this.guS.field_type)) {
x.w("MicroMsg.ContactWidgetBizInfo", "%s is not my contact", new Object[]{this.guS.field_username});
bnq();
ZZ = this.eOE.ZZ("contact_info_biz_add");
if (ZZ != null && this.lVK) {
ZZ.setTitle(R.l.contact_info_biz_join);
}
if (uK(this.eLK)) {
if (dVar == null) {
x.e("MicroMsg.ContactWidgetBizInfo", "bizinfo is null in temp session");
} else {
((CheckBoxPreference) this.eOE.ZZ("contact_info_subscribe_bizinfo")).qpJ = dVar.LQ();
this.eOE.bw("contact_info_subscribe_bizinfo", false);
}
}
this.bGc.showOptionMenu(false);
}
if (dVar != null) {
checkBoxPreference = (CheckBoxPreference) this.eOE.ZZ("contact_info_subscribe_bizinfo");
checkBoxPreference2 = (CheckBoxPreference) this.eOE.ZZ("contact_info_locate");
if (dVar.Ma()) {
checkBoxPreference.setTitle(R.l.enterprise_chat_receive_msg);
this.lVG = z.Nc().cz(z.Nc().cA(dVar.field_username));
if (this.lVG != null) {
if (this.lVG.hu(4)) {
z2 = false;
} else {
z2 = true;
}
checkBoxPreference.qpJ = z2;
} else {
x.w("MicroMsg.ContactWidgetBizInfo", "bizChatMyuser bizChatUserInfo is null");
}
} else if (dVar.LY()) {
checkBoxPreference.setTitle(R.l.enterprise_brand_receive_msg);
checkBoxPreference.qpJ = !z.Nh().kr(dVar.field_username);
} else {
checkBoxPreference.qpJ = dVar.LQ();
}
if (dVar.LQ()) {
if (this.dKP == null && dVar != null) {
this.dKP = dVar.bG(false);
}
if (this.dKP != null && this.dKP.Mk() && com.tencent.mm.bg.d.QS("brandservice")) {
this.eOE.bw("contact_info_template_recv", false);
} else {
this.eOE.bw("contact_info_template_recv", true);
}
} else {
this.eOE.bw("contact_info_template_recv", true);
}
if (dVar.bG(false).LU()) {
checkBoxPreference2.qpJ = dVar.LR();
} else {
this.eOE.bw("contact_info_locate", true);
checkBoxPreference2.qpJ = dVar.LR();
}
} else {
this.eOE.bw("contact_info_subscribe_bizinfo", true);
this.eOE.bw("contact_info_locate", true);
this.eOE.bw("contact_info_template_recv", true);
}
this.eOE.bw("contact_info_biz_read_msg_online", true);
this.eOE.bw("contact_info_biz_add", true);
BL = this.guS.BL();
if (BL != null) {
this.bGc.setMMTitle(BL);
}
if (s.hr(this.guS.field_username)) {
this.eOE.ZZ("contact_info_biz_go_chatting").setTitle(R.l.contact_info_send);
this.bGc.setMMTitle(R.l.contact_info_title);
}
if (!s.hM(this.guS.field_username) && this.lUs != null) {
this.bGc.addIconOptionMenu(0, R.g.mm_title_btn_menu, new 18(this));
}
}
}
keyValuePreference.setSummary(charSequence);
} else {
x.e("MicroMsg.ContactWidgetBizInfo", "[arthurdan.emojiSpan] Notice!!!! extInfo.verifyInfo.verifySourceDescription is null");
}
} else {
this.eOE.bw("contact_info_verifyuser", true);
}
} else if (this.dKP == null || this.dKP.Mu() == null || bi.oW(this.dKP.Mu().dLS)) {
x.w("MicroMsg.ContactWidgetBizInfo", "has not verify info");
this.eOE.bw("contact_info_verifyuser", true);
} else {
keyValuePreference = (KeyValuePreference) this.eOE.ZZ("contact_info_verifyuser");
if (keyValuePreference != null) {
keyValuePreference.setSummary(this.dKP.Mu().dLS);
}
}
if (this.dKP != null || bi.oW(this.dKP.Mn())) {
x.w("MicroMsg.ContactWidgetBizInfo", "has not trademark info");
this.eOE.bw("contact_info_trademark", true);
} else {
keyValuePreference = (KeyValuePreference) this.eOE.ZZ("contact_info_trademark");
if (keyValuePreference != null) {
keyValuePreference.csl();
keyValuePreference.tCA = false;
if (am.a.dBt != null) {
e = com.tencent.mm.sdk.platformtools.c.CV(R.k.biz_info_trademark_protection);
} else {
e = null;
}
str = "MicroMsg.ContactWidgetBizInfo";
str2 = "trademark bmp is null ? %B";
objArr = new Object[1];
if (e == null) {
z2 = true;
} else {
z2 = false;
}
objArr[0] = Boolean.valueOf(z2);
x.i(str, str2, objArr);
if (e != null) {
bitmapDrawable = new BitmapDrawable(this.bGc.getResources(), e);
} else {
bitmapDrawable = null;
}
keyValuePreference.tCI = bitmapDrawable;
keyValuePreference.setSummary(this.dKP.Mn());
x.d("MicroMsg.ContactWidgetBizInfo", "trademark name : %s, url : %s.", new Object[]{this.dKP.Mn(), this.dKP.Mm()});
}
}
if (this.dKP != null || this.dKP.Mp() == null || this.dKP.Mp().size() <= 0) {
this.eOE.bw("contact_info_privilege", true);
} else {
keyValuePreference = (KeyValuePreference) this.eOE.ZZ("contact_info_privilege");
keyValuePreference.csl();
keyValuePreference.lO(false);
keyValuePreference.csk();
for (b.f fVar2 : this.dKP.Mp()) {
LinearLayout linearLayout = (LinearLayout) View.inflate(this.bGc, R.i.keyvalue_pref_item, null);
((ImageView) linearLayout.findViewById(R.h.image_iv)).setImageDrawable(new com.tencent.mm.plugin.profile.ui.b.a(this.bGc.getResources(), fVar2.iconUrl));
CharSequence charSequence2 = fVar2.description;
identifier = this.bGc.getResources().getIdentifier(fVar2.dLR, "string", this.bGc.getPackageName());
if (identifier > 0) {
charSequence2 = this.bGc.getString(identifier);
}
((TextView) linearLayout.findViewById(R.h.summary)).setText(charSequence2);
keyValuePreference.dp(linearLayout);
}
}
indexOf = this.eOE.indexOf("contact_info_category2");
if (indexOf >= 0 || this.dKO == null || this.dKO.size() <= 0) {
x.d("MicroMsg.ContactWidgetBizInfo", "pos no more");
} else {
int size = this.dKO.size() - 1;
while (size >= 0) {
if (this.dKO.get(size) != null && ((!this.bGc.getString(R.l.contact_info_biz_participants).equals(((d.a) this.dKO.get(size)).title) || this.dKW) && !(bi.oW(((d.a) this.dKO.get(size)).title) && bi.oW(((d.a) this.dKO.get(size)).dKS)))) {
Preference preference = new Preference(this.bGc);
preference.setKey("contact_info_bizinfo_external#" + size);
charSequence = ((d.a) this.dKO.get(size)).title;
int identifier2 = this.bGc.getResources().getIdentifier(((d.a) this.dKO.get(size)).dKS, "string", this.bGc.getPackageName());
if (identifier2 > 0) {
charSequence = this.bGc.getString(identifier2);
}
if (this.lUs.LX() && ("__mp_wording__brandinfo_history_massmsg".equals(((d.a) this.dKO.get(size)).dKS) || r1.equals(this.bGc.getString(R.l.__mp_wording__brandinfo_history_massmsg)))) {
charSequence = this.bGc.getString(R.l.enterprise_brand_history);
}
preference.setTitle(charSequence);
if (!bi.oW(((d.a) this.dKO.get(size)).description)) {
preference.setSummary(((d.a) this.dKO.get(size)).description);
}
if (bi.oV(((d.a) this.dKO.get(size)).dKS).equals("__mp_wording__brandinfo_feedback")) {
identifier2 = this.eOE.indexOf("contact_info_scope_of_business");
if (identifier2 > 0) {
identifier = identifier2 + 1;
this.eOE.a(preference, identifier);
if (bi.oV(((d.a) this.dKO.get(size)).dKS).equals("__mp_wording__brandinfo_biz_detail")) {
this.eOE.a(new PreferenceSmallCategory(this.bGc), identifier);
}
}
}
identifier = indexOf;
this.eOE.a(preference, identifier);
if (bi.oV(((d.a) this.dKO.get(size)).dKS).equals("__mp_wording__brandinfo_biz_detail")) {
this.eOE.a(new PreferenceSmallCategory(this.bGc), identifier);
}
}
size--;
}
}
if (this.lVJ || !s.v(this.guS) || this.guS.csO == null || this.guS.csO.equals("")) {
this.eOE.bw("contact_info_verifyuser_weibo", true);
} else {
keyValuePreference = (KeyValuePreference) this.eOE.ZZ("contact_info_verifyuser_weibo");
if (keyValuePreference != null) {
keyValuePreference.setSummary(bi.aG(this.guS.field_weiboNickname, "") + this.bGc.getString(R.l.settings_show_weibo_field, new Object[]{s.hV(this.guS.csO)}));
keyValuePreference.hIZ = com.tencent.mm.bp.a.g(this.bGc, R.e.link_color);
keyValuePreference.lO(false);
}
}
if (this.dKP != null || this.dKP.Mr() == null) {
this.eOE.bw("contact_info_reputation", true);
this.eOE.bw("contact_info_guarantee_info", true);
this.eOE.bw("contact_info_scope_of_business", true);
} else {
BizInfoPayInfoIconPreference bizInfoPayInfoIconPreference = (BizInfoPayInfoIconPreference) this.eOE.ZZ("contact_info_reputation");
if (this.dKP.Mr().dLN > 0) {
bizInfoPayInfoIconPreference.uD(this.dKP.Mr().dLN);
} else {
this.eOE.bw("contact_info_reputation", true);
}
bizInfoPayInfoIconPreference = (BizInfoPayInfoIconPreference) this.eOE.ZZ("contact_info_guarantee_info");
if (this.dKP.Mr().dLP == null || this.dKP.Mr().dLP.size() <= 0) {
this.eOE.bw("contact_info_guarantee_info", true);
} else {
bizInfoPayInfoIconPreference.bH(this.dKP.Mr().dLP);
}
keyValuePreference = (KeyValuePreference) this.eOE.ZZ("contact_info_scope_of_business");
if (bi.oW(this.dKP.Mr().dLO)) {
this.eOE.bw("contact_info_scope_of_business", true);
} else {
keyValuePreference.setSummary(this.dKP.Mr().dLO);
keyValuePreference.tCG = 4;
keyValuePreference.lO(false);
}
}
if (this.lVH != null || this.lVH.size() <= 0) {
this.eOE.bw("contact_info_bindwxainfo", true);
} else {
this.eOE.bw("contact_info_bindwxainfo", false);
BizBindWxaInfoPreference bizBindWxaInfoPreference = (BizBindWxaInfoPreference) this.eOE.ZZ("contact_info_bindwxainfo");
d dVar2 = this.lUs;
Collection collection = this.lVH;
bizBindWxaInfoPreference.lUg = true;
bizBindWxaInfoPreference.eXL = dVar2;
if (bizBindWxaInfoPreference.gEP == null) {
bizBindWxaInfoPreference.gEP = new LinkedList();
} else {
bizBindWxaInfoPreference.gEP.clear();
}
if (!(collection == null || collection.isEmpty())) {
bizBindWxaInfoPreference.gEP.addAll(collection);
}
bizBindWxaInfoPreference.aeP();
}
string = this.bGc.getIntent().getStringExtra("Contact_BIZ_KF_WORKER_ID");
x.d("MicroMsg.ContactWidgetBizInfo", "updateKF %s, %b", new Object[]{string, Boolean.valueOf(this.lVO)});
if (this.lVO) {
this.lVN = string;
g kR22;
IconWidgetPreference iconWidgetPreference22;
if (this.dKP == null || !this.dKP.MA() || this.guS == null) {
this.eOE.bw("contact_info_kf_worker", true);
} else if (bi.oW(string)) {
kR22 = z.MX().kR(this.guS.field_username);
if (kR22 == null) {
this.eOE.bw("contact_info_kf_worker", true);
z.MZ().a(this);
z.MZ().ag(this.guS.field_username, com.tencent.mm.model.q.GF());
this.lVO = true;
} else {
x.d("MicroMsg.ContactWidgetBizInfo", "has default kf %s", new Object[]{kR22.field_openId});
this.eOE.bw("contact_info_kf_worker", false);
iconWidgetPreference22 = (IconWidgetPreference) this.eOE.ZZ("contact_info_kf_worker");
iconWidgetPreference22.setSummary(kR22.field_nickname);
e2 = com.tencent.mm.aa.c.a(kR22.field_openId, false, -1);
if (e2 == null) {
c(kR22);
JF(kR22.field_openId);
} else {
iconWidgetPreference22.C(e2);
}
}
} else {
com.tencent.mm.ac.i MX22 = z.MX();
g kQ22 = MX22.kQ(string);
if (kQ22 == null || com.tencent.mm.ac.i.a(kQ22)) {
z.MZ().a(this);
z.MZ().ah(this.guS.field_username, string);
this.lVO = true;
}
if (kQ22 == null) {
x.d("MicroMsg.ContactWidgetBizInfo", "no such kf, get default kf");
kR22 = MX22.kR(this.guS.field_username);
} else {
kR22 = kQ22;
}
if (kR22 == null) {
this.eOE.bw("contact_info_kf_worker", true);
} else {
this.eOE.bw("contact_info_kf_worker", false);
iconWidgetPreference22 = (IconWidgetPreference) this.eOE.ZZ("contact_info_kf_worker");
iconWidgetPreference22.setSummary(kR22.field_nickname);
e2 = com.tencent.mm.aa.c.a(kR22.field_openId, false, -1);
if (e2 == null) {
c(kR22);
JF(kR22.field_openId);
} else {
iconWidgetPreference22.C(e2);
}
x.d("MicroMsg.ContactWidgetBizInfo", "kf worker %s, %s", new Object[]{kR22.field_openId, kR22.field_nickname});
}
}
}
x.d("MicroMsg.ContactWidgetBizInfo", "KIsardDevice(%b)", new Object[]{Boolean.valueOf(this.bGc.getIntent().getBooleanExtra("KIsHardDevice", false))});
if (this.bGc.getIntent() == null && this.bGc.getIntent().getBooleanExtra("KIsHardDevice", false)) {
x.d("MicroMsg.ContactWidgetBizInfo", "Hard device biz...");
z = bns();
x.d("MicroMsg.ContactWidgetBizInfo", "contact.isContact()(%b), isHardDeviceBound(%b)", new Object[]{Boolean.valueOf(com.tencent.mm.l.a.gd(this.guS.field_type)), Boolean.valueOf(z)});
if (com.tencent.mm.l.a.gd(this.guS.field_type) && z) {
if (dVar != null) {
checkBoxPreference = (CheckBoxPreference) this.eOE.ZZ("contact_info_subscribe_bizinfo");
checkBoxPreference2 = (CheckBoxPreference) this.eOE.ZZ("contact_info_locate");
if (dVar.Ma()) {
this.lVG = z.Nc().cz(z.Nc().cA(dVar.field_username));
if (this.lVG != null) {
checkBoxPreference.qpJ = !this.lVG.hu(4);
} else {
x.w("MicroMsg.ContactWidgetBizInfo", "bizChatMyuser bizChatUserInfo is null");
}
} else {
checkBoxPreference.qpJ = dVar.LQ();
}
if (dVar.LQ()) {
if (this.dKP == null && dVar != null) {
this.dKP = dVar.bG(false);
}
if (this.dKP != null && this.dKP.Mk() && com.tencent.mm.bg.d.QS("brandservice")) {
this.eOE.bw("contact_info_template_recv", false);
} else {
this.eOE.bw("contact_info_template_recv", true);
}
} else {
this.eOE.bw("contact_info_template_recv", true);
}
if (dVar.bG(false).LU()) {
checkBoxPreference2.qpJ = dVar.LR();
} else {
this.eOE.bw("contact_info_locate", true);
checkBoxPreference2.qpJ = dVar.LR();
}
} else {
this.eOE.bw("contact_info_subscribe_bizinfo", true);
this.eOE.bw("contact_info_locate", true);
this.eOE.bw("contact_info_template_recv", true);
}
this.eOE.bw("contact_info_biz_read_msg_online", true);
this.eOE.bw("contact_info_biz_add", true);
BL = this.guS.BL();
if (BL != null) {
this.bGc.setMMTitle(BL);
}
if (s.hr(this.guS.field_username)) {
this.eOE.ZZ("contact_info_biz_go_chatting").setTitle(R.l.contact_info_send);
this.bGc.setMMTitle(R.l.contact_info_title);
}
if (!s.hM(this.guS.field_username) && this.lUs != null && !this.lUs.LZ()) {
this.bGc.addIconOptionMenu(0, R.g.mm_title_btn_menu, new 17(this));
return;
}
return;
}
x.w("MicroMsg.ContactWidgetBizInfo", "%s is not my hard biz contact", new Object[]{this.guS.field_username});
bnq();
Preference ZZ2 = this.eOE.ZZ("contact_info_biz_add");
x.d("MicroMsg.ContactWidgetBizInfo", "isBizConferenceAccount(%b)", new Object[]{Boolean.valueOf(this.lVK)});
if (ZZ2 != null) {
if (z) {
ZZ2.setTitle(R.l.contact_info_biz_join);
} else {
ZZ2.setTitle(R.l.contact_info_biz_bind_exdevice);
}
}
if (uK(this.eLK)) {
if (dVar == null) {
x.e("MicroMsg.ContactWidgetBizInfo", "bizinfo is null in temp session");
} else {
((CheckBoxPreference) this.eOE.ZZ("contact_info_subscribe_bizinfo")).qpJ = dVar.LQ();
this.eOE.bw("contact_info_subscribe_bizinfo", false);
}
}
this.bGc.showOptionMenu(false);
} else if (com.tencent.mm.l.a.gd(this.guS.field_type)) {
if (dVar != null) {
checkBoxPreference = (CheckBoxPreference) this.eOE.ZZ("contact_info_subscribe_bizinfo");
checkBoxPreference2 = (CheckBoxPreference) this.eOE.ZZ("contact_info_locate");
if (dVar.Ma()) {
checkBoxPreference.setTitle(R.l.enterprise_chat_receive_msg);
this.lVG = z.Nc().cz(z.Nc().cA(dVar.field_username));
if (this.lVG != null) {
if (this.lVG.hu(4)) {
z2 = false;
} else {
z2 = true;
}
checkBoxPreference.qpJ = z2;
} else {
x.w("MicroMsg.ContactWidgetBizInfo", "bizChatMyuser bizChatUserInfo is null");
}
} else if (dVar.LY()) {
checkBoxPreference.setTitle(R.l.enterprise_brand_receive_msg);
checkBoxPreference.qpJ = !z.Nh().kr(dVar.field_username);
} else {
checkBoxPreference.qpJ = dVar.LQ();
}
if (dVar.LQ()) {
if (this.dKP == null && dVar != null) {
this.dKP = dVar.bG(false);
}
if (this.dKP != null && this.dKP.Mk() && com.tencent.mm.bg.d.QS("brandservice")) {
this.eOE.bw("contact_info_template_recv", false);
} else {
this.eOE.bw("contact_info_template_recv", true);
}
} else {
this.eOE.bw("contact_info_template_recv", true);
}
if (dVar.bG(false).LU()) {
checkBoxPreference2.qpJ = dVar.LR();
} else {
this.eOE.bw("contact_info_locate", true);
checkBoxPreference2.qpJ = dVar.LR();
}
} else {
this.eOE.bw("contact_info_subscribe_bizinfo", true);
this.eOE.bw("contact_info_locate", true);
this.eOE.bw("contact_info_template_recv", true);
}
this.eOE.bw("contact_info_biz_read_msg_online", true);
this.eOE.bw("contact_info_biz_add", true);
BL = this.guS.BL();
if (BL != null) {
this.bGc.setMMTitle(BL);
}
if (s.hr(this.guS.field_username)) {
this.eOE.ZZ("contact_info_biz_go_chatting").setTitle(R.l.contact_info_send);
this.bGc.setMMTitle(R.l.contact_info_title);
}
if (!s.hM(this.guS.field_username) && this.lUs != null) {
this.bGc.addIconOptionMenu(0, R.g.mm_title_btn_menu, new 18(this));
}
} else {
x.w("MicroMsg.ContactWidgetBizInfo", "%s is not my contact", new Object[]{this.guS.field_username});
bnq();
ZZ = this.eOE.ZZ("contact_info_biz_add");
if (ZZ != null && this.lVK) {
ZZ.setTitle(R.l.contact_info_biz_join);
}
if (uK(this.eLK)) {
if (dVar == null) {
x.e("MicroMsg.ContactWidgetBizInfo", "bizinfo is null in temp session");
} else {
((CheckBoxPreference) this.eOE.ZZ("contact_info_subscribe_bizinfo")).qpJ = dVar.LQ();
this.eOE.bw("contact_info_subscribe_bizinfo", false);
}
}
this.bGc.showOptionMenu(false);
}
}
private void bnq() {
if (this.guS == null || !com.tencent.mm.l.a.gd(this.guS.field_type) || s.hr(this.guS.field_username) || s.hW(this.guS.field_username)) {
this.eOE.bw("contact_is_mute", true);
if (this.guS == null || com.tencent.mm.l.a.gd(this.guS.field_type) || !uK(this.eLK)) {
this.eOE.bw("contact_info_expose_btn", true);
} else {
this.eOE.bw("contact_info_expose_btn", false);
}
} else {
this.eOE.bw("contact_is_mute", false);
}
this.eOE.bw("contact_info_verifyuser_weibo", true);
this.eOE.bw("contact_info_subscribe_bizinfo", true);
this.eOE.bw("contact_info_template_recv", true);
this.eOE.bw("contact_info_locate", true);
if (this.lVJ) {
this.eOE.bw("contact_info_biz_add", true);
} else {
this.eOE.bw("contact_info_time_expired", true);
}
if (this.guS == null || !((s.hM(this.guS.field_username) || s.hW(this.guS.field_username)) && com.tencent.mm.l.a.gd(this.guS.field_type))) {
this.eOE.bw("contact_info_biz_go_chatting", true);
} else {
this.eOE.bw("contact_info_biz_go_chatting", false);
}
if (s.hW(this.guS.field_username)) {
this.eOE.bw("contact_info_user_desc", true);
}
}
public final boolean auw() {
BizInfoHeaderPreference bizInfoHeaderPreference = (BizInfoHeaderPreference) this.eOE.ZZ("contact_info_header_bizinfo");
if (bizInfoHeaderPreference != null) {
bizInfoHeaderPreference.onDetach();
}
return true;
}
public final void onActivityResult(int i, int i2, Intent intent) {
if (this.bGc == null) {
x.e("MicroMsg.ContactWidgetBizInfo", "null == context");
return;
}
x.i("MicroMsg.ContactWidgetBizInfo", "onActivityResult, requestCode = %d, resultCode = %d", new Object[]{Integer.valueOf(i), Integer.valueOf(i2)});
switch (i) {
case 1:
if (i2 == -1 && intent != null) {
String stringExtra = intent.getStringExtra("be_send_card_name");
String stringExtra2 = intent.getStringExtra("received_card_name");
boolean booleanExtra = intent.getBooleanExtra("Is_Chatroom", false);
String stringExtra3 = intent.getStringExtra("custom_send_text");
com.tencent.mm.plugin.messenger.a.g.bcT().l(stringExtra, stringExtra2, booleanExtra);
com.tencent.mm.plugin.messenger.a.g.bcT().dF(stringExtra3, stringExtra2);
com.tencent.mm.ui.widget.snackbar.b.h(this.bGc, this.bGc.getString(R.l.finish_sent));
return;
}
return;
default:
return;
}
}
private static boolean JE(String str) {
try {
long j = bi.getLong(str, 0);
if (j <= 0 || j - (System.currentTimeMillis() / 1000) >= 0) {
return false;
}
return true;
} catch (Exception e) {
return false;
}
}
final void ay(int i, String str) {
if (this.lVQ == null || !(this.eLK == 39 || this.eLK == 56 || this.eLK == 35 || this.eLK == 87 || this.eLK == 88 || this.eLK == 89 || this.eLK == 85)) {
x.d("MicroMsg.ContactWidgetBizInfo", "mExtArgs is null or the add contact action is not from biz search.");
} else if (this.guS == null) {
x.i("MicroMsg.ContactWidgetBizInfo", "contact is null.");
} else {
int i2;
String string = this.lVQ.getString("Contact_Ext_Args_Search_Id");
String oV = bi.oV(this.lVQ.getString("Contact_Ext_Args_Query_String"));
int i3 = this.lVQ.getInt("Contact_Ext_Args_Index");
switch (this.eLK) {
case a$k.AppCompatTheme_actionModeSelectAllDrawable /*35*/:
i2 = 1;
break;
case a$k.AppCompatTheme_colorControlNormal /*85*/:
i2 = 5;
break;
case a$k.AppCompatTheme_colorControlHighlight /*87*/:
i2 = 2;
break;
case a$k.AppCompatTheme_colorButtonNormal /*88*/:
i2 = 3;
break;
case a$k.AppCompatTheme_colorSwitchThumbNormal /*89*/:
i2 = 4;
break;
default:
i2 = 0;
break;
}
String oV2 = bi.oV(this.lVQ.getString("Contact_Ext_Extra_Params"));
String str2 = oV + "," + i + "," + bi.oV(this.guS.field_username) + "," + i3 + "," + (System.currentTimeMillis() / 1000) + "," + string + "," + i2;
if (bi.oW(str)) {
str2 = str2 + ",," + oV2;
} else {
str2 = str2 + "," + str + "," + oV2;
}
x.v("MicroMsg.ContactWidgetBizInfo", "report 10866: %s", new Object[]{str2});
h.mEJ.k(10866, str2);
}
}
final void bnr() {
if (this.bGc.getIntent() != null && this.bGc.getIntent().getBooleanExtra("KIsHardDevice", false)) {
String stringExtra = this.bGc.getIntent().getStringExtra("KHardDeviceBindTicket");
if (bi.oW(stringExtra)) {
x.i("MicroMsg.ContactWidgetBizInfo", "bindTicket is null, means it is not switch from QRcode scan, just add contact");
} else if (!bns()) {
x.d("MicroMsg.ContactWidgetBizInfo", "IsHardDevice, bindTicket = %s", new Object[]{stringExtra});
au.DF().a(536, this);
cv cvVar = new cv();
cvVar.bKm.bKo = stringExtra;
cvVar.bKm.opType = 1;
com.tencent.mm.sdk.b.a.sFg.m(cvVar);
l lVar = cvVar.bKn.bKq;
MMActivity mMActivity = this.bGc;
this.bGc.getString(R.l.app_tip);
this.tipDialog = com.tencent.mm.ui.base.h.a(mMActivity, this.bGc.getString(R.l.app_waiting), true, new 5(this, lVar));
return;
}
}
com.tencent.mm.pluginsdk.ui.applet.a aVar = new com.tencent.mm.pluginsdk.ui.applet.a(this.bGc, new 6(this));
LinkedList linkedList = new LinkedList();
linkedList.add(Integer.valueOf(this.eLK));
if (this.dKY != null) {
aVar.qHZ = this.dKY;
}
if (!bi.oW(this.juZ)) {
aVar.juZ = this.juZ;
}
aVar.qIf = true;
aVar.a(this.guS.field_username, linkedList, this.lVS);
}
private boolean bns() {
if (this.bGc.getIntent() == null) {
return false;
}
String stringExtra = this.bGc.getIntent().getStringExtra("device_id");
String stringExtra2 = this.bGc.getIntent().getStringExtra("device_type");
cz czVar = new cz();
czVar.bKx.byN = stringExtra;
czVar.bKx.bKv = stringExtra2;
com.tencent.mm.sdk.b.a.sFg.m(czVar);
return czVar.bKy.bKz;
}
final void bnt() {
if (this.guS != null && !bi.oW(this.guS.field_username)) {
Intent intent = new Intent();
intent.putExtra("rawUrl", String.format("https://mp.weixin.qq.com/mp/infringement?username=%s&from=1#wechat_redirect", new Object[]{this.guS.field_username}));
intent.putExtra("showShare", false);
com.tencent.mm.bg.d.b(this.bGc, "webview", ".ui.tools.WebViewUI", intent);
}
}
private void ha(boolean z) {
if (this.guS != null) {
if (this.bGc != null) {
if (!z || com.tencent.mm.ac.f.eZ(this.guS.field_username)) {
this.bGc.setTitleMuteIconVisibility(8);
} else {
this.bGc.setTitleMuteIconVisibility(0);
}
}
CheckBoxPreference checkBoxPreference = (CheckBoxPreference) this.eOE.ZZ("contact_is_mute");
if (checkBoxPreference != null) {
checkBoxPreference.qpJ = z;
}
}
}
private void JF(final String str) {
ah.i(new Runnable() {
public final void run() {
if (c.this.eOE == null) {
x.w("MicroMsg.ContactWidgetBizInfo", "LazyGetAvatar screen is null");
return;
}
IconWidgetPreference iconWidgetPreference = (IconWidgetPreference) c.this.eOE.ZZ("contact_info_kf_worker");
if (iconWidgetPreference != null && c.this.eOE != null) {
Bitmap a = com.tencent.mm.aa.c.a(str, false, -1);
if (a != null) {
x.d("MicroMsg.ContactWidgetBizInfo", "LazyGetAvatar success %s, update screen", new Object[]{str});
iconWidgetPreference.C(a);
c.this.eOE.notifyDataSetChanged();
}
}
}
}, 2000);
}
private static void c(g gVar) {
long currentTimeMillis = System.currentTimeMillis();
k KH = q.KH();
if (KH.kc(gVar.field_openId) == null) {
com.tencent.mm.aa.j jVar = new com.tencent.mm.aa.j();
jVar.username = gVar.field_openId;
jVar.dHQ = gVar.field_headImgUrl;
jVar.by(false);
jVar.csA = 3;
KH.a(jVar);
}
q.KJ().jP(gVar.field_openId);
x.d("MicroMsg.ContactWidgetBizInfo", "downloadKFAvatar, %d", new Object[]{Long.valueOf(System.currentTimeMillis() - currentTimeMillis)});
}
public final void a(int i, int i2, String str, l lVar) {
bls bls = null;
x.d("MicroMsg.ContactWidgetBizInfo", "onSceneEnd errType = " + i + ", errCode = " + i2 + ",errMsg = " + str);
this.lVO = false;
if (this.tipDialog != null && this.tipDialog.isShowing()) {
this.tipDialog.dismiss();
}
if (lVar == null) {
x.e("MicroMsg.ContactWidgetBizInfo", "scene == null");
return;
}
au.DF().b(lVar.getType(), this);
if (i == 0 && i2 == 0) {
x.d("MicroMsg.ContactWidgetBizInfo", "scene.getType() = %s", new Object[]{Integer.valueOf(lVar.getType())});
if (lVar.getType() == 536) {
au.DF().b(536, this);
bnp();
return;
} else if (lVar.getType() == 1363) {
blt blt;
com.tencent.mm.plugin.profile.a.b bVar = (com.tencent.mm.plugin.profile.a.b) lVar;
if (bVar.diG == null || bVar.diG.dIE.dIL == null) {
blt = null;
} else {
blt = (blt) bVar.diG.dIE.dIL;
}
com.tencent.mm.plugin.profile.a.b bVar2 = (com.tencent.mm.plugin.profile.a.b) lVar;
if (!(bVar2.diG == null || bVar2.diG.dID.dIL == null)) {
bls = (bls) bVar2.diG.dID.dIL;
}
if (blt == null || blt.riQ == null || blt.riQ.ret != 0 || blt.riN == null || bi.oW(blt.riN.riL)) {
if (blt == null || blt.riQ == null) {
x.w("MicroMsg.ContactWidgetBizInfo", "willen onSceneEnd err:resp == null");
return;
}
x.w("MicroMsg.ContactWidgetBizInfo", "willen onSceneEnd err:code:%s", new Object[]{Integer.valueOf(blt.riQ.ret)});
return;
} else if (blt.riN == null) {
x.w("MicroMsg.ContactWidgetBizInfo", "willen onSceneEnd resp.user == null");
return;
} else {
j cz = z.Nc().cz(blt.riN.riL);
if (cz == null) {
cz = new j();
cz.field_userId = blt.riN.riL;
}
cz.field_userName = blt.riN.hyG;
cz.field_brandUserName = bls.riK;
cz.field_UserVersion = blt.riN.ver;
cz.field_headImageUrl = blt.riN.riF;
cz.field_profileUrl = blt.riN.riT;
cz.field_bitFlag = blt.riN.riG;
cz.field_addMemberUrl = blt.riN.riJ;
cz.field_needToUpdate = false;
if (!z.Nc().b(cz)) {
z.Nc().a(cz);
return;
}
return;
}
} else if (lVar.getType() == 1394) {
brs bnl = ((com.tencent.mm.plugin.profile.a.c) lVar).bnl();
brt bnk = ((com.tencent.mm.plugin.profile.a.c) lVar).bnk();
if (bnk != null && bnk.riQ != null && bnk.riQ.ret == 0) {
boolean z;
if (bnl.spC) {
z = false;
} else {
z = true;
}
d dVar;
if (z) {
ai aiVar;
dVar = this.lUs;
dVar.field_brandFlag &= -2;
a(dVar, true);
au.HU();
if (com.tencent.mm.model.c.FW().Yq(dVar.field_username) == null) {
aiVar = new ai(dVar.field_username);
aiVar.ef(bi.oV(this.lUs.Mg()));
au.HU();
bd GE = com.tencent.mm.model.c.FT().GE(dVar.field_username);
if (GE != null) {
au.HU();
com.tencent.mm.model.c.FW().d(aiVar);
au.HU();
com.tencent.mm.model.c.FW().ak(GE);
} else {
aiVar.clx();
au.HU();
com.tencent.mm.model.c.FW().d(aiVar);
}
}
au.HU();
if (com.tencent.mm.model.c.FW().Yq(dVar.field_enterpriseFather) == null) {
aiVar = new ai(dVar.field_enterpriseFather);
aiVar.clx();
au.HU();
com.tencent.mm.model.c.FW().d(aiVar);
return;
}
au.HU();
com.tencent.mm.model.c.FV().XJ(dVar.field_enterpriseFather);
return;
}
dVar = this.lUs;
dVar.field_brandFlag |= 1;
a(dVar, true);
au.HU();
com.tencent.mm.model.c.FW().Yp(dVar.field_username);
au.HU();
if (com.tencent.mm.model.c.FW().YC(dVar.field_enterpriseFather) <= 0) {
au.HU();
com.tencent.mm.model.c.FW().Yp(dVar.field_enterpriseFather);
return;
}
au.HU();
com.tencent.mm.model.c.FV().XJ(dVar.field_enterpriseFather);
return;
} else if (bnk == null || bnk.riQ == null) {
x.w("MicroMsg.ContactWidgetBizInfo", "chuangchen onSceneEnd type:%s, err:resp == null", new Object[]{Integer.valueOf(lVar.getType())});
return;
} else {
x.w("MicroMsg.ContactWidgetBizInfo", "chuangchen onSceneEnd type:%s, err:code:%s", new Object[]{Integer.valueOf(lVar.getType()), Integer.valueOf(bnk.riQ.ret)});
return;
}
} else if (lVar.getType() == 1343) {
bnp();
return;
} else if (lVar.getType() == 1228) {
bnp();
return;
} else {
return;
}
}
x.e("MicroMsg.ContactWidgetBizInfo", "scene.getType() = %s", new Object[]{Integer.valueOf(lVar.getType())});
}
public final void d(LinkedList<cgc> linkedList) {
z.MZ().b(this);
if (this.eOE == null) {
x.e("MicroMsg.ContactWidgetBizInfo", "onKFSceneEnd, screen is null");
} else if (this.guS == null) {
x.e("MicroMsg.ContactWidgetBizInfo", "onKFSceneEnd, contact is null");
} else if (linkedList == null || linkedList.size() <= 0) {
x.w("MicroMsg.ContactWidgetBizInfo", "onKFSceneEnd, worker is null");
} else {
if (!bi.oW(this.lVN)) {
Iterator it = linkedList.iterator();
while (it.hasNext()) {
cgc cgc = (cgc) it.next();
if (cgc.sAB != null && cgc.sAB.equals(this.lVN)) {
this.eOE.bw("contact_info_kf_worker", false);
this.eOE.ZZ("contact_info_kf_worker").setSummary(cgc.rTW);
return;
}
}
}
this.eOE.bw("contact_info_kf_worker", false);
this.eOE.ZZ("contact_info_kf_worker").setSummary(((cgc) linkedList.get(0)).rTW);
}
}
public final void a(int i, l lVar) {
if (this.lUs != null && this.lUs.Ma() && lVar.getType() == 1354) {
CheckBoxPreference checkBoxPreference = (CheckBoxPreference) this.eOE.ZZ("contact_info_subscribe_bizinfo");
this.lVG = z.Nc().cz(z.Nc().cA(this.lUs.field_username));
if (this.lVG != null) {
checkBoxPreference.qpJ = !this.lVG.hu(4);
this.eOE.notifyDataSetChanged();
return;
}
x.w("MicroMsg.ContactWidgetBizInfo", "bizChatMyuser bizChatUserInfo is null after GetBizChatMyUserInfo");
}
}
public final String MQ() {
return "MicroMsg.ContactWidgetBizInfo";
}
private void bnu() {
x.d("MicroMsg.ContactWidgetBizInfo", "updatePlaceTop");
if (this.duR == null) {
this.duR = this.bGc.getSharedPreferences(this.bGc.getPackageName() + "_preferences", 0);
}
if (this.hLs != null) {
if (this.guS != null) {
this.duR.edit().putBoolean("biz_placed_to_the_top", this.guS.BG()).commit();
} else {
this.duR.edit().putBoolean("biz_placed_to_the_top", false).commit();
}
}
this.eOE.notifyDataSetChanged();
}
private static boolean uK(int i) {
if (i == 81 || i == 92 || i == 93 || i == 94) {
return true;
}
return false;
}
}
|
package com.tencent.mm.plugin.appbrand.jsapi.live;
import com.tencent.mm.plugin.appbrand.jsapi.h;
final class c$a extends h {
private static final int CTRL_INDEX = 411;
private static final String NAME = "onLivePusherNetStatus";
private c$a() {
}
/* synthetic */ c$a(byte b) {
this();
}
}
|
package com.wechat.service;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.security.KeyStore;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import javax.net.ssl.SSLContext;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLContexts;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import com.ssm.wechatpro.object.InputObject;
import com.ssm.wechatpro.object.OutputObject;
import com.ssm.wechatpro.util.Constants;
import com.ssm.wechatpro.util.OrderUtil;
import com.ssm.wechatpro.util.WeixinUtil;
/**
* 退款
*mch_id:微信支付分配的商户号
*out_trade_no :系统内部生成的订单号
*total_fee:订单金额
*refund_fee:退款金额
*refund_desc:退款原因
*key:商户的key
* @author 殷曾祥
* 2017-10-9 下午8:49:22
*/
public class RefundService {
public static Map<String, Object> getRefundParams(String sub_mch_id,String out_trade_no,String total_fee,String refund_fee, InputObject inputObject,OutputObject outputObject)throws Exception{
Map<String,Object> parameters = new HashMap<String,Object>();
parameters.put("appid", Constants.APPID);//appid
parameters.put("mch_id", Constants.MCH_ID);//商户号
parameters.put("nonce_str", CreateNoncestr());
//在notify_url中解析微信返回的信息获取到 transaction_id,此项不是必填,详细请看上图文档
// parameters.put("transaction_id", "4200000016201710178680537928");
parameters.put("out_trade_no", out_trade_no);//订单号
parameters.put("out_refund_no", out_trade_no);//我们自己设定的退款申请号,约束为UK
parameters.put("total_fee", total_fee) ;//单位为分
parameters.put("refund_fee", refund_fee);//单位为分
parameters.put("sub_mch_id", sub_mch_id);
parameters.put("op_user_id", Constants.MCH_ID);//操作人员,默认为商户账号
String sign = OrderUtil.sign(parameters, Constants.KEY);
parameters.put("sign", sign);
String reuqestXml = getRequestXml(parameters);
KeyStore keyStore = KeyStore.getInstance("PKCS12");
FileInputStream instream = new FileInputStream(new File(Constants.SSL_PATH));//放退款证书的路径
try {
keyStore.load(instream, Constants.MCH_ID.toCharArray());//"商户号
} finally {
instream.close();
}
SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, Constants.MCH_ID.toCharArray()).build();//"123456"指的是商户号
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslcontext,
new String[] { "TLSv1" },
null,
SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
Map<String, Object> returnMap = new HashMap<>();
try {
HttpPost httpPost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund");//退款接口
System.out.println("executing request" + httpPost.getRequestLine());
StringEntity reqEntity = new StringEntity(reuqestXml);
// 设置类型
reqEntity.setContentType("application/x-www-form-urlencoded");
httpPost.setEntity(reqEntity);
CloseableHttpResponse response = httpclient.execute(httpPost);
try {
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
if (entity != null) {
System.out.println("Response content length: " + entity.getContentLength());
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent(),"UTF-8"));
String text;
while ((text = bufferedReader.readLine()) != null) {
returnMap.put("returnText",text );
System.out.println(text);
}
}
EntityUtils.consume(entity);
} finally {
response.close();
}
} finally {
httpclient.close();
}
return returnMap;
}
public static String CreateNoncestr() {
String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
String res = "";
for (int i = 0; i < 16; i++) {
Random rd = new Random();
res += chars.charAt(rd.nextInt(chars.length() - 1));
}
return res;
}
public static String getRequestXml(Map<String, Object> parameters){
StringBuffer sb = new StringBuffer();
sb.append("<xml>");
Set es = parameters.entrySet();
Iterator it = es.iterator();
while(it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next();
String k = (String)entry.getKey();
String v = (String)entry.getValue();
if ("attach".equalsIgnoreCase(k)||"body".equalsIgnoreCase(k)||"sign".equalsIgnoreCase(k)) {
sb.append("<"+k+">"+"<![CDATA["+v+"]]></"+k+">");
}else {
sb.append("<"+k+">"+v+"</"+k+">");
}
}
sb.append("</xml>");
return sb.toString();
}
}
|
package ist.meic.ie.addiotdevice;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
import ist.meic.ie.utils.Constants;
import ist.meic.ie.utils.DatabaseConfig;
import ist.meic.ie.utils.HTTPMessages;
import ist.meic.ie.utils.LambdaUtils;
import org.json.simple.JSONObject;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class DeleteIoTDevice implements RequestStreamHandler {
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException {
LambdaLogger logger = context.getLogger();
JSONObject obj = LambdaUtils.parseInput(inputStream, logger);
if (verifyJsonArgs(outputStream, obj)) return;
int customerId = ((Long) obj.get("customerId")).intValue();
int SIMCARD = ((Long) obj.get("SIMCARD")).intValue();
logger.log("1");
Connection conn = new DatabaseConfig(Constants.CUSTOMER_HANDLING_DB, "CustomerHandling", Constants.CUSTOMER_HANDLING_DB_USER, Constants.CUSTOMER_HANDLING_DB_PASSWORD).getConnection();
logger.log("1.1");
try {
conn.setAutoCommit(false);
if (checkCustomer(outputStream, customerId, conn)) return;
if (checkDevice(outputStream, SIMCARD, conn)) return;
if (checkCustomerDevice(outputStream, customerId, SIMCARD, conn)) return;
logger.log("2");
deleteDevice(SIMCARD, conn);
JSONObject simcardToDelete = new JSONObject();
simcardToDelete.put("SIMCARD", SIMCARD);
logger.log("3");
if (HTTPMessages.postMsg(simcardToDelete, "application/json", "deletesimcard.com", logger) != 200) {
conn.rollback();
conn.close();
return;
}
logger.log("5");
LambdaUtils.buildResponse(outputStream, "IoT Device with SIMCARD " + SIMCARD + " deleted!", 200);
logger.log("6");
conn.commit();
} catch (Exception e) {
logger.log(e.toString());
} finally {
try {
conn.close();
} catch (SQLException throwables) {
logger.log(throwables.getStackTrace().toString());
}
}
}
private void deleteDevice(int SIMCARD, Connection conn) throws SQLException {
PreparedStatement stmt;
stmt = conn.prepareStatement("DELETE FROM Device WHERE SIMCARD = ?");
stmt.setInt(1, SIMCARD);
stmt.executeUpdate();
stmt.close();
}
private boolean checkCustomerDevice(OutputStream outputStream, int customerId, int SIMCARD, Connection conn) throws SQLException, IOException {
PreparedStatement stmt;
ResultSet rs;
stmt = conn.prepareStatement("SELECT * FROM Device WHERE customerId = ? AND SIMCARD = ?");
stmt.setInt(1, customerId);
stmt.setInt(2, SIMCARD);
rs = stmt.executeQuery();
if (!rs.next()) {
LambdaUtils.buildResponse(outputStream, "Device with SIMCARD " + SIMCARD + " does not belong to user " + customerId, 500);
return true;
}
rs.close();
stmt.close();
return false;
}
private boolean checkDevice(OutputStream outputStream, int SIMCARD, Connection conn) throws SQLException, IOException {
PreparedStatement stmt;
ResultSet rs;
stmt = conn.prepareStatement("SELECT * FROM Device WHERE SIMCARD = ?");
stmt.setInt(1, SIMCARD);
rs = stmt.executeQuery();
if (!rs.next()) {
LambdaUtils.buildResponse(outputStream, "Device with SIMCARD " + SIMCARD + " does not exist!", 500);
return true;
}
rs.close();
stmt.close();
return false;
}
private boolean checkCustomer(OutputStream outputStream, int customerId, Connection conn) throws SQLException, IOException {
PreparedStatement stmt;
ResultSet rs;
stmt = conn.prepareStatement("SELECT * FROM Customer WHERE id = ?");
stmt.setInt(1, customerId);
rs = stmt.executeQuery();
if (!rs.next()) {
LambdaUtils.buildResponse(outputStream, "Customer with id " + customerId + " does not exist!", 500);
return true;
}
rs.close();
stmt.close();
return false;
}
private boolean verifyJsonArgs(OutputStream outputStream, JSONObject obj) throws IOException {
if(obj.get("customerId") == null) {
LambdaUtils.buildResponse(outputStream, "Customer Id not provided", 500);
return true;
}
if(obj.get("SIMCARD") == null) {
LambdaUtils.buildResponse(outputStream, "SIMCARD not provided", 500);
return true;
}
return false;
}
}
|
package SUT.SE61.Team07.Entity;
import javax.persistence.*;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.*;
@Entity
@Data
public class Gender {
@Id
@SequenceGenerator(name = "gender_seq", sequenceName = "gender_seq")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "gender_seq")
private Long genderId;
@NotNull(message = "not Sex to null")
@Size(min = 3, max =6)
private String sex;
public Gender() {
}
public Gender(String sex) {
this.sex = sex;
}
}
|
package com.polsl.edziennik.desktopclient.controller.student;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;
import com.polsl.edziennik.delegates.login.LoginManager;
import com.polsl.edziennik.desktopclient.view.student.StudentMainView;
import com.polsl.edziennik.desktopclient.view.student.StudentSummary;
/**
*
* Klasa odpowiedzialna za wykoananie akcji uruchomienia modułu podsumowania
* studenta
*
* @author Mateusz Gołąb
*
*/
public class SummaryAction extends StudentAction {
private static String title = menu.getString("summary");
public SummaryAction(StudentMainView parent) {
super(title);
this.parent = parent;
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO : currentStudent
StudentSummary s = new StudentSummary(LoginManager.getUser().getId());
// StudentSummary s = new StudentSummary(2);
parent.addTab(title + " ", s, new ImageIcon(bundle.getString("StudentsIcon")));
parent.invalidate();
parent.validate();
}
}
|
execute(des, registers, memory) {
String value = registers.x87().peek();
if ( des.isRegister() ) {
registers.set(des, value);
}
else if ( des.isMemory() ) {
int size = memory.getBitSize(des);
Converter cal = new Converter(value);
if ( size == 32 ) {
// conversion to single precision
value = cal.toSinglePrecisionHex();
} else if ( size == 64 ) {
// conversion to double precision
value = cal.toDoublePrecisionHex();
}
memory.write(des, value, des);
}
}
|
package TCP.Character;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Arrays;
public class ClientCharacterStream {
public static String MINMAX(int a[]) {
Arrays.sort(a);
return String.format("%d,%d", a[0], a[a.length - 1]);
}
public static void main(String[] args) throws IOException {
Socket s = new Socket("localhost", 8000);
BufferedReader is = new BufferedReader(new InputStreamReader(s.getInputStream()));
BufferedWriter os = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
os.write("B17DCCN510");
os.newLine();
os.flush();
String rcv = is.readLine();
System.out.println(rcv);
String t[] = rcv.split(",");
int arr[] = new int[t.length];
for (int i = 0; i < t.length; i++) {
arr[i] = Integer.parseInt(t[i].trim());
}
os.write(MINMAX(arr));
os.newLine();
os.flush();
String res = is.readLine();
System.out.println(res);
s.close();
}
}
|
package com.cnk.travelogix.custom.zif.erp.ws.custmastercreate;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
import com.cnk.travelogix.sapintegrations.dto.factory.DTOObjectFactory;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.cnk.travelogix.custom.zif.erp.ws.custmastercreate package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory implements DTOObjectFactory
{
private final static QName _ZifTerpCustomerCreate_QNAME = new QName("urn:sap-com:document:sap:soap:functions:mc-style",
"ZifTerpPartnerSave");
private final static QName _ZifTerpCustomerCreateResponse_QNAME = new QName(
"urn:sap-com:document:sap:soap:functions:mc-style", "ZifTerpPartnerSaveResponse");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.cnk.travelogix.custom.zif.erp.ws.custmastercreate
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link ZifTerpPartnerSave }
*
*/
public ZifTerpPartnerSave createZifTerpPartnerSave() {
return new ZifTerpPartnerSave();
}
/**
* Create an instance of {@link ZifErpTtContmast }
*
*/
public ZifErpTtContmast createZifErpTtContmast() {
return new ZifErpTtContmast();
}
/**
* Create an instance of {@link ZifErpStCustmast }
*
*/
public ZifErpStCustmast createZifErpStCustmast() {
return new ZifErpStCustmast();
}
/**
* Create an instance of {@link ZifTerpPartnerSaveResponse }
*
*/
public ZifTerpPartnerSaveResponse createZifTerpPartnerSaveResponse() {
return new ZifTerpPartnerSaveResponse();
}
/**
* Create an instance of {@link ZifErpTtStatusC }
*
*/
public ZifErpTtStatusC createZifErpTtStatusC() {
return new ZifErpTtStatusC();
}
/**
* Create an instance of {@link ZifErpStStatusC }
*
*/
public ZifErpStStatusC createZifErpStStatusC() {
return new ZifErpStStatusC();
}
/**
* Create an instance of {@link ZifErpStContmast }
*
*/
public ZifErpStContmast createZifErpStContmast() {
return new ZifErpStContmast();
}
@XmlElementDecl(namespace = "urn:sap-com:document:sap:soap:functions:mc-style", name = "ZifTerpPartnerSave")
public JAXBElement<ZifTerpPartnerSave> createZifTerpPartnerSave(final ZifTerpPartnerSave value)
{
return new JAXBElement<ZifTerpPartnerSave>(_ZifTerpCustomerCreate_QNAME, ZifTerpPartnerSave.class, null, value);
}
@XmlElementDecl(namespace = "urn:sap-com:document:sap:soap:functions:mc-style", name = "ZifTerpPartnerSaveResponse")
public JAXBElement<ZifTerpPartnerSaveResponse> createZifTerpPartnerSaveResponse(final ZifTerpPartnerSaveResponse value)
{
return new JAXBElement<ZifTerpPartnerSaveResponse>(_ZifTerpCustomerCreateResponse_QNAME, ZifTerpPartnerSaveResponse.class,
null, value);
}
}
|
/*You are given a string s that consists of lower case English letters and brackets.
Reverse the strings in each pair of matching parentheses, starting from the innermost one.
Your result should not contain any brackets.
Example 1:
Input: s = "(abcd)"
Output: "dcba"
Example 2:
Input: s = "(u(love)i)"
Output: "iloveu"
Explanation: The substring "love" is reversed first, then the whole string is reversed.
Example 3:
Input: s = "(ed(et(oc))el)"
Output: "leetcode"
Explanation: First, we reverse the substring "oc", then "etco", and finally, the whole string.
Example 4:
Input: s = "a(bcdefghijkl(mno)p)q"
Output: "apmnolkjihgfedcbq"
Constraints:
0 <= s.length <= 2000
s only contains lower case English characters and parentheses.
It's guaranteed that all parentheses are balanced.*/
class Solution {
public String reverseParentheses(String s) {
Stack<Character> st = new Stack<>();
for(char c : s.toCharArray()) {
if(c == ')') {
Queue<Character> q = new LinkedList<>();
while(!st.isEmpty() && st.peek() != '(') q.add(st.pop());
if(!st.isEmpty()) st.pop();
while(!q.isEmpty()) st.push(q.remove());
}
else {
st.push(c);
}
}
StringBuilder sb = new StringBuilder();
while(!st.isEmpty())
sb.append(st.pop());
return sb.reverse().toString();
}
}
|
/*
* Copyright (C) 2018 Ilya Lebedev
*
* 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 io.github.ilya_lebedev.worldmeal.ui.classification;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import com.google.android.gms.ads.MobileAds;
import io.github.ilya_lebedev.worldmeal.R;
/**
* ClassificationActivity
*/
public class ClassificationActivity extends AppCompatActivity {
private ClassificationPagerAdapter mPagerAdapter;
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_classification);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mPagerAdapter = new ClassificationPagerAdapter(getSupportFragmentManager(), this);
mViewPager = findViewById(R.id.viewpager);
mViewPager.setAdapter(mPagerAdapter);
// Give the TabLayout the ViewPager
TabLayout tabLayout = findViewById(R.id.tablayout);
tabLayout.setupWithViewPager(mViewPager);
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
}
}
|
package uk.ac.ed.inf.aqmaps.unitTests.simulation.planning.collectionOrder.optimisers;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.jupiter.api.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import uk.ac.ed.inf.aqmaps.simulation.planning.DistanceMatrix;
import uk.ac.ed.inf.aqmaps.simulation.planning.collectionOrder.optimisers.Optimiser2Opt;
@SuppressWarnings("all")
public class Optimiser2OptTest {
DistanceMatrix mockDistanceMatrix = mock(DistanceMatrix.class);
@Test
public void simpleCrossoverTest(){
/**
* the test matrix represents a "knot", swapping 2 and 3 is what makes 2-opt work
* 1 2
* \/|
* / \
* 0 3
*
*/
double[][] dm = new double[][]{
/** 0, 1, 2, 3 */
/*0*/{0, 1, 1.5, 1},
/*1*/{1, 0, 1, 1.5},
/*2*/{1.5, 1, 0, 1},
/*3*/{1, 1.5, 1, 0}};
when(mockDistanceMatrix.distanceBetween(anyInt(),anyInt()))
.thenAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) {
Object[] args = invocation.getArguments();
Object mock = invocation.getMock();
return dm[(int)args[0]][(int)args[1]];
}
});
when(mockDistanceMatrix.totalDistance(any()))
.thenAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) {
Object[] args = invocation.getArguments();
Object mock = invocation.getMock();
int[] input = (int[])args[0];
double sum = 0;
for(int i = 0; i < input.length - 1;i++){
sum+= dm[input[i]][input[i+1]];
}
return sum;
}
});
Optimiser2Opt testUnit = new Optimiser2Opt(0.001d);
var output = new int[]{0,2,3,1};
testUnit.optimise(mockDistanceMatrix, output);
assertArrayEquals(new int[]{0,3,2,1}, output);
}
}
|
package com.wby.edu.service.edu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
/**
* 指定扫描的基本包
* @ComponentScan(basePackages = {"com.wby.edu"})
* 扫描controllerAdvice,controller,service,respsitory,configuration,component
* @MapperScan(basePackages = "com.wby.edu.service.*.mapper")
* 扫描mybatis的mapper
* @ServletComponentScan
* 扫描tomcat的三大组件:@webServlet,@WebFilter,@WebListener
*/
@SpringBootApplication
@ComponentScan(basePackages = {"com.wby.edu"})//扫描controllerAdvice,controller,service,respsitory,configuration,component
//@MapperScan(basePackages = "com.wby.edu.service.*.mapper") 通过mybatis配置类全局扫描
public class ServiceTeacherApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceTeacherApplication.class,args);
}
}
|
package de.acetous.nocake.controller;
import de.acetous.nocake.service.AuthorizationService;
import de.acetous.nocake.service.LockService;
import de.acetous.nocake.service.QrCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Map;
@Controller
public class CakeController {
private LockService lockService;
private AuthorizationService authorizationService;
private QrCodeService qrCodeService;
@Autowired
public CakeController(LockService lockService, AuthorizationService authorizationService, QrCodeService qrCodeService) {
this.lockService = lockService;
this.authorizationService = authorizationService;
this.qrCodeService = qrCodeService;
}
@RequestMapping("/")
public ModelAndView home(Map<String, Object> model, @RequestParam String token) {
checkToken(token);
model.put("locked", lockService.isLocked());
model.put("token", token);
return new ModelAndView("home", model);
}
@RequestMapping("/lock")
public String lock(@RequestParam String token) {
checkToken(token);
try {
lockService.lock();
} catch (IOException e) {
e.printStackTrace();
}
return "redirect:/?token=" + token;
}
private void checkToken(@RequestParam String token) {
if (!authorizationService.checkToken(token)) {
throw new ForbiddenException();
}
}
@RequestMapping("/connect")
public ModelAndView connect(Map<String, Object> model, @Value("${server.port}") String port, @RequestParam(required = false) String token) {
if (authorizationService.hasToken()) {
checkToken(token);
}
String generatedToken = authorizationService.generateToken();
String hostname = getHostname();
String connectUrl = "http://" + hostname + ":" + port + "/?token=" + generatedToken;
String qrCode = qrCodeService.generate(connectUrl);
model.put("url", connectUrl);
model.put("qrCode", "data:image/gif;base64," + qrCode);
return new ModelAndView("connect", model);
}
@RequestMapping("/shutdown")
public ModelAndView shutdown(@RequestParam String token) {
checkToken(token);
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(3000);
System.exit(0);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
return new ModelAndView("down");
}
private String getHostname() {
String hostname;
try {
hostname = InetAddress.getLocalHost().getCanonicalHostName();
} catch (UnknownHostException e) {
hostname = "localhost";
}
return hostname.toLowerCase();
}
}
|
public class HotWaterContainer extends WaterContainer {
private int temperature;
static final int MIN_TEMPERATURE = 80;
static final int MAX_TEMPERATURE = 100;
public HotWaterContainer(int capacity) {
super(capacity);
temperature = MAX_TEMPERATURE;
new Thread(new DropTemperature()).start();
}
public int getTemperature() {
return temperature;
}
public void reBrew() {
new Thread(new ReBrew()).start();
}
public synchronized void addWater(int water) {
temperature = averageTemp(super.getCapacity(), temperature,
water, 100);
super.addWater(water);
}
private int averageTemp(int oldCap, int oldTemp,
int newCap, int newTemp) {
int result = 0;
result = ((oldCap * oldTemp) + (newCap * newTemp))
/ (oldCap + newCap);
return result;
}
public class ReBrew implements Runnable {
public void run() {
setIsReady(false);
setIsBrewing(true);
for (; temperature < MAX_TEMPERATURE; ) {
try {
Thread.sleep(100);
temperature++;
} catch (Exception ex) {
//
}
}
setIsReady(true);
setIsBrewing(false);
}
}
public class DropTemperature implements Runnable {
public void run() {
while (true) {
try {
Thread.sleep(1000);
temperature--;
} catch (Exception ex) {
//
}
if (temperature < MIN_TEMPERATURE) {
reBrew();
}
}
}
}
}
|
package eu.torsteneriksson.storetracker;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.preference.PreferenceFragment;
import android.os.Bundle;
import android.view.MenuItem;
public class SettingsActivity extends Activity {
public final static String MAX_FAVORITES = "pref_key_max_favorites";
public final static String MIN_TIME_IN_AREA = "pref_key_min_time_in_area";
public final static String TRACKING_DISTANCE = "pref_key_tracking_distance";
public final static String TRACKING_INTERVAL = "pref_key_tracking_interval";
public final static String FAVORITE_UPDATE = "pref_key_favorite_update";
public final static String MAX_HITS_OUTSIDE_AREA = "pref_key_max_hits_outside_area";
public final static String MIN_HITS_INSIDE_AREA = "pref_key_min_hits_inside_area";
public final static String SHOW_LOCATION_DATA = "pref_key_show_location_data";
public final static String LOCATION_ACCURACY = "pref_key_location_accuracy";
public final static String APP_VERSION = "pref_key_app_version";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Display the fragment as the main content.
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
}
@Override
protected void onDestroy() {
notifySettingsUsers(this);
super.onDestroy();
}
public static class SettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
}
}
private static void notifySettingsUsers(Context context) {
if (TrackerUtilities.isMyServiceRunning(TrackerService.class, context)) {
Intent serviceIntent = new Intent(context, TrackerService.class);
serviceIntent.putExtra("START", false);
context.startService(serviceIntent);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
onBackPressed();
}
return super.onOptionsItemSelected(item);
}
}
|
/*
* Copyright 2017-present The Material Motion Authors. 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.google.android.reactive.motion.interactions;
import android.view.View;
import com.google.android.material.motion.gestures.ScaleGestureRecognizer;
import com.google.android.reactive.motion.MotionObservable;
import com.google.android.reactive.motion.MotionRuntime;
import com.google.android.reactive.motion.gestures.GestureInteraction;
import com.google.android.reactive.motion.properties.ViewProperties;
import static com.google.android.reactive.motion.operators.GestureOperators.scaled;
/**
* A pinchable interaction.
*/
public class Pinchable extends GestureInteraction<ScaleGestureRecognizer, Float[]> {
public Pinchable() {
this(new ScaleGestureRecognizer());
}
public Pinchable(ScaleGestureRecognizer gestureRecognizer) {
super(gestureRecognizer);
}
@Override
protected void onApply(final MotionRuntime runtime, MotionObservable<ScaleGestureRecognizer> stream, final View target) {
MotionObservable<Float[]> scaledStream = stream.compose(scaled(target));
scaledStream = flatten(scaledStream);
runtime.write(scaledStream, target, ViewProperties.SCALE);
}
}
|
package mk.petrovski.weathergurumvp.presenter;
import io.reactivex.Observable;
import io.reactivex.disposables.CompositeDisposable;
import mk.petrovski.weathergurumvp.TestModels;
import mk.petrovski.weathergurumvp.data.DataManager;
import mk.petrovski.weathergurumvp.data.remote.helper.CompositeDisposableHelper;
import mk.petrovski.weathergurumvp.data.remote.helper.error.ErrorHandlerHelper;
import mk.petrovski.weathergurumvp.data.remote.helper.error.ServerNotAvailableException;
import mk.petrovski.weathergurumvp.data.remote.model.weather_models.WeatherModel;
import mk.petrovski.weathergurumvp.data.remote.model.weather_models.WeatherResponseModel;
import mk.petrovski.weathergurumvp.ui.day.DayMvpView;
import mk.petrovski.weathergurumvp.ui.day.DayPresenter;
import mk.petrovski.weathergurumvp.ui.day_detail.DayDetailMvpView;
import mk.petrovski.weathergurumvp.ui.day_detail.DayDetailPresenter;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* Created by Nikola Petrovski on 3/20/2017.
*/
@RunWith(MockitoJUnitRunner.class) public class DayPresenterTest extends
BasePresenterTest<DayPresenter<DayMvpView>, DayMvpView> {
@Override DayPresenter<DayMvpView> createPresenter() {
return new DayPresenter<>(compositeDisposableHelper, dataManager);
}
@Override DayMvpView createView() {
return mock(DayMvpView.class);
}
@Test public void loadDaysSuccessfully() {
WeatherResponseModel responseModel = TestModels.getWeatherResponseModel(5);
stubDataManagerLoadWeather(Observable.just(responseModel));
presenter.loadWeather();
testScheduler.triggerActions();
verify(view, times(1)).showLoading();
verify(view).showWeather(responseModel.getData().getWeather());
verify(view, times(1)).hideLoading();
verify(view, never()).showEmptyView();
verify(view, never()).onError(anyString());
}
@Test public void loadDaysEmpty() {
WeatherResponseModel responseModel = TestModels.getWeatherResponseModel(0);
stubDataManagerLoadWeather(Observable.just(responseModel));
presenter.loadWeather();
testScheduler.triggerActions();
verify(view).showEmptyView();
verify(view, never()).showWeather(ArgumentMatchers.<WeatherModel>anyList());
verify(view, never()).onError(anyString());
}
@Test public void loadDaysFail() {
ServerNotAvailableException exception = new ServerNotAvailableException();
when(dataManager.getErrorHandlerHelper()).thenReturn(errorHandlerHelper);
when(errorHandlerHelper.getProperErrorMessage(exception)).thenReturn("Server not available");
stubDataManagerLoadWeather(Observable.<WeatherResponseModel>error(exception));
presenter.loadWeather();
testScheduler.triggerActions();
verify(view).onError("Server not available");
verify(view, never()).showWeather(ArgumentMatchers.<WeatherModel>anyList());
verify(view, never()).showEmptyView();
}
@Test public void noSelectCity() {
when(dataManager.getSelectedCityModel()).thenReturn(null);
presenter.loadWeather();
testScheduler.triggerActions();
verify(view).showEmptyView();
}
private void stubDataManagerLoadWeather(Observable observable) {
when(view.isNetworkConnected()).thenReturn(true);
when(dataManager.getSelectedCityModel()).thenReturn(TestModels.newCityModel());
when(dataManager.weatherApiRequest(anyString(), anyString())).thenReturn(observable);
}
}
|
/*
* 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 org.apache.commons.net.examples.mail;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.TimeZone;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.net.PrintCommandListener;
import org.apache.commons.net.ProtocolCommandEvent;
import org.apache.commons.net.imap.IMAP;
import org.apache.commons.net.imap.IMAP.IMAPChunkListener;
import org.apache.commons.net.imap.IMAPClient;
import org.apache.commons.net.imap.IMAPReply;
/**
* This is an example program demonstrating how to use the IMAP[S]Client class. This program connects to a IMAP[S] server and exports selected messages from a
* folder into an mbox file.
* <p>
* Usage: IMAPExportMbox imap[s]://user:password@host[:port]/folder/path <mboxfile> [sequence-set] [item-names]
* <p>
* An example sequence-set might be:
* <ul>
* <li>11,2,3:10,20:*</li>
* <li>1:* - this is the default</li>
* </ul>
* <p>
* Some example item-names might be:
* <ul>
* <li>BODY.PEEK[HEADER]</li>
* <li>'BODY.PEEK[HEADER.FIELDS (SUBJECT)]'</li>
* <li>ALL - macro equivalent to '(FLAGS INTERNALDATE RFC822.SIZE ENVELOPE)'</li>
* <li>FAST - macro equivalent to '(FLAGS INTERNALDATE RFC822.SIZE)'</li>
* <li>FULL - macro equivalent to '(FLAGS INTERNALDATE RFC822.SIZE ENVELOPE BODY)'</li>
* <li>ENVELOPE X-GM-LABELS</li>
* <li>'(INTERNALDATE BODY.PEEK[])' - this is the default</li>
* </ul>
* <p>
* Macro names cannot be combined with anything else; they must be used alone.<br>
* Note that using BODY will set the \Seen flag. This is why the default uses BODY.PEEK[].<br>
* The item name X-GM-LABELS is a Google Mail extension; it shows the labels for a message.<br>
* For example:<br>
* IMAPExportMbox imaps://username:password@imap.googlemail.com/messages_for_export exported.mbox 1:10,20<br>
* IMAPExportMbox imaps://username:password@imap.googlemail.com/messages_for_export exported.mbox 3 ENVELOPE X-GM-LABELS<br>
* <p>
* The sequence-set is passed unmodified to the FETCH command.<br>
* The item names are wrapped in parentheses if more than one is provided. Otherwise, the parameter is assumed to be wrapped if necessary.<br>
* Parameters with spaces must be quoted otherwise the OS shell will normally treat them as separate parameters.<br>
* Also, the listener that writes the mailbox only captures the multi-line responses (e.g. ones that include BODY references). It does not capture the output
* from FETCH commands using item names such as ENVELOPE or FLAGS that return a single line response.
*/
public final class IMAPExportMbox {
private static class MboxListener implements IMAPChunkListener {
private final BufferedWriter bufferedWriter;
volatile AtomicInteger total = new AtomicInteger();
volatile String lastFetched;
volatile List<String> missingIds = new ArrayList<>();
volatile long lastSeq = -1;
private final String lineSeparator;
private final SimpleDateFormat DATE_FORMAT // for mbox From_ lines
= new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy");
// e.g. INTERNALDATE "27-Oct-2013 07:43:24 +0000"
// for parsing INTERNALDATE
private final SimpleDateFormat IDPARSE = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss Z");
private final boolean printHash;
private final boolean printMarker;
private final boolean checkSequence;
MboxListener(final BufferedWriter bufferedWriter, final String lineSeparator, final boolean printHash, final boolean printMarker,
final boolean checkSequence) {
this.lineSeparator = lineSeparator;
this.printHash = printHash;
this.printMarker = printMarker;
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
this.bufferedWriter = bufferedWriter;
this.checkSequence = checkSequence;
}
@Override
public boolean chunkReceived(final IMAP imap) {
final String[] replyStrings = imap.getReplyStrings();
Date received = new Date();
final String firstLine = replyStrings[0];
Matcher m = PATID.matcher(firstLine);
if (m.lookingAt()) { // found a match
final String date = m.group(PATID_DATE_GROUP);
try {
received = IDPARSE.parse(date);
} catch (final ParseException e) {
System.err.println(e);
}
} else {
System.err.println("No timestamp found in: " + firstLine + " - using current time");
}
String replyTo = "MAILER-DAEMON"; // default
for (int i = 1; i < replyStrings.length - 1; i++) {
final String line = replyStrings[i];
if (line.startsWith("Return-Path: ")) {
final String[] parts = line.split(" ", 2);
if (!parts[1].equals("<>")) {// Don't replace default with blank
replyTo = parts[1];
if (replyTo.startsWith("<")) {
if (replyTo.endsWith(">")) {
replyTo = replyTo.substring(1, replyTo.length() - 1); // drop <> wrapper
} else {
System.err.println("Unexpected Return-path: '" + line + "' in " + firstLine);
}
}
}
break;
}
}
try {
// Add initial mbox header line
bufferedWriter.append("From ");
bufferedWriter.append(replyTo);
bufferedWriter.append(' ');
bufferedWriter.append(DATE_FORMAT.format(received));
bufferedWriter.append(lineSeparator);
// Debug
bufferedWriter.append("X-IMAP-Response: ").append(firstLine).append(lineSeparator);
if (printMarker) {
System.err.println("[" + total + "] " + firstLine);
}
// Skip first and last lines
for (int i = 1; i < replyStrings.length - 1; i++) {
final String line = replyStrings[i];
if (startsWith(line, PATFROM)) {
bufferedWriter.append('>'); // Escape a From_ line
}
bufferedWriter.append(line);
bufferedWriter.append(lineSeparator);
}
// The last line ends with the trailing closing ")" which needs to be stripped
final String lastLine = replyStrings[replyStrings.length - 1];
final int lastLength = lastLine.length();
if (lastLength > 1) { // there's some content, we need to save it
bufferedWriter.append(lastLine, 0, lastLength - 1);
bufferedWriter.append(lineSeparator);
}
bufferedWriter.append(lineSeparator); // blank line between entries
} catch (final IOException e) {
e.printStackTrace();
throw new UncheckedIOException(e); // chunkReceived cannot throw a checked Exception
}
lastFetched = firstLine;
total.incrementAndGet();
if (checkSequence) {
m = PATSEQ.matcher(firstLine);
if (m.lookingAt()) { // found a match
final long msgSeq = Long.parseLong(m.group(PATSEQ_SEQUENCE_GROUP)); // Cannot fail to parse
if (lastSeq != -1) {
final long missing = msgSeq - lastSeq - 1;
if (missing != 0) {
for (long j = lastSeq + 1; j < msgSeq; j++) {
missingIds.add(String.valueOf(j));
}
System.err.println("*** Sequence error: current=" + msgSeq + " previous=" + lastSeq + " Missing=" + missing);
}
}
lastSeq = msgSeq;
}
}
if (printHash) {
System.err.print(".");
}
return true;
}
public void close() throws IOException {
if (bufferedWriter != null) {
bufferedWriter.close();
}
}
}
private static final String CRLF = "\r\n";
private static final String LF = "\n";
private static final String EOL_DEFAULT = System.lineSeparator();
private static final Pattern PATFROM = Pattern.compile(">*From "); // unescaped From_
// e.g. * nnn (INTERNALDATE "27-Oct-2013 07:43:24 +0000" BODY[] {nn} ...)
private static final Pattern PATID = // INTERNALDATE
Pattern.compile(".*INTERNALDATE \"(\\d\\d-\\w{3}-\\d{4} \\d\\d:\\d\\d:\\d\\d [+-]\\d+)\"");
private static final int PATID_DATE_GROUP = 1;
private static final Pattern PATSEQ = Pattern.compile("\\* (\\d+) "); // Sequence number
private static final int PATSEQ_SEQUENCE_GROUP = 1;
// e.g. * 382 EXISTS
private static final Pattern PATEXISTS = Pattern.compile("\\* (\\d+) EXISTS"); // Response from SELECT
// AAAC NO [TEMPFAIL] FETCH Temporary failure on server [CODE: WBL]
private static final Pattern PATTEMPFAIL = Pattern.compile("[A-Z]{4} NO \\[TEMPFAIL\\] FETCH .*");
private static final int CONNECT_TIMEOUT = 10; // Seconds
private static final int READ_TIMEOUT = 10;
public static void main(final String[] args) throws IOException, URISyntaxException {
int connect_timeout = CONNECT_TIMEOUT;
int read_timeout = READ_TIMEOUT;
int argIdx = 0;
String eol = EOL_DEFAULT;
boolean printHash = false;
boolean printMarker = false;
int retryWaitSecs = 0;
for (argIdx = 0; argIdx < args.length; argIdx++) {
if (args[argIdx].equals("-c")) {
connect_timeout = Integer.parseInt(args[++argIdx]);
} else if (args[argIdx].equals("-r")) {
read_timeout = Integer.parseInt(args[++argIdx]);
} else if (args[argIdx].equals("-R")) {
retryWaitSecs = Integer.parseInt(args[++argIdx]);
} else if (args[argIdx].equals("-LF")) {
eol = LF;
} else if (args[argIdx].equals("-CRLF")) {
eol = CRLF;
} else if (args[argIdx].equals("-.")) {
printHash = true;
} else if (args[argIdx].equals("-X")) {
printMarker = true;
} else {
break;
}
}
final int argCount = args.length - argIdx;
if (argCount < 2) {
System.err.println("Usage: IMAPExportMbox [-LF|-CRLF] [-c n] [-r n] [-R n] [-.] [-X]"
+ " imap[s]://user:password@host[:port]/folder/path [+|-]<mboxfile> [sequence-set] [itemnames]");
System.err.println("\t-LF | -CRLF set end-of-line to LF or CRLF (default is the line.separator system property)");
System.err.println("\t-c connect timeout in seconds (default 10)");
System.err.println("\t-r read timeout in seconds (default 10)");
System.err.println("\t-R temporary failure retry wait in seconds (default 0; i.e. disabled)");
System.err.println("\t-. print a . for each complete message received");
System.err.println("\t-X print the X-IMAP line for each complete message received");
System.err.println("\tthe mboxfile is where the messages are stored; use '-' to write to standard output.");
System.err.println("\tPrefix file name with '+' to append to the file. Prefix with '-' to allow overwrite.");
System.err.println("\ta sequence-set is a list of numbers/number ranges e.g. 1,2,3-10,20:* - default 1:*");
System.err.println("\titemnames are the message data item name(s) e.g. BODY.PEEK[HEADER.FIELDS (SUBJECT)]"
+ " or a macro e.g. ALL - default (INTERNALDATE BODY.PEEK[])");
System.exit(1);
}
final String uriString = args[argIdx++];
URI uri;
try {
uri = URI.create(uriString);
} catch (final IllegalArgumentException e) { // cannot parse the path as is; let's pull it apart and try again
final Matcher m = Pattern.compile("(imaps?://[^/]+)(/.*)").matcher(uriString);
if (!m.matches()) {
throw e;
}
uri = URI.create(m.group(1)); // Just the scheme and auth parts
uri = new URI(uri.getScheme(), uri.getAuthority(), m.group(2), null, null);
}
final String file = args[argIdx++];
String sequenceSet = argCount > 2 ? args[argIdx++] : "1:*";
final String itemNames;
// Handle 0, 1 or multiple item names
if (argCount > 3) {
if (argCount > 4) {
final StringBuilder sb = new StringBuilder();
sb.append("(");
for (int i = 4; i <= argCount; i++) {
if (i > 4) {
sb.append(" ");
}
sb.append(args[argIdx++]);
}
sb.append(")");
itemNames = sb.toString();
} else {
itemNames = args[argIdx++];
}
} else {
itemNames = "(INTERNALDATE BODY.PEEK[])";
}
final boolean checkSequence = sequenceSet.matches("\\d+:(\\d+|\\*)"); // are we expecting a sequence?
final MboxListener mboxListener;
if (file.equals("-")) {
mboxListener = null;
} else if (file.startsWith("+")) {
final File mbox = new File(file.substring(1));
System.out.println("Appending to file " + mbox);
mboxListener = new MboxListener(new BufferedWriter(new FileWriter(mbox, true)), eol, printHash, printMarker, checkSequence);
} else if (file.startsWith("-")) {
final File mbox = new File(file.substring(1));
System.out.println("Writing to file " + mbox);
mboxListener = new MboxListener(new BufferedWriter(new FileWriter(mbox, false)), eol, printHash, printMarker, checkSequence);
} else {
final File mboxFile = new File(file);
if (mboxFile.exists() && mboxFile.length() > 0) {
throw new IOException("mailbox file: " + mboxFile + " already exists and is non-empty!");
}
System.out.println("Creating file " + mboxFile);
mboxListener = new MboxListener(new BufferedWriter(new FileWriter(mboxFile)), eol, printHash, printMarker, checkSequence);
}
final String path = uri.getPath();
if (path == null || path.length() < 1) {
throw new IllegalArgumentException("Invalid folderPath: '" + path + "'");
}
final String folder = path.substring(1); // skip the leading /
// suppress login details
final PrintCommandListener listener = new PrintCommandListener(System.out, true) {
@Override
public void protocolReplyReceived(final ProtocolCommandEvent event) {
if (event.getReplyCode() != IMAPReply.PARTIAL) { // This is dealt with by the chunk listener
super.protocolReplyReceived(event);
}
}
};
// Connect and login
final IMAPClient imap = IMAPUtils.imapLogin(uri, connect_timeout * 1000, listener);
String maxIndexInFolder = null;
try {
imap.setSoTimeout(read_timeout * 1000);
if (!imap.select(folder)) {
throw new IOException("Could not select folder: " + folder);
}
for (final String line : imap.getReplyStrings()) {
maxIndexInFolder = matches(line, PATEXISTS, 1);
if (maxIndexInFolder != null) {
break;
}
}
if (mboxListener != null) {
imap.setChunkListener(mboxListener);
} // else the command listener displays the full output without processing
while (true) {
final boolean ok = imap.fetch(sequenceSet, itemNames);
// If the fetch failed, can we retry?
if (ok || (retryWaitSecs <= 0) || (mboxListener == null) || !checkSequence) {
break;
}
final String replyString = imap.getReplyString(); // includes EOL
if (!startsWith(replyString, PATTEMPFAIL)) {
throw new IOException("FETCH " + sequenceSet + " " + itemNames + " failed with " + replyString);
}
System.err.println("Temporary error detected, will retry in " + retryWaitSecs + "seconds");
sequenceSet = mboxListener.lastSeq + 1 + ":*";
try {
Thread.sleep(retryWaitSecs * 1000);
} catch (final InterruptedException e) {
// ignored
}
}
} catch (final IOException ioe) {
final String count = mboxListener == null ? "?" : mboxListener.total.toString();
System.err.println("FETCH " + sequenceSet + " " + itemNames + " failed after processing " + count + " complete messages ");
if (mboxListener != null) {
System.err.println("Last complete response seen: " + mboxListener.lastFetched);
}
throw ioe;
} finally {
if (printHash) {
System.err.println();
}
if (mboxListener != null) {
mboxListener.close();
final Iterator<String> missingIds = mboxListener.missingIds.iterator();
if (missingIds.hasNext()) {
final StringBuilder sb = new StringBuilder();
for (;;) {
sb.append(missingIds.next());
if (!missingIds.hasNext()) {
break;
}
sb.append(",");
}
System.err.println("*** Missing ids: " + sb.toString());
}
}
imap.logout();
imap.disconnect();
}
if (mboxListener != null) {
System.out.println("Processed " + mboxListener.total + " messages.");
}
if (maxIndexInFolder != null) {
System.out.println("Folder contained " + maxIndexInFolder + " messages.");
}
}
private static String matches(final String input, final Pattern pat, final int index) {
final Matcher m = pat.matcher(input);
if (m.lookingAt()) {
return m.group(index);
}
return null;
}
private static boolean startsWith(final String input, final Pattern pat) {
final Matcher m = pat.matcher(input);
return m.lookingAt();
}
}
|
/*
* 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.
*/
/*
Класс, обслуживающий приложение FileObserver. Реализует интерфейс WLSession
*/
package weblistener;
import filesobserver.RequestResponse;
import java.net.Socket;
import java.io.ObjectInputStream;
/**
*
* @author icemen78
*/
public class WLFileObserver implements WLSession{
Socket s;
public WLFileObserver() {
// this.s = s;
}
@Override
public boolean responseXML(Socket socket) {
boolean retval = false;
try (ObjectInputStream ois = new ObjectInputStream(s.getInputStream())) {
RequestResponse rr = (RequestResponse)ois.readObject();
retval = true;
}catch (Exception e) { }
return retval;
}
}
|
package com.fabio.dropbox.domain;
import com.fabio.dropbox.dto.FileDto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import javax.swing.*;
import java.io.Serializable;
import java.util.List;
@Document
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User implements Serializable {
@Id
private String id;
private String email;
private String name;
private String password;
private List<FileDto> sharedFile;
private List<FileDto> sharedWithMe;
}
|
package com.mashibing.tank.frame;
import io.vavr.control.Try;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.ListIterator;
import java.util.concurrent.TimeUnit;
/***********************
* Description: 继承frame窗口类 <BR>
* @author: zhao.song
* @date: 2020/11/13 16:10
* @version: 1.0
***********************/
public class TankFrame extends Frame {
//16:9
//窗口宽度
public static final int GAME_WIDTH = PropertyMgr.getInt("gameWidth");
//窗口高度
public static final int GAME_HEIGHT = PropertyMgr.getInt("gameHeight");
Tank mainTank = new Tank(200, 300, Dir.DOWN, Group.GOOD, this);
//子弹容器,实现多个字段的输出
java.util.List<Bullet> bulletContainer = new ArrayList<Bullet>();
java.util.List<Tank> enemyTankContainer = new ArrayList<>();
java.util.List<Explode> explodes = new ArrayList<>();
Bullet b = new Bullet(200, 200, Dir.DOWN, Group.GOOD, this);
public TankFrame() throws HeadlessException {
// 2.设置窗口参数
// 2.1 设置窗口大小
setSize(GAME_WIDTH, GAME_HEIGHT);
// 2.2 设置窗口是否可改变大小
setResizable(true);
// 2.3 设置窗口名
setTitle("tank");
// 3.设置窗口可见
setVisible(true);
addKeyListener(new TankFrame.MyKeyListener());
// 4.添加一个window监听器
addWindowListener(new WindowAdapter() {
// 4.1监听windowclosing这个事件
@Override
public void windowClosing(WindowEvent e) {
// super.windowClosing(e);
// 系统退出
System.exit(0);
}
});
}
//定义一个图片
Image offScreenImage = null;
// 用双缓冲解决闪烁问题:在paint方法之前调用(repaint->update->paint)
@Override
public void update(Graphics g) {
if (offScreenImage == null) {
offScreenImage = this.createImage(GAME_WIDTH, GAME_HEIGHT);
}
//将图片渲染完成,整体输出到客户显示界面,从而达到双缓冲的效果:https://blog.csdn.net/jxw167/article/details/72157154
Graphics gOffScreen = offScreenImage.getGraphics();
Color c = gOffScreen.getColor();
gOffScreen.setColor(Color.BLACK);
gOffScreen.fillRect(0, 0, GAME_WIDTH, GAME_HEIGHT);
gOffScreen.setColor(c);
//开始真正的输出图片的描绘
paint(gOffScreen);
//图片描绘完成后,完整的输出到显示窗口
g.drawImage(offScreenImage, 0, 0, null);
}
//窗口需要重新绘制的时候,自动调用该方法(1.窗口第一次显示的时候,2.窗口被别人盖住又显示出来的时候,3.窗口改变大小的时候)
@Override
public void paint(Graphics g) {
Color c = g.getColor();
g.setColor(Color.YELLOW);
g.drawString("子弹数量:" + bulletContainer.size(), 10, 50);
g.drawString("敌坦数量:" + (enemyTankContainer.size()), 10, 80);
g.drawString("爆炸数量:" + (explodes.size()), 10, 110);
g.setColor(c);
// tip: 面向对象的思维:应该是将画笔递给坦克,坦克最知道该如何移动
// ,而不是把tank的属性获取到再去设置
mainTank.paint(g);
for (int i = 0; i < enemyTankContainer.size(); i++) {
Tank enemyTank = enemyTankContainer.get(i);
if (enemyTank.getGroup() == Group.GOOD) {
continue;
}
enemyTank.setMoving(true);
enemyTank.paint(g);
}
/* bulletContainer.forEach(bullet -> {
//思考问题: 打出去的子弹是否该移出容器? 应该怎样移出容器?
//ans:1.不可以,因为每次都是重画窗口,如果移出会导致子弹消失;
// 2.如果不移出,就需要考虑内存的优化,集合不可一直增大
bullet.paint(g);
if (bullet.getX() > this.GAME_WIDTH || bullet.getY() > this.GAME_HEIGHT) {
bulletContainer.remove(bullet);
}
});*/
// 1.可行解决方案一
/* ListIterator<Bullet> iterator = bulletContainer.listIterator();
while (iterator.hasNext()) {
Bullet bullet = iterator.next();
bullet.paint(g);
if (bullet.getX() > this.GAME_WIDTH || bullet.getY() > this.GAME_HEIGHT) {
iterator.remove();
}
}*/
// 2.可行解决方案二:
for (int i = 0; i < bulletContainer.size(); i++) {
bulletContainer.get(i).paint(g);
}
// 3.碰撞判断
for (int i = bulletContainer.size() - 1; i >= 0; i--) {
for (int j = enemyTankContainer.size() - 1; j >= 0; j--) {
bulletContainer.get(i).collideWithTank(enemyTankContainer.get(j));
}
}
for (int i = 0; i < explodes.size(); i++) {
explodes.get(i).paint(g);
}
}
public class MyKeyListener extends KeyAdapter {
boolean bL = false;
boolean bU = false;
boolean bR = false;
boolean bD = false;
// 1.键按下
@Override
public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
switch (key) {
case KeyEvent.VK_LEFT:
bL = true;
break;
case KeyEvent.VK_RIGHT:
bR = true;
break;
case KeyEvent.VK_UP:
bU = true;
break;
case KeyEvent.VK_DOWN:
bD = true;
break;
default:
break;
}
setMainTankDir();
}
// 2.键释放
@Override
public void keyReleased(KeyEvent e) {
int key = e.getKeyCode();
switch (key) {
case KeyEvent.VK_LEFT:
bL = false;
break;
case KeyEvent.VK_RIGHT:
bR = false;
break;
case KeyEvent.VK_UP:
bU = false;
break;
case KeyEvent.VK_DOWN:
bD = false;
break;
case KeyEvent.VK_CONTROL:
mainTank.fire();
// bulletContainer.add(b);
break;
default:
break;
}
setMainTankDir();
}
private void setMainTankDir() {
// Tank mainTank = getMainTank();
if (!bL && !bU && !bR && !bD) {
mainTank.setMoving(false);
} else {
mainTank.setMoving(true);
if (bL) mainTank.setDir(Dir.LEFT);
if (bU) mainTank.setDir(Dir.UP);
if (bR) mainTank.setDir(Dir.RIGHT);
if (bD) mainTank.setDir(Dir.DOWN);
}
}
}
/* public Tank getMainTank(){
return this.mainTank;
}*/
}
|
package com.xxw.pattern.factory.entity;
/**
* @author xiongxianwei
* 2020/6/5 0005
*/
public class DellMouse implements Mouse {
@Override
public void sayHi() {
System.out.println("生产戴尔鼠标");
}
}
|
package models.analise_sintaxe;
import models.pilha.PilhaEncadeada;
public class AnaliseSintaxe{
PilhaEncadeada pilha;
public AnaliseSintaxe(){
pilha = new PilhaEncadeada();
}
public boolean analisador(String frase){
int tam = frase.length() - 1;
for(int i = 0; i <= tam; i++){
// não é número?
char l = frase.charAt(i);
if(!number(l)){
// não é operador
if(!operador(l)){
if(parenteses(l) == 1){
if(pilha.estaVazia()){
pilha.push(l);
}else{
char aux = pilha.pop().toString().charAt(0);
if(operador(aux)){
pilha.push(l);
}else if(parenteses(aux) == 1){
pilha.push(aux);
pilha.push(l);
}else if(parenteses(aux) == 2){
return false;
}
}
}else if(parenteses(l) == 2){
if(pilha.estaVazia()){
return false;
}else{
char aux = pilha.pop().toString().charAt(0);
if(parenteses(aux) != 1){
return false;
}
}
}
}
// é operador
else{
if(pilha.estaVazia()){
pilha.push(l);
}else{
char aux = pilha.pop().toString().charAt(0);
if(operador(aux)){
return false;
}else{
pilha.push(aux);
pilha.push(l);
}
}
}
}else{
if(!pilha.estaVazia()){
char aux = pilha.pop().toString().charAt(0);
if(!operador(aux)){
if(parenteses(aux) == 2){
return false;
}
pilha.push(aux);
}
}
}// if number
}//fim for
if(pilha.estaVazia()){
return true;
}else{
return false;
}
}//fim método
private int parenteses(char par){
if(par == '('){
return 1;
}else if(par == ')'){
return 2;
}else{
return 0;
}
}
private boolean operador(char op){
switch(op){
case '+':
return true;
case '-':
return true;
case '*':
return true;
case '/':
return true;
default:
return false;
}
}
private boolean number(char numb){
switch(numb){
case '0':
return true;
case '1':
return true;
case '2':
return true;
case '3':
return true;
case '4':
return true;
case '5':
return true;
case '6':
return true;
case '7':
return true;
case '8':
return true;
case '9':
return true;
default:
return false;
}
}
}//fim classe
|
/*
* 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 listaoo.questao4;
import listaoo.questao3.Hora;
/**
*
* @author acer
*/
public class Estacionamento {
private String nchapa;
private String marca;
private Hora entrada ;
private Hora saida;
public Estacionamento(){
}
public String getNchapa() {
return nchapa;
}
public void setNchapa(String nchapa) {
this.nchapa = nchapa;
}
public String getMarca() {
return marca;
}
public void setMarca(String marca) {
this.marca = marca;
}
public Hora getEntrada() {
return entrada;
}
public void setEntrada(Hora entrada) {
this.entrada = entrada;
}
public Hora getSaida() {
return saida;
}
public void setSaida(Hora saida) {
this.saida = saida;
}
public void entrada(String marca, String numero, Hora x , Hora y){
setMarca(marca);
setNchapa(numero);
setEntrada(x);
setSaida(y);
}
public String mostra(){
return "Marca: "+getMarca()+" "+"Nº "+getNchapa()+" "+"Hora entrada: "+entrada.imprimir()+" "+"Hora Saida: "+saida.imprimir();
}
public double valor(){
int hora;
int minuto;
int segundo;
hora=saida.getHora()-entrada.getHora();
minuto = saida.getMinuto()-entrada.getMinuto();
segundo = saida.getSegundo()-entrada.getSegundo();
if (minuto>0) {
hora=(hora*1)+1;
}else{
hora=hora*1;
}
return hora;
}
}
|
package com.lingnet.vocs.dao.impl.bominfo;
import java.util.HashMap;
import java.util.List;
import javax.annotation.Resource;
import org.hibernate.Criteria;
import org.hibernate.SQLQuery;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import com.lingnet.common.dao.impl.BaseDaoImplInit;
import com.lingnet.common.service.BaseService;
import com.lingnet.vocs.dao.bominfo.DwDao;
import com.lingnet.vocs.dao.bominfo.ItemDao;
import com.lingnet.vocs.dao.jcsj.GoodcatManageDao;
import com.lingnet.vocs.entity.Goodcat;
import com.lingnet.vocs.entity.Item;
import com.lingnet.vocs.entity.Jcsj_Dw;
/**
*
* @ClassName: ItemDaoImpl
* @Description: 商品的dao接口实现类
* @author 张丽丽
* @date 2017-10-11 上午8:19:31
*
*/
@Repository("itemDao")
public class ItemDaoImpl extends BaseDaoImplInit<Item, String> implements ItemDao{
@SuppressWarnings("rawtypes")
@Resource(name = "baseService")
private BaseService baseService;
@Resource(name = "goodcatManageDao")
private GoodcatManageDao goodcatManageDao;
@Resource(name="dwDao")
private DwDao dwDao;
// @Resource(name = "locStkLocDao")
// private LocStkLocDao locStkLocDao;
private Goodcat goodcat;//商品种类及编码设置
private Jcsj_Dw dw;//商品种类及编码设置
private static int seq = 0;
private static long currentTime = 0;
/**
* 根据id查询某一条商品数据
*/
@Override
public Item getItem(String id) {
String HQL="FROM Item as item WHERE item.id=?";
return uniqueResult(HQL,id);
}
/**
* 根据商品编号查询商品信息
* @pramat wlbh 商品编号
* @return item 商品实体
*/
@Override
public Item gentbycode(String wlbh){
Item Item=null;
if(wlbh!=null&&!("".equals(wlbh))){
Criteria criteria = getSession().createCriteria(Item.class);
criteria.add(Restrictions.eq("itemCode", wlbh));
criteria.add(Restrictions.eq("is_delete", "0"));
Item=(Item)criteria.uniqueResult();
}
return Item;
}
@Override
public Item getbyName(String name, String itemclassId, String des1) {
String Hql = "from item where name = ? and itemclassId = ? and des1 = ? and is_delete = '0'";
return uniqueResult(Hql, name, itemclassId, des1);
}
@SuppressWarnings("unchecked")
@Override
public String finItems(String name) {
String sql = "select item_code from item where name like '%"+name+"%'";
SQLQuery query=this.getSession().createSQLQuery(sql.toString());
List<Object> list = query.list();
String itemCode = "";
for(int i=0;i<list.size();i++){
itemCode = list.get(i).toString()+",";
}
if(!"".equals(itemCode)){
itemCode = itemCode.substring(0, itemCode.length()-1);
}
return itemCode;
}
/**
* 商品编码生成公共方法
* @Title: getCode
* @param goodcat
* @param hashmap
* @return
* String
* @author mazm
* @throws Exception
* @since 2016-7-29 V 1.0
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public String getCode(Goodcat goodcat, HashMap hashmap) throws Exception {
String Codeheader = null;
String Goodcatname = null;
String itemcode = null;
Codeheader = goodcat.getCodeheader();
Goodcatname = goodcat.getGoodcatname();
if (hashmap.size()>0&&hashmap.get(Goodcatname)!=null) {
System.out.println(hashmap.get(Goodcatname).toString());
String aaa =hashmap.get(Goodcatname).toString();
aaa = aaa.substring(Codeheader.length() + 1);
Long bb = Long.valueOf(aaa) + 1;
String cc = bb + "";
StringBuffer sb = null;
for (int z = cc.length(); z < 8; z++) {
sb = new StringBuffer();
sb.append("0").append(cc);// 左(前)补0
// sb.append(cc).append("0");//右(后)补0
cc = sb.toString();
}
itemcode = Codeheader+"-"+cc;
hashmap.put(Goodcatname,itemcode);
} else {
StringBuilder sqls = new StringBuilder();
int code=Codeheader.length() + 9;
sqls.append(" SELECT max(item_code) FROM item WHERE item_code LIKE '%"
+ Codeheader
+ "-%' AND LENGTH(ITEM_CODE)="
+ code + " ");
SQLQuery query = this.getSession().createSQLQuery(
sqls.toString());
List<Object> aa = query.list();
try{
if (aa.size() > 0) {
if (aa.get(0) != null) {
String s = aa.get(0).toString();
s = s.substring(Codeheader.length() + 1);
Long bb = Long.valueOf(s) + 1;
String cc = bb + "";
int strLen = cc.length();
int stra = s.length();
StringBuffer sb = null;
for (int z = strLen; z < 8; z++) {
sb = new StringBuffer();
sb.append("0").append(cc);// 左(前)补0
// sb.append(cc).append("0");//右(后)补0
cc = sb.toString();
}
itemcode=Codeheader+"-"+cc;
hashmap.put(Goodcatname, itemcode);
}else{
itemcode=Codeheader+"-00000001";
hashmap.put(Goodcatname, itemcode);
}
}
}catch (Exception e) {
// TODO: handle exception
throw new Exception("上传表格中有未加商品编码商品,商品编码超出系统自动生成范围,请自行编码再上传!");
}
}
return itemcode;
}
@Override
public String findSequence() {
String sql= "SELECT NEXT VALUE FOR ItemCode;";
Object result = this.getSession().createSQLQuery(sql).uniqueResult();
return result.toString();
}
}
|
package day04operators;
public class Modulus01 {
public static void main(String[] args) {
// 12835 sayisini 23 e bolumunde kalan prog yaz
System.out.println(12835%23);//Hard Coding: dogrudan sayi kullanmaya denir
int sayi1 = 12835;
int sayi2 = 23;
//int sonuc = sayi1 % sayi2; bu sekilde de kullanabiliriz birden fayla kullsnacaksak
System.out.println(sayi1 % sayi2);
}
}
|
package com.abst;
public class Circle extends Shape implements Comparable<Circle>{
int r;
public Circle(int r) {
this.r =r;
}
@Override
public double getArea() {
return 3.14*r*r;
}
@Override
public double getCircum() {
return 2*3.14*r;
}
@Override
public int compareTo(Circle o) {
return o.r -r;
}
@Override
public String toString() {
return "Circle [r=" + r + "]";
}
}
|
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Class for the Club symbol.
* Stores the club image.
* @author Saksham Ghimire and Densai Moua
* @version 12/15/2010
*/
public class club extends Actor
{
/**
* Act - do whatever the club wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
}
|
/**
*
* @author Erich Ostendarp
* @version 0
*/
public class View
{
}
|
package com.alanb.gesturecommon;
public class NanoTimer
{
private long start = 0;
private long finish = 0;
private boolean running = false;
public void begin() { this.start = System.nanoTime(); this.finish = this.start; this.running = true; }
public void check() { this.finish = System.nanoTime(); }
public void end() { this.running = false; }
public boolean running() { return running; }
public long getDiff()
{
return this.finish - this.start;
}
public double getDiffInSeconds()
{
return getDiff() / (double)(1.0e9);
}
}
|
package mop.main.java.database.objectrelationalmapping.helpers;
import java.util.ArrayList;
import mop.main.java.backend.caching.Cache;
import mop.main.java.backend.utilities.Log;
import mop.main.java.common.Constants;
import mop.main.java.common.exceptions.EntityMetadataException;
import mop.main.java.database.model.writable.Writable;
import org.apache.logging.log4j.Logger;
public class SqlGenerator {
private static final Logger log = Log.getLog(SqlGenerator.class);
/**
* Generates the a sql string to delete an entity.
* @param entityType, the name of the entity to be retrieved
* @param id, the id of the entity to be retrieved
* @return the get script as a string
*/
public String generateGetScript(String entityType, int id, Cache cache) {
if(entityType == null || entityType.equals("")) {
log.error("Cannot generate get script with null or empty entity name.");
throw new IllegalArgumentException("Cannot generate get script with null or empty entity name.");
}
return String.format("SELECT * FROM %1$s.%2$s WHERE %2$sId = %3$d LIMIT 1",
cache.get(Constants.AppConfigSections.defaultSchema),
entityType,
id
);
}
/**
* Generates scripts to save an entity and any related entities.
* @param entity, the entity to save
* @return an array of string scripts
* @throws EntityMetadataException
*/
public <T extends Writable> String[] generateSaveScripts(T entity, Cache cache) throws EntityMetadataException {
EntityMetadata metadata = entity.getMetadata(null);
ArrayList<Entity> entities = metadata.getEntities();
String[] scripts = new String[entities.size()];
for(int i = 0; i < entities.size(); i++) {
Entity temp = entities.get(i);
StringBuilder values = new StringBuilder();
StringBuilder columns = new StringBuilder();
StringBuilder script = this.constructHeader((String) cache.get(Constants.AppConfigSections.defaultSchema), temp.getTableName().toString());
script.append("(");
values.append(" VALUES (");
ArrayList<Attribute> attributes = temp.getAttributes();
for(int a = 0; a < attributes.size(); a ++) {
Attribute attribute = attributes.get(a);
columns.append(attribute.getName());
String value = this.formatValue(attribute);
values.append(value);
if((a + 1) < attributes.size()) {
columns.append(", ");
values.append(", ");
}
}
columns.append(")");
values.append(");");
script.append(columns);
script.append(values);
scripts[i] = script.toString();
}
return scripts;
}
/**
* Generates the a sql string to delete an entity.
* @param entityType, the name of the entity to be deleted
* @param id, the id of the entity to be deleted
* @return the delete script as a string
*/
public String generateDeleteScript(String entityType, int id, Cache cache) {
if(entityType == null || entityType.equals("")) {
log.error("Cannot generate delete script with null or empty entity name.");
throw new IllegalArgumentException("Cannot generate delete script with null or empty entity name.");
}
return String.format("DELETE FROM %1$s.%2$s WHERE %2$sId = %3$d",
cache.get(Constants.AppConfigSections.defaultSchema),
entityType,
id
);
}
/**
* Prepares a field value for use in a sql statement.
* @param attribute, contains the field type, and value
* @return a string representation of
*/
private String formatValue(Attribute attribute) {
// if the attribute is a String then surround with quotes
if(attribute.getType() == String.class) {
return "'" + attribute.getValue() + "'";
}
// if the field is a boolean then convert to either 0 or 1
if(attribute.getType() == boolean.class) {
return (boolean) attribute.getValue() ? "1" : "0";
}
return attribute.getValue() + "";
}
private StringBuilder constructHeader(String schema, String table) {
StringBuilder builder = new StringBuilder();
builder.append("INSERT INTO ");
builder.append(schema);
builder.append(".");
builder.append(table);
builder.append(" ");
return builder;
}
}
|
package org.libGlobal;
public class TestProgram {
public static void UserName() {
System.out.println("UserName");
}
public static void main(String[] args) {
UserName();
}
}
|
package com.ims.dto;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.type.TrueFalseType;
@Entity
@Table(name = "product_master")
public class ProductMasterDTO implements Serializable {
int id;
String productCode;
String productName;
String weight_unit;
ProductGroupMapDTO prGroupMapDTO;
String qty_unit;
boolean sub_item_type_req;
private String gown;
@Id
@Column(name = "id")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="product_master_seq_gen")
@SequenceGenerator(
name="product_master_seq_gen",
sequenceName="product_master_seqs",
allocationSize=1
)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "product_code" ,unique=true)
public String getProductCode() {
if(productCode!=null)
productCode=productCode.trim();
return productCode;
}
public void setProductCode(String productCode) {
this.productCode = productCode;
}
@Column(name = "product_name",unique=true)
public String getProductName() {
if(productName!=null)
productName=productName.trim();
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "group_id")
@Cascade({CascadeType.SAVE_UPDATE})
public ProductGroupMapDTO getPrGroupMapDTO() {
return prGroupMapDTO;
}
public void setPrGroupMapDTO(ProductGroupMapDTO prGroupMapDTO) {
this.prGroupMapDTO = prGroupMapDTO;
}
@Column(name = "weight_unit")
public String getWeight_unit() {
return weight_unit;
}
public void setWeight_unit(String weight_unit) {
this.weight_unit = weight_unit;
}
@Column(name = "qty_unit")
public String getQty_unit() {
return qty_unit;
}
public void setQty_unit(String qty_unit) {
this.qty_unit = qty_unit;
}
@Column(name = "is_sub_item_type_req")
public boolean isSub_item_type_req() {
return sub_item_type_req;
}
public void setSub_item_type_req(boolean sub_item_type_req) {
this.sub_item_type_req = sub_item_type_req;
}
@Column(name="gown")
public String getGown() {
return gown;
}
public void setGown(String gown) {
this.gown = gown;
}
/*public boolean getSub_item_type_req() {
return sub_item_type_req;
}
public void setSub_item_type_req(boolean sub_item_type_req) {
this.sub_item_type_req = sub_item_type_req;
}*/
}
|
package com.smxknife.java.ex1;
public class OddDemo2 {
public static void main(String[] args) {
for (int i = -10; i < 10; i++) {
mod2(i);
}
}
public static void mod2(int i) {
System.out.println(i + " % 2 = " + (i % 2));
}
}
|
package InnferClass;
/**
* 匿名内部类的演示
* @author Administrator
*
*/
public class InnerClass_niming {
public static void main(String[] args) {
//1.创建了Inter2的一个子类,没有名字
//2.为该子类创建了一个对象,引用叫o1
//3.大括号中的为子类的类体
Inter2 o1 = new Inter2(){
};
//1.“又”创建了Inter2的一个子类,没有名字
//2.为该子类创建了一个对象,引用叫o2
//3.大括号中的为子类的类体
Inter2 o2 = new Inter2(){
};
final int num=5;
//1.创建了Inter3的一个子类,没有名字
//2.为该子类创建了一个对象,引用叫o3
//3.大括号中的为子类的类体
Inter3 o3 = new Inter3(){
public void show() {
System.out.println("showshow");
System.out.println(num);
}
};
o3.show();
}
}
interface Inter3{
public void show();
}
interface Inter2{
}
|
package kr.ac.hansung.cst.recycleback.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.jsoup.nodes.Element;
import javax.persistence.Entity;
import javax.persistence.Table;
@Getter
@Setter
@ToString
@NoArgsConstructor
public class Article {
int num;
String pageUrl;
String imgSrc;
String title;
String date;
}
|
package com.example.timerapp;
import android.os.AsyncTask;
import android.os.Bundle;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import java.util.TimerTask;
public class MainActivity extends AppCompatActivity {
TextView countdown, textView2;
FloatingActionButton fab;
EditText editText;
String[] strings;
Spinner spinner;
AsyncTaskCD taskCD;
ThreadCD threadCD;
TimerTaskThread taskThread;
boolean hasStarted;
boolean runningThread;
int seconds;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
strings = getResources().getStringArray(R.array.spinner);
countdown = findViewById(R.id.textView);
textView2 = findViewById(R.id.textView2);
spinner = findViewById(R.id.spinner);
editText = findViewById(R.id.editText);
taskCD = new AsyncTaskCD();
threadCD = new ThreadCD();
taskThread = new TimerTaskThread();
fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (editText.getText().toString().isEmpty()) {
seconds = 10;
} else {
seconds = Integer.parseInt(editText.getText().toString());
}
if (spinner.getSelectedItem().equals(strings[0])) {
if (taskCD.getStatus() == AsyncTaskCD.Status.RUNNING) {
taskCD.cancel(true);
textView2.setText(getResources().getString(R.string.button_start));
fab.setImageDrawable(getDrawable(R.drawable.ic_action_start_timer));
countdown.setText(getResources().getString(R.string.timer_start));
Toast.makeText(MainActivity.this, getResources().getString(R.string.finished_by_user), Toast.LENGTH_LONG).show();
} else {
taskCD = new AsyncTaskCD();
taskCD.execute();
}
} else if (spinner.getSelectedItem().equals(strings[1])) {
if (threadCD.isAlive()) {
runningThread = false;
textView2.setText(getResources().getString(R.string.button_start));
fab.setImageDrawable(getDrawable(R.drawable.ic_action_start_timer));
countdown.setText(getResources().getString(R.string.timer_start));
Toast.makeText(MainActivity.this, getResources().getString(R.string.finished_by_user), Toast.LENGTH_LONG).show();
} else {
textView2.setText(getResources().getString(R.string.button_stop));
fab.setImageDrawable(getDrawable(R.drawable.ic_action_stop_timer));
runningThread = true;
threadCD = new ThreadCD();
threadCD.start();
}
} else if (spinner.getSelectedItem().equals(strings[2])) {
if (hasStarted) {
hasStarted = false;
textView2.setText(getResources().getString(R.string.button_start));
fab.setImageDrawable(getDrawable(R.drawable.ic_action_start_timer));
countdown.setText(getResources().getString(R.string.timer_start));
Toast.makeText(MainActivity.this, getResources().getString(R.string.finished_by_user), Toast.LENGTH_LONG).show();
} else {
textView2.setText(getResources().getString(R.string.button_stop));
fab.setImageDrawable(getDrawable(R.drawable.ic_action_stop_timer));
hasStarted = true;
taskThread = new TimerTaskThread();
Thread thread = new Thread(taskThread);
thread.start();
}
}
}
});
}
private class AsyncTaskCD extends AsyncTask<Void, Integer, Void> {
@Override
protected void onPreExecute() {
textView2.setText(getResources().getString(R.string.button_stop));
fab.setImageDrawable(getDrawable(R.drawable.ic_action_stop_timer));
}
@Override
protected Void doInBackground(Void... params) {
for(int i=seconds; i >= 0; i--){
try {
Thread.sleep(1000);
publishProgress(i);
} catch (InterruptedException e) {
Toast.makeText(MainActivity.this, getResources().getString(R.string.err), Toast.LENGTH_LONG).show();
}
}
return null;
}
@Override
protected void onProgressUpdate(Integer... values) {
countdown.setText(String.valueOf(values[0]));
}
@Override
protected void onPostExecute(Void result) {
textView2.setText(getResources().getString(R.string.button_start));
fab.setImageDrawable(getDrawable(R.drawable.ic_action_start_timer));
countdown.setText(getResources().getString(R.string.timer_start));
Toast.makeText(MainActivity.this, getResources().getString(R.string.finished), Toast.LENGTH_LONG).show();
}
}
private class ThreadCD extends Thread {
@Override
public void run() {
for(int i=seconds; i >= 0; i--){
if (!runningThread) {
interrupt();
break;
}
try {
Thread.sleep(1000);
setValue(i);
} catch (InterruptedException e) {
e.getMessage();
}
}
runOnUiThread(new Runnable() {
@Override
public void run() {
textView2.setText(getResources().getString(R.string.button_start));
fab.setImageDrawable(getDrawable(R.drawable.ic_action_start_timer));
countdown.setText(getResources().getString(R.string.timer_start));
if (runningThread) {
Toast.makeText(MainActivity.this, getResources().getString(R.string.finished), Toast.LENGTH_LONG).show();
}
}
});
}
void setValue(final int i) {
runOnUiThread(new Runnable() {
@Override
public void run() {
countdown.setText(String.valueOf(i));
}
});
}
}
private class TimerTaskThread extends TimerTask {
@Override
public void run() {
for(int i=seconds; i >= 0; i--){
if (!hasStarted) {
cancel();
break;
}
try {
Thread.sleep(1000);
setValue(i);
} catch (InterruptedException e) {
e.getMessage();
}
}
runOnUiThread(new Runnable() {
@Override
public void run() {
textView2.setText(getResources().getString(R.string.button_start));
fab.setImageDrawable(getDrawable(R.drawable.ic_action_start_timer));
countdown.setText(getResources().getString(R.string.timer_start));
if (hasStarted) {
Toast.makeText(MainActivity.this, getResources().getString(R.string.finished), Toast.LENGTH_LONG).show();
}
}
});
hasStarted = false;
}
void setValue(final int i) {
runOnUiThread(new Runnable() {
@Override
public void run() {
countdown.setText(String.valueOf(i));
}
});
}
}
}
|
package com.vikastadge.hibernate.xml.dao;
import com.vikastadge.hibernate.xml.dao.entity.PersonEntity;
import com.vikastadge.hibernate.xml.util.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class PersonDAO {
public void save(PersonEntity personEntity){
System.out.println("in DAO");
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction transaction = session.beginTransaction();
session.save(personEntity);
transaction.commit();
HibernateUtil.shutdown();
}
}
|
package InsertSort;
import SortUtil.SortUtil;
public class InsertTest {
public static void main(String[] args) {
int[] data = SortUtil.makeRandom(500);
InsertSort.ShellSort(data);
SortUtil.printData(data);
}
}
|
package assembler;
import java.io.IOException;
import java.io.PrintWriter;
public class ProcessController {
public static void main(String[] args) {
// TODO Auto-generated method stub
InstructionType type = new InstructionType("file2.txt");
try{
PrintWriter writer = new PrintWriter("the-file-name.txt", "UTF-8");
for(int i=0;i<type.getFilelist().size();i++){
writer.println(type.getFilelist().get(i));
}
writer.close();
} catch(IOException e) {
// do something
System.out.println("file not found");
}
}
}
|
/**
* 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 org.apache.hadoop.mapred;
import java.io.File;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapred.ClusterWithLinuxTaskController.MyLinuxTaskController;
import org.apache.hadoop.mapreduce.filecache.TestTrackerDistributedCacheManager;
import org.apache.hadoop.security.UserGroupInformation;
/**
* Test the DistributedCacheManager when LinuxTaskController is used.
*
*/
public class TestTrackerDistributedCacheManagerWithLinuxTaskController extends
TestTrackerDistributedCacheManager {
private File configFile;
private static final Log LOG =
LogFactory
.getLog(TestTrackerDistributedCacheManagerWithLinuxTaskController.class);
@Override
protected void setUp()
throws IOException, InterruptedException {
if (!ClusterWithLinuxTaskController.shouldRun()) {
return;
}
TEST_ROOT_DIR =
new File(System.getProperty("test.build.data", "/tmp"),
TestTrackerDistributedCacheManagerWithLinuxTaskController.class
.getSimpleName()).getAbsolutePath();
super.setUp();
taskController = new MyLinuxTaskController();
String path =
System.getProperty(ClusterWithLinuxTaskController.TASKCONTROLLER_PATH);
String execPath = path + "/task-controller";
((MyLinuxTaskController)taskController).setTaskControllerExe(execPath);
taskController.setConf(conf);
taskController.setup();
}
@Override
protected void refreshConf(Configuration conf) throws IOException {
super.refreshConf(conf);
String path =
System.getProperty(ClusterWithLinuxTaskController.TASKCONTROLLER_PATH);
configFile =
ClusterWithLinuxTaskController.createTaskControllerConf(path, conf);
}
@Override
protected void tearDown()
throws IOException {
if (!ClusterWithLinuxTaskController.shouldRun()) {
return;
}
if (configFile != null) {
configFile.delete();
}
super.tearDown();
}
@Override
protected boolean canRun() {
return ClusterWithLinuxTaskController.shouldRun();
}
@Override
protected String getJobOwnerName() {
String ugi =
System.getProperty(ClusterWithLinuxTaskController.TASKCONTROLLER_UGI);
String userName = ugi.split(",")[0];
return userName;
}
@Override
protected void checkFilePermissions(Path[] localCacheFiles)
throws IOException {
String userName = getJobOwnerName();
String filePermissions = UserGroupInformation.getLoginUser()
.getShortUserName().equals(userName) ? "-rwxrwx---" : "-r-xrwx---";
for (Path p : localCacheFiles) {
// First make sure that the cache file has proper permissions.
TestTaskTrackerLocalization.checkFilePermissions(p.toUri().getPath(),
filePermissions, userName,
ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
// Now. make sure that all the path components also have proper
// permissions.
checkPermissionOnPathComponents(p.toUri().getPath(), userName);
}
}
/**
* @param cachedFilePath
* @param userName
* @throws IOException
*/
private void checkPermissionOnPathComponents(String cachedFilePath,
String userName)
throws IOException {
// The trailing distcache/file/... string
String trailingStringForFirstFile =
cachedFilePath.replaceFirst(ROOT_MAPRED_LOCAL_DIR.getAbsolutePath()
+ Path.SEPARATOR + "0_[0-" + (numLocalDirs - 1) + "]"
+ Path.SEPARATOR + TaskTracker.getPrivateDistributedCacheDir(userName),
"");
LOG.info("Trailing path for cacheFirstFile is : "
+ trailingStringForFirstFile);
// The leading mapreduce.cluster.local.dir/0_[0-n]/taskTracker/$user string.
String leadingStringForFirstFile =
cachedFilePath.substring(0, cachedFilePath
.lastIndexOf(trailingStringForFirstFile));
LOG.info("Leading path for cacheFirstFile is : "
+ leadingStringForFirstFile);
String dirPermissions = UserGroupInformation.getLoginUser()
.getShortUserName().equals(userName) ? "drwxrws---" : "dr-xrws---";
// Now check path permissions, starting with cache file's parent dir.
File path = new File(cachedFilePath).getParentFile();
while (!path.getAbsolutePath().equals(leadingStringForFirstFile)) {
TestTaskTrackerLocalization.checkFilePermissions(path.getAbsolutePath(),
dirPermissions, userName,
ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
path = path.getParentFile();
}
}
}
|
package com.smxknife.servlet.springboot.demo04;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.util.ClassUtils;
/**
* @author smxknife
* 2020/2/12
*/
public class Demo4AnnoImportRegistrator implements ImportBeanDefinitionRegistrar, EnvironmentAware {
private Environment environment;
@Override
public void setEnvironment(Environment environment) {
this.environment = environment;
}
@Override
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry beanDefinitionRegistry) {
// 创建一个classpath的scanner
ClassPathScanningCandidateComponentProvider scanner = getScanner();
// 添加一个扫描的拦截器,只让被TestUtil注解装饰的class过
scanner.addIncludeFilter(new AnnotationTypeFilter(Demo4Anno.class));
for(BeanDefinition beanDefinition : scanner.findCandidateComponents(ClassUtils.getPackageName(annotationMetadata.getClassName()))){
// 对于扫描出来的BeanDefinition,如果class是TestInferface
if(beanDefinition.getBeanClassName().equals(Demo4AnnoInterface.class.getCanonicalName())){
// 就将实现类TestImpl当做bean class 添加到beanDefinitionRegistry
// 方便后面容器启动创建bean的时候创建出来
beanDefinition.setBeanClassName(Demo4AnnoInterfaceImpl.class.getCanonicalName());
beanDefinitionRegistry.registerBeanDefinition(ClassUtils.getShortName(Demo4AnnoInterface.class), beanDefinition);
}
}
}
private ClassPathScanningCandidateComponentProvider getScanner(){
// 创建一个class path scanner
return new ClassPathScanningCandidateComponentProvider(false, environment){
@Override
protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
// 只要候选的class是个interface就让他过
return beanDefinition.getMetadata().isInterface();
}
};
}
}
|
package org.motechproject.server.service.impl;
import org.junit.*;
import org.mockito.Mock;
import org.motechproject.server.svc.RegistrarBean;
import org.motechproject.server.util.MotechConstants;
import org.openmrs.Encounter;
import org.openmrs.Patient;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
public class RegistrationRequirementTest {
private RegistrationRequirement requirement;
@Mock
private RegistrarBean registerBean;
@Before
public void setup() {
initMocks(this);
requirement = new RegistrationRequirement();
requirement.setRegistrarBean(registerBean);
}
@Test
public void shouldReturnTrueWhenPatientIsRegisteredAfterValidDate() {
Calendar cal = Calendar.getInstance();
cal.set(2000, 1, 1);
Date birthDate = cal.getTime();
cal.set(2011, 4, 19);
Date validRegDate = cal.getTime();
cal.set(2011, 5, 19);
Date encounterDate = cal.getTime();
Patient patient = new Patient();
patient.setBirthdate(birthDate);
Encounter encounter = new Encounter();
encounter.setEncounterDatetime(encounterDate);
when(registerBean.getChildRegistrationDate()).thenReturn(validRegDate);
when(registerBean.getEncounters(patient, MotechConstants.ENCOUNTER_TYPE_PATIENTREGVISIT, patient.getBirthdate())).thenReturn(Arrays.asList(encounter));
assertTrue(requirement.meetsRequirement(patient, new Date()));
}
@Test
public void shouldReturnFalseWhenPatientIsRegisteredBeforeValidDate() {
Calendar cal = Calendar.getInstance();
cal.set(2000, 1, 1);
Date birthDate = cal.getTime();
cal.set(2011, 4, 19);
Date validRegDate = cal.getTime();
cal.set(2011, 3, 19);
Date encounterDate = cal.getTime();
Patient patient = new Patient();
patient.setBirthdate(birthDate);
Encounter encounter = new Encounter();
encounter.setEncounterDatetime(encounterDate);
when(registerBean.getChildRegistrationDate()).thenReturn(validRegDate);
when(registerBean.getEncounters(patient, MotechConstants.ENCOUNTER_TYPE_PATIENTREGVISIT, patient.getBirthdate())).thenReturn(Arrays.asList(encounter));
assertFalse(requirement.meetsRequirement(patient, new Date()));
}
@Test
public void shouldReturnFalseIfNoEncountersArePresentForPatient() {
Calendar cal = Calendar.getInstance();
cal.set(2000, 1, 1);
Date birthDate = cal.getTime();
cal.set(2011, 4, 19);
Date validRegDate = cal.getTime();
cal.set(2011, 3, 19);
Date encounterDate = cal.getTime();
Patient patient = new Patient();
patient.setBirthdate(birthDate);
Encounter encounter = new Encounter();
encounter.setEncounterDatetime(encounterDate);
when(registerBean.getChildRegistrationDate()).thenReturn(validRegDate);
when(registerBean.getEncounters(patient, MotechConstants.ENCOUNTER_TYPE_PATIENTREGVISIT, patient.getBirthdate())).thenReturn(Collections.EMPTY_LIST);
assertFalse(requirement.meetsRequirement(patient, new Date()));
}
}
|
package com.example.george.practica_1;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
public class Principal extends AppCompatActivity {
RadioGroup rdGroupCafe;
RadioButton rdButtonAme, rdButtonCap, rdButtonExp;
EditText editTextCant, editTextDesc;
CheckBox chkBoxAz, chkBoxCre;
Button buttonTotal;
int total;
int canttidad,cafe;
String descripcion;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_principal);
setContentView(R.layout.activity_principal);
rdGroupCafe = (RadioGroup) findViewById(R.id.rdGroupCafe);
rdButtonAme =(RadioButton)findViewById(R.id.rdButtonAme);
rdButtonCap =(RadioButton)findViewById(R.id.rdButtonCap);
rdButtonExp =(RadioButton)findViewById(R.id.rdButtonExp);
editTextCant = (EditText)findViewById(R.id.editTextCant);
editTextDesc = (EditText)findViewById(R.id.editTextDesc);
chkBoxAz = (CheckBox)findViewById(R.id.chkBoxAz);
chkBoxCre = (CheckBox)findViewById(R.id.chkBoxCre);
buttonTotal = (Button)findViewById(R.id.buttonTotal);
}
public void miClick (View e){
if (rdButtonAme.isChecked()){
cafe = 20;
descripcion = "Americano";
canttidad = Integer.parseInt(editTextCant.getText().toString());
if (chkBoxAz.isChecked()) {
cafe = cafe + 1;
descripcion = descripcion.concat(", Azucar");
}
if (chkBoxCre.isChecked()) {
cafe = cafe + 1;
descripcion = descripcion.concat(", Crema");
}
total = canttidad * cafe;
}else if (rdButtonCap.isChecked()){
cafe = 48;
descripcion = "Capuchino";
canttidad = Integer.parseInt(editTextCant.getText().toString());
if (chkBoxAz.isChecked()) {
cafe = cafe + 1;
descripcion = descripcion.concat(", Azucar");
}
if (chkBoxCre.isChecked()) {
cafe = cafe + 1;
descripcion = descripcion.concat(", Crema");
}
total = canttidad * cafe;
}else if (rdButtonExp.isChecked()){
cafe = 30;
descripcion = "Express";
canttidad = Integer.parseInt(editTextCant.getText().toString());
if (chkBoxAz.isChecked()) {
cafe = cafe + 1;
descripcion = descripcion.concat(", Azucar");
}
if (chkBoxCre.isChecked()) {
cafe = cafe + 1;
descripcion = descripcion.concat(", Crema");
}
total = cafe * canttidad;
}
Toast.makeText(this,""+ total, Toast.LENGTH_SHORT).show();
if (canttidad == 1) {
editTextDesc.setText(canttidad + " Cafe " + descripcion);
}
else if (canttidad == 0){
editTextDesc.setText("Coloque una cantidad mayor a 1");
}
else {
editTextDesc.setText(canttidad + " Cafes " + descripcion);
}
}
}
|
package workstarter.domain;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Objects;
/**
* A Project.
*/
@Entity
@Table(name = "project")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "project")
public class Project implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotNull
@Column(name = "title", nullable = false)
private String title;
@NotNull
@Column(name = "year", nullable = false)
private LocalDate year;
@Column(name = "image_url")
private String imageUrl;
@Column(name = "description")
private String description;
@Column(name = "link")
private String link;
@NotNull
@Column(name = "context", nullable = false)
private String context;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public Project title(String title) {
this.title = title;
return this;
}
public void setTitle(String title) {
this.title = title;
}
public LocalDate getYear() {
return year;
}
public Project year(LocalDate year) {
this.year = year;
return this;
}
public void setYear(LocalDate year) {
this.year = year;
}
public String getImageUrl() {
return imageUrl;
}
public Project imageUrl(String imageUrl) {
this.imageUrl = imageUrl;
return this;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getDescription() {
return description;
}
public Project description(String description) {
this.description = description;
return this;
}
public void setDescription(String description) {
this.description = description;
}
public String getLink() {
return link;
}
public Project link(String link) {
this.link = link;
return this;
}
public void setLink(String link) {
this.link = link;
}
public String getContext() {
return context;
}
public Project context(String context) {
this.context = context;
return this;
}
public void setContext(String context) {
this.context = context;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Project project = (Project) o;
if (project.id == null || id == null) {
return false;
}
return Objects.equals(id, project.id);
}
@Override
public int hashCode() {
return Objects.hashCode(id);
}
@Override
public String toString() {
return "Project{" +
"id=" + id +
", title='" + title + "'" +
", year='" + year + "'" +
", imageUrl='" + imageUrl + "'" +
", description='" + description + "'" +
", link='" + link + "'" +
", context='" + context + "'" +
'}';
}
}
|
package com.espendwise.manta.web.forms;
import com.espendwise.manta.model.data.AllUserData;
import com.espendwise.manta.model.view.AllStoreIdentificationView;
import com.espendwise.manta.model.view.UserIdentView;
import com.espendwise.manta.spi.Initializable;
import com.espendwise.manta.spi.Resetable;
import com.espendwise.manta.util.Constants;
import com.espendwise.manta.util.RefCodeNames;
import com.espendwise.manta.util.SelectableObjects;
import com.espendwise.manta.util.validation.Validation;
import com.espendwise.manta.web.validator.UserFormValidator;
import com.espendwise.manta.model.data.LanguageData;
import java.util.List;
@Validation(UserFormValidator.class)
public class UserForm extends WebForm implements Resetable, Initializable {
private boolean initialize;
private UserIdentView userInfo;
private AllUserData allUserData;
// User Information
private Long userId;
private String userLogonName;
private String userType;
private String userPassword;
private String userConfirmPassword;
private String userCode;
private String userLanguage;
private String userStatus;
private String userActiveDate;
private String userInactiveDate;
private String loginAsTarget = Constants.LOGIN_AS_TARGET.PROCUREMENT;
// User Contact Information
private UserContactInputForm userContact = new UserContactInputForm();
// Interactive Voice Response(IVR)
private String ivrUserIdentificationNumber;
private String ivrPIN;
private String ivrConfirmPIN;
// User Permissions
private Boolean approveOrders;
private Boolean browseOnly;
private Boolean corporateUser;
private Boolean doesNotUseReporting;
private Boolean updateBillToInformation;
private Boolean updateShipToInformation;
private String userRole;
// Payment
private Boolean creditCard;
private Boolean onAccount;
private Boolean otherPayment;
// Restrictions
private Boolean showPrices;
private Boolean poNumRequired;
private String defaultStoreId;
private SelectableObjects entities;
private List<AllStoreIdentificationView> allAdminStores;
private List<AllStoreIdentificationView> userStores;
private List<AllStoreIdentificationView> currentStore;
private boolean isClone;
private Long sourceUserId;
private boolean mainDbAlive;
private boolean multiStoreDb;
private List<LanguageData> availableLanguages;
public UserForm() {
}
public boolean isInitialize() {
return initialize;
}
public void setInitialize(boolean initialize) {
this.initialize = initialize;
}
public String getUserPassword() {
return userPassword;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getUserLogonName() {
return userLogonName;
}
public void setUserLogonName(String userLogonName) {
this.userLogonName = userLogonName;
}
public String getUserConfirmPassword() {
return userConfirmPassword;
}
public void setUserConfirmPassword(String userConfirmPassword) {
this.userConfirmPassword = userConfirmPassword;
}
public Boolean getApproveOrders() {
return approveOrders;
}
public void setApproveOrders(Boolean approveOrders) {
this.approveOrders = approveOrders;
}
public Boolean getBrowseOnly() {
return browseOnly;
}
public void setBrowseOnly(Boolean browseOnly) {
this.browseOnly = browseOnly;
}
public Boolean getCorporateUser() {
return corporateUser;
}
public void setCorporateUser(Boolean corporateUser) {
this.corporateUser = corporateUser;
}
public Boolean getCreditCard() {
return creditCard;
}
public void setCreditCard(Boolean creditCard) {
this.creditCard = creditCard;
}
public Boolean getDoesNotUseReporting() {
return doesNotUseReporting;
}
public void setDoesNotUseReporting(Boolean doesNotUseReporting) {
this.doesNotUseReporting = doesNotUseReporting;
}
public Boolean getOnAccount() {
return onAccount;
}
public void setOnAccount(Boolean onAccount) {
this.onAccount = onAccount;
}
public Boolean getOtherPayment() {
return otherPayment;
}
public void setOtherPayment(Boolean otherPayment) {
this.otherPayment = otherPayment;
}
public Boolean getPoNumRequired() {
return poNumRequired;
}
public void setPoNumRequired(Boolean poNumRequired) {
this.poNumRequired = poNumRequired;
}
public Boolean getShowPrices() {
return showPrices;
}
public void setShowPrices(Boolean showPrices) {
this.showPrices = showPrices;
}
public Boolean getUpdateBillToInformation() {
return updateBillToInformation;
}
public void setUpdateBillToInformation(Boolean updateBillToInformation) {
this.updateBillToInformation = updateBillToInformation;
}
public Boolean getUpdateShipToInformation() {
return updateShipToInformation;
}
public void setUpdateShipToInformation(Boolean updateShipToInformation) {
this.updateShipToInformation = updateShipToInformation;
}
public SelectableObjects getEntities() {
return entities;
}
public void setEntities(SelectableObjects entities) {
this.entities = entities;
}
public boolean isIsClone() {
return isClone;
}
public void setIsClone(boolean isClone) {
this.isClone = isClone;
}
public Long getSourceUserId() {
return sourceUserId;
}
public void setSourceUserId(Long sourceUserId) {
this.sourceUserId = sourceUserId;
}
public String getIvrConfirmPIN() {
return ivrConfirmPIN;
}
public void setIvrConfirmPIN(String ivrConfirmPIN) {
this.ivrConfirmPIN = ivrConfirmPIN;
}
public String getIvrPIN() {
return ivrPIN;
}
public void setIvrPIN(String ivrPIN) {
this.ivrPIN = ivrPIN;
}
public String getIvrUserIdentificationNumber() {
return ivrUserIdentificationNumber;
}
public void setIvrUserIdentificationNumber(String ivrUserIdentificationNumber) {
this.ivrUserIdentificationNumber = ivrUserIdentificationNumber;
}
public String getUserActiveDate() {
return userActiveDate;
}
public void setUserActiveDate(String userActiveDate) {
this.userActiveDate = userActiveDate;
}
public String getUserCode() {
return userCode;
}
public void setUserCode(String userCode) {
this.userCode = userCode;
}
public String getUserInactiveDate() {
return userInactiveDate;
}
public void setUserInactiveDate(String userInactiveDate) {
this.userInactiveDate = userInactiveDate;
}
public UserIdentView getUserInfo() {
return userInfo;
}
public void setUserInfo(UserIdentView userInfo) {
this.userInfo = userInfo;
}
public UserContactInputForm getUserContact() {
return userContact;
}
public void setUserContact(UserContactInputForm userContact) {
this.userContact = userContact;
}
public String getUserLanguage() {
return userLanguage;
}
public void setUserLanguage(String userLanguage) {
this.userLanguage = userLanguage;
}
public String getUserRole() {
return userRole;
}
public void setUserRole(String userRole) {
this.userRole = userRole;
}
public String getUserStatus() {
return userStatus;
}
public void setUserStatus(String userStatus) {
this.userStatus = userStatus;
}
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
public List<AllStoreIdentificationView> getAllAdminStores() {
return allAdminStores;
}
public void setAllAdminStores(List<AllStoreIdentificationView> allAdminStores) {
this.allAdminStores = allAdminStores;
}
public List<AllStoreIdentificationView> getCurrentStore() {
return currentStore;
}
public void setCurrentStore(List<AllStoreIdentificationView> currentStore) {
this.currentStore = currentStore;
}
public List<AllStoreIdentificationView> getUserStores() {
return userStores;
}
public void setUserStores(List<AllStoreIdentificationView> userStores) {
this.userStores = userStores;
}
public AllUserData getAllUserData() {
return allUserData;
}
public void setAllUserData(AllUserData allUserData) {
this.allUserData = allUserData;
}
@Override
public void initialize() {
initialize = true;
}
@Override
public boolean isInitialized() {
return initialize;
}
public boolean getIsNew() {
return isNew();
}
public boolean isNew() {
return isInitialized() && (userId == null || userId == 0);
}
public String getDefaultStoreId() {
return defaultStoreId;
}
public void setDefaultStoreId(String defaultStoreId) {
this.defaultStoreId = defaultStoreId;
}
public void setMainDbAlive(boolean mainDbAlive) {
this.mainDbAlive = mainDbAlive;
}
public boolean isMainDbAlive() {
return mainDbAlive;
}
public String getLoginAsTarget() {
return loginAsTarget;
}
public void setLoginAsTarget(String loginAsTarget) {
this.loginAsTarget = loginAsTarget;
}
public boolean isCanUseLoginAs() {
// bug MANTA-151
//return !isNew()
// && !RefCodeNames.USER_TYPE_CD.STORE_ADMINISTRATOR.equals(userType)
// && !RefCodeNames.USER_TYPE_CD.ADMINISTRATOR.equals(userType)
// && !RefCodeNames.USER_TYPE_CD.STORE_ADMINISTRATOR.equals(userType);
return !isNew() && RefCodeNames.USER_TYPE_CD.MULTI_SITE_BUYER.equals(userType);
}
@Override
public String toString() {
return "UserForm{)";
}
public void setMultiStoreDb(boolean mainDbOn) {
this.multiStoreDb = mainDbOn;
}
public boolean isMultiStoreDb() {
return multiStoreDb;
}
public void setAvailableLanguages(List<LanguageData> v) {
availableLanguages = v;
}
public List<LanguageData> getAvailableLanguages() {
return availableLanguages;
}
@Override
public void reset() {
approveOrders = false;
browseOnly = false;
corporateUser = false;
doesNotUseReporting = false;
updateBillToInformation = false;
updateShipToInformation = false;
ivrUserIdentificationNumber = null;
ivrPIN = null;
ivrConfirmPIN = null;
loginAsTarget = Constants.LOGIN_AS_TARGET.PROCUREMENT;
userCode = null;
}
}
|
package com.esprit.lyricsplus;
/**
* Created by aziz on 1/3/17.
*/
public class PlayerConfig {
public static final String API_KEY="AIzaSyByp4usFJQ0srWjFv0P3QXv7WJpp1eKWQ4";
public PlayerConfig() {
}
}
|
package Lab01.Zad6;
public class Worker{
public Commute commute;
public FreeTime spend;
public Work work;
public Worker(Commute commute, FreeTime spend, Work work){
this.commute = commute;
this.spend = spend;
this.work = work;
}
}
|
package ru.otus.models;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
public class StatisticEntitiesTest
{
@Test
public void equals()
{
StatisticEntities test = new StatisticEntities();
List<StatisticEntity> list = new ArrayList<>();
StatisticEntities expected = new StatisticEntities(list);
StatisticEntity entity = new StatisticEntity();
entity.setId(13L);
expected.add(entity);
Assert.assertFalse(expected.equals(test));
test.setRegistrations(list);
Assert.assertTrue(expected.equals(test));
}
}
|
class Main {
public static void main(String[] args) {
CasaUmQuarto c1 = new CasaUmQuarto();
CasaDoisQuartos c2 = new CasaDoisQuartos();
System.out.println("c1 tem "+c1.getMetrosQuadrados()+" m quadrados");
System.out.println("c2 tem "+c2.getMetrosQuadrados()+" m quadrados");
}
}
class CasaDoisQuartos{
private Quarto quarto1;
private Quarto quarto2;
private Banheiro banheiro;
private Sala sala;
private Cozinha cozinha;
public CasaDoisQuartos(){
this.quarto1 = new Quarto(5,4);
this.quarto2 = new Quarto(5,5);
this.banheiro = new Banheiro(2,1);
this.sala = new Sala(6,6);
this.cozinha = new Cozinha(3,4);
}
public double getMetrosQuadrados(){
return
this.quarto1.getMetrosQuadrados()+
this.quarto2.getMetrosQuadrados()+
this.banheiro.getMetrosQuadrados()+
this.sala.getMetrosQuadrados()+
this.cozinha.getMetrosQuadrados();
}
}
class CasaUmQuarto{
private Quarto quarto;
private Banheiro banheiro;
private Sala sala;
private Cozinha cozinha;
public CasaUmQuarto(){
this.quarto = new Quarto(5,4);
this.banheiro = new Banheiro(2,1);
this.sala = new Sala(6,6);
this.cozinha = new Cozinha(3,4);
}
public double getMetrosQuadrados(){
return
this.quarto.getMetrosQuadrados()+
this.banheiro.getMetrosQuadrados()+
this.sala.getMetrosQuadrados()+
this.cozinha.getMetrosQuadrados();
}
}
class Quarto{
private double largura;
private double profundidade;
public Quarto(double p, double l){
this.profundidade = p;
this.largura = l;
}
public double getLargura(){
return this.largura;
}
public double getProfudidade(){
return this.profundidade;
}
public double getMetrosQuadrados(){
return this.profundidade*this.largura;
}
public String getNome(){
return "Quarto";
}
}
class Cozinha{
private double largura;
private double profundidade;
public Cozinha(double p, double l){
this.profundidade = p;
this.largura = l;
}
public double getLargura(){
return this.largura;
}
public double getProfudidade(){
return this.profundidade;
}
public double getMetrosQuadrados(){
return this.profundidade*this.largura;
}
public String getNome(){
return "Cozinha";
}
}
class Sala{
private double largura;
private double profundidade;
public Sala(double p, double l){
this.profundidade = p;
this.largura = l;
}
public double getLargura(){
return this.largura;
}
public double getProfudidade(){
return this.profundidade;
}
public double getMetrosQuadrados(){
return this.profundidade*this.largura;
}
}
class Banheiro{
private double largura;
private double profundidade;
public Banheiro(double p, double l){
this.profundidade = p;
this.largura = l;
}
public double getLargura(){
return this.largura;
}
public double getProfudidade(){
return this.profundidade;
}
public double getMetrosQuadrados(){
return this.profundidade*this.largura;
}
public String getNome(){
return "Banheiro";
}
}
|
package com.tencent.mm.plugin.sns.data;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import java.util.LinkedList;
import java.util.List;
public class SnsCmdList implements Parcelable {
public static final Creator<SnsCmdList> CREATOR = new 1();
private int nkL = 0;
private int nkM = 0;
public List<Integer> nkN = new LinkedList();
public List<Integer> nkO = new LinkedList();
public final void wj(int i) {
this.nkN.add(Integer.valueOf(i));
}
public final void wk(int i) {
this.nkO.add(Integer.valueOf(i));
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel parcel, int i) {
int i2 = 0;
this.nkL = this.nkN.size();
parcel.writeInt(this.nkL);
for (int i3 = 0; i3 < this.nkL; i3++) {
parcel.writeInt(((Integer) this.nkN.get(i3)).intValue());
}
this.nkM = this.nkO.size();
parcel.writeInt(this.nkM);
while (i2 < this.nkM) {
parcel.writeInt(((Integer) this.nkO.get(i2)).intValue());
i2++;
}
}
}
|
package com.cranestylelabs.danhoffman.listviewsample.ui_tests;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;
import android.widget.TextView;
import com.cranestylelabs.danhoffman.listviewsample.R;
import com.cranestylelabs.danhoffman.listviewsample.activities.SimpleListViewActivity;
import com.cranestylelabs.danhoffman.listviewsample.ui_tests.custom_assertions.EspressoViewCountAssertion;
import org.junit.After;
import org.junit.Before;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
@LargeTest
public class SimpleListViewActivityTest extends ActivityInstrumentationTestCase2<SimpleListViewActivity> {
public SimpleListViewActivityTest() {
super(SimpleListViewActivity.class);
}
@Before
public void setUp() throws Exception {
super.setUp();
getActivity();
}
@After
public void tearDown() throws Exception {
super.tearDown();
}
public void testScreenText() {
onView(withId(R.id.screen_text)).check(matches(withText(R.string.simple_screen_text)));
}
public void testCountListItems() {
onView(withId(R.id.listView1)).check(EspressoViewCountAssertion.has(5, TextView.class));
}
}
|
package com.blackvelvet.cybos.bridge.cpsysdib ;
import com4j.*;
/**
* Defines methods to create COM objects
*/
public abstract class ClassFactory {
private ClassFactory() {} // instanciation is not allowed
/**
* CpField Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ICpField createCpField() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ICpField.class, "{BF085D15-ACE9-4E36-8E48-76BB29DA5584}" );
}
/**
* CpFields Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ICpFields createCpFields() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ICpFields.class, "{43733869-291F-43B0-B2EE-8019E7363B55}" );
}
/**
* CpSvrNew7224 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvrNew7224() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{E8931FA7-2E91-416F-85B8-F80351FD5C24}" );
}
/**
* CpSvr3745 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr3745() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{AF38F980-ABC8-4C99-8B95-19A1CC39ACB7}" );
}
/**
* CpSvr7043 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr7043() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{EA332802-B845-4C3D-8C3A-BBF6D0B11B79}" );
}
/**
* CpSvr8548 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr8548() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{DB6CADF4-515A-4845-BE7B-ECA2D93DAB26}" );
}
/**
* CpSvrNew7221 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvrNew7221() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{942C11D6-2DA7-4119-8D4F-493F0623C1B7}" );
}
/**
* CpSvrNew7221S Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvrNew7221S() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{8A0FAF47-A6A1-4518-B66A-61B7143C389C}" );
}
/**
* CpSvrNew7216 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvrNew7216() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{6B0B7CB1-03BC-44CB-8768-79FFC699B41A}" );
}
/**
* CpSvr8114 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr8114() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{8DB220EA-04E0-4272-9AED-6B1550F6DBAB}" );
}
/**
* CpSvr9842 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr9842() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{79A10F99-442F-472D-8088-816B25F85523}" );
}
/**
* CpSvr9842S Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr9842S() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{C6CE0564-B055-46AA-A406-DF1AF0A549C2}" );
}
/**
* CpMarketWatch Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpMarketWatch() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{9FA37D6D-1E16-442C-8EDD-A3E423E8FEA1}" );
}
/**
* CpMarketWatchS Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpMarketWatchS() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{D6633FD4-D339-4782-B337-2A6C9ED3CA47}" );
}
/**
* CpSvrNew7222 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvrNew7222() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{13173568-9547-4910-B040-9168A5DC950C}" );
}
/**
* CpSvr7748 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr7748() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{AF9498CB-FFBC-45FA-A5B5-3BE5E48146E5}" );
}
/**
* ElwAll Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createElwAll() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{061DCC2D-02E9-4F42-9090-3EACF821480B}" );
}
/**
* Elw Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createElw() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{49EC4E41-32D5-4994-8B0C-BC7AAB238E6A}" );
}
/**
* ElwUnderCur Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createElwUnderCur() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{AE0BD6DB-C9C5-403B-AF49-7B953B362112}" );
}
/**
* ElwInvest Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createElwInvest() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{51BEC419-2C7F-456F-AF83-4E1E9C1F7543}" );
}
/**
* CpSvrNew7215A Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvrNew7215A() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{4E793A3C-DFD4-499A-93F6-B2CEC3DC151B}" );
}
/**
* CpSvrNew7215B Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvrNew7215B() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{BE5F7180-7E74-4F44-8C67-700811BAD363}" );
}
/**
* CpSvr7068 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr7068() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{10674C56-4ACC-4104-BC8D-42F855EBA17D}" );
}
/**
* CpSvr7063 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr7063() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{C8C73E26-6C02-46CB-B8B6-1600E5A86A6B}" );
}
/**
* ElwJpbid Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createElwJpbid() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{75CCA696-16F2-459D-9F73-9EE5B92D60B3}" );
}
/**
* ElwJpbid2 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createElwJpbid2() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{DAAF202A-393E-4353-A4EA-092733536C64}" );
}
/**
* CpSvr7066 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr7066() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{42A23EE1-5CB9-4F9F-8467-208ED8602665}" );
}
/**
* CpSvr7254 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr7254() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{1B54A2E7-8F72-4825-B109-7E2DD61D6C8E}" );
}
/**
* CpSvr3744 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr3744() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{923667A7-245E-44E2-AB39-CB224F5B913E}" );
}
/**
* StockAdj Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createStockAdj() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{EF251164-0FC9-4582-A6EE-7C6A3B981111}" );
}
/**
* StockUniMst Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createStockUniMst() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{7E291B7A-D229-4741-A8C1-C33B0DBBF6FB}" );
}
/**
* StockUniCur Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createStockUniCur() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{DC573A7F-3301-47CE-B2F2-F36A1E5500B7}" );
}
/**
* StockUniJpBid Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createStockUniJpBid() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{B7CC7EE7-C619-4D27-8EA9-03C2B0370ED0}" );
}
/**
* StockUniWeek Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createStockUniWeek() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{348306A3-8692-4758-AE08-883CF96B0B4C}" );
}
/**
* StockUniBid Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createStockUniBid() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{1C6B4381-B00C-4529-ABA1-FF705BFA342F}" );
}
/**
* OptionCurOnly Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createOptionCurOnly() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{928A6FAF-3874-42D6-BCB6-74D65F758B35}" );
}
/**
* WorldCur Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createWorldCur() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{3D49364D-18D9-49A8-9B9F-7C5471EB129B}" );
}
/**
* MarketEye Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createMarketEye() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{D71F9B56-85A0-49F8-B102-19C223ACF298}" );
}
/**
* StockChart Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createStockChart() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{4F5E5E9A-5BEA-409F-9828-B66A70B4B51B}" );
}
/**
* CpSvr7037 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr7037() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{1AAC83CC-FA40-485F-952F-FB5667392E4F}" );
}
/**
* K200Expect Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createK200Expect() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{39DADC73-104A-4C23-AC9B-9875B35EA194}" );
}
/**
* FutOptChart Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createFutOptChart() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{5337FA2B-B02E-42DC-A5A1-12BC4F36B6DA}" );
}
/**
* CpSvrNew7043 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvrNew7043() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{BC2B7C0D-8481-4067-B1A4-5D7BDCA9DCBA}" );
}
/**
* CpSvrNew7212 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvrNew7212() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{DC43995C-F264-4ECA-B88A-20B4FD238DAF}" );
}
/**
* CpSvr7726 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr7726() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{23DEEA4C-FCF5-49B6-B1A8-07EF1D6D4AD4}" );
}
/**
* CpSvrCpFutOptTheoVal Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpFutOptTheoVal() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{FFE900B3-D906-492B-9AA1-C9411371C108}" );
}
/**
* CpSvr7326 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr7326() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{D9A23D4E-624D-43E8-9FDA-F9174A073209}" );
}
/**
* StockOpenSb Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createStockOpenSb() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{F1AE467A-86BE-4F77-8A5C-F23D4883E3A7}" );
}
/**
* CmeMst Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCmeMst() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{9B08D6BE-4DE0-4F6A-B32A-22C9F0B182F7}" );
}
/**
* CmeMo Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCmeMo() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{8195B34A-E25A-4174-A41E-3283BFD0CBD6}" );
}
/**
* CmeBid Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCmeBid() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{E7FBCAA1-E01F-4CD5-B215-DB77D3AF5448}" );
}
/**
* CmeDaily Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCmeDaily() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{09832FA6-1662-4EE3-9F91-6C8CD66EB3B2}" );
}
/**
* CmeBidOnly Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCmeBidOnly() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{2ADC5BB3-40A2-450C-A503-51084AD15D99}" );
}
/**
* CmeCurOnly Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCmeCurOnly() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{75FDB7F9-6B05-49E7-B7BD-80DA111FF3D5}" );
}
/**
* CmeCurr Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCmeCurr() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{70C14953-D33B-454B-856F-9464B7D7BAB5}" );
}
/**
* FutureJpBid Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createFutureJpBid() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{D14D1214-71D0-4207-9780-6DAC389EAE85}" );
}
/**
* OptionJpBid Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createOptionJpBid() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{6D4EC009-130A-4C74-98D2-42B020889449}" );
}
/**
* CWList Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCWList() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{EDD5DE53-96D2-4F1D-BA3D-C6DF75154066}" );
}
/**
* NStockMst Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createNStockMst() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{D3825EE2-C49F-4756-890D-530CDAA25EC5}" );
}
/**
* NStockCur Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createNStockCur() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{3014C34B-46C3-4440-B6F5-93997817047B}" );
}
/**
* BondMst Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createBondMst() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{A0B46FA8-216D-47EB-A5DC-C500ACCEEA1A}" );
}
/**
* BondCur Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createBondCur() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{3618D98B-BE61-4A46-9A2B-C6B38ECD2A09}" );
}
/**
* FOExpectCur Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createFOExpectCur() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{55D92823-F6CD-49FC-A3A8-9B4FAE025175}" );
}
/**
* EurexBid Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createEurexBid() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{A45C67C3-53B6-4740-92AF-A04338D9215B}" );
}
/**
* EurexDaily Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createEurexDaily() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{A0696F58-8C6B-4E3B-8F7B-9EB4CC094EBB}" );
}
/**
* EurexCurOnly Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createEurexCurOnly() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{3626A621-23F1-409F-BDD0-5AE10FF924E0}" );
}
/**
* EurexMst Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createEurexMst() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{65950801-9C94-4756-A92A-B20F319CDE2E}" );
}
/**
* EurexJpbid Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createEurexJpbid() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{D07D7BAC-7FDD-4AA1-9FEB-156EC5344B8E}" );
}
/**
* CpSvrNew7244S Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvrNew7244S() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{5B6B6338-5843-4D9F-87BB-5C5BB40C579D}" );
}
/**
* CpSvrNew8300 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvrNew8300() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{D03AB487-0553-4F48-8DAA-C7A8C1549B11}" );
}
/**
* CssStgList Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCssStgList() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{B9CB3A84-F66B-4FB0-A481-C9CCC8B8AE1F}" );
}
/**
* CssStgFind Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCssStgFind() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{60E404D1-AA50-4AC9-BC86-476626CBC983}" );
}
/**
* CssWatchStgControl Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCssWatchStgControl() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{6F6615F0-DA4A-4E5F-8E74-F3597F9D6865}" );
}
/**
* CssWatchStgSubscribe Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCssWatchStgSubscribe() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{7F5AF5D2-2C13-4E84-92E4-9298F1436756}" );
}
/**
* CssAlert Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCssAlert() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{37001E74-5FAA-4502-94FA-3AE9FC102DEB}" );
}
/**
* CpSvr7921 Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr7921() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{435AC599-969D-46A0-B119-6D7C4C7F5AB7}" );
}
/**
* CpSvr8119S Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr8119S() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{02762DC2-93FA-48CA-897C-DAE7D68514AB}" );
}
/**
* CpSvr9619S Class
*/
public static com.blackvelvet.cybos.bridge.cpsysdib.ISysDib createCpSvr9619S() {
return COM4J.createInstance( com.blackvelvet.cybos.bridge.cpsysdib.ISysDib.class, "{772812D7-6F16-41C5-9E4A-95955F9203DC}" );
}
}
|
package com.codecool.zsana.scrumtrackertest.scrumtrackertest;
import org.openqa.selenium.Alert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
public class Basepage {
private WebDriver driver;
private String homepage = "http://192.168.1.105:3000";
Basepage(WebDriver driver) {
this.driver = driver;
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 5), this);
}
public WebDriver getDriver() {
return this.driver;
}
public boolean isElementPresent(WebElement element) {
return element.isDisplayed();
}
public void writeIntoInputField(WebElement element, String input) {
element.sendKeys(input);
}
public void clickOnElement(WebElement element) {
element.click();
}
public void navigateToPage(String url) {
driver.navigate().to(url);
}
public void acceptPopUpAlert() {
Alert alert = driver.switchTo().alert();
alert.accept();
}
public String getHomepage() {
return homepage;
}
}
|
package com.avogine.junkyard.io.event;
public interface InputListener {
}
|
package com.guilhermefgl.spring.crudproduto.models.repositories;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;
import com.guilhermefgl.spring.crudproduto.models.Produto;
@Transactional(readOnly = true)
public interface ProdutoRepository extends JpaRepository<Produto, Integer> {
List<Produto> findAll();
List<Produto> findByProdutoPai(Produto produtoPai);
Produto findByIdProduto(Integer idProduto);
}
|
package ru.kappers.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import ru.kappers.model.leonmodels.MarketLeon;
public interface MarketLeonRepository extends JpaRepository<MarketLeon, Long> {
MarketLeon getByName(String name);
}
|
package com.hendriksen.listeners;
/**
* Created by Sam on 17/02/2015.
*
* Used to broadcast the outcome of a classifier build.
*/
public interface BuildClassifierListener {
public void onBuildSuccess();
public void onBuildFail();
}
|
package com.pacific.dao;
import com.pacific.domain.StockDetail;
import java.util.Date;
import java.util.List;
/**
* Created by yadavm on 30/05/14.
*/
public interface StockDateDao {
public void create(StockDetail stockDetail);
public List<StockDetail> getAll();
public List<StockDetail> getOne(Integer stockId, Date date);
public Integer getCount(Integer stockId, Date date);
public int update(StockDetail stockDetail);
public int delete(StockDetail stockDetail);
public Integer getStockDateIdForOptionsCreation(String symbol);
}
|
package A_Ex1_WithoutPom;
import static org.testng.Assert.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.testng.annotations.Test;
import util.BaseTest;
public class TestLoginBasic3 extends EmpBaseTest{
// login with correct un and correct pwd
@Test
public void testLoginSuccess() throws InterruptedException {
login("admin","admin");
Thread.sleep(5000);
// logout
WebElement logout = driver.findElement(By.id("logoutLbl"));
assertTrue(logout.isDisplayed(), "element expeceted to display");
assertTrue(logout.isEnabled(), "element expected to enable");
assertTrue(logout.getText().equals("Logout"));
logout.click();
Thread.sleep(5000);
}
// login with correct un and wrong pwd
@Test
public void testLoginFailure() throws InterruptedException {
login("admin", "admin2");
Thread.sleep(5000);
// validate the error message
WebElement invalidlogin = driver.findElement(By.xpath("//font[@color='Red']"));
assertTrue(invalidlogin.isDisplayed(), "element expeceted to display");
assertTrue(invalidlogin.isEnabled(), "element expected to enable");
assertTrue(invalidlogin.getText().equals("Invalid Login."));
}
}
|
/**
* 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 org.apache.hadoop.mapred;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import junit.framework.TestCase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.RawLocalFileSystem;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import static org.apache.hadoop.mapred.QueueManagerTestUtils.*;
import org.apache.hadoop.mapreduce.Cluster;
import org.apache.hadoop.mapreduce.Counters;
import org.apache.hadoop.mapreduce.JobACL;
import org.apache.hadoop.mapreduce.JobID;
import org.apache.hadoop.mapreduce.MRConfig;
import org.apache.hadoop.mapreduce.TaskAttemptID;
import org.apache.hadoop.mapreduce.TaskID;
import org.apache.hadoop.mapreduce.TaskType;
import org.apache.hadoop.mapreduce.server.jobtracker.JTConfig;
import org.apache.hadoop.mapreduce.jobhistory.JobHistory;
import org.apache.hadoop.mapreduce.jobhistory.JobHistoryParser;
import org.apache.hadoop.mapreduce.jobhistory.JobSubmittedEvent;
import org.apache.hadoop.mapreduce.jobhistory.JobHistoryParser.JobInfo;
import org.apache.hadoop.mapreduce.jobhistory.JobHistoryParser.TaskAttemptInfo;
import org.apache.hadoop.mapreduce.jobhistory.JobHistoryParser.TaskInfo;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authorize.AccessControlList;
/**
*
* testJobHistoryFile
* Run a job that will be succeeded and validate its history file format and
* content.
*
* testJobHistoryJobStatus
* Run jobs that will be (1) succeeded (2) failed (3) killed.
* Validate job status read from history file in each case.
*
*/
public class TestJobHistory extends TestCase {
private static final Log LOG = LogFactory.getLog(TestJobHistory.class);
private static String TEST_ROOT_DIR = new File(System.getProperty(
"test.build.data", "/tmp")).toURI().toString().replace(' ', '+');
private static final String DIGITS = "[0-9]+";
// hostname like /default-rack/host1.foo.com OR host1.foo.com
private static final Pattern hostNamePattern = Pattern.compile(
"(/(([\\w\\-\\.]+)/)+)?([\\w\\-\\.]+)");
private static final String IP_ADDR =
"\\d\\d?\\d?\\.\\d\\d?\\d?\\.\\d\\d?\\d?\\.\\d\\d?\\d?";
private static final Pattern trackerNamePattern = Pattern.compile(
"tracker_" + hostNamePattern + ":([\\w\\-\\.]+)/" +
IP_ADDR + ":" + DIGITS);
private static final Pattern splitsPattern = Pattern.compile(
hostNamePattern + "(," + hostNamePattern + ")*");
private static Map<String, List<String>> taskIDsToAttemptIDs =
new HashMap<String, List<String>>();
//Each Task End seen from history file is added here
private static List<String> taskEnds = new ArrayList<String>();
// Validate Format of Job Level Keys, Values read from history file
private static void validateJobLevelKeyValuesFormat(JobInfo jobInfo,
String status) {
long submitTime = jobInfo.getSubmitTime();
long launchTime = jobInfo.getLaunchTime();
long finishTime = jobInfo.getFinishTime();
assertTrue("Invalid submit time", submitTime > 0);
assertTrue("SubmitTime > LaunchTime", submitTime <= launchTime);
assertTrue("LaunchTime > FinishTime", launchTime <= finishTime);
String stat = jobInfo.getJobStatus();
assertTrue("Unexpected JOB_STATUS \"" + stat + "\" is seen in" +
" history file", (status.equals(stat)));
String priority = jobInfo.getPriority();
assertNotNull(priority);
assertTrue("Unknown priority for the job in history file",
(priority.equals("HIGH") ||
priority.equals("LOW") || priority.equals("NORMAL") ||
priority.equals("VERY_HIGH") || priority.equals("VERY_LOW")));
}
// Validate Format of Task Level Keys, Values read from history file
private static void validateTaskLevelKeyValuesFormat(JobInfo job,
boolean splitsCanBeEmpty) {
Map<TaskID, TaskInfo> tasks = job.getAllTasks();
// validate info of each task
for (TaskInfo task : tasks.values()) {
TaskID tid = task.getTaskId();
long startTime = task.getStartTime();
assertTrue("Invalid Start time", startTime > 0);
long finishTime = task.getFinishTime();
assertTrue("Task FINISH_TIME is < START_TIME in history file",
startTime < finishTime);
// Make sure that the Task type exists and it is valid
TaskType type = task.getTaskType();
assertTrue("Unknown Task type \"" + type + "\" is seen in " +
"history file for task " + tid,
(type.equals(TaskType.MAP) ||
type.equals(TaskType.REDUCE) ||
type.equals(TaskType.JOB_CLEANUP) ||
type.equals(TaskType.JOB_SETUP)));
if (type.equals(TaskType.MAP)) {
String splits = task.getSplitLocations();
//order in the condition OR check is important here
if (!splitsCanBeEmpty || splits.length() != 0) {
Matcher m = splitsPattern.matcher(splits);
assertTrue("Unexpected format of SPLITS \"" + splits + "\" is seen" +
" in history file for task " + tid, m.matches());
}
}
// Validate task status
String status = task.getTaskStatus();
assertTrue("Unexpected TASK_STATUS \"" + status + "\" is seen in" +
" history file for task " + tid, (status.equals("SUCCEEDED") ||
status.equals("FAILED") || status.equals("KILLED")));
}
}
// Validate foramt of Task Attempt Level Keys, Values read from history file
private static void validateTaskAttemptLevelKeyValuesFormat(JobInfo job) {
Map<TaskID, TaskInfo> tasks = job.getAllTasks();
// For each task
for (TaskInfo task : tasks.values()) {
// validate info of each attempt
for (TaskAttemptInfo attempt : task.getAllTaskAttempts().values()) {
TaskAttemptID id = attempt.getAttemptId();
assertNotNull(id);
long startTime = attempt.getStartTime();
assertTrue("Invalid Start time", startTime > 0);
long finishTime = attempt.getFinishTime();
assertTrue("Task FINISH_TIME is < START_TIME in history file",
startTime < finishTime);
// Make sure that the Task type exists and it is valid
TaskType type = attempt.getTaskType();
assertTrue("Unknown Task type \"" + type + "\" is seen in " +
"history file for task attempt " + id,
(type.equals(TaskType.MAP) || type.equals(TaskType.REDUCE) ||
type.equals(TaskType.JOB_CLEANUP) ||
type.equals(TaskType.JOB_SETUP)));
// Validate task status
String status = attempt.getTaskStatus();
assertTrue("Unexpected TASK_STATUS \"" + status + "\" is seen in" +
" history file for task attempt " + id,
(status.equals(TaskStatus.State.SUCCEEDED.toString()) ||
status.equals(TaskStatus.State.FAILED.toString()) ||
status.equals(TaskStatus.State.KILLED.toString())));
// Successful Reduce Task Attempts should have valid SHUFFLE_FINISHED
// time and SORT_FINISHED time
if (type.equals(TaskType.REDUCE) &&
status.equals(TaskStatus.State.SUCCEEDED.toString())) {
long shuffleFinishTime = attempt.getShuffleFinishTime();
assertTrue(startTime < shuffleFinishTime);
long sortFinishTime = attempt.getSortFinishTime();
assertTrue(shuffleFinishTime < sortFinishTime);
}
else if (type.equals(TaskType.MAP) &&
status.equals(TaskStatus.State.SUCCEEDED.toString())) {
// Successful MAP Task Attempts should have valid MAP_FINISHED time
long mapFinishTime = attempt.getMapFinishTime();
assertTrue(startTime < mapFinishTime);
}
// check if hostname is valid
String hostname = attempt.getHostname();
Matcher m = hostNamePattern.matcher(hostname);
assertTrue("Unexpected Host name of task attempt " + id, m.matches());
// check if trackername is valid
String trackerName = attempt.getTrackerName();
m = trackerNamePattern.matcher(trackerName);
assertTrue("Unexpected tracker name of task attempt " + id,
m.matches());
if (!status.equals("KILLED")) {
// check if http port is valid
int httpPort = attempt.getHttpPort();
assertTrue(httpPort > 0);
}
// check if counters are parsable
Counters counters = attempt.getCounters();
assertNotNull(counters);
}
}
}
/**
* Returns the conf file name in the same
* @param path path of the jobhistory file
* @param running whether the job is running or completed
*/
private static Path getPathForConf(Path path, Path dir) {
String parts[] = path.getName().split("_");
//TODO this is a hack :(
// jobtracker-hostname_jobtracker-identifier_
String id = parts[0] + "_" + parts[1] + "_" + parts[2];
return new Path(dir, id + "_conf.xml");
}
/**
* Validates the format of contents of history file
* (1) history file exists and in correct location
* (2) Verify if the history file is parsable
* (3) Validate the contents of history file
* (a) Format of all TIMEs are checked against a regex
* (b) validate legality/format of job level key, values
* (c) validate legality/format of task level key, values
* (d) validate legality/format of attempt level key, values
* (e) check if all the TaskAttempts, Tasks started are finished.
* Check finish of each TaskAttemptID against its start to make sure
* that all TaskAttempts, Tasks started are indeed finished and the
* history log lines are in the proper order.
* We want to catch ordering of history lines like
* Task START
* Attempt START
* Task FINISH
* Attempt FINISH
* (speculative execution is turned off for this).
* @param id job id
* @param conf job conf
*/
public static void validateJobHistoryFileFormat(JobHistory jobHistory,
JobID id, JobConf conf,
String status, boolean splitsCanBeEmpty) throws IOException {
// Get the history file name
Path dir = jobHistory.getCompletedJobHistoryLocation();
String logFileName = getDoneFile(jobHistory, conf, id, dir);
// Framework history log file location
Path logFile = new Path(dir, logFileName);
FileSystem fileSys = logFile.getFileSystem(conf);
// Check if the history file exists
assertTrue("History file does not exist", fileSys.exists(logFile));
JobHistoryParser parser = new JobHistoryParser(fileSys,
logFile.toUri().getPath());
JobHistoryParser.JobInfo jobInfo = parser.parse();
// validate format of job level key, values
validateJobLevelKeyValuesFormat(jobInfo, status);
// validate format of task level key, values
validateTaskLevelKeyValuesFormat(jobInfo, splitsCanBeEmpty);
// validate format of attempt level key, values
validateTaskAttemptLevelKeyValuesFormat(jobInfo);
// check if all the TaskAttempts, Tasks started are finished for
// successful jobs
if (status.equals("SUCCEEDED")) {
// Make sure that the lists in taskIDsToAttemptIDs are empty.
for(Iterator<String> it =
taskIDsToAttemptIDs.keySet().iterator();it.hasNext();) {
String taskid = it.next();
assertTrue("There are some Tasks which are not finished in history " +
"file.", taskEnds.contains(taskid));
List<String> attemptIDs = taskIDsToAttemptIDs.get(taskid);
if(attemptIDs != null) {
assertTrue("Unexpected. TaskID " + taskid + " has task attempt(s)" +
" that are not finished.", (attemptIDs.size() == 1));
}
}
}
}
// Validate Job Level Keys, Values read from history file by
// comparing them with the actual values from JT.
private static void validateJobLevelKeyValues(MiniMRCluster mr,
RunningJob job, JobInfo jobInfo, JobConf conf) throws IOException {
JobTracker jt = mr.getJobTrackerRunner().getJobTracker();
JobInProgress jip = jt.getJob(job.getID());
assertTrue("SUBMIT_TIME of job obtained from history file did not " +
"match the expected value", jip.getStartTime() ==
jobInfo.getSubmitTime());
assertTrue("LAUNCH_TIME of job obtained from history file did not " +
"match the expected value", jip.getLaunchTime() ==
jobInfo.getLaunchTime());
assertTrue("FINISH_TIME of job obtained from history file did not " +
"match the expected value", jip.getFinishTime() ==
jobInfo.getFinishTime());
assertTrue("Job Status of job obtained from history file did not " +
"match the expected value",
jobInfo.getJobStatus().equals("SUCCEEDED"));
assertTrue("Job Priority of job obtained from history file did not " +
"match the expected value", jip.getPriority().toString().equals(
jobInfo.getPriority()));
assertTrue("Job Name of job obtained from history file did not " +
"match the expected value",
conf.getJobName().equals(
jobInfo.getJobname()));
String user = UserGroupInformation.getCurrentUser().getUserName();
assertTrue("User Name of job obtained from history file did not " +
"match the expected value",
user.equals(
jobInfo.getUsername()));
// Validate job counters
Counters c = new Counters(jip.getCounters());
Counters jiCounters = jobInfo.getTotalCounters();
assertTrue("Counters of job obtained from history file did not " +
"match the expected value",
c.equals(jiCounters));
// Validate number of total maps, total reduces, finished maps,
// finished reduces, failed maps, failed recudes
assertTrue("Unexpected number of total maps in history file",
jobInfo.getTotalMaps() == jip.desiredMaps());
assertTrue("Unexpected number of total reduces in history file",
jobInfo.getTotalReduces() == jip.desiredReduces());
assertTrue("Unexpected number of finished maps in history file",
jobInfo.getFinishedMaps() == jip.finishedMaps());
assertTrue("Unexpected number of finished reduces in history file",
jobInfo.getFinishedReduces() == jip.finishedReduces());
assertTrue("Unexpected number of failed maps in history file",
jobInfo.getFailedMaps() == jip.failedMapTasks);
assertTrue("Unexpected number of failed reduces in history file",
jobInfo.getFailedReduces() == jip.failedReduceTasks);
}
// Validate Task Level Keys, Values read from history file by
// comparing them with the actual values from JT.
private static void validateTaskLevelKeyValues(MiniMRCluster mr,
RunningJob job, JobInfo jobInfo) throws IOException {
JobTracker jt = mr.getJobTrackerRunner().getJobTracker();
JobInProgress jip = jt.getJob(job.getID());
// Get the 1st map, 1st reduce, cleanup & setup taskIDs and
// validate their history info
TaskID mapTaskId = new TaskID(job.getID(), TaskType.MAP, 0);
TaskID reduceTaskId = new TaskID(job.getID(), TaskType.REDUCE, 0);
TaskInProgress cleanups[] = jip.cleanup;
TaskID cleanupTaskId;
if (cleanups[0].isComplete()) {
cleanupTaskId = cleanups[0].getTIPId();
}
else {
cleanupTaskId = cleanups[1].getTIPId();
}
TaskInProgress setups[] = jip.setup;
TaskID setupTaskId;
if (setups[0].isComplete()) {
setupTaskId = setups[0].getTIPId();
}
else {
setupTaskId = setups[1].getTIPId();
}
Map<TaskID, TaskInfo> tasks = jobInfo.getAllTasks();
// validate info of the 4 tasks(cleanup, setup, 1st map, 1st reduce)
for (TaskInfo task : tasks.values()) {
TaskID tid = task.getTaskId();
if (tid.equals(mapTaskId) ||
tid.equals(reduceTaskId) ||
tid.equals(cleanupTaskId) ||
tid.equals(setupTaskId)) {
TaskInProgress tip = jip.getTaskInProgress
(org.apache.hadoop.mapred.TaskID.downgrade(tid));
assertTrue("START_TIME of Task " + tid + " obtained from history " +
"file did not match the expected value",
tip.getExecStartTime() ==
task.getStartTime());
assertTrue("FINISH_TIME of Task " + tid + " obtained from history " +
"file did not match the expected value",
tip.getExecFinishTime() ==
task.getFinishTime());
if (tid == mapTaskId) {//check splits only for map task
assertTrue("Splits of Task " + tid + " obtained from history file " +
" did not match the expected value",
tip.getSplitNodes().equals(task.getSplitLocations()));
}
TaskAttemptID attemptId = tip.getSuccessfulTaskid();
TaskStatus ts = tip.getTaskStatus(
org.apache.hadoop.mapred.TaskAttemptID.downgrade(attemptId));
// Validate task counters
Counters c = new Counters(ts.getCounters());
assertTrue("Counters of Task " + tid + " obtained from history file " +
" did not match the expected value",
c.equals(task.getCounters()));
}
}
}
// Validate Task Attempt Level Keys, Values read from history file by
// comparing them with the actual values from JT.
private static void validateTaskAttemptLevelKeyValues(MiniMRCluster mr,
RunningJob job, JobInfo jobInfo) throws IOException {
JobTracker jt = mr.getJobTrackerRunner().getJobTracker();
JobInProgress jip = jt.getJob(job.getID());
Map<TaskID, TaskInfo> tasks = jobInfo.getAllTasks();
// For each task
for (TaskInfo task : tasks.values()) {
// validate info of each attempt
for (TaskAttemptInfo attempt : task.getAllTaskAttempts().values()) {
TaskAttemptID attemptId = attempt.getAttemptId();
TaskID tid = attemptId.getTaskID();
TaskInProgress tip = jip.getTaskInProgress
(org.apache.hadoop.mapred.TaskID.downgrade(tid));
TaskStatus ts = tip.getTaskStatus(
org.apache.hadoop.mapred.TaskAttemptID.downgrade(attemptId));
// Validate task attempt start time
assertTrue("START_TIME of Task attempt " + attemptId +
" obtained from " +
"history file did not match the expected value",
ts.getStartTime() == attempt.getStartTime());
// Validate task attempt finish time
assertTrue("FINISH_TIME of Task attempt " + attemptId +
" obtained from " +
"history file " + ts.getFinishTime() +
" did not match the expected value, " +
attempt.getFinishTime(),
ts.getFinishTime() == attempt.getFinishTime());
TaskTrackerStatus ttStatus =
jt.getTaskTrackerStatus(ts.getTaskTracker());
if (ttStatus != null) {
assertTrue("http port of task attempt " + attemptId +
" obtained from " +
"history file did not match the expected value",
ttStatus.getHttpPort() ==
attempt.getHttpPort());
if (attempt.getTaskStatus().equals("SUCCEEDED")) {
String ttHostname = jt.getNode(ttStatus.getHost()).toString();
// check if hostname is valid
assertTrue("Host name of task attempt " + attemptId +
" obtained from" +
" history file did not match the expected value",
ttHostname.equals(attempt.getHostname()));
}
}
if (attempt.getTaskStatus().equals("SUCCEEDED")) {
// Validate SHUFFLE_FINISHED time and SORT_FINISHED time of
// Reduce Task Attempts
if (attempt.getTaskType().equals("REDUCE")) {
assertTrue("SHUFFLE_FINISHED time of task attempt " + attemptId +
" obtained from history file did not match the expected" +
" value", ts.getShuffleFinishTime() ==
attempt.getShuffleFinishTime());
assertTrue("SORT_FINISHED time of task attempt " + attemptId +
" obtained from history file did not match the expected" +
" value", ts.getSortFinishTime() ==
attempt.getSortFinishTime());
}
//Validate task counters
Counters c = new Counters(ts.getCounters());
assertTrue("Counters of Task Attempt " + attemptId + " obtained from " +
"history file did not match the expected value",
c.equals(attempt.getCounters()));
}
// check if tracker name is valid
assertTrue("Tracker name of task attempt " + attemptId +
" obtained from " +
"history file did not match the expected value",
ts.getTaskTracker().equals(attempt.getTrackerName()));
}
}
}
/**
* Checks if the history file content is as expected comparing with the
* actual values obtained from JT.
* Job Level, Task Level and Task Attempt Level Keys, Values are validated.
* @param job RunningJob object of the job whose history is to be validated
* @param conf job conf
*/
public static void validateJobHistoryFileContent(MiniMRCluster mr,
RunningJob job, JobConf conf) throws IOException {
JobID id = job.getID();
JobHistory jobHistory =
mr.getJobTrackerRunner().getJobTracker().getJobHistory();
Path doneDir = jobHistory.getCompletedJobHistoryLocation();
// Get the history file name
String logFileName = getDoneFile(jobHistory, conf, id, doneDir);
// Framework history log file location
Path logFile = new Path(doneDir, logFileName);
FileSystem fileSys = logFile.getFileSystem(conf);
// Check if the history file exists
assertTrue("History file does not exist", fileSys.exists(logFile));
JobHistoryParser parser = new JobHistoryParser(fileSys,
logFile.toUri().getPath());
JobHistoryParser.JobInfo jobInfo = parser.parse();
// Now the history file contents are available in jobInfo. Let us compare
// them with the actual values from JT.
validateJobLevelKeyValues(mr, job, jobInfo, conf);
validateTaskLevelKeyValues(mr, job, jobInfo);
validateTaskAttemptLevelKeyValues(mr, job, jobInfo);
// Also JobACLs should be correct
if (mr.getJobTrackerRunner().getJobTracker()
.areACLsEnabled()) {
AccessControlList acl = new AccessControlList(
conf.get(JobACL.VIEW_JOB.getAclName(), " "));
assertTrue("VIEW_JOB ACL is not properly logged to history file.",
acl.toString().equals(
jobInfo.getJobACLs().get(JobACL.VIEW_JOB).toString()));
acl = new AccessControlList(
conf.get(JobACL.MODIFY_JOB.getAclName(), " "));
assertTrue("MODIFY_JOB ACL is not properly logged to history file.",
acl.toString().equals(
jobInfo.getJobACLs().get(JobACL.MODIFY_JOB).toString()));
}
// Validate the job queue name
assertTrue(jobInfo.getJobQueueName().equals(conf.getQueueName()));
}
public void testDoneFolderOnHDFS() throws IOException, InterruptedException {
runDoneFolderTest("history_done");
}
public void testDoneFolderNotOnDefaultFileSystem() throws IOException, InterruptedException {
runDoneFolderTest("file://" + System.getProperty("test.build.data", "tmp") + "/history_done");
}
private void runDoneFolderTest(String doneFolder) throws IOException, InterruptedException {
MiniMRCluster mr = null;
MiniDFSCluster dfsCluster = null;
try {
JobConf conf = new JobConf();
// keep for less time
conf.setLong("mapred.jobtracker.retirejob.check", 1000);
conf.setLong("mapred.jobtracker.retirejob.interval", 1000);
//set the done folder location
conf.set(JTConfig.JT_JOBHISTORY_COMPLETED_LOCATION, doneFolder);
String logDir =
"file:///" + new File(System.getProperty("hadoop.log.dir")).
getAbsolutePath() + File.separator + "history";
Path logDirPath = new Path(logDir);
FileSystem logDirFs = logDirPath.getFileSystem(conf);
//there may be some stale files, clean them
if (logDirFs.exists(logDirPath)) {
boolean deleted = logDirFs.delete(logDirPath, true);
LOG.info(logDirPath + " deleted " + deleted);
}
logDirFs.mkdirs(logDirPath);
assertEquals("No of file in logDir not correct", 0,
logDirFs.listStatus(logDirPath).length);
logDirFs.create(new Path(logDirPath, "f1"));
logDirFs.create(new Path(logDirPath, "f2"));
assertEquals("No of file in logDir not correct", 2,
logDirFs.listStatus(logDirPath).length);
dfsCluster = new MiniDFSCluster(conf, 2, true, null);
mr = new MiniMRCluster(2, dfsCluster.getFileSystem().getUri().toString(),
3, null, null, conf);
assertEquals("Files in logDir did not move to DONE folder",
0, logDirFs.listStatus(logDirPath).length);
JobHistory jobHistory =
mr.getJobTrackerRunner().getJobTracker().getJobHistory();
Path doneDir = jobHistory.getCompletedJobHistoryLocation();
assertEquals("Files in DONE dir not correct",
2, doneDir.getFileSystem(conf).listStatus(doneDir).length);
// run the TCs
conf = mr.createJobConf();
FileSystem fs = FileSystem.get(conf);
// clean up
fs.delete(new Path("succeed"), true);
Path inDir = new Path("succeed/input");
Path outDir = new Path("succeed/output");
//Disable speculative execution
conf.setSpeculativeExecution(false);
// Make sure that the job is not removed from memory until we do finish
// the validation of history file content
conf.setInt("mapred.jobtracker.completeuserjobs.maximum", 10);
// Run a job that will be succeeded and validate its history file
RunningJob job = UtilsForTests.runJobSucceed(conf, inDir, outDir);
assertEquals("History DONE folder not correct",
new Path(doneFolder).getName(), doneDir.getName());
JobID id = job.getID();
String logFileName = getDoneFile(jobHistory, conf, id, doneDir);
// Framework history log file location
Path logFile = new Path(doneDir, logFileName);
FileSystem fileSys = logFile.getFileSystem(conf);
Cluster cluster = new Cluster(conf);
assertEquals("Client returned wrong history url", logFile.toString(),
cluster.getJobHistoryUrl(id));
// Check if the history file exists
assertTrue("History file does not exist", fileSys.exists(logFile));
// check if the corresponding conf file exists
Path confFile = getPathForConf(logFile, doneDir);
assertTrue("Config for completed jobs doesnt exist",
fileSys.exists(confFile));
// check if the file exists in a done folder
assertTrue("Completed job config doesnt exist in the done folder",
doneDir.getName().equals(confFile.getParent().getName()));
// check if the file exists in a done folder
assertTrue("Completed jobs doesnt exist in the done folder",
doneDir.getName().equals(logFile.getParent().getName()));
// check if the job file is removed from the history location
Path runningJobsHistoryFolder = logFile.getParent().getParent();
Path runningJobHistoryFilename =
new Path(runningJobsHistoryFolder, logFile.getName());
Path runningJobConfFilename =
new Path(runningJobsHistoryFolder, confFile.getName());
assertFalse("History file not deleted from the running folder",
fileSys.exists(runningJobHistoryFilename));
assertFalse("Config for completed jobs not deleted from running folder",
fileSys.exists(runningJobConfFilename));
validateJobHistoryFileFormat(jobHistory,
job.getID(), conf, "SUCCEEDED", false);
validateJobHistoryFileContent(mr, job, conf);
// get the job conf filename
} finally {
if (mr != null) {
cleanupLocalFiles(mr);
mr.shutdown();
}
if (dfsCluster != null) {
dfsCluster.shutdown();
}
}
}
/** Run a job that will be succeeded and validate its history file format
* and its content.
*/
public void testJobHistoryFile() throws Exception {
MiniMRCluster mr = null;
try {
JobConf conf = new JobConf();
// keep for less time
conf.setLong("mapred.jobtracker.retirejob.check", 1000);
conf.setLong("mapred.jobtracker.retirejob.interval", 1000);
//set the done folder location
String doneFolder = TEST_ROOT_DIR + "history_done";
conf.set(JTConfig.JT_JOBHISTORY_COMPLETED_LOCATION, doneFolder);
// Enable ACLs so that they are logged to history
conf.setBoolean(MRConfig.MR_ACLS_ENABLED, true);
mr = new MiniMRCluster(2, "file:///", 3, null, null, conf);
// run the TCs
conf = mr.createJobConf();
FileSystem fs = FileSystem.get(conf);
// clean up
fs.delete(new Path(TEST_ROOT_DIR + "/succeed"), true);
Path inDir = new Path(TEST_ROOT_DIR + "/succeed/input");
Path outDir = new Path(TEST_ROOT_DIR + "/succeed/output");
//Disable speculative execution
conf.setSpeculativeExecution(false);
// set the job acls
conf.set(JobACL.VIEW_JOB.getAclName(), "user1,user2 group1,group2");
conf.set(JobACL.MODIFY_JOB.getAclName(), "user3,user4 group3,group4");
// Make sure that the job is not removed from memory until we do finish
// the validation of history file content
conf.setInt("mapred.jobtracker.completeuserjobs.maximum", 10);
// Run a job that will be succeeded and validate its history file
RunningJob job = UtilsForTests.runJobSucceed(conf, inDir, outDir);
JobHistory jobHistory =
mr.getJobTrackerRunner().getJobTracker().getJobHistory();
Path doneDir = jobHistory.getCompletedJobHistoryLocation();
assertEquals("History DONE folder not correct",
doneFolder, doneDir.toString());
JobID id = job.getID();
String logFileName = getDoneFile(jobHistory, conf, id, doneDir);
// Framework history log file location
Path logFile = new Path(doneDir, logFileName);
FileSystem fileSys = logFile.getFileSystem(conf);
// Check if the history file exists
assertTrue("History file does not exist", fileSys.exists(logFile));
// check if the corresponding conf file exists
Path confFile = getPathForConf(logFile, doneDir);
assertTrue("Config for completed jobs doesnt exist",
fileSys.exists(confFile));
// check if the conf file exists in a done folder
assertTrue("Completed job config doesnt exist in the done folder",
doneDir.getName().equals(confFile.getParent().getName()));
// check if the file exists in a done folder
assertTrue("Completed jobs doesnt exist in the done folder",
doneDir.getName().equals(logFile.getParent().getName()));
// check if the job file is removed from the history location
Path runningJobsHistoryFolder = logFile.getParent().getParent();
Path runningJobHistoryFilename =
new Path(runningJobsHistoryFolder, logFile.getName());
Path runningJobConfFilename =
new Path(runningJobsHistoryFolder, confFile.getName());
assertFalse("History file not deleted from the running folder",
fileSys.exists(runningJobHistoryFilename));
assertFalse("Config for completed jobs not deleted from running folder",
fileSys.exists(runningJobConfFilename));
validateJobHistoryFileFormat(jobHistory, job.getID(), conf,
"SUCCEEDED", false);
validateJobHistoryFileContent(mr, job, conf);
// get the job conf filename
JobTracker jt = mr.getJobTrackerRunner().getJobTracker();
String name = jt.getLocalJobFilePath(job.getID());
File file = new File(name);
// check if the file get deleted
while (file.exists()) {
LOG.info("Waiting for " + file + " to be deleted");
UtilsForTests.waitFor(100);
}
} finally {
if (mr != null) {
cleanupLocalFiles(mr);
mr.shutdown();
}
}
}
//Returns the file in the done folder
//Waits for sometime to get the file moved to done
private static String getDoneFile(JobHistory jobHistory,
JobConf conf, JobID id,
Path doneDir) throws IOException {
String name = null;
String user = UserGroupInformation.getCurrentUser().getUserName();
for (int i = 0; name == null && i < 20; i++) {
Path path = JobHistory.getJobHistoryFile(
jobHistory.getCompletedJobHistoryLocation(), id, user);
if (path.getFileSystem(conf).exists(path)) {
name = path.toString();
}
UtilsForTests.waitFor(1000);
}
assertNotNull("Job history file not created", name);
return name;
}
private void cleanupLocalFiles(MiniMRCluster mr)
throws IOException {
Configuration conf = mr.createJobConf();
JobTracker jt = mr.getJobTrackerRunner().getJobTracker();
Path sysDir = new Path(jt.getSystemDir());
FileSystem fs = sysDir.getFileSystem(conf);
fs.delete(sysDir, true);
Path jobHistoryDir =
mr.getJobTrackerRunner().getJobTracker().getJobHistory().
getJobHistoryLocation();
fs = jobHistoryDir.getFileSystem(conf);
fs.delete(jobHistoryDir, true);
}
/**
* Checks if the history file has expected job status
* @param id job id
* @param conf job conf
*/
private static void validateJobHistoryJobStatus(JobHistory jobHistory,
JobID id, JobConf conf, String status) throws IOException {
// Get the history file name
Path doneDir = jobHistory.getCompletedJobHistoryLocation();
String logFileName = getDoneFile(jobHistory, conf, id, doneDir);
// Framework history log file location
Path logFile = new Path(doneDir, logFileName);
FileSystem fileSys = logFile.getFileSystem(conf);
// Check if the history file exists
assertTrue("History file does not exist", fileSys.exists(logFile));
// check history file permission
assertTrue("History file permissions does not match",
fileSys.getFileStatus(logFile).getPermission().equals(
new FsPermission(JobHistory.HISTORY_FILE_PERMISSION)));
JobHistoryParser parser = new JobHistoryParser(fileSys,
logFile.toUri().getPath());
JobHistoryParser.JobInfo jobInfo = parser.parse();
assertTrue("Job Status read from job history file is not the expected" +
" status", status.equals(jobInfo.getJobStatus()));
}
// run jobs that will be (1) succeeded (2) failed (3) killed
// and validate job status read from history file in each case
public void testJobHistoryJobStatus() throws IOException {
MiniMRCluster mr = null;
try {
mr = new MiniMRCluster(2, "file:///", 3);
// run the TCs
JobConf conf = mr.createJobConf();
FileSystem fs = FileSystem.get(conf);
// clean up
fs.delete(new Path(TEST_ROOT_DIR + "/succeedfailkilljob"), true);
Path inDir = new Path(TEST_ROOT_DIR + "/succeedfailkilljob/input");
Path outDir = new Path(TEST_ROOT_DIR + "/succeedfailkilljob/output");
// Run a job that will be succeeded and validate its job status
// existing in history file
RunningJob job = UtilsForTests.runJobSucceed(conf, inDir, outDir);
JobHistory jobHistory =
mr.getJobTrackerRunner().getJobTracker().getJobHistory();
validateJobHistoryJobStatus(jobHistory, job.getID(), conf,
JobStatus.getJobRunState(JobStatus.SUCCEEDED));
// Run a job that will be failed and validate its job status
// existing in history file
job = UtilsForTests.runJobFail(conf, inDir, outDir);
validateJobHistoryJobStatus(jobHistory, job.getID(), conf,
JobStatus.getJobRunState(JobStatus.FAILED));
// Run a job that will be killed and validate its job status
// existing in history file
job = UtilsForTests.runJobKill(conf, inDir, outDir);
validateJobHistoryJobStatus(jobHistory, job.getID(), conf,
JobStatus.getJobRunState(JobStatus.KILLED));
} finally {
if (mr != null) {
cleanupLocalFiles(mr);
mr.shutdown();
}
}
}
public void testHistoryInitWithCorruptFiles() throws IOException {
MiniMRCluster mr = null;
try {
JobConf conf = new JobConf();
Path historyDir = new Path(System.getProperty("test.build.data", "."),
"history");
conf.set(JTConfig.JT_JOBHISTORY_LOCATION,
historyDir.toString());
conf.setUser("user");
FileSystem localFs = FileSystem.getLocal(conf);
//there may be some stale files, clean them
if (localFs.exists(historyDir)) {
boolean deleted = localFs.delete(historyDir, true);
LOG.info(historyDir + " deleted " + deleted);
}
// Start the cluster, create a history file
mr = new MiniMRCluster(0, "file:///", 3, null, null, conf);
JobTracker jt = mr.getJobTrackerRunner().getJobTracker();
JobHistory jh = jt.getJobHistory();
final JobID jobId = JobID.forName("job_200809171136_0001");
jh.setupEventWriter(jobId, conf);
Map<JobACL, AccessControlList> jobACLs =
new HashMap<JobACL, AccessControlList>();
JobSubmittedEvent jse =
new JobSubmittedEvent(jobId, "job", "user", 12345, "path", jobACLs,
"default");
jh.logEvent(jse, jobId);
jh.closeWriter(jobId);
// Corrupt the history file. User RawLocalFileSystem so that we
// do keep the original CRC file intact.
String historyFileName = jobId.toString() + "_" + "user";
Path historyFilePath = new Path (historyDir.toString(), historyFileName);
RawLocalFileSystem fs = (RawLocalFileSystem)
FileSystem.getLocal(conf).getRaw();
FSDataOutputStream out = fs.create(historyFilePath, true);
byte[] corruptData = new byte[32];
new Random().nextBytes(corruptData);
out.write (corruptData, 0, 32);
out.close();
// Stop and start the tracker. The tracker should come up nicely
mr.stopJobTracker();
mr.startJobTracker();
jt = mr.getJobTrackerRunner().getJobTracker();
assertNotNull("JobTracker did not come up", jt );
jh = jt.getJobHistory();
assertNotNull("JobHistory did not get initialized correctly", jh);
// Only the done folder should remain in the history directory
assertEquals("Files in logDir did not move to DONE folder",
1, historyDir.getFileSystem(conf).listStatus(historyDir).length);
} finally {
if (mr != null) {
cleanupLocalFiles(mr);
mr.shutdown();
}
}
}
}
|
package com.niemisami.opticalmobilesensor.SignalProcessing;
import java.util.ArrayList;
import java.util.List;
/**
* Created by sakrnie on 5.7.2016.
*/
public class DSP {
public static double getWeightedAverage(int[] array) {
int[] instances = getInstances(array);
int[] weights = getWeights(instances, array);
if (instances.length != weights.length) {
return 0.0;
}
double sumWeightedInstances = 0.0;
double sumInstances = 0.0;
for (int i = 0; i < instances.length; i++) {
sumInstances += weights[i];
sumWeightedInstances += instances[i] * weights[i];
}
return sumWeightedInstances / sumInstances;
}
public static float getAverage(int[] array) {
float sum = 0.0f;
for (int i = 0; i < array.length; i++) {
sum += array[i];
}
return sum / array.length;
}
public static int[] getWeights(int[] instances, int[] values) {
int[] weights = new int[instances.length];
for (int i = 0; i < instances.length; i++) {
int weight = 0;
for (int j = 0; j < values.length; j++) {
if (values[j] == instances[i]) {
weight++;
}
}
weights[i] = weight;
}
return weights;
}
public static int[] getInstances(int[] values) {
// int[] instances = new int[values.length];
List<Integer> instances = new ArrayList<>();
instances.add(values[0]);
boolean isInstance;
for (int i : values) {
isInstance = false;
for (int j = 0; j < instances.size(); j++) {
if (i == instances.get(j)) {
isInstance = true;
break;
}
}
if (!isInstance) {
instances.add(i);
}
}
return listToArray(instances);
}
public static int[] listToArray(List<Integer> list) {
int[] array = new int[list.size()];
for (int i = 0; i < list.size(); i++) {
array[i] = list.get(i);
}
return array;
}
}
|
package com.lnunno.musicutils.echonest;
import com.echonest.api.v4.Artist;
import com.echonest.api.v4.Biography;
import com.echonest.api.v4.Blog;
import com.echonest.api.v4.EchoNestException;
import com.echonest.api.v4.Image;
import com.echonest.api.v4.Review;
import java.util.List;
import static com.lnunno.musicutils.echonest.EchoNestExampleUtils.EN;
/**
* Created by Lucas on 1/19/2015.
*/
public class EchoNestExamples {
private static void printDetail(String title, String text) {
System.out.println(title + ":\n\t" + text);
}
public static void runArtistExample() throws EchoNestException {
List<Artist> results = EN.searchArtists("minus the bear");
for (Artist artist : results) {
System.out.println(artist);
for (Biography bio : artist.getBiographies()) {
System.out.println("SITE:\n" + bio.getSite());
System.out.println("LICENSE:\n" + bio.getLicenseType());
System.out.println("TEXT:\n" + bio.getText());
}
for (Blog blog : artist.getBlogs()) {
System.out.println("BLOG_TITLE:\n\t" + blog.getName());
System.out.println("BLOG_SUMMARY:\n\t" + blog.getSummary());
}
for (Image image : artist.getImages()) {
System.out.println("IMAGE:\n\t" + image.getURL());
}
for (Review review : artist.getReviews()) {
printDetail("REVIEW_NAME", review.getName());
printDetail("REVIEW_IMAGE", review.getImageURL());
printDetail("REVIEW_SUMMARY", review.getSummary());
}
}
}
public static void main(String[] args) throws EchoNestException {
runArtistExample();
}
}
|
package com.basic.table.model;
import com.basic.comp.impl.table.model.UsrTableModel;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import java.util.List;
public class UsrTMforGrp extends UsrTableModel {
@Override
public void setModels(List models) {
this.models=models;
fireTableDataChanged();
}
@Override
public void loadJumlahData(ODatabaseDocumentTx db) {
if (paging != null) {
paging.getPanel().setVisible(false);
}
}
}
|
package com.cannapaceus.jfx;
import com.cannapaceus.grader.DBService;
import com.cannapaceus.services.EmailService;
import com.jfoenix.controls.JFXPasswordField;
import com.jfoenix.controls.JFXTextField;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
public class SettingsController {
ScreenController sc;
DBService db;
EmailService em;
@FXML
JFXTextField tfInstructorEmail;
@FXML
JFXPasswordField tfInstructorEmailPass;
@FXML
private void initialize()
{
sc = ScreenController.getInstance();
db = DBService.getInstance();
em = EmailService.getInstance();
tfInstructorEmail.setText(em.getsFromAddress());
tfInstructorEmailPass.setText(em.getsPassword());
}
public void saveClick(ActionEvent event) {
if(!formValidate())
return;
db.updateEmail(tfInstructorEmail.getText());
db.updateEmailPass(tfInstructorEmailPass.getText());
em.setsFromAddress(tfInstructorEmail.getText());
em.setsPassword(tfInstructorEmailPass.getText());
}
private boolean formValidate() {
boolean isAllValid = true;
if (!tfInstructorEmail.validate())
isAllValid = false;
if (!tfInstructorEmailPass.validate())
isAllValid = false;
return isAllValid;
}
}
|
package com.tencent.mm.booter.notification;
class f$a {
private static final f cYV = new f((byte) 0);
}
|
package cn.gd.gy.component;
public class DataHolder {
public String mTitle;
public String mText;
public boolean mChecked;
public DataHolder(String title,String text,boolean checked)
{
this.mTitle=title;
this.mText=text;
this.mChecked=checked;
}
}
|
package net.minecraft.client.audio;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
public class MovingSoundMinecartRiding extends MovingSound {
private final EntityPlayer player;
private final EntityMinecart minecart;
public MovingSoundMinecartRiding(final EntityPlayer playerRiding, final EntityMinecart minecart)
{
super(new ResourceLocation("minecraft:minecart.inside"));
this.player = playerRiding;
this.minecart = minecart;
this.attenuationType = ISound.AttenuationType.NONE;
this.repeat = true;
this.repeatDelay = 0;
}
/**
* Like the old updateEntity(), except more generic.
*/
@Override
public void update() {
if (!this.minecart.isDead && this.player.isRiding() && this.player.ridingEntity == this.minecart) {
final float f = MathHelper.sqrt_double(this.minecart.motionX * this.minecart.motionX + this.minecart.motionZ * this.minecart.motionZ);
if (f >= 0.01D) this.volume = 0.0F + MathHelper.clamp_float(f, 0.0F, 1.0F) * 0.75F;
else this.volume = 0.0F;
} else this.donePlaying = true;
}
}
|
package com.agenin.report.Model;
import com.agenin.report.Model.ProductModel;
import com.google.gson.annotations.SerializedName;
public class OrderListModel {
@SerializedName("ordered_date")
private String ordered_date;
@SerializedName("confirmed_date")
private String confirmed_date;
@SerializedName("packed_date")
private String packed_date;
@SerializedName("shipped_date")
private String shipped_date;
@SerializedName("delivered_date")
private String delivered_date;
@SerializedName("canceled_date")
private String canceled_date;
@SerializedName("confirmed")
private Boolean confirmed;
@SerializedName("packed")
private Boolean packed;
@SerializedName("shipped")
private Boolean shipped;
@SerializedName("delivered")
private Boolean delivered;
@SerializedName("canceled")
private Boolean canceled;
@SerializedName("_id")
private String _id;
@SerializedName("user_id")
private String user_id;
@SerializedName("username")
private String username;
@SerializedName("bukti")
private String bukti;
@SerializedName("atas_nama")
private String atas_nama;
@SerializedName("bank")
private String bank;
@SerializedName("tgl_transfer")
private String tgl_transfer;
@SerializedName("total_amount")
private Integer total_amount;
@SerializedName("date")
private String date;
public String getTgl_transfer() {
return tgl_transfer;
}
public void setTgl_transfer(String tgl_transfer) {
this.tgl_transfer = tgl_transfer;
}
public Integer getTotal_amount() {
return total_amount;
}
public void setTotal_amount(Integer total_amount) {
this.total_amount = total_amount;
}
public String getOrdered_date() {
return ordered_date;
}
public void setOrdered_date(String ordered_date) {
this.ordered_date = ordered_date;
}
public String getConfirmed_date() {
return confirmed_date;
}
public void setConfirmed_date(String confirmed_date) {
this.confirmed_date = confirmed_date;
}
public String getPacked_date() {
return packed_date;
}
public void setPacked_date(String packed_date) {
this.packed_date = packed_date;
}
public String getShipped_date() {
return shipped_date;
}
public void setShipped_date(String shipped_date) {
this.shipped_date = shipped_date;
}
public String getDelivered_date() {
return delivered_date;
}
public void setDelivered_date(String delivered_date) {
this.delivered_date = delivered_date;
}
public String getCanceled_date() {
return canceled_date;
}
public void setCanceled_date(String canceled_date) {
this.canceled_date = canceled_date;
}
public Boolean getConfirmed() {
return confirmed;
}
public void setConfirmed(Boolean confirmed) {
this.confirmed = confirmed;
}
public Boolean getPacked() {
return packed;
}
public void setPacked(Boolean packed) {
this.packed = packed;
}
public Boolean getShipped() {
return shipped;
}
public void setShipped(Boolean shipped) {
this.shipped = shipped;
}
public Boolean getDelivered() {
return delivered;
}
public void setDelivered(Boolean delivered) {
this.delivered = delivered;
}
public Boolean getCanceled() {
return canceled;
}
public void setCanceled(Boolean canceled) {
this.canceled = canceled;
}
public String get_id() {
return _id;
}
public void set_id(String _id) {
this._id = _id;
}
public String getUser_id() {
return user_id;
}
public void setUser_id(String user_id) {
this.user_id = user_id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getBukti() {
return bukti;
}
public void setBukti(String bukti) {
this.bukti = bukti;
}
public String getAtas_nama() {
return atas_nama;
}
public void setAtas_nama(String atas_nama) {
this.atas_nama = atas_nama;
}
public String getBank() {
return bank;
}
public void setBank(String bank) {
this.bank = bank;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
}
|
package org.caps.spring.bean;
/**
* @Author: caps
* @Date: 2019/4/22 16:12
* @Version 1.0
*/
public class BeanException extends RuntimeException {
public BeanException(String message) {
super(message);
}
public BeanException(String message,Throwable cause) {
super(message,cause);
}
}
|
package com.technology.share.mapper;
import com.technology.share.domain.view.VExtJs;
public interface VExtJsMapper extends MyMapper<VExtJs> {
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.