blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 410 | content_id stringlengths 40 40 | detected_licenses listlengths 0 51 | license_type stringclasses 2
values | repo_name stringlengths 5 132 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 80 | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 132
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 9.45M | extension stringclasses 28
values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 352 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
862c1782ed23617bd93dd09f18b6f0ecfb423b6c | 8fb650e8b01da20d3355535d74278471da0cc143 | /src/test/java/tests/TestCase_001.java | c79d091549a6b583145ac0edf50a6fd54cc9ad14 | [] | no_license | Parag-Yadav-09/AmazonWebsiteAutomation | ca48355ee639aef53f1895c319389a80b7ec1717 | 24caa949ee4d665084dad45eed0519cb7ce23b75 | refs/heads/master | 2023-05-02T04:40:27.493987 | 2021-05-25T03:54:42 | 2021-05-25T03:54:42 | 370,378,348 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,729 | java | package tests;
import pageClass.*;
import utilities.SeleniumUtils;
import org.testng.Assert;
import org.testng.annotations.Test;
import base.TestBase;
public class TestCase_001 extends TestBase {
@Test
public void placeOrder() throws InterruptedException {
SeleniumUtils seleniumUtils = new SeleniumUtils(driver);
HomePage hPage = new HomePage(driver);
SearchResult rPage = new SearchResult(driver);
ProductPage pPage = new ProductPage(driver);
CartPage cPage = new CartPage(driver);
//Step 1: Enter text in search field & search
hPage.enterTextInSearchField("QA testing for beginners");
hPage.clickSearchButton();
//Step 2: Click on the Product
String productPrice = rPage.getProductPrice()+".00";
rPage.clickSearchedProduct();
//Step 3: Verify Product Price & Click Add to Cart
seleniumUtils.switchTab();
String displayedPrice = pPage.getProductPriceFromProductDetailsScreen();
Assert.assertEquals(true, displayedPrice.contains(productPrice), "Correct Price not reflecting on Product Details screen");
pPage.clickAddToCartButton();
//Step 4: Verify Product Price & Click Proceed to Buy
String printedPrice = pPage.getProductPriceFromProceedToBuyScreen();
Assert.assertEquals(true, printedPrice.contains(printedPrice), "Correct Price not reflecting on Proceed to buy screen");
pPage.clickCartButton();
//Step 5: Verify the Product Price on Cart screen
String totalPrice = cPage.gettotalAmount();
Assert.assertEquals(true, totalPrice.contains(productPrice), "Correct Price not reflecting on Cart screen");
}
} | [
"parag.yadav@office365.3pillarglobal.com"
] | parag.yadav@office365.3pillarglobal.com |
9d829452700c0a1ca217e3057d8e670fc9f253ad | 013d3ae01ed0a85ba49caa64a159ecceb09809e3 | /src/main/java/com/firefly/conoche/service/mapper/RatingLocalMapper.java | fa7efb343b1af3e0df853328b10246f31fcc4db6 | [] | no_license | Sergiocr16/conoche-jh | b7e24a208bfa6710bb0b019e0774544c3cdd60bf | 10d54a7ac2be963743d42659231259e23be384f9 | refs/heads/master | 2021-01-17T08:07:16.794175 | 2017-03-07T23:35:57 | 2017-03-07T23:35:57 | 83,855,095 | 0 | 0 | null | 2017-05-05T07:38:27 | 2017-03-04T01:07:25 | JavaScript | UTF-8 | Java | false | false | 1,177 | java | package com.firefly.conoche.service.mapper;
import com.firefly.conoche.domain.*;
import com.firefly.conoche.service.dto.RatingLocalDTO;
import org.mapstruct.*;
import java.util.List;
/**
* Mapper for the entity RatingLocal and its DTO RatingLocalDTO.
*/
@Mapper(componentModel = "spring", uses = {UserMapper.class, })
public interface RatingLocalMapper {
@Mapping(source = "userDetails.id", target = "userDetailsId")
@Mapping(source = "local.id", target = "localId")
@Mapping(source = "local.name", target = "localName")
RatingLocalDTO ratingLocalToRatingLocalDTO(RatingLocal ratingLocal);
List<RatingLocalDTO> ratingLocalsToRatingLocalDTOs(List<RatingLocal> ratingLocals);
@Mapping(source = "userDetailsId", target = "userDetails")
@Mapping(source = "localId", target = "local")
RatingLocal ratingLocalDTOToRatingLocal(RatingLocalDTO ratingLocalDTO);
List<RatingLocal> ratingLocalDTOsToRatingLocals(List<RatingLocalDTO> ratingLocalDTOs);
default Local localFromId(Long id) {
if (id == null) {
return null;
}
Local local = new Local();
local.setId(id);
return local;
}
}
| [
"guntanis666@hotmail.com"
] | guntanis666@hotmail.com |
22ff0e7bc17c4eff37d4e10d675509629ea03c2a | cfe54edd08c8e554e39810f372efb918f01f24f1 | /project/src/main/java/priv/entity/StopWordsSingleton.java | da0ce01a2ce1a32dc967e4c2edd54cf6db1de6a0 | [] | no_license | wx8900/MyProjects | 6e381f57f8e2dd18c993ddd6b61f704b19b06a22 | d4c1bf07ddd8c727edbcd9abfdebe8a37bdd2107 | refs/heads/master | 2022-12-22T06:25:26.352278 | 2020-02-03T14:26:19 | 2020-02-03T14:26:19 | 100,753,874 | 1 | 0 | null | 2022-12-16T10:31:55 | 2017-08-18T22:13:05 | Java | UTF-8 | Java | false | false | 12,889 | java | package priv.entity;
import java.util.HashSet;
public class StopWordsSingleton {
private static HashSet<String> sw = new HashSet<String>();
static {
initStopWords();
}
private StopWordsSingleton(){
//System.out.println("Singleton: " + System.nanoTime());
}
private static class SingletonFactory{
private static StopWordsSingleton singletonInstance = new StopWordsSingleton();
}
public static StopWordsSingleton getInstance() {
return SingletonFactory.singletonInstance;
}
public static boolean hasStopWords (String word) {
return sw.contains(word.toLowerCase());
}
public static void main(String[] args) {
Runnable task = new Runnable() {
public void run() {
try {
System.out.println("===4444==="+StopWordsSingleton.getInstance().hasStopWords("about"));
} catch (Exception e) {
Thread.currentThread().interrupt();
}
}
};
for(int i=0; i<100; i++){
new Thread(task).start();
}
}
private static void initStopWords() {
sw.add("a");
sw.add("able");
sw.add("about");
sw.add("above");
sw.add("according");
sw.add("accordingly");
sw.add("across");
sw.add("actually");
sw.add("after");
sw.add("afterwards");
sw.add("again");
sw.add("against");
sw.add("all");
sw.add("allow");
sw.add("allows");
sw.add("almost");
sw.add("alone");
sw.add("along");
sw.add("already");
sw.add("also");
sw.add("although");
sw.add("always");
sw.add("am");
sw.add("among");
sw.add("amongst");
sw.add("an");
sw.add("and");
sw.add("another");
sw.add("any");
sw.add("anybody");
sw.add("anyhow");
sw.add("anyone");
sw.add("anything");
sw.add("anyway");
sw.add("anyways");
sw.add("anywhere");
sw.add("apart");
sw.add("appear");
sw.add("appreciate");
sw.add("appropriate");
sw.add("are");
sw.add("around");
sw.add("as");
sw.add("aside");
sw.add("ask");
sw.add("asking");
sw.add("associated");
sw.add("at");
sw.add("available");
sw.add("away");
sw.add("awfully");
sw.add("b");
sw.add("be");
sw.add("became");
sw.add("because");
sw.add("become");
sw.add("becomes");
sw.add("becoming");
sw.add("been");
sw.add("before");
sw.add("beforehand");
sw.add("behind");
sw.add("being");
sw.add("believe");
sw.add("below");
sw.add("beside");
sw.add("besides");
sw.add("best");
sw.add("better");
sw.add("between");
sw.add("beyond");
sw.add("both");
sw.add("brief");
sw.add("but");
sw.add("by");
sw.add("c");
sw.add("came");
sw.add("can");
sw.add("cannot");
sw.add("cant");
sw.add("cause");
sw.add("causes");
sw.add("certain");
sw.add("certainly");
sw.add("changes");
sw.add("clearly");
sw.add("co");
sw.add("com");
sw.add("come");
sw.add("comes");
sw.add("concerning");
sw.add("consequently");
sw.add("consider");
sw.add("considering");
sw.add("contain");
sw.add("containing");
sw.add("contains");
sw.add("corresponding");
sw.add("could");
sw.add("course");
sw.add("currently");
sw.add("d");
sw.add("definitely");
sw.add("described");
sw.add("despite");
sw.add("did");
sw.add("different");
sw.add("do");
sw.add("does");
sw.add("doing");
sw.add("done");
sw.add("down");
sw.add("downwards");
sw.add("during");
sw.add("e");
sw.add("each");
sw.add("edu");
sw.add("eg");
sw.add("eight");
sw.add("either");
sw.add("else");
sw.add("elsewhere");
sw.add("enough");
sw.add("entirely");
sw.add("especially");
sw.add("et");
sw.add("etc");
sw.add("even");
sw.add("ever");
sw.add("every");
sw.add("everybody");
sw.add("everyone");
sw.add("everything");
sw.add("everywhere");
sw.add("ex");
sw.add("exactly");
sw.add("example");
sw.add("except");
sw.add("f");
sw.add("far");
sw.add("few");
sw.add("fifth");
sw.add("first");
sw.add("five");
sw.add("followed");
sw.add("following");
sw.add("follows");
sw.add("for");
sw.add("former");
sw.add("formerly");
sw.add("forth");
sw.add("four");
sw.add("from");
sw.add("further");
sw.add("furthermore");
sw.add("g");
sw.add("get");
sw.add("gets");
sw.add("getting");
sw.add("given");
sw.add("gives");
sw.add("go");
sw.add("goes");
sw.add("going");
sw.add("gone");
sw.add("got");
sw.add("gotten");
sw.add("greetings");
sw.add("h");
sw.add("had");
sw.add("happens");
sw.add("hardly");
sw.add("has");
sw.add("have");
sw.add("having");
sw.add("he");
sw.add("hello");
sw.add("help");
sw.add("hence");
sw.add("her");
sw.add("here");
sw.add("hereafter");
sw.add("hereby");
sw.add("herein");
sw.add("hereupon");
sw.add("hers");
sw.add("herself");
sw.add("hi");
sw.add("him");
sw.add("himself");
sw.add("his");
sw.add("hither");
sw.add("hopefully");
sw.add("how");
sw.add("howbeit");
sw.add("however");
sw.add("i");
sw.add("ie");
sw.add("if");
sw.add("ignored");
sw.add("immediate");
sw.add("in");
sw.add("inasmuch");
sw.add("inc");
sw.add("indeed");
sw.add("indicate");
sw.add("indicated");
sw.add("indicates");
sw.add("inner");
sw.add("insofar");
sw.add("instead");
sw.add("into");
sw.add("inward");
sw.add("is");
sw.add("it");
sw.add("its");
sw.add("itself");
sw.add("j");
sw.add("just");
sw.add("k");
sw.add("keep");
sw.add("keeps");
sw.add("kept");
sw.add("know");
sw.add("knows");
sw.add("known");
sw.add("l");
sw.add("last");
sw.add("lately");
sw.add("later");
sw.add("latter");
sw.add("latterly");
sw.add("least");
sw.add("less");
sw.add("lest");
sw.add("let");
sw.add("like");
sw.add("liked");
sw.add("likely");
sw.add("little");
sw.add("ll");
sw.add("look");
sw.add("looking");
sw.add("looks");
sw.add("ltd");
sw.add("m");
sw.add("mainly");
sw.add("many");
sw.add("may");
sw.add("maybe");
sw.add("me");
sw.add("mean");
sw.add("meanwhile");
sw.add("merely");
sw.add("might");
sw.add("more");
sw.add("moreover");
sw.add("most");
sw.add("mostly");
sw.add("much");
sw.add("must");
sw.add("my");
sw.add("myself");
sw.add("n");
sw.add("name");
sw.add("namely");
sw.add("nd");
sw.add("near");
sw.add("nearly");
sw.add("necessary");
sw.add("need");
sw.add("needs");
sw.add("neither");
sw.add("never");
sw.add("nevertheless");
sw.add("new");
sw.add("next");
sw.add("nine");
sw.add("no");
sw.add("nobody");
sw.add("non");
sw.add("none");
sw.add("noone");
sw.add("nor");
sw.add("normally");
sw.add("not");
sw.add("nothing");
sw.add("novel");
sw.add("now");
sw.add("nowhere");
sw.add("o");
sw.add("obviously");
sw.add("of");
sw.add("off");
sw.add("often");
sw.add("oh");
sw.add("ok");
sw.add("okay");
sw.add("old");
sw.add("on");
sw.add("once");
sw.add("one");
sw.add("ones");
sw.add("only");
sw.add("onto");
sw.add("or");
sw.add("other");
sw.add("others");
sw.add("otherwise");
sw.add("ought");
sw.add("our");
sw.add("ours");
sw.add("ourselves");
sw.add("out");
sw.add("outside");
sw.add("over");
sw.add("overall");
sw.add("own");
sw.add("p");
sw.add("particular");
sw.add("particularly");
sw.add("per");
sw.add("perhaps");
sw.add("placed");
sw.add("please");
sw.add("plus");
sw.add("possible");
sw.add("presumably");
sw.add("probably");
sw.add("provides");
sw.add("q");
sw.add("que");
sw.add("quite");
sw.add("qv");
sw.add("r");
sw.add("rather");
sw.add("rd");
sw.add("re");
sw.add("really");
sw.add("reasonably");
sw.add("regarding");
sw.add("regardless");
sw.add("regards");
sw.add("relatively");
sw.add("respectively");
sw.add("right");
sw.add("s");
sw.add("said");
sw.add("same");
sw.add("saw");
sw.add("say");
sw.add("saying");
sw.add("says");
sw.add("second");
sw.add("secondly");
sw.add("see");
sw.add("seeing");
sw.add("seem");
sw.add("seemed");
sw.add("seeming");
sw.add("seems");
sw.add("seen");
sw.add("self");
sw.add("selves");
sw.add("sensible");
sw.add("sent");
sw.add("serious");
sw.add("seriously");
sw.add("seven");
sw.add("several");
sw.add("shall");
sw.add("she");
sw.add("should");
sw.add("since");
sw.add("six");
sw.add("so");
sw.add("some");
sw.add("somebody");
sw.add("somehow");
sw.add("someone");
sw.add("something");
sw.add("sometime");
sw.add("sometimes");
sw.add("somewhat");
sw.add("somewhere");
sw.add("soon");
sw.add("sorry");
sw.add("specified");
sw.add("specify");
sw.add("specifying");
sw.add("still");
sw.add("sub");
sw.add("such");
sw.add("sup");
sw.add("sure");
sw.add("t");
sw.add("take");
sw.add("taken");
sw.add("tell");
sw.add("tends");
sw.add("th");
sw.add("than");
sw.add("thank");
sw.add("thanks");
sw.add("thanx");
sw.add("that");
sw.add("thats");
sw.add("the");
sw.add("their");
sw.add("theirs");
sw.add("them");
sw.add("themselves");
sw.add("then");
sw.add("thence");
sw.add("there");
sw.add("thereafter");
sw.add("thereby");
sw.add("therefore");
sw.add("therein");
sw.add("theres");
sw.add("thereupon");
sw.add("these");
sw.add("they");
sw.add("think");
sw.add("third");
sw.add("this");
sw.add("thorough");
sw.add("thoroughly");
sw.add("those");
sw.add("though");
sw.add("three");
sw.add("through");
sw.add("throughout");
sw.add("thru");
sw.add("thus");
sw.add("to");
sw.add("together");
sw.add("too");
sw.add("took");
sw.add("toward");
sw.add("towards");
sw.add("tried");
sw.add("tries");
sw.add("truly");
sw.add("try");
sw.add("trying");
sw.add("twice");
sw.add("two");
sw.add("u");
sw.add("un");
sw.add("under");
sw.add("unfortunately");
sw.add("unless");
sw.add("unlikely");
sw.add("until");
sw.add("unto");
sw.add("up");
sw.add("upon");
sw.add("us");
sw.add("use");
sw.add("used");
sw.add("useful");
sw.add("uses");
sw.add("using");
sw.add("usually");
sw.add("uucp");
sw.add("v");
sw.add("value");
sw.add("various");
sw.add("ve");
sw.add("very");
sw.add("via");
sw.add("viz");
sw.add("vs");
sw.add("w");
sw.add("want");
sw.add("wants");
sw.add("was");
sw.add("way");
sw.add("we");
sw.add("welcome");
sw.add("well");
sw.add("went");
sw.add("were");
sw.add("what");
sw.add("whatever");
sw.add("when");
sw.add("whence");
sw.add("whenever");
sw.add("where");
sw.add("whereafter");
sw.add("whereas");
sw.add("whereby");
sw.add("wherein");
sw.add("whereupon");
sw.add("wherever");
sw.add("whether");
sw.add("which");
sw.add("while");
sw.add("whither");
sw.add("who");
sw.add("whoever");
sw.add("whole");
sw.add("whom");
sw.add("whose");
sw.add("why");
sw.add("will");
sw.add("willing");
sw.add("wish");
sw.add("with");
sw.add("within");
sw.add("without");
sw.add("wonder");
sw.add("would");
sw.add("would");
sw.add("x");
sw.add("y");
sw.add("yes");
sw.add("yet");
sw.add("you");
sw.add("your");
sw.add("yours");
sw.add("yourself");
sw.add("yourselves");
sw.add("z");
sw.add("zero");
}
}
| [
"cwx8900@gmail.com"
] | cwx8900@gmail.com |
2ec12e181018e49f570eefb2149153df5c400b9b | c77094557504c70c234dd93ac9ee9b845a0260a5 | /src/package1/EndGameState.java | 8820e72b080bee5f0cac544bf16d3cc4b532ee61 | [] | no_license | Kyvi/Dead-s-Mirror-Slick | 0821fbeba5f66aed571663016864cb8f942da90f | 090a3f197639a2d194feac0d9de78c91a1d8d0a4 | refs/heads/master | 2020-03-15T22:49:18.987851 | 2018-05-06T22:53:16 | 2018-05-06T22:53:16 | 132,380,829 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,490 | java | package package1;
import java.awt.Font;
import java.awt.FontFormatException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.Sound;
import org.newdawn.slick.TrueTypeFont;
import org.newdawn.slick.gui.AbstractComponent;
import org.newdawn.slick.gui.ComponentListener;
import org.newdawn.slick.gui.MouseOverArea;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition;
import org.newdawn.slick.util.ResourceLoader;
public class EndGameState extends BasicGameState implements ComponentListener{
public static final int ID = 60;
private StateBasedGame game;
private Image background1;
private Image background2;
private Image background3;
private Image background4;
private Image background5;
private TrueTypeFont font2;
private boolean antiAlias = true;
private MouseOverArea newgame;
private int barre = 0 ;
private int etat = 0;
private int etatbis = 0;
private Sound enter;
private Sound beep;
private Jeu jeu;
private Music music;
public EndGameState(Jeu j){
jeu=j;
}
public void init(GameContainer gc, StateBasedGame s) throws SlickException {
this.game = s;
this.background1 = new Image("/src/package1/ressources/background/miroir.jpg");
this.background2 = new Image("/src/package1/ressources/background/filledort.jpg");
this.background3 = new Image("/src/package1/ressources/background/hommedort.jpg");
this.background4 = new Image("/src/package1/ressources/background/filleetonne.png");
this.background5 = new Image("/src/package1/ressources/background/hommeetonne.jpg");
Image buttonImage = new Image("/src/package1/ressources/hud/newgame.png").getScaledCopy(100, 50);
enter=new Sound("/src/package1/ressources/music/enter.ogg");
beep=new Sound("/src/package1/ressources/music/beep.wav");
music = new Music("/src/package1/ressources/music/creation.ogg");
newgame = new MouseOverArea (gc, buttonImage, 350, 500, this);
try {
InputStream inputStream = ResourceLoader.getResourceAsStream("/src/package1/ressources/Font/immortal/IMMORTAL.ttf");
Font awtFont2 = Font.createFont(Font.TRUETYPE_FONT, inputStream);
awtFont2 = awtFont2.deriveFont(52f); // set font size
font2 = new TrueTypeFont(awtFont2, antiAlias);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FontFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void render(GameContainer gc, StateBasedGame s, Graphics g) throws SlickException {
String textef1[]= {"Après tous ces périples, " + jeu.getplayer().getnom() + " a réussi "
,"a vaincre Keldranor et Mirrathia et ainsi à ramener "
,"le miroir des morts dans son village. Ravie de la "
,"conclusion de cette histoire, " + jeu.getplayer().getnom() + " resta des "
,"heures à parler avec sa défunte mère. Quand d'un coup"
," ... "};
String texteh1[]= {"Après tous ces périples, " + jeu.getplayer().getnom() + " a réussi "
,"a vaincre Keldranor et Mirrathia et ainsi à ramener "
,"le miroir des morts dans son village. Ravi de la "
,"conclusion de cette histoire, " + jeu.getplayer().getnom() + " resta des "
,"heures à parler avec sa défunte mère. Quand d'un coup"
," ... "};
String textef2[] = { jeu.getplayer().getnom() + " ouvrit les yeux se rendant compte que tout ceci",
"n'était qu'un affreux cauchemar. A la fois déçue, ",
"et contente que ce ne fut qu'un rêve, "+ jeu.getplayer().getnom()+"",
"se rendit à son lieu de travail comme tous les jours.",
};
String texteh2[] = { jeu.getplayer().getnom() + " ouvrit les yeux se rendant compte que tout ceci",
"n'était qu'un affreux cauchemar. A la fois déçu, ",
"et content que ce ne fut qu'un rêve, "+ jeu.getplayer().getnom()+"",
"se rendit à son lieu de travail comme tous les jours.",
};
String textef3[]= {"Mais une fois arrivée sur son lieu de travail, "+ jeu.getplayer().getnom()+" ",
"se rendit compte que le miroir avait été volé avec pour seul",
"message un vulgaire papier sur lequel il était écrit : ",
"Ma vengence sera terrible!!"};
String texteh3[]= {"Mais une fois arrivé sur son lieu de travail, "+ jeu.getplayer().getnom()+" ",
"se rendit compte que le miroir avait été volé avec pour seul",
"message un vulgaire papier sur lequel il était écrit : ",
"Ma vengence sera terrible!!"};
g.setColor(new Color(0,0,0,100));
g.fillRect(125, 125, 550, 325);
// Barre de chargement
/*if (barre < 5000) {
g.setColor(new Color(255,0,0,150));
g.fillRect(150, 500, (int)(barre/10), 20);
g.setColor(Color.white);
g.drawString("Chargement en cours", 175, 500);
}*/
g.setColor(Color.white);
switch (etat){
case 0 :
//Important proportions à garder A augmenter pour ralentir, diminuer pour accelerer !! :
//-> vitesse de texte 1000/20,
//-> vitesse de défilement 1000/40
background1.draw(0,0,gc.getWidth(),gc.getHeight());
g.setColor(new Color(0,0,0,100));
g.fillRect(100,100,600,350);
g.setColor(Color.white);
switch(jeu.getplayer().getsexe()){
case 1 :
for (int i=0;i<6;i++){
g.drawString(textef1[i].substring(0, Math.max(0,Math.min((int)((barre-(2000*i))/40),textef1[i].length()))),
150, Math.max(150+(25*i),((int)400-((barre-(2000*i))/80))));}
break;
case 0 :
for (int i=0;i<6;i++){
g.drawString(texteh1[i].substring(0, Math.max(0,Math.min((int)((barre-(2000*i))/40),texteh1[i].length()))),
150, Math.max(150+(25*i),((int)400-((barre-(2000*i))/80))));}
break;
}
if (barre > 20000) { newgame.render(gc, g); g.drawString("Suivant",360,515);}
break;
case 1 :
switch(jeu.getplayer().getsexe()){
case 1 :
background2.draw(0,0,gc.getWidth(),gc.getHeight());
g.setColor(new Color(0,0,0,100));
g.fillRect(100,100,600,350);
g.setColor(Color.white);
for (int i=0;i<4;i++){
g.drawString(textef2[i].substring(0, Math.max(0,Math.min((int)((barre-(2000*i))/40),textef2[i].length()))),
150, Math.max(150+(25*i),((int)400-((barre-(2000*i))/80))));}
break;
case 0 :
background3.draw(0,0,gc.getWidth(),gc.getHeight());
g.setColor(new Color(0,0,0,100));
g.fillRect(100,100,600,350);
g.setColor(Color.white);
for (int i=0;i<4;i++){
g.drawString(texteh2[i].substring(0, Math.max(0,Math.min((int)((barre-(2000*i))/40),texteh2[i].length()))),
150, Math.max(150+(25*i),((int)400-((barre-(2000*i))/80))));}
break;
}
if (barre > 20000) { newgame.render(gc, g); g.drawString("Suivant",360,515);}
break;
case 2 :
switch(jeu.getplayer().getsexe()){
case 1 :
background4.draw(0,0,gc.getWidth(),gc.getHeight());
g.setColor(new Color(0,0,0,100));
g.fillRect(100,100,600,350);
g.setColor(Color.white);
for (int i=0;i<4;i++){
g.drawString(textef3[i].substring(0, Math.max(0,Math.min((int)((barre-(2000*i))/40),textef3[i].length()))),
150, Math.max(150+(25*i),((int)400-((barre-(2000*i))/80))));}
break;
case 0 :
background5.draw(0,0,gc.getWidth(),gc.getHeight());
g.setColor(new Color(0,0,0,100));
g.fillRect(100,100,600,350);
g.setColor(Color.white);
for (int i=0;i<4;i++){
g.drawString(texteh3[i].substring(0, Math.max(0,Math.min((int)((barre-(2000*i))/40),texteh3[i].length()))),
150, Math.max(150+(25*i),((int)400-((barre-(2000*i))/80))));}
break;
}
if (barre > 20000) { newgame.render(gc, g); g.drawString("Suivant",360,515);}
break;
case 3 :
g.setColor(Color.black);
g.fillRect(0,0,gc.getWidth(),gc.getHeight());
g.setColor(Color.white);
font2.drawString(200, 200, "To be continued");
font2.drawString(300, 300, ". . .");
break;
}
}
@Override
public void update(GameContainer gc, StateBasedGame s, int delta) throws SlickException {
if (etatbis==1){barre=0;etatbis = 0;}
barre += delta;
if (etat == 3 && barre > 8000){music.loop();game.enterState(1,new FadeOutTransition(Color.black, 1000), new FadeInTransition(Color.black,1000));}
}
public void componentActivated(AbstractComponent source) {
switch (etat){
case 0 :
if (source == newgame && barre > 20000) {
beep.play();
etat = 1;
etatbis = 1;
}
break;
case 1 :
if (source == newgame && barre > 20000) {
beep.play();
etat = 2;
etatbis = 1;
}
break;
case 2 :
if (source == newgame && barre > 20000) {
beep.play();
etat = 3;
etatbis = 1;
}
break;
}
}
public void keyPressed(int key, char c) {
switch (key) {
case Input.KEY_ENTER:
barre =25000;
break;
}
}
@Override
public int getID() {
return ID;
}
} | [
"vincent657.leclerc@gmail.com"
] | vincent657.leclerc@gmail.com |
5f419a80824ed6be74a45ad01b8f7fed1d91b40f | 68fa49b6f53e33a10e92fd2fc19b273142a59f13 | /core/src/main/java/lab/ride/security/core/validate/ValidateCodeProcessorHolder.java | 8a4a205da9c416de4cec36ff37664c40083bc8aa | [] | no_license | Claymoreterasa/spring-security-learn | 2371d362707515d3c2bcaaff3d05a984dcaeef94 | 9c405c17697b03812be7c7bba5d6a7751c96e2b6 | refs/heads/master | 2020-04-08T02:00:53.701610 | 2018-12-05T07:38:10 | 2018-12-05T07:38:10 | 158,919,057 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 948 | java | package lab.ride.security.core.validate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* @author cwz
* @date 2018/11/30
*/
@Component
public class ValidateCodeProcessorHolder {
@Autowired
private Map<String, ValidateCodeProcessor> validateCodeProcessors;
public ValidateCodeProcessor findValidateCodeProcessor(ValidateCodeType type){
return findValidateCodeProcessor(type.name());
}
public ValidateCodeProcessor findValidateCodeProcessor(String type){
String beanName = type.toLowerCase() + ValidateCodeProcessor.class.getSimpleName();
ValidateCodeProcessor processor = validateCodeProcessors.get(beanName);
if(processor == null){
throw new ValidateCodeException("没有" + type + "类型的验证码处理器");
}
return validateCodeProcessors.get(beanName);
}
}
| [
"517364893@qq.com"
] | 517364893@qq.com |
f4ca6425df8df719c3b65218b5a7771c8eed69fd | 11f942da831230d6460bf472fb16d1faa6b129df | /src/main/java/tddmain/Calculator.java | f0c1f3dd53d70e47eccca0682394b72830dada82 | [] | no_license | sujtha82/june-batch-cucumber | 02dd46aafbf7c950ef3c8fd97b8221c5ca4f7905 | 7e8ba8c2dcf943a51ccf53c808eaee5f933324db | refs/heads/master | 2023-05-31T18:55:15.362944 | 2021-06-28T13:24:07 | 2021-06-28T13:24:07 | 381,040,059 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 117 | java | package tddmain;
public class Calculator {
public int add(int i , int i1) {
return add ( i,i1 );
}
} | [
"sujatha"
] | sujatha |
16053acf9436cb20b4df1f36f9d7136e8f565985 | d1cf984ae2409e3522a83615449cf53d0efa0ccb | /code/metro/src/main/java/cn/zdmake/metro/model/MetroLineInterval.java | 1361a350ff8a79ccfca1db9a482f694ba8c5f18f | [] | no_license | luojionghao/metro | 10d85d2c3e9c348c3622f866ac2939dae87ce5db | 11ed9ab23251783eabea67e8c1eb47b00d560188 | refs/heads/master | 2021-01-01T18:21:21.160320 | 2017-08-11T09:00:16 | 2017-08-11T09:00:16 | 98,320,298 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,413 | java | package cn.zdmake.metro.model;
import java.util.Date;
import java.util.List;
/**
* 线路区间
* @author MAJL
*
*/
public class MetroLineInterval implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = -2009337539319164592L;
private Long id;//系统ID
private Long lineId;//线路id
private String intervalName;//区间名称
private Integer intervalMark;//工程标号
private Integer status;//状态控制区间在工程树中是否可见(0禁用1启用)
private String projectPdfUrl;//工程文档URL
private String imgMapXyUrl;//剖面图大地坐标文件URL
private String riskPdfUrl;//风险组段划分URL
private String remark;//备注
private Date updateTime;//更新时间
private Date createTime;//创建时间
private List<MetroLineIntervalData> intervalDataList;//线路区间左右线数据列表
private List<MetroLineIntervalLr> intervalLrList;//左右线信息
private Long intervalId;//区间id用于地图
public MetroLineInterval(){}
/**
* 获取id
* @return id id
*/
public Long getId() {
return id;
}
/**
* 设置id
* @param id id
*/
public void setId(Long id) {
this.id = id;
this.intervalId = id;
}
/**
* 获取lineId
* @return lineId lineId
*/
public Long getLineId() {
return lineId;
}
/**
* 设置lineId
* @param lineId lineId
*/
public void setLineId(Long lineId) {
this.lineId = lineId;
}
/**
* 获取status
* @return status status
*/
public Integer getStatus() {
return status;
}
/**
* 设置status
* @param status status
*/
public void setStatus(Integer status) {
this.status = status;
}
/**
* 获取projectPdfUrl
* @return projectPdfUrl projectPdfUrl
*/
public String getProjectPdfUrl() {
return projectPdfUrl;
}
/**
* 设置projectPdfUrl
* @param projectPdfUrl projectPdfUrl
*/
public void setProjectPdfUrl(String projectPdfUrl) {
this.projectPdfUrl = projectPdfUrl;
}
/**
* 获取imgMapXyUrl
* @return imgMapXyUrl imgMapXyUrl
*/
public String getImgMapXyUrl() {
return imgMapXyUrl;
}
/**
* 设置imgMapXyUrl
* @param imgMapXyUrl imgMapXyUrl
*/
public void setImgMapXyUrl(String imgMapXyUrl) {
this.imgMapXyUrl = imgMapXyUrl;
}
/**
* 获取riskPdfUrl
* @return riskPdfUrl riskPdfUrl
*/
public String getRiskPdfUrl() {
return riskPdfUrl;
}
/**
* 设置riskPdfUrl
* @param riskPdfUrl riskPdfUrl
*/
public void setRiskPdfUrl(String riskPdfUrl) {
this.riskPdfUrl = riskPdfUrl;
}
/**
* 获取remark
* @return remark remark
*/
public String getRemark() {
return remark;
}
/**
* 设置remark
* @param remark remark
*/
public void setRemark(String remark) {
this.remark = remark;
}
/**
* 获取updateTime
* @return updateTime updateTime
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* 设置updateTime
* @param updateTime updateTime
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取createTime
* @return createTime createTime
*/
public Date getCreateTime() {
return createTime;
}
/**
* 设置createTime
* @param createTime createTime
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getIntervalName() {
return intervalName;
}
public void setIntervalName(String intervalName) {
this.intervalName = intervalName;
}
/**
* 获取intervalDataList
* @return intervalDataList intervalDataList
*/
public List<MetroLineIntervalData> getIntervalDataList() {
return intervalDataList;
}
/**
* 设置intervalDataList
* @param intervalDataList intervalDataList
*/
public void setIntervalDataList(List<MetroLineIntervalData> intervalDataList) {
this.intervalDataList = intervalDataList;
}
/**
* 获取intervalLrList
* @return intervalLrList intervalLrList
*/
public List<MetroLineIntervalLr> getIntervalLrList() {
return intervalLrList;
}
public void setIntervalLrList(List<MetroLineIntervalLr> intervalLrList) {
this.intervalLrList = intervalLrList;
}
public Long getIntervalId() {
return intervalId;
}
public void setIntervalId(Long intervalId) {
this.intervalId = intervalId;
}
public Integer getIntervalMark() {
return intervalMark;
}
public void setIntervalMark(Integer intervalMark) {
this.intervalMark = intervalMark;
}
}
| [
"455709246@qq.com"
] | 455709246@qq.com |
41691b63d9ab25668d279f4e81b6e2185cb35f70 | 04356c47fb3c6497f7e2e4cf2132cb909505a51e | /core/src/main/java/com/mindtree/net/core/models/Testing.java | 5ee651bfdddc116cd6d9035e815deb3ff4126246 | [] | no_license | dushyntSharma/slingtest-aem-project | 8521a362387dd221ca56df114b2c7a89f9461ed4 | 63659af436aa741b1489a179c0032180887d2ff1 | refs/heads/master | 2023-05-10T07:20:49.105967 | 2021-06-03T16:33:18 | 2021-06-03T16:33:18 | 362,999,005 | 1 | 2 | null | null | null | null | UTF-8 | Java | false | false | 2,957 | java | package com.mindtree.net.core.models;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Via;
import org.apache.sling.models.annotations.injectorspecific.RequestAttribute;
import org.apache.sling.models.annotations.injectorspecific.ResourcePath;
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.wcm.api.Page;
import lombok.Getter;
@Model(adaptables = SlingHttpServletRequest.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class Testing {
private static final Logger LOGGER = LoggerFactory.getLogger(Testing.class);
@RequestAttribute(name = "rAttribute")
private String reqAttribute;
@ResourcePath(path = "/content/Test/en/Annotations")
@Via("resource")
Resource resource;
@ScriptVariable
Page currentPage;
@Inject
@Via("resource")
@Named("jcr:createdBy")
String createdBy;
@Inject
@Via("resource")
String firstName;
@ValueMapValue
String lastName;
@Inject
@Via("resource")
boolean currentEmployee;
@ValueMapValue
private List<String> books;
@Inject
@Via("resource")
String country;
@Inject
@Via("resource")
String gender;
@ValueMapValue
String fileReference;
@ValueMapValue
String pathBrowser;
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public boolean getCurrentEmployee() {
return currentEmployee;
}
public String getPageTitle() {
return currentPage.getTitle();
}
public String getRequestAttribute() {
return reqAttribute;
}
public String getHomePageName() {
return resource.getName();
}
public String getLastModifiedBy() {
return createdBy;
}
public List<String> getAuthBooks() {
if (books != null) {
return new ArrayList<String>(books);
} else {
return Collections.emptyList();
}
}
public String getCountry() {
return country;
}
public String getGender() {
return gender;
}
public String getPathBrowser() {
return pathBrowser;
}
@PostConstruct
public String getFileReference() {
return fileReference;
}
@Getter
private String output;
@PostConstruct
protected void init() {
output = "FirstName: " + firstName + "\nLastName: " + lastName + "\nEmployee?: " + currentEmployee
+ "\nCountry: " + country + "\nGender: " + gender;
}
// @PostConstruct
// protected void init() {
// LOGGER.info("\n Inside INIT {} : {}", currentPage.getTitle(), resource.getPath());
//
// }
}
| [
"shreevatsa.dush@gmail.com"
] | shreevatsa.dush@gmail.com |
89b2147e417edd0e6b593755c91cd30e9846c328 | 5b4ffaf1c07077452d6921c44c50bc995ebb8df9 | /conexion.java | f6bef76f302fd8010f806655811c259aa59c2328 | [] | no_license | jdelacruzduarte/FarmaciaBalin | c93e00e6ef81da7df47ca37182810693de714773 | b20f5b35cde0c116e8ff1b7d9b5118d40b06f5c0 | refs/heads/master | 2021-01-10T09:02:12.340283 | 2016-04-16T23:09:43 | 2016-04-16T23:09:43 | 54,592,913 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,653 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package servicios;
import com.mysql.jdbc.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author Jesus
*/
public class conexion {
public static Statement createStatement() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
java.sql.Connection conect = null;
public java.sql.Connection obtener()
{
try {
//Cargamos el Driver MySQL
Class.forName("com.mysql.jdbc.Driver");
conect = DriverManager.getConnection("jdbc:mysql://localhost/mydb","root","123456");
//JOptionPane.showMessageDialog(null, "conectado");
//Cargamos el Driver Access
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Conectar en red base
//String strConect = "jdbc:odbc:Driver=Microsoft Access Driver (*.mdb);DBQ=//servidor/bd_cw/cw.mdb";
//Conectar Localmente
//String strConect = "jdbc:odbc:Driver=Microsoft Access Driver (*.mdb);DBQ=D:/cwnetbeans/cw.mdb";
//conect = DriverManager.getConnection(strConect,"","");
} catch (Exception e) {
JOptionPane.showMessageDialog(null,"Error "+e);
}
return conect;
}
//nuevo metodo para hacer algo
//algo muy importante
// algo reciente esta por
}
| [
"jdelacruzduarte@gmail.com"
] | jdelacruzduarte@gmail.com |
0d892fb87541915f96a9542a49354f7766f26406 | b57e2c7d2a586581ae2e87ed7b69f80200e1cfa8 | /app/src/main/java/com/huxin/communication/view/ClipView.java | 21b1362d88f1acb0d1cf0e366672c088855b384e | [] | no_license | q57690633/SCommunication | 7e90c244434666345067b8bf154d5f8289fdced9 | 345163e39fb85dcb5e99099a99c60d354fc923a3 | refs/heads/master | 2020-04-23T15:52:54.559082 | 2019-03-18T18:46:58 | 2019-03-18T18:46:58 | 171,279,419 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,246 | java | package com.huxin.communication.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.Xfermode;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.WindowManager;
/**
* 头像上传裁剪框
*/
public class ClipView extends View {
private Paint paint = new Paint();
//画裁剪区域边框的画笔
private Paint borderPaint = new Paint();
//裁剪框水平方向间距
private float mHorizontalPadding;
//裁剪框边框宽度
private int clipBorderWidth;
//裁剪圆框的半径
private int clipRadiusWidth;
//裁剪框矩形宽度
private int clipWidth;
//裁剪框类别,(圆形、矩形),默认为圆形
private ClipType clipType = ClipType.CIRCLE;
private Xfermode xfermode;
public ClipView(Context context) {
this(context, null);
}
public ClipView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ClipView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
//去锯齿
paint.setAntiAlias(true);
borderPaint.setStyle(Style.STROKE);
borderPaint.setColor(Color.WHITE);
borderPaint.setStrokeWidth(clipBorderWidth);
borderPaint.setAntiAlias(true);
xfermode = new PorterDuffXfermode(PorterDuff.Mode.DST_OUT);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int LAYER_FLAGS = Canvas.MATRIX_SAVE_FLAG | Canvas.CLIP_SAVE_FLAG
| Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.FULL_COLOR_LAYER_SAVE_FLAG
| Canvas.CLIP_TO_LAYER_SAVE_FLAG;
//通过Xfermode的DST_OUT来产生中间的透明裁剪区域,一定要另起一个Layer(层)
canvas.saveLayer(0, 0, this.getWidth(), this.getHeight(), null, LAYER_FLAGS);
//设置背景
canvas.drawColor(Color.parseColor("#a8000000"));
paint.setXfermode(xfermode);
//绘制圆形裁剪框
if (clipType == ClipType.CIRCLE) {
//中间的透明的圆
canvas.drawCircle(this.getWidth() / 2, this.getHeight() / 2, clipRadiusWidth, paint);
//白色的圆边框
canvas.drawCircle(this.getWidth() / 2, this.getHeight() / 2, clipRadiusWidth, borderPaint);
} else if (clipType == ClipType.RECTANGLE) { //绘制矩形裁剪框
//绘制中间的矩形
canvas.drawRect(mHorizontalPadding, this.getHeight() / 2 - clipWidth / 2,
this.getWidth() - mHorizontalPadding, this.getHeight() / 2 + clipWidth / 2, paint);
//绘制白色的矩形边框
canvas.drawRect(mHorizontalPadding, this.getHeight() / 2 - clipWidth / 2,
this.getWidth() - mHorizontalPadding, this.getHeight() / 2 + clipWidth / 2, borderPaint);
}
//出栈,恢复到之前的图层,意味着新建的图层会被删除,新建图层上的内容会被绘制到canvas (or the previous layer)
canvas.restore();
}
/**
* 获取裁剪区域的Rect
*
* @return
*/
public Rect getClipRect() {
Rect rect = new Rect();
//宽度的一半 - 圆的半径
rect.left = (this.getWidth() / 2 - clipRadiusWidth);
//宽度的一半 + 圆的半径
rect.right = (this.getWidth() / 2 + clipRadiusWidth);
//高度的一半 - 圆的半径
rect.top = (this.getHeight() / 2 - clipRadiusWidth);
//高度的一半 + 圆的半径
rect.bottom = (this.getHeight() / 2 + clipRadiusWidth);
return rect;
}
/**
* 设置裁剪框边框宽度
*
* @param clipBorderWidth
*/
public void setClipBorderWidth(int clipBorderWidth) {
this.clipBorderWidth = clipBorderWidth;
borderPaint.setStrokeWidth(clipBorderWidth);
invalidate();
}
/**
* 设置裁剪框水平间距
*
* @param mHorizontalPadding
*/
public void setmHorizontalPadding(float mHorizontalPadding) {
this.mHorizontalPadding = mHorizontalPadding;
this.clipRadiusWidth = (int) (getScreenWidth(getContext()) - 2 * mHorizontalPadding) / 2;
this.clipWidth = clipRadiusWidth * 2;
}
/**
* 获得屏幕高度
*
* @param context
* @return
*/
public static int getScreenWidth(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics outMetrics = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(outMetrics);
return outMetrics.widthPixels;
}
/**
* 设置裁剪框类别
*
* @param clipType
*/
public void setClipType(ClipType clipType) {
this.clipType = clipType;
}
/**
* 裁剪框类别,圆形、矩形
*/
public enum ClipType {
CIRCLE, RECTANGLE
}
}
| [
"312325322@qq.com"
] | 312325322@qq.com |
ca6a20bfb17153cb11e7bebe00e789428f786b33 | dc945e62937adfecd9faad1ce434d5856316369e | /src/utils/Log.java | 83567e3bb02b95ec76e093cbb900be1d84a6d0d3 | [] | no_license | SCRAPPYDOO/ScrappyAirsoftShop | bbdc7a7da4f1ab0b47ffb08905d6cf3ee031bd35 | 977a7030b3643ce7796cf8e4d0005eb55aafd5bc | refs/heads/master | 2021-03-12T21:45:57.101351 | 2015-09-16T10:49:45 | 2015-09-16T10:49:45 | 41,765,695 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 519 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package utils;
import global.GlobalParameters;
/**
*
* @author User
*/
public class Log {
private static boolean logEnabled = true;
public static void log(String log) {
if(logEnabled) {
System.out.println(log);
}
}
public static void email(String log) {
if(GlobalParameters.LOGGER_EMAIL) {
log("EMAIL SENDER: " + log);
}
}
}
| [
"scrapek69@gmail.com"
] | scrapek69@gmail.com |
d41ce3ba64f711785e127486eaa2528374f2a68b | fb05698271aaf416b4f0d473b8590e0cdb657230 | /You Tube Data Analysis/Length Count/toplengthvideos(source code)/src/LengthReducer.java | d6f00d6616a3ad32f612cc484b5969cbc2c08b79 | [] | no_license | abhijitdey123/Youtube_Data_Analysis_Hadoop | 78b86def135ca463fd0b3a9cb443c1fdec93ed64 | 81457b846e18ea58b44240605d0bbcd1d607c034 | refs/heads/master | 2021-09-02T11:35:55.850363 | 2018-01-02T09:03:02 | 2018-01-02T09:03:02 | 115,933,196 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 573 | java | import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
public class LengthReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
@Override
protected void reduce(Text key, Iterable<IntWritable> value,
Reducer<Text, IntWritable, Text, IntWritable>.Context con) throws IOException, InterruptedException {
int sum = 0;
int l = 0;
for (IntWritable val : value) {
sum += val.get();
l++;
}
sum = sum / l;
con.write(key, new IntWritable(sum));
}
}
| [
"33427964+abhijitdey123@users.noreply.github.com"
] | 33427964+abhijitdey123@users.noreply.github.com |
0bc8190ba92d7eaf5c12c59e6d42c80e80f1ca08 | 55e507e28cf7b760028b6751ea07ecb05e4553b7 | /src/main/java/ysh/com/demo/biz/service/impl/TestUserServiceImpl.java | be7c4bf140ce1f6e4532ab99f131e98d374d544c | [] | no_license | yangsh1024/study-springboot | 3fe2419bf9caf3c1dd68848d27e91e43c68bbea3 | 1af5d4d7cd313c064f9d0203a5d35bb1caa98b98 | refs/heads/master | 2023-04-28T15:41:54.013552 | 2021-05-18T04:20:12 | 2021-05-18T04:20:12 | 364,846,920 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 493 | java | package ysh.com.demo.biz.service.impl;
import org.springframework.stereotype.Service;
import ysh.com.db.base.biz.service.impl.BaseServiceImpl;
import ysh.com.demo.biz.entity.TestUser;
import ysh.com.demo.biz.service.TestUserService;
/**
* @author yangsh
* @since 2021/4/15 4:36 下午
*/
@Service
public class TestUserServiceImpl extends BaseServiceImpl<TestUser> implements TestUserService {
@Override
public boolean saveUser(TestUser user) {
return save(user);
}
}
| [
"shouhao.yang@jdongtech.com"
] | shouhao.yang@jdongtech.com |
b2359e09dc2c53857892b6b0d8de77362b178256 | 8a53d9a526ec13a979719ba6c63a172b34496c8a | /src/main/java/com/mvoicu/sales/benefits/web/rest/errors/InvalidPasswordException.java | cb662683407aa91c1e6a4d1790b6a0c4cebf41d1 | [] | no_license | mihaivoicu7/sales-incentive | c6cfd69f51321c0b1114aff3d3d91e725f54ba18 | 24b5bab037dc9ed0a3234c43541a004505767f3a | refs/heads/master | 2020-03-28T11:29:58.659139 | 2018-09-13T20:14:58 | 2018-09-13T20:14:58 | 148,220,784 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 412 | java | package com.mvoicu.sales.benefits.web.rest.errors;
import org.zalando.problem.AbstractThrowableProblem;
import org.zalando.problem.Status;
public class InvalidPasswordException extends AbstractThrowableProblem {
private static final long serialVersionUID = 1L;
public InvalidPasswordException() {
super(ErrorConstants.INVALID_PASSWORD_TYPE, "Incorrect password", Status.BAD_REQUEST);
}
}
| [
"mihai.voicu@ax-ao.de"
] | mihai.voicu@ax-ao.de |
24ec0e7bfffa30ab82d025c7c31c94c1a0668ae8 | 462668f00eefbc55be61963b113dc9217c8adde4 | /Java_Fundemantals/FizzBuzz/FizzBuzz.java | 7d594ed31c4143d9e12b8c888966ee3a58b103f8 | [] | no_license | AwsRadwan/Java_Stack | 432156654a0f7858bd4c0a2d106587080c09f89d | fd6c7ef695aa06bfad8cf868e49d52563b3fcbb3 | refs/heads/master | 2023-06-03T03:57:30.979453 | 2021-06-30T17:11:46 | 2021-06-30T17:11:46 | 378,265,472 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 391 | java | public class FizzBuzz {
public String fizzBuzz(int number) {
if(number%3 == 0 && number%5 == 0){
return "FizzBuzz";
}
else if(number%5 == 0){
return "Buzz";
}
else if(number%3 == 0){
return "Fizz";
}
else{
String x = Integer.toString(number);
return x;
}
}
}
| [
"awsradwan3@gmail.com"
] | awsradwan3@gmail.com |
f1ea8f3a4840f24095342564f378b2cccf9ee80c | 14d9fb2ba87c697bd010cb36e549e2c1014bb287 | /18. JSON Processing Exercise/json-ex-demo/src/main/java/com/example/demo/models/dtos/ex3query3/CategoryWithProductsDto.java | 770a6e08fa6fa11a2d75e5d64dd927c2cfc4df54 | [] | no_license | Stanislav-Petkov/SoftUni-Spring-Data | 8362e888ff337fa24de84c129565b1e19fd72f8a | 600d29610d00073d84231c69d00d51a9fca741f0 | refs/heads/master | 2023-03-10T09:25:24.967036 | 2021-02-26T10:57:20 | 2021-02-26T10:57:20 | 342,517,134 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,136 | java | package com.example.demo.models.dtos.ex3query3;
import com.google.gson.annotations.Expose;
import java.math.BigDecimal;
import java.math.BigInteger;
public class CategoryWithProductsDto {
@Expose
private String category;
@Expose
private Integer productsCount;
@Expose
private BigDecimal averagePrice;
@Expose
private BigDecimal totalRevenue;
public CategoryWithProductsDto() {
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public int getProductsCount() {
return productsCount;
}
public void setProductsCount(Integer productsCount) {
this.productsCount = productsCount;
}
public BigDecimal getAveragePrice() {
return averagePrice;
}
public void setAveragePrice(BigDecimal averagePrice) {
this.averagePrice = averagePrice;
}
public BigDecimal getTotalRevenue() {
return totalRevenue;
}
public void setTotalRevenue(BigDecimal totalRevenue) {
this.totalRevenue = totalRevenue;
}
}
| [
"slavipetkov10@gmail.com"
] | slavipetkov10@gmail.com |
4abb5108a45a41985715ff380a90f63cb6000a5c | c4e934bd492d427a965cd41e0ef1f483c9b34e32 | /src/Module_2/Laba_2_7_Inheritance_Polymorphism/Shapes/Main.java | def19f60648f1df28f88a29aa45e1727c8670597 | [] | no_license | SergeyKhmel/MainAcademy | fd5f57e3d19f8d99ceac4343e5ff3047d83b3c66 | 3a45fa135c1d122b2154079680a2b86dee268e7c | refs/heads/master | 2021-03-13T02:54:52.354190 | 2017-05-26T12:50:26 | 2017-05-26T12:50:26 | 91,484,758 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,556 | java | package Module_2.Laba_2_7_Inheritance_Polymorphism.Shapes;
import java.util.Random;
/*Create class Main_1 with method main().
The program must demonstrate the creation of one Shape object and print it name and color to console.
Then add code to invoke calcArea() method and print result to console.
Program output must looks like:
“This is Shape, color is: RED”
“Shape area is: 0”
Use MyShapes project. The program must demonstrate the creation of an array of different types of shapes
and print characteristics of each shape on console.
1. Add new code to method main() in class Main_1:
2. Create array (Shape[] arr) of different Shape objects, (five rectangles, two circles and two triangles);
3. Add code to iterate over shapes array in loop (use for-each loop) and print characteristics of each shape on
console (using toString() method) with area of this shape (using calcArea() method).
4. Execute the program, output must looks like:
This is Rectangle, color: RED, width=11, height=22, area is: 242
This is Triangle, color: BLACK, a=5, b=5, c=5, area is: 10.825
This is Circle, color: GREEN, radius=10, area is: 314.15926 …
5. Add code to calculate total area of all shape types. Define sumArea (of double type) local variable
and use it in loop to sum total area for all shapes.
6. Add code to sum total area for each shape types.
Define sumRectArea, sumTriangleArea, sumCircleArea (of double type) local variables
and use it in loop to sum total area for each shape type. You should use instanceof keyword for determining,
total area for each of shape types (Rectangle, Circle, Triangle) and print it to console.
7. Execute the program, output must looks like:
Rectangles total area: 234.54
Circle total area: 547.231
Triangle total area: 356.56*/
public class Main {
static double sumArea=0, sumRectArea=0, sumTriangleArea=0, sumCircleArea=0;
static Random random = new Random();
public static void main(String[] args) {
Shape[] shapes = new Shape[random.nextInt(10)+3];
setArrayRandomShapes(shapes);
printArrayShapes(shapes);
calcTotalArea(shapes);
printTotalArea();
}
public static void setArrayRandomShapes(Shape[] shapes){
int a;
for (int i=0; i<shapes.length; i++) {
a = random.nextInt(3);
switch (a){
case 0: shapes[i] = Triangle.getRandomTriangle(); break;
case 1: shapes[i] = Rectangle.getRandomRectangle(); break;
case 2: shapes[i] = Circle.getRandomCircle(); break;
}
}
}
public static void printArrayShapes(Shape[] shapes){
for (Shape shape : shapes) {
System.out.print(shape);
System.out.printf(", area is: %.2f\n",shape.calcArea());
}
}
public static void calcTotalArea(Shape[] shapes){
double area;
for (int i = 0; i < shapes.length; i++){
area = shapes[i].calcArea();
sumArea+=area;
if (shapes[i] instanceof Rectangle) sumRectArea+=area;
if (shapes[i] instanceof Triangle) sumTriangleArea+=area;
if (shapes[i] instanceof Circle) sumCircleArea+=area;
}
}
public static void printTotalArea(){
System.out.printf("Rectangles total area: %.2f\n", sumRectArea);
System.out.printf("Circle total area: %.3f\n", sumCircleArea);
System.out.printf("Triangle total area: %.2f\n", sumTriangleArea);
System.out.printf("Total area of all shape types = %.2f\n", sumArea);
}
}
| [
"telec159"
] | telec159 |
e32d3c9de4bf5c69ea00b95214cab867199761d1 | 17feef48b5aee29c2c270b4253f909c3737c6a38 | /Difficulty 1.5/Apaxian Parent/ApaxianParent.java | f624f8426868f52b2c565f715915ec76b4b087bb | [] | no_license | ngzhaoming/Kattis | 7e321ab43ad7fc5569e0281010d907978641be59 | c765ec73a09b4084d715af7dcac3697d51a0d051 | refs/heads/master | 2022-07-13T11:44:23.125354 | 2022-06-24T06:48:55 | 2022-06-24T06:48:55 | 226,272,370 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 818 | java | import java.util.Scanner;
public class ApaxianParent {
public static void main (String [] args) {
Scanner sc = new Scanner(System.in);
String child = sc.next();
String parent = sc.next();
String lastChar = child.substring(child.length() - 1);
if (lastChar.equals("e")) {
System.out.println(child + "x" + parent);
} else if (lastChar.equals("a") || lastChar.equals("i") || lastChar.equals("o") || lastChar.equals("u")) {
child = child.substring(0, child.length() - 1);
System.out.println(child + "ex" + parent);
} else if (child.substring(child.length() - 2).equals("ex")) {
System.out.println(child + parent);
} else {
System.out.println(child + "ex" + parent);
}
}
}
| [
"ngzhaoming@gmail.com"
] | ngzhaoming@gmail.com |
80c7fe34950ca9ba9a694c7961af82e86fa7de12 | 355a684ea008c7f925e4a2d6435fa16261f46dc9 | /src/main/java/org/capgemini/aarogyaNiketan/Repository/HospitalRepository.java | 94a3acef82370ef526ea000c1a0d7c57921a7fd7 | [] | no_license | karthickVellingiri96/aarogyanikrtan | 9dda8927552708b48ee05fc8ff6c8c8ede982d41 | 04ca7ed4a39e25fc1954d60d2843d8fb23b8e757 | refs/heads/master | 2023-07-04T04:01:00.990032 | 2021-08-07T18:23:31 | 2021-08-07T18:23:31 | 391,368,447 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 424 | java | package org.capgemini.aarogyaNiketan.Repository;
import org.capgemini.aarogyaNiketan.model.Hospital;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface HospitalRepository extends JpaRepository<Hospital, Long>{
List<Hospital> findAllByUserId(Long userId);
List<Hospital> findAllByLocation(String location);
Hospital findByIdAndUserId(Long id, Long userId);
}
| [
"v.karthick.v@welab.co"
] | v.karthick.v@welab.co |
0fab80d480c4a72c0d0ec3e905d6d60728b396db | 5fa48a0da4bb139dd859c11c255114ef6872ba76 | /alipaysdk/src/main/java/com/alipay/api/response/AlipayMarketingCampaignActivityOfflineCreateResponse.java | 91b20132cffc679a4a58c263e4db8331fa967c5d | [] | no_license | zhangzui/alipay_sdk | 0b6c4ff198fc5c1249ff93b4d26245405015f70f | e86b338364b24f554e73a6be430265799765581c | refs/heads/master | 2020-03-22T17:43:26.553694 | 2018-07-11T10:28:33 | 2018-07-11T10:28:33 | 140,411,652 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 860 | java | package com.alipay.api.response;
import com.alipay.api.internal.mapping.ApiField;
import com.alipay.api.AlipayResponse;
/**
* ALIPAY API: alipay.marketing.campaign.activity.offline.create response.
*
* @author auto create
* @since 1.0, 2017-04-07 18:22:19
*/
public class AlipayMarketingCampaignActivityOfflineCreateResponse extends AlipayResponse {
private static final long serialVersionUID = 2473957256426715897L;
/**
* 创建成功的活动id
*/
@ApiField("camp_id")
private String campId;
/**
* 创建成功的券模版id
*/
@ApiField("prize_id")
private String prizeId;
public void setCampId(String campId) {
this.campId = campId;
}
public String getCampId( ) {
return this.campId;
}
public void setPrizeId(String prizeId) {
this.prizeId = prizeId;
}
public String getPrizeId( ) {
return this.prizeId;
}
}
| [
"zhangzuizui@qq.com"
] | zhangzuizui@qq.com |
b44032853f79a6cc7b4338acd500a97c079e5a87 | 422e6c9c9b8dd421ff49ae17b2abdef340af6311 | /tao-dal/src/main/java/com/taotao/dao/pojo/TbContentCategory.java | a448ec64fc013fd80cdf465fb1a8ed7a5ef57f34 | [] | no_license | hzf-bye/taotao | 3815df8465762ff6c3b1724da1ac09fe76fb6b84 | 38096343579e3859eaae4f139faa34e9605fe944 | refs/heads/master | 2021-05-11T10:33:30.872885 | 2018-01-19T09:34:14 | 2018-01-19T09:34:14 | 117,617,091 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,482 | java | package com.taotao.dao.pojo;
import java.util.Date;
public class TbContentCategory {
private Long id;
private Long parentId;
private String name;
private Integer status;
private Integer sortOrder;
private Boolean isParent;
private Date created;
private Date updated;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getSortOrder() {
return sortOrder;
}
public void setSortOrder(Integer sortOrder) {
this.sortOrder = sortOrder;
}
public Boolean getIsParent() {
return isParent;
}
public void setIsParent(Boolean isParent) {
this.isParent = isParent;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getUpdated() {
return updated;
}
public void setUpdated(Date updated) {
this.updated = updated;
}
} | [
"1206124189@qq.com"
] | 1206124189@qq.com |
49f5a32157a479dd39ddd3b7585a47dcb1e3a4ed | a30cc3e4e9471ef63d35a7c40cc9fa36b0c61d62 | /app/src/main/java/com/example/unittestingdemo/di/ViewModelFactoryModule.java | 069b9006043ae4f80e36169a5301fa20676ffa81 | [] | no_license | sayedseu/Unit-Testing-Demo | 204a30856314975239651ffe576975bd1bfca203 | b53f90432bd1891213210c7129283651bae673d5 | refs/heads/master | 2022-08-01T11:18:55.501909 | 2020-05-15T08:51:36 | 2020-05-15T08:51:36 | 264,144,155 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 296 | java | package com.example.unittestingdemo.di;
import androidx.lifecycle.ViewModelProvider;
import dagger.Binds;
import dagger.Module;
@Module
public abstract class ViewModelFactoryModule {
@Binds
public abstract ViewModelProvider.Factory factory(ViewModelProviderFactory providerFactory);
}
| [
"sayedhasanseu@gmail.com"
] | sayedhasanseu@gmail.com |
c23426d35800307f6ef18f48e2d2e6edd5dc2905 | 947774cbc17848015482005589898e16d103bea0 | /3. Dynamic Programing/Time and space complexity/Quick Sort.java | d66fe6628e7b8f47422bcb1efa8e7430d32b2bd8 | [] | no_license | gouravmadhan/Programming-Level-1 | e5b56992724bc0a0ef17b757987412b2dcac1ced | 55cd2088e279decd91622820f729f43450764f1c | refs/heads/main | 2023-01-14T04:56:48.630086 | 2020-11-22T15:55:13 | 2020-11-22T15:55:13 | 308,861,414 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,479 | java | // 1. You are given an array(arr) of integers.
// 2. You have to sort the given array in increasing order using quick-sort.
import java.io.*;
import java.util.*;
public class Main {
public static void quickSort(int[] arr, int lo, int hi) {
//write your code here
if(lo>hi)
return;
int pivot = arr[hi];
int pi = partition(arr,pivot,lo,hi);
quickSort(arr,lo,pi-1);
quickSort(arr,pi+1,hi);
}
public static int partition(int[] arr, int pivot, int lo, int hi) {
System.out.println("pivot -> " + pivot);
int i = lo, j = lo;
while (i <= hi) {
if (arr[i] <= pivot) {
swap(arr, i, j);
i++;
j++;
} else {
i++;
}
}
System.out.println("pivot index -> " + (j - 1));
return (j - 1);
}
// used for swapping ith and jth elements of array
public static void swap(int[] arr, int i, int j) {
System.out.println("Swapping " + arr[i] + " and " + arr[j]);
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
public static void print(int[] arr) {
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + " ");
}
System.out.println();
}
public static void main(String[] args) throws Exception {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = scn.nextInt();
}
quickSort(arr, 0, arr.length - 1);
print(arr);
}
} | [
"gouravmadhan411@gmail.com"
] | gouravmadhan411@gmail.com |
7c6c336db1dec6d35f033914365551948e3d83c5 | 9343bb6a442bbb0ce98c11709eeb9f4c7acf9bc2 | /src/main/java/com/ssau/best1team/pizzadelivering/pizzadeliveringmanagement/controllers/PaymentMethodController.java | 736a7416606ead560bfe0b2225f79b99755857cf | [] | no_license | MegaOmegaAlpha/Pizza_Delivery | 97540d9fed5df30c7a2adc3e49c9d78c31beaad7 | e2c209630e4d17035af96fd280562f88e588e4cd | refs/heads/master | 2023-02-04T04:47:21.282339 | 2020-12-25T19:25:31 | 2020-12-25T19:25:31 | 295,637,666 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 881 | java | package com.ssau.best1team.pizzadelivering.pizzadeliveringmanagement.controllers;
import com.ssau.best1team.pizzadelivering.pizzadeliveringmanagement.dto.PaymentMethodDTO;
import com.ssau.best1team.pizzadelivering.pizzadeliveringmanagement.services.PaymentMethodService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/api")
@CrossOrigin(origins = "http://localhost:4200")
public class PaymentMethodController {
private PaymentMethodService paymentMethodService;
@GetMapping(value = "/customer/payment-methods")
public List<PaymentMethodDTO> findAll() {
return paymentMethodService.findAll();
}
}
| [
"bajjramov.vladimir@gmail.com"
] | bajjramov.vladimir@gmail.com |
dfa249cd653d6c6d035560ae266b50735a00bf53 | 0730753b531d1682e939ac1375c1febb38360cc9 | /plugin/securityGroup/src/main/java/org/zstack/network/securitygroup/APIAddVmNicToSecurityGroupMsg.java | 0f10c9836f67675555a5a32d0a300a67468be6b1 | [
"Apache-2.0"
] | permissive | SoftwareKing/zstack | 6f18d0df1370641b062920f993d532a6536be69a | 4d0109f0312496e03dc7296d061838c537c1f4e3 | refs/heads/master | 2021-01-18T17:36:05.864815 | 2015-04-21T02:14:19 | 2015-04-21T02:14:19 | 34,370,895 | 1 | 0 | null | 2015-04-22T05:33:00 | 2015-04-22T05:33:00 | null | UTF-8 | Java | false | false | 1,758 | java | package org.zstack.network.securitygroup;
import org.zstack.header.message.APIMessage;
import org.zstack.header.message.APIParam;
import java.util.List;
/**
* @api
* add vm nic to a security group
*
* @category security group
*
* @since 0.1.0
*
* @cli
*
* @httpMsg
* {
"org.zstack.network.securitygroup.APIAddVmNicToSecurityGroupMsg": {
"securityGroupUuid": "3904b4837f0c4f539063777ed463b648",
"vmNicUuids": [
"e93a0d92a37c4be7b26a6e565f24b063"
],
"session": {
"uuid": "47bd38c2233d469db97930ab8c71e699"
}
}
}
*
* @msg
* {
"org.zstack.network.securitygroup.APIAddVmNicToSecurityGroupMsg": {
"securityGroupUuid": "3904b4837f0c4f539063777ed463b648",
"vmNicUuids": [
"e93a0d92a37c4be7b26a6e565f24b063"
],
"session": {
"uuid": "47bd38c2233d469db97930ab8c71e699"
},
"timeout": 1800000,
"id": "61f68cba51f8466893194a5af7801ab3",
"serviceId": "api.portal"
}
}
*
* @result
*
* see :ref:`APIAddVmNicToSecurityGroupEvent`
*/
public class APIAddVmNicToSecurityGroupMsg extends APIMessage {
/**
* @desc security group uuid
*/
@APIParam(resourceType = SecurityGroupVO.class)
private String securityGroupUuid;
/**
* @desc a list of vm nic uuid. See :ref:`VmNicInventory`
*/
@APIParam(nonempty = true)
private List<String> vmNicUuids;
public String getSecurityGroupUuid() {
return securityGroupUuid;
}
public List<String> getVmNicUuids() {
return vmNicUuids;
}
public void setVmNicUuids(List<String> vmNicUuids) {
this.vmNicUuids = vmNicUuids;
}
public void setSecurityGroupUuid(String securityGroupUuid) {
this.securityGroupUuid = securityGroupUuid;
}
}
| [
"xing5820@gmail.com"
] | xing5820@gmail.com |
99c188663d4b1f230d9b565a64012e3996f12a01 | acbe12fdc29235605b0113fec01d2124e237250c | /src/com/api/java/nikhil/weatherapp/CurrentWeather.java | 907c9989ab592b76a283d264d8e90b7c71958923 | [] | no_license | nikhilrajr/WeatherAPP | 9e25cd7f8203ff11df1d9fc3ba6ab4f809fc781f | 0218ae796f3f98a97d99435837013774fcab7604 | refs/heads/master | 2021-01-20T15:53:29.145304 | 2016-06-29T05:38:32 | 2016-06-29T05:38:32 | 62,198,614 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,162 | java |
package com.api.java.nikhil.weatherapp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
public class CurrentWeather {
private static final String JSON_RESPONSE_CODE = "cod";
private static final String JSON_CITY_ID = "id";
private static final String JSON_CITY_NAME = "name";
static final String JSON_COORD = "coord";
static final String JSON_MAIN = "main";
private static final String JSON_WEATHER = "weather";
private static final String JSON_DATE_TIME = "dt";
private final int responseCode;
private final String rawResponse;
private final long cityId;
private final String cityName;
private final Coord coord;
private final Main main;
private final Date dateTime;
private final int weatherCount;
private final List<Weather> weatherList;
public CurrentWeather(JSONObject jsonObj) {
this.cityId = (jsonObj != null) ? jsonObj.optLong(JSON_CITY_ID, Long.MIN_VALUE) : Long.MIN_VALUE;
this.cityName = (jsonObj != null) ? jsonObj.optString(JSON_CITY_NAME, null) : null;
this.rawResponse = (jsonObj != null) ? jsonObj.toString() : null;
this.responseCode = (jsonObj != null) ? jsonObj.optInt(JSON_RESPONSE_CODE, Integer.MIN_VALUE) : Integer.MIN_VALUE;
JSONObject coordObj = (jsonObj != null) ? jsonObj.optJSONObject(JSON_COORD) : null;
this.coord = (coordObj != null) ? new Coord(coordObj) : null;
JSONObject mainObj = (jsonObj != null) ? jsonObj.optJSONObject(JSON_MAIN) : null;
this.main = (mainObj != null) ? new Main(mainObj) : null;
long sec = (jsonObj != null) ? jsonObj.optLong(JSON_DATE_TIME, Long.MIN_VALUE) : Long.MIN_VALUE;
if (sec != Long.MIN_VALUE) { // converting seconds to Date object
this.dateTime = new Date(sec * 1000);
} else {
this.dateTime = null;
}
JSONArray weatherArray = (jsonObj != null) ? jsonObj.optJSONArray(JSON_WEATHER) : new JSONArray();
if(weatherArray != null)
this.weatherList = new ArrayList<Weather>(weatherArray.length());
else
this.weatherList = null;
if (weatherArray != null && this.weatherList != Collections.EMPTY_LIST) {
for (int i = 0; i < weatherArray.length(); i++) {
JSONObject weatherObj = weatherArray.optJSONObject(i);
if (weatherObj != null) {
this.weatherList.add(new Weather(weatherObj));
}
}
}
this.weatherCount = this.weatherList.size();
}
public boolean isValid() {
return this.responseCode == 200;
}
public boolean hasResponseCode() {
return this.responseCode != Integer.MIN_VALUE;
}
public boolean hasRawResponse() {
return this.rawResponse != null;
}
public boolean hasCityCode() {
return this.cityId != Long.MIN_VALUE;
}
public boolean hasCityName() {
return this.cityName != null && (! "".equals(this.cityName));
}
public boolean hasCoordInstance() {
return coord != null;
}
public boolean hasMainInstance() {
return main != null;
}
public boolean hasDateTime() {
return this.dateTime != null;
}
public boolean hasWeatherInstance() {
return weatherCount != 0;
}
public int getResponseCode() {
return this.responseCode;
}
public String getRawResponse() {
return this.rawResponse;
}
public Date getDateTime() {
return this.dateTime;
}
public int getWeatherCount() {
return this.weatherCount;
}
public Weather getWeatherInstance(int index) {
return this.weatherList.get(index);
}
public long getCityCode() {
return this.cityId;
}
public String getCityName() {
return this.cityName;
}
public Coord getCoordInstance() {
return this.coord;
}
public Main getMainInstance() {
return this.main;
}
} | [
"nikhilrajr90@gmail.com"
] | nikhilrajr90@gmail.com |
51d0a10c5eb2f29285e78f9e962361baff030999 | 7f31f0f3314aefe3f527b694c9cdaeba7c83c147 | /app/src/main/java/maks/radioproject/NotificationService.java | cebe05edfe301a043cc067d64498563b0945fb72 | [] | no_license | Maks365/RadioProject | 508b6ee44a78ba779650a1b8fcacecde856a9a3b | 11d5169795aa82cab28ea4c1803a73936ce8cfe0 | refs/heads/master | 2016-08-12T17:42:21.859050 | 2015-12-06T09:58:38 | 2015-12-06T09:58:38 | 47,491,405 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,296 | java | package maks.radioproject;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.os.IBinder;
import android.app.Service;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
import android.app.Notification;
import android.app.PendingIntent;
import android.view.View;
import android.widget.RemoteViews;
import java.io.IOException;
public class NotificationService extends Service implements OnPreparedListener, OnCompletionListener {
final String DATA_STREAM = "http://sportfm32.streamr.ru";
MediaPlayer mediaPlayer = new MediaPlayer();
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent.getAction().equals(Constants.ACTION.STARTFOREGROUND_ACTION)) {
// showNotification();
// Toast.makeText(this, "Service Started", Toast.LENGTH_SHORT).show();
releaseMP();
try {
mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(DATA_STREAM);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
Log.d(LOG_TAG, "prepareAsync");
mediaPlayer.setOnPreparedListener(this);
mediaPlayer.prepareAsync();
} catch (Exception e) {
e.printStackTrace();
}
mediaPlayer.setOnCompletionListener(this);
} else if (intent.getAction().equals(Constants.ACTION.PLAY_ACTION)) {
Toast.makeText(this, "Clicked Play", Toast.LENGTH_SHORT).show();
Log.i(LOG_TAG, "Clicked Play");
mediaPauseResume();
} else if (intent.getAction().equals(
Constants.ACTION.STOPFOREGROUND_ACTION)) {
Log.i(LOG_TAG, "Received Stop Foreground Intent");
Toast.makeText(this, "Service Stoped", Toast.LENGTH_SHORT).show();
mediaStop();
stopForeground(true);
stopSelf();
}
return START_STICKY;
}
Notification status;
private final String LOG_TAG = "NotificationService";
private void showNotification() {
// Using RemoteViews to bind custom layouts into Notification
RemoteViews views = new RemoteViews(getPackageName(),
R.layout.status_bar);
RemoteViews bigViews = new RemoteViews(getPackageName(),
R.layout.status_bar_expanded);
// showing default album image
views.setViewVisibility(R.id.status_bar_icon, View.VISIBLE);
views.setViewVisibility(R.id.status_bar_album_art, View.GONE);
bigViews.setImageViewBitmap(R.id.status_bar_album_art,
Constants.getDefaultAlbumArt(this));
Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.setAction(Constants.ACTION.MAIN_ACTION);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);
Intent playIntent = new Intent(this, NotificationService.class);
playIntent.setAction(Constants.ACTION.PLAY_ACTION);
PendingIntent pplayIntent = PendingIntent.getService(this, 0,
playIntent, 0);
Intent closeIntent = new Intent(this, NotificationService.class);
closeIntent.setAction(Constants.ACTION.STOPFOREGROUND_ACTION);
PendingIntent pcloseIntent = PendingIntent.getService(this, 0,
closeIntent, 0);
views.setOnClickPendingIntent(R.id.status_bar_play, pplayIntent);
bigViews.setOnClickPendingIntent(R.id.status_bar_play, pplayIntent);
views.setOnClickPendingIntent(R.id.status_bar_collapse, pcloseIntent);
bigViews.setOnClickPendingIntent(R.id.status_bar_collapse, pcloseIntent);
views.setImageViewResource(R.id.status_bar_play,
R.drawable.apollo_holo_dark_pause);
bigViews.setImageViewResource(R.id.status_bar_play,
R.drawable.apollo_holo_dark_pause);
views.setTextViewText(R.id.status_bar_track_name, "Song Title");
bigViews.setTextViewText(R.id.status_bar_track_name, "Song Title");
views.setTextViewText(R.id.status_bar_artist_name, "Artist Name");
bigViews.setTextViewText(R.id.status_bar_artist_name, "Artist Name");
bigViews.setTextViewText(R.id.status_bar_album_name, "Album Name");
status = new Notification.Builder(this).build();
status.contentView = views;
status.bigContentView = bigViews;
status.flags = Notification.FLAG_ONGOING_EVENT;
status.icon = R.mipmap.ic_launcher;
status.contentIntent = pendingIntent;
startForeground(Constants.NOTIFICATION_ID.FOREGROUND_SERVICE, status);
}
public void onMediaStart(View view) {
releaseMP();
try {
Log.d(LOG_TAG, "start Stream");
mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(DATA_STREAM);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
Log.d(LOG_TAG, "prepareAsync");
mediaPlayer.setOnPreparedListener(this);
mediaPlayer.prepareAsync();
} catch (IOException e) {
e.printStackTrace();
}
if (mediaPlayer == null) {
return;
}
mediaPlayer.setOnCompletionListener(this);
}
private void releaseMP() {
if (mediaPlayer != null) {
try {
mediaPlayer.release();
mediaPlayer = null;
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void mediaPauseResume() {
if (mediaPlayer != null) {
if (mediaPlayer.isPlaying()) {
status.contentView.setImageViewResource(R.id.status_bar_play,
R.drawable.apollo_holo_dark_play);
status.bigContentView.setImageViewResource(R.id.status_bar_play,
R.drawable.apollo_holo_dark_play);
mediaPlayer.pause();
// Log.d("TAG",s);
} else {
status.contentView.setImageViewResource(R.id.status_bar_play,
R.drawable.apollo_holo_dark_pause);
status.bigContentView.setImageViewResource(R.id.status_bar_play,
R.drawable.apollo_holo_dark_pause);
mediaPlayer.start();
}
startForeground(Constants.NOTIFICATION_ID.FOREGROUND_SERVICE, status);
}
}
private void mediaStop() {
if (mediaPlayer != null) {
mediaPlayer.stop();
}
}
@Override
public void onPrepared(MediaPlayer mp) {
showNotification();
Log.d(LOG_TAG, "onPrepared");
mp.start();
}
@Override
public void onCompletion(MediaPlayer mp) {
Log.d(LOG_TAG, "onCompletion");
}
}
| [
"max@365scores.com"
] | max@365scores.com |
90d722119a5c5bf958e48d26bc842900eda2fc42 | fccd407dbab92eab5dac914fb3338ebba7b6bed3 | /brickbreaker/src/models/modelsimp/bricks.java | 925769a08d119fa14d4327a574aa574a2daa84e1 | [] | no_license | DiaeTribak/DHH-Bb | 15bd5e704f80a27ed71da85507155e91e505dccf | d296b02e2cb6c091da052cfa0b66c8a1261d842a | refs/heads/main | 2023-02-23T17:23:27.679792 | 2021-01-29T10:14:32 | 2021-01-29T10:14:32 | 324,789,075 | 1 | 0 | null | 2021-01-07T22:48:11 | 2020-12-27T15:20:08 | null | UTF-8 | Java | false | false | 426 | java | package models.modelsimp;
public class bricks { ;
private String value;
;
public bricks(String value) {
this.value = value;
}
public boolean isSet() {
return this.value.length()>0;
}
public String toString() {
if(isSet()){
return this.value;
}else {
return "___";
}
}
public String getValue() {
return value;
}
}
| [
"66046303+Dodo879@users.noreply.github.com"
] | 66046303+Dodo879@users.noreply.github.com |
66e675b6350af1886f8044d622911c93742e8928 | 76e9c45c1855590ca0eb390a1fb562c92054aa98 | /src/main/java/com/acko/apiservice/resource/CustomerResource.java | 7e34f704e9cfb39849d0aa0497f2e1a61b81328f | [] | no_license | cptekam/acko-back-end | e5f934ebe99fd726962ec3e5708a3e8f81377a21 | 0fedb3bd2f20b18c4caae87f1fdb18a3d00941ef | refs/heads/master | 2022-12-12T10:02:00.901935 | 2020-08-25T05:15:13 | 2020-08-25T05:15:13 | 290,117,376 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,067 | java | package com.acko.apiservice.resource;
import com.acko.apiservice.model.CustomerHistory;
import com.acko.apiservice.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/customer")
public class CustomerResource {
@Autowired
CustomerService customerService;
@CrossOrigin(origins = "http://localhost:4200")
@GetMapping("/history/{phoneNumber}")
public ResponseEntity<?> getCustomerHistory(@PathVariable Long phoneNumber) {
List<CustomerHistory> histories = customerService.getCustomerHistory(phoneNumber);
return ResponseEntity.ok()
.body(histories);
}
}
| [
"tekamchandraprakash@gmail.com"
] | tekamchandraprakash@gmail.com |
eac6c1b661264a4b30c7adf6e29cb513138b6901 | a94d20a6346d219c84cc97c9f7913f1ce6aba0f8 | /mottak/web/webapp/src/main/java/no/nav/foreldrepenger/fordel/web/app/metrics/InntektsmeldingCache.java | b53e23467c06b9030b78b37276d180006b43ef8d | [
"MIT"
] | permissive | junnae/spsak | 3c8a155a1bf24c30aec1f2a3470289538c9de086 | ede4770de33bd896d62225a9617b713878d1efa5 | refs/heads/master | 2020-09-11T01:56:53.748986 | 2019-02-06T08:14:42 | 2019-02-06T08:14:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,202 | java | package no.nav.foreldrepenger.fordel.web.app.metrics;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import no.nav.foreldrepenger.fordel.kodeverk.DokumentTypeId;
import no.nav.foreldrepenger.fordel.kodeverk.Fagsystem;
import no.nav.foreldrepenger.mottak.domene.oppgavebehandling.OpprettGSakOppgaveTask;
import no.nav.foreldrepenger.mottak.task.KlargjorForVLTask;
import no.nav.vedtak.util.FPDateUtil;
@ApplicationScoped
public class InntektsmeldingCache {
private MetricRepository metricRepository;
private static final long MAX_DATA_ALDER_MS = 10000;
private Map<String, Long> total;
private Map<String, Long> dagens;
private Map<Fagsystem, String> taskNames;
private long antallLestTidspunktMs = 0;
InntektsmeldingCache() {
// for CDI proxy
}
@Inject
public InntektsmeldingCache(MetricRepository metricRepository) {
this.metricRepository = metricRepository;
this.total = new HashMap<>();
this.dagens = new HashMap<>();
this.taskNames = new HashMap<>();
taskNames.put(Fagsystem.GOSYS, OpprettGSakOppgaveTask.TASKNAME);
taskNames.put(Fagsystem.FPSAK, KlargjorForVLTask.TASKNAME);
}
public Long hentInntektsMeldingerSendtTilSystem(Fagsystem fagsystem, LocalDate dag) {
refreshDataIfNeeded();
String task = taskNames.get(fagsystem);
return dag == null ? total.getOrDefault(task, 0l) : dagens.getOrDefault(task, 0l);
}
private void refreshDataIfNeeded() {
long naaMs = System.currentTimeMillis();
long alderMs = naaMs - antallLestTidspunktMs;
if (alderMs >= MAX_DATA_ALDER_MS) {
for (String task : taskNames.values()) {
dagens.put(task, metricRepository.tellAntallDokumentTypeIdForTaskType(task, DokumentTypeId.INNTEKTSMELDING.getKode(), FPDateUtil.iDag()));
total.put(task, metricRepository.tellAntallDokumentTypeIdForTaskType(task, DokumentTypeId.INNTEKTSMELDING.getKode(), null));
}
antallLestTidspunktMs = System.currentTimeMillis();
}
}
}
| [
"roy.andre.gundersen@nav.no"
] | roy.andre.gundersen@nav.no |
b27e9f126d0b03d6bf7a77700df86e871619249f | 035e766f7c80574f840b18b8894b06315c23145e | /src/com/blinov/itymchuk/four/learn/animal/Dog.java | cedfd1c4127a39b0ec41aec6281a1537d9be018e | [] | no_license | ihor-tymchuk/Java_exercises | 1a7cd1062621a778a30da67e61777c3a86cd7cb3 | d53388f3bb2aaa7844f3d00ee2a9ac7474ba3a29 | refs/heads/master | 2023-06-03T18:13:38.841040 | 2021-06-22T17:59:57 | 2021-06-22T17:59:57 | 372,766,945 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 172 | java | package com.blinov.itymchuk.four.learn.animal;
public class Dog extends Animal{
@Override
public void introduce() {
System.out.println("I'm Dog");
}
}
| [
"igortym777@gmail.com"
] | igortym777@gmail.com |
6b588ef47f2d313fba6c0a395be28d8cc7f05417 | f6c298da782773d4ca9dc8a56629f5a9bdb4c16d | /spring-cloud-service-customer-feign-refactor/src/main/java/org/my/spring/cloud/service/customer/feign/service/IRefactorHelloService.java | 185bb99eee523a6a1951f812ba31882f0add6caa | [] | no_license | yongxing510/spring-cloud | 28a50c489d94e1e120bfd363251c7c86c8efc257 | de270b75e6652b4f249ee6b6d3bf185fe70c9c27 | refs/heads/master | 2021-04-15T10:04:53.515431 | 2017-12-05T09:11:38 | 2017-12-05T09:11:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 537 | java | package org.my.spring.cloud.service.customer.feign.service;
import org.my.spring.cloud.refactor.service.IHelloService;
import org.my.spring.cloud.service.customer.feign.service.hystrix.HelloServiceFallBack;
import org.springframework.cloud.netflix.feign.FeignClient;
/**
*
*
* 消费者注入该接口
*
* @author ShuaishuaiXiao
*
*/
@FeignClient(value = "spring-cloud-service-provider-refactor", fallback = HelloServiceFallBack.class) // 大小写不敏感
public interface IRefactorHelloService extends IHelloService {
}
| [
"xstojob@gamil.com"
] | xstojob@gamil.com |
01d0907445bc048a9559968e203404752e7a5a52 | a579e4f80d2974cd2b8ecd8c5a5385c536e7cce3 | /threeTeach/threeminutestoteach/src/main/java/com/min/threeminutestoteach/listener/OnGetAnswerDetailFinishListener.java | ee8edc30fd350ea1559a5bcba72d70059af1655d | [] | no_license | ljh-dobest/association-android | b880d36327b656ee760f8a3da70e1437f697b14d | 6bed2ac52e3253a98d6f79d47d9879b046ba8068 | refs/heads/master | 2021-06-19T05:20:57.455980 | 2017-07-19T11:04:39 | 2017-07-19T11:04:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 347 | java | package com.min.threeminutestoteach.listener;
import com.min.threeminutestoteach.bean.ArticleCommentBean;
/**
* Created by Min on 2017/4/6.
*/
public interface OnGetAnswerDetailFinishListener {
void showError(String errorString);
void returnAnswerDetail(ArticleCommentBean articleComment);
void showSucceedComment(String msg);
}
| [
"710601912@qq.com"
] | 710601912@qq.com |
1e0922d8c3936a7944741faf7e8f45ad0d7ea0b9 | 6033c480307fc419522ca965d0fa3bad28ae35e7 | /sejda-model/src/main/java/org/sejda/model/exception/TaskException.java | 928d785595fd529ee1f8acb6d9caa3724236a165 | [
"Apache-2.0"
] | permissive | bradparks/sejda__pdf_cli_command_line_merge_split | 96cac41f9a48c6cb00551b41d551d325ab6291c4 | 768e2df33ba0976041ad3d64e4eb374a9d8c0e12 | refs/heads/master | 2021-01-17T21:06:09.933222 | 2015-03-27T20:18:43 | 2015-03-27T20:18:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,188 | java | /*
* Created on 12/mag/2010
*
* Copyright 2010 by Andrea Vacondio (andrea.vacondio@gmail.com).
*
* 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 org.sejda.model.exception;
/**
* General task exception
* @author Andrea Vacondio
*
*/
public class TaskException extends Exception {
private static final long serialVersionUID = -1829569805895216058L;
public TaskException() {
super();
}
public TaskException(String message, Throwable cause) {
super(message, cause);
}
public TaskException(String message) {
super(message);
}
public TaskException(Throwable cause) {
super(cause);
}
}
| [
"andrea.vacondio@gmail.com"
] | andrea.vacondio@gmail.com |
7bca23eda0ced434b584f2f2b5056bf29f9120ee | f6055fcf828781c7dfa7fcd4f978a210b8ef32d2 | /kodilla-jdbc/src/test/java/com/kodilla/jdbc/DbManagerTestSuite.java | 5972b8ef2297969adb9b20667ef3938a2c97473b | [] | no_license | nowy513/Task-module | 99b64e549a0657096f9bb33dc62354b80201cf5e | 14f72c0425eeb628db3d89fc524f027860234d6d | refs/heads/master | 2023-06-19T16:15:30.052993 | 2021-07-13T09:18:32 | 2021-07-13T09:18:32 | 330,603,988 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,967 | java | package com.kodilla.jdbc;
import org.junit.Assert;
import org.junit.Test;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class DbManagerTestSuite {
@Test
public void testConnection() throws SQLException {
//Given
//when
DbManager dbManager = DbManager.getInstance();
//then
Assert.assertNotNull(dbManager);
}
@Test
public void testSelectedUsers() throws SQLException {
//Given
DbManager dbManager = DbManager.getInstance();
//when
String sqlQuerry = "SELECT * FROM USERS";
Statement statement = dbManager.getConnection().createStatement();
ResultSet rs = statement.executeQuery(sqlQuerry);
//Then
int counter = 0;
while (rs.next()) {
System.out.println(rs.getInt("ID") + "," + rs.getString("FIRSTNAME") + "," + rs.getString("LASTNAME"));
counter++;
}
rs.close();
statement.close();
Assert.assertEquals(5, counter);
}
@Test
public void testSelectUsersAndPosts() throws SQLException {
// Given
DbManager dbManager = DbManager.getInstance();
// When
String sqlQuery = "SELECT U.ID, U.FIRSTNAME, U.LASTNAME, COUNT(*) AS POSTS_NUMBER\n" +
"FROM POSTS P\n" +
"JOIN USERS U ON U.ID = P.USER_ID\n" +
"GROUP BY P.USER_ID\n" +
"HAVING COUNT(*) >= 2;\n";
Statement statement = dbManager.getConnection().createStatement();
ResultSet rs = statement.executeQuery(sqlQuery);
// Then
int counter = 0;
while (rs.next()){
System.out.println(rs.getString("FIRSTNAME") + "," + rs.getString("LASTNAME"));
counter++;
}
rs.close();
statement.close();
assertEquals(1, counter);
}
}
| [
"slawomir.swie@gmail.com"
] | slawomir.swie@gmail.com |
6b2235d4169ecf5b169301f23ee3bfbe97b7713b | 665e00c2335853ab86cc0aa9f2fe1459c2ac1ac7 | /ideaCode/springCloud/spring-cloud-hystrix/hystrix-feign/hystrixFeign-producer/src/main/java/lb/study/hystrixfeign/feignproducer/ServletInitializer.java | 537f4d3ab00e4db88bc1867f5abd2a1d39afa6cc | [] | no_license | 626178241/studyRepository | ddf61d6af797bfa88b3dea1d6ef4b580c18456fd | cd86626659f89a156e0a567469f5a7821f766e28 | refs/heads/master | 2022-07-10T03:51:34.108966 | 2019-05-24T09:50:10 | 2019-05-24T09:50:10 | 179,192,633 | 0 | 0 | null | 2022-06-21T04:08:24 | 2019-04-03T02:12:50 | Java | UTF-8 | Java | false | false | 447 | java | package lb.study.hystrixfeign.feignproducer;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(FeignProducerApplication.class);
}
}
| [
"libo@citycloud.com.cn"
] | libo@citycloud.com.cn |
e4754c562f8f58cd166f8935ccd3bc5393c4415d | 6129f61a656001aefc24463e5ca7da8fed75785a | /src/java/br/com/psystems/crud/command/BuscarFornecedorCommand.java | a64a53af67a0e3e1ee10f07d2f89e9f156db953c | [] | no_license | diegotpereira/Projeto-Web | aabbee15600926e44f55e08acf74b2e3744e413a | f86f38eb4d63be7e55a31fb65d6603bcdef7b724 | refs/heads/master | 2020-09-13T16:41:36.823729 | 2019-11-20T03:48:37 | 2019-11-20T03:48:37 | 222,844,290 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,164 | java | /**
*
*/
package br.com.psystems.crud.command;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import br.com.psystems.crud.base.AbstractCommand;
import br.com.psystems.crud.base.BaseDAO;
import br.com.psystems.crud.dao.FornecedorDAO;
import br.com.psystems.crud.exception.DAOException;
import br.com.psystems.crud.model.Fornecedor;
/**
* @author rafael.saldanha
*
*/
public class BuscarFornecedorCommand extends AbstractCommand {
public BuscarFornecedorCommand(FornecedorDAO dao) {
this.dao = dao;
}
private static final long serialVersionUID = 7606485709102366372L;
private static Logger logger = Logger.getLogger(BuscarFornecedorCommand.class);
private String pagina = PAGE_FORNECEDOR_FORMULARIO;
private BaseDAO<Fornecedor> dao;
@Override
public String execute(HttpServletRequest request) {
try {
Fornecedor fornecedor = dao.findById(getID(request));
setEntity(request, fornecedor);
} catch (DAOException | ServletException e) {
logger.error(e.getMessage());
pagina = PAGE_FORNECEDOR_LISTA;
setException(request, e);
}
return pagina;
}
}
| [
"diegoteixeirapereira@hotmail.com"
] | diegoteixeirapereira@hotmail.com |
c4f1ba321d217538313152cdd829758aec774af1 | bec6e3a136f7bf49eca61d4475656570914dc671 | /pipe2.5/src/pipe/gui/HelpBox.java | 10b57cf42b650d3020d884ac991404a9632e8566 | [] | no_license | shawn47/BeehiveZ3 | 3b6a2cbd4b1274efa98549a571e269aa2057a7bb | 2404b5b3299aaecb08ff449cdefdcbaac594e6ab | refs/heads/master | 2021-01-20T10:10:29.060837 | 2017-05-18T08:07:59 | 2017-05-18T08:07:59 | 90,331,204 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,213 | java | /*
* Created on 07-Mar-2004
*/
package pipe.gui;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.LinkedList;
import javax.swing.ImageIcon;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.border.BevelBorder;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import pipe.gui.action.GuiAction;
import pipe.gui.widgets.ButtonBar;
/**
* @author Maxim
*/
public class HelpBox extends GuiAction implements HyperlinkListener {
private JFrame dialog;
private JEditorPane content;
private LinkedList history = new LinkedList();
private String filename;
public HelpBox(String name, String tooltip, String keystroke,
String filename) {
super(name, tooltip, keystroke);
this.filename = filename;
}
/**
* Sets the page to the given non-absolute filename assumed to be in the
* Docs directory
*/
private void setPage(String filename) {
if (dialog == null) {
dialog = new JFrame("PIPE2 help");
Container contentPane = dialog.getContentPane();
contentPane.setLayout(new BorderLayout(5, 5));
content = new JEditorPane();
content.setEditable(false);
content.setMargin(new Insets(5, 5, 5, 5));
content.setContentType("text/html");
content.addHyperlinkListener(this);
JScrollPane scroller = new JScrollPane(content);
scroller.setBorder(new BevelBorder(BevelBorder.LOWERED));
dialog.setIconImage(((ImageIcon) this.getValue(SMALL_ICON))
.getImage());
scroller.setPreferredSize(new Dimension(400, 400));
contentPane.add(scroller, BorderLayout.CENTER);
contentPane.add(new ButtonBar(new String[] { "Index", "Back" },
new ActionListener[] { this, this }),
BorderLayout.PAGE_START);
dialog.pack();
}
dialog.setLocationRelativeTo(CreateGui.getApp());
dialog.setVisible(true);
try {
setPage(new URL("file://"
+ new File("src" + System.getProperty("file.separator")
+ "Docs" + System.getProperty("file.separator")
+ filename).getAbsolutePath()), true);
} catch (MalformedURLException e) {
System.err.println(e.getMessage());
System.err.println("Error setting page to " + filename);
}
}
private void setPage(URL url, boolean addHistory) {
try {
content.setPage(url);
if (addHistory) {
history.add(url);
}
} catch (IOException e) {
System.err.println("Error setting page to " + url);
}
}
public void actionPerformed(ActionEvent e) {
String s = e.getActionCommand();
if ((s == "Back") && (history.size() > 1)) {
history.removeLast();
setPage((URL) (history.getLast()), false);
} else {
// default and index
setPage(filename);
}
}
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
setPage(e.getURL(), true);
}
}
}
| [
"xiaoyb2010@gmail.com"
] | xiaoyb2010@gmail.com |
e600cf62e423fb26c49896288d6960dfb868ebda | 82a80f757099da7b852bc9dda3acf03aef06639e | /src/main/java/com/nowcoder/community/service/DataService.java | 5d3779d0545891c16d4d08d6ff06ee3a7ea17eb2 | [] | no_license | zhangkunliang/Nowcoder | 38b4b509ebe83ef2fdc04f5102304e48f308af92 | 18cac3ea332a0f09e3ecc8fa0fbbbe36d856f161 | refs/heads/master | 2023-07-25T03:50:41.276208 | 2021-08-21T11:39:16 | 2021-08-21T11:39:16 | 398,542,544 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,308 | java | package com.nowcoder.community.service;
import com.nowcoder.community.util.RedisKeyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisStringCommands;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Service
public class DataService {
@Autowired
private RedisTemplate redisTemplate;
private SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
// 将指定的IP计入UV
public void recordUV(String ip) {
String redisKey = RedisKeyUtil.getUVKey(df.format(new Date()));
redisTemplate.opsForHyperLogLog().add(redisKey, ip);
}
// 统计指定日期范围内的UV
public long calculateUV(Date start, Date end) {
if (start == null || end == null) {
throw new IllegalArgumentException("参数不能为空!");
}
// 整理该日期范围内的key
List<String> keyList = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
calendar.setTime(start);
while (!calendar.getTime().after(end)) {
String key = RedisKeyUtil.getUVKey(df.format(calendar.getTime()));
keyList.add(key);
calendar.add(Calendar.DATE, 1);
}
// 合并这些数据
String redisKey = RedisKeyUtil.getUVKey(df.format(start), df.format(end));
redisTemplate.opsForHyperLogLog().union(redisKey, keyList.toArray());
// 返回统计的结果
return redisTemplate.opsForHyperLogLog().size(redisKey);
}
// 将指定用户计入DAU
public void recordDAU(int userId) {
String redisKey = RedisKeyUtil.getDAUKey(df.format(new Date()));
redisTemplate.opsForValue().setBit(redisKey, userId, true);
}
// 统计指定日期范围内的DAU
public long calculateDAU(Date start, Date end) {
if (start == null || end == null) {
throw new IllegalArgumentException("参数不能为空!");
}
// 整理该日期范围内的key
List<byte[]> keyList = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
calendar.setTime(start);
while (!calendar.getTime().after(end)) {
String key = RedisKeyUtil.getDAUKey(df.format(calendar.getTime()));
keyList.add(key.getBytes());
calendar.add(Calendar.DATE, 1);
}
// 进行OR运算
return (long) redisTemplate.execute(new RedisCallback() {
@Override
public Object doInRedis(RedisConnection connection) throws DataAccessException {
String redisKey = RedisKeyUtil.getDAUKey(df.format(start), df.format(end));
connection.bitOp(RedisStringCommands.BitOperation.OR,
redisKey.getBytes(), keyList.toArray(new byte[0][0]));
return connection.bitCount(redisKey.getBytes());
}
});
}
}
| [
"1005789053@qq.com"
] | 1005789053@qq.com |
ff5a3c50ca1cce3658cdab5d3c36e958b8c89797 | e27942cce249f7d62b7dc8c9b86cd40391c1ddd4 | /modules/dfp_appengine/src/main/java/com/google/api/ads/dfp/jaxws/v201702/ContentBundleServiceInterfacecreateContentBundles.java | 3d90e7b0164cbeded687f947b6eccfb3b178ee60 | [
"Apache-2.0"
] | permissive | mo4ss/googleads-java-lib | b4b6178747d25d16ae6aa0c80d80ee18a2dfe01a | efaa9c3bd8a46a3ed4b00963dc9760c6dd8bd641 | refs/heads/master | 2022-12-05T00:30:56.740813 | 2022-11-16T10:47:15 | 2022-11-16T10:47:15 | 108,132,394 | 0 | 0 | Apache-2.0 | 2022-11-16T10:47:16 | 2017-10-24T13:41:43 | Java | UTF-8 | Java | false | false | 2,929 | java | // Copyright 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.ads.dfp.jaxws.v201702;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
*
* Creates new {@link ContentBundle} objects.
*
* @param contentBundles the content bundles to create
* @return the created content bundles with their IDs filled in
*
*
* <p>Java class for createContentBundles element declaration.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <element name="createContentBundles">
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="contentBundles" type="{https://www.google.com/apis/ads/publisher/v201702}ContentBundle" maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </element>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"contentBundles"
})
@XmlRootElement(name = "createContentBundles")
public class ContentBundleServiceInterfacecreateContentBundles {
protected List<ContentBundle> contentBundles;
/**
* Gets the value of the contentBundles property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the contentBundles property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getContentBundles().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link ContentBundle }
*
*
*/
public List<ContentBundle> getContentBundles() {
if (contentBundles == null) {
contentBundles = new ArrayList<ContentBundle>();
}
return this.contentBundles;
}
}
| [
"api.cseeley@gmail.com"
] | api.cseeley@gmail.com |
36e3c7c38fbf5e840e98c631005937648edff3bd | 1eeba392b623f50c31b47a1e9e29f8044cac9c56 | /lanp/src/main/java/org/pq/esql/map/EsqlCallableResultBeanMapper.java | bce89d6fe7a94632b2347eaa500d8bcfa2e3e8a9 | [] | no_license | smallniu/lanp-all | 11cfe8ca551a42bb83166e375e113fc57a793cfe | 2505ee3e1bfd9df1abc3bc965fee283a12b367d9 | refs/heads/master | 2020-05-18T10:43:05.342465 | 2014-07-21T09:59:58 | 2014-07-21T09:59:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,278 | java | package org.pq.esql.map;
import java.beans.PropertyDescriptor;
import java.sql.CallableStatement;
import java.sql.SQLException;
import org.pq.core.joor.Reflect;
import org.pq.esql.param.EsqlParamPlaceholder;
import org.pq.esql.param.EsqlParamPlaceholder.InOut;
import org.pq.esql.bean.EsqlSub;
public class EsqlCallableResultBeanMapper extends EsqlBaseBeanMapper implements EsqlCallableReturnMapper {
public EsqlCallableResultBeanMapper(Class<?> mappedClass) {
super(mappedClass);
}
@Override
public Object mapResult(EsqlSub subSql, CallableStatement cs) throws SQLException {
Object mappedObject = Reflect.on(this.mappedClass).create().get();
for (int i = 0, ii = subSql.getPlaceHolders().length; i < ii; ++i) {
EsqlParamPlaceholder placeholder = subSql.getPlaceHolders()[i];
if (placeholder.getInOut() != InOut.IN) {
String field = placeholder.getPlaceholder();
PropertyDescriptor pd = this.mappedFields.get(field.toLowerCase());
if (pd != null) {
Object object = cs.getObject(i + 1);
Reflect.on(mappedObject).set(pd.getName(), object);
}
}
}
return mappedObject;
}
}
| [
"agent4pq@gmail.com"
] | agent4pq@gmail.com |
17ff20f7efd1334d417259a0a2279df47409851f | 1ce0a9c4e7fd0b9e45b2216d3efab4a50a6cd3cb | /XMLwork/src/com/gqxing/Main/Menu.java | 360c8136bff06e3f893f8d3da8181611529b1df7 | [] | no_license | GQXING/JavaWebStudy | 373698b2a6d5b40ac1b4448098d52bfc0d094e74 | 2b480caf7bcf526a445f383bd3466a7b523bae23 | refs/heads/master | 2020-07-12T13:18:51.265047 | 2016-11-16T10:14:22 | 2016-11-16T10:14:22 | 73,908,149 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 2,568 | java | package com.gqxing.Main;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Scanner;
import com.gqxing.dao.Operate;
import com.gqxing.entity.Student;
public class Menu {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Operate operate=new Operate();
BufferedReader in =
new BufferedReader(new InputStreamReader(System.in));
//进入菜单部分
while (true) {
//显现菜单
System.out.println("/*********************************************************/");
System.out.println("1、添加到本地学生列表(student.xml)");
System.out.println("2、查看本地所有学生的列表信息(student.xml)");
System.out.println("3、删除指定ID学生的列表信息(student.xml)");
System.out.println("4、退出该查询和添加服务系统");
System.out.println("/*********************************************************/");
int select=Integer.parseInt(in.readLine());
switch (select) {
case 1:
//将学生添加到本地xml文件
Student student=new Student();
System.out.println("请输入学生的姓名:");
String name=in.readLine();
student.setName(name);
System.out.println("请输入学生的ID:");
String id=in.readLine();
student.setID(id);
System.out.println("请输入学生的班级:");
String classString=in.readLine();
student.setClassString(classString);
System.out.println("请输入学生的性别:");
String sex=in.readLine();
student.setSex(sex);
System.out.println("请输入学生的出生年月日");
String birth=in.readLine();
student.setBirth(birth);
System.out.println("请输入学生户籍所在地:");
String city=in.readLine();
student.setCity(city);
System.out.println("请输入学生的手机号码:");
String mobile=in.readLine();
student.setMonile(mobile);
operate.addStudent(student);
break;
case 2:
List<Student> students=operate.getStudents();
for (Student s : students) {
System.out.println(s);
}
break;
case 3:
System.out.println("请输入你要删除的联系人ID:");
String idString=in.readLine();
operate.remove(idString);
case 4:
System.out.println("您已退出本系统!");
System.exit(0);
break;
default:
System.out.println(in);
System.out.println("抱歉,您的输入有问题请重新输入!");
break;
}
}
}
}
| [
"862163475@qq.com"
] | 862163475@qq.com |
5a1d926d9fcbba8460ecfae2fba9ae80c1df138b | 6d402d0430cc332213d5402dbb3f44c96945814b | /src/main/java/org/seqdoop/hadoop_bam/CRAMRecordWriter.java | 580495903c926b63d2941491ca48068e40134e03 | [
"Apache-2.0",
"MIT"
] | permissive | Kryanush/Hadoop-BAM | 8e035ef49c422e0b3bf08778397c9dee5ec779e7 | 5f43540b49c8b9dd5b1d057bceada9f2980dde12 | refs/heads/master | 2020-12-11T03:45:15.832708 | 2016-03-14T09:05:21 | 2016-03-14T09:05:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,585 | java | package org.seqdoop.hadoop_bam;
import hbparquet.hadoop.util.ContextUtil;
import java.io.*;
import java.net.URI;
import java.nio.file.Paths;
import htsjdk.samtools.CRAMContainerStreamWriter;
import htsjdk.samtools.SAMTextHeaderCodec;
import htsjdk.samtools.cram.ref.ReferenceSource;
import htsjdk.samtools.SAMFileHeader;
import htsjdk.samtools.SAMRecord;
import htsjdk.samtools.reference.ReferenceSequenceFileFactory;
import htsjdk.samtools.util.StringLineReader;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.seqdoop.hadoop_bam.util.SAMHeaderReader;
/** A base {@link RecordWriter} for CRAM records.
*
* <p>Handles the output stream, writing the header if requested, and provides
* the {@link #writeAlignment} function for subclasses.</p>
* <p>Note that each file created by this class consists of a fragment of a
* complete CRAM file containing only one or more CRAM containers that do not
* include a CRAM file header, a SAMFileHeader, or a CRAM EOF container.</p>
*/
public abstract class CRAMRecordWriter<K>
extends RecordWriter<K,SAMRecordWritable>
{
// generic ID passed to CRAM code for internal error reporting
private static final String HADOOP_BAM_PART_ID= "Hadoop-BAM-Part";
private OutputStream origOutput;
private CRAMContainerStreamWriter cramContainerStream = null;
private ReferenceSource refSource = null;
private boolean writeHeader = true;
/** A SAMFileHeader is read from the input Path. */
public CRAMRecordWriter(
final Path output,
final Path input,
final boolean writeHeader,
final TaskAttemptContext ctx) throws IOException
{
init(
output,
SAMHeaderReader.readSAMHeaderFrom(input, ContextUtil.getConfiguration(ctx)),
writeHeader, ctx);
}
public CRAMRecordWriter(
final Path output, final SAMFileHeader header, final boolean writeHeader,
final TaskAttemptContext ctx)
throws IOException
{
init(
output.getFileSystem(ContextUtil.getConfiguration(ctx)).create(output),
header, writeHeader, ctx);
}
// Working around not being able to call a constructor other than as the
// first statement...
private void init(
final Path output, final SAMFileHeader header, final boolean writeHeader,
final TaskAttemptContext ctx)
throws IOException
{
init(
output.getFileSystem(ContextUtil.getConfiguration(ctx)).create(output),
header, writeHeader, ctx);
}
private void init(
final OutputStream output, final SAMFileHeader header, final boolean writeHeader,
final TaskAttemptContext ctx)
throws IOException
{
origOutput = output;
this.writeHeader = writeHeader;
final URI referenceURI = URI.create(
ctx.getConfiguration().get(CRAMInputFormat.REFERENCE_SOURCE_PATH_PROPERTY)
);
refSource = new ReferenceSource(Paths.get(referenceURI));
// A SAMFileHeader must be supplied at CRAMContainerStreamWriter creation time; if
// we don't have one then delay creation until we do
if (header != null) {
cramContainerStream = new CRAMContainerStreamWriter(
origOutput, null, refSource, header, HADOOP_BAM_PART_ID);
if (writeHeader) {
this.writeHeader(header);
}
}
}
@Override public void close(TaskAttemptContext ctx) throws IOException {
cramContainerStream.finish(false); // Close, but suppress CRAM EOF container
origOutput.close(); // And close the original output.
}
protected void writeAlignment(final SAMRecord rec) {
if (null == cramContainerStream) {
final SAMFileHeader header = rec.getHeader();
if (header == null) {
throw new RuntimeException("Cannot write record to CRAM: null header in SAM record");
}
if (writeHeader) {
this.writeHeader(header);
}
cramContainerStream = new CRAMContainerStreamWriter(
origOutput, null, refSource, header, HADOOP_BAM_PART_ID);
}
cramContainerStream.writeAlignment(rec);
}
private void writeHeader(final SAMFileHeader header) {
cramContainerStream.writeHeader(header);
}
}
| [
"cnorman@broadinstitute.org"
] | cnorman@broadinstitute.org |
21b2438cfdd53e05b57b350e5c0fc51d9a4b9fca | 4c23bb95106657319443053b03777471a6b290b2 | /ThreadInAction/src/com/sun/thread/chapter3/TryLock.java | 109602271b836ff1f3117be0cb1bdb6e61fa202b | [] | no_license | sunailian/TouchHigh | 1d77f415def546014b9de59b67e777192d2520d2 | 367f9904b14a7a95f1454970d8f452eafefce107 | refs/heads/master | 2023-03-16T17:11:43.886929 | 2023-03-03T14:12:24 | 2023-03-03T14:12:24 | 49,575,167 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,445 | java | /**
*
*/
package com.sun.thread.chapter3;
import java.util.concurrent.locks.ReentrantLock;
/**
* @Package com.guozha.oms.web.controller.user
* @Description: TODO
* @author sunhanbin
* @date 2016-1-19下午9:52:26
*/
public class TryLock implements Runnable {
public static ReentrantLock lock1 = new ReentrantLock();
public static ReentrantLock lock2 = new ReentrantLock();
int lock;
public TryLock(int lock) {
this.lock = lock;
}
public void run() {
if (lock == 1) {
while (true) {
try {
if (lock1.tryLock()) {
Thread.sleep(500);
if (lock2.tryLock()) {
try {
System.out.println(Thread.currentThread().getId() + "My Job is Done!");
return;
} finally {
lock2.unlock();
}
}
}
} catch (InterruptedException e) {
} finally {
lock1.unlock();
}
}
} else {
while (true) {
if (lock2.tryLock()) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (lock1.tryLock()) {
try {
System.out.println(Thread.currentThread().getId() + "My Job is Done!");
return;
} finally {
lock1.unlock();
}
}
}
}
}
}
public static void main(String[] args) {
TryLock l1 = new TryLock(1);
TryLock l2 = new TryLock(2);
Thread t1 = new Thread(l1);
Thread t2 = new Thread(l2);
t1.start();
t2.start();
}
}
| [
"sunangie@126.com"
] | sunangie@126.com |
cf5628566b4c8d4e6f9e157ece4e0c98151e7f36 | e0df638646bbb7891c5ff5ff996f8d3f4d08d0cb | /modules/mq/mq-service/mq-service-impl/src/main/java/grape/mq/service/impl/ApiMqProducerServiceImpl.java | 6b81ecf50bbc40a2e25e5086bb0b593e810ba21c | [] | no_license | feihua666/grape | 479f758600da13e7b43b2d60744c304ed72f71a4 | 22bd2eebd4952022dde72ea8ff9e85d6b1d79595 | refs/heads/master | 2023-01-22T13:00:02.901359 | 2020-01-02T05:01:22 | 2020-01-02T05:01:22 | 197,750,420 | 0 | 0 | null | 2023-01-04T08:23:17 | 2019-07-19T10:05:42 | TSQL | UTF-8 | Java | false | false | 489 | java | package grape.mq.service.impl;
import grape.mq.service.api.ApiMqProducerService;
import grape.mq.service.dto.MessageParam;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Created by yangwei
* Created at 2019/11/12 14:22
*/
@Component
public class ApiMqProducerServiceImpl implements ApiMqProducerService {
@Autowired
private AmqpTemplate amqpTemplate;
}
| [
"feihua666@sina.com"
] | feihua666@sina.com |
e09eb7264e01825c5c3b0728b261dcba34953a3c | 08812ba43975da3b44de72e0c2221cb73c662d45 | /src/test/java/br/com/ifood/challenge/celsiustracks/template/CelsiusPlaylistTemplateLoader.java | e556c36eed5fd2aa79a0709c7abb9f3a0dfa3697 | [] | no_license | find0ub7/CelsiusTracks | bf96a42f669735d12dd39d0eda3ecb98b8f5a55e | 5ed7ea16759e52a1b3029be2c6af2b9a659a9103 | refs/heads/master | 2022-07-26T03:28:38.391228 | 2022-07-17T21:16:21 | 2022-07-17T21:16:21 | 175,818,229 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 566 | java | package br.com.ifood.challenge.celsiustracks.template;
import br.com.ifood.challenge.celsiustracks.domain.celsiustracks.CelsiusPlaylist;
import br.com.six2six.fixturefactory.Fixture;
import br.com.six2six.fixturefactory.Rule;
import br.com.six2six.fixturefactory.loader.TemplateLoader;
public class CelsiusPlaylistTemplateLoader implements TemplateLoader {
@Override
public void load() {
Fixture.of(CelsiusPlaylist.class).addTemplate(FixtureLabel.RANDOM_PLAYLIST.name(), new Rule(){{
add("name", regex("\\w{30}"));
}});
}
}
| [
"leon.watanabe@gmail.com"
] | leon.watanabe@gmail.com |
a5cf4c3abb16e0ef78dda247e887d422657b6e05 | 9f30085b3198e72638fd64faaccaf0d92869dcd7 | /11_Spring_Security/Demo/demo/src/main/java/edu/hes/e57/demo/domain/Auto.java | 2441597652cfbe71b02d282ef01863acd9ba0594 | [] | no_license | RobertFrenette/E-57_Fall_2017 | f7930e4caea2ebe31bb2a36d5d4c6e178598072f | b8769dc53b9e8cd47244664823fc1338450b26cd | refs/heads/master | 2021-01-23T19:33:59.149581 | 2018-09-07T07:38:00 | 2018-09-07T07:38:00 | 102,828,471 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,109 | java | package edu.hes.e57.demo.domain;
import static javax.persistence.GenerationType.IDENTITY;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotEmpty;
@Entity
@Table(name = "AUTO")
public class Auto implements Serializable {
private Long id;
private int version;
private String model;
private String year;
private String msrp;
private byte[] photo;
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "ID")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Version
@Column(name = "VERSION")
public int getVersion() {
return this.version;
}
public void setVersion(int version) {
this.version = version;
}
@NotEmpty(message="{validation.model.NotEmpty.message}")
@Size(min=1, max=100, message="{validation.model.Size.message}")
@Column(name = "MODEL")
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
@NotEmpty(message="{validation.year.NotEmpty.message}")
@Column(name = "YEAR")
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
@NotEmpty(message="{validation.msrp.NotEmpty.message}")
@Column(name = "MSRP")
public String getMsrp() {
return msrp;
}
public void setMsrp(String msrp) {
this.msrp = msrp;
}
// Photo
@Basic(fetch= FetchType.LAZY)
@Lob
@Column(name = "PHOTO")
public byte[] getPhoto() {
return photo;
}
public void setPhoto(byte[] photo) {
this.photo = photo;
}
@Override
public String toString() {
return "Auto - Id: " + id + ", Model: " + model + ", Year: " + year + ", MSRP: $" + msrp;
}
}
| [
"robert.frenette@comcast.net"
] | robert.frenette@comcast.net |
34129fc9ae7ad75a359706560b55a9105a6d97b5 | 129f58086770fc74c171e9c1edfd63b4257210f3 | /src/testcases/CWE369_Divide_by_Zero/CWE369_Divide_by_Zero__float_Property_divide_71a.java | 398d44dd6ce242801a927c8bac4d00313aaf92bc | [] | no_license | glopezGitHub/Android23 | 1bd0b6a6c7ce3c7439a74f1e4dcef2c4c0fac4ba | 6215d0684c4fbdc7217ccfbedfccfca69824cc5e | refs/heads/master | 2023-03-07T15:14:59.447795 | 2023-02-06T13:59:49 | 2023-02-06T13:59:49 | 6,856,387 | 0 | 3 | null | 2023-02-06T18:38:17 | 2012-11-25T22:04:23 | Java | UTF-8 | Java | false | false | 3,415 | java | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE369_Divide_by_Zero__float_Property_divide_71a.java
Label Definition File: CWE369_Divide_by_Zero__float.label.xml
Template File: sources-sinks-71a.tmpl.java
*/
/*
* @description
* CWE: 369 Divide by zero
* BadSource: Property Read data from a system property
* GoodSource: A hardcoded non-zero number (two)
* Sinks: divide
* GoodSink: Check for zero before dividing
* BadSink : Dividing by a value that may be zero
* Flow Variant: 71 Data flow: data passed as an Object reference argument from one method to another in different classes in the same package
*
* */
package testcases.CWE369_Divide_by_Zero;
import testcasesupport.*;
import java.sql.*;
import javax.servlet.http.*;
import java.security.SecureRandom;
import java.util.logging.Level;
import java.util.logging.Logger;
public class CWE369_Divide_by_Zero__float_Property_divide_71a extends AbstractTestCase
{
public void bad() throws Throwable
{
float data;
data = -1.0f; /* Initialize data */
/* get system property user.home */
/* POTENTIAL FLAW: Read data from a system property */
{
String s_data = System.getProperty("user.home");
if (s_data != null)
{
try
{
data = Float.parseFloat(s_data.trim());
}
catch(NumberFormatException nfe)
{
IO.logger.log(Level.WARNING, "Number format exception parsing data from string", nfe);
}
}
}
(new CWE369_Divide_by_Zero__float_Property_divide_71b()).bad_sink((Object)data );
}
public void good() throws Throwable
{
goodG2B();
goodB2G();
}
/* goodG2B() - use goodsource and badsink */
private void goodG2B() throws Throwable
{
float data;
/* FIX: Use a hardcoded number that won't a divide by zero */
data = 2.0f;
(new CWE369_Divide_by_Zero__float_Property_divide_71b()).goodG2B_sink((Object)data );
}
/* goodB2G() - use badsource and goodsink */
private void goodB2G() throws Throwable
{
float data;
data = -1.0f; /* Initialize data */
/* get system property user.home */
/* POTENTIAL FLAW: Read data from a system property */
{
String s_data = System.getProperty("user.home");
if (s_data != null)
{
try
{
data = Float.parseFloat(s_data.trim());
}
catch(NumberFormatException nfe)
{
IO.logger.log(Level.WARNING, "Number format exception parsing data from string", nfe);
}
}
}
(new CWE369_Divide_by_Zero__float_Property_divide_71b()).goodB2G_sink((Object)data );
}
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
public static void main(String[] args) throws ClassNotFoundException,
InstantiationException, IllegalAccessException
{
mainFromParent(args);
}
}
| [
"guillermo.pando@gmail.com"
] | guillermo.pando@gmail.com |
b2aeb5eb2059c8708f47d5f505f2b2ada9432bde | 05dab5688cac6e0b4ae141e27bd5870112e5e017 | /H071191059/Praktikum 2/ABC/src/AtBeCo/Main.java | 82c668b8fe1aec3af61d2ceb001be5bc4bd3f22c | [] | no_license | nugratar/PBO-Team-7 | 4761f5c7c47832fbe7282c0a1f48aa80cd6e6a2a | 62ed6c42950579b4457fbe2f91d7538f3b27ede2 | refs/heads/master | 2022-05-26T02:09:24.097096 | 2020-04-16T15:07:15 | 2020-04-16T15:07:15 | 243,649,282 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 571 | java | package AtBeCo;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double width = input.nextDouble();
double heigth = input.nextDouble();
double depth = input.nextDouble();
double mass = input.nextDouble();
Box box = new Box(width, heigth, depth);
box.setMass(mass);
System.out.println("Masa jenis = " + box.getDensity());
box.setMass(mass*2);
System.out.println("Masa jenis = " + box.getDensity());
}
} | [
"nugratar59@gmail.com"
] | nugratar59@gmail.com |
20de9c0ffef55f9e0a631a21d17609164fa6737b | dae1617b4f5ee8b139a660b73a51a51f3ef62030 | /thinking-in-java/src/main/java/concurrency/EvenChecker.java | 445ddf49ba9e31afd444dcb8e593585541361802 | [] | no_license | gsdxzwq/book-examples | 7adbd196b0753e299bc654acfef82ca5058bb5d9 | 7981181df4c45848c47bd7929082b8ee3a1a780d | refs/heads/master | 2022-03-22T19:28:49.843613 | 2019-12-26T08:25:08 | 2019-12-26T08:25:08 | 104,466,458 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,078 | java | package concurrency;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class EvenChecker implements Runnable {
private IntGenerator generator;
private final int id;
public EvenChecker(IntGenerator generator, int id) {
super();
this.generator = generator;
this.id = id;
}
public void run() {
while (!generator.isCanceled()) {
int val = generator.next();
if (val % 2 != 0) {
System.out.println(val + "not even");
generator.cancel();
}
}
}
public static void test(IntGenerator intGenerator, int count) {
System.out.println("press ctrl+c to exit");
ExecutorService executorService = Executors.newCachedThreadPool();
for (int i = 0; i < count; i++) {
executorService.execute(new EvenChecker(intGenerator, count));
}
executorService.shutdown();
}
public static void test(IntGenerator intGenerator) {
test(intGenerator, 10);
}
}
| [
"zhaowq@tclking.com"
] | zhaowq@tclking.com |
fd70e40c65fe00483c4c79988a8b01486db5bb8f | c7c7905c17812fa5bc1a5334f66b3240b4f45335 | /service-system/src/main/java/com/wfm/servicesystem/controller/RoleController.java | 8595c31917a0f3521f69f045a6c7c89153225610 | [] | no_license | wufengming/spring-cloud-demo | 9f4c7f7b48f6fa8c573e72e71896fc068b5af59b | 3c9a9ca56d2887eeeee536274c068b1ea75ae2ac | refs/heads/master | 2022-09-23T01:28:38.366080 | 2020-04-19T03:38:29 | 2020-04-19T03:38:29 | 229,693,610 | 0 | 0 | null | 2022-09-01T23:17:52 | 2019-12-23T06:47:53 | JavaScript | UTF-8 | Java | false | false | 2,949 | java | package com.wfm.servicesystem.controller;
import com.wfm.servicecommon.api.ApiResult;
import com.wfm.servicecommon.vo.Paging;
import com.wfm.servicesystem.entity.RoleEntity;
import com.wfm.servicesystem.model.vo.role.RoleQueryParam;
import com.wfm.servicesystem.model.vo.role.RoleQueryVo;
import com.wfm.servicesystem.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.wfm.servicesystem.common.base.BaseController;
import javax.validation.Valid;
/**
* <p>
* 角色表 前端控制器
* </p>
*
* @author wfm
* @since 2019-11-06
*/
@Slf4j
@RestController
@RequestMapping("/role")
@Api("系统角色API")
public class RoleController extends BaseController {
@Autowired
private RoleService roleService;
/**
* 添加系统角色
*/
@PostMapping("/add")
@ApiOperation(value = "添加Role对象", notes = "添加系统角色", response = ApiResult.class)
public ApiResult<Boolean> addSysRole(@Valid @RequestBody RoleQueryVo roleQueryVo) throws Exception {
boolean flag = roleService.saveSysRole(roleQueryVo);
return ApiResult.result(flag);
}
/**
* 修改系统角色
*/
@PostMapping("/update")
@ApiOperation(value = "修改SysRole对象", notes = "修改系统角色", response = ApiResult.class)
public ApiResult<Boolean> updateSysRole(@Valid @RequestBody RoleQueryVo roleQueryVo) throws Exception {
boolean flag = roleService.updateSysRole(roleQueryVo);
return ApiResult.result(flag);
}
/**
* 删除系统角色
*/
@PostMapping("/delete/{id}")
@ApiOperation(value = "删除SysRole对象", notes = "删除系统角色", response = ApiResult.class)
public ApiResult<Boolean> deleteSysRole(@PathVariable("id") Long id) throws Exception {
boolean flag = roleService.deleteSysRole(id);
return ApiResult.result(flag);
}
/**
* 获取系统角色
*/
@GetMapping("/info/{id}")
@ApiOperation(value = "获取SysRole对象详情", notes = "查看系统角色", response = RoleQueryVo.class)
public ApiResult<RoleQueryVo> getSysRole(@PathVariable("id") Long id) throws Exception {
RoleQueryVo sysRoleQueryVo = roleService.getSysRoleById(id);
return ApiResult.ok(sysRoleQueryVo);
}
/**
* 系统角色分页列表
*/
@PostMapping("/getPageList")
@ApiOperation(value = "获取SysRole分页列表", notes = "系统角色分页列表", response = RoleQueryVo.class)
public ApiResult<Paging<RoleQueryVo>> getSysRolePageList(@Valid @RequestBody RoleQueryParam sysRoleQueryParam) throws Exception {
Paging<RoleQueryVo> paging = roleService.getSysRolePageList(sysRoleQueryParam);
return ApiResult.ok(paging);
}
}
| [
"542171065@qq.com"
] | 542171065@qq.com |
78284aed84c101f189022d52a3b4d4a3fd50d63b | db4de57e8dd7cf60249450e928c4d44260a9b570 | /pc-client/src/main/java/com/alipay/sign/MD5.java | 5dbfcccca0d7a3a0d5eae97e20cdfe7f9c233742 | [] | no_license | eseawind/eb | 4d2bc80ea90e674f93862768b16a63384e958769 | b38d4c15344bf9d7a5a0bd7c02806781c1d7c313 | refs/heads/master | 2021-01-18T07:34:55.372740 | 2015-08-06T09:29:59 | 2015-08-06T09:29:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,738 | java | package com.alipay.sign;
import java.io.UnsupportedEncodingException;
import java.security.SignatureException;
import org.apache.commons.codec.digest.DigestUtils;
/**
* 功能:支付宝MD5签名处理核心文件,不需要修改
* */
public class MD5 {
/**
* 签名字符串
* @param text 需要签名的字符串
* @param key 密钥
* @param input_charset 编码格式
* @return 签名结果
*/
public static String sign(String text, String key, String input_charset) {
text = text + key;
return DigestUtils.md5Hex(getContentBytes(text, input_charset));
}
/**
* 签名字符串
* @param text 需要签名的字符串
* @param sign 签名结果
* @param key 密钥
* @param input_charset 编码格式
* @return 签名结果
*/
public static boolean verify(String text, String sign, String key, String input_charset) {
text = text + key;
String mysign = DigestUtils.md5Hex(getContentBytes(text, input_charset));
if(mysign.equals(sign)) {
return true;
}
else {
return false;
}
}
/**
* @param content
* @param charset
* @return
* @throws SignatureException
* @throws UnsupportedEncodingException
*/
private static byte[] getContentBytes(String content, String charset) {
if (charset == null || "".equals(charset)) {
return content.getBytes();
}
try {
return content.getBytes(charset);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("MD5签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset);
}
}
} | [
"1053931671@qq.com"
] | 1053931671@qq.com |
85712bb9e31dc4f437232ea72b8784163b432fe2 | 2da4b4311f8bd335be6d06ca99d97ce588e7bdca | /src/main/java/cn/springmvc/controller/MainController.java | f577eb11e0d66c725a9d47f03635f35b0c7cc1bf | [] | no_license | diggazoon/MSM | 6627480f45c88fdf0df4b2b7337c36687b2120cb | 856ad8e7ce5afb6b682ef747fd401662d78b8fc2 | refs/heads/master | 2020-06-13T23:22:42.492158 | 2014-11-06T02:01:29 | 2014-11-06T02:01:29 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 427 | java | package cn.springmvc.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/")
public class MainController {
@RequestMapping("index")
public String index(){
System.out.println(111);
return "index";
//防止重复提交数据,可以使用重定向视图:
//return "redirect:/index"
}
}
| [
"zhanguo.dong@163.com"
] | zhanguo.dong@163.com |
257eca78e1af93d3065a5e135558dc0233eb1594 | 5363d8d6dc75357d40ebfbb07f7795a16bbbaa5e | /library-integration/src/main/java/library/LibraryIntegrationApp.java | 47d1dfde07e43a0b907ac0944311b5d81df4ea9d | [] | no_license | davidepravata/SpringInAction | d5930bf62774c69bbc40756a77789c5a801fc125 | 3c0ec5604e1f218f41d05fc93fd2076750175ed6 | refs/heads/master | 2020-04-08T11:09:09.783098 | 2018-12-05T20:29:39 | 2018-12-05T20:29:39 | 159,295,044 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,078 | java | package library;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlows;
import org.springframework.integration.dsl.MessageChannels;
import org.springframework.integration.dsl.Pollers;
import org.springframework.integration.file.dsl.Files;
import org.springframework.integration.file.support.FileExistsMode;
import org.springframework.messaging.MessageChannel;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.io.File;
import java.util.concurrent.atomic.AtomicInteger;
@SpringBootApplication
public class LibraryIntegrationApp implements WebMvcConfigurer {
public static void main(String[] args) {
SpringApplication.run(LibraryIntegrationApp.class, args);
}
}
| [
"davide.pravata@docomodigital.com"
] | davide.pravata@docomodigital.com |
e8500fb30018a82f9a1c24b04c3845bc6301a945 | 7f61c75cf7f4fccbb383030ace112f83876431cd | /src/main/java/online/xuanwei/bbs/interceptor/SessionInterceptor.java | ccc3e3d086d1e29e944d43ad7ea289ab056668ea | [] | no_license | JXWJS/bbs | 8597c04e96d570b28ce05b940e6d4baf4c583698 | 8e3d561cbdcb9de7adb5f7ee677553694a6c9457 | refs/heads/master | 2023-04-06T11:19:49.394695 | 2021-04-26T10:55:01 | 2021-04-26T10:55:01 | 347,348,675 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,851 | java | package online.xuanwei.bbs.interceptor;
import online.xuanwei.bbs.mapper.UserMapper;
import online.xuanwei.bbs.model.User;
import online.xuanwei.bbs.model.UserExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@Service
public class SessionInterceptor implements HandlerInterceptor {
@Autowired
UserMapper userMapper;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Cookie[] cookies = request.getCookies();
if(cookies != null) {
for (Cookie cookie : cookies) {
if (cookie.getName().equals("token")) {
String token = cookie.getValue();
UserExample userExample = new UserExample();
userExample.createCriteria()
.andTokenEqualTo(token);
List<User> users = userMapper.selectByExample(userExample);
if (users.size() !=0) {
request.getSession().setAttribute("user", users.get(0));
}
break;
}
}
}
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
}
}
| [
"lx554468@outlook.com"
] | lx554468@outlook.com |
3a713887146b1e3f99f500a09d0442c5400af5ab | 3132af11d96fe17a385a9f1acd58b4e76649c639 | /src/StudyAlgorithm_SWEA/S_5644.java | cc74ef2f7f1a7adf272e642fcab070c58801e2ba | [] | no_license | kyun9/PracticeAlgorithm | a25413284d8933aeebd29ead32ad0d493a8dac3a | 54c2c9938510a593562fbb5e6065ef5b78b549e2 | refs/heads/master | 2021-06-15T13:47:35.371264 | 2021-04-21T15:08:55 | 2021-04-21T15:08:55 | 187,728,314 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,220 | java | package StudyAlgorithm_SWEA;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
class Ap {
int x;
int y;
int cov;
int p;
Ap(int x, int y, int cov, int p) {
this.x = x;
this.y = y;
this.cov = cov;
this.p = p;
}
}
class People {
int x;
int y;
People(int x, int y) {
this.x = x;
this.y = y;
}
}
public class S_5644 {
static int M, N;
static People A, B;
static int[] arrA;
static int[] arrB;
static int[][] map;
static int[] dx = { 0, 0, 1, 0, -1 };
static int[] dy = { 0, -1, 0, 1, 0 };
static ArrayList<Ap> list;
static ArrayList<Integer> sumList;
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine().trim());
for (int test = 1; test <= T; test++) {
StringTokenizer st = new StringTokenizer(br.readLine());
M = Integer.parseInt(st.nextToken());
N = Integer.parseInt(st.nextToken());
A = new People(0, 0);
B = new People(9, 9);
map = new int[10][10];
arrA = new int[M];
arrB = new int[M];
st = new StringTokenizer(br.readLine());
for (int i = 0; i < M; i++) {
arrA[i] = Integer.parseInt(st.nextToken());
}
st = new StringTokenizer(br.readLine());
for (int i = 0; i < M; i++) {
arrB[i] = Integer.parseInt(st.nextToken());
}
list = new ArrayList<>();
sumList = new ArrayList<>();
for (int i = 0; i < N; i++) {
st = new StringTokenizer(br.readLine());
list.add(new Ap(Integer.parseInt(st.nextToken()) - 1, Integer.parseInt(st.nextToken()) - 1,
Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken())));
}
// 0,0 9,9 시작 일때
containAp();
for (int i = 0; i < M; i++) {
int dicA = arrA[i];
int dicB = arrB[i];
A.x += dx[dicA];
A.y += dy[dicA];
B.x += dx[dicB];
B.y += dy[dicB];
containAp();
}
int result = 0;
for (int i = 0; i < sumList.size(); i++) {
result += sumList.get(i);
}
System.out.println("#" + test + " " + result);
}
}
static void containAp() {
boolean[] check1 = new boolean[N];
boolean[] check2 = new boolean[N];
int ax = A.x;
int ay = A.y;
int bx = B.x;
int by = B.y;
for (int i = 0; i < N; i++) {
int x = list.get(i).x;
int y = list.get(i).y;
int cov = list.get(i).cov;
int p = list.get(i).p;
if (Math.abs(x - ax) + Math.abs(y - ay) <= cov) {
check1[i] = true;
}
if (Math.abs(x - bx) + Math.abs(y - by) <= cov) {
check2[i] = true;
}
}
combSize(check1, check2);
}
static void combSize(boolean[] check1, boolean[] check2) {
int a = 0, b = 0;
int sum = 0;
for (int i = 0; i < N; i++) {
if (check1[i]) {
a = list.get(i).p;
for (int j = 0; j < N; j++) {
if (check2[j]) {
b = list.get(j).p;
if (i == j) {
sum = Math.max(sum, a);
} else {
sum = Math.max(sum, a + b);
}
} else {
sum = Math.max(sum, a);
}
}
} else {
for (int j = 0; j < N; j++) {
if (check2[j]) {
b = list.get(j).p;
sum = Math.max(sum, b);
}
}
}
}
sumList.add(sum);
}
}
| [
"gusl108@naver.com"
] | gusl108@naver.com |
fe47cfbc18e373948aa0b7a65ed1571bfa7fb7f8 | d86036ecb5a3874a67dfaed4ee38c1b506623881 | /src/dongfang/xsltools/diagnostics/ParseLocationBean.java | 06f9ceafa88db983401b22f0b65b371619dc4d71 | [] | no_license | cs-au-dk/XSLV | 44aaa11f12829328b057e56e92a39c50c39f5a3d | 41e53c964d2cf797e2c2c77531156ec3e7dcd0ef | refs/heads/master | 2021-01-01T20:05:16.004917 | 2013-08-19T09:44:54 | 2013-08-19T09:44:54 | 7,849,936 | 2 | 3 | null | null | null | null | UTF-8 | Java | false | false | 2,835 | java | package dongfang.xsltools.diagnostics;
import dk.brics.misc.Origin;
/*
* dongfang M. Sc. Thesis
* Created on 09-02-2005
*/
/**
* @author dongfang
*/
public class ParseLocationBean implements ParseLocation {
int elementStartTagBeginningLine;
int elementStartTagBeginningColumn;
int elementStartTagEndLine;
int elementStartTagEndColumn;
int elementEndTagEndLine;
int elementEndTagEndColumn;
public ParseLocationBean() {
}
public ParseLocationBean(Origin o) {
this.elementStartTagBeginningLine = o.getLine();
this.elementStartTagEndColumn = o.getColumn();
}
public ParseLocationBean(int elementStartTagBeginningLine,
int elementStartTagBeginningColumn) {
this.elementStartTagBeginningLine = elementStartTagBeginningLine;
this.elementStartTagBeginningColumn = elementStartTagBeginningColumn;
}
public ParseLocationBean(int elementStartTagBeginningLine,
int elementStartTagBeginningColumn, int elementStartTagEndLine,
int elementStartTagEndColumn) {
this(elementStartTagBeginningLine, elementStartTagBeginningColumn);
this.elementStartTagEndLine = elementStartTagEndLine;
this.elementStartTagEndColumn = elementStartTagEndColumn;
}
public void setElementEndTagEndLine(int i) {
this.elementEndTagEndLine = i;
}
public void setElementEndTagEndColumn(int i) {
this.elementEndTagEndColumn = i;
}
public int elementStartTagBeginningLine() {
return elementStartTagBeginningLine;
}
public int elementStartTagBeginningColumn() {
return elementStartTagBeginningColumn;
}
public int elementStartTagEndLine() {
return elementStartTagEndLine;
}
public int elementStartTagEndColumn() {
return elementStartTagEndColumn;
}
public int elementEndTagEndLine() {
return elementEndTagEndLine;
}
public int elementEndTagEndColumn() {
return elementEndTagEndColumn;
}
@Override
public String toString() {
return elementStartTagBeginningLine + "," + elementStartTagBeginningColumn
+ "," + elementStartTagEndLine + "," + elementStartTagEndColumn + ","
+ elementEndTagEndLine + "," + elementEndTagEndColumn;
}
public String toReadableString(Extent extent) {
if (extent == Extent.TAG)
return "(line " + elementStartTagBeginningLine + ", column "
+ elementStartTagBeginningColumn + ")" + " - (line "
+ elementStartTagEndLine + ", column " + elementStartTagEndColumn
+ ")";
if (extent == Extent.ELEMENT)
return "(line " + elementStartTagBeginningLine + ", column "
+ elementStartTagBeginningColumn + ")" + " - (line "
+ elementEndTagEndLine + ", column " + elementEndTagEndColumn + ")";
return "(@line " + elementStartTagBeginningLine + ", column "
+ elementStartTagBeginningColumn + ")";
}
} | [
"soren.kuula@gmail.com"
] | soren.kuula@gmail.com |
8cc01b44a99f9c12cd7bb9b0f72b70179d526615 | a5f448d8e450a2e79d5abef19b468a8a4c5a7b34 | /src/com/lovo/netCRM/dept/frame/DeptPanel.java | 1b84d3dd62dc4c7ef946c02dcf577a57cb4fabae | [] | no_license | houmingsong/crmModelaa | 3135a189c337c28346d59cdc7541ce25eff60aaa | c27c67d98b5498faadd832d1e69c35bfd332517e | refs/heads/master | 2020-06-16T07:41:31.353886 | 2019-07-06T08:10:51 | 2019-07-06T08:10:51 | 195,514,856 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 2,525 | java | package com.lovo.netCRM.dept.frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import com.lovo.netCRM.component.LovoButton;
import com.lovo.netCRM.component.LovoTable;
import com.lovo.netCRM.component.LovoTitleLabel;
import com.project.Bean.DepartmentBean;
import com.project.service.IDepartmentService;
import com.project.serviceImpl.DepartmentServiceImpl;
/**
*
* 四川网脉CRM系统
* @author 张成峰
* @version 1.0
* @see
* @description 部门管理面板
* 开发日期:2012-10-6
*/
public class DeptPanel extends JPanel{
/**部门表格组件*/
private LovoTable deptTable;
/**窗体对象*/
private JFrame jf;
IDepartmentService service=new DepartmentServiceImpl();
public DeptPanel(JFrame jf){
this.jf = jf;
this.setLayout(null);
this.init();
}
/**
* 初始化
*
*/
private void init() {
new LovoTitleLabel("部 门 管 理",this);
this.initTable();
this.initButton();
this.initData();
}
/**
* 初始化数据
*/
public void initData(){
this.updateDeptTable();
}
/**
* 初始化按钮
*
*/
private void initButton() {
LovoButton lbadd = new LovoButton("添加新部门",200,500,this);
lbadd.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
new DeptAddDialog(jf,DeptPanel.this);
}});
LovoButton lbupdate = new LovoButton("修改部门信息",400,500,this);
lbupdate.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
int key = deptTable.getKey();
if(key == -1){
JOptionPane.showMessageDialog(null,"请选择行");
return;
}
new DeptUpdateDialog(jf,key,DeptPanel.this);
}});
}
//--------------------------
/**
* 初始化表格
*/
private void initTable() {
deptTable = new LovoTable(this,
new String[]{"部门名称","成立时间","部门描述"},
new String[]{"department","dtime","departmentDescribe"},//部门实体属性名数组 new String[]{"deptName","time"}
"id");//主键属性名 deptId
deptTable.setSizeAndLocation(20, 90, 700, 300);
}
/**
* 更新部门表格
*/
private void updateDeptTable(){
//更新表格,插入部门List集合
List<DepartmentBean>list=service.findAll();
deptTable.updateLovoTable(list);
}
}
| [
"castle@192.168.1.111"
] | castle@192.168.1.111 |
eecedf0692d47606463e7d8acd4d0d4b9a476968 | 7fdc131e615a6f67bcc2b39446a2d7036dc1f5f6 | /src/main/java/org/c3s/edgo/event/impl/beans/TouchdownBean.java | 643002ac30cfeed5c88a3254e0de5c3070c485d9 | [] | no_license | hapsys/ed-go | 7e4711d7404b7fa3313182eb3df185cc7c64ef8b | 73f31073a19a318c0cfbccb5d841761224d73a52 | refs/heads/develop | 2022-10-08T01:01:28.591446 | 2019-10-23T04:40:55 | 2019-10-23T04:40:55 | 74,848,503 | 1 | 2 | null | 2022-10-05T18:41:25 | 2016-11-26T20:19:06 | Java | UTF-8 | Java | false | false | 1,017 | java | package org.c3s.edgo.event.impl.beans;
import java.util.Date;
import org.c3s.edgo.event.AbstractEventBean;
public class TouchdownBean extends AbstractEventBean {
private Date timestamp;
private String event;
/**
*
*/
private String Latitude;
/**
*
*/
private String Longitude;
/**
* @return
*/
public Date getTimestamp() {
return timestamp;
}
/**
* @param timestamp
*/
public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
/**
* @return
*/
public String getEvent() {
return event;
}
/**
* @param event
*/
public void setEvent(String event) {
this.event = event;
}
/**
* @return
*/
public String getLatitude() {
return Latitude;
}
/**
* @param latitude
*/
public void setLatitude(String latitude) {
this.Latitude = latitude;
}
/**
* @return
*/
public String getLongitude() {
return Longitude;
}
/**
* @param longitude
*/
public void setLongitude(String longitude) {
this.Longitude = longitude;
}
}
| [
"hapsys@gmail.com"
] | hapsys@gmail.com |
f925c3aa79ce8ae2ed6a3150a2b6d20367d56e9a | 65f9dbc3b86a22df229a8b16cf8377b21843cbc0 | /src/main/java/bpel/org/example/salida/EntradaBR.java | f92302605c368a4d43027caaec0a9857b91ff63e | [] | no_license | frankrb27/taller-soa-eai | 19d790cfd03d281a87da466f335a66f29c8452a0 | 1711867657edcea86782847d5dd0929aab0a383f | refs/heads/master | 2021-04-26T22:42:51.171407 | 2018-03-15T03:02:15 | 2018-03-15T03:02:15 | 124,135,907 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,195 | java |
package bpel.org.example.salida;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Clase Java para entradaBR complex type.
*
* <p>El siguiente fragmento de esquema especifica el contenido que se espera que haya en esta clase.
*
* <pre>
* <complexType name="entradaBR">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="tailNumber" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="OnAirShopping" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="AlertsOnAir" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="CancelFlight" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="ActualIngate" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="ActualOutgate" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="EstimatedIngate" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="EstimatedOutgate" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="Status" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="Combustible" type="{http://www.w3.org/2001/XMLSchema}int"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "entradaBR", propOrder = {
"tailNumber",
"onAirShopping",
"alertsOnAir",
"cancelFlight",
"actualIngate",
"actualOutgate",
"estimatedIngate",
"estimatedOutgate",
"status",
"combustible"
})
public class EntradaBR {
@XmlElement(required = true)
protected String tailNumber;
@XmlElement(name = "OnAirShopping")
protected boolean onAirShopping;
@XmlElement(name = "AlertsOnAir")
protected boolean alertsOnAir;
@XmlElement(name = "CancelFlight")
protected boolean cancelFlight;
@XmlElement(name = "ActualIngate")
protected boolean actualIngate;
@XmlElement(name = "ActualOutgate")
protected boolean actualOutgate;
@XmlElement(name = "EstimatedIngate")
protected boolean estimatedIngate;
@XmlElement(name = "EstimatedOutgate")
protected boolean estimatedOutgate;
@XmlElement(name = "Status", required = true)
protected String status;
@XmlElement(name = "Combustible")
protected int combustible;
/**
* Obtiene el valor de la propiedad tailNumber.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTailNumber() {
return tailNumber;
}
/**
* Define el valor de la propiedad tailNumber.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setTailNumber(String value) {
this.tailNumber = value;
}
/**
* Obtiene el valor de la propiedad onAirShopping.
*
*/
public boolean isOnAirShopping() {
return onAirShopping;
}
/**
* Define el valor de la propiedad onAirShopping.
*
*/
public void setOnAirShopping(boolean value) {
this.onAirShopping = value;
}
/**
* Obtiene el valor de la propiedad alertsOnAir.
*
*/
public boolean isAlertsOnAir() {
return alertsOnAir;
}
/**
* Define el valor de la propiedad alertsOnAir.
*
*/
public void setAlertsOnAir(boolean value) {
this.alertsOnAir = value;
}
/**
* Obtiene el valor de la propiedad cancelFlight.
*
*/
public boolean isCancelFlight() {
return cancelFlight;
}
/**
* Define el valor de la propiedad cancelFlight.
*
*/
public void setCancelFlight(boolean value) {
this.cancelFlight = value;
}
/**
* Obtiene el valor de la propiedad actualIngate.
*
*/
public boolean isActualIngate() {
return actualIngate;
}
/**
* Define el valor de la propiedad actualIngate.
*
*/
public void setActualIngate(boolean value) {
this.actualIngate = value;
}
/**
* Obtiene el valor de la propiedad actualOutgate.
*
*/
public boolean isActualOutgate() {
return actualOutgate;
}
/**
* Define el valor de la propiedad actualOutgate.
*
*/
public void setActualOutgate(boolean value) {
this.actualOutgate = value;
}
/**
* Obtiene el valor de la propiedad estimatedIngate.
*
*/
public boolean isEstimatedIngate() {
return estimatedIngate;
}
/**
* Define el valor de la propiedad estimatedIngate.
*
*/
public void setEstimatedIngate(boolean value) {
this.estimatedIngate = value;
}
/**
* Obtiene el valor de la propiedad estimatedOutgate.
*
*/
public boolean isEstimatedOutgate() {
return estimatedOutgate;
}
/**
* Define el valor de la propiedad estimatedOutgate.
*
*/
public void setEstimatedOutgate(boolean value) {
this.estimatedOutgate = value;
}
/**
* Obtiene el valor de la propiedad status.
*
* @return
* possible object is
* {@link String }
*
*/
public String getStatus() {
return status;
}
/**
* Define el valor de la propiedad status.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setStatus(String value) {
this.status = value;
}
/**
* Obtiene el valor de la propiedad combustible.
*
*/
public int getCombustible() {
return combustible;
}
/**
* Define el valor de la propiedad combustible.
*
*/
public void setCombustible(int value) {
this.combustible = value;
}
}
| [
"frank.rb27@hotmail.com"
] | frank.rb27@hotmail.com |
0c97115f7823bc2eae0797d98995b2352a0b2812 | 4be72dee04ebb3f70d6e342aeb01467e7e8b3129 | /bin/ext-integration/sap/synchronousOM/sapordermgmtbol/src/de/hybris/platform/sap/sapordermgmtbol/transaction/salesdocument/backend/interf/erp/ConstantsR3Lrd.java | 81e711a4f4767373d6fd4f2d8519821045c1a9e4 | [] | no_license | lun130220/hybris | da00774767ba6246d04cdcbc49d87f0f4b0b1b26 | 03c074ea76779f96f2db7efcdaa0b0538d1ce917 | refs/heads/master | 2021-05-14T01:48:42.351698 | 2018-01-07T07:21:53 | 2018-01-07T07:21:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,529 | java | /*
* [y] hybris Platform
*
* Copyright (c) 2000-2015 hybris AG
* All rights reserved.
*
* This software is the confidential and proprietary information of hybris
* ("Confidential Information"). You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the
* license agreement you entered into with hybris.
*
*
*/
package de.hybris.platform.sap.sapordermgmtbol.transaction.salesdocument.backend.interf.erp;
import java.util.Date;
/**
* Interface containing names of function modules and UI Elements, RFC
* Constants, field names <br>
*
* @version 1.0
*/
public interface ConstantsR3Lrd {
/**
* Represents an initial date for the ERP backend layer.
*/
public static final Date DATE_INITIAL = new Date(0);
/**
* ID of function module ERP_LORD_SET to set sales document data in ERP.
*/
public static final String FM_LO_API_SET = "ERP_LORD_SET";
/**
* ID of function module ERP_LORD_DO_ACTIONS to perform LO-API actions.
*/
public static final String FM_LO_API_DO_ACTIONS = "ERP_LORD_DO_ACTIONS";
/**
* ID of function module ERP_LORD_LOAD which starts a LO-API session in ERP.
*/
public static final String FM_LO_API_LOAD = "ERP_WEC_ORDER_LOAD";
/**
* ID of function module ERP_LORD_SAVE which saves the sales document data
* in ERP.
*/
public static final String FM_LO_API_SAVE = "ERP_LORD_SAVE";
/**
* ID of function module ERP_LORD_SET_ACTIVE_FIELDS which sets the LORD
* active fields in ERP.
*/
public static final String FM_LO_API_SET_ACTIVE_FIELDS = "ERP_LORD_SET_ACTIVE_FIELDS";
/**
* ID of function module ERP_LORD_SET_VCFG_ALL which sets data of
* configurable products in ERP.
*/
public static final String FM_LO_API_SET_VCFG_ALL = "ERP_LORD_SET_VCFG_ALL";
/**
* ID of function module ERP_WEC_GET_VCFG_ALL which gets data of
* configurable products in ERP.
*/
public static final String FM_WEC_API_GET_VCFG_ALL = "ERP_WEC_GET_VCFG_ALL";
/**
* ID of function module ERP_WEC_ORDER_GET which reads all necessary
* attributes of a sales document via LO-API.
*/
public static final String FM_LO_API_WEC_ORDER_GET = "ERP_WEC_ORDER_GET";
/**
* ID of function module ERP_LORD_CLOSE which closes a LO-API session
*/
public static final String FM_LO_API_CLOSE = "ERP_LORD_CLOSE";
/**
* ID of function module ERP_LORD_COPY which copies a LO-API document, e.g.
* when an order is created referring to a quotation
*/
public static final String FM_LO_API_COPY = "ERP_LORD_COPY";
/**
* Ignore message variables for message comparison. This attribute needs to
* be passed for the first message variable. The contents of the other ones
* are then ignored.
*/
public static final String MESSAGE_IGNORE_VARS = "*";
/* Attributes for dynamic field control */
/** UI element */
public static String UI_ELEMENT_PURCHASE_ORDER_EXT = "order.purchaseOrderExt";
/** UI element */
public static String UI_ELEMENT_SHIPPING_METHOD = "order.shippingMethod";
/** UI element */
public static String UI_ELEMENT_HEADER_TEXT = "order.headerText";
/** UI element */
public static String UI_ELEMENT_SHIPPING_COUNTRY = "order.shippingCountry";
/** UI element */
public static String UI_ELEMENT_DELIVERY_REGION = "order.deliveryRegion";
/** UI element */
public static String UI_ELEMENT_DELIVERY_TYPE = "order.deliveryType";
/** UI element */
public static String UI_ELEMENT_DISCOUNTS = "order.rebatesValue";
/** UI element */
public static String UI_ELEMENT_HEADER_USERSTATUS = "order.userStatusList";
/** UI element */
public static String UI_ELEMENT_REFERENCES = "order.extRefNumbers";
/** UI element */
public static String UI_ELEMENT_RECALL_ID = "order.recallId";
/** UI element */
public static String UI_ELEMENT_EXT_REF_OBJECTS = "order.extRefObjects";
/** UI element */
public static String UI_ELEMENT_ITEM_REQDELIVDATE = "item.reqDeliveryDate";
/** UI element */
public static String UI_ELEMENT_ITEM_OVERALLSTATUS = "item.overallStatus";
// not there in UI control now
/** UI element */
public static String UI_ELEMENT_ITEM_DESCRIPTION = "item.description";
/**
* UI element: Item text
*/
public static String UI_ELEMENT_ITEM_TEXT = "item.itemText";
/** UI element */
public static String UI_ELEMENT_ITEM_PRODUCT = "item.productID";
/** UI element */
public static String UI_ELEMENT_ITEM_PRODUCT_ID = "item.productGUID";
/** UI element */
// not there in UI control now
public static String UI_ELEMENT_ITEM_LATESTDELIVDATE = "item.latestDelivDate"; // not
/** UI element */
public static String UI_ELEMENT_ITEM_PAYTERMS = "item.paymentterms";
/** UI element */
public static String UI_ELEMENT_ITEM_QTY = "item.quantity";
/** UI element */
public static String UI_ELEMENT_ITEM_UNIT = "item.unit";
/** UI element */
// not there in UI control now
public static String UI_ELEMENT_ITEM_DELIVPRIO = "item.deliveryPriority";
/** UI element */
public static String UI_ELEMENT_ITEM_DELIVERTO = "item.deliverTo";
/** UI element */
public static String UI_ELEMENT_ITEM_CONFIG = "item.configuration";
/** UI element */
public static String UI_GROUP_ORDER = "order.header";
/** UI element */
public static String UI_GROUP_ITEM = "order.item";
/** UI element */
public static String UI_ELEMENT_ITEM_USERSTATUS = "item.userStatusList";
/** text control constant */
public static String LF = "\n";
/** text control constant */
public static String SEPARATOR = "/";
/** RFC constant. */
public static String BAPI_RETURN_ERROR = "E";
/** RFC constant. */
public static String BAPI_RETURN_WARNING = "W";
/** RFC constant. */
public static String BAPI_RETURN_INFO = "I";
/** RFC constant. */
public static String BAPI_RETURN_ABORT = "A";
/** RFC constant. */
public static String ROLE_CONTACT = "AP";
/** RFC constant. */
public static String ROLE_SOLDTO = "AG";
/** RFC constant. */
public static String ROLE_SHIPTO = "WE";
/** RFC constant. */
public static String ROLE_BILLPARTY = "RE";
/** RFC constant. */
public static String ROLE_PAYER = "RG";
/**
* The scenario ID for the LO-API call. Will not be persistet, but can be
* used to control LO-API processing.
*/
public static String scenario_LO_API_WEC = "CRM_WEC";
/** ABAP constant */
public static String ABAP_TRUE = "X";
/*
* A list of commonly used RFC constants, to save memory via reducing the
* number of static strings
*/
/** field name */
public static String FIELD_HANDLE = "HANDLE";
/**
* Represents item number in SD
*/
public static String FIELD_POSNR = "POSNR";
/** field name */
public static String FIELD_HANDLE_PARENT = "HANDLE_PARENT";
/** field name */
public static String FIELD_OBJECT_ID = "OBJECT_ID";
/** field name */
public static String FIELD_ID = "ID";
/** field name */
public static String FIELD_SPRAS_ISO = "SPRAS_ISO";
/** field name */
public static String FIELD_TEXT_STRING = "TEXT_STRING";
/** field name */
public static String FIELD_HANDLE_ITEM = "HANDLE_ITEM";
}
| [
"lun130220@gamil.com"
] | lun130220@gamil.com |
c0a6ec7ba4ac3822b473bb438ade66fb96de4c44 | 1b15fe5acedc014df2e0ae108a4c929dccf0911d | /src/main/java/com/turk/delayprobe/TaskDataEntry.java | fe47c6040cf3cf33f41e1d8f1f1269006f0f054d | [] | no_license | feinzaghi/Capricorn | 9fb9593828e4447a9735079bad6b440014f322b3 | e1fca2926b1842577941b070a826a2448739a2e8 | refs/heads/master | 2020-06-14T11:43:29.627233 | 2017-01-24T03:19:28 | 2017-01-24T03:19:28 | 75,029,435 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 11,661 | java | package com.turk.delayprobe;
import java.sql.Connection;
import java.sql.Timestamp;
import java.util.*;
import javax.servlet.jsp.jstl.sql.Result;
import org.apache.commons.net.ftp.*;
import org.apache.log4j.Logger;
import com.turk.config.ConstDef;
import com.turk.config.SystemConfig;
import com.turk.task.CollectObjInfo;
import com.turk.templet.*;
import com.turk.util.CommonDB;
import com.turk.util.LogMgr;
import com.turk.util.Util;
public class TaskDataEntry
{
private CollectObjInfo taskInfo;
private TaskDataEntry pre;
private int eqCount;
private int probeCount;
private boolean isNoError;
private List<DataEntry> entrys = new ArrayList<DataEntry>();
private ProbeLogger probeLogger;
private static Logger logger = LogMgr.getInstance().getSystemLogger();
public TaskDataEntry(CollectObjInfo taskInfo)
{
this.taskInfo = taskInfo;
this.isNoError = init();
}
public void addEntry(DataEntry de)
{
if ((de != null) && (!this.entrys.contains(de)))
{
this.entrys.add(de);
}
}
public List<DataEntry> getAll()
{
return this.entrys;
}
public ProbeLogger getProbeLogger()
{
return this.probeLogger;
}
public void setProbeLogger(ProbeLogger probeLogger)
{
this.probeLogger = probeLogger;
}
private Connection getConnection(CollectObjInfo task, int iSleepTime, byte maxTryTimes)
{
if (task == null) {
return null;
}
Connection conn = null;
conn = CommonDB.getConnection(task.getDBDriver(), task.getDBUrl(), task.getDevInfo().getHostUser(), task.getDevInfo().getHostPwd());
if (conn == null)
{
String strLog = "Task-" + task.getTaskID();
logger.error(strLog + ": 获取对方数据库连接失败,尝试重连 ... ");
byte tryTimes = 0;
int sleepTime = iSleepTime;
while ((tryTimes < maxTryTimes) && (conn == null))
{
try
{
Thread.sleep(sleepTime);
}
catch (InterruptedException e)
{
break;
}
conn = CommonDB.getConnection(task.getDBDriver(), task.getDBUrl(), task.getDevInfo().getHostUser(), task.getDevInfo().getHostPwd());
tryTimes = (byte)(tryTimes + 1);
if (conn == null)
{
logger.error(strLog + ": 尝试数据库重连失败 (" + tryTimes + ") ... ");
}
sleepTime += sleepTime * 2;
}
if (conn == null)
{
logger.error(strLog + ": 多次获取对方数据库连接失败.");
}
else
{
logger.info(strLog + ": 数据库重连成功(" + tryTimes + ").");
}
}
return conn;
}
private boolean init()
{
Connection con = null;
try
{
if (taskInfo.getCollectType() == 6 || taskInfo.getCollectType() == 60)
{
int parseTempletId = taskInfo.getParseTmpID();
Result rs = CommonDB.queryForResult((new StringBuilder("select tempfilename from utl_conf_templet where tmpid=")).append(parseTempletId).toString());
String fileName = rs.getRows()[0].get("tempfilename").toString();
AbstractTempletBase p = ((AbstractTempletBase) (taskInfo.getCollectType() != 6 ? ((AbstractTempletBase) (new DBAutoTempletP2())) : ((AbstractTempletBase) (new DBAutoTempletP()))));
p.parseTemp(fileName);
Map<?, ?> tables = (Map<?, ?>)p.getClass().getDeclaredMethod("getTemplets", new Class[0]).invoke(p, new Object[0]);
con = CommonDB.getConnection(taskInfo.getDBDriver(), taskInfo.getDBUrl(), taskInfo.getDevInfo().getHostUser(), taskInfo.getDevInfo().getHostPwd());
if (con == null)
con = getConnection(taskInfo, 100, (byte)3);
if (con == null)
throw new Exception("获取对方数据库连接失败");
String selectStatement;
String next;
long size;
for (Iterator<?> it = tables.keySet().iterator(); it.hasNext(); entrys.add(new DataEntry((new StringBuilder(String.valueOf(next))).append(" [实际采集所用语句:").append(selectStatement).append("]").toString(), size)))
{
selectStatement = null;
next = (String)it.next();
Object sql = tables.get(next).getClass().getDeclaredMethod("getSql", new Class[0]).invoke(tables.get(next), new Object[0]);
sql = sql != null ? ((Object) (sql.toString())) : "";
Object condition = tables.get(next).getClass().getDeclaredMethod("getCondition", new Class[0]).invoke(tables.get(next), new Object[0]);
condition = condition != null ? ((Object) (condition.toString())) : "";
if (Util.isNotNull(sql.toString()))
selectStatement = ConstDef.ParseFilePathForDB(sql.toString(), taskInfo.getLastCollectTime());
else
if (Util.isNotNull(condition.toString()))
{
String tmp = ConstDef.ParseFilePathForDB(next, taskInfo.getLastCollectTime());
selectStatement = ConstDef.ParseFilePathForDB((new StringBuilder("select * from ")).append(tmp).append(" where ").append(condition.toString()).toString(), taskInfo.getLastCollectTime());
} else
{
String tmp = ConstDef.ParseFilePathForDB(next, taskInfo.getLastCollectTime());
selectStatement = ConstDef.ParseFilePathForDB((new StringBuilder("select * from ")).append(tmp).toString(), taskInfo.getLastCollectTime());
}
size = 0L;
try
{
if (CommonDB.tableExists(con, next, taskInfo.getTaskID()))
{
size = CommonDB.getRowCount(con, selectStatement);
Thread.sleep(50L);
} else
{
size = -1L;
}
}
catch (Exception e)
{
throw e;
}
}
}
else if (taskInfo.getCollectType() == 3 && SystemConfig.getInstance().isProbeFTP())
{
String encode = taskInfo.getDevInfo().getEncode();
String collectPaths[] = taskInfo.getCollectPath().split(";");
FTPClient ftp = new FTPClient();
ftp.connect(taskInfo.getDevInfo().getIP(), taskInfo.getDevPort());
ftp.login(taskInfo.getDevInfo().getHostUser(), taskInfo.getDevInfo().getHostPwd());
ftp.enterLocalPassiveMode();
setFTPClientConfig(ftp);
Set<String> tmp = new HashSet<String>();
String as[];
int k = (as = collectPaths).length;
for (int i = 0; i < k; i++)
{
String path = as[i];
if (!Util.isNull(path))
{
List<String> list = Util.listFTPDirs(path, taskInfo.getDevInfo().getIP(), taskInfo.getDevPort(), taskInfo.getDevInfo().getHostUser(),
taskInfo.getDevInfo().getHostPwd(), encode, false);
tmp.addAll(list);
}
}
collectPaths = (String[])tmp.toArray(new String[0]);
k = (as = collectPaths).length;
for (int j = 0; j < k; j++)
{
String path = as[j];
String fileName = ConstDef.ParseFilePath(path, taskInfo.getLastCollectTime());
String o = fileName;
fileName = Util.isNotNull(encode) ? new String(fileName.getBytes(encode), "iso_8859_1") : fileName;
FTPFile fs[] = ftp.listFiles(fileName);
if (fs.length == 0)
{
entrys.add(new DataEntry(o, -1L));
}
else
{
FTPFile aftpfile[];
int i1 = (aftpfile = fs).length;
for (int l = 0; l < i1; l++)
{
FTPFile f = aftpfile[l];
if (f != null)
if (o.lastIndexOf("/") >= 0)
{
String str = o.substring(0, fileName.lastIndexOf("/") + 1);
entrys.add(new DataEntry((new StringBuilder(String.valueOf(str))).append(f.getName()).toString(), f.getSize()));
} else
{
entrys.add(new DataEntry(Util.isNotNull(encode) ? new String(f.getName().getBytes("iso_8859_1"), encode) : f.getName(), f.getSize()));
}
}
}
}
ftp.disconnect();
}
else
{
throw new Exception((new StringBuilder("不支持的采集类型:")).append(taskInfo.getCollectType()).toString());
}
}
catch (Exception e)
{
logger.error("获取采集目标时异常", e);
}
if (con != null)
{
try
{
con.close();
}
catch (Exception exception1)
{
return false;
}
}
if (con != null)
{
try
{
con.close();
}
catch
(Exception exception2)
{ }
}
if (con != null)
{
try
{
con.close();
}
catch (Exception exception3)
{ }
}
return true;
}
public boolean isNoError()
{
return this.isNoError;
}
public TaskDataEntry getPre()
{
return this.pre;
}
public void setPre(TaskDataEntry pre)
{
this.pre = pre;
}
public int getEqCount()
{
return this.eqCount;
}
public void setEqCount(int eqCount)
{
this.eqCount = eqCount;
}
public int getProbeCount()
{
return this.probeCount;
}
public void setProbeCount(int probeCount)
{
this.probeCount = probeCount;
}
private String formart(int max, int length)
{
if (length >= max)
return " ";
StringBuilder sb = new StringBuilder();
int diff = max - length;
for (int i = 0; i < diff; i++)
{
sb.append(" ");
}
sb.append(" ");
return sb.toString();
}
private int maxLength(List<DataEntry> list)
{
int max = 0;
for (DataEntry de : list)
{
if (de.getName().length() < max)
continue;
max = de.getName().length();
}
return max;
}
private void setFTPClientConfig(FTPClient ftp)
{
try
{
ftp.configure(new FTPClientConfig("UNIX"));
if (!Util.isFileNotNull(ftp.listFiles("/*")))
{
ftp.configure(new FTPClientConfig("WINDOWS"));
}
else
{
return;
}
if (!Util.isFileNotNull(ftp.listFiles("/*")))
{
ftp.configure(new FTPClientConfig("AS/400"));
}
else
{
return;
}
if (!Util.isFileNotNull(ftp.listFiles("/*")))
{
ftp.configure(new FTPClientConfig("TYPE: L8"));
}
else
{
return;
}
if (!Util.isFileNotNull(ftp.listFiles("/*")))
{
ftp.configure(new FTPClientConfig("MVS"));
}
else
{
return;
}
if (!Util.isFileNotNull(ftp.listFiles("/*")))
{
ftp.configure(new FTPClientConfig("NETWARE"));
}
else
{
return;
}
if (!Util.isFileNotNull(ftp.listFiles("/*")))
{
ftp.configure(new FTPClientConfig("OS/2"));
}
else
{
return;
}
if (!Util.isFileNotNull(ftp.listFiles("/*")))
{
ftp.configure(new FTPClientConfig("OS/400"));
}
else
{
return;
}
if (!Util.isFileNotNull(ftp.listFiles("/*")))
{
ftp.configure(new FTPClientConfig("VMS"));
}
else
{
return;
}
}
catch (Exception e)
{
logger.error("配置FTP客户端时异常", e);
}
}
public boolean compare()
{
boolean b = false;
int preCount = 0;
int thisCount = 0;
int max = maxLength(getAll());
for (DataEntry de : getAll())
{
this.probeLogger.println("表名/文件名:" + de.getName() +
formart(max, de.getName().length()) + "记录数/尺寸:" + (
de.getSize() == -1L ? "不存在" : Long.valueOf(de.getSize())));
thisCount = (int)(thisCount + de.getSize());
}
if (this.pre != null)
{
for (DataEntry de : this.pre.getAll())
{
preCount = (int)(preCount + de.getSize());
}
if (preCount == thisCount)
{
this.eqCount += 1;
b = true;
}
else
{
this.eqCount = 0;
}
}
return b;
}
public static void main(String[] args)
throws Exception
{
CollectObjInfo info = new CollectObjInfo(433);
info.setLastCollectTime(new Timestamp(Util.getDate1("2010-07-10 00:00:00").getTime()));
info.setCollectType(60);
info.setParseTmpID(731);
TaskDataEntry t = new TaskDataEntry(info);
System.out.println(t.getAll());
}
} | [
"huangxiao227@gmail.com"
] | huangxiao227@gmail.com |
2305779877b4dcebd75c7ad42be54eefeb827072 | a95fbe4532cd3eb84f63906167f3557eda0e1fa3 | /src/main/java/l2f/gameserver/network/loginservercon/gspackets/PlayerInGame.java | afb904f9642404e9c6eb3dd20d2b6fd78b36fd91 | [
"MIT"
] | permissive | Kryspo/L2jRamsheart | a20395f7d1f0f3909ae2c30ff181c47302d3b906 | 98c39d754f5aba1806f92acc9e8e63b3b827be49 | refs/heads/master | 2021-04-12T10:34:51.419843 | 2018-03-26T22:41:39 | 2018-03-26T22:41:39 | 126,892,421 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 351 | java | package l2f.gameserver.network.loginservercon.gspackets;
import l2f.gameserver.network.loginservercon.SendablePacket;
public class PlayerInGame extends SendablePacket
{
private String account;
public PlayerInGame(String account)
{
this.account = account;
}
@Override
protected void writeImpl()
{
writeC(0x03);
writeS(account);
}
}
| [
"cristianleon48@gmail.com"
] | cristianleon48@gmail.com |
784a3a32fb862e89868dba784f30ce996d488fdc | 61a2d341255eb0d9658c2c0447d5ebb9f253becf | /src/main/java/com/supconit/kqfx/web/xtgl/entities/ExtPerson.java | a9eaa9ab3d8b7d142e1fa933ede559188a33ea0c | [] | no_license | aouoxx/yjfxzf | 07a651bbd2aeaf0978b3894091baea89b6dac723 | e9b189d33bf3490891b6f9527193ce0bb9204a38 | refs/heads/master | 2021-09-15T23:59:31.997293 | 2018-03-12T21:32:52 | 2018-03-12T21:32:52 | 124,951,224 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 6,507 | java | package com.supconit.kqfx.web.xtgl.entities;
import hc.orm.search.SQLTerm;
import hc.orm.search.Term;
import java.util.ArrayList;
import java.util.List;
import jodd.util.StringUtil;
import com.supconit.honeycomb.business.organization.entities.Person;
public class ExtPerson extends Person {
/**
*
*/
private static final long serialVersionUID = 8748027901147925280L;
private String jgxxJgmc;
/** 所属机构ID */
protected Long jgbh;
/** 性别 */
protected String ryxb;
/** 出生日期 */
protected String rycsrq;
/** 证件类型 */
protected String ryzjlx;
/** 证件号码 */
protected String ryzjhm;
/** 民族 */
protected String rymz;
/** 政治面貌 */
protected String ryzzmm;
/** 进机构时间 */
protected String ryjjgsj;
/** 职务 */
protected String ryzw;
/** 学历 */
protected String ryxl;
/** 毕业学校 */
protected String rybyxx;
/** 所学专业 */
protected String rysxzy;
/** 职称 */
protected String ryzc;
/** 手机号码 */
protected String rysjhm;
/** 联系方式 */
protected String rylxfs;
/** 传真 */
protected String rycz;
/** 电子邮箱 */
protected String rydzyx;
protected Long departmentId;
protected String rygh;
protected String ryxnw;
private String departmentName;
/** 机构信息 */
protected Jgxx jgxx;
protected ExtDepartment department;
/*机构等级,用于查询条件,此查询条件与jgbh互斥*/
private String jgdj;
/* 机构编号列表 如:"1,2,3"用逗号分隔 此查询条件与jgbh、jgdj互斥*/
private String jgbhs;
public String getJgxxJgmc() {
return jgxxJgmc;
}
public void setJgxxJgmc(String jgxxJgmc) {
this.jgxxJgmc = jgxxJgmc;
}
/**
* 是否选中
*/
private String checked;
/**
*
*/
public ExtPerson() {
super();
}
/**
*
* @param id
*/
public ExtPerson(long id) {
setId(id);
}
public Long getJgbh() {
return jgbh;
}
public void setJgbh(Long jgbh) {
this.jgbh = jgbh;
}
public String getRyxb() {
return ryxb;
}
public void setRyxb(String ryxb) {
this.ryxb = ryxb;
}
public String getRycsrq() {
return rycsrq;
}
public void setRycsrq(String rycsrq) {
this.rycsrq = rycsrq;
}
public String getRyzjlx() {
return ryzjlx;
}
public void setRyzjlx(String ryzjlx) {
this.ryzjlx = ryzjlx;
}
public String getRyzjhm() {
return ryzjhm;
}
public void setRyzjhm(String ryzjhm) {
this.ryzjhm = ryzjhm;
}
public String getRymz() {
return rymz;
}
public void setRymz(String rymz) {
this.rymz = rymz;
}
public String getRyzzmm() {
return ryzzmm;
}
public void setRyzzmm(String ryzzmm) {
this.ryzzmm = ryzzmm;
}
public String getRyjjgsj() {
return ryjjgsj;
}
public void setRyjjgsj(String ryjjgsj) {
this.ryjjgsj = ryjjgsj;
}
public String getRyzw() {
return ryzw;
}
public void setRyzw(String ryzw) {
this.ryzw = ryzw;
}
public String getRyxl() {
return ryxl;
}
public void setRyxl(String ryxl) {
this.ryxl = ryxl;
}
public String getRybyxx() {
return rybyxx;
}
public void setRybyxx(String rybyxx) {
this.rybyxx = rybyxx;
}
public String getRysxzy() {
return rysxzy;
}
public void setRysxzy(String rysxzy) {
this.rysxzy = rysxzy;
}
public String getRyzc() {
return ryzc;
}
public void setRyzc(String ryzc) {
this.ryzc = ryzc;
}
public String getRysjhm() {
return rysjhm;
}
public void setRysjhm(String rysjhm) {
this.rysjhm = rysjhm;
}
public String getRylxfs() {
return rylxfs;
}
public void setRylxfs(String rylxfs) {
this.rylxfs = rylxfs;
}
public String getRycz() {
return rycz;
}
public void setRycz(String rycz) {
this.rycz = rycz;
}
public String getRydzyx() {
return rydzyx;
}
public void setRydzyx(String rydzyx) {
this.rydzyx = rydzyx;
}
public Long getDepartmentId() {
return departmentId;
}
public void setDepartmentId(Long departmentId) {
this.departmentId = departmentId;
}
public String getRygh() {
return rygh;
}
public void setRygh(String rygh) {
this.rygh = rygh;
}
public String getRyxnw() {
return ryxnw;
}
public void setRyxnw(String ryxnw) {
this.ryxnw = ryxnw;
}
public Jgxx getJgxx() {
return jgxx;
}
public void setJgxx(Jgxx jgxx) {
this.jgxx = jgxx;
}
public ExtDepartment getDepartment() {
return department;
}
public void setDepartment(ExtDepartment department) {
this.department = department;
}
public String getJgdj() {
return jgdj;
}
public void setJgdj(String jgdj) {
this.jgdj = jgdj;
}
public String getJgbhs() {
return jgbhs;
}
public void setJgbhs(String jgbhs) {
this.jgbhs = jgbhs;
}
public String getDepartmentName() {
return departmentName;
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
public String getChecked() {
return checked;
}
public void setChecked(String checked) {
this.checked = checked;
}
/*
* @see hc.base.domains.Tableable#getTableName()
*/
@Override
public String getTableName() {
return TABLE_NAME;
}
@Override
public Term getTerm(String prefix) {
StringBuilder sql = new StringBuilder();
List<Object> params = new ArrayList<Object>();
if (StringUtil.isNotBlank(this.getCode())) {
buildSQLLike(sql, prefix, "CODE");
params.add("%" + this.getCode() + "%");
}
if (StringUtil.isNotBlank(this.getName())) {
buildSQLLike(sql, prefix, "NAME");
params.add("%" + this.getName() + "%");
}
if(StringUtil.isNotBlank(this.getJgbhs())){
if (StringUtil.isNotBlank(prefix)) {
sql.append("AND " + prefix).append(".");
}
sql.append("JGBH IN ( "+ this.getJgbhs()+" )");
}else{
if(null != this.getJgbh() && this.getJgbh() > 1){
buildSQLAnd(sql, prefix, "JGBH");
params.add(this.getJgbh());
}else{
if(StringUtil.isNotBlank(this.getJgdj())) {
if (StringUtil.isNotBlank(prefix)) {
// sql.append(prefix).append(".");
sql.append("AND " + prefix).append(".");
}
sql.append("JGBH IN ( select id from " + Jgxx.TABLE_NAME+ " where jgdj = ? )");
params.add(this.getJgdj());
}
}
}
if (sql.indexOf("AND ") == 0) sql.delete(0, 3);
SQLTerm term = new SQLTerm(sql.toString());
term.setParams(params.toArray());
return term;
}
}
| [
"aouo1987@163.com"
] | aouo1987@163.com |
73b24d64d3287991d560c06012efad5f73364df9 | fa2223e25fab70b8483d54f5fdbb897fa0887137 | /arcMenu/build/generated/source/r/debug/com/criptext/R.java | 3d495bed6836753a5a874b1bdcd4dabdf49030ae | [] | no_license | Criptext/ArcMenu | eafeaf4ea544cd4aa10678dab2529196f7a0daff | b51107a86c2e5273b33950dffe3e615d2d45750e | refs/heads/master | 2021-01-11T11:35:14.780882 | 2016-12-20T00:41:04 | 2016-12-20T00:41:04 | 76,908,605 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,024 | java | /* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.criptext;
public final class R {
public static final class attr {
/** <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
<p>May be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
*/
public static int childSize=0x7f010000;
/** <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
<p>May be a floating point value, such as "<code>1.2</code>".
*/
public static int fromDegrees=0x7f010001;
/** <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
<p>This may also be a reference to a resource (in the form
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
theme attribute (in the form
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
containing a value of this type.
*/
public static int leftHolderWidth=0x7f010003;
/** <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
<p>May be a floating point value, such as "<code>1.2</code>".
*/
public static int toDegrees=0x7f010002;
}
public static final class color {
public static int bg_grey=0x7f040000;
public static int light_gray=0x7f040001;
}
public static final class dimen {
public static int max_Height=0x7f050000;
public static int max_circle=0x7f050001;
}
public static final class drawable {
public static int composer_button=0x7f020000;
public static int composer_button_normal=0x7f020001;
public static int composer_button_pressed=0x7f020002;
public static int composer_icn_plus=0x7f020003;
public static int composer_icn_plus_normal=0x7f020004;
public static int composer_icn_plus_pressed=0x7f020005;
public static int my_button=0x7f020006;
}
public static final class id {
public static int control_hint=0x7f060003;
public static int control_layout=0x7f060001;
public static int item_layout=0x7f060000;
public static int picture=0x7f060002;
}
public static final class layout {
public static int arc_menu=0x7f030000;
public static int ray_menu=0x7f030001;
}
public static final class styleable {
/** Attributes that can be used with a ArcLayout.
<p>Includes the following attributes:</p>
<table>
<colgroup align="left" />
<colgroup align="left" />
<tr><th>Attribute</th><th>Description</th></tr>
<tr><td><code>{@link #ArcLayout_childSize com.criptext:childSize}</code></td><td></td></tr>
<tr><td><code>{@link #ArcLayout_fromDegrees com.criptext:fromDegrees}</code></td><td></td></tr>
<tr><td><code>{@link #ArcLayout_toDegrees com.criptext:toDegrees}</code></td><td></td></tr>
</table>
@see #ArcLayout_childSize
@see #ArcLayout_fromDegrees
@see #ArcLayout_toDegrees
*/
public static final int[] ArcLayout = {
0x7f010000, 0x7f010001, 0x7f010002
};
/**
<p>This symbol is the offset where the {@link com.criptext.R.attr#childSize}
attribute's value can be found in the {@link #ArcLayout} array.
<p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
<p>May be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
@attr name com.criptext:childSize
*/
public static int ArcLayout_childSize = 0;
/**
<p>This symbol is the offset where the {@link com.criptext.R.attr#fromDegrees}
attribute's value can be found in the {@link #ArcLayout} array.
<p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
<p>May be a floating point value, such as "<code>1.2</code>".
@attr name com.criptext:fromDegrees
*/
public static int ArcLayout_fromDegrees = 1;
/**
<p>This symbol is the offset where the {@link com.criptext.R.attr#toDegrees}
attribute's value can be found in the {@link #ArcLayout} array.
<p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
<p>May be a floating point value, such as "<code>1.2</code>".
@attr name com.criptext:toDegrees
*/
public static int ArcLayout_toDegrees = 2;
/** Attributes that can be used with a ArcMenu.
<p>Includes the following attributes:</p>
<table>
<colgroup align="left" />
<colgroup align="left" />
<tr><th>Attribute</th><th>Description</th></tr>
<tr><td><code>{@link #ArcMenu_childSize com.criptext:childSize}</code></td><td></td></tr>
<tr><td><code>{@link #ArcMenu_fromDegrees com.criptext:fromDegrees}</code></td><td></td></tr>
<tr><td><code>{@link #ArcMenu_toDegrees com.criptext:toDegrees}</code></td><td></td></tr>
</table>
@see #ArcMenu_childSize
@see #ArcMenu_fromDegrees
@see #ArcMenu_toDegrees
*/
public static final int[] ArcMenu = {
0x7f010000, 0x7f010001, 0x7f010002
};
/**
<p>This symbol is the offset where the {@link com.criptext.R.attr#childSize}
attribute's value can be found in the {@link #ArcMenu} array.
<p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
<p>May be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
@attr name com.criptext:childSize
*/
public static int ArcMenu_childSize = 0;
/**
<p>This symbol is the offset where the {@link com.criptext.R.attr#fromDegrees}
attribute's value can be found in the {@link #ArcMenu} array.
<p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
<p>May be a floating point value, such as "<code>1.2</code>".
@attr name com.criptext:fromDegrees
*/
public static int ArcMenu_fromDegrees = 1;
/**
<p>This symbol is the offset where the {@link com.criptext.R.attr#toDegrees}
attribute's value can be found in the {@link #ArcMenu} array.
<p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
<p>May be a floating point value, such as "<code>1.2</code>".
@attr name com.criptext:toDegrees
*/
public static int ArcMenu_toDegrees = 2;
/** Attributes that can be used with a RayLayout.
<p>Includes the following attributes:</p>
<table>
<colgroup align="left" />
<colgroup align="left" />
<tr><th>Attribute</th><th>Description</th></tr>
<tr><td><code>{@link #RayLayout_leftHolderWidth com.criptext:leftHolderWidth}</code></td><td></td></tr>
</table>
@see #RayLayout_leftHolderWidth
*/
public static final int[] RayLayout = {
0x7f010003
};
/**
<p>This symbol is the offset where the {@link com.criptext.R.attr#leftHolderWidth}
attribute's value can be found in the {@link #RayLayout} array.
<p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
<p>This may also be a reference to a resource (in the form
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
theme attribute (in the form
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
containing a value of this type.
@attr name com.criptext:leftHolderWidth
*/
public static int RayLayout_leftHolderWidth = 0;
};
}
| [
"gabrielfima@live.com"
] | gabrielfima@live.com |
117c1997659f12f295a6b65e25becda209a33be4 | 2ec89a83db0057d6240c9c0136271abc1d58118b | /app/src/main/java/com/pencilbox/user/smartwallet/Database/FullIncome.java | 52a8d72fab5ab02ebec13bf97435f620a4633f9b | [] | no_license | syedtanvirahmad/smartwallet | 438dc44ff9d92c13426185ce5b1dbcf403d28475 | be7811e44a3fa5c6e3663c58a93446d23bd6dd09 | refs/heads/master | 2020-03-09T16:05:33.108935 | 2018-09-16T08:43:13 | 2018-09-16T08:43:13 | 128,875,760 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 204 | java | package com.pencilbox.user.smartwallet.Database;
/**
* Created by User on 12/3/2017.
*/
public class FullIncome {
public int id;
public double income_amount;
public String income_date;
}
| [
"bonny.ahmad@gmail.com"
] | bonny.ahmad@gmail.com |
fd3ce539d73c67e5e0b417f766ba63ffc5eeb97d | c0da86779f7037d9fa50499c470f8dd91fb11093 | /STS_Project/SpringDemo_1/src/org/wang/newinstance/HtmlCourse.java | 80c90218024cb9244ba636bca84ce0c9bd06c3af | [] | no_license | SuoSuo-Rocky/HaiYan_left_Pro | 9c96148a9fe9edc191b2aa1ba1a4caf55184d2e1 | 670aedee8b403141c5e81615dea89d28dfcd9ebb | refs/heads/master | 2023-01-12T07:12:53.602217 | 2019-07-07T06:20:25 | 2019-07-07T06:20:25 | 195,602,247 | 0 | 0 | null | 2023-01-05T20:39:51 | 2019-07-07T02:39:33 | JavaScript | UTF-8 | Java | false | false | 146 | java | package org.wang.newinstance;
public class HtmlCourse implements ICourse{
@Override
public void learn() {
System.out.println("ѧϰHTML");
}
}
| [
"dt1930dgbomb@aliyun.com"
] | dt1930dgbomb@aliyun.com |
e95dc61c7d5ab70394f66ccc14cd4a32cfab0254 | 9b324f5da4a137cebab05b3dec377de3a5edc74e | /src/main/java/com/luthynetwork/core/events/PlayerWalkEvent.java | d8b1ef3906b68660de25a68cff391001f29771af | [] | no_license | LuthyNetwork/LuthyCore | 4fd12d800df5c3757be069271d987cb5f0e970cc | 53b9536e91c65b99adb5ea9bee6316d31880f9cc | refs/heads/master | 2022-12-11T05:14:40.078442 | 2020-09-04T21:56:41 | 2020-09-04T21:56:41 | 292,422,688 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 562 | java | package com.luthynetwork.core.events;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerMoveEvent;
@AllArgsConstructor
public class PlayerWalkEvent extends Event {
@Getter private final PlayerMoveEvent move;
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}
| [
"huetroll1@gmail.com"
] | huetroll1@gmail.com |
17e4a349e9e9c143817d71eae7f5f65b6a52e9d3 | 68df5a46d9196784ff910d4fc23a97080bac1721 | /src/main/java/com/praxis/topics/repository/TopicRepository.java | ae0d9a525cddd679f6d97eea90a47dce5529e1e0 | [] | no_license | jtapiase/praxisapp | 407f6f4fd28c74532411e7f37e16ab11e3e55650 | a2e2a8f35abfbdb93432bed7e62d44968ebb9b6f | refs/heads/master | 2021-01-25T09:47:59.608853 | 2018-03-01T17:24:06 | 2018-03-01T17:24:06 | 123,320,965 | 0 | 0 | null | 2018-02-28T17:50:00 | 2018-02-28T17:50:00 | null | UTF-8 | Java | false | false | 392 | java | package com.praxis.topics.repository;
import com.praxis.topics.entity.Topic;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository("TopicRepository")
public interface TopicRepository extends MongoRepository<Topic, String> {
Topic findByName(String name);
List<Topic> findAll();
}
| [
"lualopezpe@unal.edu.co"
] | lualopezpe@unal.edu.co |
f718d013bdbca1a10932195c74479c4e9071c776 | 1476bbf47f2013d1b52bb7f55d2e8d08b7969b3e | /Hadoop/SIFT/hadoop-SIFT/hipi-SIFT/tools/covar/src/main/java/org/hipi/tools/covar/Covariance.java | 90b54eb647a0769b0a1f58899c9886d2a82f06f7 | [
"Apache-2.0"
] | permissive | felidsche/BigDataBench_V5.0_BigData_ComponentBenchmark | a031e78b82cacf098786d53faa1a4e9e745ee94f | c65c3df033b84dfb6d229f74e564d69cfe624556 | refs/heads/main | 2023-08-19T07:04:56.553436 | 2021-09-28T17:02:25 | 2021-09-28T17:02:25 | 406,797,617 | 0 | 0 | Apache-2.0 | 2021-09-15T14:20:49 | 2021-09-15T14:20:48 | null | UTF-8 | Java | false | false | 4,651 | java | package org.hipi.tools.covar;
import static org.bytedeco.javacpp.opencv_imgproc.CV_RGB2GRAY;
import org.hipi.image.FloatImage;
import org.hipi.image.HipiImageHeader.HipiColorSpace;
import org.hipi.opencv.OpenCVUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
import org.bytedeco.javacpp.opencv_imgproc;
import org.bytedeco.javacpp.opencv_core.Mat;
import java.io.IOException;
public class Covariance extends Configured implements Tool {
public static final int patchSize = 64; // Patch dimensions: patchSize x patchSize
public static final float sigma = 10; // Standard deviation of Gaussian weighting function
// Used to convert input FloatImages into grayscale OpenCV Mats in MeanMapper and CovarianceMapper
public static boolean convertFloatImageToGrayscaleMat(FloatImage image, Mat cvImage) {
// Convert FloatImage to Mat, and convert Mat to grayscale (if necessary)
HipiColorSpace colorSpace = image.getColorSpace();
switch(colorSpace) {
//if RGB, convert to grayscale
case RGB:
Mat cvImageRGB = OpenCVUtils.convertRasterImageToMat(image);
opencv_imgproc.cvtColor(cvImageRGB, cvImage, CV_RGB2GRAY);
return true;
//if LUM, already grayscale
case LUM:
cvImage = OpenCVUtils.convertRasterImageToMat(image);
return true;
//otherwise, color space is not supported for this example. Skip input image.
default:
System.out.println("HipiColorSpace [" + colorSpace + "] not supported in covar example. ");
return false;
}
}
private static void rmdir(String path, Configuration conf) throws IOException {
Path outputPath = new Path(path);
FileSystem fileSystem = FileSystem.get(conf);
if (fileSystem.exists(outputPath)) {
fileSystem.delete(outputPath, true);
}
}
private static void mkdir(String path, Configuration conf) throws IOException {
Path outputPath = new Path(path);
FileSystem fileSystem = FileSystem.get(conf);
if (!fileSystem.exists(outputPath)) {
fileSystem.mkdirs(outputPath);
}
}
private static void validateArgs(String[] args, Configuration conf) throws IOException {
if (args.length != 2) {
System.out.println("Usage: covar.jar <input HIB> <output directory>");
System.exit(1);
}
Path inputPath = new Path(args[0]);
FileSystem fileSystem = FileSystem.get(conf);
if (!fileSystem.exists(inputPath)) {
System.out.println("Input HIB does not exist at location: " + inputPath);
System.exit(1);
}
}
private static void validateMeanPath(String inputMeanPathString, Configuration conf)
throws IOException {
Path meanPath = new Path(inputMeanPathString);
FileSystem fileSystem = FileSystem.get(conf);
if (!fileSystem.exists(meanPath)) {
System.out.println("Mean patch does not exist at location: " + meanPath);
System.exit(1);
}
}
public int run(String[] args) throws Exception {
// Used for initial argument validation and hdfs configuration before jobs are run
Configuration conf = Job.getInstance().getConfiguration();
// Validate arguments before any work is done
validateArgs(args, conf);
// Build I/O path strings
String inputHibPath = args[0];
String outputBaseDir = args[1];
String outputMeanDir = outputBaseDir + "/mean-output/";
String outputCovarianceDir = outputBaseDir + "/covariance-output/";
String inputMeanPath = outputMeanDir + "part-r-00000"; //used to access ComputeMean result
// Set up directory structure
mkdir(outputBaseDir, conf);
rmdir(outputMeanDir, conf);
rmdir(outputCovarianceDir, conf);
// Run compute mean
if (ComputeMean.run(args, inputHibPath, outputMeanDir) == 1) {
System.out.println("Compute mean job failed to complete.");
return 1;
}
validateMeanPath(inputMeanPath, conf);
// Run compute covariance
if (ComputeCovariance.run(args, inputHibPath, outputCovarianceDir, inputMeanPath) == 1) {
System.out.println("Compute covariance job failed to complete.");
return 1;
}
// Indicate success
return 0;
}
// Main driver for full covariance computation
public static void main(String[] args) throws Exception {
int res = ToolRunner.run(new Covariance(), args);
System.exit(res);
}
}
| [
"gaowanling@ict.ac.cn"
] | gaowanling@ict.ac.cn |
b8533085077303210d172c8c1a5354a468f799a3 | 774d36285e48bd429017b6901a59b8e3a51d6add | /sources/com/google/android/gms/internal/ads/zzqh.java | 145223251a1faff223c4ee6077634048dfc4af1c | [] | no_license | jorge-luque/hb | 83c086851a409e7e476298ffdf6ba0c8d06911db | b467a9af24164f7561057e5bcd19cdbc8647d2e5 | refs/heads/master | 2023-08-25T09:32:18.793176 | 2020-10-02T11:02:01 | 2020-10-02T11:02:01 | 300,586,541 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 535 | java | package com.google.android.gms.internal.ads;
import android.app.Activity;
import android.app.Application;
/* compiled from: com.google.android.gms:play-services-ads@@19.1.0 */
final class zzqh implements zzqk {
private final /* synthetic */ Activity val$activity;
zzqh(zzqc zzqc, Activity activity) {
this.val$activity = activity;
}
public final void zza(Application.ActivityLifecycleCallbacks activityLifecycleCallbacks) {
activityLifecycleCallbacks.onActivityDestroyed(this.val$activity);
}
}
| [
"jorge.luque@taiger.com"
] | jorge.luque@taiger.com |
28caaf2848003be6b9ec99e320821cf3933ffdd0 | 576ca2c9629069915d09b1e36dc1acafb3ee2939 | /HackerRankJavaPractice/src/com/hackerrank/JavaBigDecimal.java | 0dab2caf87a7377107207e0df1b2e30693868e15 | [] | no_license | jgrodrigueza/CodingPractice | a97a48a7f07c1c958b5bb7b3f93111c97d8237c7 | 388f963fa1a092199c9dd6106611bf564746d118 | refs/heads/master | 2023-03-04T11:15:04.064309 | 2021-01-07T20:35:42 | 2021-01-07T20:35:42 | 316,969,174 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,072 | java | //https://www.hackerrank.com/challenges/java-bigdecimal/problem
package com.hackerrank;
import java.math.BigDecimal;
import java.util.*;
class JavaBigDecimal{
public static void main(String []args){
//Input
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
String []s=new String[n+2];
for(int i=0;i<n;i++){
s[i]=sc.next();
}
sc.close();
class BigDecimalComparator implements Comparator<String> {
@Override
public int compare(String string1, String string2) {
BigDecimal bd1 = new BigDecimal(string1);
BigDecimal bd2 = new BigDecimal(string2);
return bd2.compareTo(bd1);
}
}
String []strings = new String[n];
for(int i = 0; i < n;i++){
strings[i] = s[i];
}
Arrays.sort(strings, new BigDecimalComparator());
s = strings;
//Output
for(int i=0;i<n;i++)
{
System.out.println(s[i]);
}
}
} | [
"jgrodrigueza@users.noreply.github.com"
] | jgrodrigueza@users.noreply.github.com |
07ad67c04581d472ac8f361b6deb5664558ca77e | d0b0d4d5464dd4e387b7cfd2869187b99414b50d | /app/src/androidTest/java/co/devhack/todoapp/ExampleInstrumentedTest.java | bb2ce24f06bd3a501a5fbfd83aae5c546ce27232 | [] | no_license | carboleda/android-todo-app | 0a9a04e2fe26bead8afde6e9d73f260a7aec9964 | ac781d52e5a08b73fff5dbcf75bc1e120a872c25 | refs/heads/master | 2021-07-23T18:54:14.283514 | 2017-09-02T02:31:16 | 2017-09-02T02:31:16 | 102,163,113 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 740 | java | package co.devhack.todoapp;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("co.devhack.todoapp", appContext.getPackageName());
}
}
| [
"arbofercho@gmail.com"
] | arbofercho@gmail.com |
f1213d47301624040c3f76f43a2c4106de13034c | c3c848ae6c90313fed11be129187234e487c5f96 | /VC6PLATSDK/samples/Com/Services/Transaction/SampleBank/vjAcct/MsAdo15/_Parameter.java | 4343750059b72df3add38ddd7d04535e8d9b3253 | [] | no_license | timxx/VC6-Platform-SDK | 247e117cfe77109cd1b1effcd68e8a428ebe40f0 | 9fd59ed5e8e25a1a72652b44cbefb433c62b1c0f | refs/heads/master | 2023-07-04T06:48:32.683084 | 2021-08-10T12:52:47 | 2021-08-10T12:52:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,851 | java | //
// Auto-generated using JActiveX.EXE 5.00.2918
// ("D:\Program Files\Microsoft Visual Studio\VJ98\jactivex.exe" /wfc /w /xi /X:rkc /l "D:\DOCUME~1\erica\LOCALS~1\Temp\jvc22.tmp" /nologo /d "D:\mssdk\samples\Com\Services\Transaction\SampleBank\vjacct" "D:\Program Files\Common Files\System\ado\msado15.dll")
//
// WARNING: Do not remove the comments that include "@com" directives.
// This source file must be compiled by a @com-aware compiler.
// If you are using the Microsoft Visual J++ compiler, you must use
// version 1.02.3920 or later. Previous versions will not issue an error
// but will not generate COM-enabled class files.
//
package msado15;
import com.ms.com.*;
import com.ms.com.IUnknown;
import com.ms.com.Variant;
// Dual interface _Parameter
/** @com.interface(iid=0000050C-0000-0010-8000-00AA006D2EA4, thread=AUTO, type=DUAL) */
public interface _Parameter extends msado15._ADO
{
/** @com.method(vtoffset=4, dispid=500, type=PROPGET, name="Properties", name2="getProperties", addFlagsVtable=4)
@com.parameters([iid=00000504-0000-0010-8000-00AA006D2EA4,thread=AUTO,type=DISPATCH] return) */
public msado15.Properties getProperties();
/** @com.method(vtoffset=5, dispid=1610809344, type=PROPGET, name="Name", name2="getName", addFlagsVtable=4)
@com.parameters([type=STRING] return) */
public String getName();
/** @com.method(vtoffset=6, dispid=1610809344, type=PROPPUT, name="Name", name2="putName", addFlagsVtable=4)
@com.parameters([in,type=STRING] pbstr) */
public void setName(String pbstr);
/** @com.method(vtoffset=7, dispid=0, type=PROPGET, name="Value", name2="getValue", addFlagsVtable=4)
@com.parameters([type=VARIANT] return) */
public Variant getValue();
/** @com.method(vtoffset=8, dispid=0, type=PROPPUT, name="Value", name2="putValue", addFlagsVtable=4)
@com.parameters([in,type=VARIANT] pvar) */
public void setValue(Variant pvar);
/** @com.method(vtoffset=9, dispid=1610809348, type=PROPGET, name="Type", name2="getType", addFlagsVtable=4)
@com.parameters([type=I4] return) */
public int getType();
/** @com.method(vtoffset=10, dispid=1610809348, type=PROPPUT, name="Type", name2="putType", addFlagsVtable=4)
@com.parameters([in,type=I4] psDataType) */
public void setType(int psDataType);
/** @com.method(vtoffset=11, dispid=1610809350, type=PROPPUT, name="Direction", name2="putDirection", addFlagsVtable=4)
@com.parameters([in,type=I4] plParmDirection) */
public void setDirection(int plParmDirection);
/** @com.method(vtoffset=12, dispid=1610809350, type=PROPGET, name="Direction", name2="getDirection", addFlagsVtable=4)
@com.parameters([type=I4] return) */
public int getDirection();
/** @com.method(vtoffset=13, dispid=1610809352, type=PROPPUT, name="Precision", name2="putPrecision", addFlagsVtable=4)
@com.parameters([in,type=U1] pbPrecision) */
public void setPrecision(byte pbPrecision);
/** @com.method(vtoffset=14, dispid=1610809352, type=PROPGET, name="Precision", name2="getPrecision", addFlagsVtable=4)
@com.parameters([type=U1] return) */
public byte getPrecision();
/** @com.method(vtoffset=15, dispid=1610809354, type=PROPPUT, name="NumericScale", name2="putNumericScale", addFlagsVtable=4)
@com.parameters([in,type=U1] pbScale) */
public void setNumericScale(byte pbScale);
/** @com.method(vtoffset=16, dispid=1610809354, type=PROPGET, name="NumericScale", name2="getNumericScale", addFlagsVtable=4)
@com.parameters([type=U1] return) */
public byte getNumericScale();
/** @com.method(vtoffset=17, dispid=1610809356, type=PROPPUT, name="Size", name2="putSize", addFlagsVtable=4)
@com.parameters([in,type=I4] pl) */
public void setSize(int pl);
/** @com.method(vtoffset=18, dispid=1610809356, type=PROPGET, name="Size", name2="getSize", addFlagsVtable=4)
@com.parameters([type=I4] return) */
public int getSize();
/** @com.method(vtoffset=19, dispid=1610809358, type=METHOD, name="AppendChunk", addFlagsVtable=4)
@com.parameters([in,type=VARIANT] Val) */
public void AppendChunk(Variant Val);
/** @com.method(vtoffset=20, dispid=1610809359, type=PROPGET, name="Attributes", name2="getAttributes", addFlagsVtable=4)
@com.parameters([type=I4] return) */
public int getAttributes();
/** @com.method(vtoffset=21, dispid=1610809359, type=PROPPUT, name="Attributes", name2="putAttributes", addFlagsVtable=4)
@com.parameters([in,type=I4] plParmAttribs) */
public void setAttributes(int plParmAttribs);
public static final com.ms.com._Guid iid = new com.ms.com._Guid((int)0x50c, (short)0x0, (short)0x10, (byte)0x80, (byte)0x0, (byte)0x0, (byte)0xaa, (byte)0x0, (byte)0x6d, (byte)0x2e, (byte)0xa4);
}
| [
"radiowebmasters@gmail.com"
] | radiowebmasters@gmail.com |
188faa16d5a232b316820e6da9380b5f3f161a99 | 51ad815c64bfc254e56560ad7bbac13e01a898bf | /src/main/java/com/choa/s4/board/qna/QnaController.java | 4dace19eab277e2669cc72191a9b2577b91c2263 | [] | no_license | hyun3915/spring_4-1 | 05d2b756e4bac00150d280e9d06fa87013325f58 | 57e26977909df77110e21053f5f20ed89b660816 | refs/heads/main | 2023-01-03T10:13:26.917440 | 2020-10-27T07:35:37 | 2020-10-27T07:35:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,685 | java | package com.choa.s4.board.qna;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.choa.s4.board.BoardDTO;
import com.choa.s4.util.Pager;
@Controller
@RequestMapping("/qna/**")
public class QnaController {
@Autowired
private QnaService qnaService;
@PostMapping("qnaReply")
public ModelAndView setReply(BoardDTO boardDTO)throws Exception{
ModelAndView mv = new ModelAndView();
int result = qnaService.setReply(boardDTO);
String message = "Reply Write Fail";
if(result>0) {
message ="Reply Write Success";
}
mv.addObject("msg", message);
mv.addObject("path", "./qnaList");
mv.setViewName("common/result");
return mv;
}
@GetMapping("qnaReply")
public ModelAndView setReply()throws Exception{
ModelAndView mv = new ModelAndView();
mv.setViewName("board/boardReply");
mv.addObject("board", "qna");
return mv;
}
@GetMapping("qnaSelect")
public ModelAndView getOne(BoardDTO boardDTO)throws Exception{
ModelAndView mv = new ModelAndView();
boardDTO = qnaService.getOne(boardDTO);
if(boardDTO != null) {
mv.setViewName("board/boardSelect");
mv.addObject("dto", boardDTO);
mv.addObject("board", "qna");
}else {
mv.setViewName("common/result");
mv.addObject("msg", "No Data");
mv.addObject("path", "./qnaList");
}
return mv;
}
@PostMapping("qnaWrite")
public ModelAndView setInsert(BoardDTO boardDTO)throws Exception{
ModelAndView mv = new ModelAndView();
int result = qnaService.setInsert(boardDTO);
String message="Write Fail";
if(result>0) {
message ="Write Success";
}
mv.addObject("msg", message);
mv.addObject("path", "./qnaList");
mv.setViewName("common/result");
return mv;
}
@GetMapping("qnaWrite")
public ModelAndView setInsert()throws Exception{
ModelAndView mv = new ModelAndView();
mv.setViewName("board/boardWrite");
mv.addObject("board", "qna");
return mv;
}
@GetMapping("qnaList")
public ModelAndView getList(Pager pager)throws Exception{
ModelAndView mv = new ModelAndView();
List<BoardDTO> ar = qnaService.getList(pager);
BoardDTO boardDTO = ar.get(0);
QnaDTO qnaDTO = (QnaDTO)boardDTO;
System.out.println(qnaDTO.getDepth());
mv.addObject("board", "qna");
mv.addObject("list", ar);
mv.addObject("pager", pager);
mv.setViewName("board/boardList");
return mv;
}
}
| [
"kimdaeki@gmail.com"
] | kimdaeki@gmail.com |
61657c712e922a12b49a20b1dd580976237b86e5 | 0af8b92686a58eb0b64e319b22411432aca7a8f3 | /api-vs-impl-small/app/src/main/java/org/gradle/testapp/performancenull_7/Productionnull_686.java | 5eed1b302d7a627f6f1b891dde559d97d2f1a8f0 | [] | no_license | gradle/performance-comparisons | b0d38db37c326e0ce271abebdb3c91769b860799 | e53dc7182fafcf9fedf07920cbbea8b40ee4eef4 | refs/heads/master | 2023-08-14T19:24:39.164276 | 2022-11-24T05:18:33 | 2022-11-24T05:18:33 | 80,121,268 | 17 | 15 | null | 2022-09-30T08:04:35 | 2017-01-26T14:25:33 | null | UTF-8 | Java | false | false | 585 | java | package org.gradle.testapp.performancenull_7;
public class Productionnull_686 {
private final String property;
public Productionnull_686(String param) {
this.property = param;
}
public String getProperty() {
return property;
}
private String prop0;
public String getProp0() {
return prop0;
}
public void setProp0(String value) {
prop0 = value;
}
private String prop1;
public String getProp1() {
return prop1;
}
public void setProp1(String value) {
prop1 = value;
}
}
| [
"cedric.champeau@gmail.com"
] | cedric.champeau@gmail.com |
bce4cfd27a00a6cfa85e87c70d8ea9e9b2b726a7 | 328ea813e0b69ac2d715ebdef8479c62c763701a | /src/main/java/com/bolder/server/models/dao/IClienteDao.java | eb16fe69a13d124d7deafb6c1848f1e01e597b29 | [] | no_license | marionegreira/bolder | fef9aed0916701c06e90225120341865c7b65b42 | b51c27096ef48312f689c7ab09e4f966b9de6368 | refs/heads/master | 2023-08-15T22:00:33.288354 | 2021-10-04T09:58:24 | 2021-10-04T09:58:24 | 413,363,981 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 299 | java | package com.bolder.server.models.dao;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import com.bolder.server.models.entity.Cliente;
public interface IClienteDao extends JpaRepository<Cliente, Long> {
}
| [
"mario@negreira.net"
] | mario@negreira.net |
26e6b3ae837977636ff3c6793b0a0469979b3876 | 6f5aa600f9c0820ad61160712f23796d86ff3f1e | /src/com/ztk/algorithm/Dynamic/BagProblem.java | e990ec1e946c9a16dcc10a0046eb2f36854ccc71 | [] | no_license | ztkyaojiayou/DataStructrue | 029a72654764e1c7b36ac318ce3e9465426f72d0 | 81cfc86c82bb687b1fa338183b6471d3e1dfc397 | refs/heads/master | 2022-04-09T08:08:05.484041 | 2020-03-26T14:15:48 | 2020-03-26T14:15:48 | 250,277,591 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,424 | java | package com.ztk.algorithm.Dynamic;
/**
* 程序员必备的算法之(3)动态规划算法之(1)背包问题
* 似乎动态规划和递归区别不大???
*/
public class BagProblem {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] w = {1, 4, 3};//物品的重量
int[] val = {1500, 3000, 2000}; //物品的价值 这里val[i] 就是前面讲的v[i]
int m = 4; //背包的容量
int n = val.length; //物品的个数
//创建二维数组,
//v[i][j] 表示在前i个物品中能够装入容量为j的背包中的最大价值
int[][] v = new int[n+1][m+1];
//为了记录放入商品的情况,我们定一个二维数组
int[][] path = new int[n+1][m+1];
//初始化第一行和第一列, 这里在本程序中,可以不去处理,因为默认就是0
for(int i = 0; i < v.length; i++) {
v[i][0] = 0; //将第一列设置为0
}
for(int i=0; i < v[0].length; i++) {
v[0][i] = 0; //将第一行设置0
}
//根据前面得到公式来动态规划处理
for(int i = 1; i < v.length; i++) { //不处理第一行 i是从1开始的
for(int j=1; j < v[0].length; j++) {//不处理第一列, j是从1开始的
//公式
if(w[i-1]> j) { // 因为我们程序i 是从1开始的,因此原来公式中的 w[i] 修改成 w[i-1]
v[i][j]=v[i-1][j];
} else {
//说明:
//因为我们的i 从1开始的, 因此公式需要调整成
//v[i][j]=Math.max(v[i-1][j], val[i-1]+v[i-1][j-w[i-1]]);
//v[i][j] = Math.max(v[i - 1][j], val[i - 1] + v[i - 1][j - w[i - 1]]);
//为了记录商品存放到背包的情况,我们不能直接的使用上面的公式,需要使用if-else来体现公式
if(v[i - 1][j] < val[i - 1] + v[i - 1][j - w[i - 1]]) {
v[i][j] = val[i - 1] + v[i - 1][j - w[i - 1]];
//把当前的情况记录到path
path[i][j] = 1;
} else {
v[i][j] = v[i - 1][j];
}
}
}
}
//输出一下v 看看目前的情况
for(int i =0; i < v.length;i++) {
for(int j = 0; j < v[i].length;j++) {
System.out.print(v[i][j] + " ");
}
System.out.println();
}
System.out.println("============================");
//输出最后我们是放入的哪些商品
//遍历path, 这样输出会把所有的放入情况都得到, 其实我们只需要最后的放入
// for(int i = 0; i < path.length; i++) {
// for(int j=0; j < path[i].length; j++) {
// if(path[i][j] == 1) {
// System.out.printf("第%d个商品放入到背包\n", i);
// }
// }
// }
//动脑筋
int i = path.length - 1; //行的最大下标
int j = path[0].length - 1; //列的最大下标
while(i > 0 && j > 0 ) { //从path的最后开始找
if(path[i][j] == 1) {
System.out.printf("第%d个商品放入到背包\n", i);
j -= w[i-1]; //w[i-1]
}
i--;
}
}
}
| [
"liliu@signcc.com"
] | liliu@signcc.com |
a7c4898c0683de73f9e38da44bc027869147e721 | 4622ed84fbb0aa0892234475be563e35443a2989 | /src/test/java/com/assignment/flightinfo/web/FlightInfoHanlerTest.java | 07a28ce015e3f978636687911dbe1ed2894eee34 | [] | no_license | dattadiware/flight-info-service | 9b343c027717e91271831b7ae1753d39d6e3fd7b | 39ca23df6c1fe8d276a4e4f1647b607e6fa56898 | refs/heads/main | 2023-06-07T10:43:01.792009 | 2021-07-01T11:27:30 | 2021-07-01T11:27:30 | 381,654,173 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,864 | java | package com.assignment.flightinfo.web;
import static org.mockito.Mockito.when;
import java.time.LocalDate;
import java.time.LocalTime;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentMatchers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.reactive.server.WebTestClient;
import com.assignment.flightinfo.model.FlightInfo;
import com.assignment.flightinfo.service.FlightInfoService;
import com.assignment.flightinfo.utils.TestUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import reactor.core.publisher.Mono;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DirtiesContext
@AutoConfigureWebTestClient
public class FlightInfoHanlerTest {
@Autowired private WebTestClient webTestClient;
@MockBean private FlightInfoService service;
@Test
public void given_valid_input_should_return_ok() throws JsonProcessingException {
when(service.getFlightInfo(
ArgumentMatchers.any()))
.thenReturn(Mono.just(TestUtils.mockFlightInfo()));
webTestClient
.get()
.uri(
uri ->
uri.path("/flight/{localdate}/{airportId}/{arrival}/{diparture}")
.build(LocalDate.now(), "airport", LocalTime.now(), LocalTime.now()))
.exchange()
.expectStatus()
.isOk()
.expectBodyList(FlightInfo.class);
}
}
| [
"datta.diware@gmail.com"
] | datta.diware@gmail.com |
020f2f04a57c8b7240c002f1deba0533ee34f95a | 6f29a7dfeb4bb8220231f55b8e502af219385fcf | /2BSorted/peoplefinder/code/java/PeopleFinder/Model/src/au/com/leighton/portal/peoplefinder/model/locationsearch/Phosearchlocations_client_ep.java | 66f3c0485f8ee1bc77b1442c9ad2c015e3603a3b | [] | no_license | juanbecerra/WebCenter_FastStart | fc8d7d9925084642877d8e27fdaf9fee561007e3 | 88b6ddd4a96306db1b5da91789b7587ce3c848bd | refs/heads/master | 2016-09-05T08:50:42.117194 | 2013-04-18T01:20:28 | 2013-04-18T01:20:28 | 9,490,773 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,214 | java | package au.com.leighton.portal.peoplefinder.model.locationsearch;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
// !DO NOT EDIT THIS FILE!
// This source file is generated by Oracle tools
// Contents may be subject to change
// For reporting problems, use the following
// Version = Oracle WebServices (11.1.1.0.0, build 101221.1153.15811)
@WebServiceClient(wsdlLocation="http://lclxsoa11gdev.lc.local:7001/soa-infra/services/default/PhoSearchLocations/phosearchlocations_client_ep?WSDL",
targetNamespace="http://xmlns.oracle.com/Portal/PhoSearchLocations/PhoSearchLocations",
name="phosearchlocations_client_ep")
public class Phosearchlocations_client_ep
extends Service
{
private static URL wsdlLocationURL;
private static Logger logger;
static
{
try
{
logger = Logger.getLogger("au.com.leighton.portal.peoplefinder.model.locationsearch.Phosearchlocations_client_ep");
URL baseUrl = Phosearchlocations_client_ep.class.getResource(".");
if (baseUrl == null)
{
wsdlLocationURL =
Phosearchlocations_client_ep.class.getResource("http://lclxsoa11gdev.lc.local:7001/soa-infra/services/default/PhoSearchLocations/phosearchlocations_client_ep?WSDL");
if (wsdlLocationURL == null)
{
baseUrl = new File(".").toURL();
wsdlLocationURL =
new URL(baseUrl, "http://lclxsoa11gdev.lc.local:7001/soa-infra/services/default/PhoSearchLocations/phosearchlocations_client_ep?WSDL");
}
}
else
{
if (!baseUrl.getPath().endsWith("/")) {
baseUrl = new URL(baseUrl, baseUrl.getPath() + "/");
}
wsdlLocationURL =
new URL(baseUrl, "http://lclxsoa11gdev.lc.local:7001/soa-infra/services/default/PhoSearchLocations/phosearchlocations_client_ep?WSDL");
}
}
catch (MalformedURLException e)
{
logger.log(Level.ALL,
"Failed to create wsdlLocationURL using http://lclxsoa11gdev.lc.local:7001/soa-infra/services/default/PhoSearchLocations/phosearchlocations_client_ep?WSDL",
e);
}
}
public Phosearchlocations_client_ep()
{
super(wsdlLocationURL,
new QName("http://xmlns.oracle.com/Portal/PhoSearchLocations/PhoSearchLocations",
"phosearchlocations_client_ep"));
}
public Phosearchlocations_client_ep(URL wsdlLocation, QName serviceName)
{
super(wsdlLocation, serviceName);
}
@WebEndpoint(name="PhoSearchLocations_pt")
public au.com.leighton.portal.peoplefinder.model.locationsearch.PhoSearchLocations getPhoSearchLocations_pt()
{
return (au.com.leighton.portal.peoplefinder.model.locationsearch.PhoSearchLocations) super.getPort(new QName("http://xmlns.oracle.com/Portal/PhoSearchLocations/PhoSearchLocations",
"PhoSearchLocations_pt"),
au.com.leighton.portal.peoplefinder.model.locationsearch.PhoSearchLocations.class);
}
@WebEndpoint(name="PhoSearchLocations_pt")
public au.com.leighton.portal.peoplefinder.model.locationsearch.PhoSearchLocations getPhoSearchLocations_pt(WebServiceFeature... features)
{
return (au.com.leighton.portal.peoplefinder.model.locationsearch.PhoSearchLocations) super.getPort(new QName("http://xmlns.oracle.com/Portal/PhoSearchLocations/PhoSearchLocations",
"PhoSearchLocations_pt"),
au.com.leighton.portal.peoplefinder.model.locationsearch.PhoSearchLocations.class,
features);
}
}
| [
"juan.becerra@oakton.com.au"
] | juan.becerra@oakton.com.au |
e36a5d08ab48217bd4ae8890ef3bb5f2ad6b0ac3 | bd30db2bda717bce5ce20ba32ba623310d17d615 | /HPull/src/main/java/com/ichongliang/hpull/library/PullToRefreshListView.java | 7aaabd8cf91d0c9cd05272fc52339f6d8537dd7c | [] | no_license | bxunzhao/PullRefresh | e65276ee26599e422c00c894dcefad97e400ca42 | 191c168f5dac7ec2f3ee4a6b454b51b2285f7c71 | refs/heads/master | 2020-04-02T12:25:52.332808 | 2018-10-24T07:40:35 | 2018-10-24T07:40:35 | 154,433,036 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,484 | java | /*******************************************************************************
* Copyright 2011, 2012 Chris Banes.
*
* 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.ichongliang.hpull.library;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import com.ichongliang.hpull.library.internal.EmptyViewMethodAccessor;
import com.ichongliang.hpull.library.internal.LoadingLayout;
import com.ichongliang.hpull.R;
public class PullToRefreshListView extends PullToRefreshAdapterViewBase<ListView> {
private LoadingLayout mHeaderLoadingView;
private LoadingLayout mFooterLoadingView;
private FrameLayout mLvFooterLoadingFrame;
private boolean mListViewExtrasEnabled;
public PullToRefreshListView(Context context) {
super(context);
}
public PullToRefreshListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public PullToRefreshListView(Context context, Mode mode) {
super(context, mode);
}
public PullToRefreshListView(Context context, Mode mode, AnimationStyle style) {
super(context, mode, style);
}
@Override
public final Orientation getPullToRefreshScrollDirection() {
return Orientation.VERTICAL;
}
@Override
protected void onRefreshing(final boolean doScroll) {
/**
* If we're not showing the Refreshing view, or the list is empty, the
* the header/footer views won't show so we use the normal method.
*/
ListAdapter adapter = mRefreshableView.getAdapter();
if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
super.onRefreshing(doScroll);
return;
}
super.onRefreshing(false);
final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
final int selection, scrollToY;
switch (getCurrentMode()) {
case MANUAL_REFRESH_ONLY:
case PULL_FROM_END:
origLoadingView = getFooterLayout();
listViewLoadingView = mFooterLoadingView;
oppositeListViewLoadingView = mHeaderLoadingView;
selection = mRefreshableView.getCount() - 1;
scrollToY = getScrollY() - getFooterSize();
break;
case PULL_FROM_START:
default:
origLoadingView = getHeaderLayout();
listViewLoadingView = mHeaderLoadingView;
oppositeListViewLoadingView = mFooterLoadingView;
selection = 0;
scrollToY = getScrollY() + getHeaderSize();
break;
}
// Hide our original Loading View
origLoadingView.reset();
origLoadingView.hideAllViews();
// Make sure the opposite end is hidden too
oppositeListViewLoadingView.setVisibility(View.GONE);
// Show the ListView Loading View and set it to refresh.
listViewLoadingView.setVisibility(View.VISIBLE);
listViewLoadingView.refreshing();
if (doScroll) {
// We need to disable the automatic visibility changes for now
disableLoadingLayoutVisibilityChanges();
// We scroll slightly so that the ListView's header/footer is at the
// same Y position as our normal header/footer
setHeaderScroll(scrollToY);
// Make sure the ListView is scrolled to show the loading
// header/footer
mRefreshableView.setSelection(selection);
// Smooth scroll as normal
smoothScrollTo(0);
}
}
@Override
protected void onReset() {
/**
* If the extras are not enabled, just call up to super and return.
*/
if (!mListViewExtrasEnabled) {
super.onReset();
return;
}
final LoadingLayout originalLoadingLayout, listViewLoadingLayout;
final int scrollToHeight, selection;
final boolean scrollLvToEdge;
switch (getCurrentMode()) {
case MANUAL_REFRESH_ONLY:
case PULL_FROM_END:
originalLoadingLayout = getFooterLayout();
listViewLoadingLayout = mFooterLoadingView;
selection = mRefreshableView.getCount() - 1;
scrollToHeight = getFooterSize();
scrollLvToEdge = Math.abs(mRefreshableView.getLastVisiblePosition() - selection) <= 1;
break;
case PULL_FROM_START:
default:
originalLoadingLayout = getHeaderLayout();
listViewLoadingLayout = mHeaderLoadingView;
scrollToHeight = -getHeaderSize();
selection = 0;
scrollLvToEdge = Math.abs(mRefreshableView.getFirstVisiblePosition() - selection) <= 1;
break;
}
// If the ListView header loading layout is showing, then we need to
// flip so that the original one is showing instead
if (listViewLoadingLayout.getVisibility() == View.VISIBLE) {
// Set our Original View to Visible
originalLoadingLayout.showInvisibleViews();
// Hide the ListView Header/Footer
listViewLoadingLayout.setVisibility(View.GONE);
/**
* Scroll so the View is at the same Y as the ListView
* header/footer, but only scroll if: we've pulled to refresh, it's
* positioned correctly
*/
if (scrollLvToEdge && getState() != State.MANUAL_REFRESHING) {
mRefreshableView.setSelection(selection);
setHeaderScroll(scrollToHeight);
}
}
// Finally, call up to super
super.onReset();
}
@Override
protected LoadingLayoutProxy createLoadingLayoutProxy(final boolean includeStart, final boolean includeEnd) {
LoadingLayoutProxy proxy = super.createLoadingLayoutProxy(includeStart, includeEnd);
if (mListViewExtrasEnabled) {
final Mode mode = getMode();
if (includeStart && mode.showHeaderLoadingLayout()) {
proxy.addLayout(mHeaderLoadingView);
}
if (includeEnd && mode.showFooterLoadingLayout()) {
proxy.addLayout(mFooterLoadingView);
}
}
return proxy;
}
protected ListView createListView(Context context, AttributeSet attrs) {
final ListView lv;
if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
lv = new InternalListViewSDK9(context, attrs);
} else {
lv = new InternalListView(context, attrs);
}
return lv;
}
@Override
protected ListView createRefreshableView(Context context, AttributeSet attrs) {
ListView lv = createListView(context, attrs);
// Set it to this so it can be used in ListActivity/ListFragment
lv.setId(android.R.id.list);
return lv;
}
@Override
protected void handleStyledAttributes(TypedArray a) {
super.handleStyledAttributes(a);
mListViewExtrasEnabled = a.getBoolean(R.styleable.PullToRefresh_ptrListViewExtrasEnabled, true);
if (mListViewExtrasEnabled) {
final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL);
// Create Loading Views ready for use later
FrameLayout frame = new FrameLayout(getContext());
mHeaderLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_START, a);
mHeaderLoadingView.setVisibility(View.GONE);
frame.addView(mHeaderLoadingView, lp);
mRefreshableView.addHeaderView(frame, null, false);
mLvFooterLoadingFrame = new FrameLayout(getContext());
mFooterLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_END, a);
mFooterLoadingView.setVisibility(View.GONE);
mLvFooterLoadingFrame.addView(mFooterLoadingView, lp);
/**
* If the value for Scrolling While Refreshing hasn't been
* explicitly set via XML, enable Scrolling While Refreshing.
*/
if (!a.hasValue(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled)) {
setScrollingWhileRefreshingEnabled(true);
}
}
}
@TargetApi(9)
final class InternalListViewSDK9 extends InternalListView {
public InternalListViewSDK9(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX,
int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) {
final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX,
scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent);
// Does all of the hard work...
OverscrollHelper.overScrollBy(PullToRefreshListView.this, deltaX, scrollX, deltaY, scrollY, isTouchEvent);
return returnValue;
}
}
protected class InternalListView extends ListView implements EmptyViewMethodAccessor {
private boolean mAddedLvFooter = false;
public InternalListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void dispatchDraw(Canvas canvas) {
/**
* This is a bit hacky, but Samsung's ListView has got a bug in it
* when using Header/Footer Views and the list is empty. This masks
* the issue so that it doesn't cause an FC. See Issue #66.
*/
try {
super.dispatchDraw(canvas);
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
/**
* This is a bit hacky, but Samsung's ListView has got a bug in it
* when using Header/Footer Views and the list is empty. This masks
* the issue so that it doesn't cause an FC. See Issue #66.
*/
try {
return super.dispatchTouchEvent(ev);
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
return false;
}
}
@Override
public void setAdapter(ListAdapter adapter) {
// Add the Footer View at the last possible moment
if (null != mLvFooterLoadingFrame && !mAddedLvFooter) {
addFooterView(mLvFooterLoadingFrame, null, false);
mAddedLvFooter = true;
}
super.setAdapter(adapter);
}
@Override
public void setEmptyView(View emptyView) {
PullToRefreshListView.this.setEmptyView(emptyView);
}
@Override
public void setEmptyViewInternal(View emptyView) {
super.setEmptyView(emptyView);
}
}
}
| [
"454464006@qq.com"
] | 454464006@qq.com |
b6a2a1042ff8341645b7c6baf91aadfcf2f3f680 | 30472cec0dbe044d52b029530051ab404701687f | /src/main/java/com/sforce/soap/tooling/ContainerAsyncRequestState.java | 58cdbd10e2094dca9de319f2223799c412c1b3f9 | [
"BSD-3-Clause"
] | permissive | madmax983/ApexLink | f8e9dcf8f697ed4e34ddcac353c13bec707f3670 | 30c989ce2c0098097bfaf586b87b733853913155 | refs/heads/master | 2020-05-07T16:03:15.046972 | 2019-04-08T21:08:06 | 2019-04-08T21:08:06 | 180,655,963 | 1 | 0 | null | 2019-04-10T20:08:30 | 2019-04-10T20:08:30 | null | UTF-8 | Java | false | false | 1,112 | java | package com.sforce.soap.tooling;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
/**
* This is a generated class for the SObject Enterprise API.
* Do not edit this file, as your changes will be lost.
*/
public enum ContainerAsyncRequestState {
/**
* Enumeration : Queued
*/
Queued("Queued"),
/**
* Enumeration : Invalidated
*/
Invalidated("Invalidated"),
/**
* Enumeration : Completed
*/
Completed("Completed"),
/**
* Enumeration : Failed
*/
Failed("Failed"),
/**
* Enumeration : Error
*/
Error("Error"),
/**
* Enumeration : Aborted
*/
Aborted("Aborted"),
;
public static Map<String, String> valuesToEnums;
static {
valuesToEnums = new HashMap<String, String>();
for (ContainerAsyncRequestState e : EnumSet.allOf(ContainerAsyncRequestState.class)) {
valuesToEnums.put(e.toString(), e.name());
}
}
private String value;
private ContainerAsyncRequestState(String value) {
this.value = value;
}
@Override
public String toString() {
return value;
}
}
| [
"nawforce@gmail.com"
] | nawforce@gmail.com |
9883b71d74a069865e626402acaa32263bb94a50 | 3c9d9d141964d6bbf8bead5dfc9fc64df034db84 | /src/main/java/com/sky/nio/channel/TestChannel.java | a1bd13c1e10c00432eb866b50966a6c083eb3449 | [] | no_license | Bruce5022/java-core-nio | 0ae9d234a0c35ac46d9bd46c3b7bea5f3d960244 | 5e37a362c8002c03821edf5065a2b3230dc01b42 | refs/heads/master | 2021-07-12T13:17:49.576094 | 2019-08-29T23:00:53 | 2019-08-29T23:00:53 | 204,148,599 | 0 | 0 | null | 2020-10-13T15:33:44 | 2019-08-24T11:32:02 | Java | UTF-8 | Java | false | false | 2,134 | java | package com.sky.nio.channel;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
/**
* 一.通道:用于源节点与目标节点的连接.在java nio中负责缓冲区的传输.channel本身不存储数据,因此需要配合缓冲区进行传输.
* <p>
* 二.通道的主要实现类
* java.nio.channels.Channel 接口:
* |--FileChannel:本地文件
* |--SocketChannel:tcp网络传输
* |--ServerSocketChannel:tcp网络传输
* |--DatagramChannel:utp网络传输
* <p>
* 三.获取通道
* 1.Java针对支持通道的类提供了getChannel()方法
* 本地io:FileInputStream/FileOutputStream,RandomAccessFile
* 网络io:Socket/ServerSocket,DatagramSocket
* <p>
* 2.在JDK 1.7中的NIO.2针对各个通道提供了静态方法open()
* <p>
* 3.在JDK 1.7中的NIO.2的Files工具类的newByteChannel()
*
* 4.通道之间的数据传输transferFrom()和transferTo()
*/
public class TestChannel {
public static void main(String[] args) throws Exception {
// test1();
}
/**
* 1.利用通道完成文件的复制(非直接缓冲区)
* 耗时:0.446
* @throws Exception
*/
public static void test1() throws Exception {
long start = System.currentTimeMillis();
FileInputStream fis = new FileInputStream("111.qsv");
FileOutputStream fos = new FileOutputStream("222.qsv");
// 获取通道
FileChannel inChannel = fis.getChannel();
FileChannel outChannel = fos.getChannel();
// 分配指定大小的缓冲区
ByteBuffer buffer = ByteBuffer.allocate(1024);
// 将通道中的数据存入缓冲区中
while (inChannel.read(buffer) != -1){
// 将缓冲区中的数据写入通道中
buffer.flip(); // 切换成读取模式
outChannel.write(buffer);
buffer.clear();
}
outChannel.close();
inChannel.close();
fos.close();
fis.close();
System.out.println("耗时:" + (System.currentTimeMillis()-start)/1000.0);
}
}
| [
"shizhanwei123@aliyun.com"
] | shizhanwei123@aliyun.com |
204a7923b60919df981c116d23567efef9b6bcdf | 5e93b90a0b7c3cee3570de82aec07559576eed13 | /unmixin/src/unmixin/Parser.java | 083fcf1e714433839b0de81e348efbda4e2d7416 | [] | no_license | priangulo/BttFTestProjects | a6f37c83b52273f8b5f3d7cbb7116c85a0fd4ef2 | cc2294d24f9b0fed46110b868bd3a8f6c8794475 | refs/heads/master | 2021-03-27T10:30:10.316285 | 2017-10-25T21:39:55 | 2017-10-25T21:39:55 | 64,432,711 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,344 | java | package unmixin;
import java.io.File ;
import java.io.FileInputStream ;
import java.io.FileNotFoundException ;
import java.io.InputStream ;
import java.io.InputStreamReader ;
import java.io.Reader ;
import java.io.UnsupportedEncodingException ;
import java.lang.reflect.Method ;
import java.util.HashMap ;
import java.util.Map ;
//-----------------------------------------------------------------------//
// Parser facade below:
//-----------------------------------------------------------------------//
/**
* Facade for underlying {@link BaliParser} that provides factory methods
* named <code>getInstance</code> for obtaining a <em>singleton</em>
* instance of the parser. The factory methods should be used instead of
* constructors or the {@link BaliParser#ReInit()} methods.
*
* @layer<kernel>
*/
final public class Parser {
//-----------------------------------------------------------------------//
// Static factory methods for instantiation:
//-----------------------------------------------------------------------//
/**
* Return singleton <code>Parser</code> in current state.
*
* @layer<kernel>
*/
public static Parser getInstance() {
return parser ;
}
/**
* Re-initialize singleton <code>Parser</code> to start parsing from
* a given {@link File}, returning the updated <code>Parser</code>.
*
* @layer<kernel>
*/
public static Parser getInstance( File inputFile )
throws FileNotFoundException {
return getInstance( new FileInputStream( inputFile ) ) ;
}
/**
* Re-initialize singleton <code>Parser</code> to start parsing from
* an {@link InputStream}, returning the updated <code>Parser</code>.
*
* @layer<kernel>
*/
public static Parser getInstance( InputStream stream ) {
try {
return getInstance( new InputStreamReader( stream,"ISO-8859-1" ) );
}
catch ( UnsupportedEncodingException except ) {
return getInstance( new InputStreamReader( stream ) ) ;
}
}
/**
* Re-initialize singleton <code>Parser</code> to start parsing from
* a {@link Reader} object, returning the updated <code>Parser</code>.
*
* @layer<kernel>
*/
public static Parser getInstance( Reader reader ) {
if ( parser == null )
parser = new Parser( reader ) ;
else
parser.reset (reader) ;
return parser ;
}
//-----------------------------------------------------------------------//
// Parser instance methods:
//-----------------------------------------------------------------------//
/**
* Returns the result of the last parse, <code>null</code> if none.
**/
public AstNode getParse () {
return lastParse ;
}
/**
* Parses the input against the specified non-terminal rule. This method
* doesn't require that a successful parse must be terminated by an
* end-of-file. Instead, any non-matching input is allowed.
*
* @return an {@link AstNode} with the result of the parse.
* @throws ParseException if the parse fails.
**/
public AstNode parse (String rule) throws ParseException {
try {
Method method = (Method) ruleMap.get (rule) ;
if (null == method) {
Class klass = baliParser.getClass() ;
method = klass.getMethod (rule, class0) ;
if (! AstNode.class.isAssignableFrom (method.getReturnType()))
throw new IllegalArgumentException (rule + " not found") ;
ruleMap.put (rule, method) ;
}
return (AstNode) method.invoke (baliParser, object0) ;
} catch (RuntimeException re) {
throw re ;
} catch (Exception except) {
ParseException pe = baliParser.generateParseException() ;
pe.initCause (except) ;
throw pe ;
}
}
/**
* Parses the input against the start rule, then parses an end-of-file.
*
* @return an {@link AstNode} with the result of the parse.
*
* @throws ParseException
* if input doesn't match the start rule or if it's not terminated by an
* end-of-file.
**/
public AstNode parseAll () throws ParseException {
lastParse = BaliParser.getStartRoot (baliParser) ;
return lastParse ;
}
/**
* Parses an end-of-file from the input.
*
* @throws ParseException if input is not at end of file.
**/
public void parseEOF () throws ParseException {
baliParser.requireEOF() ;
}
/**
* Resets the parser's input to another {@link Reader}.
**/
private void reset (Reader reader) {
baliParser.ReInit (reader) ;
}
//-----------------------------------------------------------------------//
/**
* Private constructor to create singleton of <code>Parser</code>.
*
* @layer<kernel>
*/
private Parser( Reader reader ) {
if (null == reader)
throw new NullPointerException ("\"reader\" is null") ;
this.baliParser = new BaliParser (reader) ;
this.lastParse = null ;
this.ruleMap = new HashMap() ;
}
final private BaliParser baliParser ;
private AstNode lastParse ;
final private Map ruleMap ;
final private static Class[] class0 = new Class [0] ;
final private static Object[] object0 = new Object [0] ;
private static Parser parser = null ;
}
| [
"priangulo@gmail.com"
] | priangulo@gmail.com |
59234cc97655c40184bc740511ffd6ac8a511064 | 30d2716e35b8f4b67fd365d7ceb4284490cde711 | /src/com/example/contacts/MyMsg.java | 570afca56c07f79062d52af5f28d4f61fc5c87ab | [] | no_license | CrandoLee/Contacts | 11cee03d5acee7ccf069b0d72dbbfb29ea1473a3 | a9ba7f033acd3565874d459d21c20a91c6cf30c8 | refs/heads/master | 2021-01-20T21:59:27.177670 | 2015-08-18T13:56:27 | 2015-08-18T13:56:27 | 39,200,234 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 887 | java | package com.example.contacts;
public class MyMsg {
private String smsbody; //消息内容
private String phoneNumber; //电话号码
private String date; //日期
private String name; //姓名
private String type; //短信类型
public String getSmsbody() {
return smsbody;
}
public void setSmsbody(String smsbody) {
this.smsbody = smsbody;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
| [
"crandolee@outlook.com"
] | crandolee@outlook.com |
8ee3aac0e326331d5709cf4fb8c661dac925c4ff | 7c1e3c3ce8d5c2ac9790259baa5490087a93072b | /src/meng/spring/test17/aop/Test.java | 5ea1c633342c703c3fe836dc20b094dd935457f1 | [] | no_license | mengzhang6/spring-framework-sample-v01 | 00f37a38dbcfc5d7e089668c9401bdfc4feb86c0 | 1ed83e604f9b4fe5d7fe610cc84cb578afaa0039 | refs/heads/master | 2021-10-26T04:50:01.482291 | 2019-04-10T16:41:07 | 2019-04-10T16:41:07 | 82,324,762 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 536 | java | package meng.spring.test17.aop;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
public static void main(String[] args) {
ApplicationContext context = null;
try {
context = new ClassPathXmlApplicationContext(
"classpath:spring-aop.xml");
} catch (BeansException e) {
e.printStackTrace();
}
Fit fit= (Fit)context.getBean("aspectBiz");
fit.filter();
}
}
| [
"1213252320@qq.com"
] | 1213252320@qq.com |
b47eb8d3667541bc08fe4af5ccba3fb73a6019e7 | 0857c34613f13f226d0c101c9f2add0dba1de88e | /app/src/main/java/chau/voipapp/ContactActivity.java | 3e803b58f463e3f6d4207a246971e85533e7678b | [] | no_license | tamchau2809/VoipAppAS | abf4f1668884c9bca9e640e222d1467d20ce82e1 | 9ac9624391661f0fa55878b5bd5373d443a67095 | refs/heads/master | 2021-01-01T05:19:50.495928 | 2016-10-07T04:38:45 | 2016-10-07T04:38:45 | 57,285,759 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,863 | java | package chau.voipapp;
import java.util.ArrayList;
import java.util.Collections;
import android.annotation.SuppressLint;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.AdapterContextMenuInfo;
@SuppressLint({ "InflateParams", "DefaultLocale" })
public class ContactActivity extends Fragment
{
View rootView;
Keyboard keyboard;
String name;
String phoneNo;
public static ListView lvContact;
EditText edSearch;
public static ListviewContactAdapter adapter;
TextWatcher watcher;
ContactItem contactSelected;
AdapterView.OnItemClickListener listenerlvContact;
int lvContactPos;
ArrayList<ContactItem> mContactArrayList = new ArrayList<ContactItem>();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
setHasOptionsMenu(true);
rootView = inflater.inflate(R.layout.activity_contact, container, false);
initWiget();
initListener();
InputMethodManager ipm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
ipm.hideSoftInputFromWindow(edSearch.getWindowToken(), 0);
registerForContextMenu(lvContact);
mContactArrayList = getContact();
adapter = new ListviewContactAdapter(getActivity(), mContactArrayList);
Collections.sort(mContactArrayList);
lvContact.setAdapter(adapter);
lvContact.setOnItemClickListener(listenerlvContact);
edSearch.addTextChangedListener(watcher);
return rootView;
}
@Override
public void onCreateOptionsMenu(Menu menu,MenuInflater inflater){
inflater.inflate(R.menu.contact_bottom_bar, menu);
super.onCreateOptionsMenu(menu,inflater);
}
@Override
public void onStart()
{
super.onStart();
// adapter.notifyDataSetChanged();
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.contact_click_menu, menu);
}
@Override
public boolean onContextItemSelected(MenuItem item)
{
AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.getMenuInfo();
switch(item.getItemId())
{
case R.id.action_call_contact:
Keyboard.numCall = (mContactArrayList.get(info.position).getNum());
Intent intent = new Intent(getActivity(), OnCallingActivity.class);
startActivity(intent);
break;
case R.id.action_edit_contact:
// Intent intent1 = new Intent(Intent.ACTION_EDIT);
// intent1.setData(Uri.parse("content://com.android.contacts/raw_contacts/" + contactSelected.getNum()));
Intent intent1 = new Intent(getActivity(), EditContactActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("CONTACT", contactSelected);
intent1.putExtra("CONTACT_DATA", bundle);
startActivityForResult(intent1, 8);
break;
default:
break;
}
return super.onContextItemSelected(item);
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
int id = item.getItemId();
if(id == R.id.action_contact_search)
{
if(edSearch.isShown())
edSearch.setVisibility(View.GONE);
else edSearch.setVisibility(View.VISIBLE);
}
if(id == R.id.action_contact_add_contact)
{
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
//Tranh cho viec mo activity bi loi do chua khoi tao Edittext
if(keyboard.isVisible())
{
intent.putExtra(ContactsContract.Intents.Insert.PHONE, Keyboard.edNumInput.getText().toString());
}
startActivity(intent);
}
if(id == R.id.action_contact_show_keyboard)
{
if(keyboard==null)
{
adapter.restoreList();
// keyboard = new Keyboard();
getActivity().getSupportFragmentManager().beginTransaction().add(R.id.Key_board_container, keyboard).commit();
}
else
{
if(keyboard.isVisible())
{
adapter.restoreList();
getActivity().getSupportFragmentManager().beginTransaction().hide(keyboard).commit();
}
else
{
adapter.restoreList();
keyboard = new Keyboard();
getActivity().getSupportFragmentManager().beginTransaction().add(R.id.Key_board_container, keyboard).commit();
}
}
}
return super.onOptionsItemSelected(item);
}
@Override
public void onPrepareOptionsMenu(Menu menu)
{
super.onPrepareOptionsMenu(menu);
// getActivity().invalidateOptionsMenu();
// MenuItem filter = menu.findItem(R.id.bottomSearch).setVisible(false);
// filter = menu.findItem(R.id.bottomStatus).setVisible(false);
// filter.setVisible(false);
}
@Override
public void onResume()
{
edSearch.setText(null);
super.onResume();
}
/**
* Khởi tạo các thành phần
*/
public void initWiget()
{
keyboard = new Keyboard();
edSearch = (EditText)rootView.findViewById(R.id.edSearchContact);
lvContact = (ListView)rootView.findViewById(R.id.lvContact);
}
public void initListener()
{
listenerlvContact = new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
lvContactPos = arg2;
contactSelected = (ContactItem)arg0.getAdapter().getItem(arg2);
getActivity().openContextMenu(arg1);
}
};
watcher = new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
adapter.getFilter().filter(s.toString());
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
};
}
private ArrayList<ContactItem> getContact()
{
ArrayList<ContactItem> list = new ArrayList<ContactItem>();
ContentResolver cr = getActivity().getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
null, null, null, null);
if(cur.getCount() > 0)
{
while(cur.moveToNext())
{
String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
if (Integer.parseInt(cur.getString(
cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0)
{
Cursor pCur = cr.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",
new String[]{id}, null);
while (pCur.moveToNext()) {
phoneNo = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
phoneNo = phoneNo.replace(" ", "");
list.add(new ContactItem(name, phoneNo));
}
pCur.close();
}
}
}
return list;
}
public class ListviewContactAdapter extends BaseAdapter implements Filterable
{
private ArrayList<ContactItem> listOriginContact;
private ArrayList<ContactItem> listDisplayValue;
ArrayList<ContactItem> arr;
private LayoutInflater mInflater;
public ListviewContactAdapter(Context contactFragment, ArrayList<ContactItem> mContactArrayList)
{
// TODO Auto-generated constructor stub
this.listOriginContact = mContactArrayList;
this.listDisplayValue = mContactArrayList;
this.arr = mContactArrayList;
mInflater = LayoutInflater.from(contactFragment);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return listDisplayValue.size();
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return listDisplayValue.get(arg0);
}
@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return arg0;
}
public void restoreList()
{
this.listDisplayValue = arr;
notifyDataSetChanged();
}
@Override
public View getView(int pos, View view, ViewGroup parent)
{
// TODO Auto-generated method stub
ViewHolder holder;
if(view == null)
{
view = mInflater.inflate(R.layout.activity_contact_custom_view, null);
holder = new ViewHolder();
holder.contactName = (TextView)view.findViewById(R.id.contact_name);
view.setTag(holder);
}
else
{
holder = (ViewHolder)view.getTag();
}
holder.contactName = (TextView)view.findViewById(R.id.contact_name);
holder.contactName.setText(listDisplayValue.get(pos).getName());
holder.contactNum = (TextView)view.findViewById(R.id.contact_number);
holder.contactNum.setText(listDisplayValue.get(pos).getNum());
return view;
}
class ViewHolder
{
TextView contactName, contactNum;
}
@SuppressLint("DefaultLocale")
@Override
public Filter getFilter() {
// TODO Auto-generated method stub
Filter filter = new Filter() {
@SuppressWarnings("unchecked")
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
// TODO Auto-generated method stub
if(results.count == 0)
{
notifyDataSetInvalidated();
}
else
{
listDisplayValue = (ArrayList<ContactItem>)results.values;
notifyDataSetChanged();
}
}
@Override
protected FilterResults performFiltering(CharSequence constraint) {
// TODO Auto-generated method stub
FilterResults filterResults = new FilterResults();
ArrayList<ContactItem> filterList = new ArrayList<ContactItem>();
if(listOriginContact == null)
{
listOriginContact = new ArrayList<ContactItem>(listDisplayValue);
}
if(constraint == null || constraint.length() == 0)
{
filterResults.count = listOriginContact.size();
filterResults.values = listOriginContact;
}
else
{
constraint = constraint.toString().toLowerCase();
for(int i = 0; i < listOriginContact.size(); i++)
{
String data = listOriginContact.get(i).getName();
String num = listOriginContact.get(i).getNum();
if (data.toLowerCase().contains(constraint.toString())
|| num.contains(constraint.toString())) {
filterList.add(new ContactItem(
listOriginContact.get(i).getName(),
listOriginContact.get(i).getNum()));
}
}
filterResults.count = filterList.size();
filterResults.values = filterList;
}
return filterResults;
}
};
return filter;
}
}
}
| [
"tamcha2809@gmail.com"
] | tamcha2809@gmail.com |
a7c55641988a217b516304ff5a3ce62c7e0764da | 92b96898c2d450602b7176e0cce8cbe089754a57 | /src/main/java/com/recipes/RecipeManagementBackend/service/IngredientService.java | 7c786417f715069f227314ff52d99383e42ab37d | [] | no_license | rimshar/Recipe-Management-System-Backend | a75f56d5ce05b057a33d03b82f64df485551eec4 | 5fdddc6c573c8982c436da0be29ca858b7bb3cfc | refs/heads/master | 2022-12-09T00:34:51.372751 | 2020-09-01T16:26:00 | 2020-09-01T16:26:00 | 282,601,193 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,395 | java | package com.recipes.RecipeManagementBackend.service;
import com.recipes.RecipeManagementBackend.exception.EntityNotFoundException;
import com.recipes.RecipeManagementBackend.model.Ingredient;
import com.recipes.RecipeManagementBackend.repository.IngredientRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class IngredientService {
private IngredientRepository ingredientRepository;
@Autowired
public IngredientService(IngredientRepository ingredientRepository){
this.ingredientRepository = ingredientRepository;
}
public Ingredient getIngredientById(Long id){
return ingredientRepository.findById(id).orElseThrow(
() -> new EntityNotFoundException("Ingredient " + id + " not found!"));
}
public Ingredient getIngredientByName(String name){
return ingredientRepository.findByName(name).orElseThrow(
() -> new EntityNotFoundException("Ingredient " + name + " not found!"));
}
public List<Ingredient> getAllIngredients() {
return ingredientRepository.findAll();
}
@Transactional
public Ingredient saveIngredient(Ingredient ingredient) {
return ingredientRepository.save(ingredient);
}
}
| [
"rimsha.r@gmail.com"
] | rimsha.r@gmail.com |
16be5541bc769ca5679ac556bc1b4dff55348725 | e729071c6c6ec72f9d5b3abf7fa4653805a1a408 | /Libraries/src/librerias/Vector.java | b4582b953c3b82832e64a860d43db46a11071260 | [] | no_license | hroda06/Java-POO-Excercises | 573dcd0f687bc65ae21990c1403669f087c76705 | 5e22e17c28ca0316805cee98e627a5180145d86c | refs/heads/master | 2021-01-07T00:35:36.815749 | 2020-02-19T03:53:26 | 2020-02-19T03:53:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,344 | java |
package librerias;
/**
*
* @author HERNAN
*/
import java.util.Scanner;
public class Vector {
Scanner sn=new Scanner(System.in);
protected int []x;
public Vector(int n)
{
x=new int[n];
}
public void cargar()
{
for(int i=0;i<x.length;i++)
{ System.out.print(" Ingrese un numero entero ");
x[i]=sn.nextInt();
}
}
public int maximo() //método publico
{return maximo(x.length-1);
}
private int maximo(int c) // método sobrecargado y privado
{
int aux;
if (c==0)
return x[0];
if( x[c-1] < x[c] )
{
aux=x[c-1];
x[c-1]=x[c];
x[c]=aux;
return maximo(c-1);
}
else
return maximo(c-1);
}
public int minimo() //método publico
{return minimo(x.length-1);
}
private int minimo(int c) // método sobrecargado y privado
{ int aux;
if (c==0)
return x[0];
if( x[c-1] > x[c] )
{
aux=x[c-1];
x[c-1]=x[c];
x[c]=aux;
return minimo(c-1);
}
else
return minimo(c-1);
}
public int producto() //método publico
{ return producto(x.length-1);
}
private int producto(int c) // método sobrecargado y privado
{
if (c==0)
return x[0];
else
return x[c]*producto(c-1);
}
public int pares() //método publico
{return pares(x.length-1);
}
private int pares(int c) // método sobrecargado y privado
{ if (c==-1)
return 0;
else
if (x[c] %2==0 )
return 1+pares(c-1);
else
return pares(c-1);
}
public String toString()
{String aux="\n Elementos del vector \n";
for(int i=0;i<x.length;i++)
aux+="\t"+x[i];
return aux;
}
// METODO EXTERNO PARA CALCULAR FACTORIAL
static double fact (double n)
{
if (n==0)
return 1;
else
return n*fact(n-1);
// n=4 retorna 4*3*2*1*1(el ultimo 1 es lo que retorna cuando n=0 ya que el factorial de 0=1 coincide)
}
// METODO EXTERNO PARA CALCULAR PRODUCTO DE 2 NUMEROS POR MEDIO DE SUMAS SUSESIVAS
static int producto (int x, int y)
{
if (y==0)
return 0;
else
return x+producto(x, y-1);
// n=4,y=3 retorna 4+4+4+0 (el ultimo 0 es cuando "y" llega a 0 y termina el metodo sumas susesivas de "x")
}
// METODO EXTERNO PARA CALCULAR SUMATORIA RECURSIVA DE UN NUMERO
static int suma (int z)
{
if (z==1)
return 1;
else
return z+suma(z-1);
// n=4 retorna 4+3+2+1 (el ultimo 1 es cuando corta el metodo ya que z=1)(es lo mismo si hago z==0, return 0)
}
}
| [
"hroda06@gmail.com"
] | hroda06@gmail.com |
a9f06f207d0a87054f5bb0485fa18d307669e677 | 22358d350e9c51d2b4ec3455784efa9326487254 | /Team4-master/src/CrazyEights/CrazyEightsGame.java | 1d3c1e94f6a367d67637538193f3844bb3985626 | [] | no_license | rdhupia/CRM_Project | 9b34cbfb3bb96c47683986cabf99109542678806 | ba5e0e30aac0822373f5b8441399e906443c8573 | refs/heads/master | 2021-06-11T14:22:34.830909 | 2017-02-26T19:02:43 | 2017-02-26T19:02:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,900 | java | package CrazyEights;
import java.util.Scanner;
import cgfw.card.*;
import cgfw.game.*;
import cgfw.player.Player;
public class CrazyEightsGame extends GameComposite {
protected static int consecutivePasses = 0;
private static int currentLeaderIndex = -1;
private CardsStack starterPile = new CardsStack();
private CardsStack stockPile = new CardsStack();
@Override
public void postGame() {
System.out.println("Game Over!!!!!");
System.out.println("");
System.out.println("----------- Scores -----------");
// Update and display scores
updateGameScores();
for( Player player : super.getPlayers() ) {
System.out.println(player.getUserName() + ": " + player.getScore());
}
System.out.println("");
System.out.println("***** Winner: " + super.getPlayerAtIndex(currentLeaderIndex).getUserName() + " !! *****");
String proceed = "";
@SuppressWarnings("resource")
Scanner input = new Scanner(System.in);
System.out.print( "Play another game ? [Y]=> " );
proceed = input.nextLine();
if( proceed.equalsIgnoreCase("y"))
super.run();
else
System.out.println("Thanks for playing, GoodBye!!");
}
// Updates scores for each player, gets winner
private void updateGameScores() {
int lowestScore = 10000000;
for( int x = 0; x < super.getPlayers().size(); x++ )
{
int total = 0;
for( int i = 0; i < super.getPlayerAtIndex(x).getCardsInHand().count(); i++ )
{
Card card = super.getPlayerAtIndex(x).getCardsInHand().getCardAtIndex(i);
if( card.getRankFaceValue() == 8 )
total += 50;
else if( card.getRankFaceValue() >= 10 && card.getRankFaceValue() <= 13 )
total += 10;
else
total += card.getRankFaceValue();
}
super.getPlayerAtIndex(x).updateScore(total);
if( super.getPlayerAtIndex(x).getScore() < lowestScore )
{
lowestScore = super.getPlayerAtIndex(x).getScore();
currentLeaderIndex = x;
}
}
}
@Override
public void preGame() {
Deck deck = new Deck();
int numberOfCards = 5;
for(Player player : super.getPlayers()){
player.setCardsInHand(deck.getCards(numberOfCards));
}
stockPile = deck;
Card card = stockPile.removeCardFromTop();
System.out.println("");
System.out.println("Initial Card: *" + card.toString() + "*");
while ( card.getRankFaceValue() == 8 ) {
System.out.println("--------- Initial Card will be changed -----------");
stockPile.addCard(card);
stockPile.shuffle();
card = stockPile.removeCardFromTop();
}
// CardsStack starterPile = new CardsStack();
starterPile.addCard(card);
// Set initial legal rank and legal suite
if(super.getGameComponent() instanceof CrazyEightsTurn) {
( (CrazyEightsTurn)super.getGameComponent() ).setLegalRank( card.getRankFaceValue() );
( (CrazyEightsTurn)super.getGameComponent() ).setLegalSuite( card.getSuite() );
}
}
@Override
public void preRun() {
}
@Override
public void postRun() {
}
@Override
public boolean isGameCompleted() {
// If everyone has passed
if( consecutivePasses >= super.getPlayers().size() )
return true;
// If a player has 0 cards left
for( Player player : super.getPlayers() ) {
if( player.getCardsInHand().count() <= 0) {
return true;
}
}
return false;
}
public GameComponent getGameComponent() {
return super.getGameComponent();
}
public CardsStack getStarterPile() {
return starterPile;
}
public void setStarterPile(CardsStack starterPile) {
this.starterPile = starterPile;
}
public CardsStack getStockPile() {
return stockPile;
}
public void setStockPile(CardsStack stockPile) {
this.stockPile = stockPile;
}
}
| [
"rsdhupia@gmail.com"
] | rsdhupia@gmail.com |
8614683ec6e943f64a9b87260dde715688d679fc | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/25/25_f77d71453c46daea1abd64d3c6e93f0e89acd2bf/FileListStorage/25_f77d71453c46daea1abd64d3c6e93f0e89acd2bf_FileListStorage_s.java | 0a57a14027121d7dcba94c4f2ed490d7290f354c | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 27,128 | java | /*
FileListStorage.java / Frost
Copyright (C) 2007 Frost Project <jtcfrost.sourceforge.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package frost.storage.perst.filelist;
import java.beans.*;
import java.util.*;
import org.garret.perst.*;
import frost.*;
import frost.fileTransfer.*;
import frost.storage.*;
import frost.storage.perst.*;
public class FileListStorage extends AbstractFrostStorage implements ExitSavable, PropertyChangeListener {
private FileListStorageRoot storageRoot = null;
private static final String STORAGE_FILENAME = "filelist.dbs";
private static FileListStorage instance = new FileListStorage();
private boolean rememberSharedFileDownloaded;
protected FileListStorage() {
super();
}
public static FileListStorage inst() {
return instance;
}
@Override
public String getStorageFilename() {
return STORAGE_FILENAME;
}
@Override
public boolean initStorage() {
rememberSharedFileDownloaded = Core.frostSettings.getBoolValue(SettingsClass.REMEMBER_SHAREDFILE_DOWNLOADED);
Core.frostSettings.addPropertyChangeListener(SettingsClass.REMEMBER_SHAREDFILE_DOWNLOADED, this);
final String databaseFilePath = buildStoragePath(getStorageFilename()); // path to the database file
final int pagePoolSize = getPagePoolSize(SettingsClass.PERST_PAGEPOOLSIZE_FILELIST);
open(databaseFilePath, pagePoolSize, true, true, false);
storageRoot = (FileListStorageRoot)getStorage().getRoot();
if (storageRoot == null) {
// Storage was not initialized yet
storageRoot = new FileListStorageRoot(getStorage());
getStorage().setRoot(storageRoot);
commit(); // commit transaction
}
return true;
}
public void silentClose() {
close();
storageRoot = null;
}
public void exitSave() {
close();
storageRoot = null;
System.out.println("INFO: FileListStorage closed.");
}
public IPersistentList createList() {
return getStorage().createScalableList();
}
public boolean insertOrUpdateFileListFileObject(final FrostFileListFileObject flf) {
// check for dups and update them!
final FrostFileListFileObject pflf = storageRoot.getFileListFileObjects().get(flf.getSha());
if( pflf == null ) {
// insert new
storageRoot.getFileListFileObjects().put(flf.getSha(), flf);
for( final Iterator<FrostFileListFileObjectOwner> i = flf.getFrostFileListFileObjectOwnerIterator(); i.hasNext(); ) {
final FrostFileListFileObjectOwner o = i.next();
addFileListFileOwnerToIndices(o);
}
} else {
// update existing
updateFileListFileFromOtherFileListFile(pflf, flf);
}
return true;
}
/**
* Adds a new FrostFileListFileObjectOwner to the indices.
*/
private void addFileListFileOwnerToIndices(final FrostFileListFileObjectOwner o) {
// maybe the owner already shares other files
PerstIdentitiesFiles pif = storageRoot.getIdentitiesFiles().get(o.getOwner());
if( pif == null ) {
pif = new PerstIdentitiesFiles(o.getOwner(), getStorage());
storageRoot.getIdentitiesFiles().put(o.getOwner(), pif);
}
pif.addFileToIdentity(o);
// add to indices
maybeAddFileListFileInfoToIndex(o.getName(), o, storageRoot.getFileNameIndex());
maybeAddFileListFileInfoToIndex(o.getComment(), o, storageRoot.getFileCommentIndex());
maybeAddFileListFileInfoToIndex(o.getKeywords(), o, storageRoot.getFileKeywordIndex());
maybeAddFileListFileInfoToIndex(o.getOwner(), o, storageRoot.getFileOwnerIndex());
}
private void maybeAddFileListFileInfoToIndex(String lName, final FrostFileListFileObjectOwner o, final Index<PerstFileListIndexEntry> ix) {
if( lName == null || lName.length() == 0 ) {
return;
}
lName = lName.toLowerCase();
PerstFileListIndexEntry ie = ix.get(lName);
if( ie == null ) {
ie = new PerstFileListIndexEntry(getStorage());
ix.put(lName, ie);
}
ie.getFileOwnersWithText().add(o);
}
public FrostFileListFileObject getFileBySha(final String sha) {
if( !beginCooperativeThreadTransaction() ) {
return null;
}
final FrostFileListFileObject o;
try {
o = storageRoot.getFileListFileObjects().get(sha);
} finally {
endThreadTransaction();
}
return o;
}
public int getFileCount() {
if( !beginCooperativeThreadTransaction() ) {
return 0;
}
final int count;
try {
count = storageRoot.getFileListFileObjects().size();
} finally {
endThreadTransaction();
}
return count;
}
public int getFileCount(final String idUniqueName) {
if( !beginCooperativeThreadTransaction() ) {
return 0;
}
final int count;
try {
final PerstIdentitiesFiles pif = storageRoot.getIdentitiesFiles().get(idUniqueName);
if( pif != null ) {
count = pif.getFilesFromIdentity().size();
} else {
count = 0;
}
} finally {
endThreadTransaction();
}
return count;
}
public int getSharerCount() {
if( !beginCooperativeThreadTransaction() ) {
return 0;
}
final int count;
try {
count = storageRoot.getIdentitiesFiles().size();
} finally {
endThreadTransaction();
}
return count;
}
// FIXME: implement this faster, e.g. maintain the sum in storageRoot, update on each insert/remove
public long getFileSizes() {
if( !beginCooperativeThreadTransaction() ) {
return 0L;
}
long sizes = 0;
try {
for( final FrostFileListFileObject fo : storageRoot.getFileListFileObjects() ) {
sizes += fo.getSize();
}
} finally {
endThreadTransaction();
}
return sizes;
}
private void maybeRemoveFileListFileInfoFromIndex(
final String lName,
final FrostFileListFileObjectOwner o,
final Index<PerstFileListIndexEntry> ix)
{
if( lName != null && lName.length() > 0 ) {
final String lowerCaseName = lName.toLowerCase();
final PerstFileListIndexEntry ie = ix.get(lowerCaseName);
if( ie != null ) {
// System.out.println("ix-remove: "+o.getOid());
ie.getFileOwnersWithText().remove(o);
if( ie.getFileOwnersWithText().size() == 0 ) {
// no more owners for this text, remove from index
if( ix.remove(lowerCaseName) != null ) {
ie.deallocate();
}
}
}
}
}
/**
* Remove owners that were not seen for more than MINIMUM_DAYS_OLD days and have no CHK key set.
*/
public int cleanupFileListFileOwners(final boolean removeOfflineFilesWithKey, final int offlineFilesMaxDaysOld) {
if( !beginExclusiveThreadTransaction() ) {
return 0;
}
// final boolean removeOld07ChkKeys;
// if( FcpHandler.isFreenet07()
// && (storageRoot.getStorageStatus() & FileListStorageRoot.OLD_07_CHK_KEYS_REMOVED) == 0 )
// {
// removeOld07ChkKeys = true;
// } else {
// removeOld07ChkKeys = false;
// }
int count = 0;
try {
final long minVal = System.currentTimeMillis() - (offlineFilesMaxDaysOld * 24L * 60L * 60L * 1000L);
for( final PerstIdentitiesFiles pif : storageRoot.getIdentitiesFiles() ) {
for( final Iterator<FrostFileListFileObjectOwner> i = pif.getFilesFromIdentity().iterator(); i.hasNext(); ) {
final FrostFileListFileObjectOwner o = i.next();
boolean remove = false;
if( o.getLastReceived() < minVal ) {
// outdated owner
if( o.getKey() != null && o.getKey().length() > 0 ) {
// has a key
if( removeOfflineFilesWithKey ) {
remove = true;
}
} else {
// has no key
remove = true;
}
// } else if( removeOld07ChkKeys && FreenetKeys.isOld07ChkKey(o.getKey()) ) {
// // we have a key (outdated or not)
// // check if the key is an old 0.7 CHK key
// remove = true;
}
if( remove ) {
// remove this owner file info from file list object
final FrostFileListFileObject fof = o.getFileListFileObject();
o.setFileListFileObject(null);
fof.deleteFrostFileListFileObjectOwner(o);
// remove from indices
maybeRemoveFileListFileInfoFromIndex(o.getName(), o, storageRoot.getFileNameIndex());
maybeRemoveFileListFileInfoFromIndex(o.getComment(), o, storageRoot.getFileCommentIndex());
maybeRemoveFileListFileInfoFromIndex(o.getKeywords(), o, storageRoot.getFileKeywordIndex());
maybeRemoveFileListFileInfoFromIndex(o.getOwner(), o, storageRoot.getFileOwnerIndex());
// System.out.println("dealloc: "+o.getOid());
// remove this owner file info from identities files
i.remove();
// delete from store
o.deallocate();
fof.modify();
count++;
}
}
if( pif.getFilesFromIdentity().size() == 0 ) {
// no more files for this identity, remove
if( storageRoot.getIdentitiesFiles().remove(pif.getUniqueName()) != null ) {
pif.deallocate();
}
}
}
} finally {
endThreadTransaction();
}
return count;
}
/**
* Remove files that have no owner.
*/
public int cleanupFileListFiles() {
if( !beginExclusiveThreadTransaction() ) {
return 0;
}
// final boolean removeOld07ChkKeys;
// if( FcpHandler.isFreenet07()
// && (storageRoot.getStorageStatus() & FileListStorageRoot.OLD_07_CHK_KEYS_REMOVED) == 0 )
// {
// removeOld07ChkKeys = true;
// } else {
// removeOld07ChkKeys = false;
// }
int count = 0;
try {
for( final Iterator<FrostFileListFileObject> i = storageRoot.getFileListFileObjects().iterator(); i.hasNext(); ) {
final FrostFileListFileObject fof = i.next();
if( fof.getFrostFileListFileObjectOwnerListSize() == 0 ) {
// no more owners, we also have no name, remove
i.remove();
fof.deallocate();
count++;
}
}
} finally {
endThreadTransaction();
}
// if( removeOld07ChkKeys ) {
// // we removed the keys, update flag
// final int newStorageStatus = storageRoot.getStorageStatus() | FileListStorageRoot.OLD_07_CHK_KEYS_REMOVED;
// storageRoot.setStorageStatus( newStorageStatus );
// storageRoot.modify();
// }
return count;
}
/**
* Reset the lastdownloaded column for all file entries.
*/
public void resetLastDownloaded() {
if( !beginExclusiveThreadTransaction() ) {
return;
}
try {
for( final FrostFileListFileObject fof : storageRoot.getFileListFileObjects() ) {
fof.setLastDownloaded(0);
fof.modify();
}
} finally {
endThreadTransaction();
}
}
/**
* Update the item with SHA, set requestlastsent and requestssentcount.
* Does NOT commit!
*/
public boolean updateFrostFileListFileObjectAfterRequestSent(final String sha, final long requestLastSent) {
final FrostFileListFileObject oldSfo = getFileBySha(sha);
if( oldSfo == null ) {
return false;
}
oldSfo.setRequestLastSent(requestLastSent);
oldSfo.setRequestsSentCount(oldSfo.getRequestsSentCount() + 1);
oldSfo.modify();
return true;
}
/**
* Update the item with SHA, set requestlastsent and requestssentcount
* Does NOT commit!
*/
public boolean updateFrostFileListFileObjectAfterRequestReceived(final String sha, long requestLastReceived) {
final FrostFileListFileObject oldSfo = getFileBySha(sha);
if( oldSfo == null ) {
return false;
}
if( oldSfo.getRequestLastReceived() > requestLastReceived ) {
requestLastReceived = oldSfo.getRequestLastReceived();
}
oldSfo.setRequestLastReceived(requestLastReceived);
oldSfo.setRequestsReceivedCount(oldSfo.getRequestsReceivedCount() + 1);
oldSfo.modify();
return true;
}
/**
* Update the item with SHA, set lastdownloaded
*/
public boolean updateFrostFileListFileObjectAfterDownload(final String sha, final long lastDownloaded) {
if( !rememberSharedFileDownloaded ) {
return true;
}
if( !beginExclusiveThreadTransaction() ) {
return false;
}
try {
final FrostFileListFileObject oldSfo = getFileBySha(sha);
if( oldSfo == null ) {
endThreadTransaction();
return false;
}
oldSfo.setLastDownloaded(lastDownloaded);
oldSfo.modify();
} finally {
endThreadTransaction();
}
return true;
}
/**
* Retrieves a list of FrostSharedFileOjects.
*/
public void retrieveFiles(
final FileListCallback callback,
final List<String> names,
final List<String> comments,
final List<String> keywords,
final List<String> owners,
String[] extensions)
{
if( !beginCooperativeThreadTransaction() ) {
return;
}
System.out.println("Starting file search...");
final long t = System.currentTimeMillis();
boolean searchForNames = true;
boolean searchForComments = true;
boolean searchForKeywords = true;
boolean searchForOwners = true;
boolean searchForExtensions = true;
if( names == null || names.size() == 0 ) { searchForNames = false; }
if( comments == null || comments.size() == 0 ) { searchForComments = false; }
if( keywords == null || keywords.size() == 0 ) { searchForKeywords = false; }
if( owners == null || owners.size() == 0 ) { searchForOwners = false; }
if( extensions == null || extensions.length == 0 ) { searchForExtensions = false; }
try {
if( !searchForNames && !searchForComments && ! searchForKeywords && !searchForOwners && !searchForExtensions) {
// find ALL files
for(final FrostFileListFileObject o : storageRoot.getFileListFileObjects()) {
if(callback.fileRetrieved(o)) {
return; // stop requested
}
}
return;
}
if( !searchForExtensions ) {
extensions = null;
}
final HashSet<Integer> ownerOids = new HashSet<Integer>();
if( searchForNames || searchForExtensions ) {
searchForFiles(ownerOids, names, extensions, storageRoot.getFileNameIndex());
}
if( searchForComments ) {
searchForFiles(ownerOids, comments, null, storageRoot.getFileCommentIndex());
}
if( searchForKeywords ) {
searchForFiles(ownerOids, keywords, null, storageRoot.getFileKeywordIndex());
}
if( searchForOwners ) {
searchForFiles(ownerOids, owners, null, storageRoot.getFileOwnerIndex());
}
final HashSet<Integer> fileOids = new HashSet<Integer>();
for( final Integer i : ownerOids ) {
// System.out.println("search-oid: "+i);
final FrostFileListFileObjectOwner o = (FrostFileListFileObjectOwner)getStorage().getObjectByOID(i);
final int oid = o.getFileListFileObject().getOid();
fileOids.add(oid);
}
for( final Integer i : fileOids ) {
final FrostFileListFileObject o = (FrostFileListFileObject)getStorage().getObjectByOID(i);
if( o != null ) {
if(callback.fileRetrieved(o)) {
return;
}
}
}
} finally {
System.out.println("Finished file search, duration="+(System.currentTimeMillis() - t));
endThreadTransaction();
}
}
private void searchForFiles(
final HashSet<Integer> oids,
final List<String> searchStrings,
final String[] extensions, // only used for name search
final Index<PerstFileListIndexEntry> ix)
{
for(final Map.Entry<Object,PerstFileListIndexEntry> entry : ix.entryIterator() ) {
final String key = (String)entry.getKey();
if( searchStrings != null ) {
for(final String searchString : searchStrings) {
if( key.indexOf(searchString) > -1 ) {
// add all owner oids
final Iterator<FrostFileListFileObjectOwner> i = entry.getValue().getFileOwnersWithText().iterator();
while(i.hasNext()) {
final int oid = ((PersistentIterator)i).nextOid();
oids.add(oid);
}
}
}
}
if( extensions != null ) {
for( final String extension : extensions ) {
if( key.endsWith(extension) ) {
// add all owner oids
final Iterator<FrostFileListFileObjectOwner> i = entry.getValue().getFileOwnersWithText().iterator();
while(i.hasNext()) {
final int oid = ((PersistentIterator)i).nextOid();
oids.add(oid);
}
}
}
}
}
}
boolean alwaysUseLatestChkKey = true; // FIXME: must be true as long as the key changes now and then. False prevents fake files.
private boolean updateFileListFileFromOtherFileListFile(final FrostFileListFileObject oldFof, final FrostFileListFileObject newFof) {
// file is already in FILELIST table, maybe add new FILEOWNER and update fields
// maybe update oldSfo
boolean doUpdate = false;
if( oldFof.getKey() == null && newFof.getKey() != null ) {
oldFof.setKey(newFof.getKey()); doUpdate = true;
} else if( alwaysUseLatestChkKey
&& oldFof.getLastUploaded() < newFof.getLastUploaded()
&& oldFof.getKey() != null
&& newFof.getKey() != null
&& !oldFof.getKey().equals(newFof.getKey()) )
{
oldFof.setKey(newFof.getKey()); doUpdate = true;
// } else if( oldFof.getKey() != null && newFof.getKey() != null ) {
// // fix to replace 0.7 keys before 1010 on the fly
// if( FreenetKeys.isOld07ChkKey(oldFof.getKey()) ) {
// // replace old chk key with new one
// oldFof.setKey(newFof.getKey()); doUpdate = true;
// }
}
if( oldFof.getFirstReceived() > newFof.getFirstReceived() ) {
oldFof.setFirstReceived(newFof.getFirstReceived()); doUpdate = true;
}
if( oldFof.getLastReceived() < newFof.getLastReceived() ) {
oldFof.setLastReceived(newFof.getLastReceived()); doUpdate = true;
}
if( oldFof.getLastUploaded() < newFof.getLastUploaded() ) {
oldFof.setLastUploaded(newFof.getLastUploaded()); doUpdate = true;
}
if( oldFof.getLastDownloaded() < newFof.getLastDownloaded() ) {
oldFof.setLastDownloaded(newFof.getLastDownloaded()); doUpdate = true;
}
if( oldFof.getRequestLastReceived() < newFof.getRequestLastReceived() ) {
oldFof.setRequestLastReceived(newFof.getRequestLastReceived()); doUpdate = true;
}
if( oldFof.getRequestLastSent() < newFof.getRequestLastSent() ) {
oldFof.setRequestLastSent(newFof.getRequestLastSent()); doUpdate = true;
}
if( oldFof.getRequestsReceivedCount() < newFof.getRequestsReceivedCount() ) {
oldFof.setRequestsReceivedCount(newFof.getRequestsReceivedCount()); doUpdate = true;
}
if( oldFof.getRequestsSentCount() < newFof.getRequestsSentCount() ) {
oldFof.setRequestsSentCount(newFof.getRequestsSentCount()); doUpdate = true;
}
for(final Iterator<FrostFileListFileObjectOwner> i=newFof.getFrostFileListFileObjectOwnerIterator(); i.hasNext(); ) {
final FrostFileListFileObjectOwner obNew = i.next();
// check if we have an owner object for this sharer
FrostFileListFileObjectOwner obOld = null;
for(final Iterator<FrostFileListFileObjectOwner> j=oldFof.getFrostFileListFileObjectOwnerIterator(); j.hasNext(); ) {
final FrostFileListFileObjectOwner o = j.next();
if( o.getOwner().equals(obNew.getOwner()) ) {
obOld = o;
break;
}
}
if( obOld == null ) {
// add new
oldFof.addFrostFileListFileObjectOwner(obNew);
addFileListFileOwnerToIndices(obNew);
doUpdate = true;
} else {
// update existing
if( obOld.getLastReceived() < obNew.getLastReceived() ) {
maybeUpdateFileListInfoInIndex(obOld.getName(), obNew.getName(), obOld, storageRoot.getFileNameIndex());
obOld.setName(obNew.getName());
maybeUpdateFileListInfoInIndex(obOld.getComment(), obNew.getComment(), obOld, storageRoot.getFileCommentIndex());
obOld.setComment(obNew.getComment());
maybeUpdateFileListInfoInIndex(obOld.getKeywords(), obNew.getKeywords(), obOld, storageRoot.getFileKeywordIndex());
obOld.setKeywords(obNew.getKeywords());
obOld.setLastReceived(obNew.getLastReceived());
obOld.setLastUploaded(obNew.getLastUploaded());
obOld.setRating(obNew.getRating());
obOld.setKey(obNew.getKey());
obOld.modify();
doUpdate = true;
}
}
}
if( doUpdate ) {
oldFof.modify();
}
return doUpdate;
}
private void maybeUpdateFileListInfoInIndex(
final String oldValue,
final String newValue,
final FrostFileListFileObjectOwner o,
final Index<PerstFileListIndexEntry> ix)
{
// remove current value from index of needed, add new value to index if needed
if( oldValue != null ) {
if( newValue != null ) {
if( oldValue.toLowerCase().equals(newValue.toLowerCase()) ) {
// value not changed, ignore index change
return;
}
// we have to add this value to the index
maybeAddFileListFileInfoToIndex(newValue, o, ix);
}
// we have to remove the old value from index
maybeRemoveFileListFileInfoFromIndex(oldValue, o, ix);
}
}
public void propertyChange(final PropertyChangeEvent evt) {
rememberSharedFileDownloaded = Core.frostSettings.getBoolValue(SettingsClass.REMEMBER_SHAREDFILE_DOWNLOADED);
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
04726b69e1c81ed9f237e77846abc7508094ee14 | bc4a5a8e6b97b0240866b96b43b4164710291d9e | /src/main/java/com/test/todel/test/JsonTEST.java | 40ae34857cca4c0c6a187e7d5f57f31c222567d8 | [] | no_license | xingxiaolin/loudong | 547cdb1de9a8670c0f73f43c4eb7c28c87e59cab | 02cd556a8abec8fb1edb0e82934df45fff9da625 | refs/heads/master | 2023-03-19T18:55:50.470833 | 2021-03-09T03:48:02 | 2021-03-09T03:48:02 | 345,863,652 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,952 | java | package com.test.todel.test;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.test.todel.jsondatabind.UserEntity;
public class JsonTEST {
public static void main(String[] args) throws JsonProcessingException {
UserEntity user = new UserEntity();
user.setName("zhangsan");
user.setUid("zhangsan@163.com");
// user.setAge(20);
//
// SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
// user.setBirthday(dateformat.parse("1996-10-01"));
/**
* ObjectMapper是JSON操作的核心,Jackson的所有JSON操作都是在ObjectMapper中实现。
* ObjectMapper有多个JSON序列化的方法,可以把JSON字符串保存File、OutputStream等不同的介质中。
* writeValue(File arg0, Object arg1)把arg1转成json序列,并保存到arg0文件中。
* writeValue(OutputStream arg0, Object arg1)把arg1转成json序列,并保存到arg0输出流中。
* writeValueAsBytes(Object arg0)把arg0转成json序列,并把结果输出成字节数组。
* writeValueAsString(Object arg0)把arg0转成json序列,并把结果输出成字符串。
*/
ObjectMapper mapper = new ObjectMapper();
//User类转JSON
//输出结果:{"name":"zhangsan","age":20,"birthday":844099200000,"email":"zhangsan@163.com"}
String json = mapper.writeValueAsString(user);
System.out.println(json);
//Java集合转JSON
//输出结果:[{"name":"zhangsan","age":20,"birthday":844099200000,"email":"zhangsan@163.com"}]
List<UserEntity> users = new ArrayList<UserEntity>();
users.add(user);
String jsonlist = mapper.writeValueAsString(users);
System.out.println(jsonlist);
}
}
| [
"xingxiaolin212@sina.com"
] | xingxiaolin212@sina.com |
ca482587c4d9e641cd651c8b0ff2693a107aec94 | cfe1d18021d8f4121c7837357d73ac0a23646166 | /mediaplayer/jaxb/ObjectFactory.java | 54d856d1f817f3fa730c9521f393ff43112b05e0 | [] | no_license | feniyanto/MediaPlayer | e043038df356525167fff5d74c7e5a5936a374a9 | e8b62243e3b2e550bf6ecfc2a7a8aca20122c6eb | refs/heads/master | 2021-01-21T11:23:42.835591 | 2012-02-21T05:20:34 | 2012-02-21T05:20:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,586 | java | package mediaplayer.jaxb;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the MediaPlayer.jaxb package.
* <p>An ObjectFactory allows you to 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.
*
* @author Emil A. Lefkof III (2005-2006)
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _Playlist_QNAME = new QName("playlist");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.melloware.jspiff.jaxb
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link MetaType }
*
*/
public MetaType createMetaType() {
return new MetaType();
}
/**
* Create an instance of {@link PlaylistType }
*
*/
public PlaylistType createPlaylistType() {
return new PlaylistType();
}
/**
* Create an instance of {@link TrackType }
*
*/
public TrackType createTrackType() {
return new TrackType();
}
/**
* Create an instance of {@link AttributionType }
*
*/
public AttributionType createAttributionType() {
return new AttributionType();
}
/**
* Create an instance of {@link LinkType }
*
*/
public LinkType createLinkType() {
return new LinkType();
}
/**
* Create an instance of {@link TrackListType }
*
*/
public TrackListType createTrackListType() {
return new TrackListType();
}
/**
* Create an instance of {@link ExtensionType }
*
*/
public ExtensionType createExtensionType() {
return new ExtensionType();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link PlaylistType }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://xspf.org/ns/0/", name = "playlist")
public JAXBElement<PlaylistType> createPlaylist(PlaylistType value) {
return new JAXBElement<PlaylistType>(_Playlist_QNAME, PlaylistType.class, null, value);
}
}
| [
"myst1701@gmail.com"
] | myst1701@gmail.com |
3a8a0be2aacde410d5a18207371eb2cee361ec2c | baf0c5152a9e1d1bfac648c15136a9d39a0a3341 | /SSHJ/src/com/ssh/dao/BaseDao.java | 962c09774df1e28959c383bc13d832f8c15db4fa | [] | no_license | zhaoccx/FrameWork | 8a3015b5cfdaa3765ea45e93c9fe66786e1dfada | bbd4e121b6acb47e5330f315da4a74185c3e64ac | refs/heads/master | 2020-05-21T23:21:00.880641 | 2018-07-06T04:44:17 | 2018-07-06T04:44:17 | 29,951,828 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 368 | java | package com.ssh.dao;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
public class BaseDao {
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public Session getSession() {
return this.sessionFactory.getCurrentSession();
}
}
| [
"zhaoccx@hotmail.com"
] | zhaoccx@hotmail.com |
884724ecd4116b893c05cb306ded4304e46db7d3 | afb2a5da2693ddc7ae85e910bc255507789b3c38 | /parceler-api/src/main/java/org/parceler/Generated.java | fa190c4db062f5ecb8b1d18aa720782cb588875e | [
"Apache-2.0"
] | permissive | FlyingHeem/parceler | e93d2a8881ac37788a0ef131937efdbd96c2af33 | e03ce0f9ce6194d4ffff18f2d3c12e18f1fba6a0 | refs/heads/master | 2021-01-16T02:27:18.107164 | 2015-03-12T01:23:17 | 2015-03-12T01:23:17 | 32,388,159 | 1 | 0 | null | 2015-03-17T10:57:12 | 2015-03-17T10:57:12 | null | UTF-8 | Java | false | false | 1,475 | java | /**
* Copyright 2013-2015 John Ericksen
*
* 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 org.parceler;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.SOURCE;
/**
* Copy of the Java Generated annotation (absent in Android implementation)
*
* @author John Ericksen
*/
@Documented
@Retention(SOURCE)
@Target({PACKAGE, TYPE, ANNOTATION_TYPE, METHOD, CONSTRUCTOR, FIELD, LOCAL_VARIABLE, PARAMETER})
public @interface Generated {
/**
* Identifies the Generator used to generate the annotated class.
*/
java.lang.String[] value();
/**
* Specifies the date in ISO 8601 format when this class was generated.
*/
java.lang.String date() default "";
/**
* Contains any relevant comments.
*/
java.lang.String comments() default "";
}
| [
"johncarl81@gmail.com"
] | johncarl81@gmail.com |
a8e4ce885ebcb328dbc511c352cc6db5921b8390 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/18/18_4dd5e493ed5b0625bdc1da25929f8d7467a8a647/FloatingBox/18_4dd5e493ed5b0625bdc1da25929f8d7467a8a647_FloatingBox_t.java | 7b94745988836b8591d4d2e8880c5e0378c0f775 | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 13,153 | java | /* Catroid: An on-device graphical programming language for Android devices
* Copyright (C) 2010 Catroid development team
* (<http://code.google.com/p/catroid/wiki/Credits>)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package at.tugraz.ist.paintroid.graphic.utilities;
import java.util.Vector;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Cap;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import at.tugraz.ist.paintroid.graphic.DrawingSurface;
/**
* Class managing the floating box tools behavior
*
* Status: refactored 12.03.2011
* @author PaintroidTeam
* @version 6.0.4b
*/
public class FloatingBox extends Tool {
protected int default_width = 200;
protected int default_height = 200;
protected int width;
protected int height;
// Rotation of the box in degree
protected float rotation = 0;
// Tolerance that the resize action is performed if the frame is touched
protected float frameTolerance = 30;
// Distance from box frame to rotation symbol
protected int roationSymbolDistance = 30;
protected int roationSymbolWidth = 40;
protected ResizeAction resizeAction;
protected Bitmap floatingBoxBitmap = null;
protected Bitmap floatingBoxBitmap2 = null;
public enum FloatingBoxAction {
NONE, MOVE, RESIZE, ROTATE;
}
protected enum ResizeAction {
NONE, TOP, RIGHT, BOTTOM, LEFT, TOPLEFT, TOPRIGHT, BOTTOMLEFT, BOTTOMRIGHT;
}
/**
* constructor
*
* @param tool to copy
*/
public FloatingBox(Tool tool) {
super(tool);
resizeAction = ResizeAction.NONE;
reset();
}
/**
* Single tap while in floating box mode.
* If floating box is empty, the clipping is copied,
* else the copied clipping is used as a stamp.
*
* @param drawingSurface Drawing surface
* @return true if the event is consumed, else false
*/
public boolean singleTapEvent(DrawingSurface drawingSurface) {
if(state == ToolState.ACTIVE)
{
if(floatingBoxBitmap == null)
{
clipBitmap(drawingSurface);
}
else
{
stampBitmap(drawingSurface);
}
}
return true;
}
/**
* Copies the image below the floating box
*
* @param drawingSurface Drawing surface
*/
protected void clipBitmap(DrawingSurface drawingSurface)
{
Point left_top_box_bitmapcoordinates = drawingSurface.getPixelCoordinates(this.position.x-this.width/2, this.position.y-this.height/2);
Point right_bottom_box_bitmapcoordinates = drawingSurface.getPixelCoordinates(this.position.x+this.width/2, this.position.y+this.height/2);
floatingBoxBitmap = Bitmap.createBitmap(drawingSurface.getBitmap(), left_top_box_bitmapcoordinates.x, left_top_box_bitmapcoordinates.y, right_bottom_box_bitmapcoordinates.x-left_top_box_bitmapcoordinates.x, right_bottom_box_bitmapcoordinates.y-left_top_box_bitmapcoordinates.y);
}
protected void stampBitmap(DrawingSurface drawingSurface)
{
Canvas drawingCanvas = new Canvas(drawingSurface.getBitmap());
Paint bitmap_paint = new Paint(Paint.DITHER_FLAG);
float zoom_level = drawingSurface.getZoomLevel();
Point box_position_bitmapcoordinates = drawingSurface.getPixelCoordinates(this.position.x, this.position.y);
PointF size_bitmapcoordinates = new PointF((float)(this.width*3/4-15)/zoom_level, (float)(this.height*3/4-15)/zoom_level);
drawingCanvas.translate(box_position_bitmapcoordinates.x, box_position_bitmapcoordinates.y);
drawingCanvas.rotate(rotation);
drawingCanvas.drawBitmap(floatingBoxBitmap, null, new RectF(-size_bitmapcoordinates.x/2, -size_bitmapcoordinates.y/2, size_bitmapcoordinates.x/2, size_bitmapcoordinates.y/2), bitmap_paint);
}
/**
* double tap while in floating box mode
*
* @return true if event is used
*/
public boolean doubleTapEvent(){
return false;
}
/**
* draws the floating box
*
* @param view_canvas canvas on which to be drawn
* @param shape shape of the cursor to be drawn
* @param stroke_width stroke_width of the cursor to be drawn
* @param color color of the cursor to be drawn
*/
public void draw(Canvas view_canvas, Cap shape, int stroke_width, int color)
{
if(state == ToolState.ACTIVE)
{
view_canvas.translate(position.x, position.y);
view_canvas.rotate(rotation);
if(floatingBoxBitmap != null)
{
Paint bitmap_paint = new Paint(Paint.DITHER_FLAG);
view_canvas.drawBitmap(floatingBoxBitmap, null, new RectF(-this.width/2, -this.height/2, this.width/2, this.height/2), bitmap_paint);
}
DrawFunctions.setPaint(linePaint, Cap.ROUND, toolStrokeWidth, primaryColor, true, null);
view_canvas.drawRect(-this.width/2, this.height/2, this.width/2, -this.height/2, linePaint);
// Only draw rotation symbol if an image is present
if(floatingBoxBitmap != null)
{
view_canvas.drawCircle(-this.width/2-this.roationSymbolDistance-this.roationSymbolWidth/2, -this.height/2-this.roationSymbolDistance-this.roationSymbolWidth/2, this.roationSymbolWidth, linePaint);
}
DrawFunctions.setPaint(linePaint, Cap.ROUND, toolStrokeWidth, secundaryColor, true, new DashPathEffect(new float[] { 10, 20 }, 0));
view_canvas.drawRect(-this.width/2, this.height/2, this.width/2, -this.height/2, linePaint);
// Only draw rotation symbol if an image is present
if(floatingBoxBitmap != null)
{
view_canvas.drawCircle(-this.width/2-this.roationSymbolDistance-this.roationSymbolWidth/2, -this.height/2-this.roationSymbolDistance-this.roationSymbolWidth/2, this.roationSymbolWidth, linePaint);
}
view_canvas.restore();
}
}
/**
* Rotates the box
*
* @param delta_x move in direction x
* @param delta_y move in direction y
*/
public void rotate(float delta_x, float delta_y)
{
double rotationRadiant = rotation*Math.PI/180;
double delta_x_corrected = Math.cos(-rotationRadiant)*(delta_x)-Math.sin(-rotationRadiant)*(delta_y);
double delta_y_corrected = Math.sin(-rotationRadiant)*(delta_x)+Math.cos(-rotationRadiant)*(delta_y);
rotation += (delta_x_corrected-delta_y_corrected)/(5);
}
/**
* Resizes the box
*
* @param delta_x resize width
* @param delta_y resize height
*/
public void resize(float delta_x, float delta_y)
{
double rotationRadian = rotation*Math.PI/180;
double delta_x_corrected = Math.cos(-rotationRadian)*(delta_x)-Math.sin(-rotationRadian)*(delta_y);
double delta_y_corrected = Math.sin(-rotationRadian)*(delta_x)+Math.cos(-rotationRadian)*(delta_y);
float resize_x_move_center_x = (float) ((delta_x_corrected/2)*Math.cos(rotationRadian));
float resize_x_move_center_y = (float) ((delta_x_corrected/2)*Math.sin(rotationRadian));
float resize_y_move_center_x = (float) ((delta_y_corrected/2)*Math.sin(rotationRadian));
float resize_y_move_center_y = (float) ((delta_y_corrected/2)*Math.cos(rotationRadian));
switch (resizeAction) {
case TOP:
case TOPRIGHT:
case TOPLEFT:
this.height -= (int)delta_y_corrected;
this.position.x -= (int)resize_y_move_center_x;
this.position.y += (int)resize_y_move_center_y;
break;
case BOTTOM:
case BOTTOMLEFT:
case BOTTOMRIGHT:
this.height += (int)delta_y_corrected;
this.position.x -= (int)resize_y_move_center_x;
this.position.y += (int)resize_y_move_center_y;
break;
default:
break;
}
switch (resizeAction) {
case LEFT:
case TOPLEFT:
case BOTTOMLEFT:
this.width -= (int)delta_x_corrected;
this.position.x += (int)resize_x_move_center_x;
this.position.y += (int)resize_x_move_center_y;
break;
case RIGHT:
case TOPRIGHT:
case BOTTOMRIGHT:
this.width += (int)delta_x_corrected;
this.position.x += (int)resize_x_move_center_x;
this.position.y += (int)resize_x_move_center_y;
break;
default:
break;
}
//prevent that box gets too small
if(this.width < frameTolerance)
{
this.width = (int) frameTolerance;
}
if(this.height < frameTolerance)
{
this.height = (int) frameTolerance;
}
}
/**
* Resets the box to the default position
*
*/
public void reset()
{
this.width = default_width;
this.height = default_width;
this.position.x = this.screenSize.x/2;
this.position.y = this.screenSize.y/2;
this.rotation = 0;
this.floatingBoxBitmap = null;
}
/**
* Gets the action the user has selected through clicking on a specific
* position of the floating box
*
* @param clickCoordinates coordinates the user has touched
* @return action to perform
*/
public FloatingBoxAction getAction(float clickCoordinatesX, float clickCoordinatesY)
{
resizeAction = ResizeAction.NONE;
double rotationRadiant = rotation*Math.PI/180;
float clickCoordinatesRotatedX = (float) (this.position.x + Math.cos(-rotationRadiant)*(clickCoordinatesX-this.position.x)-Math.sin(-rotationRadiant)*(clickCoordinatesY-this.position.y));
float clickCoordinatesRotatedY = (float) (this.position.y + Math.sin(-rotationRadiant)*(clickCoordinatesX-this.position.x)+Math.cos(-rotationRadiant)*(clickCoordinatesY-this.position.y));
// Move (within box)
if(clickCoordinatesRotatedX < this.position.x+this.width/2-frameTolerance &&
clickCoordinatesRotatedX > this.position.x-this.width/2+frameTolerance &&
clickCoordinatesRotatedY < this.position.y+this.height/2-frameTolerance &&
clickCoordinatesRotatedY > this.position.y-this.height/2+frameTolerance)
{
return FloatingBoxAction.MOVE;
}
// Only allow rotation if an image is present
if(floatingBoxBitmap != null)
{
// Rotate (on symbol)
if(clickCoordinatesRotatedX < this.position.x-this.width/2-roationSymbolDistance &&
clickCoordinatesRotatedX > this.position.x-this.width/2-roationSymbolDistance-roationSymbolWidth &&
clickCoordinatesRotatedY < this.position.y-this.height/2-roationSymbolDistance &&
clickCoordinatesRotatedY > this.position.y-this.height/2-roationSymbolDistance-roationSymbolWidth)
{
return FloatingBoxAction.ROTATE;
}
}
// Resize (on frame)
if(clickCoordinatesRotatedX < this.position.x+this.width/2+frameTolerance &&
clickCoordinatesRotatedX > this.position.x-this.width/2-frameTolerance &&
clickCoordinatesRotatedY < this.position.y+this.height/2+frameTolerance &&
clickCoordinatesRotatedY > this.position.y-this.height/2-frameTolerance)
{
if(clickCoordinatesRotatedX < this.position.x-this.width/2+frameTolerance)
{
resizeAction = ResizeAction.LEFT;
}
else if(clickCoordinatesRotatedX > this.position.x+this.width/2-frameTolerance)
{
resizeAction = ResizeAction.RIGHT;
}
if(clickCoordinatesRotatedY < this.position.y-this.height/2+frameTolerance)
{
if(resizeAction == ResizeAction.LEFT)
{
resizeAction = ResizeAction.TOPLEFT;
} else if(resizeAction == ResizeAction.RIGHT)
{
resizeAction = ResizeAction.TOPRIGHT;
} else {
resizeAction = ResizeAction.TOP;
}
}
else if(clickCoordinatesRotatedY > this.position.y+this.height/2-frameTolerance)
{
if(resizeAction == ResizeAction.LEFT)
{
resizeAction = ResizeAction.BOTTOMLEFT;
} else if(resizeAction == ResizeAction.RIGHT)
{
resizeAction = ResizeAction.BOTTOMRIGHT;
} else {
resizeAction = ResizeAction.BOTTOM;
}
}
return FloatingBoxAction.RESIZE;
}
// No valid click
return FloatingBoxAction.NONE;
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
f9fd9b0d0cb332ce76fa3031cafdb4f4e33e96f0 | 855dbb07e21ba8ceb3b4487d8fef36da09ff9cd7 | /workspace/MergeSort_Tests/src/principal/ParallelMergeSort.java | 8bdec24bb9368a3359cf23bb096a57917be6009e | [] | no_license | RafasTavares/Estrutura-de-dados-Materiais-Alunos | fd7cc39c82e079cde97be2aedc4e3e2ef917593d | 93db25919e8636548f67adfa79c238449d9d261f | refs/heads/master | 2016-08-12T14:21:54.564846 | 2015-06-08T21:07:27 | 2015-06-08T21:07:27 | 36,172,757 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,664 | java | package principal;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
/**
* A multi threaded Merge Sort which will perform Parallel Merge Sort,The idea is to do splitting in the list
* in 2 different thread and then do the final merge in the parent thread. {@link java.util.concurrent.CyclicBarrier}
* is used to handle this splitting and merging
* @param <T> A generic Object which implements Comparable interface
* @see org.idey.sort.AbstractSort
* @see java.util.concurrent.Executors
* @see java.util.concurrent.ExecutorService
*/
public class ParallelMergeSort<T extends Comparable<T>> extends AbstractSort<T> {
private final int thresholds;
private final ExecutorService executor;
/**
*
* @param list List which will be sorted using Multi threading
* @param start start index of the list
* @param end end index of the list
* @param thresholds threshold beyond of which it will be executed as {@link org.idey.sort.SerialMergeSort}
* @see org.idey.sort.SerialMergeSort
*/
public ParallelMergeSort(List<T> list, int start, int end, final int thresholds) {
super(list, start, end);
if(thresholds >1){
this.thresholds = thresholds;
}else{
throw new IllegalArgumentException("Invalid threshold value");
}
executor = Executors.newCachedThreadPool();
}
public ParallelMergeSort(List<T> list, final int thresholds) {
this(list,0,list.size()-1, thresholds);
}
@Override
public void sort() {
try{
if(list!=null && !list.isEmpty()){
Future<?> sort = executor.submit(new ParallelMerge(start,end));
sort.get();
}
}catch (ExecutionException e){
throw new RuntimeException(e);
}catch(InterruptedException e){
throw new RuntimeException(e);
}finally {
executor.shutdown();
}
}
private class ParallelMerge implements Runnable{
private CyclicBarrier barrier;
private final int fromIndex;
private final int toIndex;
private ParallelMerge(CyclicBarrier barrier, final int fromIndex, final int toIndex) {
this.barrier = barrier;
this.fromIndex = fromIndex;
this.toIndex = toIndex;
}
private ParallelMerge(final int fromIndex, final int toIndex) {
this(null,fromIndex, toIndex);
}
@Override
public void run() {
try{
if(fromIndex != toIndex){
final int size = toIndex - fromIndex + 1;
//If the size is less than or equal to threshold it will execute as SerialMergeSort
if(size<= thresholds){
AbstractSort<T> sortObject = new SerialMergeSort<T>(list, fromIndex, toIndex);
sortObject.sort();
}else{
final int mid = (fromIndex+toIndex)/2;
CyclicBarrier c = new CyclicBarrier(2, new MergeRunnable(fromIndex, mid, toIndex));
ParallelMerge leftParallelMerge = new ParallelMerge(c,fromIndex,mid);
ParallelMerge rightParallelMerge = new ParallelMerge(c,mid+1,toIndex);
Future<?> leftFuture = executor.submit(leftParallelMerge);
Future<?> rightFuture = executor.submit(rightParallelMerge);
leftFuture.get();
rightFuture.get();
}
}
if(barrier !=null){
barrier.await();
}
}catch (ExecutionException e){
throw new RuntimeException(e);
}catch(InterruptedException e){
throw new RuntimeException(e);
}catch(BrokenBarrierException e){
throw new RuntimeException(e);
}
}
}
private class MergeRunnable implements Runnable{
private final int from;
private final int mid;
private final int to;
private MergeRunnable(final int from, final int mid, final int to) {
this.from = from;
this.mid = mid;
this.to = to;
}
@Override
public void run() {
merge(from, mid, to);
}
}
} | [
"rafaeltavaresandrade@gmail.com"
] | rafaeltavaresandrade@gmail.com |
42d4f718523a2e87148f624808b76ffc8004ba7f | a770e95028afb71f3b161d43648c347642819740 | /sources/org/telegram/tgnet/TLRPC$TL_pageBlockTable.java | c2e182a62cd8d483a9972482eb7fca028fdbf4f0 | [] | no_license | Edicksonjga/TGDecompiledBeta | d7aa48a2b39bbaefd4752299620ff7b72b515c83 | d1db6a445d5bed43c1dc8213fb8dbefd96f6c51b | refs/heads/master | 2023-08-25T04:12:15.592281 | 2021-10-28T20:24:07 | 2021-10-28T20:24:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,158 | java | package org.telegram.tgnet;
import java.util.ArrayList;
public class TLRPC$TL_pageBlockTable extends TLRPC$PageBlock {
public static int constructor = -NUM;
public boolean bordered;
public int flags;
public ArrayList<TLRPC$TL_pageTableRow> rows = new ArrayList<>();
public boolean striped;
public TLRPC$RichText title;
public void readParams(AbstractSerializedData abstractSerializedData, boolean z) {
int readInt32 = abstractSerializedData.readInt32(z);
this.flags = readInt32;
int i = 0;
this.bordered = (readInt32 & 1) != 0;
this.striped = (readInt32 & 2) != 0;
this.title = TLRPC$RichText.TLdeserialize(abstractSerializedData, abstractSerializedData.readInt32(z), z);
int readInt322 = abstractSerializedData.readInt32(z);
if (readInt322 == NUM) {
int readInt323 = abstractSerializedData.readInt32(z);
while (i < readInt323) {
TLRPC$TL_pageTableRow TLdeserialize = TLRPC$TL_pageTableRow.TLdeserialize(abstractSerializedData, abstractSerializedData.readInt32(z), z);
if (TLdeserialize != null) {
this.rows.add(TLdeserialize);
i++;
} else {
return;
}
}
} else if (z) {
throw new RuntimeException(String.format("wrong Vector magic, got %x", new Object[]{Integer.valueOf(readInt322)}));
}
}
public void serializeToStream(AbstractSerializedData abstractSerializedData) {
abstractSerializedData.writeInt32(constructor);
int i = this.bordered ? this.flags | 1 : this.flags & -2;
this.flags = i;
int i2 = this.striped ? i | 2 : i & -3;
this.flags = i2;
abstractSerializedData.writeInt32(i2);
this.title.serializeToStream(abstractSerializedData);
abstractSerializedData.writeInt32(NUM);
int size = this.rows.size();
abstractSerializedData.writeInt32(size);
for (int i3 = 0; i3 < size; i3++) {
this.rows.get(i3).serializeToStream(abstractSerializedData);
}
}
}
| [
"fabian_pastor@msn.com"
] | fabian_pastor@msn.com |
db4121eabf783e50d0271a39109a51292c7ca15e | 065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be | /eclipseswt_cluster/21918/src_1.java | 0433139cac332887513186696ae9fe8085d35571 | [] | no_license | martinezmatias/GenPat-data-C3 | 63cfe27efee2946831139747e6c20cf952f1d6f6 | b360265a6aa3bb21bd1d64f1fc43c3b37d0da2a4 | refs/heads/master | 2022-04-25T17:59:03.905613 | 2020-04-15T14:41:34 | 2020-04-15T14:41:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 67,855 | java | package org.eclipse.swt.graphics;
/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*/
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.*;
/**
* Class <code>GC</code> is where all of the drawing capabilities that are
* supported by SWT are located. Instances are used to draw on either an
* <code>Image</code>, a <code>Control</code>, or directly on a <code>Display</code>.
* <p>
* Application code must explicitly invoke the <code>GC.dispose()</code>
* method to release the operating system resources managed by each instance
* when those instances are no longer required. This is <em>particularly</em>
* important on Windows95 and Windows98 where the operating system has a limited
* number of device contexts available.
* </p>
*
* @see org.eclipse.swt.events.PaintEvent
*/
public final class GC {
/**
* the handle to the OS device context
* (Warning: This field is platform dependent)
*/
public int handle;
Drawable drawable;
GCData data;
GC() {
}
/**
* Constructs a new instance of this class which has been
* configured to draw on the specified drawable. Sets the
* foreground and background color in the GC to match those
* in the drawable.
* <p>
* You must dispose the graphics context when it is no longer required.
* </p>
* @param drawable the drawable to draw on
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the drawable is null</li>
* <li>ERROR_NULL_ARGUMENT - if there is no current device</li>
* <li>ERROR_INVALID_ARGUMENT
* - if the drawable is an image that is not a bitmap or an icon
* - if the drawable is an image or printer that is already selected
* into another graphics context</li>
* </ul>
* @exception SWTError <ul>
* <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
* </ul>
*/
public GC(Drawable drawable) {
if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
GCData data = new GCData();
int gdkGC = drawable.internal_new_GC(data);
init(drawable, data, gdkGC);
}
/**
* Copies a rectangular area of the receiver at the specified
* position into the image, which must be of type <code>SWT.BITMAP</code>.
*
* @param x the x coordinate in the receiver of the area to be copied
* @param y the y coordinate in the receiver of the area to be copied
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the image is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the image is not a bitmap or has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void copyArea(Image image, int x, int y) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
Rectangle rect = image.getBounds();
int gdkGC = OS.gdk_gc_new(image.pixmap);
if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.gdk_gc_set_subwindow(gdkGC, OS.GDK_INCLUDE_INFERIORS);
OS.gdk_draw_drawable(image.pixmap, gdkGC, data.drawable, x, y, 0, 0, rect.width, rect.height);
OS.g_object_unref(gdkGC);
}
/**
* Copies a rectangular area of the receiver at the source
* position onto the receiver at the destination position.
*
* @param srcX the x coordinate in the receiver of the area to be copied
* @param srcY the y coordinate in the receiver of the area to be copied
* @param width the width of the area to copy
* @param height the height of the area to copy
* @param destX the x coordinate in the receiver of the area to copy to
* @param destY the y coordinate in the receiver of the area to copy to
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width <= 0 || height <= 0) return;
int deltaX = destX - srcX, deltaY = destY - srcY;
if (deltaX == 0 && deltaY == 0) return;
int drawable = data.drawable;
OS.gdk_gc_set_exposures(handle, true);
OS.gdk_draw_drawable(drawable, handle, drawable, srcX, srcY, destX, destY, width, height);
OS.gdk_gc_set_exposures(handle, false);
if (data.image != null) return;
boolean disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY);
GdkRectangle rect = new GdkRectangle ();
if (disjoint) {
rect.x = srcX;
rect.y = srcY;
rect.width = width;
rect.height = height;
OS.gdk_window_invalidate_rect (drawable, rect, false);
// OS.gdk_window_clear_area_e(drawable, srcX, srcY, width, height);
} else {
if (deltaX != 0) {
int newX = destX - deltaX;
if (deltaX < 0) newX = destX + width;
rect.x = newX;
rect.y = srcY;
rect.width = Math.abs(deltaX);
rect.height = height;
OS.gdk_window_invalidate_rect (drawable, rect, false);
// OS.gdk_window_clear_area_e(drawable, newX, srcY, Math.abs(deltaX), height);
}
if (deltaY != 0) {
int newY = destY - deltaY;
if (deltaY < 0) newY = destY + height;
rect.x = srcX;
rect.y = newY;
rect.width = width;
rect.height = Math.abs(deltaY);
OS.gdk_window_invalidate_rect (drawable, rect, false);
// OS.gdk_window_clear_area_e(drawable, srcX, newY, width, Math.abs(deltaY));
}
}
}
/**
* Disposes of the operating system resources associated with
* the graphics context. Applications must dispose of all GCs
* which they allocate.
*/
public void dispose() {
if (handle == 0) return;
if (data.device.isDisposed()) return;
/* Free resources */
int clipRgn = data.clipRgn;
if (clipRgn != 0) OS.gdk_region_destroy(clipRgn);
Image image = data.image;
if (image != null) {
image.memGC = null;
if (image.transparentPixel != -1) image.createMask();
}
int context = data.context;
if (context != 0) OS.g_object_unref(context);
int layout = data.layout;
if (layout != 0) OS.g_object_unref(layout);
/* Dispose the GC */
drawable.internal_dispose_GC(handle, data);
data.layout = data.context = data.drawable = data.clipRgn = 0;
drawable = null;
data.image = null;
data = null;
handle = 0;
}
/**
* Draws the outline of a circular or elliptical arc
* within the specified rectangular area.
* <p>
* The resulting arc begins at <code>startAngle</code> and extends
* for <code>arcAngle</code> degrees, using the current color.
* Angles are interpreted such that 0 degrees is at the 3 o'clock
* position. A positive value indicates a counter-clockwise rotation
* while a negative value indicates a clockwise rotation.
* </p><p>
* The center of the arc is the center of the rectangle whose origin
* is (<code>x</code>, <code>y</code>) and whose size is specified by the
* <code>width</code> and <code>height</code> arguments.
* </p><p>
* The resulting arc covers an area <code>width + 1</code> pixels wide
* by <code>height + 1</code> pixels tall.
* </p>
*
* @param x the x coordinate of the upper-left corner of the arc to be drawn
* @param y the y coordinate of the upper-left corner of the arc to be drawn
* @param width the width of the arc to be drawn
* @param height the height of the arc to be drawn
* @param startAngle the beginning angle
* @param arcAngle the angular extent of the arc, relative to the start angle
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if any of the width, height or endAngle is zero.</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawArc(int x, int y, int width, int height, int startAngle, int endAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0) {
x = x + width;
width = -width;
}
if (height < 0) {
y = y + height;
height = -height;
}
if (width == 0 || height == 0 || endAngle == 0) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
OS.gdk_draw_arc(data.drawable, handle, 0, x, y, width, height, startAngle * 64, endAngle * 64);
}
/**
* Draws a rectangle, based on the specified arguments, which has
* the appearance of the platform's <em>focus rectangle</em> if the
* platform supports such a notion, and otherwise draws a simple
* rectangle in the receiver's foreground color.
*
* @param x the x coordinate of the rectangle
* @param y the y coordinate of the rectangle
* @param width the width of the rectangle
* @param height the height of the rectangle
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #drawRectangle
*/
public void drawFocus(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
GtkStyle style = new GtkStyle();
//CHECK - default style might not be attached to any window
OS.memmove(style, OS.gtk_widget_get_default_style());
GdkColor color = new GdkColor();
color.pixel = style.fg0_pixel;
color.red = style.fg0_red;
color.green = style.fg0_green;
color.blue = style.fg0_blue;
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
OS.gdk_gc_set_foreground(handle, color);
OS.gdk_draw_rectangle(data.drawable, handle, 0, x, y, width, height);
color.pixel = values.foreground_pixel;
color.red = values.foreground_red;
color.green = values.foreground_green;
color.blue = values.foreground_blue;
OS.gdk_gc_set_foreground(handle, color);
}
/**
* Draws the given image in the receiver at the specified
* coordinates.
*
* @param image the image to draw
* @param x the x coordinate of where to draw
* @param y the y coordinate of where to draw
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the image is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
* <li>ERROR_INVALID_ARGUMENT - if the given coordinates are outside the bounds of the image</li>
* @exception SWTError <ul>
* <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawImage(Image image, int x, int y) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
}
/**
* Copies a rectangular area from the source image into a (potentially
* different sized) rectangular area in the receiver. If the source
* and destination areas are of differing sizes, then the source
* area will be stretched or shrunk to fit the destination area
* as it is copied. The copy fails if any part of the source rectangle
* lies outside the bounds of the source image, or if any of the width
* or height arguments are negative.
*
* @param image the source image
* @param srcX the x coordinate in the source image to copy from
* @param srcY the y coordinate in the source image to copy from
* @param srcWidth the width in pixels to copy from the source
* @param srcHeight the height in pixels to copy from the source
* @param destX the x coordinate in the destination to copy to
* @param destY the y coordinate in the destination to copy to
* @param destWidth the width in pixels of the destination rectangle
* @param destHeight the height in pixels of the destination rectangle
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the image is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
* <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
* <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
* </ul>
* @exception SWTError <ul>
* <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
SWT.error (SWT.ERROR_INVALID_ARGUMENT);
}
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
}
void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
int[] width = new int[1];
int[] height = new int[1];
OS.gdk_drawable_get_size(srcImage.pixmap, width, height);
int imgWidth = width[0];
int imgHeight = height[0];
if (simple) {
srcWidth = destWidth = imgWidth;
srcHeight = destHeight = imgHeight;
} else {
simple = srcX == 0 && srcY == 0 &&
srcWidth == destWidth && destWidth == imgWidth &&
srcHeight == destHeight && destHeight == imgHeight;
if (srcX + srcWidth > imgWidth || srcY + srcHeight > imgHeight) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
}
if (srcImage.alpha != -1 || srcImage.alphaData != null) {
drawImageAlpha(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
} else if (srcImage.transparentPixel != -1 || srcImage.mask != 0) {
drawImageMask(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
} else {
drawImage(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
}
}
void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight) {
if (srcWidth == destWidth && srcHeight == destHeight) {
OS.gdk_draw_drawable(data.drawable, handle, srcImage.pixmap, srcX, srcY, destX, destY, destWidth, destHeight);
} else {
int pixbuf = scale(srcImage.pixmap, srcX, srcY, srcWidth, srcHeight, destWidth, destHeight);
OS.gdk_pixbuf_render_to_drawable(pixbuf, data.drawable, handle, 0, 0, destX, destY, destWidth, destHeight, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
OS.g_object_unref(pixbuf);
}
}
void drawImageAlpha(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight) {
if (srcImage.alpha == 0) return;
if (srcImage.alpha == 255) {
drawImage(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
return;
}
int pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, true, 8, srcWidth, srcHeight);
if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
int colormap = OS.gdk_colormap_get_system();
OS.gdk_pixbuf_get_from_drawable(pixbuf, srcImage.pixmap, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight);
int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
int pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
byte[] line = new byte[stride];
byte alpha = (byte)srcImage.alpha;
byte[] alphaData = srcImage.alphaData;
for (int y=0; y<srcHeight; y++) {
int alphaIndex = (y + srcY) * imgWidth + srcX;
OS.memmove(line, pixels + (y * stride), stride);
for (int x=3; x<stride; x+=4) {
line[x] = alphaData == null ? alpha : alphaData[alphaIndex++];
}
OS.memmove(pixels + (y * stride), line, stride);
}
if (srcWidth != destWidth || srcHeight != destHeight) {
int scaledPixbuf = OS.gdk_pixbuf_scale_simple(pixbuf, destWidth, destHeight, OS.GDK_INTERP_BILINEAR);
OS.g_object_unref(pixbuf);
if (scaledPixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
pixbuf = scaledPixbuf;
}
OS.gdk_pixbuf_render_to_drawable_alpha(
pixbuf, data.drawable,
0, 0, destX, destY, destWidth, destHeight,
OS.GDK_PIXBUF_ALPHA_BILEVEL, 128, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
OS.g_object_unref(pixbuf);
}
void drawImageMask(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight) {
int drawable = data.drawable;
int colorPixmap = srcImage.pixmap;
/* Generate the mask if necessary. */
if (srcImage.transparentPixel != -1) srcImage.createMask();
int maskPixmap = srcImage.mask;
if (srcWidth != destWidth || srcHeight != destHeight) {
//NOT DONE - there must be a better way of scaling a GdkBitmap
int pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, true, 8, srcWidth, srcHeight);
if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
int colormap = OS.gdk_colormap_get_system();
OS.gdk_pixbuf_get_from_drawable(pixbuf, colorPixmap, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight);
int gdkImagePtr = OS.gdk_drawable_get_image(maskPixmap, 0, 0, imgWidth, imgHeight);
int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
int pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
if (gdkImagePtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);
byte[] line = new byte[stride];
for (int y=0; y<srcHeight; y++) {
OS.memmove(line, pixels + (y * stride), stride);
for (int x=0; x<srcWidth; x++) {
if (OS.gdk_image_get_pixel(gdkImagePtr, x + srcX, y + srcY) != 0) {
line[x*4+3] = (byte)0xFF;
} else {
line[x*4+3] = 0;
}
}
OS.memmove(pixels + (y * stride), line, stride);
}
OS.g_object_unref(gdkImagePtr);
int scaledPixbuf = OS.gdk_pixbuf_scale_simple(pixbuf, destWidth, destHeight, OS.GDK_INTERP_BILINEAR);
OS.g_object_unref(pixbuf);
if (scaledPixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.gdk_pixbuf_render_to_drawable_alpha(
scaledPixbuf, data.drawable,
0, 0, destX, destY, destWidth, destHeight,
OS.GDK_PIXBUF_ALPHA_BILEVEL, 128, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
OS.g_object_unref(scaledPixbuf);
} else {
/* Blit cliping the mask */
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
OS.gdk_gc_set_clip_mask(handle, maskPixmap);
OS.gdk_gc_set_clip_origin(handle, destX - srcX, destY - srcY);
OS.gdk_draw_drawable(drawable, handle, colorPixmap, srcX, srcY, destX, destY, srcWidth, srcHeight);
OS.gdk_gc_set_values(handle, values, OS.GDK_GC_CLIP_MASK | OS.GDK_GC_CLIP_X_ORIGIN | OS.GDK_GC_CLIP_Y_ORIGIN);
}
/* Destroy scaled pixmaps */
if (colorPixmap != 0 && srcImage.pixmap != colorPixmap) OS.g_object_unref(colorPixmap);
if (maskPixmap != 0 && srcImage.mask != maskPixmap) OS.g_object_unref(maskPixmap);
/* Destroy the image mask if the there is a GC created on the image */
if (srcImage.transparentPixel != -1 && srcImage.memGC != null) srcImage.destroyMask();
}
int scale(int src, int srcX, int srcY, int srcWidth, int srcHeight, int destWidth, int destHeight) {
int pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, srcWidth, srcHeight);
if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
int colormap = OS.gdk_colormap_get_system();
OS.gdk_pixbuf_get_from_drawable(pixbuf, src, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight);
int scaledPixbuf = OS.gdk_pixbuf_scale_simple(pixbuf, destWidth, destHeight, OS.GDK_INTERP_BILINEAR);
OS.g_object_unref(pixbuf);
if (scaledPixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
return scaledPixbuf;
}
/**
* Draws a line, using the foreground color, between the points
* (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>).
*
* @param x1 the first point's x coordinate
* @param y1 the first point's y coordinate
* @param x2 the second point's x coordinate
* @param y2 the second point's y coordinate
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawLine(int x1, int y1, int x2, int y2) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
OS.gdk_draw_line (data.drawable, handle, x1, y1, x2, y2);
}
/**
* Draws the outline of an oval, using the foreground color,
* within the specified rectangular area.
* <p>
* The result is a circle or ellipse that fits within the
* rectangle specified by the <code>x</code>, <code>y</code>,
* <code>width</code>, and <code>height</code> arguments.
* </p><p>
* The oval covers an area that is <code>width + 1</code>
* pixels wide and <code>height + 1</code> pixels tall.
* </p>
*
* @param x the x coordinate of the upper left corner of the oval to be drawn
* @param y the y coordinate of the upper left corner of the oval to be drawn
* @param width the width of the oval to be drawn
* @param height the height of the oval to be drawn
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawOval(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0) {
x = x + width;
width = -width;
}
if (height < 0) {
y = y + height;
height = -height;
}
OS.gdk_draw_arc(data.drawable, handle, 0, x, y, width, height, 0, 23040);
}
/**
* Draws the closed polygon which is defined by the specified array
* of integer coordinates, using the receiver's foreground color. The array
* contains alternating x and y values which are considered to represent
* points which are the vertices of the polygon. Lines are drawn between
* each consecutive pair, and between the first pair and last pair in the
* array.
*
* @param pointArray an array of alternating x and y values which are the vertices of the polygon
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT if pointArray is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawPolygon(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
OS.gdk_draw_polygon(data.drawable, handle, 0, pointArray, pointArray.length / 2);
}
/**
* Draws the polyline which is defined by the specified array
* of integer coordinates, using the receiver's foreground color. The array
* contains alternating x and y values which are considered to represent
* points which are the corners of the polyline. Lines are drawn between
* each consecutive pair, but not between the first pair and last pair in
* the array.
*
* @param pointArray an array of alternating x and y values which are the corners of the polyline
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the point array is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawPolyline(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
OS.gdk_draw_lines(data.drawable, handle, pointArray, pointArray.length / 2);
}
/**
* Draws the outline of the rectangle specified by the arguments,
* using the receiver's foreground color. The left and right edges
* of the rectangle are at <code>x</code> and <code>x + width</code>.
* The top and bottom edges are at <code>y</code> and <code>y + height</code>.
*
* @param x the x coordinate of the rectangle to be drawn
* @param y the y coordinate of the rectangle to be drawn
* @param width the width of the rectangle to be drawn
* @param height the height of the rectangle to be drawn
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawRectangle(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0) {
x = x + width;
width = -width;
}
if (height < 0) {
y = y + height;
height = -height;
}
OS.gdk_draw_rectangle(data.drawable, handle, 0, x, y, width, height);
}
/**
* Draws the outline of the specified rectangle, using the receiver's
* foreground color. The left and right edges of the rectangle are at
* <code>rect.x</code> and <code>rect.x + rect.width</code>. The top
* and bottom edges are at <code>rect.y</code> and
* <code>rect.y + rect.height</code>.
*
* @param rect the rectangle to draw
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawRectangle(Rectangle rect) {
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
drawRectangle (rect.x, rect.y, rect.width, rect.height);
}
/**
* Draws the outline of the round-cornered rectangle specified by
* the arguments, using the receiver's foreground color. The left and
* right edges of the rectangle are at <code>x</code> and <code>x + width</code>.
* The top and bottom edges are at <code>y</code> and <code>y + height</code>.
* The <em>roundness</em> of the corners is specified by the
* <code>arcWidth</code> and <code>arcHeight</code> arguments.
*
* @param x the x coordinate of the rectangle to be drawn
* @param y the y coordinate of the rectangle to be drawn
* @param width the width of the rectangle to be drawn
* @param height the height of the rectangle to be drawn
* @param arcWidth the horizontal diameter of the arc at the four corners
* @param arcHeight the vertical diameter of the arc at the four corners
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int nx = x;
int ny = y;
int nw = width;
int nh = height;
int naw = arcWidth;
int nah = arcHeight;
if (nw < 0) {
nw = 0 - nw;
nx = nx - nw;
}
if (nh < 0) {
nh = 0 - nh;
ny = ny -nh;
}
if (naw < 0)
naw = 0 - naw;
if (nah < 0)
nah = 0 - nah;
int naw2 = naw / 2;
int nah2 = nah / 2;
int drawable = data.drawable;
if (nw > naw) {
if (nh > nah) {
OS.gdk_draw_arc(drawable, handle, 0, nx, ny, naw, nah, 5760, 5760);
OS.gdk_draw_line(drawable, handle, nx + naw2, ny, nx + nw - naw2, ny);
OS.gdk_draw_arc(drawable, handle, 0, nx + nw - naw, ny, naw, nah, 0, 5760);
OS.gdk_draw_line(drawable, handle, nx + nw, ny + nah2, nx + nw, ny + nh - nah2);
OS.gdk_draw_arc(drawable, handle, 0, nx + nw - naw, ny + nh - nah, naw, nah, 17280, 5760);
OS.gdk_draw_line(drawable,handle, nx + naw2, ny + nh, nx + nw - naw2, ny + nh);
OS.gdk_draw_arc(drawable, handle, 0, nx, ny + nh - nah, naw, nah, 11520, 5760);
OS.gdk_draw_line(drawable, handle, nx, ny + nah2, nx, ny + nh - nah2);
} else {
OS.gdk_draw_arc(drawable, handle, 0, nx, ny, naw, nh, 5760, 11520);
OS.gdk_draw_line(drawable, handle, nx + naw2, ny, nx + nw - naw2, ny);
OS.gdk_draw_arc(drawable, handle, 0, nx + nw - naw, ny, naw, nh, 17280, 11520);
OS.gdk_draw_line(drawable,handle, nx + naw2, ny + nh, nx + nw - naw2, ny + nh);
}
} else {
if (nh > nah) {
OS.gdk_draw_arc(drawable, handle, 0, nx, ny, nw, nah, 0, 11520);
OS.gdk_draw_line(drawable, handle, nx + nw, ny + nah2, nx + nw, ny + nh - nah2);
OS.gdk_draw_arc(drawable, handle, 0, nx, ny + nh - nah, nw, nah, 11520, 11520);
OS.gdk_draw_line(drawable,handle, nx, ny + nah2, nx, ny + nh - nah2);
} else {
OS.gdk_draw_arc(drawable, handle, 0, nx, ny, nw, nh, 0, 23040);
}
}
}
/**
* Draws the given string, using the receiver's current font and
* foreground color. No tab expansion or carriage return processing
* will be performed. The background of the rectangular area where
* the string is being drawn will be filled with the receiver's
* background color.
*
* @param string the string to be drawn
* @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
* @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the string is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawString (String string, int x, int y) {
drawString(string, x, y, false);
}
/**
* Draws the given string, using the receiver's current font and
* foreground color. No tab expansion or carriage return processing
* will be performed. If <code>isTransparent</code> is <code>true</code>,
* then the background of the rectangular area where the string is being
* drawn will not be modified, otherwise it will be filled with the
* receiver's background color.
*
* @param string the string to be drawn
* @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
* @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
* @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the string is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawString(String string, int x, int y, boolean isTransparent) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
//FIXME - need to avoid delimiter and tabs
int layout = data.layout;
byte[] buffer = Converter.wcsToMbcs(null, string, true);
OS.pango_layout_set_text(layout, buffer, buffer.length - 1);
OS.gdk_draw_layout(data.drawable, handle, x, y, layout);
}
/**
* Draws the given string, using the receiver's current font and
* foreground color. Tab expansion and carriage return processing
* are performed. The background of the rectangular area where
* the text is being drawn will be filled with the receiver's
* background color.
*
* @param string the string to be drawn
* @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
* @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the string is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawText(String string, int x, int y) {
drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
}
/**
* Draws the given string, using the receiver's current font and
* foreground color. Tab expansion and carriage return processing
* are performed. If <code>isTransparent</code> is <code>true</code>,
* then the background of the rectangular area where the text is being
* drawn will not be modified, otherwise it will be filled with the
* receiver's background color.
*
* @param string the string to be drawn
* @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
* @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
* @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the string is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawText(String string, int x, int y, boolean isTransparent) {
int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
drawText(string, x, y, flags);
}
/**
* Draws the given string, using the receiver's current font and
* foreground color. Tab expansion, line delimiter and mnemonic
* processing are performed according to the specified flags. If
* <code>flags</code> includes <code>DRAW_TRANSPARENT</code>,
* then the background of the rectangular area where the text is being
* drawn will not be modified, otherwise it will be filled with the
* receiver's background color.
* <p>
* The parameter <code>flags</code> may be a combination of:
* <dl>
* <dt><b>DRAW_DELIMITER</b></dt>
* <dd>draw multiple lines</dd>
* <dt><b>DRAW_TAB</b></dt>
* <dd>expand tabs</dd>
* <dt><b>DRAW_MNEMONIC</b></dt>
* <dd>underline the mnemonic character</dd>
* <dt><b>DRAW_TRANSPARENT</b></dt>
* <dd>transparent background</dd>
* </dl>
* </p>
*
* @param string the string to be drawn
* @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
* @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
* @param flags the flags specifing how to process the text
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the string is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void drawText (String string, int x, int y, int flags) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
//FIXME - check flags
int layout = data.layout;
byte[] buffer = Converter.wcsToMbcs(null, string, true);
OS.pango_layout_set_text(layout, buffer, buffer.length - 1);
OS.gdk_draw_layout(data.drawable, handle, x, y, layout);
}
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
* specific comparison.
*
* @param object the object to compare with this object
* @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
*
* @see #hashCode
*/
public boolean equals(Object object) {
if (object == this) return true;
if (!(object instanceof GC)) return false;
return handle == ((GC)object).handle;
}
/**
* Fills the interior of a circular or elliptical arc within
* the specified rectangular area, with the receiver's background
* color.
* <p>
* The resulting arc begins at <code>startAngle</code> and extends
* for <code>arcAngle</code> degrees, using the current color.
* Angles are interpreted such that 0 degrees is at the 3 o'clock
* position. A positive value indicates a counter-clockwise rotation
* while a negative value indicates a clockwise rotation.
* </p><p>
* The center of the arc is the center of the rectangle whose origin
* is (<code>x</code>, <code>y</code>) and whose size is specified by the
* <code>width</code> and <code>height</code> arguments.
* </p><p>
* The resulting arc covers an area <code>width + 1</code> pixels wide
* by <code>height + 1</code> pixels tall.
* </p>
*
* @param x the x coordinate of the upper-left corner of the arc to be filled
* @param y the y coordinate of the upper-left corner of the arc to be filled
* @param width the width of the arc to be filled
* @param height the height of the arc to be filled
* @param startAngle the beginning angle
* @param arcAngle the angular extent of the arc, relative to the start angle
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if any of the width, height or endAngle is zero.</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #drawArc
*/
public void fillArc(int x, int y, int width, int height, int startAngle, int endAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0) {
x = x + width;
width = -width;
}
if (height < 0) {
y = y + height;
height = -height;
}
if (width == 0 || height == 0 || endAngle == 0) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
color.pixel = values.background_pixel;
OS.gdk_gc_set_foreground(handle, color);
OS.gdk_draw_arc(data.drawable, handle, 1, x, y, width, height, startAngle * 64, endAngle * 64);
color.pixel = values.foreground_pixel;
OS.gdk_gc_set_foreground(handle, color);
}
/**
* Fills the interior of the specified rectangle with a gradient
* sweeping from left to right or top to bottom progressing
* from the receiver's foreground color to its background color.
*
* @param x the x coordinate of the rectangle to be filled
* @param y the y coordinate of the rectangle to be filled
* @param width the width of the rectangle to be filled, may be negative
* (inverts direction of gradient if horizontal)
* @param height the height of the rectangle to be filled, may be negative
* (inverts direction of gradient if vertical)
* @param vertical if true sweeps from top to bottom, else
* sweeps from left to right
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #drawRectangle
*/
public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if ((width == 0) || (height == 0)) return;
/* Rewrite this to use GdkPixbuf */
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
RGB backgroundRGB, foregroundRGB;
backgroundRGB = getBackground().getRGB();
foregroundRGB = getForeground().getRGB();
RGB fromRGB, toRGB;
fromRGB = foregroundRGB;
toRGB = backgroundRGB;
boolean swapColors = false;
if (width < 0) {
x += width; width = -width;
if (! vertical) swapColors = true;
}
if (height < 0) {
y += height; height = -height;
if (vertical) swapColors = true;
}
if (swapColors) {
fromRGB = backgroundRGB;
toRGB = foregroundRGB;
}
if (fromRGB == toRGB) {
fillRectangle(x, y, width, height);
return;
}
ImageData.fillGradientRectangle(this, data.device,
x, y, width, height, vertical, fromRGB, toRGB,
8, 8, 8);
}
/**
* Fills the interior of an oval, within the specified
* rectangular area, with the receiver's background
* color.
*
* @param x the x coordinate of the upper left corner of the oval to be filled
* @param y the y coordinate of the upper left corner of the oval to be filled
* @param width the width of the oval to be filled
* @param height the height of the oval to be filled
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #drawOval
*/
public void fillOval(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0) {
x = x + width;
width = -width;
}
if (height < 0) {
y = y + height;
height = -height;
}
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
color.pixel = values.background_pixel;
OS.gdk_gc_set_foreground(handle, color);
OS.gdk_draw_arc(data.drawable, handle, 1, x, y, width, height, 0, 23040);
color.pixel = values.foreground_pixel;
OS.gdk_gc_set_foreground(handle, color);
}
/**
* Fills the interior of the closed polygon which is defined by the
* specified array of integer coordinates, using the receiver's
* background color. The array contains alternating x and y values
* which are considered to represent points which are the vertices of
* the polygon. Lines are drawn between each consecutive pair, and
* between the first pair and last pair in the array.
*
* @param pointArray an array of alternating x and y values which are the vertices of the polygon
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT if pointArray is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #drawPolygon
*/
public void fillPolygon(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
color.pixel = values.background_pixel;
OS.gdk_gc_set_foreground(handle, color);
OS.gdk_draw_polygon(data.drawable, handle, 1, pointArray, pointArray.length / 2);
color.pixel = values.foreground_pixel;
OS.gdk_gc_set_foreground(handle, color);
}
/**
* Fills the interior of the rectangle specified by the arguments,
* using the receiver's background color.
*
* @param x the x coordinate of the rectangle to be filled
* @param y the y coordinate of the rectangle to be filled
* @param width the width of the rectangle to be filled
* @param height the height of the rectangle to be filled
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #drawRectangle
*/
public void fillRectangle(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0) {
x = x + width;
width = -width;
}
if (height < 0) {
y = y + height;
height = -height;
}
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
color.pixel = values.background_pixel;
OS.gdk_gc_set_foreground(handle, color);
OS.gdk_draw_rectangle(data.drawable, handle, 1, x, y, width, height);
color.pixel = values.foreground_pixel;
OS.gdk_gc_set_foreground(handle, color);
}
/**
* Fills the interior of the specified rectangle, using the receiver's
* background color.
*
* @param rectangle the rectangle to be filled
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #drawRectangle
*/
public void fillRectangle(Rectangle rect) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
fillRectangle(rect.x, rect.y, rect.width, rect.height);
}
/**
* Fills the interior of the round-cornered rectangle specified by
* the arguments, using the receiver's background color.
*
* @param x the x coordinate of the rectangle to be filled
* @param y the y coordinate of the rectangle to be filled
* @param width the width of the rectangle to be filled
* @param height the height of the rectangle to be filled
* @param arcWidth the horizontal diameter of the arc at the four corners
* @param arcHeight the vertical diameter of the arc at the four corners
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #drawRoundRectangle
*/
public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int nx = x;
int ny = y;
int nw = width;
int nh = height;
int naw = arcWidth;
int nah = arcHeight;
if (nw < 0) {
nw = 0 - nw;
nx = nx - nw;
}
if (nh < 0) {
nh = 0 - nh;
ny = ny -nh;
}
if (naw < 0)
naw = 0 - naw;
if (nah < 0)
nah = 0 - nah;
int naw2 = naw / 2;
int nah2 = nah / 2;
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
color.pixel = values.background_pixel;
OS.gdk_gc_set_foreground(handle, color);
int drawable = data.drawable;
if (nw > naw) {
if (nh > nah) {
OS.gdk_draw_arc(drawable, handle, 1, nx, ny, naw, nah, 5760, 5760);
OS.gdk_draw_arc(drawable, handle, 1, nx, ny + nh - nah, naw, nah, 11520, 5760);
OS.gdk_draw_arc(drawable, handle, 1, nx + nw - naw, ny + nh - nah, naw, nah, 17280, 5760);
OS.gdk_draw_arc(drawable, handle, 1, nx + nw - naw, ny, naw, nah, 0, 5760);
OS.gdk_draw_rectangle(drawable, handle, 1, nx + naw2, ny, nw - naw, nh);
OS.gdk_draw_rectangle(drawable, handle, 1, nx, ny + nah2, naw2, nh - nah);
OS.gdk_draw_rectangle(drawable, handle, 1, nx + nw - naw2, ny + nah2, naw2, nh -nah);
} else {
OS.gdk_draw_arc(drawable, handle, 1, nx, ny, naw, nh, 5760, 11520);
OS.gdk_draw_rectangle(drawable, handle, 1, nx + naw2, ny, nw - naw, nh);
OS.gdk_draw_arc(drawable, handle, 1, nx + nw - naw, ny, naw, nh, 17280, 11520);
}
} else {
if (nh > nah) {
OS.gdk_draw_arc(drawable, handle, 1, nx, ny, nw, nah, 0, 11520);
OS.gdk_draw_rectangle(drawable, handle, 1, nx, ny + nah2, nw, nh - nah);
OS.gdk_draw_arc(drawable, handle, 1, nx, ny + nh - nah, nw, nah, 11520, 11520);
} else {
OS.gdk_draw_arc(drawable, handle, 1, nx, ny, nw, nh, 0, 23040);
}
}
color.pixel = values.foreground_pixel;
OS.gdk_gc_set_foreground(handle, color);
}
/**
* Returns the <em>advance width</em> of the specified character in
* the font which is currently selected into the receiver.
* <p>
* The advance width is defined as the horizontal distance the cursor
* should move after printing the character in the selected font.
* </p>
*
* @param ch the character to measure
* @return the distance in the x direction to move past the character before painting the next
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public int getAdvanceWidth(char ch) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
//BOGUS
return stringExtent(new String(new char[]{ch})).x;
}
/**
* Returns the background color.
*
* @return the receiver's background color
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Color getBackground() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
int colormap = OS.gdk_colormap_get_system();
OS.gdk_colormap_query_color(colormap, values.background_pixel, color);
return Color.gtk_new(data.device, color);
}
/**
* Returns the width of the specified character in the font
* selected into the receiver.
* <p>
* The width is defined as the space taken up by the actual
* character, not including the leading and tailing whitespace
* or overhang.
* </p>
*
* @param ch the character to measure
* @return the width of the character
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public int getCharWidth(char ch) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
//BOGUS
return stringExtent(new String(new char[]{ch})).x;
}
/**
* Returns the bounding rectangle of the receiver's clipping
* region. If no clipping region is set, the return value
* will be a rectangle which covers the entire bounds of the
* object the receiver is drawing on.
*
* @return the bounding rectangle of the clipping region
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Rectangle getClipping() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int clipRgn = data.clipRgn;
if (clipRgn == 0) {
int[] width = new int[1]; int[] height = new int[1];
OS.gdk_drawable_get_size(data.drawable, width, height);
return new Rectangle(0, 0, width[0], height[0]);
}
GdkRectangle rect = new GdkRectangle();
OS.gdk_region_get_clipbox(clipRgn, rect);
return new Rectangle(rect.x, rect.y, rect.width, rect.height);
}
/**
* Sets the region managed by the argument to the current
* clipping region of the receiver.
*
* @param region the region to fill with the clipping region
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the region is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void getClipping(Region region) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
int hRegion = region.handle;
int clipRgn = data.clipRgn;
OS.gdk_region_subtract(hRegion, hRegion);
if (data.clipRgn == 0) {
int[] width = new int[1]; int[] height = new int[1];
OS.gdk_drawable_get_size(data.drawable, width, height);
GdkRectangle rect = new GdkRectangle();
rect.x = 0; rect.y = 0;
rect.width = width[0]; rect.height = height[0];
OS.gdk_region_union_with_rect(hRegion, rect);
return;
}
OS.gdk_region_union(hRegion, clipRgn);
}
/**
* Returns the font currently being used by the receiver
* to draw and measure text.
*
* @return the receiver's font
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Font getFont() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return Font.gtk_new(data.device, data.font);
}
/**
* Returns a FontMetrics which contains information
* about the font currently being used by the receiver
* to draw and measure text.
*
* @return font metrics for the receiver's font
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public FontMetrics getFontMetrics() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int context = data.context;
//FIXME - figure out correct language
byte[] buffer = Converter.wcsToMbcs(null, "en_US", true);
int lang = OS.pango_language_from_string(buffer);
// int lang = OS.pango_context_get_language(context);
int metrics = OS.pango_context_get_metrics(context, data.font, lang);
FontMetrics fm = new FontMetrics();
fm.ascent = OS.PANGO_PIXELS(OS.pango_font_metrics_get_ascent(metrics));
fm.descent = OS.PANGO_PIXELS(OS.pango_font_metrics_get_descent(metrics));
fm.averageCharWidth = OS.PANGO_PIXELS(OS.pango_font_metrics_get_approximate_char_width(metrics));
fm.height = fm.ascent + fm.descent;
OS.pango_font_metrics_unref(metrics);
return fm;
}
/**
* Returns the receiver's foreground color.
*
* @return the color used for drawing foreground things
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Color getForeground() {
if (handle == 0) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
int colormap = OS.gdk_colormap_get_system();
OS.gdk_colormap_query_color(colormap, values.foreground_pixel, color);
return Color.gtk_new(data.device, color);
}
/**
* Returns the receiver's line style, which will be one
* of the constants <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>,
* <code>SWT.LINE_DOT</code>, <code>SWT.LINE_DASHDOT</code> or
* <code>SWT.LINE_DASHDOTDOT</code>.
*
* @return the style used for drawing lines
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public int getLineStyle() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.lineStyle;
}
/**
* Returns the width that will be used when drawing lines
* for all of the figure drawing operations (that is,
* <code>drawLine</code>, <code>drawRectangle</code>,
* <code>drawPolyline</code>, and so forth.
*
* @return the receiver's line width
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public int getLineWidth() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
return values.line_width;
}
/**
* Returns <code>true</code> if this GC is drawing in the mode
* where the resulting color in the destination is the
* <em>exclusive or</em> of the color values in the source
* and the destination, and <code>false</code> if it is
* drawing in the mode where the destination color is being
* replaced with the source color value.
*
* @return <code>true</code> true if the receiver is in XOR mode, and false otherwise
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public boolean getXORMode() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
return values.function == OS.GDK_XOR;
}
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
* <code>equals</code> must return the same value for this
* method.
*
* @return the receiver's hash
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #equals
*/
public int hashCode() {
return handle;
}
void init(Drawable drawable, GCData data, int gdkGC) {
int context = OS.gdk_pango_context_get();
if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
data.context = context;
int layout = OS.pango_layout_new(context);
if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
data.layout = layout;
GdkColor foreground = data.foreground;
if (foreground != null) OS.gdk_gc_set_foreground(gdkGC, foreground);
GdkColor background = data.background;
if (background != null) OS.gdk_gc_set_background (gdkGC, background);
int font = data.font;
if (font != 0) OS.pango_layout_set_font_description(layout, font);
Image image = data.image;
if (image != null) {
image.memGC = this;
/*
* The transparent pixel mask might change when drawing on
* the image. Destroy it so that it is regenerated when
* necessary.
*/
if (image.transparentPixel != -1) image.destroyMask();
}
this.drawable = drawable;
this.data = data;
handle = gdkGC;
}
/**
* Returns <code>true</code> if the receiver has a clipping
* region set into it, and <code>false</code> otherwise.
* If this method returns false, the receiver will draw on all
* available space in the destination. If it returns true,
* it will draw only in the area that is covered by the region
* that can be accessed with <code>getClipping(region)</code>.
*
* @return <code>true</code> if the GC has a clipping region, and <code>false</code> otherwise
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public boolean isClipped() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.clipRgn != 0;
}
/**
* Returns <code>true</code> if the GC has been disposed,
* and <code>false</code> otherwise.
* <p>
* This method gets the dispose state for the GC.
* When a GC has been disposed, it is an error to
* invoke any other method using the GC.
*
* @return <code>true</code> when the GC is disposed and <code>false</code> otherwise
*/
public boolean isDisposed() {
return handle == 0;
}
/**
* Sets the background color. The background color is used
* for fill operations and as the background color when text
* is drawn.
*
* @param color the new background color for the receiver
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the color is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void setBackground(Color color) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
OS.gdk_gc_set_background(handle, color.handle);
}
/**
* Sets the area of the receiver which can be changed
* by drawing operations to the rectangular area specified
* by the arguments.
*
* @param x the x coordinate of the clipping rectangle
* @param y the y coordinate of the clipping rectangle
* @param width the width of the clipping rectangle
* @param height the height of the clipping rectangle
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void setClipping(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int clipRgn = data.clipRgn;
if (clipRgn == 0) {
data.clipRgn = clipRgn = OS.gdk_region_new();
} else {
OS.gdk_region_subtract(clipRgn, clipRgn);
}
GdkRectangle rect = new GdkRectangle();
rect.x = x; rect.y = y;
rect.width = width; rect.height = height;
OS.gdk_gc_set_clip_rectangle(handle, rect);
OS.gdk_region_union_with_rect(clipRgn, rect);
}
/**
* Sets the area of the receiver which can be changed
* by drawing operations to the rectangular area specified
* by the argument.
*
* @param rect the clipping rectangle
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void setClipping(Rectangle rect) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int clipRgn = data.clipRgn;
if (rect == null) {
OS.gdk_gc_set_clip_region(handle, 0);
if (clipRgn != 0) {
OS.gdk_region_destroy(clipRgn);
data.clipRgn = clipRgn = 0;
}
return;
}
setClipping (rect.x, rect.y, rect.width, rect.height);
}
/**
* Sets the area of the receiver which can be changed
* by drawing operations to the region specified
* by the argument.
*
* @param rect the clipping region.
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void setClipping(Region region) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int clipRgn = data.clipRgn;
if (region == null) {
OS.gdk_gc_set_clip_region(handle, 0);
if (clipRgn != 0) {
OS.gdk_region_destroy(clipRgn);
data.clipRgn = clipRgn = 0;
}
} else {
if (clipRgn == 0) {
data.clipRgn = clipRgn = OS.gdk_region_new();
} else {
OS.gdk_region_subtract(clipRgn, clipRgn);
}
OS.gdk_region_union(clipRgn, region.handle);
OS.gdk_gc_set_clip_region(handle, clipRgn);
}
}
/**
* Sets the font which will be used by the receiver
* to draw and measure text to the argument. If the
* argument is null, then a default font appropriate
* for the platform will be used instead.
*
* @param font the new font for the receiver, or null to indicate a default font
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void setFont(Font font) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (font == null) font = data.device.systemFont;
if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int fontHandle = data.font = font.handle;
OS.pango_layout_set_font_description(data.layout, fontHandle);
}
/**
* Sets the foreground color. The foreground color is used
* for drawing operations including when text is drawn.
*
* @param color the new foreground color for the receiver
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the color is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void setForeground(Color color) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
OS.gdk_gc_set_foreground(handle, color.handle);
}
/**
* Sets the receiver's line style to the argument, which must be one
* of the constants <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>,
* <code>SWT.LINE_DOT</code>, <code>SWT.LINE_DASHDOT</code> or
* <code>SWT.LINE_DASHDOTDOT</code>.
*
* @param lineStyle the style to be used for drawing lines
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void setLineStyle(int lineStyle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
switch (lineStyle) {
case SWT.LINE_SOLID:
this.data.lineStyle = lineStyle;
OS.gdk_gc_set_line_attributes(handle, 0, OS.GDK_LINE_SOLID, OS.GDK_CAP_BUTT, OS.GDK_JOIN_MITER);
return;
case SWT.LINE_DASH:
OS.gdk_gc_set_dashes(handle, 0, new byte[] {6, 2}, 2);
break;
case SWT.LINE_DOT:
OS.gdk_gc_set_dashes(handle, 0, new byte[] {3, 1}, 2);
break;
case SWT.LINE_DASHDOT:
OS.gdk_gc_set_dashes(handle, 0, new byte[] {6, 2, 3, 1}, 4);
break;
case SWT.LINE_DASHDOTDOT:
OS.gdk_gc_set_dashes(handle, 0, new byte[] {6, 2, 3, 1, 3, 1}, 6);
break;
default:
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
data.lineStyle = lineStyle;
OS.gdk_gc_set_line_attributes(handle, 0, OS.GDK_LINE_DOUBLE_DASH, OS.GDK_CAP_BUTT, OS.GDK_JOIN_MITER);
}
/**
* Sets the width that will be used when drawing lines
* for all of the figure drawing operations (that is,
* <code>drawLine</code>, <code>drawRectangle</code>,
* <code>drawPolyline</code>, and so forth.
*
* @param lineWidth the width of a line
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void setLineWidth(int width) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (data.lineStyle == SWT.LINE_SOLID) {
OS.gdk_gc_set_line_attributes(handle, width, OS.GDK_LINE_SOLID, OS.GDK_CAP_BUTT, OS.GDK_JOIN_MITER);
} else {
OS.gdk_gc_set_line_attributes(handle, width, OS.GDK_LINE_DOUBLE_DASH, OS.GDK_CAP_BUTT, OS.GDK_JOIN_MITER);
}
}
/**
* If the argument is <code>true</code>, puts the receiver
* in a drawing mode where the resulting color in the destination
* is the <em>exclusive or</em> of the color values in the source
* and the destination, and if the argument is <code>false</code>,
* puts the receiver in a drawing mode where the destination color
* is replaced with the source color value.
*
* @param xor if <code>true</code>, then <em>xor</em> mode is used, otherwise <em>source copy</em> mode is used
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void setXORMode(boolean val) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
OS.gdk_gc_set_function(handle, val ? OS.GDK_XOR : OS.GDK_COPY);
}
/**
* Returns the extent of the given string. No tab
* expansion or carriage return processing will be performed.
* <p>
* The <em>extent</em> of a string is the width and height of
* the rectangular area it would cover if drawn in a particular
* font (in this case, the current font in the receiver).
* </p>
*
* @param string the string to measure
* @return a point containing the extent of the string
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the string is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Point stringExtent(String string) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
//FIXME - need to avoid delimiter and tabs
int layout = data.layout;
byte[] buffer = Converter.wcsToMbcs(null, string, true);
OS.pango_layout_set_text(layout, buffer, buffer.length - 1);
int[] width = new int[1];
int[] height = new int[1];
OS.pango_layout_get_size(layout, width, height);
return new Point(OS.PANGO_PIXELS(width[0]), OS.PANGO_PIXELS(height[0]));
}
/**
* Returns the extent of the given string. Tab expansion and
* carriage return processing are performed.
* <p>
* The <em>extent</em> of a string is the width and height of
* the rectangular area it would cover if drawn in a particular
* font (in this case, the current font in the receiver).
* </p>
*
* @param string the string to measure
* @return a point containing the extent of the string
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the string is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Point textExtent(String string) {
return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
}
/**
* Returns the extent of the given string. Tab expansion, line
* delimiter and mnemonic processing are performed according to
* the specified flags, which can be a combination of:
* <dl>
* <dt><b>DRAW_DELIMITER</b></dt>
* <dd>draw multiple lines</dd>
* <dt><b>DRAW_TAB</b></dt>
* <dd>expand tabs</dd>
* <dt><b>DRAW_MNEMONIC</b></dt>
* <dd>underline the mnemonic character</dd>
* <dt><b>DRAW_TRANSPARENT</b></dt>
* <dd>transparent background</dd>
* </dl>
* <p>
* The <em>extent</em> of a string is the width and height of
* the rectangular area it would cover if drawn in a particular
* font (in this case, the current font in the receiver).
* </p>
*
* @param string the string to measure
* @param flags the flags specifing how to process the text
* @return a point containing the extent of the string
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the string is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Point textExtent(String string, int flags) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
//FIXME - check flags
int layout = data.layout;
byte[] buffer = Converter.wcsToMbcs(null, string, true);
OS.pango_layout_set_text(layout, buffer, buffer.length - 1);
int[] width = new int[1];
int[] height = new int[1];
OS.pango_layout_get_size(layout, width, height);
return new Point(OS.PANGO_PIXELS(width[0]), OS.PANGO_PIXELS(height[0]));
}
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
public String toString () {
if (isDisposed()) return "GC {*DISPOSED*}";
return "GC {" + handle + "}";
}
}
| [
"375833274@qq.com"
] | 375833274@qq.com |
e540452f2578a10fcb278cc71bbee0c6caccb462 | ae2cccc9bb017205e8e96860d352109d4e2343b6 | /app/src/main/java/smartshop/com/smartshop/activities/LoginActivity.java | 30dc2418d1a6561305bc8522726d99b16ef911fd | [] | no_license | vickyck/SmartShop | 938228f1cd24a76cdcc62bcc165354ccb84607bb | 7a038c76b59500b7f7d455c3e3bec80909bcf4d6 | refs/heads/master | 2021-08-14T10:40:15.558205 | 2017-11-15T11:42:05 | 2017-11-15T11:42:05 | 110,823,185 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,140 | java | package smartshop.com.smartshop.activities;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputEditText;
import android.support.design.widget.TextInputLayout;
import android.support.v4.widget.ListViewCompat;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatButton;
import android.support.v7.widget.AppCompatTextView;
import android.speech.RecognizerIntent;
import android.speech.tts.TextToSpeech;
import android.content.ActivityNotFoundException;
import android.text.Editable;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Toast;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.Locale;
import smartshop.com.smartshop.R;
import smartshop.com.smartshop.helpers.InputValidation;
import smartshop.com.smartshop.sql.DatabaseHelper;
public class LoginActivity extends AppCompatActivity implements View.OnClickListener, TextToSpeech.OnInitListener {
private final AppCompatActivity activity = LoginActivity.this;
private NestedScrollView nestedScrollView;
private TextInputLayout textInputLayoutEmail;
private TextInputLayout textInputLayoutPassword;
private TextInputEditText textInputEditTextEmail;
private TextInputEditText textInputEditTextPassword;
private AppCompatButton appCompatButtonLogin;
private AppCompatButton appCompatButtonSpeak;
private TextToSpeech speechEngine;
private ListView speechListView;
private AppCompatTextView textViewLinkRegister;
private InputValidation inputValidation;
private DatabaseHelper databaseHelper;
private static int loginFailureCount = 0;
private static int invalidEmailFailureCount = 0;
protected static final int RESULT_SPEECH = 1;
public static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;
@Override
public void onInit(int i) {
if (i == TextToSpeech.SUCCESS) {
//Setting speech Language
speechEngine.setLanguage(Locale.US);
speechEngine.setPitch(1);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
speechEngine = new TextToSpeech(this, this);
setContentView(R.layout.activity_login);
getSupportActionBar().hide();
initViews();
initListeners();
initObjects();
}
/**
* This method is to initialize views
*/
private void initViews() {
nestedScrollView = (NestedScrollView) findViewById(R.id.nestedScrollView);
textInputLayoutEmail = (TextInputLayout) findViewById(R.id.textInputLayoutEmail);
textInputLayoutPassword = (TextInputLayout) findViewById(R.id.textInputLayoutPassword);
textInputEditTextEmail = (TextInputEditText) findViewById(R.id.textInputEditTextEmail);
textInputEditTextPassword = (TextInputEditText) findViewById(R.id.textInputEditTextPassword);
appCompatButtonLogin = (AppCompatButton) findViewById(R.id.appCompatButtonLogin);
appCompatButtonSpeak = (AppCompatButton) findViewById(R.id.appCompatButtonSpeak);
textViewLinkRegister = (AppCompatTextView) findViewById(R.id.textViewLinkRegister);
speechListView = (ListView) findViewById(R.id.speechListView);
}
/**
* This method is to initialize listeners
*/
private void initListeners() {
appCompatButtonLogin.setOnClickListener(this);
appCompatButtonSpeak.setOnClickListener(this);
textViewLinkRegister.setOnClickListener(this);
}
/**
* This method is to initialize objects to be used
*/
private void initObjects() {
databaseHelper = new DatabaseHelper(activity);
inputValidation = new InputValidation(activity);
}
/**
* This implemented method is to listen the click on view
*
* @param v
*/
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.appCompatButtonLogin:
verifyFromSQLite();
break;
case R.id.textViewLinkRegister:
// Navigate to RegisterActivity
Intent intentRegister = new Intent(getApplicationContext(), RegisterActivity.class);
startActivity(intentRegister);
break;
case R.id.appCompatButtonSpeak:
// Navigate to RegisterActivity
speechEngine.speak(getString(R.string.SayPin), TextToSpeech.QUEUE_FLUSH, null, null);
Intent intent = new Intent(
RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en-US");
intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 10000);
intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say your Pin");
try {
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
} catch (ActivityNotFoundException a) {
Toast t = Toast.makeText(getApplicationContext(),
"Oops! Your device doesn't support Speech to Text",
Toast.LENGTH_SHORT);
t.show();
}
break;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
speechListView.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, matches));
String matchedText = "";
for(int i = 0; i < matches.size(); i++)
{
if (matches.get(i) != "")
{
matchedText += matches.get(i);
}
}
if (verifySpeechInputFromSQLite(matchedText))
{
// Navigate to the product list activity class
speechEngine.speak(getString(R.string.TodaysDealTitleText), TextToSpeech.QUEUE_FLUSH, null, null);
Intent accountsIntent = new Intent(activity, ProductListActivity.class);
startActivity(accountsIntent);
emptyInputEditText();
}
else
{
speechEngine.speak(getString(R.string.InvalidPin), TextToSpeech.QUEUE_FLUSH, null, null);
}
}
}
/**
* This method is to validate the input text fields and verify login credentials from SQLite
*/
private void verifyFromSQLite() {
if (!inputValidation.isInputEditTextFilled(textInputEditTextEmail, textInputLayoutEmail, getString(R.string.error_message_email))) {
return;
}
if (!inputValidation.isInputEditTextEmail(textInputEditTextEmail, textInputLayoutEmail, getString(R.string.error_message_email))) {
return;
}
if (!inputValidation.isInputEditTextFilled(textInputEditTextPassword, textInputLayoutPassword, getString(R.string.error_message_email))) {
return;
}
if (databaseHelper.checkUser(textInputEditTextEmail.getText().toString().trim()
, textInputEditTextPassword.getText().toString().trim())) {
Intent accountsIntent = new Intent(activity, ProductListActivity.class);
accountsIntent.putExtra("EMAIL", textInputEditTextEmail.getText().toString().trim());
emptyInputEditText();
startActivity(accountsIntent);
} else {
// Snack Bar to show success message that record is wrong
Snackbar.make(nestedScrollView, getString(R.string.error_valid_email_password), Snackbar.LENGTH_LONG).show();
}
}
private boolean verifySpeechInputFromSQLite(String Pin) {
if (!inputValidation.ValidText(Pin, getString(R.string.InvalidPin))) {
return false;
}
if (databaseHelper.findUserByPin(Pin.trim())) {
return true;
} else {
// Snack Bar to show success message that record is wrong
Snackbar.make(nestedScrollView, getString(R.string.InvalidPin), Snackbar.LENGTH_LONG).show();
return false;
}
}
/**
* This method is to empty all input edit text
*/
private void emptyInputEditText() {
textInputEditTextEmail.setText(null);
textInputEditTextPassword.setText(null);
}
}
| [
"vicky.ck@gmail.com"
] | vicky.ck@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.