id
stringlengths
36
36
text
stringlengths
1
1.25M
04dbe1fc-e2fc-4c83-8d48-3637c9433bc3
public static List<Map> grabMeiziPhoto(int pageNumber) throws IOException, ParseException { List<Map> result = new ArrayList<Map>(); SimpleDateFormat dateConvert = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String pageUrl = Const.chunTuMeiziPageUrl + pageNumber; String pageContent = Ne...
cf6232cb-e716-4ddd-8df7-1ac8dffa5b91
public static List<Map> grabMeinvPhoto(int pageNumber) throws IOException, ParseException { List<Map> result = new ArrayList<Map>(0); SimpleDateFormat dateConvert = new SimpleDateFormat("yyyy年MM月dd日"); String pageUrl = Const.chunTuMeinvPageUrl + pageNumber; String pageExtUrl = Const.chu...
682c129b-f79f-44c6-abd3-1bdcfdd407ad
public static List<Map> grabTuwenPhoto(int pageNumber) throws IOException, ParseException { List<Map> result = new ArrayList<Map>(0); SimpleDateFormat dateConvert = new SimpleDateFormat("yyyy年MM月dd日"); String pageUrl = Const.chunTuTuwenPageUrl + pageNumber; String pageExtUrl = Const.chu...
90aab57b-13d0-4cd2-9cca-28f7f047977c
public static List grabTaoTuIds(int pageNumber) throws IOException { String pageUrl = Const.chunTuTaotuPageUrl + pageNumber; String pageContent = NetUtil.getPageSource(pageUrl); Pattern pattern = Pattern.compile(RegexUtil.chunTuTaotuRegex); Matcher matcher = pattern.matcher(pageContent);...
82b0518a-ef50-48a9-a517-3a5c6bc26e48
public static List<String> grabTaoTuPhotosById(int id) throws IOException { List result = new ArrayList(); String pageUrl = Const.chunTuTaotuDetailPageUrl + id; String pageContent = NetUtil.getPageSource(pageUrl); Pattern pattern = Pattern.compile("data-original=\"(.*?)\""); Matc...
395f8ace-b160-4c2a-89f0-abcbd798cd38
public static void grabPhoto(int pageNumber) throws IOException { String pageUrl = Const.s91MeiTuPageUrl + pageNumber + "0"; String userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.10 (KHTML, like Gecko) Chrome/23.0.1262.0 Safari/537.10"; String pageContent = NetUtil.getPageSour...
048f53d5-08a2-40e5-9988-e46dafe2ddc7
public static void grabPetOldPhoto(Object lastPinId, int totalCount) throws IOException { String pageUrl = Const.huaBanPetOldPageUrl; for (int index = 0; index < totalCount; index++) { pageUrl = pageUrl + lastPinId; String userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWeb...
de7a21c5-308d-4dde-9a67-cc0adad2b94d
public static void grabPetNewPhoto(Object lastPinId) throws IOException { String pageUrl = ""; int counter = 1; while (true) { if (counter > 10000) { break; } pageUrl = Const.huaBanPetNewPageUrl + lastPinId; String userAgent = "Mozi...
a02eb2bb-5113-48fe-88d4-73ec659eca65
public static void grabBeautyOldPhoto(Object lastPinId, int totalCount) throws IOException { String pageUrl = Const.huaBanBeautyOldPageUrl; for (int index = 0; index < totalCount; index++) { pageUrl = pageUrl + lastPinId; String userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) Ap...
f6f6ccfa-262f-48a6-ab09-b3420d9ad5f7
public static void grabBeautyNewPhoto(Object lastPinId) throws IOException { String pageUrl = ""; int counter = 1; while (true) { if (counter > 10000) { break; } pageUrl = Const.huaBanBeautyNewPageUrl + lastPinId; String userAgent =...
d70c9bcc-5128-4680-b62f-dfad67473aef
public void businessMethod() { }
8b1a0682-cc50-4234-9360-0ad80fc997a0
void create(NewsEntity newsEntity);
751b4160-f040-4a12-ab74-4309384b6483
void edit(NewsEntity newsEntity);
8e02b14a-0621-4311-b0fd-cd93f5e2f305
void remove(NewsEntity newsEntity);
f9ed4636-6f21-43f4-9027-8e1a20b04907
NewsEntity find(Object id);
6291bc94-fb08-4524-b7d5-8f07d5655dc4
List<NewsEntity> findAll();
27952f81-91a1-481c-ad80-1e507914872d
List<NewsEntity> findRange(int[] range);
ba177aa2-75ef-400d-98f3-e1d3cfc03826
int count();
12c50681-19d9-40a7-b7ef-006fc2b8ba6f
public NewMessage() { }
577e38ae-4c82-4855-8047-694090383dac
@Override public void onMessage(Message message) { ObjectMessage msg = null; try { if(message instanceof ObjectMessage) { msg = (ObjectMessage) message; NewsEntity e = (NewsEntity) msg.getObject(); save(e); } } catch (JM...
9e68618d-82fd-413d-9866-0fd1c5893b36
private void save(Object object) { em.persist(object); }
f5393cb0-7848-48bb-9cb6-e5e4bd09b8f6
public String getTitle() { return title; }
de5cf945-3ece-4f88-b2b6-f9df5ebefbe7
public void setTitle(String title) { this.title = title; }
3542d99d-1275-49f0-989b-0b987772509e
public String getBody() { return body; }
1c46c817-6c0c-4adf-b98b-831af32a82bd
public void setBody(String body) { this.body = body; }
c7a3c1b1-baf8-4ed0-acb9-378f3379e492
public Long getId() { return id; }
782f5c2f-39f3-4b41-91b5-2545433bfb79
public void setId(Long id) { this.id = id; }
68e453e7-6069-4001-958d-b219a0c581f1
@Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; }
3f2c405e-9a30-4dad-aaa9-486f40feab48
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof NewsEntity)) { return false; } NewsEntity other = (NewsEntity) object; if ((this.id == null && other.id != null...
905fa9f8-aba1-4c25-b6da-e5e6a95a5aca
@Override public String toString() { return "ejb.NewsEntity[ id=" + id + " ]"; }
b8af9799-f9f6-410a-ab7f-2d22acd8e562
@Override protected EntityManager getEntityManager() { return em; }
684c0881-f3bb-4565-b9f3-d3ed172cf0c0
public NewsEntityFacade() { super(NewsEntity.class); }
3bcb77c4-613d-4c71-acf2-1555458ec64c
public AbstractFacade(Class<T> entityClass) { this.entityClass = entityClass; }
88464b57-a3cc-4bf2-b760-bfd44728ccda
protected abstract EntityManager getEntityManager();
1952add0-68a0-4ed3-9e94-7ec0bdeaf682
public void create(T entity) { getEntityManager().persist(entity); }
181a76e0-326b-4b9c-bac7-961ba74ec5d3
public void edit(T entity) { getEntityManager().merge(entity); }
afdb0fd7-8abd-446f-ab80-dbbbc8273911
public void remove(T entity) { getEntityManager().remove(getEntityManager().merge(entity)); }
90b583bf-7d7e-407c-baa6-ddd15de4f784
public T find(Object id) { return getEntityManager().find(entityClass, id); }
da74bb72-5e43-4d0f-9802-f8f624938d37
public List<T> findAll() { javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery(); cq.select(cq.from(entityClass)); return getEntityManager().createQuery(cq).getResultList(); }
6eef7493-21ff-47a0-a018-0613ee827cf7
public List<T> findRange(int[] range) { javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery(); cq.select(cq.from(entityClass)); javax.persistence.Query q = getEntityManager().createQuery(cq); q.setMaxResults(range[1] - range[0] + 1); ...
daf808eb-7b26-4cdb-8ce7-e7352f4f4225
public int count() { javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery(); javax.persistence.criteria.Root<T> rt = cq.from(entityClass); cq.select(getEntityManager().getCriteriaBuilder().count(rt)); javax.persistence.Query q = getEntityManag...
875a0ef3-eee8-4ad0-8fb6-3ef3a4ae3806
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); String title=request.getParameter("title"); String body=request.getParameter("body"); if...
83c8f05e-2d30-4b2b-b075-1034ae77f7f2
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); }
81f37262-c3f2-40fa-a466-4fc7bbae0827
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); }
f67435a4-aa0d-470d-9155-c7c99495a788
@Override public String getServletInfo() { return "Short description"; }// </editor-fold>
ebfe82c4-5d17-4e8d-aa5b-04938027d781
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { /* TODO output your page here. You may use following s...
d5ab4fc3-ab02-4ea0-aa23-8b4287608be2
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); }
66d69e6d-6be9-4344-a184-5dba93b464dc
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); }
da985c00-be10-479a-b26f-33ed34a1d654
@Override public String getServletInfo() { return "Short description"; }// </editor-fold>
40b85061-f010-40d6-bdb8-f32717a0fb8d
public static void main(String[] args) {//latch的作用是牵一发而动全身,它具有的是瞬时控制效应,它不可循环利用 ExecutorService service = Executors.newCachedThreadPool(); final CountDownLatch cdOrder = new CountDownLatch(1); final CountDownLatch cdAnswer = new CountDownLatch(3); for(int i=0;i<3;i++){ Runnable runnable = new Runnable(){ ...
305c787c-dea0-420e-9f36-93bc0d71bfac
public void run(){ try { Thread.sleep((long)(Math.random()*1000)); System.out.println("线程" + Thread.currentThread().getName() + "正准备接受命令"); cdOrder.await(); cdOrder.await(); cdOrder.await(); System.out.println("线程" + Thread.currentThread().getName() + "已接受命...
0cc8fd2f-339d-4e1d-b657-e5db1fb4968c
MyThread(CountDownLatch latch) { this.latch=latch; }
ab1d723e-8e3a-42bd-b828-4e65c1e658b6
public void run() { try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("latch countDown..."); latch.countDown(); }
eca9090a-ec5b-4ddb-ada0-9219dca21064
public LockSummary_ABC() { condtionContext.put(Integer.valueOf(0),a); condtionContext.put(Integer.valueOf(1),b); condtionContext.put(Integer.valueOf(2),c); }
d9fcde89-8d2f-4e9f-a5c3-64d934b123db
public void print(int id) { lock.lock(); try { while (count < 30) { if (id == count%3) { if(id==0) { System.out.println(Thread.currentThread()+": "+"A"); } else if(id==1) { System.out.println(Thread.currentThread()+": "+"B"); } else { System.out.println(Thread.currentThre...
b8fadf42-fea3-4e05-a42f-23f5029ade3b
public static void main(String[] args) { ExecutorService executor = Executors.newFixedThreadPool(3); final CountDownLatch latch = new CountDownLatch(1); final LockSummary_ABC printer = new LockSummary_ABC(); for (int i = 0; i < 3; i++) { final int id = i; executor.submit(new Runnable() { @Override ...
117137b4-22d3-4a97-b322-05cc40603e46
@Override public void run() { try { latch.await(); } catch (InterruptedException e) { e.printStackTrace(); } printer.print(id); }
8c7af1a6-2d99-446d-ba9b-85d107aee5b8
public LockSummary_Number() { condtionContext.put(Integer.valueOf(0), c1); condtionContext.put(Integer.valueOf(1), c2); condtionContext.put(Integer.valueOf(2), c3); }
dd4daa1f-aa5d-48da-b003-78236832dbe9
public void print(int id) { lock.lock(); try { while (count * 5 < 75) { int curID = calcID();// 计算当前应该执行打印的线程 if (id == curID) { System.out.print(Thread.currentThread()+": "); for (int i = 1; i <= 5; i++) { System.out.print((count * 5 + i) + ","); } System.out.println(); c...
0556060e-bafc-448e-96f2-12cb1667c939
private int calcID() { return count % 3; }
6618b8eb-bcc9-4a58-b64d-d7aba61f44f3
public static void main(String[] args) { ExecutorService executor = Executors.newFixedThreadPool(3); final CountDownLatch latch = new CountDownLatch(1); final LockSummary_Number printer = new LockSummary_Number(); for (int i = 0; i < 3; i++) { final int id = i; executor.submit(new Runnable() { @Over...
c1311ad7-ccd4-44bb-acfa-7d202cd0f18e
@Override public void run() { try { latch.await(); } catch (InterruptedException e) { e.printStackTrace(); } printer.print(id); }
81dfa980-d8a8-4a43-aa16-a046fe1e62cd
public synchronized void sub(int seq) { if (!isShouldTrue) { try { this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } for (int i = 1; i <= 10; i++) System.out.println("seq " + seq + " sub loop " + i); isShouldTrue = false; this.notify(); }
8c47c445-938e-437b-bb27-d803b00802b1
public synchronized void main(int seq) { if (isShouldTrue) { try { this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } for (int i = 1; i <= 20; i++) { System.out.println("seq " + seq + " main loop " + i); } isShouldTrue = true; this.notify(); }
c8de1464-b960-4a57-90b7-cd036c5acc2c
public static void main(String[] args) { ExecutorService service = Executors.newCachedThreadPool(); final CyclicBarrier cb = new CyclicBarrier(3,new Runnable() { public void run() { System.out.println(Thread.currentThread().getName()+"第"+count.getAndIncrement()+"个轮回"); } });//构造方法里的数字标识有几个线程到达集合地点开...
8c6bff9d-55f1-45d1-933b-017dd9648ad4
public void run() { System.out.println(Thread.currentThread().getName()+"第"+count.getAndIncrement()+"个轮回"); }
22b06c2e-2885-420c-a215-55536431eae4
public void run(){ try { Thread.sleep((long)(Math.random()*10000)); System.out.println("线程" + Thread.currentThread().getName() + "即将到达集合地点1,当前已有" + cb.getNumberWaiting() + "个已经到达,正在等候"); cb.await(); Thread.sleep((long)(Math.random()*10000)); System.out.println(...
57cd424f-37c9-4726-bae1-6028c796d675
public static void main(String[] args) { Juego jueJuego = new Juego(); jueJuego.setVisible(true); jueJuego.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
1d13bee1-f899-4c0f-8b2b-925aa4db03b4
public Animacion(){ //Crea el arreglo de objetos que guarda los cuadros. cuadros = new ArrayList(); //Inicializa el tiempo total en 0. duracionTotal = 0; //Llama al método iniciar() iniciar(); }
378b80f9-e634-4b0d-b591-2824a79f533e
public synchronized void sumaCuadro(URL imagen, long duracion){ //Agrega la duración del cuadro a la duración de la animación duracionTotal += duracion; //Agrega el cuadro a la animación cuadros.add(new cuadroDeAnimacion(imagen, duracionTotal)...
4deef2c8-1379-4874-87fe-dc3d3b46fff0
public synchronized void iniciar(){ //Inicializa el tiempo de la animación en 0 tiempoDeAnimacion = 0; //Coloca el índice en el primer cuadro de la animación indiceCuadroActual = 0; }
c56ab31c-c286-49b6-9c95-32e628e85494
public synchronized void actualiza(long tiempoTranscurrido){ //Si la animación tiene más de un cuadro, se actualiza if (cuadros.size() > 1){ //Se suma el tiempo transcurrido al tiempo total tiempoDeAnimacion += tiempoTranscurrido; ...
8b46726a-3cbe-433f-a05c-46dde0d6c92c
public synchronized URL getImagen(){ //Si la animación esta vacía if (cuadros.size() == 0){ //Retorna nulo return null; } //De lo contrario else { ...
8ac7694b-d3ad-4ed8-a0c5-8b15d3d98eea
private cuadroDeAnimacion getCuadro(int i){ //Retorna el cuadro deseado return (cuadroDeAnimacion)cuadros.get(i); }
afb5eb2e-e406-4f71-a075-986a36b41508
public cuadroDeAnimacion(){ //Guarda valor nulo en la imagen this.imagen = null; //Guarda en 0 el tiempo this.tiempoFinal = 0; }
6e0dd90f-084d-40cd-a522-c8133d2f631f
public cuadroDeAnimacion(URL imagen, long tiempoFinal){ //Guarda la imagen del cuadro this.imagen = imagen; //Guarda el tiempo en que se da la transición al //siguiente cuadro ...
453e95ed-d12d-4ed9-b9b3-2368977e3845
public URL getImagen(){ //Retorna la imagen return imagen; }
0cdb763f-a0d8-40fa-a71b-6c6e65382c32
public long getTiempoFinal(){ //Retorna el tiempo return tiempoFinal; }
5363e5d3-95f5-4717-96e7-622deb318f46
public void setImagen (URL imagen){ //Guarda la nueva imagen this.imagen = imagen; }
d98c76a2-0ac1-4189-9407-e60919b02dc1
public void setTiempoFinal(long tiempoFinal){ //Guarda el nuevo tiempo this.tiempoFinal = tiempoFinal; }
a17ef6da-245e-494c-a8f0-c25034027681
public SoundClip() { try { //crea el Buffer de sonido clip = AudioSystem.getClip(); } catch (LineUnavailableException e) { } }
dbe50b62-46c5-4bb4-8110-98dc99506026
public SoundClip(String filename) { //Llama al constructor default. this(); //Carga el archivo de sonido. load(filename); }
7aa2b976-e812-4c58-9fc6-8411ab2a6c49
public Clip getClip() { return clip; }
7ee448c3-e500-4925-8550-e659728e7bb8
public void setLooping(boolean looping) { this.looping = looping; }
eed6cdb8-6234-4fe3-bf1c-f5648fd71703
public boolean getLooping() { return looping; }
1bc0cb17-74ee-47e9-800b-f2b6ab660dfc
public void setRepeat(int repeat) { this.repeat = repeat; }
36348f2f-5757-47ca-88ff-ce0fc8e19698
public int getRepeat() { return repeat; }
31471b31-0b56-4269-b002-1b68e0bbfac3
public void setFilename(String filename) { this.filename = filename; }
2f5e366a-a641-4629-ae82-cab05edc703c
public String getFilename() { return filename; }
c56fff71-b1f9-4370-a365-d7deb736fd08
public boolean isLoaded() { return (boolean)(sample != null); }
69c06a63-fe83-4e46-8b6e-500868415d87
private URL getURL(String filename) { URL url = null; try { url = this.getClass().getResource(filename); } catch (Exception e) { } return url; }
a72082e2-4206-4811-9be7-8bba3bb3d0f8
public boolean load(String audiofile) { try { setFilename(audiofile); sample = AudioSystem.getAudioInputStream(getURL(filename)); clip.open(sample); return true; } catch (IOException e) { return false; } catch (UnsupportedAudioFileException e) { return false; } catch (LineUnavailableException...
0b483679-606e-458c-93ec-6e81cb1b70dc
public void play() { //se sale si el sonido no a sido cargado if (!isLoaded()) return; //vuelve a empezar el sound clip clip.setFramePosition(0); //Reproduce el sonido con repeticion opcional. if (looping) clip.loop(Clip.LOOP_CONTINUOUSLY); else clip.loop(repeat); }
06d1ccb1-b540-4fd6-b5e5-d4a10db40c5c
public void stop() { clip.stop(); }
1796fa95-d41d-4849-a1d8-00f7fbcc0615
public Juego() { init(); start(); }
f8768b7a-90e2-4e62-aeda-89c9dddfaaa1
public void init() { // hago el applet de un tamaño 500,500 setSize(1200, 800); iChoque = 0; //el es cero por defecto //por defecto score empieza en 0 iScore =0; //no se ha corrido ninguna imagen de la animacion iContador = 0; //...
74575bb5-6f20-45bf-9b1c-07cd531de522
public void start () { // Declaras un hilo Thread th = new Thread ((Runnable) this); // Empieza el hilo th.start (); }
49efb75b-6ae7-403d-84f0-e43358ff0d3a
public void actualiza(){ // instrucciones para actualizar Entidads //Determina el tiempo que ha transcurrido desde que el Applet //inicio su ejecución long tiempoTranscurrido=System.currentTimeMillis() - tiempoActual; //Guarda el tiempo actual tiempoAct...
e17cb41f-9a40-4d30-b9a3-023a247819e5
public void run () { // se realiza el ciclo del juego en este caso nunca termina //Guarda el tiempo actual del sistema tiempoActual = System.currentTimeMillis(); while (true) { /* mientras dure el juego, se actualizan posiciones de jugadores ...
5acf74b7-2530-4841-99ef-3f998a99d2fe
public void checaColision(){ // instrucciones para checar colision y reacomodar Entidads si // es necesario //la barra no se puede salir del cuadro if(entBarra.getX()+entBarra.getAncho()>=getWidth()) { entBarra.setX(getWidth()-entBarra.getAncho()); } else if(...