blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
410
content_id
stringlengths
40
40
detected_licenses
sequencelengths
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
689M
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
131 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
32 values
content
stringlengths
3
9.45M
authors
sequencelengths
1
1
author_id
stringlengths
0
313
074cc6e82893a10e56396a433e24d66f1930d0e7
8eb283df69ff7c8999e299adb00f201cc1a26691
/app/src/main/java/misao/alarmproject/AlarmReceiver.java
0634f20a08082ad3042bb7c17e57e2e19f5aab90
[]
no_license
Raj-Misao/alarm
0a7519ffbaad5b1a8abace6bec43ccb000a043a8
036fa97f22faa6499ff6cd0d449ac95e4d9069e9
refs/heads/master
2021-01-09T06:06:20.657770
2017-02-04T11:18:19
2017-02-04T11:18:19
80,914,434
0
0
null
null
null
null
UTF-8
Java
false
false
833
java
package misao.alarmproject; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.media.Ringtone; import android.media.RingtoneManager; import android.net.Uri; import android.widget.Toast; /** * Created by Sonu on 1/23/2017. */ public class AlarmReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(context,"Wake Up Wake up",Toast.LENGTH_LONG).show(); Uri alarmURi = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); if(alarmURi == null) { alarmURi = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); } Ringtone ringtone = RingtoneManager.getRingtone(context,alarmURi); ringtone.play(); } }
5bd51f17d5790ee939f32d409a69011a207a40df
75265848f9a0d5b1b3167b143614d8df0a3c311f
/app/src/main/java/com/microacademylabs/hellobottomnav/MainActivity.java
8f9db85d3296aea3685a8043ecc324d622cf9048
[]
no_license
karenfreemansmith/BottomNavigation
bcc96c5b396d0d58003501e26091d8134b83b276
0adbc78fc6b06fc97c3e1b45897029786ffbf0b0
refs/heads/master
2021-01-21T18:05:18.075404
2017-05-22T03:55:34
2017-05-22T03:55:34
92,009,424
0
0
null
null
null
null
UTF-8
Java
false
false
1,460
java
package com.microacademylabs.hellobottomnav; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import android.widget.TextView; public class MainActivity extends AppCompatActivity { private TextView mTextMessage; private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.navigation_home: mTextMessage.setText(R.string.title_home); return true; case R.id.navigation_dashboard: mTextMessage.setText(R.string.title_dashboard); return true; case R.id.navigation_notifications: mTextMessage.setText(R.string.title_notifications); return true; } return false; } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTextMessage = (TextView) findViewById(R.id.message); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); } }
bb7cc0a2adf5b535d143472513d9bae6b700bd03
df5326dac9459fc52061658d26ca8334fc0964c5
/PizzaFinalV2.java
0b98fe863370db0875fcad7ca4acc6d94c516c9e
[]
no_license
MajedDadou/Majed-Pizza
0495b2436a67e23fb6d577eadcfbf82f03537413
6273146bc18c2b13a6d42dd9d420ed471d0003cf
refs/heads/main
2023-08-11T23:08:02.623094
2021-10-13T06:55:20
2021-10-13T06:55:20
416,622,637
0
0
null
null
null
null
UTF-8
Java
false
false
5,950
java
import java.util.Scanner; // Tester Benjamin public class PizzaFinalV2 { public static void main(String[] args) { //Price for the Pizza double pPrice = 0; System.out.println("-----------------------------------------------------------"); System.out.println("Welcome to Pizza Ordering System, What can I get for you?"); System.out.println("-----------------------------------------------------------\n\n\n"); System.out.println("***********************************************************************\nTo Order Please Insert the number of the desired Pizza from the list\n***********************************************************************\n"); System.out.println(" 1. Karry Kylling Pizza: Med tomat, ost, kyllingstrimler, majs, karrysauce og oregano."); System.out.println(" 2. BBQ Kylling Pizza: Med tomat, ost, kyllingstrimler, løg, BBQ sauce og oregano."); System.out.println(" 3. Pommes: Pizza Kylling Tomatsauce, ost, peberfrugt, løg, pommes frites, kylling"); System.out.println(" 4. Pommes: Pizza Kebab Tomatsauce, ost, peberfrugt, løg, pommes frites, kebab"); System.out.println(" 5. Falafel: Pizza Med tomatsauce, ost, falafel, tomatskiver, peberfrugt, champignon, løg, cremefraiche, mix max og oregano"); System.out.println(" 6. Margarita: Med tomatsauce, ost og oregano"); System.out.println(" 7. Mozerilla: Tomatsauce, ost, fetaost, sherrytomater"); System.out.println(" 8. Hawaii: Tomatsauce, ost, kalkunskinke, ananas og oregano"); System.out.println(" 9. Napoli: Tomatsauce, ost, kalkunskinke, rejer og oregano"); System.out.println(" 10. Pepperoni: Tomatsauce, ost, pepperoni, tomatskiver, peberfrugt, hvidløg og oregano\n"); //Pizza Number Scanner Pizza = new Scanner(System.in); int pNumber = Pizza.nextInt(); switch (pNumber) { case 1: System.out.println(" Great You Chose Nr 1 price is 125kr"); pPrice = 125; break; case 2: System.out.println(" Great You Chose Nr 2 price is 155kr"); pPrice = 155; break; case 3: System.out.println(" Great You Chose Nr 3 price is 100kr"); pPrice = 100; break; case 4: System.out.println(" Great You Chose Nr 4 price is 40kr"); pPrice = 40; break; case 5: System.out.println(" Great You Chose Nr 5 price is 45kr"); pPrice = 45; break; case 6: System.out.println(" Great You Chose Nr 6 price is 75kr"); pPrice = 75; break; case 7: System.out.println(" Great You Chose Nr 7 price is 85kr"); pPrice = 85; break; case 8: System.out.println(" Great You Chose Nr 8 price is 60kr"); pPrice = 60; break; case 9: System.out.println(" Great You Chose Nr 9 price is 144kr"); pPrice = 144; break; case 10: System.out.println(" Great You Chose Nr 10 price is 199kr"); pPrice = 199; break; default: System.out.println(" INVALID input please rerun"); return; } //Pizza Size System.out.println(" Please select the desired size\n Press: \n 1 for Child\n 2 for Standard\n 3 for Family"); int pSize = Pizza.nextInt(); switch (pSize){ case 1: pPrice = pPrice * 0.75; System.out.println("Child Size Selected, current total price is "+pPrice); break; case 2: System.out.println("Standard Size Selected, current total price is "+pPrice); break; case 3: pPrice = pPrice * 1.5; System.out.println("Family Size Selected, current total price is "+pPrice); break; default: System.out.println(" INVALID input please rerun"); return; } //Toppings System.out.println(" Please select the desired Topping, Extra Topping cost 15kr. \n Press: \n 1 for Extra Tasty Cheese\n 2 for Mushrooms\n 3 for Kalkun Kød\n 4 no Topping needed"); int pTopping = Pizza.nextInt(); switch (pTopping){ case 1: pPrice = pPrice + 15; System.out.println("Extra Tasty Cheese :)"); break; case 2: pPrice = pPrice + 15; System.out.println("Mushrooms :)"); break; case 3: pPrice = pPrice + 15; System.out.println("Kalkun Kød :)"); break; case 4: System.out.println("No topping"); break; default: System.out.println(" INVALID input please rerun"); return; } System.out.println("Order Confirmed, \n\nreceipt will be Printed in a moment"); System.out.println("You have ordered pizza Nr "+ pNumber+" and Size "+pSize+" and Topping "+pTopping +" the total price Now is "+pPrice+"kr Please Pay in the shop"); System.out.println("\n***********************************************************************\nThanks For Shopping using our New Pizza Ordering System. *\n***********************************************************************"); } }
07e3c6ea6ca6fcd1b80a137f445a748042dfb260
5b23eaed078f1add4fe8592c899b24887f709458
/scenario/Level4KeyCamera.java
388894c33b057a42c46ce860bda76e2dec575da1
[]
no_license
alexsaalberg/restart
2c495c212daedaff12a7ff0e00330d75aa168ca3
2b5ac0b198ee46f4c35a3b5fa840a538c65b06f6
refs/heads/master
2020-04-06T20:29:02.930243
2018-11-15T21:20:36
2018-11-15T21:20:36
157,773,746
0
0
null
null
null
null
UTF-8
Java
false
false
773
java
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class SecurityCamera here. * * @author (your name) * @version (a version number or a date) */ public class Level4KeyCamera extends ConeEnemy { /** * Act - do whatever the SecurityCamera wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { super.act(); // Add your action code here. } protected void addedToWorld(World world){ super.addedToWorld(world); GreenfootImage img = getImage(); img.rotate(90); setSightLength(200); setSightAngle(90); } }
2a1ceb1757fb896b1d18c80ebb577b2bdf2930d2
d312ffae3a5c7dae52753b77da90f44a12e4fd9e
/src/main/java/com/gilmarcarlos/developer/gcursos/service/eventos/online/CertificadoOnlineService.java
edf0935a51c2d46439e44d058ad92400331bd5d5
[]
no_license
gilmardeveloper/java-cursos
46b42502914d1c953f904a0508238192a5b72963
ed2a9543365bf995896487bcaf957b5a746204df
refs/heads/master
2020-04-03T11:45:40.593463
2018-10-29T15:21:45
2018-10-29T15:21:45
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,983
java
package com.gilmarcarlos.developer.gcursos.service.eventos.online; import java.awt.Graphics2D; import java.awt.Image; import java.awt.image.BufferedImage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.gilmarcarlos.developer.gcursos.model.eventos.online.CertificadoOnline; import com.gilmarcarlos.developer.gcursos.repository.eventos.online.CertificadoOnlineRepository; /** * Classe com serviços de persistência para entidade (CertificadoOnline) * * @author Gilmar Carlos * */ @Service public class CertificadoOnlineService { @Autowired private CertificadoOnlineRepository repository; public CertificadoOnline salvar(CertificadoOnline certificado) { return repository.save(certificado); } /** * Método que atualiza o conteudo do certificado * * @param certificado representa um certificado * @return CertificadoOnline * */ public CertificadoOnline atualizarConteudo(CertificadoOnline certificado) { CertificadoOnline temp = buscarPor(certificado.getEventoOnline().getId()); temp.setConteudo(certificado.getConteudo()); return salvar(temp); } /** * Método que atualiza a imagem de fundo do certificado * * @param certificado representa um certificado * @return CertificadoOnline * */ public CertificadoOnline atualizarImagemFundo(CertificadoOnline certificado) { CertificadoOnline temp = buscarPor(certificado.getEventoOnline().getId()); temp.setImagemFundo(certificado.getImagemFundo()); return salvar(temp); } public void deletar(Long id) { repository.deleteById(id); } public CertificadoOnline buscarPor(Long id) { return repository.buscarPor(id); } /** * Método que verifica as dimenssões de uma imagem * * @param imagem representa um buffer * @param altura representa a altura de uma imagem * @param largura representa a largura de uma imagem * @return BufferedImage * */ public BufferedImage verifica(BufferedImage imagem, Integer altura, Integer largura) { if(imagem.getHeight() > altura || imagem.getWidth() > largura) { imagem = redimensionar(imagem, largura, altura); } if(imagem.getHeight() < altura || imagem.getWidth() < largura) { imagem = redimensionar(imagem, largura, altura); } return imagem; } /** * Método que redimensiona as dimenssões de uma imagem * * @param imagem representa um buffer * @param altura representa a altura de uma imagem * @param largura representa a largura de uma imagem * @return BufferedImage * */ private BufferedImage redimensionar(BufferedImage imagem, Integer largura, Integer altura) { Image tmp = imagem.getScaledInstance(largura, altura, Image.SCALE_DEFAULT); // .SCALE_SMOOTH); imagem = new BufferedImage(largura, altura, BufferedImage.SCALE_DEFAULT); // .TYPE_INT_ARGB); Graphics2D g2d = imagem.createGraphics(); g2d.drawImage(tmp, 0, 0, null); g2d.dispose(); return imagem; } }
e3eb36e3fba7371b8bd612ce96f765e463ec8feb
4e8d52f594b89fa356e8278265b5c17f22db1210
/WebServiceArtifacts/WeatherV1SoapService/com/flightstats/weather/service/v1/VisibilityV1.java
acb7b90ade787ef9d880ca4c3d912e1127d343c5
[]
no_license
ouniali/WSantipatterns
dc2e5b653d943199872ea0e34bcc3be6ed74c82e
d406c67efd0baa95990d5ee6a6a9d48ef93c7d32
refs/heads/master
2021-01-10T05:22:19.631231
2015-05-26T06:27:52
2015-05-26T06:27:52
36,153,404
1
2
null
null
null
null
UTF-8
Java
false
false
2,548
java
package com.flightstats.weather.service.v1; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for visibilityV1 complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="visibilityV1"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="miles" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * &lt;element name="lessThan" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/> * &lt;element name="cavok" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "visibilityV1", propOrder = { "miles", "lessThan", "cavok" }) public class VisibilityV1 { protected String miles; protected Boolean lessThan; protected Boolean cavok; /** * Gets the value of the miles property. * * @return * possible object is * {@link String } * */ public String getMiles() { return miles; } /** * Sets the value of the miles property. * * @param value * allowed object is * {@link String } * */ public void setMiles(String value) { this.miles = value; } /** * Gets the value of the lessThan property. * * @return * possible object is * {@link Boolean } * */ public Boolean isLessThan() { return lessThan; } /** * Sets the value of the lessThan property. * * @param value * allowed object is * {@link Boolean } * */ public void setLessThan(Boolean value) { this.lessThan = value; } /** * Gets the value of the cavok property. * * @return * possible object is * {@link Boolean } * */ public Boolean isCavok() { return cavok; } /** * Sets the value of the cavok property. * * @param value * allowed object is * {@link Boolean } * */ public void setCavok(Boolean value) { this.cavok = value; } }
a08624e20b8d2d72760f045e89fe91e0a3c0f31e
a978bb8dbc2ea3efdd100a8e7b4b6f8935a7bea8
/src/main/java/com/caleb/project/controller/ClienteRestController.java
843dcf955fd32b35042825416b54d6fe7bcd60a9
[]
no_license
JoelCalebPA/Spring
868e9dbf86f18f5777622986a171e281a0ea18f9
a8b480aae6b37716e0cf72fce323b81969f60ec3
refs/heads/master
2020-03-24T05:42:25.679274
2018-08-11T02:32:25
2018-08-11T02:32:25
142,498,653
0
0
null
null
null
null
UTF-8
Java
false
false
985
java
package com.caleb.project.controller; import java.util.List; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; 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 com.caleb.project.entity.Cliente; import com.caleb.project.repository.ClienteRepository; @RestController @RequestMapping("/api/cliente") public class ClienteRestController { private final ClienteRepository repository; @Autowired public ClienteRestController(ClienteRepository repository) { this.repository = repository; } @GetMapping public List<Cliente> getClientes() { return repository.findAll(); } @GetMapping("/{idCliente}") public Optional<Cliente> getCLiente(@PathVariable("idCliente") int idCliente) { return repository.findById(idCliente); } }
6d4b2dc22750e57f250477ac027b6ee93678831d
387308db3dc207129ef44d6f414c8007421e2be6
/src/main/java/com/redrain/service/impl/SysMenuServiceImpl.java
6cfc742b3b23b0e27790a1f9b1dc90caca7ec7e4
[]
no_license
ywwj001/test
42d058192a04cdce7997575cddd6cd4906c11cfe
2961f004eca0b6eec3408926731868cbf0c26a22
refs/heads/main
2023-08-13T23:49:20.837648
2021-09-29T14:27:59
2021-09-29T14:27:59
411,688,525
0
0
null
null
null
null
UTF-8
Java
false
false
2,300
java
package com.redrain.service.impl; import com.redrain.common.result.ReturnData; import com.redrain.entity.ReturnDataForLayui; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.redrain.entity.SysMenu; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.redrain.mapper.SysMenuMapper; import com.redrain.service.SysMenuService; import com.redrain.common.utils.UpdateOrInsertResultDeal; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; /** * @author redrain * @Description SysMenuservice实现类 * @date 2021-04 * @qq 1351150492 */ @Service public class SysMenuServiceImpl implements SysMenuService { @Autowired private SysMenuMapper sysMenuMapper; @Transactional(propagation = Propagation.REQUIRED, readOnly = true) @Override public ReturnDataForLayui getList(SysMenu sysMenu) { PageHelper.startPage(sysMenu.getPage(), sysMenu.getLimit()); List<SysMenu> list = sysMenuMapper.getList(sysMenu); PageInfo<SysMenu> info = new PageInfo<>(list); return ReturnDataForLayui.success(list, info.getTotal()); } @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Override public ReturnData add(SysMenu sysMenu) { int i = sysMenuMapper.add(sysMenu); return UpdateOrInsertResultDeal.dealWith(i); } @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Override public ReturnData delete(SysMenu sysMenu) { int i = sysMenuMapper.delete(sysMenu); return UpdateOrInsertResultDeal.dealWith(i); } @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Override public ReturnData update(SysMenu sysMenu) { int i = sysMenuMapper.update(sysMenu); return UpdateOrInsertResultDeal.dealWith(i); } @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Override public ReturnData updateState(SysMenu sysMenu) { int i = sysMenuMapper.updateState(sysMenu); return UpdateOrInsertResultDeal.dealWith(i); } }
dbfefd25bac947f4265f28f9fe60623c3ca6e105
e0e8af3654e716d12764c5bc2e17068babe1b5e1
/app/src/main/java/test/test/utils/Base64.java
49530f90e45f9ccca881c3893d2cf063049458ba
[]
no_license
gouptosee/Test
770b43bdc05753119dd739c71fd535bb354679c4
f3f27526d0cb974fee03f67beb9327ced5fcaec7
refs/heads/master
2021-01-21T12:11:24.952747
2017-08-09T02:24:12
2017-08-09T02:24:12
91,780,389
1
0
null
null
null
null
UTF-8
Java
false
false
29,150
java
/* * Copyright (C) 2010 The Android Open Source Project * * 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 test.test.utils; import java.io.UnsupportedEncodingException; /** * Utilities for encoding and decoding the Base64 representation of * binary data. See RFCs <a * href="http://www.ietf.org/rfc/rfc2045.txt">2045</a> and <a * href="http://www.ietf.org/rfc/rfc3548.txt">3548</a>. */ public class Base64 { /** * Default values for encoder/decoder flags. */ public static final int DEFAULT = 0; /** * Encoder flag bit to omit the padding '=' characters at the end * of the output (if any). */ public static final int NO_PADDING = 1; /** * Encoder flag bit to omit all line terminators (i.e., the output * will be on one long line). */ public static final int NO_WRAP = 2; /** * Encoder flag bit to indicate lines should be terminated with a * CRLF pair instead of just an LF. Has no effect if {@code * NO_WRAP} is specified as well. */ public static final int CRLF = 4; /** * Encoder/decoder flag bit to indicate using the "URL and * filename safe" variant of Base64 (see RFC 3548 section 4) where * {@code -} and {@code _} are used in place of {@code +} and * {@code /}. */ public static final int URL_SAFE = 8; /** * Flag to pass to {@link } to indicate that it * should not close the output stream it is wrapping when it * itself is closed. */ public static final int NO_CLOSE = 16; // -------------------------------------------------------- // shared code // -------------------------------------------------------- /* package */ static abstract class Coder { public byte[] output; public int op; /** * Encode/decode another block of input data. this.output is * provided by the caller, and must be big enough to hold all * the coded data. On exit, this.opwill be set to the length * of the coded data. * * @param finish true if this is the final call to process for * this object. Will finalize the coder state and * include any final bytes in the output. * * @return true if the input so far is good; false if some * error has been detected in the input stream.. */ public abstract boolean process(byte[] input, int offset, int len, boolean finish); /** * @return the maximum number of bytes a call to process() * could produce for the given number of input bytes. This may * be an overestimate. */ public abstract int maxOutputSize(int len); } // -------------------------------------------------------- // decoding // -------------------------------------------------------- /** * Decode the Base64-encoded data in input and return the data in * a new byte array. * * <p>The padding '=' characters at the end are considered optional, but * if any are present, there must be the correct number of them. * * @param str the input String to decode, which is converted to * bytes using the default charset * @param flags controls certain features of the decoded output. * Pass {@code DEFAULT} to decode standard Base64. * * @throws IllegalArgumentException if the input contains * incorrect padding */ public static byte[] decode(String str, int flags) { return decode(str.getBytes(), flags); } /** * Decode the Base64-encoded data in input and return the data in * a new byte array. * * <p>The padding '=' characters at the end are considered optional, but * if any are present, there must be the correct number of them. * * @param input the input array to decode * @param flags controls certain features of the decoded output. * Pass {@code DEFAULT} to decode standard Base64. * * @throws IllegalArgumentException if the input contains * incorrect padding */ public static byte[] decode(byte[] input, int flags) { return decode(input, 0, input.length, flags); } /** * Decode the Base64-encoded data in input and return the data in * a new byte array. * * <p>The padding '=' characters at the end are considered optional, but * if any are present, there must be the correct number of them. * * @param input the data to decode * @param offset the position within the input array at which to start * @param len the number of bytes of input to decode * @param flags controls certain features of the decoded output. * Pass {@code DEFAULT} to decode standard Base64. * * @throws IllegalArgumentException if the input contains * incorrect padding */ public static byte[] decode(byte[] input, int offset, int len, int flags) { // Allocate space for the most data the input could represent. // (It could contain less if it contains whitespace, etc.) Decoder decoder = new Decoder(flags, new byte[len*3/4]); if (!decoder.process(input, offset, len, true)) { throw new IllegalArgumentException("bad base-64"); } // Maybe we got lucky and allocated exactly enough output space. if (decoder.op == decoder.output.length) { return decoder.output; } // Need to shorten the array, so allocate a new one of the // right size and copy. byte[] temp = new byte[decoder.op]; System.arraycopy(decoder.output, 0, temp, 0, decoder.op); return temp; } /* package */ static class Decoder extends Coder { /** * Lookup table for turning bytes into their position in the * Base64 alphabet. */ private static final int DECODE[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; /** * Decode lookup table for the "web safe" variant (RFC 3548 * sec. 4) where - and _ replace + and /. */ private static final int DECODE_WEBSAFE[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; /** Non-data values in the DECODE arrays. */ private static final int SKIP = -1; private static final int EQUALS = -2; /** * States 0-3 are reading through the next input tuple. * State 4 is having read one '=' and expecting exactly * one more. * State 5 is expecting no more data or padding characters * in the input. * State 6 is the error state; an error has been detected * in the input and no future input can "fix" it. */ private int state; // state number (0 to 6) private int value; final private int[] alphabet; public Decoder(int flags, byte[] output) { this.output = output; alphabet = ((flags & URL_SAFE) == 0) ? DECODE : DECODE_WEBSAFE; state = 0; value = 0; } /** * @return an overestimate for the number of bytes {@code * len} bytes could decode to. */ public int maxOutputSize(int len) { return len * 3/4 + 10; } /** * Decode another block of input data. * * @return true if the state machine is still healthy. false if * bad base-64 data has been detected in the input stream. */ public boolean process(byte[] input, int offset, int len, boolean finish) { if (this.state == 6) return false; int p = offset; len += offset; // Using local variables makes the decoder about 12% // faster than if we manipulate the member variables in // the loop. (Even alphabet makes a measurable // difference, which is somewhat surprising to me since // the member variable is final.) int state = this.state; int value = this.value; int op = 0; final byte[] output = this.output; final int[] alphabet = this.alphabet; while (p < len) { // Try the fast path: we're starting a new tuple and the // next four bytes of the input stream are all data // bytes. This corresponds to going through states // 0-1-2-3-0. We expect to use this method for most of // the data. // // If any of the next four bytes of input are non-data // (whitespace, etc.), value will end up negative. (All // the non-data values in decode are small negative // numbers, so shifting any of them up and or'ing them // together will result in a value with its top bit set.) // // You can remove this whole block and the output should // be the same, just slower. if (state == 0) { while (p+4 <= len && (value = ((alphabet[input[p] & 0xff] << 18) | (alphabet[input[p+1] & 0xff] << 12) | (alphabet[input[p+2] & 0xff] << 6) | (alphabet[input[p+3] & 0xff]))) >= 0) { output[op+2] = (byte) value; output[op+1] = (byte) (value >> 8); output[op] = (byte) (value >> 16); op += 3; p += 4; } if (p >= len) break; } // The fast path isn't available -- either we've read a // partial tuple, or the next four input bytes aren't all // data, or whatever. Fall back to the slower state // machine implementation. int d = alphabet[input[p++] & 0xff]; switch (state) { case 0: if (d >= 0) { value = d; ++state; } else if (d != SKIP) { this.state = 6; return false; } break; case 1: if (d >= 0) { value = (value << 6) | d; ++state; } else if (d != SKIP) { this.state = 6; return false; } break; case 2: if (d >= 0) { value = (value << 6) | d; ++state; } else if (d == EQUALS) { // Emit the last (partial) output tuple; // expect exactly one more padding character. output[op++] = (byte) (value >> 4); state = 4; } else if (d != SKIP) { this.state = 6; return false; } break; case 3: if (d >= 0) { // Emit the output triple and return to state 0. value = (value << 6) | d; output[op+2] = (byte) value; output[op+1] = (byte) (value >> 8); output[op] = (byte) (value >> 16); op += 3; state = 0; } else if (d == EQUALS) { // Emit the last (partial) output tuple; // expect no further data or padding characters. output[op+1] = (byte) (value >> 2); output[op] = (byte) (value >> 10); op += 2; state = 5; } else if (d != SKIP) { this.state = 6; return false; } break; case 4: if (d == EQUALS) { ++state; } else if (d != SKIP) { this.state = 6; return false; } break; case 5: if (d != SKIP) { this.state = 6; return false; } break; } } if (!finish) { // We're out of input, but a future call could provide // more. this.state = state; this.value = value; this.op = op; return true; } // Done reading input. Now figure out where we are left in // the state machine and finish up. switch (state) { case 0: // Output length is a multiple of three. Fine. break; case 1: // Read one extra input byte, which isn't enough to // make another output byte. Illegal. this.state = 6; return false; case 2: // Read two extra input bytes, enough to emit 1 more // output byte. Fine. output[op++] = (byte) (value >> 4); break; case 3: // Read three extra input bytes, enough to emit 2 more // output bytes. Fine. output[op++] = (byte) (value >> 10); output[op++] = (byte) (value >> 2); break; case 4: // Read one padding '=' when we expected 2. Illegal. this.state = 6; return false; case 5: // Read all the padding '='s we expected and no more. // Fine. break; } this.state = state; this.op = op; return true; } } // -------------------------------------------------------- // encoding // -------------------------------------------------------- /** * Base64-encode the given data and return a newly allocated * String with the result. * * @param input the data to encode * @param flags controls certain features of the encoded output. * Passing {@code DEFAULT} results in output that * adheres to RFC 2045. */ public static String encodeToString(byte[] input, int flags) { try { return new String(encode(input, flags), "US-ASCII"); } catch (UnsupportedEncodingException e) { // US-ASCII is guaranteed to be available. throw new AssertionError(e); } } /** * Base64-encode the given data and return a newly allocated * String with the result. * * @param input the data to encode * @param offset the position within the input array at which to * start * @param len the number of bytes of input to encode * @param flags controls certain features of the encoded output. * Passing {@code DEFAULT} results in output that * adheres to RFC 2045. */ public static String encodeToString(byte[] input, int offset, int len, int flags) { try { return new String(encode(input, offset, len, flags), "US-ASCII"); } catch (UnsupportedEncodingException e) { // US-ASCII is guaranteed to be available. throw new AssertionError(e); } } /** * Base64-encode the given data and return a newly allocated * byte[] with the result. * * @param input the data to encode * @param flags controls certain features of the encoded output. * Passing {@code DEFAULT} results in output that * adheres to RFC 2045. */ public static byte[] encode(byte[] input, int flags) { return encode(input, 0, input.length, flags); } /** * Base64-encode the given data and return a newly allocated * byte[] with the result. * * @param input the data to encode * @param offset the position within the input array at which to * start * @param len the number of bytes of input to encode * @param flags controls certain features of the encoded output. * Passing {@code DEFAULT} results in output that * adheres to RFC 2045. */ public static byte[] encode(byte[] input, int offset, int len, int flags) { Encoder encoder = new Encoder(flags, null); // Compute the exact length of the array we will produce. int output_len = len / 3 * 4; // Account for the tail of the data and the padding bytes, if any. if (encoder.do_padding) { if (len % 3 > 0) { output_len += 4; } } else { switch (len % 3) { case 0: break; case 1: output_len += 2; break; case 2: output_len += 3; break; } } // Account for the newlines, if any. if (encoder.do_newline && len > 0) { output_len += (((len-1) / (3 * Encoder.LINE_GROUPS)) + 1) * (encoder.do_cr ? 2 : 1); } encoder.output = new byte[output_len]; encoder.process(input, offset, len, true); assert encoder.op == output_len; return encoder.output; } /* package */ static class Encoder extends Coder { /** * Emit a new line every this many output tuples. Corresponds to * a 76-character line length (the maximum allowable according to * <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>). */ public static final int LINE_GROUPS = 19; /** * Lookup table for turning Base64 alphabet positions (6 bits) * into output bytes. */ private static final byte ENCODE[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', }; /** * Lookup table for turning Base64 alphabet positions (6 bits) * into output bytes. */ private static final byte ENCODE_WEBSAFE[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_', }; final private byte[] tail; /* package */ int tailLen; private int count; final public boolean do_padding; final public boolean do_newline; final public boolean do_cr; final private byte[] alphabet; public Encoder(int flags, byte[] output) { this.output = output; do_padding = (flags & NO_PADDING) == 0; do_newline = (flags & NO_WRAP) == 0; do_cr = (flags & CRLF) != 0; alphabet = ((flags & URL_SAFE) == 0) ? ENCODE : ENCODE_WEBSAFE; tail = new byte[2]; tailLen = 0; count = do_newline ? LINE_GROUPS : -1; } /** * @return an overestimate for the number of bytes {@code * len} bytes could encode to. */ public int maxOutputSize(int len) { return len * 8/5 + 10; } public boolean process(byte[] input, int offset, int len, boolean finish) { // Using local variables makes the encoder about 9% faster. final byte[] alphabet = this.alphabet; final byte[] output = this.output; int op = 0; int count = this.count; int p = offset; len += offset; int v = -1; // First we need to concatenate the tail of the previous call // with any input bytes available now and see if we can empty // the tail. switch (tailLen) { case 0: // There was no tail. break; case 1: if (p+2 <= len) { // A 1-byte tail with at least 2 bytes of // input available now. v = ((tail[0] & 0xff) << 16) | ((input[p++] & 0xff) << 8) | (input[p++] & 0xff); tailLen = 0; }; break; case 2: if (p+1 <= len) { // A 2-byte tail with at least 1 byte of input. v = ((tail[0] & 0xff) << 16) | ((tail[1] & 0xff) << 8) | (input[p++] & 0xff); tailLen = 0; } break; } if (v != -1) { output[op++] = alphabet[(v >> 18) & 0x3f]; output[op++] = alphabet[(v >> 12) & 0x3f]; output[op++] = alphabet[(v >> 6) & 0x3f]; output[op++] = alphabet[v & 0x3f]; if (--count == 0) { if (do_cr) output[op++] = '\r'; output[op++] = '\n'; count = LINE_GROUPS; } } // At this point either there is no tail, or there are fewer // than 3 bytes of input available. // The main loop, turning 3 input bytes into 4 output bytes on // each iteration. while (p+3 <= len) { v = ((input[p] & 0xff) << 16) | ((input[p+1] & 0xff) << 8) | (input[p+2] & 0xff); output[op] = alphabet[(v >> 18) & 0x3f]; output[op+1] = alphabet[(v >> 12) & 0x3f]; output[op+2] = alphabet[(v >> 6) & 0x3f]; output[op+3] = alphabet[v & 0x3f]; p += 3; op += 4; if (--count == 0) { if (do_cr) output[op++] = '\r'; output[op++] = '\n'; count = LINE_GROUPS; } } if (finish) { // Finish up the tail of the input. Note that we need to // consume any bytes in tail before any bytes // remaining in input; there should be at most two bytes // total. if (p-tailLen == len-1) { int t = 0; v = ((tailLen > 0 ? tail[t++] : input[p++]) & 0xff) << 4; tailLen -= t; output[op++] = alphabet[(v >> 6) & 0x3f]; output[op++] = alphabet[v & 0x3f]; if (do_padding) { output[op++] = '='; output[op++] = '='; } if (do_newline) { if (do_cr) output[op++] = '\r'; output[op++] = '\n'; } } else if (p-tailLen == len-2) { int t = 0; v = (((tailLen > 1 ? tail[t++] : input[p++]) & 0xff) << 10) | (((tailLen > 0 ? tail[t++] : input[p++]) & 0xff) << 2); tailLen -= t; output[op++] = alphabet[(v >> 12) & 0x3f]; output[op++] = alphabet[(v >> 6) & 0x3f]; output[op++] = alphabet[v & 0x3f]; if (do_padding) { output[op++] = '='; } if (do_newline) { if (do_cr) output[op++] = '\r'; output[op++] = '\n'; } } else if (do_newline && op > 0 && count != LINE_GROUPS) { if (do_cr) output[op++] = '\r'; output[op++] = '\n'; } assert tailLen == 0; assert p == len; } else { // Save the leftovers in tail to be consumed on the next // call to encodeInternal. if (p == len-1) { tail[tailLen++] = input[p]; } else if (p == len-2) { tail[tailLen++] = input[p]; tail[tailLen++] = input[p+1]; } } this.op = op; this.count = count; return true; } } private Base64() { } // don't instantiate }
6739a33fff2f835470736cefbb33ec1d8bd80e44
e3ee8bda887b00c627b904c894adaf9fe07a2a84
/src/main/java/miasi/handlarz/security/web/controller/AdminController.java
fb6bdffe795e24be4147dbd651194dbd783d3688
[]
no_license
PatrykBrzuchacz/handlarz
262c1abb8209482a4dd6ecf16cff84924f377ede
9c7a6b45176924209c255b2d1bf25d58ddd01e9e
refs/heads/master
2023-04-30T04:58:46.089414
2021-05-24T20:53:15
2021-05-24T20:53:15
365,549,388
0
0
null
null
null
null
UTF-8
Java
false
false
1,271
java
package miasi.handlarz.security.web.controller; import miasi.handlarz.security.web.dto.UserCriteria; import miasi.handlarz.security.web.dto.UserDto; import miasi.handlarz.security.web.dto.UserStatusChangeDto; import miasi.handlarz.user.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/api/users") public class AdminController { @Autowired private UserService userService; @PreAuthorize("hasRole('ROLE_ADMIN')") @PostMapping public Page<UserDto> getAllUsers(@RequestBody UserCriteria userCriteria) { return userService.getAllUsers(userCriteria); } @PreAuthorize("hasRole('ROLE_ADMIN')") @PutMapping("/change-active") public UserDto changeActive(@RequestBody UserStatusChangeDto dto) { return userService.updateUserActive(dto.getId(), dto.isActive() ); } @PreAuthorize("hasRole('ROLE_ADMIN')") @PutMapping("/change-request") public UserDto changeRequest(@RequestBody UserStatusChangeDto dto) { return userService.updateUserRequest(dto.getId(), dto.getStatus()); } }
c26afa897445d20a4a3d4cdd7975a8155f0b3fe7
cebecde4fe43bc012b9cd736f25733375787c7c1
/src/main/java/com/bzb/talentmarket/mapper/TalentmarketKfMapper.java
275c63e43458ce9d8fc8cf6be455a1125a7af7c5
[]
no_license
bzbstar/talentmarket
e6830d3eb0a5f3f700806cb75256fd19e12863b3
7439c57c03db3b3988e0a09c29540bcf61e22b0a
refs/heads/master
2020-04-05T15:07:53.240541
2018-11-25T15:03:06
2018-11-25T15:03:06
156,954,263
0
0
null
null
null
null
UTF-8
Java
false
false
487
java
package com.bzb.talentmarket.mapper; import com.bzb.talentmarket.entity.TalentmarketKf; import org.springframework.stereotype.Repository; @Repository public interface TalentmarketKfMapper { int deleteByPrimaryKey(Integer id); int insert(TalentmarketKf record); int insertSelective(TalentmarketKf record); TalentmarketKf selectByPrimaryKey(Integer id); int updateByPrimaryKeySelective(TalentmarketKf record); int updateByPrimaryKey(TalentmarketKf record); }
38291927d742198d5f8faeca3cd3331d2480725e
7da844fd5430720a389854d7e0180f826d65b1ba
/src/main/java/gs/ui/tests/cosmo/pages/TestBeansContext.java
44d6f45a90475ee6386f65ce79f4ed183eaf4270
[]
no_license
hagaiGS/cosmo-selenium-tests
c37e31b7f096bcd983d3d8643c2d680f8f7f777b
abe94949425d78d5ed6db4f36c4a9cabce954026
refs/heads/master
2021-01-17T16:06:46.611898
2014-09-30T14:07:26
2014-09-30T14:07:26
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,013
java
package gs.ui.tests.cosmo.pages; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; /** * Created by Itsik on 24-Apr-14. */ public class TestBeansContext implements ApplicationContextAware { private static TestBeansContext instance = null; private static ApplicationContext applicationContext; public static TestBeansContext get() { if (instance == null) { instance = applicationContext.getBean(TestBeansContext.class); } return instance; } @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } public static ApplicationContext getApplicationContext() { return applicationContext; } public BlueprintPage getBlueprintPage() { return applicationContext.getBean(BlueprintPage.class); } }
187d1304b68c005556cd3bb22c9de07983b3007a
7c2c6f24966b3eb9b876497581264d02c53ef9cd
/LibraryHandler/src/iohandlers/XMLParser.java
5055172a282b42de286c5b4e5a769091c7600027
[]
no_license
nagydani98/AB2-JP-bead
837cc9040fa986ea90ba46acd4abc090459e6889
7ca1eefc3d138dcd393a9480873c0a850414454a
refs/heads/master
2020-04-28T10:30:12.392984
2019-04-29T05:07:54
2019-04-29T05:07:54
175,203,342
0
0
null
null
null
null
UTF-8
Java
false
false
2,380
java
package iohandlers; import java.io.File; import java.sql.Date; import java.time.LocalDate; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.util.ArrayList; import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.stream.StreamResult; import javax.xml.parsers.*; import org.w3c.dom.*; import models.Member; public class XMLParser { public static ArrayList<Element> parseDocument(String path) { ArrayList<Element> returnlist = new ArrayList<>(); try { File file = null; if((!path.isEmpty()) && path.contains(".xml")) { file = new File(path); } if(file.isFile()) { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); Document doc = docBuilder.parse(file); Element docelement = doc.getDocumentElement(); for (int i = 0; i < docelement.getChildNodes().getLength(); i++) { if(!(docelement.getChildNodes().item(i).getNodeName().equals("#text"))) { Element childElement = (Element) docelement.getChildNodes().item(i); returnlist.add(childElement); } } } } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } return returnlist; } public static Document createDocument() { Document doc = null; try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); doc = docBuilder.newDocument(); } catch (ParserConfigurationException e) { e.printStackTrace(); } return doc; } public static void saveDocument(Document doc, String path) { try { DOMSource source = new DOMSource(doc); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); StreamResult result = new StreamResult(path); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.transform(source, result); } catch (TransformerException e) { e.printStackTrace(); } } }
8ff06d9551c9f17286d0b11683166fd83ec3bbef
ddeac49aa8e95d3496d4c3fe24505763098e2d3d
/src/main/java/com/daduo/api/tiktokapi/model/UserFinancialInfoResponse.java
47576ff0f6f38a55a75c3cd0a95c446b71aa5b95
[]
no_license
woodyyan/tiktok-api
22e46af5d0281ca8e587f45fa2b4b53c20e4d48e
b26f7a0fa2d1116df263c15f531d174b4c128492
refs/heads/master
2020-04-24T08:10:59.598883
2019-05-05T09:56:28
2019-05-05T09:56:28
171,823,017
2
1
null
null
null
null
UTF-8
Java
false
false
403
java
package com.daduo.api.tiktokapi.model; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; import java.util.List; @Data @ApiModel("用户财务数据") public class UserFinancialInfoResponse { @ApiModelProperty(value = "用户财务数据列表") private List<UserFinancialInfo> data = new ArrayList<>(); }
dcbfd574fa569d0385c4f0a0932191b23dac32cd
ea16de2020ab8fdefc8327a906f7aa79c65e4ad4
/src/main/java/com/hellogood/domain/NoteExample.java
f53910202d3e664849438b1eabf28308a7423215
[]
no_license
scaukejian/hellogood_admin
3cca6d4f8572e967c6d47b6afe097663201c80fd
f5754d1e55e1f322085805d9446077666f696485
refs/heads/master
2021-09-07T18:21:26.784742
2018-02-27T08:19:46
2018-02-27T08:19:46
104,710,472
1
1
null
null
null
null
UTF-8
Java
false
false
32,923
java
package com.hellogood.domain; import java.util.ArrayList; import java.util.Date; import java.util.List; public class NoteExample { protected String orderByClause; protected boolean distinct; protected List<Criteria> oredCriteria; public NoteExample() { oredCriteria = new ArrayList<Criteria>(); } public void setOrderByClause(String orderByClause) { this.orderByClause = orderByClause; } public String getOrderByClause() { return orderByClause; } public void setDistinct(boolean distinct) { this.distinct = distinct; } public boolean isDistinct() { return distinct; } public List<Criteria> getOredCriteria() { return oredCriteria; } public void or(Criteria criteria) { oredCriteria.add(criteria); } public Criteria or() { Criteria criteria = createCriteriaInternal(); oredCriteria.add(criteria); return criteria; } public Criteria createCriteria() { Criteria criteria = createCriteriaInternal(); if (oredCriteria.size() == 0) { oredCriteria.add(criteria); } return criteria; } protected Criteria createCriteriaInternal() { Criteria criteria = new Criteria(); return criteria; } public void clear() { oredCriteria.clear(); orderByClause = null; distinct = false; } protected abstract static class GeneratedCriteria { protected List<Criterion> criteria; protected GeneratedCriteria() { super(); criteria = new ArrayList<Criterion>(); } public boolean isValid() { return criteria.size() > 0; } public List<Criterion> getAllCriteria() { return criteria; } public List<Criterion> getCriteria() { return criteria; } protected void addCriterion(String condition) { if (condition == null) { throw new RuntimeException("Value for condition cannot be null"); } criteria.add(new Criterion(condition)); } protected void addCriterion(String condition, Object value, String property) { if (value == null) { throw new RuntimeException("Value for " + property + " cannot be null"); } criteria.add(new Criterion(condition, value)); } protected void addCriterion(String condition, Object value1, Object value2, String property) { if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + property + " cannot be null"); } criteria.add(new Criterion(condition, value1, value2)); } public Criteria andIdIsNull() { addCriterion("id is null"); return (Criteria) this; } public Criteria andIdIsNotNull() { addCriterion("id is not null"); return (Criteria) this; } public Criteria andIdEqualTo(Integer value) { addCriterion("id =", value, "id"); return (Criteria) this; } public Criteria andIdNotEqualTo(Integer value) { addCriterion("id <>", value, "id"); return (Criteria) this; } public Criteria andIdGreaterThan(Integer value) { addCriterion("id >", value, "id"); return (Criteria) this; } public Criteria andIdGreaterThanOrEqualTo(Integer value) { addCriterion("id >=", value, "id"); return (Criteria) this; } public Criteria andIdLessThan(Integer value) { addCriterion("id <", value, "id"); return (Criteria) this; } public Criteria andIdLessThanOrEqualTo(Integer value) { addCriterion("id <=", value, "id"); return (Criteria) this; } public Criteria andIdIn(List<Integer> values) { addCriterion("id in", values, "id"); return (Criteria) this; } public Criteria andIdNotIn(List<Integer> values) { addCriterion("id not in", values, "id"); return (Criteria) this; } public Criteria andIdBetween(Integer value1, Integer value2) { addCriterion("id between", value1, value2, "id"); return (Criteria) this; } public Criteria andIdNotBetween(Integer value1, Integer value2) { addCriterion("id not between", value1, value2, "id"); return (Criteria) this; } public Criteria andUserIdIsNull() { addCriterion("user_id is null"); return (Criteria) this; } public Criteria andUserIdIsNotNull() { addCriterion("user_id is not null"); return (Criteria) this; } public Criteria andUserIdEqualTo(Integer value) { addCriterion("user_id =", value, "userId"); return (Criteria) this; } public Criteria andUserIdNotEqualTo(Integer value) { addCriterion("user_id <>", value, "userId"); return (Criteria) this; } public Criteria andUserIdGreaterThan(Integer value) { addCriterion("user_id >", value, "userId"); return (Criteria) this; } public Criteria andUserIdGreaterThanOrEqualTo(Integer value) { addCriterion("user_id >=", value, "userId"); return (Criteria) this; } public Criteria andUserIdLessThan(Integer value) { addCriterion("user_id <", value, "userId"); return (Criteria) this; } public Criteria andUserIdLessThanOrEqualTo(Integer value) { addCriterion("user_id <=", value, "userId"); return (Criteria) this; } public Criteria andUserIdIn(List<Integer> values) { addCriterion("user_id in", values, "userId"); return (Criteria) this; } public Criteria andUserIdNotIn(List<Integer> values) { addCriterion("user_id not in", values, "userId"); return (Criteria) this; } public Criteria andUserIdBetween(Integer value1, Integer value2) { addCriterion("user_id between", value1, value2, "userId"); return (Criteria) this; } public Criteria andUserIdNotBetween(Integer value1, Integer value2) { addCriterion("user_id not between", value1, value2, "userId"); return (Criteria) this; } public Criteria andPhoneUniqueCodeIsNull() { addCriterion("phone_unique_code is null"); return (Criteria) this; } public Criteria andPhoneUniqueCodeIsNotNull() { addCriterion("phone_unique_code is not null"); return (Criteria) this; } public Criteria andPhoneUniqueCodeEqualTo(String value) { addCriterion("phone_unique_code =", value, "phoneUniqueCode"); return (Criteria) this; } public Criteria andPhoneUniqueCodeNotEqualTo(String value) { addCriterion("phone_unique_code <>", value, "phoneUniqueCode"); return (Criteria) this; } public Criteria andPhoneUniqueCodeGreaterThan(String value) { addCriterion("phone_unique_code >", value, "phoneUniqueCode"); return (Criteria) this; } public Criteria andPhoneUniqueCodeGreaterThanOrEqualTo(String value) { addCriterion("phone_unique_code >=", value, "phoneUniqueCode"); return (Criteria) this; } public Criteria andPhoneUniqueCodeLessThan(String value) { addCriterion("phone_unique_code <", value, "phoneUniqueCode"); return (Criteria) this; } public Criteria andPhoneUniqueCodeLessThanOrEqualTo(String value) { addCriterion("phone_unique_code <=", value, "phoneUniqueCode"); return (Criteria) this; } public Criteria andPhoneUniqueCodeLike(String value) { addCriterion("phone_unique_code like", value, "phoneUniqueCode"); return (Criteria) this; } public Criteria andPhoneUniqueCodeNotLike(String value) { addCriterion("phone_unique_code not like", value, "phoneUniqueCode"); return (Criteria) this; } public Criteria andPhoneUniqueCodeIn(List<String> values) { addCriterion("phone_unique_code in", values, "phoneUniqueCode"); return (Criteria) this; } public Criteria andPhoneUniqueCodeNotIn(List<String> values) { addCriterion("phone_unique_code not in", values, "phoneUniqueCode"); return (Criteria) this; } public Criteria andPhoneUniqueCodeBetween(String value1, String value2) { addCriterion("phone_unique_code between", value1, value2, "phoneUniqueCode"); return (Criteria) this; } public Criteria andPhoneUniqueCodeNotBetween(String value1, String value2) { addCriterion("phone_unique_code not between", value1, value2, "phoneUniqueCode"); return (Criteria) this; } public Criteria andContentIsNull() { addCriterion("content is null"); return (Criteria) this; } public Criteria andContentIsNotNull() { addCriterion("content is not null"); return (Criteria) this; } public Criteria andContentEqualTo(String value) { addCriterion("content =", value, "content"); return (Criteria) this; } public Criteria andContentNotEqualTo(String value) { addCriterion("content <>", value, "content"); return (Criteria) this; } public Criteria andContentGreaterThan(String value) { addCriterion("content >", value, "content"); return (Criteria) this; } public Criteria andContentGreaterThanOrEqualTo(String value) { addCriterion("content >=", value, "content"); return (Criteria) this; } public Criteria andContentLessThan(String value) { addCriterion("content <", value, "content"); return (Criteria) this; } public Criteria andContentLessThanOrEqualTo(String value) { addCriterion("content <=", value, "content"); return (Criteria) this; } public Criteria andContentLike(String value) { addCriterion("content like", value, "content"); return (Criteria) this; } public Criteria andContentNotLike(String value) { addCriterion("content not like", value, "content"); return (Criteria) this; } public Criteria andContentIn(List<String> values) { addCriterion("content in", values, "content"); return (Criteria) this; } public Criteria andContentNotIn(List<String> values) { addCriterion("content not in", values, "content"); return (Criteria) this; } public Criteria andContentBetween(String value1, String value2) { addCriterion("content between", value1, value2, "content"); return (Criteria) this; } public Criteria andContentNotBetween(String value1, String value2) { addCriterion("content not between", value1, value2, "content"); return (Criteria) this; } public Criteria andCreateTimeIsNull() { addCriterion("create_time is null"); return (Criteria) this; } public Criteria andCreateTimeIsNotNull() { addCriterion("create_time is not null"); return (Criteria) this; } public Criteria andCreateTimeEqualTo(Date value) { addCriterion("create_time =", value, "createTime"); return (Criteria) this; } public Criteria andCreateTimeNotEqualTo(Date value) { addCriterion("create_time <>", value, "createTime"); return (Criteria) this; } public Criteria andCreateTimeGreaterThan(Date value) { addCriterion("create_time >", value, "createTime"); return (Criteria) this; } public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) { addCriterion("create_time >=", value, "createTime"); return (Criteria) this; } public Criteria andCreateTimeLessThan(Date value) { addCriterion("create_time <", value, "createTime"); return (Criteria) this; } public Criteria andCreateTimeLessThanOrEqualTo(Date value) { addCriterion("create_time <=", value, "createTime"); return (Criteria) this; } public Criteria andCreateTimeIn(List<Date> values) { addCriterion("create_time in", values, "createTime"); return (Criteria) this; } public Criteria andCreateTimeNotIn(List<Date> values) { addCriterion("create_time not in", values, "createTime"); return (Criteria) this; } public Criteria andCreateTimeBetween(Date value1, Date value2) { addCriterion("create_time between", value1, value2, "createTime"); return (Criteria) this; } public Criteria andCreateTimeNotBetween(Date value1, Date value2) { addCriterion("create_time not between", value1, value2, "createTime"); return (Criteria) this; } public Criteria andUpdateTimeIsNull() { addCriterion("update_time is null"); return (Criteria) this; } public Criteria andUpdateTimeIsNotNull() { addCriterion("update_time is not null"); return (Criteria) this; } public Criteria andUpdateTimeEqualTo(Date value) { addCriterion("update_time =", value, "updateTime"); return (Criteria) this; } public Criteria andUpdateTimeNotEqualTo(Date value) { addCriterion("update_time <>", value, "updateTime"); return (Criteria) this; } public Criteria andUpdateTimeGreaterThan(Date value) { addCriterion("update_time >", value, "updateTime"); return (Criteria) this; } public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) { addCriterion("update_time >=", value, "updateTime"); return (Criteria) this; } public Criteria andUpdateTimeLessThan(Date value) { addCriterion("update_time <", value, "updateTime"); return (Criteria) this; } public Criteria andUpdateTimeLessThanOrEqualTo(Date value) { addCriterion("update_time <=", value, "updateTime"); return (Criteria) this; } public Criteria andUpdateTimeIn(List<Date> values) { addCriterion("update_time in", values, "updateTime"); return (Criteria) this; } public Criteria andUpdateTimeNotIn(List<Date> values) { addCriterion("update_time not in", values, "updateTime"); return (Criteria) this; } public Criteria andUpdateTimeBetween(Date value1, Date value2) { addCriterion("update_time between", value1, value2, "updateTime"); return (Criteria) this; } public Criteria andUpdateTimeNotBetween(Date value1, Date value2) { addCriterion("update_time not between", value1, value2, "updateTime"); return (Criteria) this; } public Criteria andValidStatusIsNull() { addCriterion("valid_status is null"); return (Criteria) this; } public Criteria andValidStatusIsNotNull() { addCriterion("valid_status is not null"); return (Criteria) this; } public Criteria andValidStatusEqualTo(Integer value) { addCriterion("valid_status =", value, "validStatus"); return (Criteria) this; } public Criteria andValidStatusNotEqualTo(Integer value) { addCriterion("valid_status <>", value, "validStatus"); return (Criteria) this; } public Criteria andValidStatusGreaterThan(Integer value) { addCriterion("valid_status >", value, "validStatus"); return (Criteria) this; } public Criteria andValidStatusGreaterThanOrEqualTo(Integer value) { addCriterion("valid_status >=", value, "validStatus"); return (Criteria) this; } public Criteria andValidStatusLessThan(Integer value) { addCriterion("valid_status <", value, "validStatus"); return (Criteria) this; } public Criteria andValidStatusLessThanOrEqualTo(Integer value) { addCriterion("valid_status <=", value, "validStatus"); return (Criteria) this; } public Criteria andValidStatusIn(List<Integer> values) { addCriterion("valid_status in", values, "validStatus"); return (Criteria) this; } public Criteria andValidStatusNotIn(List<Integer> values) { addCriterion("valid_status not in", values, "validStatus"); return (Criteria) this; } public Criteria andValidStatusBetween(Integer value1, Integer value2) { addCriterion("valid_status between", value1, value2, "validStatus"); return (Criteria) this; } public Criteria andValidStatusNotBetween(Integer value1, Integer value2) { addCriterion("valid_status not between", value1, value2, "validStatus"); return (Criteria) this; } public Criteria andDisplayIsNull() { addCriterion("display is null"); return (Criteria) this; } public Criteria andDisplayIsNotNull() { addCriterion("display is not null"); return (Criteria) this; } public Criteria andDisplayEqualTo(Integer value) { addCriterion("display =", value, "display"); return (Criteria) this; } public Criteria andDisplayNotEqualTo(Integer value) { addCriterion("display <>", value, "display"); return (Criteria) this; } public Criteria andDisplayGreaterThan(Integer value) { addCriterion("display >", value, "display"); return (Criteria) this; } public Criteria andDisplayGreaterThanOrEqualTo(Integer value) { addCriterion("display >=", value, "display"); return (Criteria) this; } public Criteria andDisplayLessThan(Integer value) { addCriterion("display <", value, "display"); return (Criteria) this; } public Criteria andDisplayLessThanOrEqualTo(Integer value) { addCriterion("display <=", value, "display"); return (Criteria) this; } public Criteria andDisplayIn(List<Integer> values) { addCriterion("display in", values, "display"); return (Criteria) this; } public Criteria andDisplayNotIn(List<Integer> values) { addCriterion("display not in", values, "display"); return (Criteria) this; } public Criteria andDisplayBetween(Integer value1, Integer value2) { addCriterion("display between", value1, value2, "display"); return (Criteria) this; } public Criteria andDisplayNotBetween(Integer value1, Integer value2) { addCriterion("display not between", value1, value2, "display"); return (Criteria) this; } public Criteria andTopIsNull() { addCriterion("top is null"); return (Criteria) this; } public Criteria andTopIsNotNull() { addCriterion("top is not null"); return (Criteria) this; } public Criteria andTopEqualTo(Integer value) { addCriterion("top =", value, "top"); return (Criteria) this; } public Criteria andTopNotEqualTo(Integer value) { addCriterion("top <>", value, "top"); return (Criteria) this; } public Criteria andTopGreaterThan(Integer value) { addCriterion("top >", value, "top"); return (Criteria) this; } public Criteria andTopGreaterThanOrEqualTo(Integer value) { addCriterion("top >=", value, "top"); return (Criteria) this; } public Criteria andTopLessThan(Integer value) { addCriterion("top <", value, "top"); return (Criteria) this; } public Criteria andTopLessThanOrEqualTo(Integer value) { addCriterion("top <=", value, "top"); return (Criteria) this; } public Criteria andTopIn(List<Integer> values) { addCriterion("top in", values, "top"); return (Criteria) this; } public Criteria andTopNotIn(List<Integer> values) { addCriterion("top not in", values, "top"); return (Criteria) this; } public Criteria andTopBetween(Integer value1, Integer value2) { addCriterion("top between", value1, value2, "top"); return (Criteria) this; } public Criteria andTopNotBetween(Integer value1, Integer value2) { addCriterion("top not between", value1, value2, "top"); return (Criteria) this; } public Criteria andFinishIsNull() { addCriterion("finish is null"); return (Criteria) this; } public Criteria andFinishIsNotNull() { addCriterion("finish is not null"); return (Criteria) this; } public Criteria andFinishEqualTo(Integer value) { addCriterion("finish =", value, "finish"); return (Criteria) this; } public Criteria andFinishNotEqualTo(Integer value) { addCriterion("finish <>", value, "finish"); return (Criteria) this; } public Criteria andFinishGreaterThan(Integer value) { addCriterion("finish >", value, "finish"); return (Criteria) this; } public Criteria andFinishGreaterThanOrEqualTo(Integer value) { addCriterion("finish >=", value, "finish"); return (Criteria) this; } public Criteria andFinishLessThan(Integer value) { addCriterion("finish <", value, "finish"); return (Criteria) this; } public Criteria andFinishLessThanOrEqualTo(Integer value) { addCriterion("finish <=", value, "finish"); return (Criteria) this; } public Criteria andFinishIn(List<Integer> values) { addCriterion("finish in", values, "finish"); return (Criteria) this; } public Criteria andFinishNotIn(List<Integer> values) { addCriterion("finish not in", values, "finish"); return (Criteria) this; } public Criteria andFinishBetween(Integer value1, Integer value2) { addCriterion("finish between", value1, value2, "finish"); return (Criteria) this; } public Criteria andFinishNotBetween(Integer value1, Integer value2) { addCriterion("finish not between", value1, value2, "finish"); return (Criteria) this; } public Criteria andTypeIsNull() { addCriterion("type is null"); return (Criteria) this; } public Criteria andTypeIsNotNull() { addCriterion("type is not null"); return (Criteria) this; } public Criteria andTypeEqualTo(String value) { addCriterion("type =", value, "type"); return (Criteria) this; } public Criteria andTypeNotEqualTo(String value) { addCriterion("type <>", value, "type"); return (Criteria) this; } public Criteria andTypeGreaterThan(String value) { addCriterion("type >", value, "type"); return (Criteria) this; } public Criteria andTypeGreaterThanOrEqualTo(String value) { addCriterion("type >=", value, "type"); return (Criteria) this; } public Criteria andTypeLessThan(String value) { addCriterion("type <", value, "type"); return (Criteria) this; } public Criteria andTypeLessThanOrEqualTo(String value) { addCriterion("type <=", value, "type"); return (Criteria) this; } public Criteria andTypeLike(String value) { addCriterion("type like", value, "type"); return (Criteria) this; } public Criteria andTypeNotLike(String value) { addCriterion("type not like", value, "type"); return (Criteria) this; } public Criteria andTypeIn(List<String> values) { addCriterion("type in", values, "type"); return (Criteria) this; } public Criteria andTypeNotIn(List<String> values) { addCriterion("type not in", values, "type"); return (Criteria) this; } public Criteria andTypeBetween(String value1, String value2) { addCriterion("type between", value1, value2, "type"); return (Criteria) this; } public Criteria andTypeNotBetween(String value1, String value2) { addCriterion("type not between", value1, value2, "type"); return (Criteria) this; } public Criteria andColorIsNull() { addCriterion("color is null"); return (Criteria) this; } public Criteria andColorIsNotNull() { addCriterion("color is not null"); return (Criteria) this; } public Criteria andColorEqualTo(String value) { addCriterion("color =", value, "color"); return (Criteria) this; } public Criteria andColorNotEqualTo(String value) { addCriterion("color <>", value, "color"); return (Criteria) this; } public Criteria andColorGreaterThan(String value) { addCriterion("color >", value, "color"); return (Criteria) this; } public Criteria andColorGreaterThanOrEqualTo(String value) { addCriterion("color >=", value, "color"); return (Criteria) this; } public Criteria andColorLessThan(String value) { addCriterion("color <", value, "color"); return (Criteria) this; } public Criteria andColorLessThanOrEqualTo(String value) { addCriterion("color <=", value, "color"); return (Criteria) this; } public Criteria andColorLike(String value) { addCriterion("color like", value, "color"); return (Criteria) this; } public Criteria andColorNotLike(String value) { addCriterion("color not like", value, "color"); return (Criteria) this; } public Criteria andColorIn(List<String> values) { addCriterion("color in", values, "color"); return (Criteria) this; } public Criteria andColorNotIn(List<String> values) { addCriterion("color not in", values, "color"); return (Criteria) this; } public Criteria andColorBetween(String value1, String value2) { addCriterion("color between", value1, value2, "color"); return (Criteria) this; } public Criteria andColorNotBetween(String value1, String value2) { addCriterion("color not between", value1, value2, "color"); return (Criteria) this; } public Criteria andFolderIdIsNull() { addCriterion("folder_id is null"); return (Criteria) this; } public Criteria andFolderIdIsNotNull() { addCriterion("folder_id is not null"); return (Criteria) this; } public Criteria andFolderIdEqualTo(Integer value) { addCriterion("folder_id =", value, "folderId"); return (Criteria) this; } public Criteria andFolderIdNotEqualTo(Integer value) { addCriterion("folder_id <>", value, "folderId"); return (Criteria) this; } public Criteria andFolderIdGreaterThan(Integer value) { addCriterion("folder_id >", value, "folderId"); return (Criteria) this; } public Criteria andFolderIdGreaterThanOrEqualTo(Integer value) { addCriterion("folder_id >=", value, "folderId"); return (Criteria) this; } public Criteria andFolderIdLessThan(Integer value) { addCriterion("folder_id <", value, "folderId"); return (Criteria) this; } public Criteria andFolderIdLessThanOrEqualTo(Integer value) { addCriterion("folder_id <=", value, "folderId"); return (Criteria) this; } public Criteria andFolderIdIn(List<Integer> values) { addCriterion("folder_id in", values, "folderId"); return (Criteria) this; } public Criteria andFolderIdNotIn(List<Integer> values) { addCriterion("folder_id not in", values, "folderId"); return (Criteria) this; } public Criteria andFolderIdBetween(Integer value1, Integer value2) { addCriterion("folder_id between", value1, value2, "folderId"); return (Criteria) this; } public Criteria andFolderIdNotBetween(Integer value1, Integer value2) { addCriterion("folder_id not between", value1, value2, "folderId"); return (Criteria) this; } } public static class Criteria extends GeneratedCriteria { protected Criteria() { super(); } } public static class Criterion { private String condition; private Object value; private Object secondValue; private boolean noValue; private boolean singleValue; private boolean betweenValue; private boolean listValue; private String typeHandler; public String getCondition() { return condition; } public Object getValue() { return value; } public Object getSecondValue() { return secondValue; } public boolean isNoValue() { return noValue; } public boolean isSingleValue() { return singleValue; } public boolean isBetweenValue() { return betweenValue; } public boolean isListValue() { return listValue; } public String getTypeHandler() { return typeHandler; } protected Criterion(String condition) { super(); this.condition = condition; this.typeHandler = null; this.noValue = true; } protected Criterion(String condition, Object value, String typeHandler) { super(); this.condition = condition; this.value = value; this.typeHandler = typeHandler; if (value instanceof List<?>) { this.listValue = true; } else { this.singleValue = true; } } protected Criterion(String condition, Object value) { this(condition, value, null); } protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { super(); this.condition = condition; this.value = value; this.secondValue = secondValue; this.typeHandler = typeHandler; this.betweenValue = true; } protected Criterion(String condition, Object value, Object secondValue) { this(condition, value, secondValue, null); } } }
df2f94eb82af6d1e043538c020d81960e70a7bd6
18d96ffa6f5dd781ad57835196f91fb8587469f4
/znylg-backend/znylg/src/main/java/com/xuanxuan/csu/model/Reply.java
e4c14b7b078c8f04b677fc43688b87113fded9cb
[]
no_license
zongyuantong/comment
ff7ab17e572221f2278b0837685936f03ad94a07
310c717b2566780c17a616b54783a9d32256b8b9
refs/heads/master
2022-11-25T14:46:54.585925
2020-08-01T04:15:44
2020-08-01T04:15:44
284,176,456
0
0
null
2020-08-01T03:11:58
2020-08-01T03:11:58
null
UTF-8
Java
false
false
885
java
package com.xuanxuan.csu.model; import lombok.Data; import javax.persistence.Column; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import java.util.Date; @Data @Table(name = "reply") public class Reply { @Id @GeneratedValue(generator = "UUID") private String id; @Column(name = "comment_id") private String commentId; @Column(name = "reply_id") private String replyId; @Column(name = "reply_type") private Integer replyType;//回复评论为1,回复回复为2 @Column(name = "content") private String content; @Column(name = "from_uid") private String fromUid; @Column(name = "create_time") private Date createTime = new Date(); @Column(name = "star_number") private Integer zanNum = 0; @Column(name = "verified") private Integer verified; }
4df9b64e91752483a5d679fb9b852f926a92e7f2
4aba828da7ecabfc4363dda79807436a2470f316
/src/test/java/com/ning/atlas/spi/TestUri.java
93411c419ce0f67a926ea0bdd224421d06b2682b
[ "MIT", "BSD-3-Clause", "Apache-2.0" ]
permissive
darthjoel/atlas
2290db32accf9cba7a78f1a57b84df3839216de9
94e6764da3f791b179fda8bcbdc9d1b89de3bcd2
refs/heads/master
2020-12-25T09:57:52.249902
2012-04-19T00:15:02
2012-04-19T00:15:02
null
0
0
null
null
null
null
UTF-8
Java
false
false
7,195
java
package com.ning.atlas.spi; import com.google.common.collect.ImmutableMap; import com.ning.atlas.Base; import org.junit.Test; import org.stringtemplate.v4.ST; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Map; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; import static org.junit.matchers.JUnitMatchers.hasItem; public class TestUri { @Test public void testScheme() throws Exception { Uri uri = Uri.valueOf("provisioner:galaxy:v2"); assertThat(uri.getScheme(), equalTo("provisioner")); } @Test public void testJustScheme() throws Exception { Uri uri = Uri.valueOf("waffle"); assertThat(uri.getScheme(), equalTo("waffle")); assertThat(uri.getFragment(), equalTo("")); } @Test public void testFragment() throws Exception { Uri uri = Uri.valueOf("provisioner:galaxy:v2"); assertThat(uri.getFragment(), equalTo("galaxy:v2")); } @Test public void testFragmentExcludesParams() throws Exception { Uri uri = Uri.valueOf("hello:world?a=1&b=2"); assertThat(uri.getFragment(), equalTo("world")); } @Test public void testParams1() throws Exception { Uri uri = Uri.valueOf("hello:world?a=1&b=2"); Map<String, Collection<String>> params = uri.getFullParams(); assertThat(params.get("a"), hasItem("1")); assertThat(params.get("b"), hasItem("2")); } @Test public void testParams2() throws Exception { Uri uri = Uri.valueOf("hello?a=1&b=2"); Map<String, Collection<String>> params = uri.getFullParams(); assertThat(params.get("a"), hasItem("1")); assertThat(params.get("b"), hasItem("2")); } @Test public void testParams3() throws Exception { Uri uri = Uri.valueOf("hello:?a=1&b=2"); Map<String, Collection<String>> params = uri.getFullParams(); assertThat(params.get("a"), hasItem("1")); assertThat(params.get("b"), hasItem("2")); } @Test public void testAdditionalParams() throws Exception { Uri uri = Uri.valueOf("hello:?a=1", ImmutableMap.<String, Collection<String>>of("b", Arrays.asList("2"))); Map<String, Collection<String>> params = uri.getFullParams(); assertThat(params.get("a"), hasItem("1")); assertThat(params.get("b"), hasItem("2")); } @Test public void testAdditionalParams2() throws Exception { Uri uri = Uri.valueOf("hello", ImmutableMap.<String, Collection<String>>of("a", Arrays.asList("1"), "b", Arrays.asList("2"))); Map<String, Collection<String>> params = uri.getFullParams(); assertThat(params.get("a"), hasItem("1")); assertThat(params.get("b"), hasItem("2")); } @Test public void testCanonicalization() throws Exception { Uri uri = new Uri("hello", "world", ImmutableMap.<String, Collection<String>>of("a", Arrays.asList("hello", "world"), "b", Arrays.asList("hello world"))); assertThat(uri.toString(), equalTo("hello:world?a=hello&a=world&b=hello world")); } @Test public void testSchemeWithNoStuff() throws Exception { Uri uri = new Uri("rds", "", ImmutableMap.<String, Collection<String>>of("hello", Arrays.asList("world"))); assertThat(uri.getScheme(), equalTo("rds")); } @Test public void testSchemeWithNoStuff2() throws Exception { Uri uri = Uri.valueOf("rds", ImmutableMap.<String, Collection<String>>of("hello", Arrays.asList("world"))); assertThat(uri.getScheme(), equalTo("rds")); } @Test public void testSchemeWithNoStuff3() throws Exception { Uri uri = Uri.valueOf("rds", ImmutableMap.<String, Collection<String>>of("hello", Arrays.asList("world"))); Uri dup = Uri.valueOf(uri.toString()); assertThat(dup.getScheme(), equalTo("rds")); } @Test public void testTemplateInUri() throws Exception { Uri uri = Uri.valueOf("hello:{name}"); assertThat(uri.isTemplate(), equalTo(true)); } @Test public void testTemplateInUri2() throws Exception { Uri uri = Uri.valueOf("hello:name?{key}=value"); assertThat(uri.isTemplate(), equalTo(true)); } @Test public void testTemplateInUri3() throws Exception { Uri uri = Uri.valueOf("hello:name?key={value}"); assertThat(uri.isTemplate(), equalTo(true)); } @Test public void testTemplateInUri4() throws Exception { Uri uri = Uri.valueOf("{hello}:name?key=value"); assertThat(uri.isTemplate(), equalTo(true)); } @Test public void testTemplateUri5() throws Exception { Uri uri = Uri.valueOf("hello:{name}?key={value}", Collections.<String, Collection<String>>emptyMap()); assertThat(uri.toStringUnEscaped(), equalTo("hello:{name}?key={value}")); assertThat(uri.isTemplate(), equalTo(true)); } @Test public void testUgh() throws Exception { Uri uri = Uri.valueOf("{base.fragment}?port={my.port}", Collections.<String, Collection<String>>emptyMap()); } @Test public void testNotTemplateInUri() throws Exception { Uri uri = Uri.valueOf("!hello:{name}"); assertThat(uri.isTemplate(), equalTo(false)); assertThat(uri.getScheme(), equalTo("hello")); } @Test public void testNotTemplateInUri2() throws Exception { Uri uri = Uri.valueOf("!hello:name?{key}=value"); assertThat(uri.isTemplate(), equalTo(false)); } @Test public void testNotTemplateInUri3() throws Exception { Uri uri = Uri.valueOf("!hello:name?key={value}"); assertThat(uri.isTemplate(), equalTo(false)); } @Test public void testNotTemplateInUri4() throws Exception { Uri uri = Uri.valueOf("!{hello}:name?key=value"); assertThat(uri.isTemplate(), equalTo(false)); assertThat(uri.getScheme(), equalTo("{hello}")); } @Test public void testActuallyApplyTemplate() throws Exception { Uri<Base> base_uri = Uri.valueOf("mysql:blog"); Uri<Provisioner> uri = Uri.valueOf("rds?name={base.fragment}&engine=MySQL"); assertThat(uri.toStringUnEscaped(), equalTo("rds?engine=MySQL&name={base.fragment}")); ST st = new ST(uri.toStringUnEscaped(), '{', '}'); st.add("base", base_uri); assertThat(st.render(), equalTo("rds?engine=MySQL&name=blog")); } @Test public void testSpaces() throws Exception { Uri<String> u = Uri.valueOf("script:sculptor/install.sh {virtual.fragment}?unwind=sculptor/uninstall.sh {virtual.fragment}"); String unwind = u.getParams().get("unwind"); assertThat(unwind, equalTo("sculptor/uninstall.sh {virtual.fragment}")); } }
ed3078b867df4a80f558684e14cae56258eece5d
4312a71c36d8a233de2741f51a2a9d28443cd95b
/RawExperiments/Math/math99/2/AstorMain-math_99/src/default/org/apache/commons/math/fraction/Fraction.java
bca4f2386b11e02634ef6ec3ebd14257a419e056
[]
no_license
SajjadZaidi/AutoRepair
5c7aa7a689747c143cafd267db64f1e365de4d98
e21eb9384197bae4d9b23af93df73b6e46bb749a
refs/heads/master
2021-05-07T00:07:06.345617
2017-12-02T18:48:14
2017-12-02T18:48:14
112,858,432
0
0
null
null
null
null
UTF-8
Java
false
false
10,427
java
package org.apache.commons.math.fraction; public class Fraction extends java.lang.Number implements java.lang.Comparable<org.apache.commons.math.fraction.Fraction> { public static final org.apache.commons.math.fraction.Fraction TWO = new org.apache.commons.math.fraction.Fraction(2 , 1); public static final org.apache.commons.math.fraction.Fraction ONE = new org.apache.commons.math.fraction.Fraction(1 , 1); public static final org.apache.commons.math.fraction.Fraction ZERO = new org.apache.commons.math.fraction.Fraction(0 , 1); public static final org.apache.commons.math.fraction.Fraction MINUS_ONE = new org.apache.commons.math.fraction.Fraction((-1) , 1); private static final long serialVersionUID = 3071409609509774764L; private final int denominator; private final int numerator; public Fraction(double value) throws org.apache.commons.math.fraction.FractionConversionException { this(value, 1.0E-5, 100); } public Fraction(double value ,double epsilon ,int maxIterations) throws org.apache.commons.math.fraction.FractionConversionException { this(value, epsilon, java.lang.Integer.MAX_VALUE, maxIterations); } public Fraction(double value ,int maxDenominator) throws org.apache.commons.math.fraction.FractionConversionException { this(value, 0, maxDenominator, 100); } private Fraction(double value ,double epsilon ,int maxDenominator ,int maxIterations) throws org.apache.commons.math.fraction.FractionConversionException { long overflow = java.lang.Integer.MAX_VALUE; double r0 = value; long a0 = ((long)(java.lang.Math.floor(r0))); if (a0 > overflow) { throw new org.apache.commons.math.fraction.FractionConversionException(value , a0 , 1L); } if ((java.lang.Math.abs((a0 - value))) < epsilon) { this.numerator = ((int)(a0)); this.denominator = 1; return ; } long p0 = 1; long q0 = 0; long p1 = a0; long q1 = 1; long p2 = 0; long q2 = 1; int n = 0; boolean stop = false; do { ++n; double r1 = 1.0 / (r0 - a0); long a1 = ((long)(java.lang.Math.floor(r1))); p2 = (a1 * p1) + p0; q2 = (a1 * q1) + q0; if ((p2 > overflow) || (q2 > overflow)) { throw new org.apache.commons.math.fraction.FractionConversionException(value , p2 , q2); } double convergent = ((double)(p2)) / ((double)(q2)); if (((n < maxIterations) && ((java.lang.Math.abs((convergent - value))) > epsilon)) && (q2 < maxDenominator)) { p0 = p1; p1 = p2; q0 = q1; q1 = q2; a0 = a1; r0 = r1; } else { stop = true; } } while (!stop ); if (n >= maxIterations) { throw new org.apache.commons.math.fraction.FractionConversionException(value , maxIterations); } if (q2 < maxDenominator) { this.numerator = ((int)(p2)); this.denominator = ((int)(q2)); } else { this.numerator = ((int)(p1)); this.denominator = ((int)(q1)); } } public Fraction(int num ,int den) { super(); if (den == 0) { throw org.apache.commons.math.MathRuntimeException.createArithmeticException("zero denominator in fraction {0}/{1}", new java.lang.Object[]{ num , den }); } if (den < 0) { if ((num == (java.lang.Integer.MIN_VALUE)) || (den == (java.lang.Integer.MIN_VALUE))) { throw org.apache.commons.math.MathRuntimeException.createArithmeticException("overflow in fraction {0}/{1}, cannot negate", new java.lang.Object[]{ num , den }); } num = -num; den = -den; } int d = org.apache.commons.math.util.MathUtils.gcd(num, den); if (d > 1) { num /= d; den /= d; } if (den < 0) { num *= -1; den *= -1; } this.numerator = num; this.denominator = den; } public org.apache.commons.math.fraction.Fraction abs() { org.apache.commons.math.fraction.Fraction ret; if ((numerator) >= 0) { ret = org.apache.commons.math.fraction.Fraction.this; } else { ret = negate(); } return ret; } public int compareTo(org.apache.commons.math.fraction.Fraction object) { int ret = 0; if ((org.apache.commons.math.fraction.Fraction.this) != object) { double first = doubleValue(); double second = object.doubleValue(); if (first < second) { ret = -1; } else if (first > second) { ret = 1; } } return ret; } public double doubleValue() { return ((double)(numerator)) / ((double)(denominator)); } public boolean equals(java.lang.Object other) { boolean ret; if ((org.apache.commons.math.fraction.Fraction.this) == other) { ret = true; } else if (other == null) { ret = false; } else { try { org.apache.commons.math.fraction.Fraction rhs = ((org.apache.commons.math.fraction.Fraction)(other)); ret = ((numerator) == (rhs.numerator)) && ((denominator) == (rhs.denominator)); } catch (java.lang.ClassCastException ex) { ret = false; } } return ret; } public float floatValue() { return ((float)(doubleValue())); } public int getDenominator() { return denominator; } public int getNumerator() { return numerator; } public int hashCode() { return (37 * ((37 * 17) + (getNumerator()))) + (getDenominator()); } public int intValue() { return ((int)(doubleValue())); } public long longValue() { return ((long)(doubleValue())); } public org.apache.commons.math.fraction.Fraction negate() { if ((numerator) == (java.lang.Integer.MIN_VALUE)) { throw org.apache.commons.math.MathRuntimeException.createArithmeticException("overflow in fraction {0}/{1}, cannot negate", new java.lang.Object[]{ numerator , denominator }); } return new org.apache.commons.math.fraction.Fraction((-(numerator)) , denominator); } public org.apache.commons.math.fraction.Fraction reciprocal() { return new org.apache.commons.math.fraction.Fraction(denominator , numerator); } public org.apache.commons.math.fraction.Fraction add(org.apache.commons.math.fraction.Fraction fraction) { return addSub(fraction, true); } public org.apache.commons.math.fraction.Fraction subtract(org.apache.commons.math.fraction.Fraction fraction) { return addSub(fraction, false); } private org.apache.commons.math.fraction.Fraction addSub(org.apache.commons.math.fraction.Fraction fraction, boolean isAdd) { if (fraction == null) { throw new java.lang.IllegalArgumentException("The fraction must not be null"); } if ((numerator) == 0) { return isAdd ? fraction : fraction.negate(); } if ((fraction.numerator) == 0) { return org.apache.commons.math.fraction.Fraction.this; } int d1 = org.apache.commons.math.util.MathUtils.gcd(denominator, fraction.denominator); if (d1 == 1) { int uvp = org.apache.commons.math.util.MathUtils.mulAndCheck(numerator, fraction.denominator); int upv = org.apache.commons.math.util.MathUtils.mulAndCheck(fraction.numerator, denominator); return new org.apache.commons.math.fraction.Fraction((isAdd ? org.apache.commons.math.util.MathUtils.addAndCheck(uvp, upv) : org.apache.commons.math.util.MathUtils.subAndCheck(uvp, upv)) , org.apache.commons.math.util.MathUtils.mulAndCheck(denominator, fraction.denominator)); } java.math.BigInteger uvp = java.math.BigInteger.valueOf(numerator).multiply(java.math.BigInteger.valueOf(((fraction.denominator) / d1))); java.math.BigInteger upv = java.math.BigInteger.valueOf(fraction.numerator).multiply(java.math.BigInteger.valueOf(((denominator) / d1))); java.math.BigInteger t = isAdd ? uvp.add(upv) : uvp.subtract(upv); int tmodd1 = t.mod(java.math.BigInteger.valueOf(d1)).intValue(); int d2 = tmodd1 == 0 ? d1 : org.apache.commons.math.util.MathUtils.gcd(tmodd1, d1); java.math.BigInteger w = t.divide(java.math.BigInteger.valueOf(d2)); if ((w.bitLength()) > 31) { throw org.apache.commons.math.MathRuntimeException.createArithmeticException("overflow, numerator too large after multiply: {0}", new java.lang.Object[]{ w }); } return new org.apache.commons.math.fraction.Fraction(w.intValue() , org.apache.commons.math.util.MathUtils.mulAndCheck(((denominator) / d1), ((fraction.denominator) / d2))); } public org.apache.commons.math.fraction.Fraction multiply(org.apache.commons.math.fraction.Fraction fraction) { if (fraction == null) { throw new java.lang.IllegalArgumentException("The fraction must not be null"); } if (((numerator) == 0) || ((fraction.numerator) == 0)) { return org.apache.commons.math.fraction.Fraction.ZERO; } int d1 = org.apache.commons.math.util.MathUtils.gcd(numerator, fraction.denominator); int d2 = org.apache.commons.math.util.MathUtils.gcd(fraction.numerator, denominator); return org.apache.commons.math.fraction.Fraction.getReducedFraction(org.apache.commons.math.util.MathUtils.mulAndCheck(((numerator) / d1), ((fraction.numerator) / d2)), org.apache.commons.math.util.MathUtils.mulAndCheck(((denominator) / d2), ((fraction.denominator) / d1))); } public org.apache.commons.math.fraction.Fraction divide(org.apache.commons.math.fraction.Fraction fraction) { if (fraction == null) { throw new java.lang.IllegalArgumentException("The fraction must not be null"); } if ((fraction.numerator) == 0) { throw org.apache.commons.math.MathRuntimeException.createArithmeticException("the fraction to divide by must not be zero: {0}/{1}", new java.lang.Object[]{ fraction.numerator , fraction.denominator }); } return multiply(fraction.reciprocal()); } public static org.apache.commons.math.fraction.Fraction getReducedFraction(int numerator, int denominator) { if (denominator == 0) { throw org.apache.commons.math.MathRuntimeException.createArithmeticException("zero denominator in fraction {0}/{1}", new java.lang.Object[]{ numerator , denominator }); } if (numerator == 0) { return org.apache.commons.math.fraction.Fraction.ZERO; } if ((denominator == (java.lang.Integer.MIN_VALUE)) && ((numerator & 1) == 0)) { numerator /= 2; denominator /= 2; } if (denominator < 0) { if ((numerator == (java.lang.Integer.MIN_VALUE)) || (denominator == (java.lang.Integer.MIN_VALUE))) { throw org.apache.commons.math.MathRuntimeException.createArithmeticException("overflow in fraction {0}/{1}, cannot negate", new java.lang.Object[]{ numerator , denominator }); } numerator = -numerator; denominator = -denominator; } int gcd = org.apache.commons.math.util.MathUtils.gcd(numerator, denominator); numerator /= gcd; denominator /= gcd; return new org.apache.commons.math.fraction.Fraction(numerator , denominator); } }
6e45e47e98c65c38ef548ac9f56cbb042b7dae79
b68ea8b705cd3c6e35e42b2d9e77395d37a586c4
/4/EarthquakeFilterStarterProgram/DepthFilter.java
1ab2a5d245e50e015b027fc337ba08c3b9d19d60
[]
no_license
misstong/Java-Programming_DUKE
66a6fa8966fb3e90a824a61d1a4e617b8052e167
43bebd9082631102689e2a60875f8c948e7aa295
refs/heads/master
2021-08-08T20:41:30.384518
2017-11-11T04:50:14
2017-11-11T04:50:14
110,318,749
0
0
null
null
null
null
UTF-8
Java
false
false
560
java
/** * Write a description of DepthFilter here. * * @author (your name) * @version (a version number or a date) */ public class DepthFilter implements Filter{ private double minDepth; private double maxDepth; public DepthFilter(double min,double max){ maxDepth=max; minDepth=min; } public boolean satisfies(QuakeEntry qe){ if(qe.getDepth()>=minDepth&&qe.getDepth()<=maxDepth){ return true; } return false; } public String getName(){ return "DepthFilter"; } }
2a27e662e2100ae4b5d9f8db927b7adcd934ed19
8058cb838e5d0c226774ae7fcd296c7fff6234c2
/alibaba-sentinel-server/src/test/java/com/demo/alibaba/AlibabaSentinelServerApplicationTests.java
696746f11edaa825719ffe6250ad419175097e0b
[]
no_license
lichangtong/spring-alibaba
28b7eba984dcc7fdc66cea313b6ce962514d05f2
b9ddc42068177db645194b412c5ddf4cfe1964ba
refs/heads/master
2023-02-12T19:53:11.583875
2021-01-06T08:22:40
2021-01-06T08:22:40
288,068,510
0
0
null
null
null
null
UTF-8
Java
false
false
232
java
package com.demo.alibaba; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class AlibabaSentinelServerApplicationTests { @Test void contextLoads() { } }
b79748afbf2bf11dfc9a86e965e7e1912b6df974
0ac05e3da06d78292fdfb64141ead86ff6ca038f
/OSWE/oswe/openCRX/rtjar/rt.jar.src/org/w3c/dom/html/HTMLMapElement.java
580af11c94296dd80d7e888b3ad6efacc895b1f3
[]
no_license
qoo7972365/timmy
31581cdcbb8858ac19a8bb7b773441a68b6c390a
2fc8baba4f53d38dfe9c2b3afd89dcf87cbef578
refs/heads/master
2023-07-26T12:26:35.266587
2023-07-17T12:35:19
2023-07-17T12:35:19
353,889,195
7
1
null
null
null
null
UTF-8
Java
false
false
355
java
package org.w3c.dom.html; public interface HTMLMapElement extends HTMLElement { HTMLCollection getAreas(); String getName(); void setName(String paramString); } /* Location: /Users/timmy/timmy/OSWE/oswe/openCRX/rt.jar!/org/w3c/dom/html/HTMLMapElement.class * Java compiler version: 8 (52.0) * JD-Core Version: 1.1.3 */
[ "t0984456716" ]
t0984456716
427f4e263727242c2b81d3d97bc9a2b29c59d22e
88f6cfe62b9d357dd7e52257bc5e013652472565
/Android_code/Robot/app/src/androidTest/java/com/example/rajitha/robot/ExampleInstrumentedTest.java
8c5c5bea75f72d8118bbc7843f1544b15aa675f0
[ "Apache-2.0" ]
permissive
rajutewari/WiFi-Robot
87e2409b24f565a585f67354297c1a434c31086b
78b6818747bc540ee19d781b7950ca85d63d3cb9
refs/heads/master
2021-04-26T23:43:15.676308
2017-12-06T15:55:03
2017-12-06T15:55:03
null
0
0
null
null
null
null
UTF-8
Java
false
false
751
java
package com.example.rajitha.robot; 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.*; /** * Instrumented 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("com.example.rajitha.robot", appContext.getPackageName()); } }
210632a71062568085ea9b02002275a7a9481771
1d4fc62d5785c761120a778777a7b92fea8f7f3b
/src/main/java/com/sogou/map/android/Voting.java
a67eade757b2a4a8185fb810241116560ec8195f
[]
no_license
liudave/FoodVoting
d583b27b252659673252d2c191c106067474ac34
75cd39d6c4870b776f881728ea031d2ea67be4c3
refs/heads/master
2021-01-20T16:54:30.233633
2016-08-04T09:17:14
2016-08-04T09:17:14
64,920,399
0
0
null
null
null
null
UTF-8
Java
false
false
10,675
java
package com.sogou.map.android; import com.sogou.map.android.com.sogou.map.android.com.sogou.map.android.reponse.LoginInfo; import com.sogou.map.android.com.sogou.map.android.com.sogou.map.android.reponse.RestaurantResultEntity; import com.sogou.map.android.com.sogou.map.android.com.sogou.map.android.reponse.Upload; import com.sogou.map.android.com.sogou.map.android.com.sogou.map.android.reponse.VotingResultEntity; import com.sogou.map.android.com.sogou.map.android.model.Restaurant; import com.sogou.map.android.com.sogou.map.android.model.User; import com.sogou.map.android.com.sogou.map.android.util.NullUtils; import com.sogou.map.android.com.sogou.map.android.util.RestaurantManager; import com.sogou.map.android.com.sogou.map.android.util.UserManger; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.MarkerManager; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * Created by liudawei on 2016/7/29. */ @Path("/vote") public class Voting { public static List<User> userList=new ArrayList<User>(); public static List<Restaurant> restaurantList=new ArrayList<Restaurant>(); private static final Logger logger = LogManager.getLogger(Voting.class.getName()); @GET @Path("/login") // @Produces(MediaType.APPLICATION_JSON+";"+MediaType.CHARSET_PARAMETER+"=utf-8") @Produces(MediaType.APPLICATION_JSON) public ResponseDTO login(@QueryParam("name") String name,@QueryParam("pass") String pass,@QueryParam("deveid") String deveid){ LoginInfo loginInfo=outhUser(name,pass); ResponseDTO responseDTO; if(loginInfo!=null){ responseDTO=new ResponseDTO(0,"你成功了!",loginInfo); }else{ responseDTO=new ResponseDTO(1,"登录失败",loginInfo); } // return (new Gson()).toJson(responseDTO); logger.debug(new MarkerManager.Log4jMarker("login"),"name="+name); return responseDTO; } private LoginInfo outhUser(String name,String pwd){ LoginInfo loginInfo=null; if(userList!=null&&userList.size()>0){ for (User user:userList) { if(user.getName().equals(name)&&user.getPwd().equals(pwd)){ loginInfo=new LoginInfo(); loginInfo.setName(name); loginInfo.setReal_name(user.getReal_name()); loginInfo.setId(user.getId()); break; } } } return loginInfo; } @GET @Path("/uploadPicks") @Produces(MediaType.APPLICATION_JSON+";"+MediaType.CHARSET_PARAMETER+"=utf-8") public ResponseDTO uploadPicks(@QueryParam("name") String name,@QueryParam("dinner") String dinner,@QueryParam("launch") String launch,@QueryParam("deveid") String deveid){ logger.debug(new MarkerManager.Log4jMarker("uploadPicks"),"name="+name+";dinner="+dinner+";launch="+launch); if(isValidUser(name)){ Upload upload=new Upload(); upload.setName(name); ResponseDTO responseDTO=new ResponseDTO(0,"提交成功",upload); String validDinnerToSave=""; String validLaunchToSave=""; if(!dinnerVotingForUser.containsKey(name)){ upatePickLst(dinnerVotingResult,dinner); validDinnerToSave=dinner; } if(!launchVotingForUser.containsKey(name)){ upatePickLst(launchVotingResult,launch); validLaunchToSave=launch; } saveUserVotingInfo(name,validLaunchToSave,validDinnerToSave); if(NullUtils.isNull(validLaunchToSave)&&NullUtils.isNull(validDinnerToSave)){ return new ResponseDTO(2,"提交失败,重复提交",null); } return responseDTO; }else{ return new ResponseDTO(1,"提交失败",null); } } /** * 累加本地的投票结果数据 * @param pickMap * @param votings */ private void upatePickLst(HashMap<String,Integer> pickMap,String votings){ if(votings!=null){ String[] voteResults=votings.split(","); for(int i=0;i<voteResults.length;i++){ if(pickMap.containsKey(voteResults[i])){ int voteNo= pickMap.get(voteResults[i]); pickMap.put(voteResults[i],++voteNo); }else{ pickMap.put(voteResults[i],1); } } } } @GET @Path("/getRestaurants") @Produces(MediaType.APPLICATION_JSON) public ResponseDTO getRestaurants(@QueryParam("name") String name,@QueryParam("deveid") String deveid){ logger.debug(new MarkerManager.Log4jMarker("getRestaurants"),"name="+name); if(NullUtils.isNull(name)){ return new ResponseDTO(2,"缺少参数-name",""); } if(!isValidUser(name)){ return new ResponseDTO(1,"获取餐厅列表失败",""); } RestaurantResultEntity resultEntity=new RestaurantResultEntity(); resultEntity.setRestaurants(this.restaurantList); if(restaurantList!=null){ return new ResponseDTO(0,"获取餐厅列表成功",resultEntity); } return new ResponseDTO(1,"获取餐厅列表失败",resultEntity); } @GET @Path("/resume") @Produces(MediaType.APPLICATION_JSON) public ResponseDTO resumeVoting(@QueryParam("name") String name,@QueryParam("deveid") String deveid){ logger.debug(new MarkerManager.Log4jMarker("resume"),"name="+name); if(NullUtils.isNull(name)){ return new ResponseDTO(2,"缺少参数-name",""); } if(!isValidUser(name)){ return new ResponseDTO(1,"获取失败",""); } doResume(); if(restaurantList!=null){ return new ResponseDTO(0,"重新投票设置完成",null); } return new ResponseDTO(1,"重新投票设置失败",null); } private void doResume(){ dinnerVotingResult.clear(); launchVotingResult.clear(); launchVotingForUser.clear(); dinnerVotingForUser.clear(); } @GET @Path("/getCurrentPicks") @Produces(MediaType.APPLICATION_JSON+";"+MediaType.CHARSET_PARAMETER+"=utf-8") public ResponseDTO getCurrentPicks(@QueryParam("name") String name,@QueryParam("deveid") String deveid){ logger.debug(new MarkerManager.Log4jMarker("getCurrentPicks"),"name="+name); if(NullUtils.isNull(name)){ return new ResponseDTO(2,"缺少参数-name",""); } if(!isValidUser(name)){ return new ResponseDTO(1,"获取失败",""); } VotingResultEntity resultEntity=new VotingResultEntity(); resultEntity.setName(name); List<VotingResultEntity.RestaurantVotingRes> dinnerVotingResLst=new ArrayList<VotingResultEntity.RestaurantVotingRes>(); List<VotingResultEntity.RestaurantVotingRes> launchVotingResLst=new ArrayList<VotingResultEntity.RestaurantVotingRes>(); for (Restaurant restaurant:restaurantList) { VotingResultEntity.RestaurantVotingRes dinnerVotingRes=new VotingResultEntity.RestaurantVotingRes(); VotingResultEntity.RestaurantVotingRes launchVotingRes=new VotingResultEntity.RestaurantVotingRes(); dinnerVotingRes.setId(restaurant.getId()); dinnerVotingRes.setName(restaurant.getName()); launchVotingRes.setId(restaurant.getId()); launchVotingRes.setName(restaurant.getName()); if(dinnerVotingResult.containsKey(restaurant.getId())){ dinnerVotingRes.setVote_num(dinnerVotingResult.get(restaurant.getId())); } if(launchVotingResult.containsKey(restaurant.getId())){ launchVotingRes.setVote_num(launchVotingResult.get(restaurant.getId())); } dinnerVotingResLst.add(dinnerVotingRes); launchVotingResLst.add(launchVotingRes); } resultEntity.setDinnerVotingRes(dinnerVotingResLst); resultEntity.setLaunchVotingRes(launchVotingResLst); ResponseDTO responseDTO=new ResponseDTO(0,"获取成功",resultEntity); return responseDTO; } @GET @Path("/reloadUser") @Produces(MediaType.APPLICATION_JSON+";"+MediaType.CHARSET_PARAMETER+"=utf-8") public ResponseDTO reloadUser(@QueryParam("name") String name,@QueryParam("deveid") String deveid){ if(NullUtils.isNull(name)){ return new ResponseDTO(2,"缺少参数-name",""); } if(!isValidUser(name)){ return new ResponseDTO(1,"重新加载用户失败",""); } Voting.userList= UserManger.getInstance().loadUserInfo(); doResume(); return new ResponseDTO(0,"重新加载用户成功",""); } @GET @Path("/reloadRestaurant") @Produces(MediaType.APPLICATION_JSON+";"+MediaType.CHARSET_PARAMETER+"=utf-8") public ResponseDTO reloadRestaurant(@QueryParam("name") String name,@QueryParam("deveid") String deveid){ if(!isValidUser(name)){ return new ResponseDTO(1,"操作失败",""); } Voting.restaurantList= RestaurantManager.getInstance().loadRestaurantInfo(); doResume(); return new ResponseDTO(0,"重新加载餐厅成功",""); } private static HashMap<String,Integer> dinnerVotingResult =new HashMap<String, Integer>(); private static HashMap<String,Integer> launchVotingResult=new HashMap<String, Integer>(); /** * 是否是有效用户 * @return */ private boolean isValidUser(String name){ boolean ret=false; if(userList.size()>0&&name!=null){ for (User user:userList) { if(user.getName().equals(name)){ ret=true; break; } } } return ret; } private static HashMap<String,String> dinnerVotingForUser =new HashMap<String, String>(); private static HashMap<String,String> launchVotingForUser=new HashMap<String, String>(); private void saveUserVotingInfo(String name,String launchVoting,String dinnerVoting){ if(launchVoting!=null&&!launchVoting.equals("")) launchVotingForUser.put(name,launchVoting); if(dinnerVoting!=null&&!dinnerVoting.equals("")) dinnerVotingForUser.put(name,dinnerVoting); } }
74b676ce7a9e04fc318b7dc53e466ae285e1dd1b
4324852a7338c4ded0ca84e2178602cc9a461e12
/src/main/java/inz/controller/OrderController.java
b569e525ff4b5718a6e905108b2423cc4f143bc8
[ "Apache-2.0" ]
permissive
Shhad/rozproszone-bazki-rest
11ffd65aebc5059f03d3796b47a7f45197ae8a88
c2378a7ee019b95548cde16969ae9313828bb079
refs/heads/master
2022-11-30T18:40:23.057379
2019-12-05T08:52:23
2019-12-05T08:52:23
225,826,383
0
0
Apache-2.0
2022-11-24T07:43:24
2019-12-04T09:17:02
Java
UTF-8
Java
false
false
4,156
java
package inz.controller; import inz.model.Order; import inz.model.OrderProducts; import inz.repository.OrderProductsRepository; import inz.repository.OrderRepository; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("api/favourite") public class OrderController { @Autowired private OrderRepository favouriteRepository; @Autowired private OrderProductsRepository orderProductsRepository; @Autowired private OrderProductsRepository fpRepository; @PostMapping("/add") public ResponseEntity<?> addFavourite(@RequestBody Order order) { JSONObject response = new JSONObject(); try { order.setFavouriteId(new Integer((int)favouriteRepository.count() + 1)); favouriteRepository.saveAndFlush(order); response.put("status", "ok"); return new ResponseEntity<String>(response.toJSONString(), HttpStatus.OK); } catch(Exception e) { response.put("status","failure"); response.put("msg", e.getMessage()); return new ResponseEntity<String>(response.toJSONString(), HttpStatus.OK); } } @PostMapping("/add2") public ResponseEntity<?> addFavouriteProduct(@RequestBody String body) { JSONObject response = new JSONObject(); try { JSONParser parser = new JSONParser(); JSONObject json = (JSONObject) parser.parse(body); OrderProducts orderProducts = new OrderProducts(); orderProducts.setFavouriteId(new Integer(json.get("favouriteid").toString())); orderProducts.setFavouriteId(new Integer(json.get("productid").toString())); orderProducts.setId(new Integer((int) orderProductsRepository.count() + 1)); orderProductsRepository.saveAndFlush(orderProducts); response.put("status", "ok"); return new ResponseEntity<String>(response.toJSONString(), HttpStatus.OK); } catch(Exception e) { response.put("status","failure"); response.put("msg", e.getMessage()); return new ResponseEntity<String>(response.toJSONString(), HttpStatus.OK); } } @GetMapping("/favourites/{userid}") public ResponseEntity<?> getUserFavourites(@PathVariable("userid") int userid) { JSONObject response = new JSONObject(); try { response.put("status", "ok"); response.put("data", favouriteRepository.getUserFavourites(userid)); return new ResponseEntity<String>(response.toJSONString(), HttpStatus.OK); } catch(Exception e) { response.put("status","failure"); response.put("msg", e.getMessage()); return new ResponseEntity<String>(response.toJSONString(), HttpStatus.OK); } } @DeleteMapping("/delete/{favouriteid}/{productid}") public ResponseEntity<?> deleteProductFromFavourite(@PathVariable("favouriteid") int favouriteid, @PathVariable("productid") int productid) { JSONObject response = new JSONObject(); try { orderProductsRepository.deleteProduct(productid, favouriteid); response.put("status", "ok"); return new ResponseEntity<String>(response.toJSONString(), HttpStatus.OK); } catch(Exception e) { response.put("status","failure"); response.put("msg", e.getMessage()); return new ResponseEntity<String>(response.toJSONString(), HttpStatus.OK); } } }
a1505330206193bcdd564567053af1f0774c0a85
cd59aea73f9a73a798f75cb9d3345ed35f7caf78
/src/cs3500/music/modelUpdated/MusicEditorModel.java
02c49ad5234bcf547bc9fe0304faaa7cb55d577c
[]
no_license
ruisi-su/MusicEditor
3f7c0ff04c9de1d2474cea250ae18e9df148400d
fd055b23bfb4023de1419a9fcb16fdbeb717eea3
refs/heads/master
2021-05-30T13:27:58.256617
2016-02-11T00:44:42
2016-02-11T00:44:42
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,577
java
package cs3500.music.modelUpdated; import java.io.IOException; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collection; /** * Created by alexgomez on 11/1/15. */ public interface MusicEditorModel { /** * Representing a Pitch */ enum Pitch { C("C", 0), CSHARP("C#", 1), D("D", 2), DSHARP("D#", 3), E("E", 4), F("F", 5), FSHARP("F#", 6), G("G", 7), GSHARP("G#", 8), A("A", 9), ASHARP("A#", 10), B("B", 11); public String value; public int order; Pitch(String value, int order) { this.value = value; this.order = order; } } /** * Adds a unique note to the piece * * @param newNote the newNote you would like to add exists * @return true if it adds, return false if it doesn't */ boolean addNote(ANote newNote); /** * @param editedNote the note you want to edit * @param newPitch the new pitch for the note * @param newOctave the new octave for the note * @param newStart the new start for the note * @param newDuration the new duration for the note */ void edit(ANote editedNote, Pitch newPitch, int newOctave, int newStart, int newDuration, int newInstrument, int newVolume); /** * removes the note from the piece * * @param n the note you will remove * @throws IllegalArgumentException this note cannot be found */ void remove(ANote n); /** * Find the notes playing at this time * * @param time at what time are we looking for the notes * @return a collection of notes playing */ Collection<ANote> notesPlaying(int time); /** * @return the last beat where a note is played */ int getEnd(); /** * Gets the tempo * * @return the tempo */ int getTempo(); /** * Get the low note * * @param note high or low note? * @param desiredOctave in which octave? * @return the low note */ int getLowOrHighNote(String note, int desiredOctave); /** * @param maxOrMin is this a max or min * @return the max or min octave */ int getMinOrMaxOctave(String maxOrMin); /** * Gets the lines * * @return the lines */ AbstractMap<Integer, ArrayList<ANote>> getLines(); /** * prints the Notes in this octave */ void printNotes(int octave, int minNote, int maxNote, int time, Appendable output) throws IOException; /** * increments the current beat it is on */ void increment(); /** * Gives the current beat you are on * * @return the beat number */ int getBeat(); }
aeb79bba67130adc320aa2b7050cdd0d2a18a4c8
ad3ccd97f33dfca06fb12ca3bd1fba62729b9b11
/main/src/Logic/GameListener.java
4162fa82f7685b8e9c40a06b32155fdfe1bb6c38
[]
no_license
TalBarami/Reversi
441d899d80a628fc8cdcd4fb31dbb5cd68c7dd4b
e648f122e17bbba8310ce8fffaecd34fa0c3408d
refs/heads/master
2021-06-07T07:42:57.109530
2017-12-24T20:42:24
2017-12-24T20:42:24
59,599,577
0
0
null
null
null
null
UTF-8
Java
false
false
1,256
java
package Logic; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseListener; /** * Created by Tal on 24/05/2016. */ public class GameListener implements ActionListener, MouseListener { public GameBoard gameBoard; private int x; private int y; private JButton button; public GameListener(GameBoard game, int x, int y, JButton button){ this.gameBoard = game; this.x = x; this.y = y; this.button = button; } public void actionPerformed(ActionEvent e){ if(gameBoard.isValidMove(x, y)) gameBoard.playMove(x, y); } @Override public void mouseClicked(java.awt.event.MouseEvent arg0) {} @Override public void mouseEntered(java.awt.event.MouseEvent arg0) { if(gameBoard.isValidMove(x,y)) gameBoard.paintSequence(x, y, false); } @Override public void mouseExited(java.awt.event.MouseEvent arg0) { if(gameBoard.isValidMove(x,y)) gameBoard.paintSequence(x, y, true); } @Override public void mousePressed(java.awt.event.MouseEvent arg0) {} @Override public void mouseReleased(java.awt.event.MouseEvent arg0) {} }
673d6d3828afb9f47ff9d50cf24bf3cc616ee89f
651e7db4a33840f541326f9591ee79f839d8a0e3
/mall_0906_keywords/src/main/java/com/atguigu/util/MySolrUtil.java
518b9f0d0a602df6eaa6299cdf95ab2e1958d325
[]
no_license
Silence03/DianshangProject
3cadd201010495716deaf2c9adf4849471192193
5c198492ec336486d189c274bb085cac717e84e7
refs/heads/master
2021-05-10T08:52:26.293800
2018-02-26T12:45:03
2018-02-26T12:45:03
118,908,237
0
0
null
null
null
null
UTF-8
Java
false
false
1,162
java
package com.atguigu.util; import java.util.List; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.HttpSolrServer; import org.apache.solr.client.solrj.impl.XMLResponseParser; import org.apache.solr.client.solrj.response.QueryResponse; import com.atguigu.bean.KEYWORDS_T_MALL_SKU; public class MySolrUtil { public static HttpSolrServer getMySolr(String properties,String solr_url) { //获取solr客户端连接 HttpSolrServer solr = new HttpSolrServer(MyPropertiesUtil.getMyProperty(properties, solr_url)); solr.setParser(new XMLResponseParser()); return solr; } public static <T> List<T> getMySolrData(HttpSolrServer solr,Class<T> t,String keywords) { //设置solr SolrQuery solrQuery = new SolrQuery(); solrQuery.setQuery(keywords); solrQuery.setRows(50); QueryResponse query = null; try { query = solr.query(solrQuery); } catch (SolrServerException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<T> list_keywords = query.getBeans(t); return list_keywords; } }
[ "Administrator@SC-201801312220" ]
Administrator@SC-201801312220
16e25ec67f22ada62c8b3312bfb2e3abb04169ee
3fa5d21853ee1ca88daef58b5e1f93c99b502743
/src/main/java/Fruta.java
979f78404eb86258566d5d9b3f2e9c7810cbc318
[]
no_license
MiguelAngelderobles/TrabajoPNT
2f5fa492e390c2c863f49da0b0dadabcff4426df
70bd156c4709259b00a1af59e3f1f97a7bb4d79e
refs/heads/master
2020-05-22T20:34:03.717914
2019-05-17T04:41:52
2019-05-17T04:41:52
186,508,113
0
0
null
null
null
null
UTF-8
Java
false
false
253
java
public class Fruta extends Producto{ private Integer kilo; public Fruta(String nombre, Integer precio, Integer kilo) { super(nombre, precio); this.kilo = kilo; } public Integer getKilo() { return kilo; } }
a70aa24b02679c9125bca5bd50351a120ff394cd
1beeca547186f508e61d55b4b2ca59e20b851825
/src/co/edu/uniminuto/dyv/ParMasCercano.java
cedfdb39b21eb8321b3906a8312c288bdc1507c6
[]
no_license
DavidPineda/DisenoSoftware
0c92f4ad1dc46f98be957cd48fe94785b937b4a1
79228711d4e435fbbbc62fc685082ce88eac85d5
refs/heads/master
2021-01-19T17:47:32.973341
2015-06-04T04:43:00
2015-06-04T04:43:00
36,848,567
0
0
null
null
null
null
UTF-8
Java
false
false
6,066
java
/** * Clase que evalua la distancia de puntos en el plano para retornar el par mas * cercano, por medio de la tecnica de divide y vencerar * * Problema: Dado un conjunto de puntos en el plano cartesiano (x,y) el problema * es encontrar aquellos dos puntos que se encuentran más cerca el uno del otro. */ package co.edu.uniminuto.dyv; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; public class ParMasCercano { /** * Funcion publica encargada llamar el metodo de ordenacion del array y * luego llamar al proceso principal * * @param puntos Array con todos los puntos cargados * @return Retorna mensaje indicando cual fue el par mas cercano encontrado */ public String divideYvenceras(Punto[] puntos) { // Se ordena el array de acuerdo a la cordenada X Arrays.sort(puntos, new OrdenPointX()); // Se obtiene el par de puntos con menor distancia ParPuntos dmin = divideYvenceras(puntos, 0, puntos.length - 1); pintarPuntos(puntos); return "El par de puntos mas cercano es: " + dmin.toString(); } /** * Funcion recursiva en la cual se aplica la tecnica divide y venceras * * @param p Arreglo con todos los puntos ingresados * @param inf Parte inferior del array(Desde donde empezar) * @param sup Parte Superior del array(Hasta donde ir) * @return El par de puntos mas cercano */ private ParPuntos divideYvenceras(Punto[] p, int inf, int sup) { if ((sup - inf) <= 2) { return fuerzaBruta(p, inf, sup); } int medio = (inf + sup) / 2; double xMed = p[medio].getX(); // parIzquierda Representa el par de puntos con menor distancia de la parte izquierda de la division ParPuntos parIzquierda = divideYvenceras(p, inf, medio); // Evalua la parte izquierda // parDerecha Representa el par de puntos con menor distancia de la parte dercha de la division ParPuntos parDerecha = divideYvenceras(p, medio + 1, sup); // Evalua la parte derecha // parResult Representa el par de puntos mas cercano entre el par izquierdo y el derecho ParPuntos parResult = minDistancia(parIzquierda, parDerecha); // Se buscan los puntos que quedaron separados por la division, y que pudene estar mas cerca que // los que quedaron a cada lado de la division Punto[] p1 = Arrays.copyOfRange(p, inf, sup + 1); // Se hace un array con la cantidad de puntos evaluados ArrayList<Punto> tempList = new ArrayList<>(); // Lista de puntos temporal en la que se almacenan los que podrian ser menores Arrays.sort(p1, new OrdenPointY()); // Se ordena el nuevo array por la posicion Y for (int i = inf; i < p1.length; i++) { if (Math.abs(xMed - ((Punto) p1[i]).getX()) < parResult.distancia()) { tempList.add(p1[i]); } } for (int i = 0; i < tempList.size() - 1; i++) { Punto pTemp1 = tempList.get(i); for (int j = i + 1; j < tempList.size(); j++) { Punto pTemp2 = tempList.get(j); ParPuntos parTemp = new ParPuntos(pTemp1, pTemp2); if (parTemp.distancia() < parResult.distancia()) // Si el punto es menor se actualiza el resultado a retornar { parResult = parTemp; } } } return parResult; } /** * Valida la distancia que existe entre dos pares para retornar el de menor * distancia * * @param parIzquierda par de puntos izquierdo * @param parDerecha par de puntos derecho * @return retorna el par de puntos cuya distancia sea menor */ ParPuntos minDistancia(ParPuntos parIzquierda, ParPuntos parDerecha) { return (parIzquierda.distancia() - parDerecha.distancia()) < 0 ? parIzquierda : parDerecha; } /** * Algortimo Voraz para encontrar la menor distancia entre dos puntos * * @param p Arreglo con los puntos * @param inf Posicion inferior de donde inicar el recorrido * @param sup Posicion final hasta donde terminar el recorrido * @return Par de puntos con la distancia mas cercana */ private ParPuntos fuerzaBruta(Punto[] p, int inf, int sup) { int rango = sup - inf; if (rango < 1) { return null; } ParPuntos parOrigen = new ParPuntos(p[inf], p[inf + 1]); if (rango > 1) { for (int i = inf; i < sup; i++) { for (int j = i + 1; j < sup + 1; j++) { ParPuntos parComparacion = new ParPuntos(p[i], p[j]); if (parComparacion.distancia() < parOrigen.distancia()) { parOrigen = parComparacion; } } } } return parOrigen; } private void pintarPuntos(Punto[] puntos){ for(Punto p: puntos){ System.out.println(p.toString()); } } /** * Clase que implementa la interfaz Comparator para realizar la ordenacion * del array por la posicion x del punto */ class OrdenPointX implements Comparator<Punto> { @Override public int compare(Punto punto1, Punto punto2) { if (punto1.getX() < punto2.getX()) { return -1; } if (punto1.getX() > punto2.getX()) { return 1; } return 0; } } class OrdenPointY implements Comparator<Punto> { @Override public int compare(Punto punto1, Punto punto2) { if (punto1.getY() < punto2.getY()) { return -1; } if (punto1.getY() > punto2.getY()) { return 1; } return 0; } } }
[ "david@david-Inspiron-5547" ]
david@david-Inspiron-5547
3f1c35a5e2d4ca99d4cface2b02d65c908d843a6
554a5dd12e6157b729d4da4f6b53a133319e4b4b
/iHappy/src/com/xiaohan/ihappy/helpers/lastfm/ItemFactory.java
ba841892bec3916c0b8d3233bccd54ea46e391a0
[]
no_license
2014-1/001
166728a516973258f736192a46235643d9504031
abe2e94a9b66c3760240628b86d840ef2dfb1e1d
refs/heads/master
2020-05-25T12:22:43.365771
2014-06-09T13:24:49
2014-06-09T13:24:49
16,660,737
1
1
null
null
null
null
UTF-8
Java
false
false
2,094
java
/* * Copyright (c) 2012, the Last.fm Java Project and Committers * All rights reserved. * * Redistribution and use of this software in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the * following disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the * following disclaimer in the documentation and/or other * materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.xiaohan.ihappy.helpers.lastfm; import com.xiaohan.ihappy.helpers.DomElement; /** * An <code>ItemFactory</code> can be used to instantiate a value object - such as Artist, Album, Track, Tag - from an XML element. Use the * {@link ItemFactoryBuilder} to obtain item factories for a specific type. * * @author Janni Kovacs * @see com.xiaohan.ihappy.helpers.lastfm.ItemFactoryBuilder * @see ResponseBuilder */ interface ItemFactory<T> { /** * Create a new instance of the type <code>T</code>, based on the passed {@link DomElement}. * * @param element the XML element * @return a new object */ public T createItemFromElement(DomElement element); }
183423f3315bdee3eddc4daf6aa5fb2af32bb254
41ae993d4698e3f692857f4b1107dcce87914014
/app/src/main/java/com/example/ordersystem/AdminLookServerPwdDialog.java
184145523fc7bdf3087d381a9675964942b17650
[]
no_license
yushihai/OrderSystem
dbe64816eeb1d652b36b81783a48e3ba8baab2f1
19a0d1b0e971a608d8d12a1c29f0542dd7da88f7
refs/heads/master
2021-05-17T23:25:33.551155
2020-03-29T10:23:19
2020-03-29T10:23:19
250,999,718
0
0
null
null
null
null
UTF-8
Java
false
false
2,980
java
package com.example.ordersystem; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Build; import android.os.Bundle; import android.text.TextUtils; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class AdminLookServerPwdDialog extends Dialog implements View.OnClickListener { EditText lookserverpwd_account; SQLiteDatabase db; AdminLookServerPwdResultDialog adminLookServerPwdResultDialog; public AdminLookServerPwdDialog(Context context) { super(context); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.admin_lookserverpwd_dialog); setCanceledOnTouchOutside(false); setCancelable(false); db=PublicData.dbHelper.getWritableDatabase(); lookserverpwd_account=findViewById(R.id.lookserverpwd_account); Button lookserverpwd_cancel=findViewById(R.id.lookserverpwd_cancel); Button lookserverpwd_submit=findViewById(R.id.lookserverpwd_submit); lookserverpwd_cancel.setOnClickListener(this); lookserverpwd_submit.setOnClickListener(this); } protected void setAdminLookServerPwdResultDialog(AdminLookServerPwdResultDialog dialog){ adminLookServerPwdResultDialog=dialog; } @Override public void onClick(View v){ switch (v.getId()){ case R.id.lookserverpwd_cancel: dismiss(); break; case R.id.lookserverpwd_submit: if(TextUtils.isEmpty(lookserverpwd_account.getText())) Toast.makeText(getContext(),"账号不能为空",Toast.LENGTH_SHORT).show(); else{ Cursor cursor=db.query("Server",null,"account=?",new String[]{lookserverpwd_account.getText().toString().trim()},null,null,null); if(cursor.moveToFirst()) { String account=cursor.getString(cursor.getColumnIndex("account")); String pwd=cursor.getString(cursor.getColumnIndex("password")); if(Build.VERSION.SDK_INT>=21) adminLookServerPwdResultDialog.create(); adminLookServerPwdResultDialog.setAccount(account); adminLookServerPwdResultDialog.setPwd(pwd); adminLookServerPwdResultDialog.show(); dismiss(); } else { Toast.makeText(getContext(), "没有该服务员!", Toast.LENGTH_SHORT).show(); lookserverpwd_account.setText(""); } } break; } } }
d02cabed745a4ab10200c845d011a171b9e6c55f
e80b4403081d6fbd94a9272a3b6b309f9e94a147
/app/src/main/java/org/tsofen/ourstory/UserModel/RegistrationPage2.java
4ee3685ed9958b49ba5db21518abeaf140dc4a6e
[]
no_license
huda163/OurStory
c9235f6121321a04a66d71ab9dbd7cb8d661c906
63f645453661941a050bfe3d6c0fdbf1b547b160
refs/heads/master
2020-07-16T13:17:22.602142
2019-09-01T17:55:08
2019-09-01T17:55:08
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,765
java
package org.tsofen.ourstory.UserModel; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.EditText; import android.widget.RadioButton; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.DialogFragment; import com.example.ourstory.R; public class RegistrationPage2 extends AppCompatActivity { public String emailString; public String firstNameString; public String lastNameString; public String passwordString; public String stateString; public String cityString; public String dateOfBirth; public String dateOfSignIn; public String dateOfLastSignIn; public String profilePicture; public String gender; //will be later used as date format. // public Date dateOfBirth; // public Date dateOfSignIn; // public Date dateOfLastSignIn; public EditText EditText6; public EditText EditText7; public EditText EditText8; public EditText DateOfB; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_registration_page2); Intent currIntent = getIntent(); emailString = currIntent.getStringExtra("email"); firstNameString = currIntent.getStringExtra("first_name"); lastNameString = currIntent.getStringExtra("last_name"); passwordString = currIntent.getStringExtra("password"); DateOfB=findViewById(R.id.showDate); Log.d("log4", "values received from registrationPage1:" + emailString + " " + firstNameString + " " + lastNameString + " " + passwordString); } public void showDatePicker(View view) { DialogFragment newFragment = new DatePickerFragment(); newFragment.show(getSupportFragmentManager(),"datePicker"); } public void processDatePickerResult(int year, int month, int day) { String month_string = Integer.toString(month+1); String day_string = Integer.toString(day); String year_string = Integer.toString(year); String dateString = (month_string + "/" + day_string + "/" + year_string); dateOfBirth = dateString; DateOfB.setText(dateOfBirth); } public void Go2RegistrationPage3andSave(View view) { Intent regIntent3 = new Intent (this, LogIn.class); EditText6 = (EditText)findViewById(R.id.showState); EditText7 = (EditText)findViewById(R.id.showCity); stateString = EditText6.getText().toString(); cityString = EditText7.getText().toString(); regIntent3.putExtra("email", emailString); regIntent3.putExtra("first_name", firstNameString ); regIntent3.putExtra("last_name", lastNameString ); regIntent3.putExtra("password", passwordString); regIntent3.putExtra("state", stateString); regIntent3.putExtra("city", cityString ); regIntent3.putExtra("dateOfBirth", dateOfBirth ); regIntent3.putExtra("gender",gender); Log.d("log-saved", "values sent to registrationPage3:" + emailString + " " + firstNameString + " " + lastNameString + " " + passwordString + " " + stateString + " " + cityString + " " + dateOfBirth+" "+gender); startActivity(regIntent3); } public void Go2RegistrationPage3andDontSave(View view) { Intent regIntent3 = new Intent (this, LogIn.class); regIntent3.putExtra("email", emailString); regIntent3.putExtra("first_name", firstNameString ); regIntent3.putExtra("last_name", lastNameString ); regIntent3.putExtra("password", passwordString); Log.d("log-not saved", "values sent to registrationPage3:" + emailString + " " + firstNameString + " " + lastNameString + " " +passwordString + " "); startActivity(regIntent3); } public void UploadPicture(View view) { //still null } public void closeActivity(View view) { Intent back=new Intent(this,LogIn.class); startActivity(back); } public void onRadioButtonClicked(View view) { // Is the button now checked? boolean checked = ((RadioButton) view).isChecked(); // Check which radio button was clicked. switch (view.getId()) { case R.id.MaleRB: if (checked) gender="Male"; break; case R.id.FemaleRB: if (checked) gender="Female"; break; default: // Do nothing. break; } } }
ea5d904f1d5f2aa961f12b23b8e193a8f9b21157
dd0d56024cda671b04035062bc8203d3e851860c
/app/src/main/java/com/egova/eagleyes/adapter/PersonSearchAdapter.java
d67833f78f47c6960fd4d4b2c10a35d3295abe80
[]
no_license
leegle/Eagleyes
987b9870ba7d387754e7700cf7f79bb471614e37
bf698047eb6ea5e540f598490d73d0a12773a204
refs/heads/master
2020-12-04T01:30:16.959662
2019-04-12T09:17:16
2019-04-12T09:17:16
null
0
0
null
null
null
null
UTF-8
Java
false
false
991
java
package com.egova.eagleyes.adapter; import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseViewHolder; import com.egova.eagleyes.R; import com.egova.eagleyes.model.respose.PersonInfo; import java.util.List; import androidx.annotation.Nullable; public class PersonSearchAdapter extends BaseQuickAdapter<PersonInfo, BaseViewHolder> { public PersonSearchAdapter(int layoutResId, @Nullable List<PersonInfo> data) { super(layoutResId, data); } @Override protected void convert(BaseViewHolder helper, PersonInfo item) { int position = helper.getLayoutPosition(); if (position == 0 || !mData.get(position - 1).getFirstLetter().equals(item.getFirstLetter())) { helper.setText(R.id.letter, item.getFirstLetter()); helper.setVisible(R.id.letter, true); } else { helper.setVisible(R.id.letter, false); } helper.setText(R.id.name, item.getName()); } }
124eae0f98855f316148bb9b9c868fdda76ef057
de26c0eba14a4e4e51638a52ae210dbd292c8161
/hrTask/src/java/org/infotechdept/hr/task/model/AdcShiftMeals.java
843d208530bbd8e1aafb377f1053c60c92878244
[]
no_license
xuyanatsyxl/hrTask
29bbcce1523fe58849537eed4526c96a257aa6db
ed383df4840e4367d6e4e4b0c925c1f2beb0332b
refs/heads/master
2021-01-09T21:52:11.276029
2015-12-18T09:20:13
2015-12-18T09:20:13
46,342,178
0
0
null
null
null
null
UTF-8
Java
false
false
1,437
java
package org.infotechdept.hr.task.model; import java.util.Date; public class AdcShiftMeals { private Long id; private Date mealsDate; private Long deptid; private Long empid; private String roomId; private String mealsType; private Integer mealsTimes; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Date getMealsDate() { return mealsDate; } public void setMealsDate(Date mealsDate) { this.mealsDate = mealsDate; } public Long getDeptid() { return deptid; } public void setDeptid(Long deptid) { this.deptid = deptid; } public Long getEmpid() { return empid; } public void setEmpid(Long empid) { this.empid = empid; } public String getRoomId() { return roomId; } public void setRoomId(String roomId) { this.roomId = roomId == null ? null : roomId.trim(); } public String getMealsType() { return mealsType; } public void setMealsType(String mealsType) { this.mealsType = mealsType == null ? null : mealsType.trim(); } public Integer getMealsTimes() { return mealsTimes; } public void setMealsTimes(Integer mealsTimes) { this.mealsTimes = mealsTimes; } }
0a98d6a1a0c31e200225dd5d9514671916e1b41c
e96b0019599c7d410a896a20b006a07648172622
/src/main/java/com/iqmsoft/mongo/solr/controller/SpringMongoSolrController.java
06ffee11a7050a772cb2c99c8d181f1782a1b8a7
[]
no_license
Murugar/SpringBootMongoSolr
a94aedd83ceb0a1074db173c2a001f1a658dccac
820c0366f3bca75bec427468b678b0b0173a4a98
refs/heads/master
2021-01-22T05:24:05.506251
2017-02-11T14:17:02
2017-02-11T14:17:02
81,657,194
0
0
null
null
null
null
UTF-8
Java
false
false
1,748
java
package com.iqmsoft.mongo.solr.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; import com.iqmsoft.mongo.solr.mongo.model.TestDocument; import com.iqmsoft.mongo.solr.service.TestDocumentService; import com.iqmsoft.mongo.solr.solr.model.TestSolrDocument; @RestController @SuppressWarnings("all") public class SpringMongoSolrController { @Autowired private TestDocumentService testDocumentService; @RequestMapping( path = "createDocument", method = RequestMethod.POST, consumes = {"application/x-www-form-urlencoded;charset=UTF-8"}, produces = "application/json;charset=UTF-8") @ResponseBody public TestSolrDocument createDocument(TestDocument document) { return testDocumentService.saveMongoAndIndex(document); } @RequestMapping(path = "clearAll", method = RequestMethod.GET) public String clearAll() { testDocumentService.clear(); return "Clear All Success!"; } @RequestMapping(path = "indexMongo", method = RequestMethod.GET) public String indexMongo() { testDocumentService.indexMongo(); return "Index Mongo Success!"; } @RequestMapping(path = "createDocument", method = RequestMethod.GET) public ModelAndView newDocument() { ModelAndView view = new ModelAndView("/createDocumentForm"); view.addObject(new TestDocument()); return view; } }
3cb7eca25f219b8ac2971d6d0b790f37e7f45c01
67c17ceb882006cf46ee1b8dd3598bfdaa1bd113
/jagathkalyani/src/Interfaceprograms/Example7.java
c229bf22e7ea75337fcf879cc5cd4d1743911f52
[]
no_license
TechieFrogs-Warriors/JavaBasics
f235205bcbe557d89409bf6cb74bae1c5279ebcd
79a83f8db96fc9f57da872a0571497df4551d01b
refs/heads/main
2023-05-04T15:43:41.130753
2021-05-17T07:41:45
2021-05-17T07:41:45
321,665,844
1
0
null
2020-12-16T04:43:34
2020-12-15T12:47:49
null
UTF-8
Java
false
false
438
java
package Interfaceprograms; public class Example7 { } interface A{ public void x(); } interface B{ public int x(); } class C implements A,B{ public void x(){ //error--------two interfaces have same method name with diff return types } public int x(){ } public static void main(String[] args) { // System.out.println(x); System.out.println(A.x); System.out.println(B.x); }
3f1577294980849a35e701762159bfceed4d3520
260fd57608a85b564bb8bbb1e2b2f7efc9d91b5d
/pv-report/src/main/java/cn/medsci/pv/report/service/impl/IRolesServiceImpl.java
e5b75229d6cd267a69dd37d131498fe6ab635c6e
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
msnetc/pv
25ebbb500d2cbe7854170dff2195531035c3e15a
0e99bb6338b546a776cfad21570e7269c960fb7a
refs/heads/master
2021-04-06T11:13:16.477010
2018-03-16T07:23:45
2018-03-16T07:23:45
125,312,872
0
0
null
null
null
null
UTF-8
Java
false
false
487
java
package cn.medsci.pv.report.service.impl; import cn.medsci.pv.report.entity.Roles; import cn.medsci.pv.report.mapper.RolesMapper; import cn.medsci.pv.report.service.IRolesService; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import org.springframework.stereotype.Service; /** * <p> * 服务实现类 * </p> * * @author wenhao.wang * @since 2018-03-16 */ @Service public class IRolesServiceImpl extends ServiceImpl<RolesMapper, Roles> implements IRolesService { }
fc0b077bbf5b9cd3583a02ddece08b54fc9aaf50
55413f8c3542bedf3fc2bb79bbf878e058663bac
/src/main/java/com/hackerrank/ClimbingTheLeaderboard.java
b72eaea7ee765e400bba32b5420ccedc5284e8ec
[ "MIT" ]
permissive
aucd29/algs-progfun
73ca37a1fb63dca662b81224c81272238449e6e2
a89b0d332a3d4a257618e9ae6c7f898cb1695246
refs/heads/master
2021-08-28T00:49:18.192680
2017-12-10T23:18:36
2017-12-10T23:18:36
null
0
0
null
null
null
null
UTF-8
Java
false
false
809
java
package com.hackerrank; import java.util.Scanner; import java.util.Stack; public class ClimbingTheLeaderboard { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); Stack<Integer> stack = new Stack<>(); for (int i = 0; i < n; i++) { int score = in.nextInt(); if (i == 0 || stack.peek() != score) { stack.push(score); } } int m = in.nextInt(); int[] alice = new int[m]; for (int i = 0; i < m; i++) { alice[i] = in.nextInt(); while (!stack.empty() && stack.peek() <= alice[i]) { stack.pop(); } System.out.println(stack.isEmpty() ? "1" : stack.size() + 1); } } }
370a7f77e4746d955d743c6aef7d7cd80ed2e1b9
c3a7fb2b30deb69c3d0935c6b1dfe822d7d19095
/src/main/java/org/dstadler/jgit/api/ResolveRef.java
026b2b240f38c0af9ba2ae4dcf930b13d8af74af
[ "Apache-2.0" ]
permissive
choffmeister/jgit-cookbook
2c1e65dff94006a38daeef0b3410adf86248d9e1
182bb1cc6ca807d9065a29dd967bdf389809914b
refs/heads/master
2023-08-30T12:45:33.501982
2014-09-11T19:55:47
2014-09-11T19:56:04
24,249,150
2
0
null
null
null
null
UTF-8
Java
false
false
1,429
java
package org.dstadler.jgit.api; /* Copyright 2013, 2014 Dominik Stadler 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. */ import java.io.IOException; import org.dstadler.jgit.helper.CookbookHelper; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; /** * Simple snippet which shows how to retrieve an ObjectId for some name. */ public class ResolveRef { public static void main(String[] args) throws IOException { Repository repository = CookbookHelper.openJGitCookbookRepository(); // basic syntax is similar to getRef() ObjectId id = repository.resolve("HEAD"); System.out.println("ObjectId of HEAD: " + id); // however resolve() supports almost all of the git-syntax, where getRef() only works on names id = repository.resolve("HEAD^1"); System.out.println("ObjectId of HEAD: " + id); repository.close(); } }
4b9ba1e2c709d6f8c85c698fb87fe79c00e1cabb
93cbfb63098de48ab21e1e8db978adc69d09e9e3
/org/college/College.java
bd3a40b5da7c2e999a1f668413786abd6f9c42a6
[]
no_license
sakthepriyaRK/week3-day1
dc98dd00753de77b99681b01d2c7f24626e9e0fc
88d93fa92729f8c257f4813f7a0cd9ba4f09d013
refs/heads/main
2023-09-06T06:56:43.073512
2021-11-13T16:42:45
2021-11-13T16:42:45
427,718,072
0
0
null
null
null
null
UTF-8
Java
false
false
334
java
package week3.day1.org.college; public class College { public void collegeName() { System.out.println("college name:"+ "Anna University"); } public void collegecode() { System.out.println("college code:"+ "100107036"); } public void collegerank() { System.out.println("college Rank:"+ "Rank 1"); } }
dd298d80fc7667e071a7b040ebeac36230c360a7
38a49a2882cfc942ffcf1dbbd4d241bc264e193d
/src/etc/Dependencies.java
aac4edb63c1753397f1322bdcc3b9eed50e32916
[ "MIT" ]
permissive
mccccopley/java-boggle-solver-etc
0778c674aaeea2a8498f7943510a006c6bb87775
e6c84ef469db96d66d6fb5a458bc7436eedac7d2
refs/heads/master
2021-01-11T14:50:51.372075
2017-02-07T20:44:54
2017-02-07T20:44:54
80,231,773
0
0
null
null
null
null
UTF-8
Java
false
false
1,711
java
package etc; /** * Created by mccccopley on 1/19/2017. */ import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; public class Dependencies { public static class Dependency { int id; int dependsOnId; public Dependency(int id, int dependsOnId) { this.id = id; this.dependsOnId = dependsOnId; } } public static List<Integer> GetDependencyOrder(int[] ids, Dependency[] dependencies) { HashMap<Integer, List<Integer>> dependents = new HashMap<>(); HashMap<Integer, Integer> dependencyCounts = new HashMap<>(); LinkedList<Integer> order = new LinkedList<>(); for (int id : ids) { dependencyCounts.put(id, 0); dependents.put(id, new LinkedList<>()); } for (Dependency dependency : dependencies) { dependencyCounts.put(dependency.id, dependencyCounts.get(dependency.id) + 1); dependents.get(dependency.dependsOnId).add(dependency.id); } while (order.size() < ids.length) { boolean wereIdsAdded = false; for (int id : dependencyCounts.keySet()) { if (dependencyCounts.get(id) == 0) { wereIdsAdded = true; order.add(id); dependencyCounts.put(id, -1); for (int dependent : dependents.get(id)) { dependencyCounts.put(dependent, dependencyCounts.get(dependent) - 1); } } } if (!wereIdsAdded) { return null; } } return order; } }
c3fb4dfba8c18031b6dfac0365a886fa51ef2050
ab6dcb8a454e2d9748d605ea6f83d438f94a17c8
/app/src/main/java/com/example/edut/qrscanner/LocationListActivity.java
394cc6e59d66f02cc2640bdf144aad3b84488ed8
[]
no_license
omeredut/FindLocation
63b8d1ef6543480a2070ce4e353ed1e410655772
1c359e0339828bb1a3efdb4b17b3bdb706de490f
refs/heads/master
2021-01-25T05:56:27.427736
2017-02-02T08:57:42
2017-02-02T08:57:42
80,705,314
0
0
null
null
null
null
UTF-8
Java
false
false
2,662
java
package com.example.edut.qrscanner; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.DragEvent; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import static com.example.edut.qrscanner.MainActivity.HIGHT_INDEX; import static com.example.edut.qrscanner.MainActivity.SAVED; import static com.example.edut.qrscanner.MainActivity.SHOW_LOCATION; import static com.example.edut.qrscanner.MainActivity.TYPE; import static com.example.edut.qrscanner.MainActivity.sharedPreferencesLocations; public class LocationListActivity extends Activity { public static final String NULL = "NULL"; private String[] locationsList; private String location; ListView listViewLocations; ArrayAdapter listAdapter; int index; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_location_list); index = sharedPreferencesLocations.getInt(HIGHT_INDEX, 0); listViewLocations = (ListView) findViewById(R.id.list_view_locations); locationsList = new String[index]; for (int i = 0; i < index; i++) { location = sharedPreferencesLocations.getString(String.valueOf(i), NULL); locationsList[i] = location; } listAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, locationsList); listViewLocations.setAdapter(listAdapter); listViewLocations.setOnItemClickListener(showLocation); listViewLocations.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(LocationListActivity.this, "long item click", Toast.LENGTH_SHORT).show(); //TODO: option to remove location return false; } }); } AdapterView.OnItemClickListener showLocation = new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intentShowSaveLocation = new Intent(LocationListActivity.this, MapsActivity.class); String savedLocation = locationsList[position]; intentShowSaveLocation.putExtra(TYPE, SAVED); intentShowSaveLocation.putExtra(SHOW_LOCATION, savedLocation); startActivity(intentShowSaveLocation); } }; }
c7745d76b4d5afbac0eb67a03d2deb68600db989
8054d4f937961027e936ca8cc9cb30236ab93009
/src/main/java/com/umanizales/apibatallanaval/model/dto/CoordenadaDTO.java
7ef1d75634580cf084686c9afac234bae5695cc2
[]
no_license
CatalinaGomezJ/ApiBatallaNaval
74f526efb8c4fb217aa58c1e28c4d70b3bbd32ba
2735ba5c10b12a1d5a89cf84cb0306d97eaa36bd
refs/heads/master
2023-05-09T23:53:47.752545
2021-06-03T19:16:06
2021-06-03T19:16:06
371,487,573
0
0
null
null
null
null
UTF-8
Java
false
false
317
java
package com.umanizales.apibatallanaval.model.dto; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import java.io.Serializable; @Getter @Setter @AllArgsConstructor public class CoordenadaDTO implements Serializable { private int x; private int y; private boolean estado; }
2bf064a2c9008c707e77b72e7fe2a435e318198e
7f147d20461b3239051c0196d13e1dae3a978480
/src/gourmet/Table.java
07735ab0d9ca9d575700d1828096a0cca8b738e9
[]
no_license
10Kbis/Gourmet
a0d34c2076cf89644aac6d87c393c9d1e0f5ff0d
3a15c901ae8f322b541ec5d99bf232361d6750f3
refs/heads/master
2020-03-19T01:47:46.152663
2018-06-07T09:00:21
2018-06-07T09:00:21
135,572,901
0
0
null
null
null
null
UTF-8
Java
false
false
2,660
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 gourmet; import java.util.ArrayList; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; /** * * @author user */ public class Table { private String num; private ArrayList<CommandePlat> commandes = new ArrayList<>(); private ArrayList<CommandePlat> commandes_envoyer = new ArrayList<>(); private int max_couverts = 0; private int couverts = 0; private Boolean addition_payee = false; private String nom_serveur; public Table() { } public Table(String num, int max_couverts) { this.num = num; this.max_couverts = max_couverts; } public String getNumero() { return num; } @XmlElement public void setNumero(String num) { this.num = num; } public int getMaxCouverts() { return max_couverts; } @XmlElement public void setMaxCouverts(int max_couverts) { this.max_couverts = max_couverts; } public int getCouverts() { return couverts; } @XmlElement public void setCouverts(int quantite) { this.couverts = quantite; } public void trySetCouverts(int quantite) throws TooManyCoversException { if (quantite > getMaxCouverts()) { throw new TooManyCoversException(); } this.couverts = quantite; } public Boolean getAdditionPayee() { return addition_payee; } @XmlElement public void setAdditionPayee(Boolean addition_payee) { this.addition_payee = addition_payee; } public ArrayList<CommandePlat> getCommandes() { return commandes; } @XmlElementWrapper @XmlElement(name = "commande") public void setCommandes(ArrayList<CommandePlat> commandes) { this.commandes = commandes; } public void ajoutCommande(CommandePlat commande) { commandes.add(commande); } public ArrayList<CommandePlat> getCommandesAEnvoyer() { return commandes_envoyer; } @XmlElementWrapper @XmlElement(name = "commandeEnvoyer") public void setCommandesAEnvoyer(ArrayList<CommandePlat> commandes) { commandes_envoyer = commandes; } public void ajoutCommandeAEnvoyer(CommandePlat commande) { commandes_envoyer.add(commande); } public void envoyerCommandes() { commandes_envoyer.clear(); } }
[ "user@work" ]
user@work
2a72cb772edf97fb8be6f6a379b7a2842bcb1f29
498dd2daff74247c83a698135e4fe728de93585a
/clients/google-api-services-bigquery/v2/1.29.2/com/google/api/services/bigquery/model/JobConfigurationLoad.java
1ec059aecf7e93a3f983edfc5792c9f26af58770
[ "Apache-2.0" ]
permissive
googleapis/google-api-java-client-services
0e2d474988d9b692c2404d444c248ea57b1f453d
eb359dd2ad555431c5bc7deaeafca11af08eee43
refs/heads/main
2023-08-23T00:17:30.601626
2023-08-20T02:16:12
2023-08-20T02:16:12
147,399,159
545
390
Apache-2.0
2023-09-14T02:14:14
2018-09-04T19:11:33
null
UTF-8
Java
false
false
39,550
java
/* * 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. */ /* * This code was generated by https://github.com/googleapis/google-api-java-client-services/ * Modify at your own risk. */ package com.google.api.services.bigquery.model; /** * Model definition for JobConfigurationLoad. * * <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is * transmitted over HTTP when working with the BigQuery API. For a detailed explanation see: * <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a> * </p> * * @author Google, Inc. */ @SuppressWarnings("javadoc") public final class JobConfigurationLoad extends com.google.api.client.json.GenericJson { /** * [Optional] Accept rows that are missing trailing optional columns. The missing values are * treated as nulls. If false, records with missing trailing columns are treated as bad records, * and if there are too many bad records, an invalid error is returned in the job result. The * default value is false. Only applicable to CSV, ignored for other formats. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.Boolean allowJaggedRows; /** * Indicates if BigQuery should allow quoted data sections that contain newline characters in a * CSV file. The default value is false. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.Boolean allowQuotedNewlines; /** * [Optional] Indicates if we should automatically infer the options and schema for CSV and JSON * sources. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.Boolean autodetect; /** * [Beta] Clustering specification for the destination table. Must be specified with time-based * partitioning, data in the table will be first partitioned and subsequently clustered. * The value may be {@code null}. */ @com.google.api.client.util.Key private Clustering clustering; /** * [Optional] Specifies whether the job is allowed to create new tables. The following values are * supported: CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. * CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in * the job result. The default value is CREATE_IF_NEEDED. Creation, truncation and append actions * occur as one atomic update upon job completion. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.String createDisposition; /** * Custom encryption configuration (e.g., Cloud KMS keys). * The value may be {@code null}. */ @com.google.api.client.util.Key private EncryptionConfiguration destinationEncryptionConfiguration; /** * [Required] The destination table to load the data into. * The value may be {@code null}. */ @com.google.api.client.util.Key private TableReference destinationTable; /** * [Beta] [Optional] Properties with which to create the destination table if it is new. * The value may be {@code null}. */ @com.google.api.client.util.Key private DestinationTableProperties destinationTableProperties; /** * [Optional] The character encoding of the data. The supported values are UTF-8 or ISO-8859-1. * The default value is UTF-8. BigQuery decodes the data after the raw, binary data has been split * using the values of the quote and fieldDelimiter properties. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.String encoding; /** * [Optional] The separator for fields in a CSV file. The separator can be any ISO-8859-1 single- * byte character. To use a character in the range 128-255, you must encode the character as UTF8. * BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the * encoded string to split the data in its raw, binary state. BigQuery also supports the escape * sequence "\t" to specify a tab separator. The default value is a comma (','). * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.String fieldDelimiter; /** * [Optional, Trusted Tester] Deprecated, do not use. Please set hivePartitioningOptions instead. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.String hivePartitioningMode; /** * [Optional, Trusted Tester] Options to configure hive partitioning support. * The value may be {@code null}. */ @com.google.api.client.util.Key private HivePartitioningOptions hivePartitioningOptions; /** * [Optional] Indicates if BigQuery should allow extra values that are not represented in the * table schema. If true, the extra values are ignored. If false, records with extra columns are * treated as bad records, and if there are too many bad records, an invalid error is returned in * the job result. The default value is false. The sourceFormat property determines what BigQuery * treats as an extra value: CSV: Trailing columns JSON: Named values that don't match any column * names * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.Boolean ignoreUnknownValues; /** * [Optional] The maximum number of bad records that BigQuery can ignore when running the job. If * the number of bad records exceeds this value, an invalid error is returned in the job result. * This is only valid for CSV and JSON. The default value is 0, which requires that all records * are valid. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.Integer maxBadRecords; /** * [Optional] Specifies a string that represents a null value in a CSV file. For example, if you * specify "\N", BigQuery interprets "\N" as a null value when loading a CSV file. The default * value is the empty string. If you set this property to a custom value, BigQuery throws an error * if an empty string is present for all data types except for STRING and BYTE. For STRING and * BYTE columns, BigQuery interprets the empty string as an empty value. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.String nullMarker; /** * If sourceFormat is set to "DATASTORE_BACKUP", indicates which entity properties to load into * BigQuery from a Cloud Datastore backup. Property names are case sensitive and must be top-level * properties. If no properties are specified, BigQuery loads all properties. If any named * property isn't found in the Cloud Datastore backup, an invalid error is returned in the job * result. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.util.List<java.lang.String> projectionFields; /** * [Optional] The value that is used to quote data sections in a CSV file. BigQuery converts the * string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the * data in its raw, binary state. The default value is a double-quote ('"'). If your data does not * contain quoted sections, set the property value to an empty string. If your data contains * quoted newline characters, you must also set the allowQuotedNewlines property to true. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.String quote; /** * [TrustedTester] Range partitioning specification for this table. Only one of timePartitioning * and rangePartitioning should be specified. * The value may be {@code null}. */ @com.google.api.client.util.Key private RangePartitioning rangePartitioning; /** * [Optional] The schema for the destination table. The schema can be omitted if the destination * table already exists, or if you're loading data from Google Cloud Datastore. * The value may be {@code null}. */ @com.google.api.client.util.Key private TableSchema schema; /** * [Deprecated] The inline schema. For CSV schemas, specify as "Field1:Type1[,Field2:Type2]*". For * example, "foo:STRING, bar:INTEGER, baz:FLOAT". * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.String schemaInline; /** * [Deprecated] The format of the schemaInline property. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.String schemaInlineFormat; /** * Allows the schema of the destination table to be updated as a side effect of the load job if a * schema is autodetected or supplied in the job configuration. Schema update options are * supported in two cases: when writeDisposition is WRITE_APPEND; when writeDisposition is * WRITE_TRUNCATE and the destination table is a partition of a table, specified by partition * decorators. For normal tables, WRITE_TRUNCATE will always overwrite the schema. One or more of * the following values are specified: ALLOW_FIELD_ADDITION: allow adding a nullable field to the * schema. ALLOW_FIELD_RELAXATION: allow relaxing a required field in the original schema to * nullable. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.util.List<java.lang.String> schemaUpdateOptions; /** * [Optional] The number of rows at the top of a CSV file that BigQuery will skip when loading the * data. The default value is 0. This property is useful if you have header rows in the file that * should be skipped. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.Integer skipLeadingRows; /** * [Optional] The format of the data files. For CSV files, specify "CSV". For datastore backups, * specify "DATASTORE_BACKUP". For newline-delimited JSON, specify "NEWLINE_DELIMITED_JSON". For * Avro, specify "AVRO". For parquet, specify "PARQUET". For orc, specify "ORC". The default value * is CSV. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.String sourceFormat; /** * [Required] The fully-qualified URIs that point to your data in Google Cloud. For Google Cloud * Storage URIs: Each URI can contain one '*' wildcard character and it must come after the * 'bucket' name. Size limits related to load jobs apply to external data sources. For Google * Cloud Bigtable URIs: Exactly one URI can be specified and it has be a fully specified and valid * HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore backups: Exactly one * URI can be specified. Also, the '*' wildcard character is not allowed. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.util.List<java.lang.String> sourceUris; /** * Time-based partitioning specification for the destination table. Only one of timePartitioning * and rangePartitioning should be specified. * The value may be {@code null}. */ @com.google.api.client.util.Key private TimePartitioning timePartitioning; /** * [Optional] If sourceFormat is set to "AVRO", indicates whether to enable interpreting logical * types into their corresponding types (ie. TIMESTAMP), instead of only using their raw types * (ie. INTEGER). * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.Boolean useAvroLogicalTypes; /** * [Optional] Specifies the action that occurs if the destination table already exists. The * following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery * overwrites the table data. WRITE_APPEND: If the table already exists, BigQuery appends the data * to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error * is returned in the job result. The default value is WRITE_APPEND. Each action is atomic and * only occurs if BigQuery is able to complete the job successfully. Creation, truncation and * append actions occur as one atomic update upon job completion. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.String writeDisposition; /** * [Optional] Accept rows that are missing trailing optional columns. The missing values are * treated as nulls. If false, records with missing trailing columns are treated as bad records, * and if there are too many bad records, an invalid error is returned in the job result. The * default value is false. Only applicable to CSV, ignored for other formats. * @return value or {@code null} for none */ public java.lang.Boolean getAllowJaggedRows() { return allowJaggedRows; } /** * [Optional] Accept rows that are missing trailing optional columns. The missing values are * treated as nulls. If false, records with missing trailing columns are treated as bad records, * and if there are too many bad records, an invalid error is returned in the job result. The * default value is false. Only applicable to CSV, ignored for other formats. * @param allowJaggedRows allowJaggedRows or {@code null} for none */ public JobConfigurationLoad setAllowJaggedRows(java.lang.Boolean allowJaggedRows) { this.allowJaggedRows = allowJaggedRows; return this; } /** * Indicates if BigQuery should allow quoted data sections that contain newline characters in a * CSV file. The default value is false. * @return value or {@code null} for none */ public java.lang.Boolean getAllowQuotedNewlines() { return allowQuotedNewlines; } /** * Indicates if BigQuery should allow quoted data sections that contain newline characters in a * CSV file. The default value is false. * @param allowQuotedNewlines allowQuotedNewlines or {@code null} for none */ public JobConfigurationLoad setAllowQuotedNewlines(java.lang.Boolean allowQuotedNewlines) { this.allowQuotedNewlines = allowQuotedNewlines; return this; } /** * [Optional] Indicates if we should automatically infer the options and schema for CSV and JSON * sources. * @return value or {@code null} for none */ public java.lang.Boolean getAutodetect() { return autodetect; } /** * [Optional] Indicates if we should automatically infer the options and schema for CSV and JSON * sources. * @param autodetect autodetect or {@code null} for none */ public JobConfigurationLoad setAutodetect(java.lang.Boolean autodetect) { this.autodetect = autodetect; return this; } /** * [Beta] Clustering specification for the destination table. Must be specified with time-based * partitioning, data in the table will be first partitioned and subsequently clustered. * @return value or {@code null} for none */ public Clustering getClustering() { return clustering; } /** * [Beta] Clustering specification for the destination table. Must be specified with time-based * partitioning, data in the table will be first partitioned and subsequently clustered. * @param clustering clustering or {@code null} for none */ public JobConfigurationLoad setClustering(Clustering clustering) { this.clustering = clustering; return this; } /** * [Optional] Specifies whether the job is allowed to create new tables. The following values are * supported: CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. * CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in * the job result. The default value is CREATE_IF_NEEDED. Creation, truncation and append actions * occur as one atomic update upon job completion. * @return value or {@code null} for none */ public java.lang.String getCreateDisposition() { return createDisposition; } /** * [Optional] Specifies whether the job is allowed to create new tables. The following values are * supported: CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. * CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in * the job result. The default value is CREATE_IF_NEEDED. Creation, truncation and append actions * occur as one atomic update upon job completion. * @param createDisposition createDisposition or {@code null} for none */ public JobConfigurationLoad setCreateDisposition(java.lang.String createDisposition) { this.createDisposition = createDisposition; return this; } /** * Custom encryption configuration (e.g., Cloud KMS keys). * @return value or {@code null} for none */ public EncryptionConfiguration getDestinationEncryptionConfiguration() { return destinationEncryptionConfiguration; } /** * Custom encryption configuration (e.g., Cloud KMS keys). * @param destinationEncryptionConfiguration destinationEncryptionConfiguration or {@code null} for none */ public JobConfigurationLoad setDestinationEncryptionConfiguration(EncryptionConfiguration destinationEncryptionConfiguration) { this.destinationEncryptionConfiguration = destinationEncryptionConfiguration; return this; } /** * [Required] The destination table to load the data into. * @return value or {@code null} for none */ public TableReference getDestinationTable() { return destinationTable; } /** * [Required] The destination table to load the data into. * @param destinationTable destinationTable or {@code null} for none */ public JobConfigurationLoad setDestinationTable(TableReference destinationTable) { this.destinationTable = destinationTable; return this; } /** * [Beta] [Optional] Properties with which to create the destination table if it is new. * @return value or {@code null} for none */ public DestinationTableProperties getDestinationTableProperties() { return destinationTableProperties; } /** * [Beta] [Optional] Properties with which to create the destination table if it is new. * @param destinationTableProperties destinationTableProperties or {@code null} for none */ public JobConfigurationLoad setDestinationTableProperties(DestinationTableProperties destinationTableProperties) { this.destinationTableProperties = destinationTableProperties; return this; } /** * [Optional] The character encoding of the data. The supported values are UTF-8 or ISO-8859-1. * The default value is UTF-8. BigQuery decodes the data after the raw, binary data has been split * using the values of the quote and fieldDelimiter properties. * @return value or {@code null} for none */ public java.lang.String getEncoding() { return encoding; } /** * [Optional] The character encoding of the data. The supported values are UTF-8 or ISO-8859-1. * The default value is UTF-8. BigQuery decodes the data after the raw, binary data has been split * using the values of the quote and fieldDelimiter properties. * @param encoding encoding or {@code null} for none */ public JobConfigurationLoad setEncoding(java.lang.String encoding) { this.encoding = encoding; return this; } /** * [Optional] The separator for fields in a CSV file. The separator can be any ISO-8859-1 single- * byte character. To use a character in the range 128-255, you must encode the character as UTF8. * BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the * encoded string to split the data in its raw, binary state. BigQuery also supports the escape * sequence "\t" to specify a tab separator. The default value is a comma (','). * @return value or {@code null} for none */ public java.lang.String getFieldDelimiter() { return fieldDelimiter; } /** * [Optional] The separator for fields in a CSV file. The separator can be any ISO-8859-1 single- * byte character. To use a character in the range 128-255, you must encode the character as UTF8. * BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the * encoded string to split the data in its raw, binary state. BigQuery also supports the escape * sequence "\t" to specify a tab separator. The default value is a comma (','). * @param fieldDelimiter fieldDelimiter or {@code null} for none */ public JobConfigurationLoad setFieldDelimiter(java.lang.String fieldDelimiter) { this.fieldDelimiter = fieldDelimiter; return this; } /** * [Optional, Trusted Tester] Deprecated, do not use. Please set hivePartitioningOptions instead. * @return value or {@code null} for none */ public java.lang.String getHivePartitioningMode() { return hivePartitioningMode; } /** * [Optional, Trusted Tester] Deprecated, do not use. Please set hivePartitioningOptions instead. * @param hivePartitioningMode hivePartitioningMode or {@code null} for none */ public JobConfigurationLoad setHivePartitioningMode(java.lang.String hivePartitioningMode) { this.hivePartitioningMode = hivePartitioningMode; return this; } /** * [Optional, Trusted Tester] Options to configure hive partitioning support. * @return value or {@code null} for none */ public HivePartitioningOptions getHivePartitioningOptions() { return hivePartitioningOptions; } /** * [Optional, Trusted Tester] Options to configure hive partitioning support. * @param hivePartitioningOptions hivePartitioningOptions or {@code null} for none */ public JobConfigurationLoad setHivePartitioningOptions(HivePartitioningOptions hivePartitioningOptions) { this.hivePartitioningOptions = hivePartitioningOptions; return this; } /** * [Optional] Indicates if BigQuery should allow extra values that are not represented in the * table schema. If true, the extra values are ignored. If false, records with extra columns are * treated as bad records, and if there are too many bad records, an invalid error is returned in * the job result. The default value is false. The sourceFormat property determines what BigQuery * treats as an extra value: CSV: Trailing columns JSON: Named values that don't match any column * names * @return value or {@code null} for none */ public java.lang.Boolean getIgnoreUnknownValues() { return ignoreUnknownValues; } /** * [Optional] Indicates if BigQuery should allow extra values that are not represented in the * table schema. If true, the extra values are ignored. If false, records with extra columns are * treated as bad records, and if there are too many bad records, an invalid error is returned in * the job result. The default value is false. The sourceFormat property determines what BigQuery * treats as an extra value: CSV: Trailing columns JSON: Named values that don't match any column * names * @param ignoreUnknownValues ignoreUnknownValues or {@code null} for none */ public JobConfigurationLoad setIgnoreUnknownValues(java.lang.Boolean ignoreUnknownValues) { this.ignoreUnknownValues = ignoreUnknownValues; return this; } /** * [Optional] The maximum number of bad records that BigQuery can ignore when running the job. If * the number of bad records exceeds this value, an invalid error is returned in the job result. * This is only valid for CSV and JSON. The default value is 0, which requires that all records * are valid. * @return value or {@code null} for none */ public java.lang.Integer getMaxBadRecords() { return maxBadRecords; } /** * [Optional] The maximum number of bad records that BigQuery can ignore when running the job. If * the number of bad records exceeds this value, an invalid error is returned in the job result. * This is only valid for CSV and JSON. The default value is 0, which requires that all records * are valid. * @param maxBadRecords maxBadRecords or {@code null} for none */ public JobConfigurationLoad setMaxBadRecords(java.lang.Integer maxBadRecords) { this.maxBadRecords = maxBadRecords; return this; } /** * [Optional] Specifies a string that represents a null value in a CSV file. For example, if you * specify "\N", BigQuery interprets "\N" as a null value when loading a CSV file. The default * value is the empty string. If you set this property to a custom value, BigQuery throws an error * if an empty string is present for all data types except for STRING and BYTE. For STRING and * BYTE columns, BigQuery interprets the empty string as an empty value. * @return value or {@code null} for none */ public java.lang.String getNullMarker() { return nullMarker; } /** * [Optional] Specifies a string that represents a null value in a CSV file. For example, if you * specify "\N", BigQuery interprets "\N" as a null value when loading a CSV file. The default * value is the empty string. If you set this property to a custom value, BigQuery throws an error * if an empty string is present for all data types except for STRING and BYTE. For STRING and * BYTE columns, BigQuery interprets the empty string as an empty value. * @param nullMarker nullMarker or {@code null} for none */ public JobConfigurationLoad setNullMarker(java.lang.String nullMarker) { this.nullMarker = nullMarker; return this; } /** * If sourceFormat is set to "DATASTORE_BACKUP", indicates which entity properties to load into * BigQuery from a Cloud Datastore backup. Property names are case sensitive and must be top-level * properties. If no properties are specified, BigQuery loads all properties. If any named * property isn't found in the Cloud Datastore backup, an invalid error is returned in the job * result. * @return value or {@code null} for none */ public java.util.List<java.lang.String> getProjectionFields() { return projectionFields; } /** * If sourceFormat is set to "DATASTORE_BACKUP", indicates which entity properties to load into * BigQuery from a Cloud Datastore backup. Property names are case sensitive and must be top-level * properties. If no properties are specified, BigQuery loads all properties. If any named * property isn't found in the Cloud Datastore backup, an invalid error is returned in the job * result. * @param projectionFields projectionFields or {@code null} for none */ public JobConfigurationLoad setProjectionFields(java.util.List<java.lang.String> projectionFields) { this.projectionFields = projectionFields; return this; } /** * [Optional] The value that is used to quote data sections in a CSV file. BigQuery converts the * string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the * data in its raw, binary state. The default value is a double-quote ('"'). If your data does not * contain quoted sections, set the property value to an empty string. If your data contains * quoted newline characters, you must also set the allowQuotedNewlines property to true. * @return value or {@code null} for none */ public java.lang.String getQuote() { return quote; } /** * [Optional] The value that is used to quote data sections in a CSV file. BigQuery converts the * string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the * data in its raw, binary state. The default value is a double-quote ('"'). If your data does not * contain quoted sections, set the property value to an empty string. If your data contains * quoted newline characters, you must also set the allowQuotedNewlines property to true. * @param quote quote or {@code null} for none */ public JobConfigurationLoad setQuote(java.lang.String quote) { this.quote = quote; return this; } /** * [TrustedTester] Range partitioning specification for this table. Only one of timePartitioning * and rangePartitioning should be specified. * @return value or {@code null} for none */ public RangePartitioning getRangePartitioning() { return rangePartitioning; } /** * [TrustedTester] Range partitioning specification for this table. Only one of timePartitioning * and rangePartitioning should be specified. * @param rangePartitioning rangePartitioning or {@code null} for none */ public JobConfigurationLoad setRangePartitioning(RangePartitioning rangePartitioning) { this.rangePartitioning = rangePartitioning; return this; } /** * [Optional] The schema for the destination table. The schema can be omitted if the destination * table already exists, or if you're loading data from Google Cloud Datastore. * @return value or {@code null} for none */ public TableSchema getSchema() { return schema; } /** * [Optional] The schema for the destination table. The schema can be omitted if the destination * table already exists, or if you're loading data from Google Cloud Datastore. * @param schema schema or {@code null} for none */ public JobConfigurationLoad setSchema(TableSchema schema) { this.schema = schema; return this; } /** * [Deprecated] The inline schema. For CSV schemas, specify as "Field1:Type1[,Field2:Type2]*". For * example, "foo:STRING, bar:INTEGER, baz:FLOAT". * @return value or {@code null} for none */ public java.lang.String getSchemaInline() { return schemaInline; } /** * [Deprecated] The inline schema. For CSV schemas, specify as "Field1:Type1[,Field2:Type2]*". For * example, "foo:STRING, bar:INTEGER, baz:FLOAT". * @param schemaInline schemaInline or {@code null} for none */ public JobConfigurationLoad setSchemaInline(java.lang.String schemaInline) { this.schemaInline = schemaInline; return this; } /** * [Deprecated] The format of the schemaInline property. * @return value or {@code null} for none */ public java.lang.String getSchemaInlineFormat() { return schemaInlineFormat; } /** * [Deprecated] The format of the schemaInline property. * @param schemaInlineFormat schemaInlineFormat or {@code null} for none */ public JobConfigurationLoad setSchemaInlineFormat(java.lang.String schemaInlineFormat) { this.schemaInlineFormat = schemaInlineFormat; return this; } /** * Allows the schema of the destination table to be updated as a side effect of the load job if a * schema is autodetected or supplied in the job configuration. Schema update options are * supported in two cases: when writeDisposition is WRITE_APPEND; when writeDisposition is * WRITE_TRUNCATE and the destination table is a partition of a table, specified by partition * decorators. For normal tables, WRITE_TRUNCATE will always overwrite the schema. One or more of * the following values are specified: ALLOW_FIELD_ADDITION: allow adding a nullable field to the * schema. ALLOW_FIELD_RELAXATION: allow relaxing a required field in the original schema to * nullable. * @return value or {@code null} for none */ public java.util.List<java.lang.String> getSchemaUpdateOptions() { return schemaUpdateOptions; } /** * Allows the schema of the destination table to be updated as a side effect of the load job if a * schema is autodetected or supplied in the job configuration. Schema update options are * supported in two cases: when writeDisposition is WRITE_APPEND; when writeDisposition is * WRITE_TRUNCATE and the destination table is a partition of a table, specified by partition * decorators. For normal tables, WRITE_TRUNCATE will always overwrite the schema. One or more of * the following values are specified: ALLOW_FIELD_ADDITION: allow adding a nullable field to the * schema. ALLOW_FIELD_RELAXATION: allow relaxing a required field in the original schema to * nullable. * @param schemaUpdateOptions schemaUpdateOptions or {@code null} for none */ public JobConfigurationLoad setSchemaUpdateOptions(java.util.List<java.lang.String> schemaUpdateOptions) { this.schemaUpdateOptions = schemaUpdateOptions; return this; } /** * [Optional] The number of rows at the top of a CSV file that BigQuery will skip when loading the * data. The default value is 0. This property is useful if you have header rows in the file that * should be skipped. * @return value or {@code null} for none */ public java.lang.Integer getSkipLeadingRows() { return skipLeadingRows; } /** * [Optional] The number of rows at the top of a CSV file that BigQuery will skip when loading the * data. The default value is 0. This property is useful if you have header rows in the file that * should be skipped. * @param skipLeadingRows skipLeadingRows or {@code null} for none */ public JobConfigurationLoad setSkipLeadingRows(java.lang.Integer skipLeadingRows) { this.skipLeadingRows = skipLeadingRows; return this; } /** * [Optional] The format of the data files. For CSV files, specify "CSV". For datastore backups, * specify "DATASTORE_BACKUP". For newline-delimited JSON, specify "NEWLINE_DELIMITED_JSON". For * Avro, specify "AVRO". For parquet, specify "PARQUET". For orc, specify "ORC". The default value * is CSV. * @return value or {@code null} for none */ public java.lang.String getSourceFormat() { return sourceFormat; } /** * [Optional] The format of the data files. For CSV files, specify "CSV". For datastore backups, * specify "DATASTORE_BACKUP". For newline-delimited JSON, specify "NEWLINE_DELIMITED_JSON". For * Avro, specify "AVRO". For parquet, specify "PARQUET". For orc, specify "ORC". The default value * is CSV. * @param sourceFormat sourceFormat or {@code null} for none */ public JobConfigurationLoad setSourceFormat(java.lang.String sourceFormat) { this.sourceFormat = sourceFormat; return this; } /** * [Required] The fully-qualified URIs that point to your data in Google Cloud. For Google Cloud * Storage URIs: Each URI can contain one '*' wildcard character and it must come after the * 'bucket' name. Size limits related to load jobs apply to external data sources. For Google * Cloud Bigtable URIs: Exactly one URI can be specified and it has be a fully specified and valid * HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore backups: Exactly one * URI can be specified. Also, the '*' wildcard character is not allowed. * @return value or {@code null} for none */ public java.util.List<java.lang.String> getSourceUris() { return sourceUris; } /** * [Required] The fully-qualified URIs that point to your data in Google Cloud. For Google Cloud * Storage URIs: Each URI can contain one '*' wildcard character and it must come after the * 'bucket' name. Size limits related to load jobs apply to external data sources. For Google * Cloud Bigtable URIs: Exactly one URI can be specified and it has be a fully specified and valid * HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore backups: Exactly one * URI can be specified. Also, the '*' wildcard character is not allowed. * @param sourceUris sourceUris or {@code null} for none */ public JobConfigurationLoad setSourceUris(java.util.List<java.lang.String> sourceUris) { this.sourceUris = sourceUris; return this; } /** * Time-based partitioning specification for the destination table. Only one of timePartitioning * and rangePartitioning should be specified. * @return value or {@code null} for none */ public TimePartitioning getTimePartitioning() { return timePartitioning; } /** * Time-based partitioning specification for the destination table. Only one of timePartitioning * and rangePartitioning should be specified. * @param timePartitioning timePartitioning or {@code null} for none */ public JobConfigurationLoad setTimePartitioning(TimePartitioning timePartitioning) { this.timePartitioning = timePartitioning; return this; } /** * [Optional] If sourceFormat is set to "AVRO", indicates whether to enable interpreting logical * types into their corresponding types (ie. TIMESTAMP), instead of only using their raw types * (ie. INTEGER). * @return value or {@code null} for none */ public java.lang.Boolean getUseAvroLogicalTypes() { return useAvroLogicalTypes; } /** * [Optional] If sourceFormat is set to "AVRO", indicates whether to enable interpreting logical * types into their corresponding types (ie. TIMESTAMP), instead of only using their raw types * (ie. INTEGER). * @param useAvroLogicalTypes useAvroLogicalTypes or {@code null} for none */ public JobConfigurationLoad setUseAvroLogicalTypes(java.lang.Boolean useAvroLogicalTypes) { this.useAvroLogicalTypes = useAvroLogicalTypes; return this; } /** * [Optional] Specifies the action that occurs if the destination table already exists. The * following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery * overwrites the table data. WRITE_APPEND: If the table already exists, BigQuery appends the data * to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error * is returned in the job result. The default value is WRITE_APPEND. Each action is atomic and * only occurs if BigQuery is able to complete the job successfully. Creation, truncation and * append actions occur as one atomic update upon job completion. * @return value or {@code null} for none */ public java.lang.String getWriteDisposition() { return writeDisposition; } /** * [Optional] Specifies the action that occurs if the destination table already exists. The * following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery * overwrites the table data. WRITE_APPEND: If the table already exists, BigQuery appends the data * to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error * is returned in the job result. The default value is WRITE_APPEND. Each action is atomic and * only occurs if BigQuery is able to complete the job successfully. Creation, truncation and * append actions occur as one atomic update upon job completion. * @param writeDisposition writeDisposition or {@code null} for none */ public JobConfigurationLoad setWriteDisposition(java.lang.String writeDisposition) { this.writeDisposition = writeDisposition; return this; } @Override public JobConfigurationLoad set(String fieldName, Object value) { return (JobConfigurationLoad) super.set(fieldName, value); } @Override public JobConfigurationLoad clone() { return (JobConfigurationLoad) super.clone(); } }
ccfde423f018a947224d1de31baa743935c06297
66ca87c8330ebb8cc46cd743c0ad8ffb1474f175
/蔡翔宇 2025作业/jcart-administration-back/src/main/java/io/cxy/jcartadministrationback/dto/in/AddressCreateCreateInDTO.java
f38c6b284f60ac98f8ea9ffc2c4d0d8b1110eb73
[ "Apache-2.0" ]
permissive
Hello-ui-commits/-0225
b217167ccd01321d10b9852bab3e734ed1a0003d
b432f57045dcfa24babbcdf7a93689ee2a96801f
refs/heads/master
2021-01-16T05:07:14.942169
2020-02-25T11:57:36
2020-02-25T11:57:36
242,986,001
0
0
null
null
null
null
UTF-8
Java
false
false
1,311
java
package io.cxy.jcartadministrationback.dto.in; public class AddressCreateCreateInDTO { private Integer addressId; private Integer customerId; private String receiverName; private String receiverMobile; private String content; private String tag; public Integer getAddressId() { return addressId; } public void setAddressId(Integer addressId) { this.addressId = addressId; } public Integer getCustomerId() { return customerId; } public void setCustomerId(Integer customerId) { this.customerId = customerId; } public String getReceiverName() { return receiverName; } public void setReceiverName(String receiverName) { this.receiverName = receiverName; } public String getReceiverMobile() { return receiverMobile; } public void setReceiverMobile(String receiverMobile) { this.receiverMobile = receiverMobile; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public String getTag() { return tag; } public void setTag(String tag) { this.tag = tag; } }
77db8eb90cc0be8bccf0ae487afc168b529d23a7
033d4ab75541e23e2829417f9e3c681e9cbf8678
/Lab1.7/src/my/test/Main.java
3fef400319e5eb32ad51468333f93495d2f2929b
[]
no_license
dezmond-necros/JavaLabs
1abcf37122e6dcd3bd48e5ac25fd3cf9db219bb5
37323f7a5fd870919e0aee96541e028f818fb921
refs/heads/master
2023-02-12T13:48:08.545768
2021-01-10T14:11:22
2021-01-10T14:11:22
304,716,418
0
0
null
null
null
null
UTF-8
Java
false
false
1,063
java
package my.test; import java.io.Console; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("введи код города: "); int num = in.nextInt(); double time = 10; switch (num) { case 905: System.out.printf("Москва, стоимость разговора: %s \n",time*4.15); break; case 194: System.out.printf("Ростов, стоимость разговора: %s \n",time*1.98); break; case 491: System.out.printf("Краснодар, стоимость разговора: %s \n",time*2.69); break; case 800: System.out.printf("Киров, стоимость разговора: %s \n",time*5.00); break; default: System.out.println("неверный код города"); } } }
ae473fd06862cd8138489eef17cf43feeac3704c
f5d00e89ec62c2b65b2398158f0889efe2c2a548
/cloud-client/src/main/java/cn/phukety/cloudclient/controller/HelloController.java
5e99c52ceb024d92076f5ff6f7083cf8594a1a1e
[]
no_license
Phukety/spring-cloud-modules
190c9badda70ae85dea1588e26d8e98053d75786
e57eb5ee4ce54cef46813df8d16de7b6c7f18382
refs/heads/main
2023-02-08T08:43:59.447206
2021-01-04T11:36:50
2021-01-04T11:36:50
313,338,576
0
0
null
null
null
null
UTF-8
Java
false
false
641
java
package cn.phukety.cloudclient.controller; import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.List; @Slf4j @RestController public class HelloController { @Resource private DiscoveryClient client; @GetMapping(value = "/hello") public String hello() { List<String> services = client.getServices(); services.forEach(System.out::println); return "this is cloud client"; } }
7ce34813bed6dff763634cec3d9d9a8ae5cd6f1f
9699d8b4db7d88ffea9e67c23b8fe9c3918c5d20
/Lab/untitled/src/Main.java
d05fe5edc3caeb38a1422f8795d39de2c19f0f55
[]
no_license
suiyschn/9331-19T2
b32e452df9466c41337f3b684832ceeaf85a0137
29b97942aa30b713d8821ba51a71fd70775d8ab5
refs/heads/master
2020-07-08T16:57:34.108748
2019-08-23T07:19:11
2019-08-23T07:19:11
203,727,533
0
0
null
null
null
null
UTF-8
Java
false
false
1,085
java
import java.util.*; import java.lang.*; public class Main { /** 主方法 */ public static void main(String[] args) { String q = "originally designed for computer clusters built from commodity hardware it has also found use on clusters of higher end hardware. hadoop is a part of apache foundation."; System.out.println(Arrays.toString(ngrams(q, 2))); } /** 返回两个整数变量较大的值 */ public static String[] ngrams(String s, int len) { String[] parts = s.split(" "); String[] result = new String[parts.length - len + 1]; for(int i = 0; i < parts.length - len + 1; i++) { StringBuilder sb = new StringBuilder(); int k = 0; do { if(k > 0) sb.append(' '); sb.append(parts[i+k]); k++; }while (k < len); result[i] = sb.toString(); } return result; } } // for(int k = 0; k < len; k++) { // if(k > 0) sb.append(' '); // sb.append(parts[i+k]);
604b6d8068e39d33d729b62c14dc77419ba7b331
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/30/30_8e2477a6e9856d62263da1432e585b212e08a56f/SupplierService/30_8e2477a6e9856d62263da1432e585b212e08a56f_SupplierService_t.java
f377868c83185495966e731653c94716e8e0a1f2
[]
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
835
java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package aic2010.services; import aic2010.exception.UnknownProductException; import aic2010.model.Product; import java.math.BigDecimal; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; /** * * @author rudolf */ @WebService(targetNamespace="http://infosys.tuwien.ac.at/aic10/ass1/dto/supplier") @SOAPBinding(style=SOAPBinding.Style.RPC, parameterStyle=SOAPBinding.ParameterStyle.BARE) public interface SupplierService { @WebMethod(operationName="order") public BigDecimal order(@WebParam(name="product") Product product, @WebParam(name="amount")Integer amount) throws UnknownProductException; }
7237100dd422af3c9abbb104a29d4211abb53e2d
250defa7d1a33187c48cbd58c550dc1070ee9011
/Application/app/src/main/java/com/virmana/flix/ui/views/ClickableViewPager.java
731613409182950081395fbbd37e00ec6842c442
[]
no_license
sunilkumararava/SunilFlix
90903a232aea38a0ed93e026d57e1948c83d7379
c45aca36b4be45c15349769413d64c7a2aee51fa
refs/heads/master
2023-02-04T11:38:01.780958
2020-12-29T04:02:41
2020-12-29T04:02:41
325,181,355
1
1
null
null
null
null
UTF-8
Java
false
false
1,589
java
package com.virmana.flix.ui.views; import android.content.Context; import android.util.AttributeSet; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; import androidx.viewpager.widget.ViewPager; /** * Created by Tamim on 28/09/2019. */ public class ClickableViewPager extends ViewPager { private OnItemClickListener mOnItemClickListener; public ClickableViewPager(Context context) { super(context); setup(); } public ClickableViewPager(Context context, AttributeSet attrs) { super(context, attrs); setup(); } private void setup() { final GestureDetector tapGestureDetector = new GestureDetector(getContext(), new TapGestureListener()); setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { tapGestureDetector.onTouchEvent(event); return false; } }); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { mOnItemClickListener = onItemClickListener; } public interface OnItemClickListener { void onItemClick(int position); } private class TapGestureListener extends GestureDetector.SimpleOnGestureListener { @Override public boolean onSingleTapConfirmed(MotionEvent e) { if(mOnItemClickListener != null) { mOnItemClickListener.onItemClick(getCurrentItem()); } return true; } } }
1b435d2c2dd5e93f0702b7ef21fdcf27d8ed12fa
bfb8198e6554bbc21694ce83745f0915a3d6de07
/src/main/java/com/lhf/mango/entity/Article.java
af68643a220be016a23676149ab5b2f082409ac7
[]
no_license
JavaCodeMood/mango-example1
4207ec4f9c1b6ddd42f64e8ae394c08139b6ed59
01401e52cf8454c94bbb2c4898048b8695f93da6
refs/heads/master
2020-04-24T15:06:19.698996
2019-02-22T11:10:12
2019-02-22T11:10:12
172,051,856
1
0
null
null
null
null
UTF-8
Java
false
false
1,395
java
package com.lhf.mango.entity; import org.jfaster.mango.annotation.ID; import java.util.Date; /** * @ClassName: Article * @Desc: 文章实体 * @Author: liuhefei * @Date: 2018/12/20 19:26 */ public class Article { @ID private Integer id; private String title; private String content; private String author; private Date updateTime; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } @Override public String toString() { return "Article{" + "id=" + id + ", title='" + title + '\'' + ", content='" + content + '\'' + ", author='" + author + '\'' + ", updateTime=" + updateTime + '}'; } }
731d7437595107399cfda150aa2e5e58f09e4848
33a10e9a3ab2b489dc982e0cba6756395cc00aef
/Calc.java
ba0e3d4ed14133b55df6e63095107102ea2d248c
[]
no_license
DevilDarkSider/Calc_WTL
44d4103845e3ae2087f9edcb5c3fd942467553d9
cd2c47e9ac75f07551e079befb3add3c93df7140
refs/heads/master
2021-01-25T11:27:20.423772
2018-03-02T05:21:12
2018-03-02T05:21:12
123,397,209
0
0
null
null
null
null
UTF-8
Java
false
false
116
java
public class Calc { public static void main(String [] args) { System.out.println("Calc on WTL"); } }
29c5fac6b81307b1a615290131401ab834108a41
08deccdb56475ccb2d0a4992be99e236c9a22264
/hongbao-api-web/src/main/java/com/yanbao/vo/HotGoodsVo.java
31d91c0850f8717bd1a3d8dad8d76d794833bd36
[]
no_license
dream-home/hongbao
92a70099c236855b32aebe3b252192c782e93c87
a660cc02ba0fd218b7c3a171ad4a217edfd4713d
refs/heads/master
2021-07-05T12:29:06.735635
2017-09-28T04:02:52
2017-09-28T04:02:52
105,000,363
0
0
null
null
null
null
UTF-8
Java
false
false
4,361
java
package com.yanbao.vo; import com.yanbao.core.model.SimpleModel; /** * 商品表 * * @date 2016年3月28日 */ public class HotGoodsVo extends SimpleModel { private static final long serialVersionUID = 6468123345520931799L; /** 商品分类ID */ private String goodsSortId; /** 商铺Id */ private String storeId; /** 商铺名称 */ private String storeName; /** 名称 */ private String name; /** 图片 */ private String icon; /** 商品价格 */ private Double price; /** 竞拍价 */ private Double drawPrice; /** 参与竞拍人数 */ private Integer drawNum; /** 商品介绍 */ private String detail; /** 商品类型:0:系统发布:1:商家发布 */ private Integer goodsType; /** 库存 */ private Integer stock; /** 当前期数编号 */ private Integer curIssueNo; /** 当前期数Id */ private String curIssueId; /** 是否置顶:0:否,1:是 */ private Integer isTop; /** 是否推荐:0:否;1:是 */ private Integer isRecommend; /** 是否委托出售:0:否,1:是 */ private Integer saleSwitch; /** 一级分销比例 */ private Double firstReferrerScale = 0d; /** 二级分销比例 */ private Double secondReferrerScale = 0d; /** 三级分销比例 */ private Double thirdReferrerScale = 0d; /** 商家赠送Ep */ private Double businessSendEp = 0d; /** 分类名称 **/ private String goodsSortName; public String getGoodsSortName() { return goodsSortName; } public void setGoodsSortName(String goodsSortName) { this.goodsSortName = goodsSortName; } public String getGoodsSortId() { return goodsSortId; } public void setGoodsSortId(String goodsSortId) { this.goodsSortId = goodsSortId; } public String getStoreId() { return storeId; } public void setStoreId(String storeId) { this.storeId = storeId; } public String getStoreName() { return storeName; } public void setStoreName(String storeName) { this.storeName = storeName; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public Double getPrice() { return price; } public void setPrice(Double price) { this.price = price; } public Double getDrawPrice() { return drawPrice; } public void setDrawPrice(Double drawPrice) { this.drawPrice = drawPrice; } public Integer getDrawNum() { return drawNum; } public void setDrawNum(Integer drawNum) { this.drawNum = drawNum; } public String getDetail() { return detail; } public void setDetail(String detail) { this.detail = detail; } public Integer getGoodsType() { return goodsType; } public void setGoodsType(Integer goodsType) { this.goodsType = goodsType; } public Integer getStock() { return stock; } public void setStock(Integer stock) { this.stock = stock; } public Integer getCurIssueNo() { return curIssueNo; } public void setCurIssueNo(Integer curIssueNo) { this.curIssueNo = curIssueNo; } public String getCurIssueId() { return curIssueId; } public void setCurIssueId(String curIssueId) { this.curIssueId = curIssueId; } public Integer getIsTop() { return isTop; } public void setIsTop(Integer isTop) { this.isTop = isTop; } public Integer getIsRecommend() { return isRecommend; } public void setIsRecommend(Integer isRecommend) { this.isRecommend = isRecommend; } public Integer getSaleSwitch() { return saleSwitch; } public void setSaleSwitch(Integer saleSwitch) { this.saleSwitch = saleSwitch; } public Double getFirstReferrerScale() { return firstReferrerScale; } public void setFirstReferrerScale(Double firstReferrerScale) { this.firstReferrerScale = firstReferrerScale; } public Double getSecondReferrerScale() { return secondReferrerScale; } public void setSecondReferrerScale(Double secondReferrerScale) { this.secondReferrerScale = secondReferrerScale; } public Double getThirdReferrerScale() { return thirdReferrerScale; } public void setThirdReferrerScale(Double thirdReferrerScale) { this.thirdReferrerScale = thirdReferrerScale; } public Double getBusinessSendEp() { return businessSendEp; } public void setBusinessSendEp(Double businessSendEp) { this.businessSendEp = businessSendEp; } }
45cc44c77e3ead13b74a4e60919f8defc338d642
005a019cfef75e6bef358c10e93a3ea5e3407a43
/app/src/main/java/software/doit/boxio/model/data/User.java
1552a4a248d18f28290532d746712663225e1d21
[]
no_license
RAZER-KIEV/Box_io
91a40faea609c3ea324fb387aaa205eeaed4df8a
b0aaa10815dee407eb94e1a1d166df634bfeac83
refs/heads/master
2020-03-28T09:36:28.951130
2019-12-20T15:07:23
2019-12-20T15:07:23
148,045,947
1
0
null
null
null
null
UTF-8
Java
false
false
1,787
java
package software.doit.boxio.model.data; import android.arch.persistence.room.Entity; import android.arch.persistence.room.PrimaryKey; import android.support.annotation.NonNull; @Entity public class User { @NonNull @PrimaryKey private String email; private long timeStamp; private String name, password, userInfo; public User(long timestamp, @NonNull String email, String name, String password, String userInfo) { this.timeStamp = timestamp; this.email = email; this.name = name; this.password = password; this.userInfo = userInfo; } public User() { } public void setTimestamp(long timestamp) { this.timeStamp = timestamp; } public long getTimeStamp() { return timeStamp; } public void setTimeStamp(long timeStamp) { this.timeStamp = timeStamp; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getUserInfo() { return userInfo; } public void setUserInfo(String userInfo) { this.userInfo = userInfo; } @Override public String toString() { return "User{" + "timestamp=" + timeStamp + ", email='" + email + '\'' + ", name='" + name + '\'' + ", password='" + password + '\'' + ", userInfo='" + userInfo + '\'' + '}'; } }
5c879ceb7bf0915a74a28502f93150461e54f18e
e184c682e85b9d63cc800957e6daf0cc404ca747
/src/test/java/com/disney/comparator/JsonComparatorTest.java
8e4b875ef50a972aeecdee8d4f82e8f1e792eda5
[]
no_license
Pbryant88/Practice
3be0563b866a92034e679cd5dbf065969519979d
6cbcd963391c92bb37cf1fcd8500fb2fa3873996
refs/heads/master
2022-04-16T17:01:57.127583
2020-04-05T17:33:30
2020-04-05T17:33:30
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,462
java
package com.disney.comparator; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import org.junit.Test; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import junit.framework.TestCase; public class JsonComparatorTest extends TestCase { /** * Tests that generated paths are correct for the path given * @throws JsonProcessingException * @throws IOException */ @Test public void testGeneratedPaths() throws JsonProcessingException, IOException { ObjectMapper mapper = new ObjectMapper(); JsonComparator comparator = new JsonComparator(); JsonNode jsonSource = mapper.readTree(this.getClass().getResourceAsStream("/json/jsonResource.json")); // JsonNode JsonDestination= // mapper.readTree(this.getClass().getResourceAsStream("/json/jsonDestination.json")); String[] paths = new String[] { "/descriptions/*/type" }; String[] pathsExpected = new String[] { "descriptions/shortDescription/type", "descriptions/shortDescriptionMobile/type", "descriptions/entityCard1/type", "descriptions/entityCard2/type", "descriptions/entityCard3/type" }; ArrayList<StringBuilder> result = comparator.generatePaths(paths[0], jsonSource); String[] resultArray = result.stream().map(String::new).toArray(String[]::new); assertTrue(Arrays.equals(resultArray, pathsExpected)); } }
fb1ba2e98b2765e4e53092542040d26419acc79c
abf4be5b577249d52ba0f9cfe8aa9cb338221aff
/gen/com/handmark/pulltorefresh/library/R.java
5127e7497bcbbc1b731357eef94a4aa3d45c750b
[]
no_license
bjzhou/DirectMsg
295944758a947db6bcd1da39e63cd01598e94367
09628e48a68553bc99e173821615de51d040000d
refs/heads/master
2020-06-26T09:01:30.318034
2013-03-21T01:10:56
2013-03-21T01:10:56
null
0
0
null
null
null
null
UTF-8
Java
false
false
5,613
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.handmark.pulltorefresh.library; public final class R { public static final class id { public static final int pullFromStart = 0x7f050001; public static final int pull_to_refresh_progress = 0x7f050018; public static final int rotate = 0x7f050007; public static final int both = 0x7f050003; public static final int webview = 0x7f05000a; public static final int pull_to_refresh_text = 0x7f050019; public static final int pullDownFromTop = 0x7f050005; public static final int gridview = 0x7f050009; public static final int pullUpFromBottom = 0x7f050006; public static final int scrollview = 0x7f05000b; public static final int pullFromEnd = 0x7f050002; public static final int pull_to_refresh_image = 0x7f050017; public static final int fl_inner = 0x7f050016; public static final int pull_to_refresh_sub_text = 0x7f05001a; public static final int disabled = 0x7f050000; public static final int flip = 0x7f050008; public static final int manualOnly = 0x7f050004; } public static final class anim { public static final int slide_out_to_bottom = 0x7f040003; public static final int slide_out_to_top = 0x7f040004; public static final int slide_in_from_bottom = 0x7f040001; public static final int slide_in_from_top = 0x7f040002; } public static final class string { public static final int pull_to_refresh_refreshing_label = 0x7f070002; public static final int pull_to_refresh_release_label = 0x7f070001; public static final int pull_to_refresh_from_bottom_pull_label = 0x7f070003; public static final int pull_to_refresh_from_bottom_refreshing_label = 0x7f070005; public static final int pull_to_refresh_pull_label = 0x7f070000; public static final int pull_to_refresh_from_bottom_release_label = 0x7f070004; } public static final class layout { public static final int pull_to_refresh_header_horizontal = 0x7f030006; public static final int pull_to_refresh_header_vertical = 0x7f030007; } public static final class styleable { public static final int PullToRefresh_ptrDrawableStart = 7; public static final int PullToRefresh_ptrShowIndicator = 5; public static final int[] PullToRefresh = { 0x7f010000, 0x7f010001, 0x7f010002, 0x7f010003, 0x7f010004, 0x7f010005, 0x7f010006, 0x7f010007, 0x7f010008, 0x7f010009, 0x7f01000a, 0x7f01000b, 0x7f01000c, 0x7f01000d, 0x7f01000e, 0x7f01000f, 0x7f010010, 0x7f010011, 0x7f010012 }; public static final int PullToRefresh_ptrHeaderTextAppearance = 10; public static final int PullToRefresh_ptrRefreshableViewBackground = 0; public static final int PullToRefresh_ptrAnimationStyle = 12; public static final int PullToRefresh_ptrScrollingWhileRefreshingEnabled = 13; public static final int PullToRefresh_ptrAdapterViewBackground = 16; public static final int PullToRefresh_ptrMode = 4; public static final int PullToRefresh_ptrHeaderTextColor = 2; public static final int PullToRefresh_ptrListViewExtrasEnabled = 14; public static final int PullToRefresh_ptrDrawableBottom = 18; public static final int PullToRefresh_ptrHeaderBackground = 1; public static final int PullToRefresh_ptrDrawableTop = 17; public static final int PullToRefresh_ptrOverScroll = 9; public static final int PullToRefresh_ptrDrawableEnd = 8; public static final int PullToRefresh_ptrRotateDrawableWhilePulling = 15; public static final int PullToRefresh_ptrSubHeaderTextAppearance = 11; public static final int PullToRefresh_ptrDrawable = 6; public static final int PullToRefresh_ptrHeaderSubTextColor = 3; } public static final class drawable { public static final int indicator_bg_top = 0x7f020008; public static final int default_ptr_flip = 0x7f020000; public static final int indicator_arrow = 0x7f020006; public static final int indicator_bg_bottom = 0x7f020007; public static final int default_ptr_rotate = 0x7f020001; } public static final class attr { public static final int ptrHeaderBackground = 0x7f010001; public static final int ptrMode = 0x7f010004; public static final int ptrScrollingWhileRefreshingEnabled = 0x7f01000d; public static final int ptrAdapterViewBackground = 0x7f010010; public static final int ptrRotateDrawableWhilePulling = 0x7f01000f; public static final int ptrDrawableStart = 0x7f010007; public static final int ptrSubHeaderTextAppearance = 0x7f01000b; public static final int ptrAnimationStyle = 0x7f01000c; public static final int ptrDrawableEnd = 0x7f010008; public static final int ptrShowIndicator = 0x7f010005; public static final int ptrDrawableTop = 0x7f010011; public static final int ptrDrawable = 0x7f010006; public static final int ptrHeaderTextAppearance = 0x7f01000a; public static final int ptrDrawableBottom = 0x7f010012; public static final int ptrHeaderSubTextColor = 0x7f010003; public static final int ptrListViewExtrasEnabled = 0x7f01000e; public static final int ptrOverScroll = 0x7f010009; public static final int ptrHeaderTextColor = 0x7f010002; public static final int ptrRefreshableViewBackground = 0x7f010000; } public static final class dimen { public static final int indicator_right_padding = 0x7f060000; public static final int indicator_corner_radius = 0x7f060001; public static final int indicator_internal_padding = 0x7f060002; public static final int header_footer_top_bottom_padding = 0x7f060004; public static final int header_footer_left_right_padding = 0x7f060003; } }
1c20cbc408080fb8f82dea9b1240c70d0b9458d8
9a667fcd46de08adf497b00e25dc0d17c3b6d734
/src/PreparedStmt.java
96e009c527bfc0f946f29aa7f668c70a0acda99b
[]
no_license
Red-French/JDBC
04740f07b6ba7ad330f30180d93fd7c18695c116
e9f820915d9786bccb4ee9cbb8f4a56236cddca1
refs/heads/master
2021-01-19T22:59:49.513457
2017-04-22T21:28:28
2017-04-22T21:28:28
88,904,977
0
0
null
null
null
null
UTF-8
Java
false
false
1,823
java
import java.sql.*; public class PreparedStmt { public static void main(String[] args) throws SQLException { String url = "jdbc:mysql://localhost:3306/demo"; String user = "student"; String password = "student"; Connection myConn = null; PreparedStatement myStmt = null; ResultSet results = null; try { myConn = DriverManager.getConnection(url, user, password); myStmt = myConn.prepareStatement("select * from employees where salary > ? and department=?"); System.out.println("Prepared statement: salary > 80000 and department = Legal\n"); myStmt.setDouble(1, 80000); // salary value myStmt.setString(2, "Legal"); // department value results = myStmt.executeQuery(); displayEmployees(myStmt, results); System.out.println("\nReuse the prepared statement: salary > 25000 and department = HR \n"); myStmt.setDouble(1, 25000); // salary value myStmt.setString(2, "HR"); // department value results = myStmt.executeQuery(); displayEmployees(myStmt, results); } catch (Exception exc) { exc.printStackTrace(); } finally { if (myConn != null) { myConn.close(); } if (results != null) { results.close(); } if (myStmt != null) { myStmt.close(); } } } private static void displayEmployees(PreparedStatement myStmt, ResultSet results) throws SQLException { try { while (results.next()) { String lastName = results.getString("last_name"); String firstName = results.getString("first_name"); double salary = results.getDouble("salary"); String department = results.getString("department"); System.out.printf("%s, %s, %.2f, %s\n", lastName, firstName, salary, department); } } catch (Exception exc) { exc.printStackTrace(); } } }
6305d1ff14beb58f34a2f4ed97cf4d0911f85758
cd7c8919c0c058716975f12cc0802f4f057adf34
/app/src/main/java/com/live/cunix/UpgradesActivity.java
4b8bfc943812c9fe66de1ffb113c6a8fd1104277
[]
no_license
itssai91/datingApp
564a355c55db222630fb6699ac432edb24aa6dda
ff2e3bf0672dc243739a44efc1c41e9f822ddee6
refs/heads/main
2023-02-09T22:08:55.046368
2020-12-28T14:24:27
2020-12-28T14:24:27
324,607,237
2
0
null
null
null
null
UTF-8
Java
false
false
2,275
java
package com.live.cunix; import android.content.Intent; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.appcompat.widget.Toolbar; import android.view.MenuItem; import com.live.cunix.common.ActivityBase; public class UpgradesActivity extends ActivityBase { Toolbar mToolbar; Fragment fragment; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_upgrades); mToolbar = findViewById(R.id.toolbar); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); if (savedInstanceState != null) { fragment = getSupportFragmentManager().getFragment(savedInstanceState, "currentFragment"); } else { fragment = new UpgradesFragment(); } FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.container_body, fragment) .commit(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); getSupportFragmentManager().putFragment(outState, "currentFragment", fragment); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); fragment.onActivityResult(requestCode, resultCode, data); } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { case android.R.id.home: { finish(); return true; } default: { return super.onOptionsItemSelected(item); } } } @Override public void onBackPressed() { // your code. finish(); } }
80aa84e398310dfac670525e80ef4718e3e7f9d3
b063ab697bf63613df10fa19dadb48bc0dbce2fd
/src/main/java/com/github/ejahns/WebElementFunction.java
aa7b9d89e602f067e0b584a373cd959773f64205
[]
no_license
ejahns/selenium-stateful
10bd68463265d3680d111b171458f671293b4604
1efbf3cc90da945759df698659f4d8db2b5ed92b
refs/heads/master
2021-01-19T22:55:42.813957
2017-06-05T22:09:50
2017-06-05T22:09:50
88,894,449
1
0
null
null
null
null
UTF-8
Java
false
false
226
java
package com.github.ejahns; import java.io.Serializable; import java.util.function.Function; import org.openqa.selenium.WebElement; public abstract class WebElementFunction implements Function<WebElement, Serializable> { }
54aa59167c42b231db82004ec0151c674e323f98
4bd826b3689838c924a366bde078dc2088216a2e
/src/main/java/com/angelchanquin/pharmacrm/config/WebConfigurer.java
190bb8b7f86531c3e366797889e7f5c1a399f1e2
[]
no_license
p-jacobo2012240/PharmaCRM
ec79a1da916b79ee9f1517c78926a3e6b6b3382a
78a716f4a2380fc12da26ebe3fd7e86f92186d3d
refs/heads/master
2020-09-03T23:42:41.669947
2018-01-28T19:08:38
2018-01-29T00:54:41
null
0
0
null
null
null
null
UTF-8
Java
false
false
8,720
java
package com.angelchanquin.pharmacrm.config; import io.github.jhipster.config.JHipsterConstants; import io.github.jhipster.config.JHipsterProperties; import io.github.jhipster.web.filter.CachingHttpHeadersFilter; import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.servlet.InstrumentedFilter; import com.codahale.metrics.servlets.MetricsServlet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.embedded.*; import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory; import io.undertow.UndertowOptions; import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.filter.CorsFilter; import org.springframework.http.MediaType; import java.io.File; import java.nio.file.Paths; import java.util.*; import javax.servlet.*; /** * Configuration of web application with Servlet 3.0 APIs. */ @Configuration public class WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { private final Logger log = LoggerFactory.getLogger(WebConfigurer.class); private final Environment env; private final JHipsterProperties jHipsterProperties; private MetricRegistry metricRegistry; public WebConfigurer(Environment env, JHipsterProperties jHipsterProperties) { this.env = env; this.jHipsterProperties = jHipsterProperties; } @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); } EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC); initMetrics(servletContext, disps); if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) { initCachingHttpHeadersFilter(servletContext, disps); } if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) { initH2Console(servletContext); } log.info("Web application fully configured"); } /** * Customize the Servlet engine: Mime types, the document root, the cache. */ @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=utf-8"); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=utf-8"); container.setMimeMappings(mappings); // When running in an IDE or with ./gradlew bootRun, set location of the static web assets. setLocationForStaticAssets(container); /* * Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/829256167700492288 * HTTP/2 requires HTTPS, so HTTP requests will fallback to HTTP/1.1. * See the JHipsterProperties class and your application-*.yml configuration files * for more information. */ if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) && container instanceof UndertowEmbeddedServletContainerFactory) { ((UndertowEmbeddedServletContainerFactory) container) .addBuilderCustomizers(builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true)); } } private void setLocationForStaticAssets(ConfigurableEmbeddedServletContainer container) { File root; String prefixPath = resolvePathPrefix(); root = new File(prefixPath + "build/www/"); if (root.exists() && root.isDirectory()) { container.setDocumentRoot(root); } } /** * Resolve path prefix to static resources. */ private String resolvePathPrefix() { String fullExecutablePath = this.getClass().getResource("").getPath(); String rootPath = Paths.get(".").toUri().normalize().getPath(); String extractedPath = fullExecutablePath.replace(rootPath, ""); int extractionEndIndex = extractedPath.indexOf("build/"); if (extractionEndIndex <= 0) { return ""; } return extractedPath.substring(0, extractionEndIndex); } /** * Initializes the caching HTTP Headers Filter. */ private void initCachingHttpHeadersFilter(ServletContext servletContext, EnumSet<DispatcherType> disps) { log.debug("Registering Caching HTTP Headers Filter"); FilterRegistration.Dynamic cachingHttpHeadersFilter = servletContext.addFilter("cachingHttpHeadersFilter", new CachingHttpHeadersFilter(jHipsterProperties)); cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*"); cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*"); cachingHttpHeadersFilter.setAsyncSupported(true); } /** * Initializes Metrics. */ private void initMetrics(ServletContext servletContext, EnumSet<DispatcherType> disps) { log.debug("Initializing Metrics registries"); servletContext.setAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE, metricRegistry); servletContext.setAttribute(MetricsServlet.METRICS_REGISTRY, metricRegistry); log.debug("Registering Metrics Filter"); FilterRegistration.Dynamic metricsFilter = servletContext.addFilter("webappMetricsFilter", new InstrumentedFilter()); metricsFilter.addMappingForUrlPatterns(disps, true, "/*"); metricsFilter.setAsyncSupported(true); log.debug("Registering Metrics Servlet"); ServletRegistration.Dynamic metricsAdminServlet = servletContext.addServlet("metricsServlet", new MetricsServlet()); metricsAdminServlet.addMapping("/management/metrics/*"); metricsAdminServlet.setAsyncSupported(true); metricsAdminServlet.setLoadOnStartup(2); } @Bean public CorsFilter corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = jHipsterProperties.getCors(); if (config.getAllowedOrigins() != null && !config.getAllowedOrigins().isEmpty()) { log.debug("Registering CORS filter"); source.registerCorsConfiguration("/api/**", config); source.registerCorsConfiguration("/management/**", config); source.registerCorsConfiguration("/v2/api-docs", config); } return new CorsFilter(source); } /** * Initializes H2 console. */ private void initH2Console(ServletContext servletContext) { log.debug("Initialize H2 console"); try { // We don't want to include H2 when we are packaging for the "prod" profile and won't // actually need it, so we have to load / invoke things at runtime through reflection. ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class<?> servletClass = Class.forName("org.h2.server.web.WebServlet", true, loader); Servlet servlet = (Servlet) servletClass.newInstance(); ServletRegistration.Dynamic h2ConsoleServlet = servletContext.addServlet("H2Console", servlet); h2ConsoleServlet.addMapping("/h2-console/*"); h2ConsoleServlet.setInitParameter("-properties", "src/main/resources/"); h2ConsoleServlet.setLoadOnStartup(1); } catch (ClassNotFoundException | LinkageError e) { throw new RuntimeException("Failed to load and initialize org.h2.server.web.WebServlet", e); } catch (IllegalAccessException | InstantiationException e) { throw new RuntimeException("Failed to instantiate org.h2.server.web.WebServlet", e); } } @Autowired(required = false) public void setMetricRegistry(MetricRegistry metricRegistry) { this.metricRegistry = metricRegistry; } }
7f1abb432b8c650039851dbf9bf4edc143ac4700
bdcbd183ef964e078ef0f0c1d103245462718fc3
/BeHereDesktop-master/src/main/java/GUIClasses/AffectationSectionsController.java
12743d53a39fa7e9076bd866abbbe4857caa6d5c
[ "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
OmarMokhfi/Behere
1af3c582cb0df8ef0b194a3a86a8c51ec0cf4153
5178f6b60824ea1515e1ae4da4057276fccecfc1
refs/heads/master
2021-06-06T21:57:28.047953
2019-08-13T18:05:59
2019-08-13T18:05:59
146,942,899
0
1
NOASSERTION
2021-06-04T01:02:36
2018-08-31T21:15:58
Java
UTF-8
Java
false
false
8,625
java
package GUIClasses; import StructureClasses.*; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.concurrent.Task; import javafx.concurrent.WorkerStateEvent; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.ChoiceBox; import javafx.scene.control.TableView; import FirebaseClasses.DbOperations; import java.net.URL; import java.util.ResourceBundle; public class AffectationSectionsController implements Initializable{ @FXML private ChoiceBox<Enseignant> enseignantsChoiceBox; @FXML private ChoiceBox<Cycle> cyclesChoiceBox; @FXML private ChoiceBox<Filliere> fillieresChoiceBox; @FXML private ChoiceBox<Specialite> specialitesChoiceBox; @FXML private ChoiceBox<Promo> promosChoiceBox; @FXML private ChoiceBox<Section> sectionsChoiceBox; @FXML private ChoiceBox<Module> modulesChoiceBox; @FXML private TableView<Section> sectionsTableView; public void initialize(URL location, ResourceBundle resources) { // remplissage des choiceBox de l'interface loadEnseignantsToChoiceBox(); loadCyclesToChoiceBox(); enseignantsChoiceBox.valueProperty().addListener(new ChangeListener<Enseignant>() { public void changed(ObservableValue<? extends Enseignant> observable, Enseignant oldValue, Enseignant newValue) { loadModulesToChoiceBox(); } }); cyclesChoiceBox.valueProperty().addListener(new ChangeListener<Cycle>() { public void changed(ObservableValue<? extends Cycle> observable, Cycle oldValue, Cycle newValue) { loadFillieresToChoiceBox(); } }); fillieresChoiceBox.valueProperty().addListener(new ChangeListener<Filliere>() { public void changed(ObservableValue<? extends Filliere> observable, Filliere oldValue, Filliere newValue) { if(fillieresChoiceBox.getSelectionModel().getSelectedItem()!=null) loadSpecialiteToChoiceBox(); } }); specialitesChoiceBox.valueProperty().addListener(new ChangeListener<Specialite>() { public void changed(ObservableValue<? extends Specialite> observable, Specialite oldValue, Specialite newValue) { if(specialitesChoiceBox.getSelectionModel().getSelectedItem()!=null) loadPromosToChoiceBox(); } }); promosChoiceBox.valueProperty().addListener(new ChangeListener<Promo>() { public void changed(ObservableValue<? extends Promo> observable, Promo oldValue, Promo newValue) { if(promosChoiceBox.getSelectionModel().getSelectedItem()!=null){ loadSectionsToChoiceBox(); } } }); modulesChoiceBox.valueProperty().addListener(new ChangeListener<Module>() { public void changed(ObservableValue<? extends Module> observable, Module oldValue, Module newValue) { loadEnseignantSectionsToTableView(); } }); // } private void loadEnseignantSectionsToTableView() { String idEnseignant = enseignantsChoiceBox.getSelectionModel().getSelectedItem().getId(); String idModule = modulesChoiceBox.getSelectionModel().getSelectedItem().getId(); String[] attributs = {"designation"}; String[] columnsTitle = {"Designation"}; String[] path = {DbOperations.ENSEIGNANT_MODULE.substring(1), idEnseignant, idModule, DbOperations.SECTIONS.substring(1)}; //String path = DbOperations.firebasePath(DbOperations.ENSEIGNANT_MODULE, idEnseignant, idModule, DbOperations.SECTIONS); GUIutils.loadChildrenToTableView(sectionsTableView, path, Structure.class, Section.class, attributs, columnsTitle); } private void loadEnseignantsToChoiceBox() { String[] path = {DbOperations.ENSEIGNANT_MODULE.substring(1)}; GUIutils.loadChildrenToChoiceBox(enseignantsChoiceBox, path, Structure.class, Enseignant.class); } private void loadCyclesToChoiceBox() { String[] path = {DbOperations.CYCLES.substring(1)}; GUIutils.loadChildrenToChoiceBox(cyclesChoiceBox, path, Structure.class, Cycle.class); } private void loadFillieresToChoiceBox() { sectionsChoiceBox.getItems().clear(); promosChoiceBox.getItems().clear(); sectionsChoiceBox.getItems().clear(); String cycleId = cyclesChoiceBox.getSelectionModel().getSelectedItem().getId(); //String path = DbOperations.firebasePath(DbOperations.CYCLES, cycleId); String[] path = {DbOperations.CYCLES.substring(1), cycleId}; GUIutils.loadChildrenToChoiceBox(fillieresChoiceBox, path, Cycle.class, Filliere.class); } private void loadSpecialiteToChoiceBox() { promosChoiceBox.getItems().clear(); sectionsChoiceBox.getItems().clear(); String idFilliere = fillieresChoiceBox.getSelectionModel().getSelectedItem().getId(); //String path = DbOperations.firebasePath(DbOperations.FILIERE_SPECIALITES, idFilliere); String[] path = {DbOperations.FILIERE_SPECIALITES.substring(1), idFilliere}; GUIutils.loadChildrenToChoiceBox(specialitesChoiceBox, path, Filliere.class, Specialite.class); } private void loadPromosToChoiceBox() { sectionsChoiceBox.getItems().clear(); String idCycle = cyclesChoiceBox.getSelectionModel().getSelectedItem().getId(); String idFilliere = fillieresChoiceBox.getSelectionModel().getSelectedItem().getId(); String[] path = {DbOperations.CYCLES.substring(1), idCycle, idFilliere}; //String path = DbOperations.firebasePath(DbOperations.CYCLES, idCycle, idFilliere); GUIutils.loadChildrenToChoiceBox(promosChoiceBox, path, Section.class, Promo.class); } private void loadSectionsToChoiceBox() { String idCycle = cyclesChoiceBox.getSelectionModel().getSelectedItem().getId(); String idFilliere = fillieresChoiceBox.getSelectionModel().getSelectedItem().getId(); String idPromo = promosChoiceBox.getSelectionModel().getSelectedItem().getId(); //String path = DbOperations.firebasePath(DbOperations.CYCLES, idCycle, idFilliere, idPromo); String[] path = {DbOperations.CYCLES.substring(1), idCycle, idFilliere, idPromo}; GUIutils.loadChildrenToChoiceBox(sectionsChoiceBox, path, Promo.class, Section.class); } private void loadModulesToChoiceBox() { sectionsTableView.getColumns().clear(); String idEnseignant =enseignantsChoiceBox.getSelectionModel().getSelectedItem().getId(); //String path = DbOperations.firebasePath(DbOperations.ENSEIGNANT_MODULE, idEnseignant); String[] path = {DbOperations.ENSEIGNANT_MODULE.substring(1), idEnseignant}; GUIutils.loadChildrenToChoiceBox(modulesChoiceBox, path, Enseignant.class, Module.class); } public void affecterSectionToEnseignant(ActionEvent actionEvent) { Enseignant enseignant = enseignantsChoiceBox.getSelectionModel().getSelectedItem(); Module module = modulesChoiceBox.getSelectionModel().getSelectedItem(); Section section = sectionsChoiceBox.getSelectionModel().getSelectedItem(); final Task<Void> affectationTask = affecterSectionDbTask(enseignant, module, section); affectationTask.setOnSucceeded(new EventHandler<WorkerStateEvent>() { public void handle(WorkerStateEvent event) { GUIutils.taskIndicatorForm.getDialogStage().close(); DbGestionController.actualiserLaBaseDeDonnee(); loadEnseignantSectionsToTableView(); } }); GUIutils.taskIndicatorForm.activateProgressBar(affectationTask); GUIutils.taskIndicatorForm.getDialogStage().show(); GUIutils.executor.execute(affectationTask); } private Task<Void> affecterSectionDbTask(final Enseignant enseignant, final Module module, final Section section) { final Task<Void> affectationTask = new Task<Void>() { @Override protected Void call() throws Exception { enseignant.affecterSection(module, section); DbGestionController.actualiserLaBaseDeDonnee(); loadEnseignantSectionsToTableView(); return null; } }; return affectationTask; } }
394a71877bb4bda0f64d892d2c844b46f4bb5db3
9e0451cde8c5d0647c91308af987d2c7581ef51e
/src/main/java/es/vicenteqs/ecommercetest/model/repository/PriceProductRepository.java
9033ac2798f1ee601439b134a27fa4b65b4890f9
[]
no_license
vicenteqs/ecommercetest
4d552da03b80ca1f7dd55c3888996716719609f3
976fa567056fa35b1144cb5b0095be55ec8e0eb4
refs/heads/master
2023-03-05T23:43:24.183798
2021-02-17T22:40:32
2021-02-17T22:40:32
339,874,138
0
0
null
null
null
null
UTF-8
Java
false
false
1,363
java
package es.vicenteqs.ecommercetest.model.repository; import java.util.Date; import java.util.List; import java.util.Optional; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.Query; import es.vicenteqs.ecommercetest.dto.PriceProductDto; import es.vicenteqs.ecommercetest.model.domain.PriceProduct; public interface PriceProductRepository extends BaseRepository<PriceProduct> { @Query("select new es.vicenteqs.ecommercetest.dto.PriceProductDto(pp.id, b.id, p.id, pp.startDate, pp.endDate, pp.priority, pp.price, pp.currency) " + "from PriceProduct pp " + "join pp.product p " + "join pp.brand b " + "where pp.startDate <= ?1 and pp.endDate >= ?1 and pp.product.id = ?2 and pp.brand.id = ?3 " + "order by pp.priority desc") List<PriceProductDto> findByBrandProductDate(Date date, Long productId, Long brandId, Pageable pageable); @Query("select pp " + "from PriceProduct pp " + "where pp.startDate <= ?1 and pp.endDate >= ?1 and pp.product.id = ?2 and pp.brand.id = ?3 " + "order by priority desc") List<PriceProduct> findByBrandProductDateNoDto(Date date, Long productId, Long brandId, Pageable pageable); Optional<PriceProduct> findFirstByStartDateLessThanEqualAndEndDateGreaterThanEqualAndProductIdAndBrandIdOrderByPriorityDesc( Date start, Date end, Long productId, Long brandId); }
007797935b902771373884538ad4545f81834545
635162ba17786e6f366f712cb8c31ffb42633554
/project/securities-portal/src/main/java/cn/hzstk/securities/sys/mapper/RoleMapper.java
396ab4175d10e56994838c817a1abcc8e4528db8
[]
no_license
macrogoal/wwh.stock
19aeed117f57acc1f22f3ed0caf34e481f00eb9c
8847a4bc6707dd881ea28133b621cf81431d845b
refs/heads/master
2020-04-17T05:51:47.771160
2018-04-04T06:21:15
2018-04-04T06:21:15
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,032
java
package cn.hzstk.securities.sys.mapper; import cn.hzstk.securities.sys.domain.Role; import org.apache.ibatis.annotations.*; import tk.mybatis.mapper.common.Mapper; import java.util.List; import java.util.Map; /** * Created by allenwc on 15/9/10. */ public interface RoleMapper extends Mapper<Role> { @Select("select * from sys_role where valid='1' and id in (select role_id from sys_r_user_role where valid='1' and user_id=#{value})") @Results(value = { @Result(property = "id", column = "ID"), @Result(property = "name", column = "NAME"), @Result(property = "code", column = "code"), @Result(property = "note", column = "note") }) public List<Role> getRolesByUser(Long userId); @Delete("DELETE FROM sys_r_user_role where user_id=#{userId}") public void deleteByUser(Long userId); @Insert("INSERT INTO sys_r_user_role(user_id,role_id,CREATE_DATE,CREATOR) VALUES (#{userId},#{roleId},NOW(),#{creator})") public void insertRoleUser(Map map); }
8e9ea9fdc161f77693dcb886fe3bf64091f422e3
0ab9b096276583a795ea962b14278da34f8997c4
/src/main/java/org/dependencytrack/util/HttpUtil.java
819e0aa1f738d849337006176f2dcbab5c16091c
[ "Apache-2.0" ]
permissive
Ramos-dev/dependency-track
e048b7006dad526b4f6832a307ef3e083721ffb9
01b86792fa03aae76cc800b8249b72c751b4c8ae
refs/heads/master
2022-10-05T18:04:51.530566
2019-01-05T03:28:45
2019-01-05T03:28:45
164,811,876
0
1
Apache-2.0
2022-09-15T09:03:07
2019-01-09T07:30:21
Java
UTF-8
Java
false
false
1,340
java
/* * This file is part of Dependency-Track. * * 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. * * Copyright (c) Steve Springett. All Rights Reserved. */ package org.dependencytrack.util; import java.util.Base64; import static org.apache.http.HttpHeaders.AUTHORIZATION; public class HttpUtil { /** * Private constructor. */ private HttpUtil() { } public static String basicAuthHeader(String username, String password) { return AUTHORIZATION + ": " + basicAuthHeader(username, password); } public static String basicAuthHeaderValue(String username, String password) { return "Basic " + Base64.getEncoder().encodeToString( String.format("%s:%s", username,password) .getBytes() ); } }
6800a4b7e731b358b92f5d005699b7ad7a13ba2a
324a9c058d5a5ddf16eb2ed79d40052259f43b39
/src/main/java/com/wzy/springboot_demo/enttiy/ServerSettings.java
9b2e6c6513259dd14e8ed98d3d516575851c9d81
[]
no_license
iswangzy/springboot_demo
478bdd73f5030cf79a8fc64de5e7ff10919cf94e
1c6ed05ff09139909589650669d8599f536737a7
refs/heads/master
2020-03-19T01:42:10.612032
2018-05-31T10:02:14
2018-05-31T10:02:14
135,565,706
0
0
null
null
null
null
UTF-8
Java
false
false
834
java
package com.wzy.springboot_demo.enttiy; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype.Component; /** * springboot_demo * 服务器配置 * * @author Wang Zhiyuan * @date 2018-05-31 17:13 **/ @Component @PropertySource({"classpath:application.properties"}) @ConfigurationProperties public class ServerSettings { private String name; private String domain; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDomain() { return domain; } public void setDomain(String domain) { this.domain = domain; } }
e5fbcbc8b68df7aedd9b01a3ae9550a1402b35b8
6baf1fe00541560788e78de5244ae17a7a2b375a
/hollywood/com.oculus.browser-base/sources/defpackage/C1501Yo0.java
2875d67a5ef93009541f5dd394bc32c5869db5dd
[]
no_license
phwd/quest-tracker
286e605644fc05f00f4904e51f73d77444a78003
3d46fbb467ba11bee5827f7cae7dfeabeb1fd2ba
refs/heads/main
2023-03-29T20:33:10.959529
2021-04-10T22:14:11
2021-04-10T22:14:11
357,185,040
4
2
null
2021-04-12T12:28:09
2021-04-12T12:28:08
null
UTF-8
Java
false
false
960
java
package defpackage; /* renamed from: Yo0 reason: default package and case insensitive filesystem */ /* compiled from: chromium-OculusBrowser.apk-stable-281887347 */ public final class C1501Yo0 extends AbstractC4340q31 { public static final CC[] b; public static final CC c; public C3093in0 d; static { CC[] ccArr = {new CC(16, 0)}; b = ccArr; c = ccArr[0]; } public C1501Yo0() { super(16, 0); } public static C1501Yo0 d(C2740gj0 gj0) { C4709sD sDVar = new C4709sD(gj0); sDVar.b(); try { C1501Yo0 yo0 = new C1501Yo0(sDVar.c(b).b); yo0.d = C3093in0.d(sDVar.s(8, true)); return yo0; } finally { sDVar.a(); } } @Override // defpackage.AbstractC4340q31 public final void a(C1648aL aLVar) { aLVar.x(c).i(this.d, 8, true); } public C1501Yo0(int i) { super(16, i); } }
4d6c7109b5f55dcbc128d38f8103c010c67b5a1c
7f9272d77f296966b431a8801c626ce970e7738f
/src/test/java/service/impl/BaseTest.java
549fb6763b78a7495bdf07a521db223adb0bc928
[]
no_license
hugooocl/pers_hugo_20180731_base_item
5130cdc1c7372d88bb29181d548e5963bc7f9c35
2ff3338932dfd136136bed24f5aaed6eeee324e4
refs/heads/master
2020-03-24T22:36:51.905758
2018-08-01T02:34:03
2018-08-01T02:34:03
143,094,180
0
0
null
null
null
null
UTF-8
Java
false
false
1,209
java
package service.impl; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import pojo.Base; import pojo.Item; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; public class BaseTest { private static EntityManagerFactory factory; @BeforeClass public static void init() { factory = Persistence.createEntityManagerFactory("customers");//持久化单元//datasource } @AfterClass public static void destory() { factory.close(); } @Test public void testAdd() throws Exception { EntityManager em = factory.createEntityManager();//Connection Base base1 = new Base("base1"); Item item1 = new Item("item1",1); Item item2 = new Item("item2",2); item1.setBase(base1); item2.setBase(base1); base1.getItems().add(item1); base1.getItems().add(item2); EntityTransaction tx = em.getTransaction(); tx.begin(); em.persist(base1); System.out.println(base1.toString()); tx.commit(); em.close(); } }
57c6835ef6d42420d7572508e8e251fb71c63fdd
cef574e01bfae9cdde1bb92763c06185aab74e3b
/app/src/main/java/com/igrs/callback/callbackapp/MyService.java
baabeaf381eb595eb59f2a9b01a4457f5af48514
[]
no_license
2164love/CallbackApp
792a4c6555d1034d180493fbef1f3abf31f80eb1
89427eaa38f0bf13915e2fc903c42c8d19af297d
refs/heads/master
2021-01-11T09:56:26.204682
2017-02-07T08:00:14
2017-02-07T08:00:14
81,152,576
0
0
null
null
null
null
UTF-8
Java
false
false
403
java
package com.igrs.callback.callbackapp; import android.app.Service; import android.content.Intent; import android.os.IBinder; public class MyService extends Service { public MyService() { } @Override public IBinder onBind(Intent intent) { // TODO: Return the communication channel to the service. throw new UnsupportedOperationException("Not yet implemented"); } }
a2cdff9d5c051bc9dda8f5cf574c808dd5fb4a3c
c0542546866385891c196b665d65a8bfa810f1a3
/decompiled/android/service/notification/IStatusBarNotificationHolder.java
254d0b9ae2ab486ca06cef694b2b33f80b558b7d
[]
no_license
auxor/android-wear-decompile
6892f3564d316b1f436757b72690864936dd1a82
eb8ad0d8003c5a3b5623918c79334290f143a2a8
refs/heads/master
2016-09-08T02:32:48.433800
2015-10-12T02:17:27
2015-10-12T02:19:32
42,517,868
5
1
null
null
null
null
UTF-8
Java
false
false
3,415
java
package android.service.notification; import android.os.Binder; import android.os.IBinder; import android.os.IInterface; import android.os.Parcel; import android.os.RemoteException; public interface IStatusBarNotificationHolder extends IInterface { public static abstract class Stub extends Binder implements IStatusBarNotificationHolder { private static final String DESCRIPTOR = "android.service.notification.IStatusBarNotificationHolder"; static final int TRANSACTION_get = 1; private static class Proxy implements IStatusBarNotificationHolder { private IBinder mRemote; Proxy(IBinder remote) { this.mRemote = remote; } public IBinder asBinder() { return this.mRemote; } public String getInterfaceDescriptor() { return Stub.DESCRIPTOR; } public StatusBarNotification get() throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { StatusBarNotification _result; _data.writeInterfaceToken(Stub.DESCRIPTOR); this.mRemote.transact(Stub.TRANSACTION_get, _data, _reply, 0); _reply.readException(); if (_reply.readInt() != 0) { _result = (StatusBarNotification) StatusBarNotification.CREATOR.createFromParcel(_reply); } else { _result = null; } _reply.recycle(); _data.recycle(); return _result; } catch (Throwable th) { _reply.recycle(); _data.recycle(); } } } public Stub() { attachInterface(this, DESCRIPTOR); } public static IStatusBarNotificationHolder asInterface(IBinder obj) { if (obj == null) { return null; } IInterface iin = obj.queryLocalInterface(DESCRIPTOR); if (iin == null || !(iin instanceof IStatusBarNotificationHolder)) { return new Proxy(obj); } return (IStatusBarNotificationHolder) iin; } public IBinder asBinder() { return this; } public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { switch (code) { case TRANSACTION_get /*1*/: data.enforceInterface(DESCRIPTOR); StatusBarNotification _result = get(); reply.writeNoException(); if (_result != null) { reply.writeInt(TRANSACTION_get); _result.writeToParcel(reply, TRANSACTION_get); return true; } reply.writeInt(0); return true; case IBinder.INTERFACE_TRANSACTION /*1598968902*/: reply.writeString(DESCRIPTOR); return true; default: return super.onTransact(code, data, reply, flags); } } } StatusBarNotification get() throws RemoteException; }
74ce5002856c28c99435d32e6219c0062fba2372
a0f8e4a59e874ba906ed39dbf8840d8b2353561a
/TryGank/app/src/main/java/com/gypsophila/trygank/business/gank/view/IGankView.java
839f47e9031d702741c330ac724ec4fa8b8b5bd4
[ "Apache-2.0" ]
permissive
AstroGypsophila/TryGank
2826ea028a3b94dead3e72f4066305f0bd237c98
cf0402af19bb2fdbd23a12b43d000025eea7c6df
refs/heads/master
2021-06-14T08:49:40.611274
2017-04-29T16:12:17
2017-04-29T16:12:17
65,220,786
56
3
null
null
null
null
UTF-8
Java
false
false
562
java
package com.gypsophila.trygank.business.gank.view; import com.gypsophila.trygank.entity.GankBean; import java.util.List; /** * Description : * Author : AstroGypsophila * GitHub : https://github.com/AstroGypsophila * Date : 2016/9/28 */ public interface IGankView { //加载过程显示进度反馈 void showProgress(); void addNews(List<GankBean> gankBeanList); void hideProgress(); void showLoadFailMsg(String msg); void showFilteringPopUpMenu(); void showNoData(boolean shown); void showMessage(String msg); }
a53ce1f923ecef5523c986f16e3ec81f800ce302
394e7605f3bd67f95b8e565f347777781ac1ae5d
/technical-service/src/main/java/com/upgrad/technical/service/business/AdminService.java
7ee5912df0e80639a5ecbc9f27435fbce98e4a02
[]
no_license
AbhishekSharma011/imagehosting
3c944a62939945936b252dce0c884f2a4bb4f5b0
796d0418171551f659074981b3225eb11917fb22
refs/heads/master
2023-04-30T19:09:15.389114
2021-05-25T09:47:21
2021-05-25T09:47:21
370,640,973
0
0
null
null
null
null
UTF-8
Java
false
false
3,021
java
package com.upgrad.technical.service.business; import com.upgrad.technical.service.dao.ImageDao; import com.upgrad.technical.service.dao.UserDao; import com.upgrad.technical.service.entity.ImageEntity; import com.upgrad.technical.service.entity.UserAuthTokenEntity; import com.upgrad.technical.service.exception.ImageNotFoundException; import com.upgrad.technical.service.exception.UnauthorizedException; import com.upgrad.technical.service.exception.UserNotSignedInException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; import java.util.Comparator; @Service public class AdminService { @Autowired private ImageDao imageDao; public ImageEntity getImage(final String imageUuid, final String authorization) throws ImageNotFoundException, UnauthorizedException, UserNotSignedInException { UserAuthTokenEntity userAuthTokenEntity = imageDao.getUserAuthToken(authorization); if(userAuthTokenEntity == null) throw new UserNotSignedInException("\"USR-001","You are not Signed in, sign in first to get the details"); String role = userAuthTokenEntity.getUser().getRole(); if(!role.equals("admin")) { throw new UnauthorizedException("ATH-001", "UNAUTHORIZED Access, Entered user is an admin."); } ImageEntity findImage = imageDao.getImage(imageUuid); if(findImage == null) throw new ImageNotFoundException("IMG-001", "Image with Uuid not found"); return findImage; } @Transactional(propagation = Propagation.REQUIRED) public ImageEntity updateImage(final ImageEntity imageEntity, final String authorization) throws ImageNotFoundException, UnauthorizedException, UserNotSignedInException { UserAuthTokenEntity userAuthTokenEntity = imageDao.getUserAuthToken(authorization); if(userAuthTokenEntity == null) throw new UserNotSignedInException("USR-001", "You are not Signed in, sign in first to get the details"); String role = userAuthTokenEntity.getUser().getRole(); if(!role.equals("admin")) throw new UnauthorizedException("ATH-001", "UNAUTHORIZED Access, Entered user is not an admin."); ImageEntity updateImage = imageDao.getImageById(imageEntity.getId()); if(updateImage == null) throw new ImageNotFoundException("IMG-001", "Image with Id not found."); updateImage.setImage(imageEntity.getImage()); updateImage.setStatus(imageEntity.getStatus()); updateImage.setDescription(imageEntity.getDescription()); updateImage.setName(imageEntity.getName()); imageDao.updateImage(updateImage); return updateImage; } }
90f34b302e7ab08609f85acc05fb39771b6eb655
b1178991eb84069f2a652bb7cb2f5957c39a9778
/build/app/generated/not_namespaced_r_class_sources/release/r/com/nik/performance/film_app_getx/R.java
12152794398d22dc1d1630f7f21a6fcde15eaba1
[]
no_license
klnfreedom/popular_films_getx
9b0344378994a7728c4a995cb202bfd7e6236b3b
a6b218d7e70f863873cfb9540858a7eaf7441a26
refs/heads/main
2023-01-31T21:49:52.043330
2020-12-15T15:59:59
2020-12-15T15:59:59
321,406,958
0
0
null
null
null
null
UTF-8
Java
false
false
41,436
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.nik.performance.film_app_getx; public final class R { public static final class attr { /** * Alpha multiplier applied to the base color. * <p>May be a floating point value, such as "<code>1.2</code>". */ public static final int alpha=0x7f010000; /** * The reference to the font file to be used. This should be a file in the res/font folder * and should therefore have an R reference value. E.g. @font/myfont * <p>May be a reference to another resource, in the form * "<code>@[+][<i>package</i>:]<i>type</i>/<i>name</i></code>" or a theme * attribute in the form * "<code>?[<i>package</i>:]<i>type</i>/<i>name</i></code>". */ public static final int font=0x7f010001; /** * The authority of the Font Provider to be used for the request. * <p>May be a string value, using '\\;' to escape characters such as * '\\n' or '\\uxxxx' for a unicode character; */ public static final int fontProviderAuthority=0x7f010002; /** * The sets of hashes for the certificates the provider should be signed with. This is * used to verify the identity of the provider, and is only required if the provider is not * part of the system image. This value may point to one list or a list of lists, where each * individual list represents one collection of signature hashes. Refer to your font provider's * documentation for these values. * <p>May be a reference to another resource, in the form * "<code>@[+][<i>package</i>:]<i>type</i>/<i>name</i></code>" or a theme * attribute in the form * "<code>?[<i>package</i>:]<i>type</i>/<i>name</i></code>". */ public static final int fontProviderCerts=0x7f010003; /** * The strategy to be used when fetching font data from a font provider in XML layouts. * This attribute is ignored when the resource is loaded from code, as it is equivalent to the * choice of API between {@link * androidx.core.content.res.ResourcesCompat#getFont(Context, int)} (blocking) and * {@link * androidx.core.content.res.ResourcesCompat#getFont(Context, int, FontCallback, Handler)} * (async). * <p>Must be one of the following constant values.</p> * <table> * <colgroup align="left" /> * <colgroup align="left" /> * <colgroup align="left" /> * <tr><th>Constant</th><th>Value</th><th>Description</th></tr> * <tr><td>async</td><td>1</td><td>The async font fetch works as follows. * First, check the local cache, then if the requeted font is not cached, trigger a * request the font and continue with layout inflation. Once the font fetch succeeds, the * target text view will be refreshed with the downloaded font data. The * fontProviderFetchTimeout will be ignored if async loading is specified.</td></tr> * <tr><td>blocking</td><td>0</td><td>The blocking font fetch works as follows. * First, check the local cache, then if the requested font is not cached, request the * font from the provider and wait until it is finished. You can change the length of * the timeout by modifying fontProviderFetchTimeout. If the timeout happens, the * default typeface will be used instead.</td></tr> * </table> */ public static final int fontProviderFetchStrategy=0x7f010004; /** * The length of the timeout during fetching. * <p>May be an integer value, such as "<code>100</code>". * <p>Must be one of the following constant values.</p> * <table> * <colgroup align="left" /> * <colgroup align="left" /> * <colgroup align="left" /> * <tr><th>Constant</th><th>Value</th><th>Description</th></tr> * <tr><td>forever</td><td>ffffffff</td><td>A special value for the timeout. In this case, the blocking font fetching will not * timeout and wait until a reply is received from the font provider.</td></tr> * </table> */ public static final int fontProviderFetchTimeout=0x7f010005; /** * The package for the Font Provider to be used for the request. This is used to verify * the identity of the provider. * <p>May be a string value, using '\\;' to escape characters such as * '\\n' or '\\uxxxx' for a unicode character; */ public static final int fontProviderPackage=0x7f010006; /** * The query to be sent over to the provider. Refer to your font provider's documentation * on the format of this string. * <p>May be a string value, using '\\;' to escape characters such as * '\\n' or '\\uxxxx' for a unicode character; */ public static final int fontProviderQuery=0x7f010007; /** * The style of the given font file. This will be used when the font is being loaded into * the font stack and will override any style information in the font's header tables. If * unspecified, the value in the font's header tables will be used. * <p>Must be one of the following constant values.</p> * <table> * <colgroup align="left" /> * <colgroup align="left" /> * <colgroup align="left" /> * <tr><th>Constant</th><th>Value</th><th>Description</th></tr> * <tr><td>italic</td><td>1</td><td></td></tr> * <tr><td>normal</td><td>0</td><td></td></tr> * </table> */ public static final int fontStyle=0x7f010008; /** * The variation settings to be applied to the font. The string should be in the following * format: "'tag1' value1, 'tag2' value2, ...". If the default variation settings should be * used, or the font used does not support variation settings, this attribute needs not be * specified. * <p>May be a string value, using '\\;' to escape characters such as * '\\n' or '\\uxxxx' for a unicode character; */ public static final int fontVariationSettings=0x7f010009; /** * The weight of the given font file. This will be used when the font is being loaded into * the font stack and will override any weight information in the font's header tables. Must * be a positive number, a multiple of 100, and between 100 and 900, inclusive. The most * common values are 400 for regular weight and 700 for bold weight. If unspecified, the value * in the font's header tables will be used. * <p>May be an integer value, such as "<code>100</code>". */ public static final int fontWeight=0x7f01000a; /** * The index of the font in the tcc font file. If the font file referenced is not in the * tcc format, this attribute needs not be specified. * <p>May be an integer value, such as "<code>100</code>". */ public static final int ttcIndex=0x7f01000b; } public static final class color { public static final int notification_action_color_filter=0x7f020000; public static final int notification_icon_bg_color=0x7f020001; public static final int ripple_material_light=0x7f020002; public static final int secondary_text_default_material_light=0x7f020003; } public static final class dimen { public static final int compat_button_inset_horizontal_material=0x7f030000; public static final int compat_button_inset_vertical_material=0x7f030001; public static final int compat_button_padding_horizontal_material=0x7f030002; public static final int compat_button_padding_vertical_material=0x7f030003; public static final int compat_control_corner_material=0x7f030004; public static final int compat_notification_large_icon_max_height=0x7f030005; public static final int compat_notification_large_icon_max_width=0x7f030006; public static final int notification_action_icon_size=0x7f030007; public static final int notification_action_text_size=0x7f030008; public static final int notification_big_circle_margin=0x7f030009; public static final int notification_content_margin_start=0x7f03000a; public static final int notification_large_icon_height=0x7f03000b; public static final int notification_large_icon_width=0x7f03000c; public static final int notification_main_column_padding_top=0x7f03000d; public static final int notification_media_narrow_margin=0x7f03000e; public static final int notification_right_icon_size=0x7f03000f; public static final int notification_right_side_padding_top=0x7f030010; public static final int notification_small_icon_background_padding=0x7f030011; public static final int notification_small_icon_size_as_large=0x7f030012; public static final int notification_subtext_size=0x7f030013; public static final int notification_top_pad=0x7f030014; public static final int notification_top_pad_large_text=0x7f030015; } public static final class drawable { public static final int launch_background=0x7f040000; public static final int notification_action_background=0x7f040001; public static final int notification_bg=0x7f040002; public static final int notification_bg_low=0x7f040003; public static final int notification_bg_low_normal=0x7f040004; public static final int notification_bg_low_pressed=0x7f040005; public static final int notification_bg_normal=0x7f040006; public static final int notification_bg_normal_pressed=0x7f040007; public static final int notification_icon_background=0x7f040008; public static final int notification_template_icon_bg=0x7f040009; public static final int notification_template_icon_low_bg=0x7f04000a; public static final int notification_tile_bg=0x7f04000b; public static final int notify_panel_notification_icon_bg=0x7f04000c; } public static final class id { public static final int accessibility_action_clickable_span=0x7f050000; public static final int accessibility_custom_action_0=0x7f050001; public static final int accessibility_custom_action_1=0x7f050002; public static final int accessibility_custom_action_10=0x7f050003; public static final int accessibility_custom_action_11=0x7f050004; public static final int accessibility_custom_action_12=0x7f050005; public static final int accessibility_custom_action_13=0x7f050006; public static final int accessibility_custom_action_14=0x7f050007; public static final int accessibility_custom_action_15=0x7f050008; public static final int accessibility_custom_action_16=0x7f050009; public static final int accessibility_custom_action_17=0x7f05000a; public static final int accessibility_custom_action_18=0x7f05000b; public static final int accessibility_custom_action_19=0x7f05000c; public static final int accessibility_custom_action_2=0x7f05000d; public static final int accessibility_custom_action_20=0x7f05000e; public static final int accessibility_custom_action_21=0x7f05000f; public static final int accessibility_custom_action_22=0x7f050010; public static final int accessibility_custom_action_23=0x7f050011; public static final int accessibility_custom_action_24=0x7f050012; public static final int accessibility_custom_action_25=0x7f050013; public static final int accessibility_custom_action_26=0x7f050014; public static final int accessibility_custom_action_27=0x7f050015; public static final int accessibility_custom_action_28=0x7f050016; public static final int accessibility_custom_action_29=0x7f050017; public static final int accessibility_custom_action_3=0x7f050018; public static final int accessibility_custom_action_30=0x7f050019; public static final int accessibility_custom_action_31=0x7f05001a; public static final int accessibility_custom_action_4=0x7f05001b; public static final int accessibility_custom_action_5=0x7f05001c; public static final int accessibility_custom_action_6=0x7f05001d; public static final int accessibility_custom_action_7=0x7f05001e; public static final int accessibility_custom_action_8=0x7f05001f; public static final int accessibility_custom_action_9=0x7f050020; public static final int action_container=0x7f050021; public static final int action_divider=0x7f050022; public static final int action_image=0x7f050023; public static final int action_text=0x7f050024; public static final int actions=0x7f050025; public static final int async=0x7f050026; public static final int blocking=0x7f050027; public static final int chronometer=0x7f050028; public static final int dialog_button=0x7f050029; public static final int forever=0x7f05002a; public static final int icon=0x7f05002b; public static final int icon_group=0x7f05002c; public static final int info=0x7f05002d; public static final int italic=0x7f05002e; public static final int line1=0x7f05002f; public static final int line3=0x7f050030; public static final int normal=0x7f050031; public static final int notification_background=0x7f050032; public static final int notification_main_column=0x7f050033; public static final int notification_main_column_container=0x7f050034; public static final int right_icon=0x7f050035; public static final int right_side=0x7f050036; public static final int tag_accessibility_actions=0x7f050037; public static final int tag_accessibility_clickable_spans=0x7f050038; public static final int tag_accessibility_heading=0x7f050039; public static final int tag_accessibility_pane_title=0x7f05003a; public static final int tag_screen_reader_focusable=0x7f05003b; public static final int tag_transition_group=0x7f05003c; public static final int tag_unhandled_key_event_manager=0x7f05003d; public static final int tag_unhandled_key_listeners=0x7f05003e; public static final int text=0x7f05003f; public static final int text2=0x7f050040; public static final int time=0x7f050041; public static final int title=0x7f050042; } public static final class integer { public static final int status_bar_notification_info_maxnum=0x7f060000; } public static final class layout { public static final int custom_dialog=0x7f070000; public static final int notification_action=0x7f070001; public static final int notification_action_tombstone=0x7f070002; public static final int notification_template_custom_big=0x7f070003; public static final int notification_template_icon_group=0x7f070004; public static final int notification_template_part_chronometer=0x7f070005; public static final int notification_template_part_time=0x7f070006; } public static final class mipmap { public static final int ic_launcher=0x7f080000; public static final int launcher_icon=0x7f080001; } public static final class string { public static final int status_bar_notification_info_overflow=0x7f090000; } public static final class style { public static final int LaunchTheme=0x7f0a0000; public static final int NormalTheme=0x7f0a0001; public static final int TextAppearance_Compat_Notification=0x7f0a0002; public static final int TextAppearance_Compat_Notification_Info=0x7f0a0003; public static final int TextAppearance_Compat_Notification_Line2=0x7f0a0004; public static final int TextAppearance_Compat_Notification_Time=0x7f0a0005; public static final int TextAppearance_Compat_Notification_Title=0x7f0a0006; public static final int Widget_Compat_NotificationActionContainer=0x7f0a0007; public static final int Widget_Compat_NotificationActionText=0x7f0a0008; } public static final class styleable { /** * Attributes that can be used with a ColorStateListItem. * <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 #ColorStateListItem_android_color android:color}</code></td><td></td></tr> * <tr><td><code>{@link #ColorStateListItem_android_alpha android:alpha}</code></td><td></td></tr> * <tr><td><code>{@link #ColorStateListItem_alpha com.nik.performance.film_app_getx:alpha}</code></td><td>Alpha multiplier applied to the base color.</td></tr> * </table> * @see #ColorStateListItem_android_color * @see #ColorStateListItem_android_alpha * @see #ColorStateListItem_alpha */ public static final int[] ColorStateListItem={ 0x010101a5, 0x0101031f, 0x7f010000 }; /** * <p> * @attr description * Base color for this state. * * <p>May be a color value, in the form of "<code>#<i>rgb</i></code>", * "<code>#<i>argb</i></code>", "<code>#<i>rrggbb</i></code>", or * "<code>#<i>aarrggbb</i></code>". * * @attr name android:color */ public static final int ColorStateListItem_android_color=0; /** * <p>This symbol is the offset where the {@link android.R.attr#alpha} * attribute's value can be found in the {@link #ColorStateListItem} array. * * <p>May be a floating point value, such as "<code>1.2</code>". * * @attr name android:alpha */ public static final int ColorStateListItem_android_alpha=1; /** * <p> * @attr description * Alpha multiplier applied to the base color. * * <p>May be a floating point value, such as "<code>1.2</code>". * * @attr name com.nik.performance.film_app_getx:alpha */ public static final int ColorStateListItem_alpha=2; /** * Attributes that can be used with a FontFamily. * <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 #FontFamily_fontProviderAuthority com.nik.performance.film_app_getx:fontProviderAuthority}</code></td><td>The authority of the Font Provider to be used for the request.</td></tr> * <tr><td><code>{@link #FontFamily_fontProviderCerts com.nik.performance.film_app_getx:fontProviderCerts}</code></td><td>The sets of hashes for the certificates the provider should be signed with.</td></tr> * <tr><td><code>{@link #FontFamily_fontProviderFetchStrategy com.nik.performance.film_app_getx:fontProviderFetchStrategy}</code></td><td>The strategy to be used when fetching font data from a font provider in XML layouts.</td></tr> * <tr><td><code>{@link #FontFamily_fontProviderFetchTimeout com.nik.performance.film_app_getx:fontProviderFetchTimeout}</code></td><td>The length of the timeout during fetching.</td></tr> * <tr><td><code>{@link #FontFamily_fontProviderPackage com.nik.performance.film_app_getx:fontProviderPackage}</code></td><td>The package for the Font Provider to be used for the request.</td></tr> * <tr><td><code>{@link #FontFamily_fontProviderQuery com.nik.performance.film_app_getx:fontProviderQuery}</code></td><td>The query to be sent over to the provider.</td></tr> * </table> * @see #FontFamily_fontProviderAuthority * @see #FontFamily_fontProviderCerts * @see #FontFamily_fontProviderFetchStrategy * @see #FontFamily_fontProviderFetchTimeout * @see #FontFamily_fontProviderPackage * @see #FontFamily_fontProviderQuery */ public static final int[] FontFamily={ 0x7f010002, 0x7f010003, 0x7f010004, 0x7f010005, 0x7f010006, 0x7f010007 }; /** * <p> * @attr description * The authority of the Font Provider to be used for the request. * * <p>May be a string value, using '\\;' to escape characters such as * '\\n' or '\\uxxxx' for a unicode character; * * @attr name com.nik.performance.film_app_getx:fontProviderAuthority */ public static final int FontFamily_fontProviderAuthority=0; /** * <p> * @attr description * The sets of hashes for the certificates the provider should be signed with. This is * used to verify the identity of the provider, and is only required if the provider is not * part of the system image. This value may point to one list or a list of lists, where each * individual list represents one collection of signature hashes. Refer to your font provider's * documentation for these values. * * <p>May be a reference to another resource, in the form * "<code>@[+][<i>package</i>:]<i>type</i>/<i>name</i></code>" or a theme * attribute in the form * "<code>?[<i>package</i>:]<i>type</i>/<i>name</i></code>". * * @attr name com.nik.performance.film_app_getx:fontProviderCerts */ public static final int FontFamily_fontProviderCerts=1; /** * <p> * @attr description * The strategy to be used when fetching font data from a font provider in XML layouts. * This attribute is ignored when the resource is loaded from code, as it is equivalent to the * choice of API between {@link * androidx.core.content.res.ResourcesCompat#getFont(Context, int)} (blocking) and * {@link * androidx.core.content.res.ResourcesCompat#getFont(Context, int, FontCallback, Handler)} * (async). * * <p>Must be one of the following constant values.</p> * <table> * <colgroup align="left" /> * <colgroup align="left" /> * <colgroup align="left" /> * <tr><th>Constant</th><th>Value</th><th>Description</th></tr> * <tr><td>async</td><td>1</td><td>The async font fetch works as follows. * First, check the local cache, then if the requeted font is not cached, trigger a * request the font and continue with layout inflation. Once the font fetch succeeds, the * target text view will be refreshed with the downloaded font data. The * fontProviderFetchTimeout will be ignored if async loading is specified.</td></tr> * <tr><td>blocking</td><td>0</td><td>The blocking font fetch works as follows. * First, check the local cache, then if the requested font is not cached, request the * font from the provider and wait until it is finished. You can change the length of * the timeout by modifying fontProviderFetchTimeout. If the timeout happens, the * default typeface will be used instead.</td></tr> * </table> * * @attr name com.nik.performance.film_app_getx:fontProviderFetchStrategy */ public static final int FontFamily_fontProviderFetchStrategy=2; /** * <p> * @attr description * The length of the timeout during fetching. * * <p>May be an integer value, such as "<code>100</code>". * <p>Must be one of the following constant values.</p> * <table> * <colgroup align="left" /> * <colgroup align="left" /> * <colgroup align="left" /> * <tr><th>Constant</th><th>Value</th><th>Description</th></tr> * <tr><td>forever</td><td>ffffffff</td><td>A special value for the timeout. In this case, the blocking font fetching will not * timeout and wait until a reply is received from the font provider.</td></tr> * </table> * * @attr name com.nik.performance.film_app_getx:fontProviderFetchTimeout */ public static final int FontFamily_fontProviderFetchTimeout=3; /** * <p> * @attr description * The package for the Font Provider to be used for the request. This is used to verify * the identity of the provider. * * <p>May be a string value, using '\\;' to escape characters such as * '\\n' or '\\uxxxx' for a unicode character; * * @attr name com.nik.performance.film_app_getx:fontProviderPackage */ public static final int FontFamily_fontProviderPackage=4; /** * <p> * @attr description * The query to be sent over to the provider. Refer to your font provider's documentation * on the format of this string. * * <p>May be a string value, using '\\;' to escape characters such as * '\\n' or '\\uxxxx' for a unicode character; * * @attr name com.nik.performance.film_app_getx:fontProviderQuery */ public static final int FontFamily_fontProviderQuery=5; /** * Attributes that can be used with a FontFamilyFont. * <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 #FontFamilyFont_android_font android:font}</code></td><td></td></tr> * <tr><td><code>{@link #FontFamilyFont_android_fontWeight android:fontWeight}</code></td><td></td></tr> * <tr><td><code>{@link #FontFamilyFont_android_fontStyle android:fontStyle}</code></td><td></td></tr> * <tr><td><code>{@link #FontFamilyFont_android_ttcIndex android:ttcIndex}</code></td><td></td></tr> * <tr><td><code>{@link #FontFamilyFont_android_fontVariationSettings android:fontVariationSettings}</code></td><td></td></tr> * <tr><td><code>{@link #FontFamilyFont_font com.nik.performance.film_app_getx:font}</code></td><td>The reference to the font file to be used.</td></tr> * <tr><td><code>{@link #FontFamilyFont_fontStyle com.nik.performance.film_app_getx:fontStyle}</code></td><td>The style of the given font file.</td></tr> * <tr><td><code>{@link #FontFamilyFont_fontVariationSettings com.nik.performance.film_app_getx:fontVariationSettings}</code></td><td>The variation settings to be applied to the font.</td></tr> * <tr><td><code>{@link #FontFamilyFont_fontWeight com.nik.performance.film_app_getx:fontWeight}</code></td><td>The weight of the given font file.</td></tr> * <tr><td><code>{@link #FontFamilyFont_ttcIndex com.nik.performance.film_app_getx:ttcIndex}</code></td><td>The index of the font in the tcc font file.</td></tr> * </table> * @see #FontFamilyFont_android_font * @see #FontFamilyFont_android_fontWeight * @see #FontFamilyFont_android_fontStyle * @see #FontFamilyFont_android_ttcIndex * @see #FontFamilyFont_android_fontVariationSettings * @see #FontFamilyFont_font * @see #FontFamilyFont_fontStyle * @see #FontFamilyFont_fontVariationSettings * @see #FontFamilyFont_fontWeight * @see #FontFamilyFont_ttcIndex */ public static final int[] FontFamilyFont={ 0x01010532, 0x01010533, 0x0101053f, 0x0101056f, 0x01010570, 0x7f010001, 0x7f010008, 0x7f010009, 0x7f01000a, 0x7f01000b }; /** * <p>This symbol is the offset where the {@link android.R.attr#font} * attribute's value can be found in the {@link #FontFamilyFont} array. * * <p>May be a reference to another resource, in the form * "<code>@[+][<i>package</i>:]<i>type</i>/<i>name</i></code>" or a theme * attribute in the form * "<code>?[<i>package</i>:]<i>type</i>/<i>name</i></code>". * * @attr name android:font */ public static final int FontFamilyFont_android_font=0; /** * <p>This symbol is the offset where the {@link android.R.attr#fontWeight} * attribute's value can be found in the {@link #FontFamilyFont} array. * * <p>May be an integer value, such as "<code>100</code>". * * @attr name android:fontWeight */ public static final int FontFamilyFont_android_fontWeight=1; /** * <p> * @attr description * References to the framework attrs * * <p>Must be one of the following constant values.</p> * <table> * <colgroup align="left" /> * <colgroup align="left" /> * <colgroup align="left" /> * <tr><th>Constant</th><th>Value</th><th>Description</th></tr> * <tr><td>italic</td><td>1</td><td></td></tr> * <tr><td>normal</td><td>0</td><td></td></tr> * </table> * * @attr name android:fontStyle */ public static final int FontFamilyFont_android_fontStyle=2; /** * <p>This symbol is the offset where the {@link android.R.attr#ttcIndex} * attribute's value can be found in the {@link #FontFamilyFont} array. * * <p>May be an integer value, such as "<code>100</code>". * * @attr name android:ttcIndex */ public static final int FontFamilyFont_android_ttcIndex=3; /** * <p>This symbol is the offset where the {@link android.R.attr#fontVariationSettings} * attribute's value can be found in the {@link #FontFamilyFont} array. * * <p>May be a string value, using '\\;' to escape characters such as * '\\n' or '\\uxxxx' for a unicode character; * * @attr name android:fontVariationSettings */ public static final int FontFamilyFont_android_fontVariationSettings=4; /** * <p> * @attr description * The reference to the font file to be used. This should be a file in the res/font folder * and should therefore have an R reference value. E.g. @font/myfont * * <p>May be a reference to another resource, in the form * "<code>@[+][<i>package</i>:]<i>type</i>/<i>name</i></code>" or a theme * attribute in the form * "<code>?[<i>package</i>:]<i>type</i>/<i>name</i></code>". * * @attr name com.nik.performance.film_app_getx:font */ public static final int FontFamilyFont_font=5; /** * <p> * @attr description * The style of the given font file. This will be used when the font is being loaded into * the font stack and will override any style information in the font's header tables. If * unspecified, the value in the font's header tables will be used. * * <p>Must be one of the following constant values.</p> * <table> * <colgroup align="left" /> * <colgroup align="left" /> * <colgroup align="left" /> * <tr><th>Constant</th><th>Value</th><th>Description</th></tr> * <tr><td>italic</td><td>1</td><td></td></tr> * <tr><td>normal</td><td>0</td><td></td></tr> * </table> * * @attr name com.nik.performance.film_app_getx:fontStyle */ public static final int FontFamilyFont_fontStyle=6; /** * <p> * @attr description * The variation settings to be applied to the font. The string should be in the following * format: "'tag1' value1, 'tag2' value2, ...". If the default variation settings should be * used, or the font used does not support variation settings, this attribute needs not be * specified. * * <p>May be a string value, using '\\;' to escape characters such as * '\\n' or '\\uxxxx' for a unicode character; * * @attr name com.nik.performance.film_app_getx:fontVariationSettings */ public static final int FontFamilyFont_fontVariationSettings=7; /** * <p> * @attr description * The weight of the given font file. This will be used when the font is being loaded into * the font stack and will override any weight information in the font's header tables. Must * be a positive number, a multiple of 100, and between 100 and 900, inclusive. The most * common values are 400 for regular weight and 700 for bold weight. If unspecified, the value * in the font's header tables will be used. * * <p>May be an integer value, such as "<code>100</code>". * * @attr name com.nik.performance.film_app_getx:fontWeight */ public static final int FontFamilyFont_fontWeight=8; /** * <p> * @attr description * The index of the font in the tcc font file. If the font file referenced is not in the * tcc format, this attribute needs not be specified. * * <p>May be an integer value, such as "<code>100</code>". * * @attr name com.nik.performance.film_app_getx:ttcIndex */ public static final int FontFamilyFont_ttcIndex=9; /** * Attributes that can be used with a GradientColor. * <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 #GradientColor_android_startColor android:startColor}</code></td><td></td></tr> * <tr><td><code>{@link #GradientColor_android_endColor android:endColor}</code></td><td></td></tr> * <tr><td><code>{@link #GradientColor_android_type android:type}</code></td><td></td></tr> * <tr><td><code>{@link #GradientColor_android_centerX android:centerX}</code></td><td></td></tr> * <tr><td><code>{@link #GradientColor_android_centerY android:centerY}</code></td><td></td></tr> * <tr><td><code>{@link #GradientColor_android_gradientRadius android:gradientRadius}</code></td><td></td></tr> * <tr><td><code>{@link #GradientColor_android_tileMode android:tileMode}</code></td><td></td></tr> * <tr><td><code>{@link #GradientColor_android_centerColor android:centerColor}</code></td><td></td></tr> * <tr><td><code>{@link #GradientColor_android_startX android:startX}</code></td><td></td></tr> * <tr><td><code>{@link #GradientColor_android_startY android:startY}</code></td><td></td></tr> * <tr><td><code>{@link #GradientColor_android_endX android:endX}</code></td><td></td></tr> * <tr><td><code>{@link #GradientColor_android_endY android:endY}</code></td><td></td></tr> * </table> * @see #GradientColor_android_startColor * @see #GradientColor_android_endColor * @see #GradientColor_android_type * @see #GradientColor_android_centerX * @see #GradientColor_android_centerY * @see #GradientColor_android_gradientRadius * @see #GradientColor_android_tileMode * @see #GradientColor_android_centerColor * @see #GradientColor_android_startX * @see #GradientColor_android_startY * @see #GradientColor_android_endX * @see #GradientColor_android_endY */ public static final int[] GradientColor={ 0x0101019d, 0x0101019e, 0x010101a1, 0x010101a2, 0x010101a3, 0x010101a4, 0x01010201, 0x0101020b, 0x01010510, 0x01010511, 0x01010512, 0x01010513 }; /** * <p> * @attr description * Start color of the gradient. * * <p>May be a color value, in the form of "<code>#<i>rgb</i></code>", * "<code>#<i>argb</i></code>", "<code>#<i>rrggbb</i></code>", or * "<code>#<i>aarrggbb</i></code>". * * @attr name android:startColor */ public static final int GradientColor_android_startColor=0; /** * <p> * @attr description * End color of the gradient. * * <p>May be a color value, in the form of "<code>#<i>rgb</i></code>", * "<code>#<i>argb</i></code>", "<code>#<i>rrggbb</i></code>", or * "<code>#<i>aarrggbb</i></code>". * * @attr name android:endColor */ public static final int GradientColor_android_endColor=1; /** * <p> * @attr description * Type of gradient. The default type is linear. * * <p>Must be one of the following constant values.</p> * <table> * <colgroup align="left" /> * <colgroup align="left" /> * <colgroup align="left" /> * <tr><th>Constant</th><th>Value</th><th>Description</th></tr> * <tr><td>linear</td><td>0</td><td></td></tr> * <tr><td>radial</td><td>1</td><td></td></tr> * <tr><td>sweep</td><td>2</td><td></td></tr> * </table> * * @attr name android:type */ public static final int GradientColor_android_type=2; /** * <p> * @attr description * X coordinate of the center of the gradient within the path. * * <p>May be a floating point value, such as "<code>1.2</code>". * <p>May be a fractional value, which is a floating point number appended with * either % or %p, such as "<code>14.5%</code>". * The % suffix always means a percentage of the base size; * the optional %p suffix provides a size relative to some parent container. * * @attr name android:centerX */ public static final int GradientColor_android_centerX=3; /** * <p> * @attr description * Y coordinate of the center of the gradient within the path. * * <p>May be a floating point value, such as "<code>1.2</code>". * <p>May be a fractional value, which is a floating point number appended with * either % or %p, such as "<code>14.5%</code>". * The % suffix always means a percentage of the base size; * the optional %p suffix provides a size relative to some parent container. * * @attr name android:centerY */ public static final int GradientColor_android_centerY=4; /** * <p> * @attr description * Radius of the gradient, used only with radial gradient. * * <p>May be a floating point value, such as "<code>1.2</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), and * mm (millimeters). * <p>May be a fractional value, which is a floating point number appended with * either % or %p, such as "<code>14.5%</code>". * The % suffix always means a percentage of the base size; * the optional %p suffix provides a size relative to some parent container. * * @attr name android:gradientRadius */ public static final int GradientColor_android_gradientRadius=5; /** * <p> * @attr description * Defines the tile mode of the gradient. SweepGradient doesn't support tiling. * * <p>Must be one of the following constant values.</p> * <table> * <colgroup align="left" /> * <colgroup align="left" /> * <colgroup align="left" /> * <tr><th>Constant</th><th>Value</th><th>Description</th></tr> * <tr><td>clamp</td><td>0</td><td></td></tr> * <tr><td>disabled</td><td>ffffffff</td><td></td></tr> * <tr><td>mirror</td><td>2</td><td></td></tr> * <tr><td>repeat</td><td>1</td><td></td></tr> * </table> * * @attr name android:tileMode */ public static final int GradientColor_android_tileMode=6; /** * <p> * @attr description * Optional center color. * * <p>May be a color value, in the form of "<code>#<i>rgb</i></code>", * "<code>#<i>argb</i></code>", "<code>#<i>rrggbb</i></code>", or * "<code>#<i>aarrggbb</i></code>". * * @attr name android:centerColor */ public static final int GradientColor_android_centerColor=7; /** * <p> * @attr description * X coordinate of the start point origin of the gradient. * Defined in same coordinates as the path itself * * <p>May be a floating point value, such as "<code>1.2</code>". * * @attr name android:startX */ public static final int GradientColor_android_startX=8; /** * <p> * @attr description * Y coordinate of the start point of the gradient within the shape. * Defined in same coordinates as the path itself * * <p>May be a floating point value, such as "<code>1.2</code>". * * @attr name android:startY */ public static final int GradientColor_android_startY=9; /** * <p> * @attr description * X coordinate of the end point origin of the gradient. * Defined in same coordinates as the path itself * * <p>May be a floating point value, such as "<code>1.2</code>". * * @attr name android:endX */ public static final int GradientColor_android_endX=10; /** * <p> * @attr description * Y coordinate of the end point of the gradient within the shape. * Defined in same coordinates as the path itself * * <p>May be a floating point value, such as "<code>1.2</code>". * * @attr name android:endY */ public static final int GradientColor_android_endY=11; /** * Attributes that can be used with a GradientColorItem. * <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 #GradientColorItem_android_color android:color}</code></td><td></td></tr> * <tr><td><code>{@link #GradientColorItem_android_offset android:offset}</code></td><td></td></tr> * </table> * @see #GradientColorItem_android_color * @see #GradientColorItem_android_offset */ public static final int[] GradientColorItem={ 0x010101a5, 0x01010514 }; /** * <p> * @attr description * The current color for the offset inside the gradient. * * <p>May be a color value, in the form of "<code>#<i>rgb</i></code>", * "<code>#<i>argb</i></code>", "<code>#<i>rrggbb</i></code>", or * "<code>#<i>aarrggbb</i></code>". * * @attr name android:color */ public static final int GradientColorItem_android_color=0; /** * <p> * @attr description * The offset (or ratio) of this current color item inside the gradient. * The value is only meaningful when it is between 0 and 1. * * <p>May be a floating point value, such as "<code>1.2</code>". * * @attr name android:offset */ public static final int GradientColorItem_android_offset=1; } }
2c3d23b883fcb6dafcb7c22c422a75fe0e9b367e
78eebe3055f221475a69072936fc581469084d60
/src/main/java/NetSocket/UDPProvide.java
882b333c59f64b17da568d217f9e053ddc57e498
[]
no_license
Chendaseven/Design-Pattern-Code
f8373b5e8756b570d32f37695e5920de3763e486
1f061050afb008086a3a40c48fa2f5b296bb2cd3
refs/heads/master
2021-07-06T11:23:38.110125
2019-08-28T12:51:01
2019-08-28T12:51:01
181,653,493
0
0
null
null
null
null
UTF-8
Java
false
false
1,108
java
package NetSocket; import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; import java.util.Scanner; import org.junit.Test; public class UDPProvide { @Test public void provideTest() throws IOException { //1.指定一个端口进行发送 DatagramSocket socket = new DatagramSocket(); //2.指定一个IP InetAddress addr = InetAddress.getByName("127.0.0.1"); int port = 5051; //3.准备一个小容器 byte[] sendBuf; while (true){ Scanner scanner = new Scanner(System.in); System.out.println("你要发什么东西:"); String s = scanner.nextLine(); //4.加入要放的数据 sendBuf = s.getBytes(); //5.数据打包 DatagramPacket packet = new DatagramPacket(sendBuf,sendBuf.length,addr,port); //6.发送包 socket.send(packet); if (s.equals("exit")){ break; } } //7.释放资源 socket.close(); } }
645959b9edb3527f04048a01853aa5e0c2437267
b919107375417431ddceeb73f9cef655a9b2731f
/news/src/main/java/com/zhaolw/zoo/newapi/MySystemTray.java
a4a309502594ce308b169e4635cc237b47ef524f
[]
no_license
zlwtrouble/z-boot
940fc94606accea221f6ab57170f2ab212d6d696
edf075eed1219db319eea20a164f4a5713c96a59
refs/heads/master
2022-07-16T02:13:48.920981
2022-03-31T05:49:39
2022-03-31T05:49:39
145,925,149
1
0
null
2022-06-21T04:17:04
2018-08-24T01:14:06
Java
UTF-8
Java
false
false
2,735
java
package com.zhaolw.zoo.newapi; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** * @author zhaoliwei * @description: * @date 2019/5/8 19:27 **/ public class MySystemTray extends JFrame { public MySystemTray() { init(); } public void init() { this.setSize(300, 200); this.setLocationRelativeTo(null); this.setTray(); this.setVisible(true); } //添加托盘显示:1.先判断当前平台是否支持托盘显示 public void setTray() { if (SystemTray.isSupported()) {//判断当前平台是否支持托盘功能 //创建托盘实例 SystemTray tray = SystemTray.getSystemTray(); //创建托盘图标:1.显示图标Image 2.停留提示text 3.弹出菜单popupMenu 4.创建托盘图标实例 //1.创建Image图像 Image image = Toolkit.getDefaultToolkit().getImage("trayIconImage/clientIcon.jpg"); //2.停留提示text String text = "MySystemTray"; //3.弹出菜单popupMenu PopupMenu popMenu = new PopupMenu(); MenuItem itmOpen = new MenuItem("打开"); itmOpen.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Show(); } }); MenuItem itmHide = new MenuItem("隐藏"); itmHide.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { UnVisible(); } }); MenuItem itmExit = new MenuItem("退出"); itmExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Exit(); } }); popMenu.add(itmOpen); popMenu.add(itmHide); popMenu.add(itmExit); //创建托盘图标 TrayIcon trayIcon = new TrayIcon(image, text, popMenu); //将托盘图标加到托盘上 try { tray.add(trayIcon); } catch (AWTException e1) { e1.printStackTrace(); } } } //内部类中不方便直接调用外部类的实例(this不能指向) public void UnVisible() { this.setVisible(false); } public void Show() { this.setVisible(true); } public void Exit() { System.exit(0); } public static void main(String[] args) { new MySystemTray(); } }
[ "resultList" ]
resultList
eb079aaeb93e886cdfdc8a99aca6c76ba32769e6
20eb62855cb3962c2d36fda4377dfd47d82eb777
/newEvaluatedBugs/Jsoup_31_buggy/mutated/1252/HtmlTreeBuilderState.java
103f52587cdcfb2f8020fe69c49dc72492610911
[]
no_license
ozzydong/CapGen
356746618848065cce4e253e5d3c381baa85044a
0ba0321b6b1191443276021f1997833342f02515
refs/heads/master
2023-03-18T20:12:02.923428
2020-08-21T03:08:28
2020-08-21T03:08:28
null
0
0
null
null
null
null
UTF-8
Java
false
false
68,543
java
package org.jsoup.parser; import org.jsoup.helper.DescendableLinkedList; import org.jsoup.helper.StringUtil; import org.jsoup.nodes.*; import java.util.Iterator; import java.util.LinkedList; /** * The Tree Builder's current state. Each state embodies the processing for the state, and transitions to other states. */ enum HtmlTreeBuilderState { Initial { boolean process(Token t, HtmlTreeBuilder tb) { if (isWhitespace(t)) { return true; // ignore whitespace } else if (t.isComment()) { tb.insert(t.asComment()); } else if (t.isDoctype()) { // todo: parse error check on expected doctypes // todo: quirk state check on doctype ids Token.Doctype d = t.asDoctype(); DocumentType doctype = new DocumentType(d.getName(), d.getPublicIdentifier(), d.getSystemIdentifier(), tb.getBaseUri()); tb.getDocument().appendChild(doctype); if (d.isForceQuirks()) tb.getDocument().quirksMode(Document.QuirksMode.quirks); tb.transition(BeforeHtml); } else { // todo: check not iframe srcdoc tb.transition(BeforeHtml); return tb.process(t); // re-process token } return true; } }, BeforeHtml { boolean process(Token t, HtmlTreeBuilder tb) { if (t.isDoctype()) { tb.error(this); return false; } else if (t.isComment()) { tb.insert(t.asComment()); } else if (isWhitespace(t)) { return true; // ignore whitespace } else if (t.isStartTag() && t.asStartTag().name().equals("html")) { tb.insert(t.asStartTag()); tb.transition(BeforeHead); } else if (t.isEndTag() && (StringUtil.in(t.asEndTag().name(), "head", "body", "html", "br"))) { return anythingElse(t, tb); } else if (t.isEndTag()) { tb.error(this); return false; } else { return anythingElse(t, tb); } return true; } private boolean anythingElse(Token t, HtmlTreeBuilder tb) { tb.insert("html"); tb.transition(BeforeHead); return tb.process(t); } }, BeforeHead { boolean process(Token t, HtmlTreeBuilder tb) { if (isWhitespace(t)) { return true; } else if (t.isComment()) { tb.insert(t.asComment()); } else if (t.isDoctype()) { tb.error(this); return false; } else if (t.isStartTag() && t.asStartTag().name().equals("html")) { return InBody.process(t, tb); // does not transition } else if (t.isStartTag() && t.asStartTag().name().equals("head")) { Element head = tb.insert(t.asStartTag()); tb.setHeadElement(head); tb.transition(InHead); } else if (t.isEndTag() && (StringUtil.in(t.asEndTag().name(), "head", "body", "html", "br"))) { tb.process(new Token.StartTag("head")); return tb.process(t); } else if (t.isEndTag()) { tb.error(this); return false; } else { tb.process(new Token.StartTag("head")); return tb.process(t); } return true; } }, InHead { boolean process(Token t, HtmlTreeBuilder tb) { if (isWhitespace(t)) { tb.insert(t.asCharacter()); return true; } switch (t.type) { case Comment: tb.insert(t.asComment()); break; case Doctype: tb.error(this); return false; case StartTag: Token.StartTag start = t.asStartTag(); String name = start.name(); if (name.equals("html")) { return InBody.process(t, tb); } else if (StringUtil.in(name, "base", "basefont", "bgsound", "command", "link")) { Element el = tb.insertEmpty(start); // jsoup special: update base the frist time it is seen if (name.equals("base") && el.hasAttr("href")) tb.maybeSetBaseUri(el); } else if (name.equals("meta")) { Element meta = tb.insertEmpty(start); // todo: charset switches } else if (name.equals("title")) { handleRcData(start, tb); } else if (StringUtil.in(name, "noframes", "style")) { handleRawtext(start, tb); } else if (name.equals("noscript")) { // else if noscript && scripting flag = true: rawtext (jsoup doesn't run script, to handle as noscript) tb.insert(start); tb.transition(InHeadNoscript); } else if (name.equals("script")) { // skips some script rules as won't execute them tb.tokeniser.transition(TokeniserState.ScriptData); tb.markInsertionMode(); tb.transition(Text); tb.insert(start); } else if (name.equals("head")) { tb.error(this); return false; } else { return anythingElse(t, tb); } break; case EndTag: Token.EndTag end = t.asEndTag(); name = end.name(); if (name.equals("head")) { tb.pop(); tb.transition(AfterHead); } else if (StringUtil.in(name, "body", "html", "br")) { return anythingElse(t, tb); } else { tb.error(this); return false; } break; default: return anythingElse(t, tb); } return true; } private boolean anythingElse(Token t, TreeBuilder tb) { tb.process(new Token.EndTag("head")); return tb.process(t); } }, InHeadNoscript { boolean process(Token t, HtmlTreeBuilder tb) { if (t.isDoctype()) { tb.error(this); } else if (t.isStartTag() && t.asStartTag().name().equals("html")) { return tb.process(t, InBody); } else if (t.isEndTag() && t.asEndTag().name().equals("noscript")) { tb.pop(); tb.transition(InHead); } else if (isWhitespace(t) || t.isComment() || (t.isStartTag() && StringUtil.in(t.asStartTag().name(), "basefont", "bgsound", "link", "meta", "noframes", "style"))) { return tb.process(t, InHead); } else if (t.isEndTag() && t.asEndTag().name().equals("br")) { return anythingElse(t, tb); } else if ((t.isStartTag() && StringUtil.in(t.asStartTag().name(), "head", "noscript")) || t.isEndTag()) { tb.error(this); return false; } else { return anythingElse(t, tb); } return true; } private boolean anythingElse(Token t, HtmlTreeBuilder tb) { tb.error(this); tb.process(new Token.EndTag("noscript")); return tb.process(t); } }, AfterHead { boolean process(Token t, HtmlTreeBuilder tb) { if (isWhitespace(t)) { tb.insert(t.asCharacter()); } else if (t.isComment()) { tb.insert(t.asComment()); } else if (t.isDoctype()) { tb.error(this); } else if (t.isStartTag()) { Token.StartTag startTag = t.asStartTag(); String name = startTag.name(); if (name.equals("html")) { return tb.process(t, InBody); } else if (name.equals("body")) { tb.insert(startTag); tb.framesetOk(false); tb.transition(InBody); } else if (name.equals("frameset")) { tb.insert(startTag); tb.transition(InFrameset); } else if (StringUtil.in(name, "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "title")) { tb.error(this); Element head = tb.getHeadElement(); tb.push(head); tb.process(t, InHead); tb.removeFromStack(head); } else if (name.equals("head")) { tb.error(this); return false; } else { anythingElse(t, tb); } } else if (t.isEndTag()) { if (StringUtil.in(t.asEndTag().name(), "body", "html")) { anythingElse(t, tb); } else { tb.error(this); return false; } } else { anythingElse(t, tb); } return true; } private boolean anythingElse(Token t, HtmlTreeBuilder tb) { tb.process(new Token.StartTag("body")); tb.framesetOk(true); return tb.process(t); } }, InBody { boolean process(Token t, HtmlTreeBuilder tb) { switch (t.type) { case Character: { Token.Character c = t.asCharacter(); if (c.getData().equals(nullString)) { // todo confirm that check tb.error(this); return false; } else if (isWhitespace(c)) { tb.reconstructFormattingElements(); tb.insert(c); } else { tb.reconstructFormattingElements(); tb.insert(c); tb.framesetOk(false); } break; } case Comment: { tb.insert(t.asComment()); break; } case Doctype: { tb.error(this); return false; } case StartTag: Token.StartTag startTag = t.asStartTag(); String name = startTag.name(); if (name.equals("html")) { tb.error(this); // merge attributes onto real html Element html = tb.getStack().getFirst(); for (Attribute attribute : startTag.getAttributes()) { if (!html.hasAttr(attribute.getKey())) html.attributes().put(attribute); } } else if (StringUtil.in(name, "base", "basefont", "bgsound", "command", "link", "meta", "noframes", "script", "style", "title")) { return tb.process(t, InHead); } else if (name.equals("body")) { tb.error(this); LinkedList<Element> stack = tb.getStack(); if (stack.size() == 1 || (stack.size() > 2 && !stack.get(1).nodeName().equals("body"))) { // only in fragment case return false; // ignore } else { tb.framesetOk(false); Element body = stack.get(1); for (Attribute attribute : startTag.getAttributes()) { if (!body.hasAttr(attribute.getKey())) body.attributes().put(attribute); } } } else if (name.equals("frameset")) { tb.error(this); LinkedList<Element> stack = tb.getStack(); if (stack.size() == 1 || (stack.size() > 2 && !stack.get(1).nodeName().equals("body"))) { // only in fragment case return false; // ignore } else if (!tb.framesetOk()) { return false; // ignore frameset } else { Element second = stack.get(1); if (second.parent() != null) second.remove(); // pop up to html element while (stack.size() > 1) stack.removeLast(); tb.insert(startTag); tb.transition(InFrameset); } } else if (StringUtil.in(name, "address", "article", "aside", "blockquote", "center", "details", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer", "header", "hgroup", "menu", "nav", "ol", "p", "section", "summary", "ul")) { if (tb.inButtonScope("p")) { tb.process(new Token.EndTag("p")); } tb.insert(startTag); } else if (StringUtil.in(name, "h1", "h2", "h3", "h4", "h5", "h6")) { if (tb.inButtonScope("p")) { tb.process(new Token.EndTag("p")); } if (StringUtil.in(tb.currentElement().nodeName(), "h1", "h2", "h3", "h4", "h5", "h6")) { tb.error(this); tb.pop(); } tb.insert(startTag); } else if (StringUtil.in(name, "pre", "listing")) { if (tb.inButtonScope("p")) { tb.process(new Token.EndTag("p")); } tb.insert(startTag); // todo: ignore LF if next token tb.framesetOk(false); } else if (name.equals("form")) { if (tb.getFormElement() != null) { tb.error(this); return false; } if (tb.inButtonScope("p")) { tb.process(new Token.EndTag("p")); } tb.insertForm(startTag, true); } else if (name.equals("li")) { tb.framesetOk(false); LinkedList<Element> stack = tb.getStack(); for (int i = stack.size() - 1; i > 0; i--) { Element el = stack.get(i); if (el.nodeName().equals("li")) { tb.process(new Token.EndTag("li")); break; } if (tb.isSpecial(el) && !StringUtil.in(el.nodeName(), "address", "div", "p")) break; } if (tb.inButtonScope("p")) { tb.process(new Token.EndTag("p")); } tb.insert(startTag); } else if (StringUtil.in(name, "dd", "dt")) { tb.framesetOk(false); LinkedList<Element> stack = tb.getStack(); for (int i = stack.size() - 1; i > 0; i--) { Element el = stack.get(i); if (StringUtil.in(el.nodeName(), "dd", "dt")) { tb.process(new Token.EndTag(el.nodeName())); break; } if (tb.isSpecial(el) && !StringUtil.in(el.nodeName(), "address", "div", "p")) break; } if (tb.inButtonScope("p")) { tb.process(new Token.EndTag("p")); } tb.insert(startTag); } else if (name.equals("plaintext")) { if (tb.inButtonScope("p")) { tb.process(new Token.EndTag("p")); } tb.insert(startTag); tb.tokeniser.transition(TokeniserState.PLAINTEXT); // once in, never gets out } else if (name.equals("button")) { if (tb.inButtonScope("button")) { // close and reprocess tb.error(this); tb.process(new Token.EndTag("button")); tb.process(startTag); } else { tb.reconstructFormattingElements(); tb.insert(startTag); tb.framesetOk(false); } } else if (name.equals("a")) { if (tb.getActiveFormattingElement("a") != null) { tb.error(this); tb.process(new Token.EndTag("a")); // still on stack? Element remainingA = tb.getFromStack("a"); if (remainingA != null) { tb.removeFromActiveFormattingElements(remainingA); tb.removeFromStack(remainingA); } } tb.reconstructFormattingElements(); Element a = tb.insert(startTag); tb.pushActiveFormattingElements(a); } else if (StringUtil.in(name, "b", "big", "code", "em", "font", "i", "s", "small", "strike", "strong", "tt", "u")) { tb.reconstructFormattingElements(); Element el = tb.insert(startTag); tb.pushActiveFormattingElements(el); } else if (name.equals("nobr")) { tb.reconstructFormattingElements(); if (tb.inScope("nobr")) { tb.error(this); tb.process(new Token.EndTag("nobr")); tb.reconstructFormattingElements(); } Element el = tb.insert(startTag); tb.pushActiveFormattingElements(el); } else if (StringUtil.in(name, "applet", "marquee", "object")) { tb.reconstructFormattingElements(); tb.insert(startTag); tb.insertMarkerToFormattingElements(); tb.framesetOk(false); } else if (name.equals("table")) { if (tb.getDocument().quirksMode() != Document.QuirksMode.quirks && tb.inButtonScope("p")) { tb.process(new Token.EndTag("p")); } tb.insert(startTag); tb.framesetOk(false); tb.transition(InTable); } else if (StringUtil.in(name, "area", "br", "embed", "img", "keygen", "wbr")) { tb.reconstructFormattingElements(); tb.insertEmpty(startTag); tb.framesetOk(false); } else if (name.equals("input")) { tb.reconstructFormattingElements(); Element el = tb.insertEmpty(startTag); if (!el.attr("type").equalsIgnoreCase("hidden")) tb.framesetOk(false); } else if (StringUtil.in(name, "param", "source", "track")) { tb.insertEmpty(startTag); } else if (name.equals("hr")) { if (tb.inButtonScope("p")) { tb.process(new Token.EndTag("p")); } tb.insertEmpty(startTag); tb.framesetOk(false); } else if (name.equals("image")) { // we're not supposed to ask. startTag.name("img"); return tb.process(startTag); } else if (name.equals("isindex")) { // how much do we care about the early 90s? tb.error(this); if (tb.getFormElement() != null) return false; tb.tokeniser.acknowledgeSelfClosingFlag(); tb.process(new Token.StartTag("form")); if (startTag.attributes.hasKey("action")) { Element form = tb.getFormElement(); form.attr("action", startTag.attributes.get("action")); } tb.process(new Token.StartTag("hr")); tb.process(new Token.StartTag("label")); // hope you like english. String prompt = startTag.attributes.hasKey("prompt") ? startTag.attributes.get("prompt") : "This is a searchable index. Enter search keywords: "; tb.process(new Token.Character(prompt)); // input Attributes inputAttribs = new Attributes(); for (Attribute attr : startTag.attributes) { if (!StringUtil.in(attr.getKey(), "name", "action", "prompt")) inputAttribs.put(attr); } inputAttribs.put("name", "isindex"); tb.process(new Token.StartTag("input", inputAttribs)); tb.process(new Token.EndTag("label")); tb.process(new Token.StartTag("hr")); tb.process(new Token.EndTag("form")); } else if (name.equals("textarea")) { tb.insert(startTag); // todo: If the next token is a U+000A LINE FEED (LF) character token, then ignore that token and move on to the next one. (Newlines at the start of textarea elements are ignored as an authoring convenience.) tb.tokeniser.transition(TokeniserState.Rcdata); tb.markInsertionMode(); tb.framesetOk(false); tb.transition(Text); } else if (name.equals("xmp")) { if (tb.inButtonScope("p")) { tb.process(new Token.EndTag("p")); } tb.reconstructFormattingElements(); tb.framesetOk(false); handleRawtext(startTag, tb); } else if (name.equals("iframe")) { tb.framesetOk(false); handleRawtext(startTag, tb); } else if (name.equals("noembed")) { // also handle noscript if script enabled handleRawtext(startTag, tb); } else if (name.equals("select")) { tb.reconstructFormattingElements(); tb.insert(startTag); tb.framesetOk(false); HtmlTreeBuilderState state = tb.state(); if (state.equals(InTable) || state.equals(InCaption) || state.equals(InTableBody) || state.equals(InRow) || state.equals(InCell)) tb.transition(InSelectInTable); else tb.transition(InSelect); } else if (StringUtil.in("optgroup", "option")) { if (tb.currentElement().nodeName().equals("option")) tb.process(new Token.EndTag("option")); tb.reconstructFormattingElements(); tb.insert(startTag); } else if (StringUtil.in("rp", "rt")) { if (tb.inScope("ruby")) { tb.generateImpliedEndTags(); if (!tb.currentElement().nodeName().equals("ruby")) { tb.error(this); tb.popStackToBefore("ruby"); // i.e. close up to but not include name } tb.insert(startTag); } } else if (name.equals("math")) { tb.reconstructFormattingElements(); // todo: handle A start tag whose tag name is "math" (i.e. foreign, mathml) tb.insert(startTag); tb.tokeniser.acknowledgeSelfClosingFlag(); } else if (name.equals("svg")) { tb.reconstructFormattingElements(); // todo: handle A start tag whose tag name is "svg" (xlink, svg) tb.insert(startTag); tb.tokeniser.acknowledgeSelfClosingFlag(); } else if (StringUtil.in(name, "caption", "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th", "thead", "tr")) { tb.error(this); return false; } else { tb.reconstructFormattingElements(); tb.insert(startTag); } break; case EndTag: Token.EndTag endTag = t.asEndTag(); name = endTag.name(); if (name.equals("body")) { if (!tb.inScope("body")) { tb.error(this); return false; } else { // todo: error if stack contains something not dd, dt, li, optgroup, option, p, rp, rt, tbody, td, tfoot, th, thead, tr, body, html tb.transition(AfterBody); } } else if (name.equals("html")) { boolean notIgnored = tb.process(new Token.EndTag("body")); if (notIgnored) return tb.process(endTag); } else if (StringUtil.in(name, "address", "article", "aside", "blockquote", "button", "center", "details", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer", "header", "hgroup", "listing", "menu", "nav", "ol", "pre", "section", "summary", "ul")) { // todo: refactor these lookups if (!tb.inScope(name)) { // nothing to close tb.error(this); return false; } else { tb.generateImpliedEndTags(); if (!tb.currentElement().nodeName().equals(name)) tb.error(this); tb.popStackToClose(name); } } else if (name.equals("form")) { Element currentForm = tb.getFormElement(); tb.setFormElement(null); if (currentForm == null || !tb.inScope(name)) { tb.error(this); return false; } else { tb.generateImpliedEndTags(); if (!tb.currentElement().nodeName().equals(name)) tb.error(this); // remove currentForm from stack. will shift anything under up. tb.removeFromStack(currentForm); } } else if (name.equals("p")) { if (!tb.inButtonScope(name)) { tb.error(this); tb.process(new Token.StartTag(name)); // if no p to close, creates an empty <p></p> return tb.process(endTag); } else { tb.generateImpliedEndTags(name); if (!tb.currentElement().nodeName().equals(name)) tb.error(this); tb.popStackToClose(name); } } else if (name.equals("li")) { if (!tb.inListItemScope(name)) { tb.error(this); return false; } else { tb.generateImpliedEndTags(name); if (!tb.currentElement().nodeName().equals(name)) tb.error(this); tb.popStackToClose(name); } } else if (StringUtil.in(name, "dd", "dt")) { if (!tb.inScope(name)) { tb.error(this); return false; } else { tb.generateImpliedEndTags(name); if (!tb.currentElement().nodeName().equals(name)) tb.error(this); tb.popStackToClose(name); } } else if (StringUtil.in(name, "h1", "h2", "h3", "h4", "h5", "h6")) { if (!tb.inScope(new String[]{"h1", "h2", "h3", "h4", "h5", "h6"})) { tb.error(this); return false; } else { tb.generateImpliedEndTags(name); if (!tb.currentElement().nodeName().equals(name)) tb.error(this); tb.popStackToClose("h1", "h2", "h3", "h4", "h5", "h6"); } } else if (name.equals("sarcasm")) { // *sigh* return anyOtherEndTag(t, tb); } else if (StringUtil.in(name, "a", "b", "big", "code", "em", "font", "i", "nobr", "s", "small", "strike", "strong", "tt", "u")) { // Adoption Agency Algorithm. OUTER: for (int i = 0; i < 8; i++) { Element formatEl = tb.getActiveFormattingElement(name); if (formatEl == null) return anyOtherEndTag(t, tb); else if (!tb.onStack(formatEl)) { tb.error(this); tb.removeFromActiveFormattingElements(formatEl); return true; } else if (!tb.inScope(formatEl.nodeName())) { tb.error(this); return false; } else if (tb.currentElement() != formatEl) tb.error(this); Element furthestBlock = null; Element commonAncestor = null; boolean seenFormattingElement = false; LinkedList<Element> stack = tb.getStack(); // the spec doesn't limit to < 64, but in degenerate cases (9000+ stack depth) this prevents // run-aways for (int si = 0; si < stack.size() && si < 64; si++) { Element el = stack.get(si); if (el == formatEl) { commonAncestor = stack.get(si - 1); seenFormattingElement = true; } else if (seenFormattingElement && tb.isSpecial(el)) { furthestBlock = el; break; } } if (furthestBlock == null) { tb.popStackToClose(formatEl.nodeName()); tb.removeFromActiveFormattingElements(formatEl); return true; } // todo: Let a bookmark note the position of the formatting element in the list of active formatting elements relative to the elements on either side of it in the list. // does that mean: int pos of format el in list? Element node = furthestBlock; Element lastNode = furthestBlock; INNER: for (int j = 0; j < 3; j++) { if (tb.onStack(node)) node = tb.aboveOnStack(node); if (!tb.isInActiveFormattingElements(node)) { // note no bookmark check tb.removeFromStack(node); continue INNER; } else if (node == formatEl) break INNER; Element replacement = new Element(Tag.valueOf(node.nodeName()), tb.getBaseUri()); tb.replaceActiveFormattingElement(node, replacement); tb.replaceOnStack(node, replacement); node = replacement; if (lastNode == furthestBlock) { // todo: move the aforementioned bookmark to be immediately after the new node in the list of active formatting elements. // not getting how this bookmark both straddles the element above, but is inbetween here... } if (lastNode.parent() != null) lastNode.remove(); node.appendChild(lastNode); lastNode = node; } if (StringUtil.in(commonAncestor.nodeName(), "table", "tbody", "tfoot", "thead", "tr")) { if (lastNode.parent() != null) lastNode.remove(); tb.insertInFosterParent(lastNode); } else { if (lastNode.parent() != null) lastNode.remove(); commonAncestor.appendChild(lastNode); } Element adopter = new Element(Tag.valueOf(name), tb.getBaseUri()); Node[] childNodes = furthestBlock.childNodes().toArray(new Node[furthestBlock.childNodeSize()]); for (Node childNode : childNodes) { adopter.appendChild(childNode); // append will reparent. thus the clone to avoid concurrent mod. } furthestBlock.appendChild(adopter); tb.removeFromActiveFormattingElements(formatEl); // todo: insert the new element into the list of active formatting elements at the position of the aforementioned bookmark. tb.removeFromStack(formatEl); tb.insertOnStackAfter(furthestBlock, adopter); } } else if (StringUtil.in(name, "applet", "marquee", "object")) { if (!tb.inScope("name")) { if (!tb.inScope(name)) { tb.error(this); return false; } tb.generateImpliedEndTags(); if (!tb.currentElement().nodeName().equals(name)) tb.error(this); tb.popStackToClose(name); tb.clearFormattingElementsToLastMarker(); } } else if (name.equals("br")) { tb.error(this); tb.process(new Token.StartTag("br")); return false; } else { return anyOtherEndTag(t, tb); } break; case EOF: // todo: error if stack contains something not dd, dt, li, p, tbody, td, tfoot, th, thead, tr, body, html // stop parsing break; } return true; } boolean anyOtherEndTag(Token t, HtmlTreeBuilder tb) { String name = t.asEndTag().name(); DescendableLinkedList<Element> stack = tb.getStack(); Iterator<Element> it = stack.descendingIterator(); while (it.hasNext()) { Element node = it.next(); if (node.nodeName().equals(name)) { tb.generateImpliedEndTags(name); tb.process(new org.jsoup.parser.Token.EndTag("button")); if (!name.equals(tb.currentElement().nodeName())) tb.error(this); tb.popStackToClose(name); break; } else { if (tb.isSpecial(node)) { tb.error(this); return false; } } } return true; } }, Text { // in script, style etc. normally treated as data tags boolean process(Token t, HtmlTreeBuilder tb) { if (t.isCharacter()) { tb.insert(t.asCharacter()); } else if (t.isEOF()) { tb.error(this); // if current node is script: already started tb.pop(); tb.transition(tb.originalState()); return tb.process(t); } else if (t.isEndTag()) { // if: An end tag whose tag name is "script" -- scripting nesting level, if evaluating scripts tb.pop(); tb.transition(tb.originalState()); } return true; } }, InTable { boolean process(Token t, HtmlTreeBuilder tb) { if (t.isCharacter()) { tb.newPendingTableCharacters(); tb.markInsertionMode(); tb.transition(InTableText); return tb.process(t); } else if (t.isComment()) { tb.insert(t.asComment()); return true; } else if (t.isDoctype()) { tb.error(this); return false; } else if (t.isStartTag()) { Token.StartTag startTag = t.asStartTag(); String name = startTag.name(); if (name.equals("caption")) { tb.clearStackToTableContext(); tb.insertMarkerToFormattingElements(); tb.insert(startTag); tb.transition(InCaption); } else if (name.equals("colgroup")) { tb.clearStackToTableContext(); tb.insert(startTag); tb.transition(InColumnGroup); } else if (name.equals("col")) { tb.process(new Token.StartTag("colgroup")); return tb.process(t); } else if (StringUtil.in(name, "tbody", "tfoot", "thead")) { tb.clearStackToTableContext(); tb.insert(startTag); tb.transition(InTableBody); } else if (StringUtil.in(name, "td", "th", "tr")) { tb.process(new Token.StartTag("tbody")); return tb.process(t); } else if (name.equals("table")) { tb.error(this); boolean processed = tb.process(new Token.EndTag("table")); if (processed) // only ignored if in fragment return tb.process(t); } else if (StringUtil.in(name, "style", "script")) { return tb.process(t, InHead); } else if (name.equals("input")) { if (!startTag.attributes.get("type").equalsIgnoreCase("hidden")) { return anythingElse(t, tb); } else { tb.insertEmpty(startTag); } } else if (name.equals("form")) { tb.error(this); if (tb.getFormElement() != null) return false; else { tb.insertForm(startTag, false); } } else { return anythingElse(t, tb); } return true; // todo: check if should return processed http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#parsing-main-intable } else if (t.isEndTag()) { Token.EndTag endTag = t.asEndTag(); String name = endTag.name(); if (name.equals("table")) { if (!tb.inTableScope(name)) { tb.error(this); return false; } else { tb.popStackToClose("table"); } tb.resetInsertionMode(); } else if (StringUtil.in(name, "body", "caption", "col", "colgroup", "html", "tbody", "td", "tfoot", "th", "thead", "tr")) { tb.error(this); return false; } else { return anythingElse(t, tb); } return true; // todo: as above todo } else if (t.isEOF()) { if (tb.currentElement().nodeName().equals("html")) tb.error(this); return true; // stops parsing } return anythingElse(t, tb); } boolean anythingElse(Token t, HtmlTreeBuilder tb) { tb.error(this); boolean processed = true; if (StringUtil.in(tb.currentElement().nodeName(), "table", "tbody", "tfoot", "thead", "tr")) { tb.setFosterInserts(true); processed = tb.process(t, InBody); tb.setFosterInserts(false); } else { processed = tb.process(t, InBody); } return processed; } }, InTableText { boolean process(Token t, HtmlTreeBuilder tb) { switch (t.type) { case Character: Token.Character c = t.asCharacter(); if (c.getData().equals(nullString)) { tb.error(this); return false; } else { tb.getPendingTableCharacters().add(c); } break; default: if (tb.getPendingTableCharacters().size() > 0) { for (Token.Character character : tb.getPendingTableCharacters()) { if (!isWhitespace(character)) { // InTable anything else section: tb.error(this); if (StringUtil.in(tb.currentElement().nodeName(), "table", "tbody", "tfoot", "thead", "tr")) { tb.setFosterInserts(true); tb.process(character, InBody); tb.setFosterInserts(false); } else { tb.process(character, InBody); } } else tb.insert(character); } tb.newPendingTableCharacters(); } tb.transition(tb.originalState()); return tb.process(t); } return true; } }, InCaption { boolean process(Token t, HtmlTreeBuilder tb) { if (t.isEndTag() && t.asEndTag().name().equals("caption")) { Token.EndTag endTag = t.asEndTag(); String name = endTag.name(); if (!tb.inTableScope(name)) { tb.error(this); return false; } else { tb.generateImpliedEndTags(); if (!tb.currentElement().nodeName().equals("caption")) tb.error(this); tb.popStackToClose("caption"); tb.clearFormattingElementsToLastMarker(); tb.transition(InTable); } } else if (( t.isStartTag() && StringUtil.in(t.asStartTag().name(), "caption", "col", "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr") || t.isEndTag() && t.asEndTag().name().equals("table")) ) { tb.error(this); boolean processed = tb.process(new Token.EndTag("caption")); if (processed) return tb.process(t); } else if (t.isEndTag() && StringUtil.in(t.asEndTag().name(), "body", "col", "colgroup", "html", "tbody", "td", "tfoot", "th", "thead", "tr")) { tb.error(this); return false; } else { return tb.process(t, InBody); } return true; } }, InColumnGroup { boolean process(Token t, HtmlTreeBuilder tb) { if (isWhitespace(t)) { tb.insert(t.asCharacter()); return true; } switch (t.type) { case Comment: tb.insert(t.asComment()); break; case Doctype: tb.error(this); break; case StartTag: Token.StartTag startTag = t.asStartTag(); String name = startTag.name(); if (name.equals("html")) return tb.process(t, InBody); else if (name.equals("col")) tb.insertEmpty(startTag); else return anythingElse(t, tb); break; case EndTag: Token.EndTag endTag = t.asEndTag(); name = endTag.name(); if (name.equals("colgroup")) { if (tb.currentElement().nodeName().equals("html")) { // frag case tb.error(this); return false; } else { tb.pop(); tb.transition(InTable); } } else return anythingElse(t, tb); break; case EOF: if (tb.currentElement().nodeName().equals("html")) return true; // stop parsing; frag case else return anythingElse(t, tb); default: return anythingElse(t, tb); } return true; } private boolean anythingElse(Token t, TreeBuilder tb) { boolean processed = tb.process(new Token.EndTag("colgroup")); if (processed) // only ignored in frag case return tb.process(t); return true; } }, InTableBody { boolean process(Token t, HtmlTreeBuilder tb) { switch (t.type) { case StartTag: Token.StartTag startTag = t.asStartTag(); String name = startTag.name(); if (name.equals("tr")) { tb.clearStackToTableBodyContext(); tb.insert(startTag); tb.transition(InRow); } else if (StringUtil.in(name, "th", "td")) { tb.error(this); tb.process(new Token.StartTag("tr")); return tb.process(startTag); } else if (StringUtil.in(name, "caption", "col", "colgroup", "tbody", "tfoot", "thead")) { return exitTableBody(t, tb); } else return anythingElse(t, tb); break; case EndTag: Token.EndTag endTag = t.asEndTag(); name = endTag.name(); if (StringUtil.in(name, "tbody", "tfoot", "thead")) { if (!tb.inTableScope(name)) { tb.error(this); return false; } else { tb.clearStackToTableBodyContext(); tb.pop(); tb.transition(InTable); } } else if (name.equals("table")) { return exitTableBody(t, tb); } else if (StringUtil.in(name, "body", "caption", "col", "colgroup", "html", "td", "th", "tr")) { tb.error(this); return false; } else return anythingElse(t, tb); break; default: return anythingElse(t, tb); } return true; } private boolean exitTableBody(Token t, HtmlTreeBuilder tb) { if (!(tb.inTableScope("tbody") || tb.inTableScope("thead") || tb.inScope("tfoot"))) { // frag case tb.error(this); return false; } tb.clearStackToTableBodyContext(); tb.process(new Token.EndTag(tb.currentElement().nodeName())); // tbody, tfoot, thead return tb.process(t); } private boolean anythingElse(Token t, HtmlTreeBuilder tb) { return tb.process(t, InTable); } }, InRow { boolean process(Token t, HtmlTreeBuilder tb) { if (t.isStartTag()) { Token.StartTag startTag = t.asStartTag(); String name = startTag.name(); if (StringUtil.in(name, "th", "td")) { tb.clearStackToTableRowContext(); tb.insert(startTag); tb.transition(InCell); tb.insertMarkerToFormattingElements(); } else if (StringUtil.in(name, "caption", "col", "colgroup", "tbody", "tfoot", "thead", "tr")) { return handleMissingTr(t, tb); } else { return anythingElse(t, tb); } } else if (t.isEndTag()) { Token.EndTag endTag = t.asEndTag(); String name = endTag.name(); if (name.equals("tr")) { if (!tb.inTableScope(name)) { tb.error(this); // frag return false; } tb.clearStackToTableRowContext(); tb.pop(); // tr tb.transition(InTableBody); } else if (name.equals("table")) { return handleMissingTr(t, tb); } else if (StringUtil.in(name, "tbody", "tfoot", "thead")) { if (!tb.inTableScope(name)) { tb.error(this); return false; } tb.process(new Token.EndTag("tr")); return tb.process(t); } else if (StringUtil.in(name, "body", "caption", "col", "colgroup", "html", "td", "th")) { tb.error(this); return false; } else { return anythingElse(t, tb); } } else { return anythingElse(t, tb); } return true; } private boolean anythingElse(Token t, HtmlTreeBuilder tb) { return tb.process(t, InTable); } private boolean handleMissingTr(Token t, TreeBuilder tb) { boolean processed = tb.process(new Token.EndTag("tr")); if (processed) return tb.process(t); else return false; } }, InCell { boolean process(Token t, HtmlTreeBuilder tb) { if (t.isEndTag()) { Token.EndTag endTag = t.asEndTag(); String name = endTag.name(); if (StringUtil.in(name, "td", "th")) { if (!tb.inTableScope(name)) { tb.error(this); tb.transition(InRow); // might not be in scope if empty: <td /> and processing fake end tag return false; } tb.generateImpliedEndTags(); if (!tb.currentElement().nodeName().equals(name)) tb.error(this); tb.popStackToClose(name); tb.clearFormattingElementsToLastMarker(); tb.transition(InRow); } else if (StringUtil.in(name, "body", "caption", "col", "colgroup", "html")) { tb.error(this); return false; } else if (StringUtil.in(name, "table", "tbody", "tfoot", "thead", "tr")) { if (!tb.inTableScope(name)) { tb.error(this); return false; } closeCell(tb); return tb.process(t); } else { return anythingElse(t, tb); } } else if (t.isStartTag() && StringUtil.in(t.asStartTag().name(), "caption", "col", "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr")) { if (!(tb.inTableScope("td") || tb.inTableScope("th"))) { tb.error(this); return false; } closeCell(tb); return tb.process(t); } else { return anythingElse(t, tb); } return true; } private boolean anythingElse(Token t, HtmlTreeBuilder tb) { return tb.process(t, InBody); } private void closeCell(HtmlTreeBuilder tb) { if (tb.inTableScope("td")) tb.process(new Token.EndTag("td")); else tb.process(new Token.EndTag("th")); // only here if th or td in scope } }, InSelect { boolean process(Token t, HtmlTreeBuilder tb) { switch (t.type) { case Character: Token.Character c = t.asCharacter(); if (c.getData().equals(nullString)) { tb.error(this); return false; } else { tb.insert(c); } break; case Comment: tb.insert(t.asComment()); break; case Doctype: tb.error(this); return false; case StartTag: Token.StartTag start = t.asStartTag(); String name = start.name(); if (name.equals("html")) return tb.process(start, InBody); else if (name.equals("option")) { tb.process(new Token.EndTag("option")); tb.insert(start); } else if (name.equals("optgroup")) { if (tb.currentElement().nodeName().equals("option")) tb.process(new Token.EndTag("option")); else if (tb.currentElement().nodeName().equals("optgroup")) tb.process(new Token.EndTag("optgroup")); tb.insert(start); } else if (name.equals("select")) { tb.error(this); return tb.process(new Token.EndTag("select")); } else if (StringUtil.in(name, "input", "keygen", "textarea")) { tb.error(this); if (!tb.inSelectScope("select")) return false; // frag tb.process(new Token.EndTag("select")); return tb.process(start); } else if (name.equals("script")) { return tb.process(t, InHead); } else { return anythingElse(t, tb); } break; case EndTag: Token.EndTag end = t.asEndTag(); name = end.name(); if (name.equals("optgroup")) { if (tb.currentElement().nodeName().equals("option") && tb.aboveOnStack(tb.currentElement()) != null && tb.aboveOnStack(tb.currentElement()).nodeName().equals("optgroup")) tb.process(new Token.EndTag("option")); if (tb.currentElement().nodeName().equals("optgroup")) tb.pop(); else tb.error(this); } else if (name.equals("option")) { if (tb.currentElement().nodeName().equals("option")) tb.pop(); else tb.error(this); } else if (name.equals("select")) { if (!tb.inSelectScope(name)) { tb.error(this); return false; } else { tb.popStackToClose(name); tb.resetInsertionMode(); } } else return anythingElse(t, tb); break; case EOF: if (!tb.currentElement().nodeName().equals("html")) tb.error(this); break; default: return anythingElse(t, tb); } return true; } private boolean anythingElse(Token t, HtmlTreeBuilder tb) { tb.error(this); return false; } }, InSelectInTable { boolean process(Token t, HtmlTreeBuilder tb) { if (t.isStartTag() && StringUtil.in(t.asStartTag().name(), "caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th")) { tb.error(this); tb.process(new Token.EndTag("select")); return tb.process(t); } else if (t.isEndTag() && StringUtil.in(t.asEndTag().name(), "caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th")) { tb.error(this); if (tb.inTableScope(t.asEndTag().name())) { tb.process(new Token.EndTag("select")); return (tb.process(t)); } else return false; } else { return tb.process(t, InSelect); } } }, AfterBody { boolean process(Token t, HtmlTreeBuilder tb) { if (isWhitespace(t)) { return tb.process(t, InBody); } else if (t.isComment()) { tb.insert(t.asComment()); // into html node } else if (t.isDoctype()) { tb.error(this); return false; } else if (t.isStartTag() && t.asStartTag().name().equals("html")) { return tb.process(t, InBody); } else if (t.isEndTag() && t.asEndTag().name().equals("html")) { if (tb.isFragmentParsing()) { tb.error(this); return false; } else { tb.transition(AfterAfterBody); } } else if (t.isEOF()) { // chillax! we're done } else { tb.error(this); tb.transition(InBody); return tb.process(t); } return true; } }, InFrameset { boolean process(Token t, HtmlTreeBuilder tb) { if (isWhitespace(t)) { tb.insert(t.asCharacter()); } else if (t.isComment()) { tb.insert(t.asComment()); } else if (t.isDoctype()) { tb.error(this); return false; } else if (t.isStartTag()) { Token.StartTag start = t.asStartTag(); String name = start.name(); if (name.equals("html")) { return tb.process(start, InBody); } else if (name.equals("frameset")) { tb.insert(start); } else if (name.equals("frame")) { tb.insertEmpty(start); } else if (name.equals("noframes")) { return tb.process(start, InHead); } else { tb.error(this); return false; } } else if (t.isEndTag() && t.asEndTag().name().equals("frameset")) { if (tb.currentElement().nodeName().equals("html")) { // frag tb.error(this); return false; } else { tb.pop(); if (!tb.isFragmentParsing() && !tb.currentElement().nodeName().equals("frameset")) { tb.transition(AfterFrameset); } } } else if (t.isEOF()) { if (!tb.currentElement().nodeName().equals("html")) { tb.error(this); return true; } } else { tb.error(this); return false; } return true; } }, AfterFrameset { boolean process(Token t, HtmlTreeBuilder tb) { if (isWhitespace(t)) { tb.insert(t.asCharacter()); } else if (t.isComment()) { tb.insert(t.asComment()); } else if (t.isDoctype()) { tb.error(this); return false; } else if (t.isStartTag() && t.asStartTag().name().equals("html")) { return tb.process(t, InBody); } else if (t.isEndTag() && t.asEndTag().name().equals("html")) { tb.transition(AfterAfterFrameset); } else if (t.isStartTag() && t.asStartTag().name().equals("noframes")) { return tb.process(t, InHead); } else if (t.isEOF()) { // cool your heels, we're complete } else { tb.error(this); return false; } return true; } }, AfterAfterBody { boolean process(Token t, HtmlTreeBuilder tb) { if (t.isComment()) { tb.insert(t.asComment()); } else if (t.isDoctype() || isWhitespace(t) || (t.isStartTag() && t.asStartTag().name().equals("html"))) { return tb.process(t, InBody); } else if (t.isEOF()) { // nice work chuck } else { tb.error(this); tb.transition(InBody); return tb.process(t); } return true; } }, AfterAfterFrameset { boolean process(Token t, HtmlTreeBuilder tb) { if (t.isComment()) { tb.insert(t.asComment()); } else if (t.isDoctype() || isWhitespace(t) || (t.isStartTag() && t.asStartTag().name().equals("html"))) { return tb.process(t, InBody); } else if (t.isEOF()) { // nice work chuck } else if (t.isStartTag() && t.asStartTag().name().equals("noframes")) { return tb.process(t, InHead); } else { tb.error(this); return false; } return true; } }, ForeignContent { boolean process(Token t, HtmlTreeBuilder tb) { return true; // todo: implement. Also; how do we get here? } }; private static String nullString = String.valueOf('\u0000'); abstract boolean process(Token t, HtmlTreeBuilder tb); private static boolean isWhitespace(Token t) { if (t.isCharacter()) { String data = t.asCharacter().getData(); // todo: this checks more than spec - "\t", "\n", "\f", "\r", " " for (int i = 0; i < data.length(); i++) { char c = data.charAt(i); if (!StringUtil.isWhitespace(c)) return false; } return true; } return false; } private static void handleRcData(Token.StartTag startTag, HtmlTreeBuilder tb) { tb.insert(startTag); tb.tokeniser.transition(TokeniserState.Rcdata); tb.markInsertionMode(); tb.transition(Text); } private static void handleRawtext(Token.StartTag startTag, HtmlTreeBuilder tb) { tb.insert(startTag); tb.tokeniser.transition(TokeniserState.Rawtext); tb.markInsertionMode(); tb.transition(Text); } }
51cc5436e9e0c579884c8c31689a7a7e2b8f339d
ad79433b09647e408aaa4f038cc24b0db2d0f69b
/src/com/cg/testmanagement/dao/OnlineTestDaoImpl.java
2402df9b93c8e07301f163496acac184c076d059
[]
no_license
CapgProject/mycode
8a7e3e5428fe75d5946897e368ddf26376f60a30
773ef273c0f1fa901af2897855f2fe405628baf5
refs/heads/master
2022-12-24T12:22:11.329473
2019-10-02T19:23:06
2019-10-02T19:23:06
212,421,611
0
0
null
2022-12-15T23:25:03
2019-10-02T19:13:12
Java
UTF-8
Java
false
false
6,967
java
package com.cg.testmanagement.dao; import java.util.List; import java.util.Set; import javax.jws.soap.SOAPBinding.Use; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.Query; import org.springframework.stereotype.Repository; import com.cg.testmanagement.dao.OnlineTestDao; import com.cg.testmanagement.dto.OnlineTest; import com.cg.testmanagement.dto.Question; import com.cg.testmanagement.dto.User; import com.cg.testmanagement.exception.ExceptionMessage; import com.cg.testmanagement.exception.UserException; @Repository("testdao") public class OnlineTestDaoImpl implements OnlineTestDao { @PersistenceContext EntityManager entitymanager; // static { // // Properties props = System.getProperties(); // String userDir = props.getProperty("user.dir") + "/src/main/resources/"; // PropertyConfigurator.configure(userDir + "log4j.properties"); // myLogger = Logger.getLogger("OnlineTestDaoImpl.class"); // } public Set<Question> getQuestionSet(Long testId) throws UserException { OnlineTest test = entitymanager.find(OnlineTest.class, testId); if(test != null && test.getTestQuestions() != null) { return test.getTestQuestions(); } else { throw new UserException(ExceptionMessage.TESTNOTFOUNDMESSAGE); } } @Override public OnlineTest saveTest(OnlineTest onlineTest) throws UserException { entitymanager.persist(onlineTest); return onlineTest; } @Override public OnlineTest searchTest(Long testId) throws UserException { OnlineTest test = entitymanager.find(OnlineTest.class, testId); if(test != null && test.getIsdeleted() == false) { return test; } else { throw new UserException(ExceptionMessage.TESTNOTFOUNDMESSAGE); } } @Override public OnlineTest removeTest(Long testId) throws UserException { OnlineTest test = entitymanager.find(OnlineTest.class, testId); if(test != null) { test.setIsdeleted(true); Set<Question> question = test.getTestQuestions(); question.forEach(quest->{ quest.setOnlinetest(null); }); return test; } else { throw new UserException(ExceptionMessage.TESTNOTFOUNDMESSAGE); } } @Override public OnlineTest updateTest(OnlineTest test) throws UserException { OnlineTest foundTest = entitymanager.find(OnlineTest.class, test.getTestId()); if(foundTest != null) { foundTest.setTestId(test.getTestId()); foundTest.setTestName(test.getTestName()); foundTest.setTestTotalMarks(test.getTestTotalMarks()); foundTest.setTestQuestions(test.getTestQuestions()); foundTest.setTestDuration(test.getTestDuration()); foundTest.setStartTime(test.getStartTime()); foundTest.setEndTime(test.getEndTime()); foundTest.setIsTestAssigned(test.getIsTestAssigned()); foundTest.setIsdeleted(test.getIsdeleted()); foundTest.setTestMarksScored(test.getTestMarksScored()); return foundTest; } else { throw new UserException(ExceptionMessage.TESTNOTFOUNDMESSAGE); } } @Override public Question saveQuestion(Question question) throws UserException { OnlineTest test = entitymanager.find(OnlineTest.class, question.getOnlinetest().getTestId()); entitymanager.persist(question); test.getTestQuestions().add(question); return question; } @Override public Question searchQuestion(Long questId) throws UserException { Question question = entitymanager.find(Question.class, questId); if(question != null) { return question; } else { throw new UserException(ExceptionMessage.QUESTIONMESSAGE); } } @Override public Question removeQuestion(Long questId) throws UserException { Question question = entitymanager.find(Question.class, questId); if(question != null) { question.setIsDeleted(true); OnlineTest onlineTest = entitymanager.find(OnlineTest.class, question.getOnlinetest().getTestId()); if (onlineTest != null){ onlineTest.getTestQuestions().remove(question); } return question; } else { throw new UserException(ExceptionMessage.QUESTIONMESSAGE); } } @Override public Question updateQuestion(Question question) throws UserException { Question foundQuestion = entitymanager.find(Question.class, question.getQuestionId()); if(foundQuestion != null) { foundQuestion.setQuestionId(question.getQuestionId()); foundQuestion.setQuestionTitle(question.getQuestionTitle()); foundQuestion.setQuestionOptions(question.getQuestionOptions()); foundQuestion.setQuestionMarks(question.getQuestionMarks()); foundQuestion.setChosenAnswer(question.getChosenAnswer()); foundQuestion.setIsDeleted(question.getIsDeleted()); foundQuestion.setMarksScored(question.getMarksScored()); foundQuestion.setQuestionAnswer(question.getQuestionAnswer()); return foundQuestion; } else { throw new UserException(ExceptionMessage.QUESTIONMESSAGE); } } @Override public User saveUser(User user) throws UserException { entitymanager.persist(user); return user; } @Override public User searchUser(Long userId) throws UserException { User user = entitymanager.find(User.class, userId); if(user!=null && user.getIsDeleted() == false) { return user; } else { throw new UserException(ExceptionMessage.USERMESSAGE); } } @Override public User removeUser(Long userId) throws UserException { User user = entitymanager.find(User.class,userId); if(user!=null) { user.setIsDeleted(true); return user; } else { throw new UserException(ExceptionMessage.USERMESSAGE); } } @Override public User updateUser(User user) throws UserException { User foundUser = entitymanager.find(User.class, user.getUserId()); OnlineTest foundTest = entitymanager.find(OnlineTest.class, foundUser.getUserTest().getTestId()); if(foundUser != null) { foundUser.setUserId(user.getUserId()); foundUser.setUserName(user.getUserName()); foundUser.setUserPassword(user.getUserPassword()); foundUser.setUserTest(foundTest); foundUser.setIsAdmin(user.getIsAdmin()); foundUser.setIsDeleted(user.getIsDeleted()); return foundUser; } else { throw new UserException(ExceptionMessage.USERMESSAGE); } } @Override public List<User> getUsers() { Query query = entitymanager.createQuery("FROM User WHERE isAdmin IS false AND isDeleted IS false"); List<User> userList = query.getResultList(); return userList; } @Override public List<OnlineTest> getTests() { Query query = entitymanager.createQuery("FROM OnlineTest WHERE isDeleted IS false AND isTestAssigned IS false"); List<OnlineTest> testList = query.getResultList(); return testList; } @Override public User login(String userName, String pass){ Query query = entitymanager.createQuery("FROM User WHERE isDeleted IS false AND userName=:first AND userPassword=:second"); query.setParameter("first", userName); query.setParameter("second", pass); try{ User user = (User) query.getSingleResult(); return user; }catch (Exception e) { return null; } } }
8865b745e1901333db3d67c0739377d9eadfaaca
0f859255f131fa60a90acd3c137bbb0b9ee32d01
/odata-core/src/test/java/org/odata4j/test/unit/producer/inmemory/InMemoryEdmTest.java
81d0494c54710c139e1132e85ed9f27361459c34
[ "Apache-2.0" ]
permissive
vhalbert/oreva
fe1f5c76b8f2416dbb36481769585b77dd46e6e9
39b6c90c432bcefc410894c04fb831178d560272
refs/heads/master
2021-01-18T01:10:00.864949
2020-01-28T15:25:14
2020-01-28T15:25:14
36,017,606
0
0
Apache-2.0
2020-02-12T14:47:49
2015-05-21T14:31:54
Java
UTF-8
Java
false
false
9,711
java
package org.odata4j.test.unit.producer.inmemory; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import java.util.Collection; import java.util.List; import org.core4j.Enumerable; import org.core4j.Predicate1; import org.junit.Ignore; import org.junit.Test; import org.odata4j.edm.EdmDataServices; import org.odata4j.edm.EdmEntityType; import org.odata4j.edm.EdmMultiplicity; import org.odata4j.edm.EdmNavigationProperty; import org.odata4j.edm.EdmProperty; import org.odata4j.producer.inmemory.BeanBasedPropertyModel; import org.odata4j.producer.inmemory.EnumsAsStringsPropertyModelDelegate; import org.odata4j.producer.inmemory.InMemoryProducer; /** * Test various aspects of InMemoryEdmGenerator * * hierarchy: * RHS * Base * ----Sub1 * ----Sub1_2 * ----Sub2 */ public class InMemoryEdmTest { public static class RHS { public String getRHSProp1() { return ""; } public void setRHSProp1() {} } public static class Base { // key public String getBaseProp1() { return ""; } public void setBaseProp1() {} // base class relationships public Collection<RHS> getRHSs() { return null; } public void setRHSs(Collection<RHS> value) {} public RHS getRHS() { return null; } public void setRHS(RHS value) {} } public static class Sub1 extends Base { public String getSub1Prop1() { return ""; } public void setSub1Prop1() {} } public static class Sub2 extends Base { public String getSub2Prop1() { return ""; } public void setSub2Prop1() {} } public static class Sub1_2 extends Sub1 { public String getSub1_2Prop1() { return ""; } public void setSub1_2Prop1() {} // leaf relationships public Collection<Sub2> getSub2s() { return null; } public void setSub2s(Collection<Sub2> value) {} public Sub2 getSub2() { return null; } public void setSub2(Sub2 value) {} } private void register(InMemoryProducer p, Class<? extends Object> clazz, boolean flat, String... keys) { p.register(clazz, new EnumsAsStringsPropertyModelDelegate(new BeanBasedPropertyModel(clazz, flat)), clazz.getSimpleName() + "s", // set clazz.getSimpleName(), // type null, keys); // keys } private void assertKeys(List<String> keys, String[] expect) { assertEquals(expect.length, keys.size()); for (String k : expect) { assertTrue(keys.contains(k)); } } private void assertNavProp(String fromType, EdmMultiplicity fromMult, String toType, EdmMultiplicity toMult, EdmNavigationProperty got) { assertEquals(fromType, got.getFromRole().getType().getName()); assertEquals(fromMult, got.getFromRole().getMultiplicity()); assertEquals(toType, got.getToRole().getType().getName()); assertEquals(toMult, got.getToRole().getMultiplicity()); } private void assertProps(Enumerable<EdmProperty> got, String... expected) { assertEquals(expected.length, got.count()); for (final String e : expected) { EdmProperty p = got.first(new Predicate1<EdmProperty>() { @Override public boolean apply(EdmProperty t) { return t.getName().equals(e); } }); assertEquals(e, p.getName()); } } @Test public void testHierarchyEdm() { InMemoryProducer p = new InMemoryProducer("myns", null, // String containerName, 100, // int maxResults, null, // EdmDecorator decorator, null, // InMemoryTypeMapping typeMapping, false); // boolean flattenEdm); register(p, RHS.class, false, "RHSProp1"); register(p, Base.class, false, "BaseProp1"); register(p, Sub1.class, false, "BaseProp1"); register(p, Sub1_2.class, false, "BaseProp1"); register(p, Sub2.class, false, "BaseProp1"); EdmDataServices edm = p.getMetadata(); //EdmxFormatWriter.write(edm, new OutputStreamWriter(System.out)); EdmEntityType rhs = (EdmEntityType) edm.findEdmEntityType("myns." + RHS.class.getSimpleName()); assertTrue(rhs != null); assertTrue(rhs.getBaseType() == null); assertKeys(rhs.getKeys(), new String[] { "RHSProp1" }); assertEquals(0, rhs.getDeclaredNavigationProperties().count()); assertEquals(1, rhs.getDeclaredProperties().count()); assertProps(rhs.getDeclaredProperties(), new String[] { "RHSProp1" }); assertProps(rhs.getProperties(), new String[] { "RHSProp1" }); EdmEntityType base = (EdmEntityType) edm.findEdmEntityType("myns." + Base.class.getSimpleName()); assertTrue(base != null); assertTrue(base.getBaseType() == null); assertKeys(base.getKeys(), new String[] { "BaseProp1" }); assertProps(base.getDeclaredProperties(), new String[] { "BaseProp1" }); assertProps(base.getProperties(), new String[] { "BaseProp1" }); assertEquals(2, base.getDeclaredNavigationProperties().count()); assertEquals(2, base.getNavigationProperties().count()); assertNavProp("Base", EdmMultiplicity.MANY, "RHS", EdmMultiplicity.ONE, base.findDeclaredNavigationProperty("RHS")); assertNavProp("Base", EdmMultiplicity.ZERO_TO_ONE, "RHS", EdmMultiplicity.MANY, base.findDeclaredNavigationProperty("RHSs")); EdmEntityType sub1 = (EdmEntityType) edm.findEdmEntityType("myns." + Sub1.class.getSimpleName()); assertTrue(sub1 != null); assertEquals(base, sub1.getBaseType()); assertKeys(sub1.getKeys(), new String[] { "BaseProp1" }); assertProps(sub1.getDeclaredProperties(), new String[] { "Sub1Prop1" }); assertProps(sub1.getProperties(), new String[] { "BaseProp1", "Sub1Prop1" }); assertEquals(0, sub1.getDeclaredNavigationProperties().count()); assertEquals(2, sub1.getNavigationProperties().count()); assertNavProp("Base", EdmMultiplicity.MANY, "RHS", EdmMultiplicity.ONE, sub1.findNavigationProperty("RHS")); assertNavProp("Base", EdmMultiplicity.ZERO_TO_ONE, "RHS", EdmMultiplicity.MANY, sub1.findNavigationProperty("RHSs")); EdmEntityType sub2 = (EdmEntityType) edm.findEdmEntityType("myns." + Sub2.class.getSimpleName()); assertTrue(sub2 != null); assertEquals(base, sub2.getBaseType()); assertKeys(sub2.getKeys(), new String[] { "BaseProp1" }); assertProps(sub2.getDeclaredProperties(), new String[] { "Sub2Prop1" }); assertProps(sub2.getProperties(), new String[] { "BaseProp1", "Sub2Prop1" }); assertEquals(0, sub2.getDeclaredNavigationProperties().count()); assertEquals(2, sub2.getNavigationProperties().count()); assertNavProp("Base", EdmMultiplicity.MANY, "RHS", EdmMultiplicity.ONE, sub2.findNavigationProperty("RHS")); assertNavProp("Base", EdmMultiplicity.ZERO_TO_ONE, "RHS", EdmMultiplicity.MANY, sub2.findNavigationProperty("RHSs")); EdmEntityType sub1_2 = (EdmEntityType) edm.findEdmEntityType("myns." + Sub1_2.class.getSimpleName()); assertTrue(sub1_2 != null); assertEquals(sub1, sub1_2.getBaseType()); assertKeys(sub1_2.getKeys(), new String[] { "BaseProp1" }); assertProps(sub1_2.getDeclaredProperties(), new String[] { "Sub1_2Prop1" }); assertProps(sub1_2.getProperties(), new String[] { "BaseProp1", "Sub1Prop1", "Sub1_2Prop1" }); assertEquals(2, sub1_2.getDeclaredNavigationProperties().count()); assertEquals(4, sub1_2.getNavigationProperties().count()); assertNavProp("Base", EdmMultiplicity.MANY, "RHS", EdmMultiplicity.ONE, sub1_2.findNavigationProperty("RHS")); assertNavProp("Base", EdmMultiplicity.ZERO_TO_ONE, "RHS", EdmMultiplicity.MANY, sub1_2.findNavigationProperty("RHSs")); assertNavProp("Sub1_2", EdmMultiplicity.MANY, "Sub2", EdmMultiplicity.ONE, sub1_2.findDeclaredNavigationProperty("Sub2")); assertNavProp("Sub1_2", EdmMultiplicity.ZERO_TO_ONE, "Sub2", EdmMultiplicity.MANY, sub1_2.findDeclaredNavigationProperty("Sub2s")); } @Test public void testFlatEdm() { InMemoryProducer p = new InMemoryProducer("myns"); register(p, RHS.class, true, "RHSProp1"); register(p, Sub1.class, true, "BaseProp1"); EdmDataServices edm = p.getMetadata(); // EdmxFormatWriter.write(edm, new OutputStreamWriter(System.out)); EdmEntityType sub1 = (EdmEntityType) edm.findEdmEntityType("myns." + Sub1.class.getSimpleName()); assertTrue(sub1 != null); assertEquals(null, sub1.getBaseType()); assertKeys(sub1.getKeys(), new String[] { "BaseProp1" }); assertProps(sub1.getDeclaredProperties(), new String[] { "BaseProp1", "Sub1Prop1" }); assertProps(sub1.getProperties(), new String[] { "BaseProp1", "Sub1Prop1" }); assertEquals(2, sub1.getDeclaredNavigationProperties().count()); assertEquals(2, sub1.getNavigationProperties().count()); assertNavProp("Sub1", EdmMultiplicity.MANY, "RHS", EdmMultiplicity.ONE, sub1.findNavigationProperty("RHS")); assertNavProp("Sub1", EdmMultiplicity.ZERO_TO_ONE, "RHS", EdmMultiplicity.MANY, sub1.findNavigationProperty("RHSs")); } @Ignore("this currently fails, should not") //@Test public void testUniqueAssociationNames() { InMemoryProducer p = new InMemoryProducer("myns"); register(p, RHS.class, true, "RHSProp1"); register(p, Base.class, true, "BaseProp1"); EdmDataServices edm = p.getMetadata(); EdmEntityType base = (EdmEntityType) edm.findEdmEntityType("myns.Base"); EdmNavigationProperty a1 = base.findNavigationProperty("RHS"); EdmNavigationProperty a2 = base.findNavigationProperty("RHSs"); assertFalse(a1.getRelationship().getName() + " should not equal " + a1.getRelationship().getName(), a1.getRelationship().getName().equals(a1.getRelationship().getName())); } }
387be1c3768df05e66bf6d908914fd1ebbfa8abd
7f6e3c414e77195debd71ec179bab5a02fd50d51
/app/src/main/java/com/example/hotsoon_user_profiiles/music/MusicHandler.java
931bc4228bb81d392e78cb01e1a9f60d5acb7667
[ "Apache-2.0" ]
permissive
hyd2016/UserProfile
a3aee010373f23d2289e2af29ab66de0a0fbada1
95583986a48489b52456267b94bfac268a982d4f
refs/heads/master
2020-07-31T05:29:07.510672
2019-09-25T07:16:14
2019-09-25T07:16:14
210,500,110
0
0
null
null
null
null
UTF-8
Java
false
false
1,408
java
package com.example.hotsoon_user_profiiles.music; import android.os.Handler; import android.os.Message; import android.os.Messenger; import android.util.Log; import com.example.hotsoon_user_profiiles.Interface.MusicChange; public class MusicHandler extends Handler { private static final int MSG_FROM_CLIENT = 0; private static final String TAG = "MusicHandler"; private MusicChange musicChange; @Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_FROM_CLIENT: Log.d(TAG, "receive msg from client: msg"); Log.d(TAG, "handleMessage: thread"+Thread.currentThread().getId()); //不加这一句话会出现ClassNotFoundException when unmarshalling msg.getData().setClassLoader(MusicParcelable.class.getClassLoader()); Messenger client = msg.replyTo; MusicParcelable musicParcelable = msg.getData().getParcelable("music"); Log.d(TAG, "handleMessage: "+ musicParcelable.getMusicUrl()); if (musicChange != null){ musicChange.musicPlay(client, musicParcelable); } break; default: super.handleMessage(msg); } } public void setMusicChange(MusicChange change){ this.musicChange = change; } }
a248b97623ee49eee47851d919b43371f1748d88
38e836ae9bb477716ad93ddd4bed4ccf8cd7fa15
/app/src/main/java/com/badikirwan/dicoding/animeapp/AnimeAdapter.java
ade38db8bac712f4645d5026072e60e5f168ce39
[]
no_license
badikirwan/AnimeApp
ab8e8c535b20197f6c945a29071b4c431ff2645f
5d154251ba397a12fc111080e4655f1ba77edeef
refs/heads/master
2020-03-23T21:53:03.525818
2018-07-24T09:51:33
2018-07-24T09:51:33
142,138,973
0
0
null
null
null
null
UTF-8
Java
false
false
4,435
java
package com.badikirwan.dicoding.animeapp; import android.content.Context; import android.content.Intent; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import com.bumptech.glide.Glide; import java.util.ArrayList; public class AnimeAdapter extends RecyclerView.Adapter<AnimeAdapter.CardViewHolder> { private ArrayList<AnimeModel> listAnime; private Context context; public AnimeAdapter(Context context) { this.context = context; } public ArrayList<AnimeModel> getListAnime() { return listAnime; } public void setListAnime(ArrayList<AnimeModel> listAnime) { this.listAnime = listAnime; } @Override public AnimeAdapter.CardViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_cardview_anime, parent,false); CardViewHolder cardViewHolder = new CardViewHolder(view); return cardViewHolder; } @Override public void onBindViewHolder(final AnimeAdapter.CardViewHolder holder, int position) { final AnimeModel animeModel = getListAnime().get(position); Glide.with(context) .load(animeModel.getPhoto()) .override(350, 550) .into(holder.imgPhoto); holder.tvName.setText(animeModel.getName()); holder.tvViewAnime.setText(animeModel.getViewAnime()); holder.btnDetail.setOnClickListener(new CustomOnItemClickListener(position, new CustomOnItemClickListener.OnItemClickCallback() { @Override public void onItemClicked(View view, int position) { Intent moveData = new Intent(context, DetailActivity.class); moveData.putExtra(DetailActivity.EXTRA_NAME, animeModel.getName()); moveData.putExtra(DetailActivity.EXTRA_PHOTO, animeModel.getPhoto()); moveData.putExtra(DetailActivity.EXTRA_EPISODE, animeModel.getEpisode()); moveData.putExtra(DetailActivity.EXTRA_DESKRIPSI, animeModel.getDeskripsi()); moveData.putExtra(DetailActivity.EXTRA_VIEW_ANIME, animeModel.getViewAnime()); context.startActivity(moveData); } })); holder.btnShare.setOnClickListener(new CustomOnItemClickListener(position, new CustomOnItemClickListener.OnItemClickCallback() { @Override public void onItemClicked(View view, int position) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Ini adalah anime fovorite saya"); shareIntent.putExtra(Intent.EXTRA_TEXT, animeModel.getName()); shareIntent.setType("text/plain"); context.startActivity(shareIntent); } })); } @Override public int getItemCount() { return getListAnime().size(); } public class CardViewHolder extends RecyclerView.ViewHolder { ImageView imgPhoto; TextView tvName, tvViewAnime; Button btnShare, btnDetail; public CardViewHolder(View itemView) { super(itemView); imgPhoto = (ImageView) itemView.findViewById(R.id.img_item_photo); tvName = (TextView) itemView.findViewById(R.id.tv_item_name); tvViewAnime = (TextView) itemView.findViewById(R.id.tv_item_view); btnShare = (Button) itemView.findViewById(R.id.btn_set_share); btnDetail = (Button) itemView.findViewById(R.id.btn_set_detail); } } public static class CustomOnItemClickListener implements View.OnClickListener { private int position; private OnItemClickCallback onItemClickCallback; private CustomOnItemClickListener(int position, OnItemClickCallback onItemClickCallback) { this.position = position; this.onItemClickCallback = onItemClickCallback; } @Override public void onClick(View view) { onItemClickCallback.onItemClicked(view, position); } public interface OnItemClickCallback { void onItemClicked(View view, int position); } } }
b96fd7a06da0f4ba2ddebd698bc228122a0039d0
e904cdfaece422a22563a147f1c6fb921d6e9566
/src/main/java/stepDefinitions/HooksDefinition.java
7632096cac24f08a16aef77688f6603dd3674c0e
[]
no_license
shermilag/BDDFramework
52b340d4d1ca4fa027fadee56fbc9cb1c501b8f9
320bfcbe5aa0c845ae8b7d80d74cd531793a06f9
refs/heads/master
2020-03-27T21:24:10.478651
2018-09-03T22:47:59
2018-09-03T22:47:59
147,140,513
0
0
null
null
null
null
UTF-8
Java
false
false
1,690
java
package stepDefinitions; import cucumber.api.java.After; import cucumber.api.java.Before; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; public class HooksDefinition { @Before public void setUP(){ System.out.println("launch FF"); System.out.println("Enter URL for Free CRM APP"); } @After public void tearDown(){ System.out.println("close the browser"); } @Given("^user is on deal page$") public void user_is_on_deal_oage() throws Throwable { System.out.println("user is on deal page"); } @When("^user fills the deals form$") public void user_fills_the_deals_form() throws Throwable { System.out.println("create a deal"); } @Then("^deal is created$") public void deal_is_created() throws Throwable { System.out.println("deal is created"); } @Given("^user is on contact page$") public void user_is_on_contact_page() throws Throwable { System.out.println("user is on contact page"); } @When("^user fills the contact form$") public void user_fills_the_contact_form() throws Throwable { System.out.println("create a contact"); } @Then("^contact is created$") public void contact_is_created() throws Throwable { System.out.println("contact is created"); } @Given("^user is on mail page$") public void user_is_on_mail_page() throws Throwable { System.out.println("user is on mail pahge"); } @When("^user fills the mail form$") public void user_fills_the_mail_form() throws Throwable { System.out.println("create a mail"); } @Then("^mail is created$") public void mail_is_created() throws Throwable { System.out.println("mail is created"); } }
068ab24a8b449dfc1cb9b3b571da35da93d89c53
6138af219efc3a8f31060e30ebc532ffcbad1768
/astrogrid/mySpace/client/src/java/org/astrogrid/store/tree/TreeClientTest.java
5ef2795b0f5ffaedd1407de67c6a472d14f73309
[]
no_license
Javastro/astrogrid-legacy
dd794b7867a4ac650d1a84bdef05dfcd135b8bb6
51bdbec04bacfc3bcc3af6a896e8c7f603059cd5
refs/heads/main
2023-06-26T10:23:01.083788
2021-07-30T11:17:12
2021-07-30T11:17:12
391,028,616
0
0
null
null
null
null
UTF-8
Java
false
false
16,232
java
/* * <cvs:source>$Source: /Users/pharriso/Work/ag/repo/git/astrogrid-mirror/astrogrid/mySpace/client/src/java/org/astrogrid/store/tree/TreeClientTest.java,v $</cvs:source> * <cvs:author>$Author: clq2 $</cvs:author> * <cvs:date>$Date: 2004/11/17 16:22:53 $</cvs:date> * <cvs:version>$Revision: 1.2 $</cvs:version> * <cvs:log> * $Log: TreeClientTest.java,v $ * Revision 1.2 2004/11/17 16:22:53 clq2 * nww-itn07-704 * * Revision 1.1.2.2 2004/11/16 17:27:58 nw * tidied imports * * Revision 1.1.2.1 2004/11/16 16:47:28 nw * copied aladinAdapter interfaces into a neutrally-named package. * deprecated original interfaces. * javadoc * * Revision 1.3 2004/11/11 17:50:42 clq2 * Noel's aladin stuff * * Revision 1.2.6.1 2004/11/11 13:12:36 nw * added some further checking of the root container * * Revision 1.2 2004/10/05 15:39:29 dave * Merged changes to AladinAdapter ... * * Revision 1.1.2.1 2004/10/05 15:30:44 dave * Moved test base from test to src tree .... * Added MimeTypeUtil * Added getMimeType to the adapter API * Added logout to the adapter API * * Revision 1.2 2004/09/28 10:24:19 dave * Added AladinAdapter interfaces and mock implementation. * * Revision 1.1.2.7 2004/09/27 22:46:53 dave * Added AdapterFile interface, with input and output stream API. * * Revision 1.1.2.6 2004/09/24 01:36:18 dave * Refactored File as Node and Container ... * * Revision 1.1.2.5 2004/09/24 01:12:09 dave * Added initial test for child nodes. * * Revision 1.1.2.4 2004/09/23 16:32:02 dave * Added better Exception handling .... * Added initial mock container .... * Added initial root container tests ... * * Revision 1.1.2.3 2004/09/23 12:21:31 dave * Added mock security service and login test ... * * Revision 1.1.2.2 2004/09/23 10:12:19 dave * Added config properties for JUnit tests .... * Added test for null password. * * Revision 1.1.2.1 2004/09/23 09:18:13 dave * Renamed AbstractTest to TestBase to exclude it from batch test .... * Added first test for null account .... * * Revision 1.1.2.1 2004/09/22 16:47:37 dave * Added initial classes and tests for AladinAdapter. * * </cvs:log> * */ package org.astrogrid.store.tree; import org.astrogrid.store.Ivorn; import org.astrogrid.store.util.MimeTypeUtil; import java.io.InputStream; import java.io.OutputStream; import java.util.Iterator; import junit.framework.TestCase; /** * A JUnit test for the Aladin adapter. * */ public class TreeClientTest extends TestCase { /** * A test string. * "A short test string ...." * */ public static final String TEST_STRING = "A short test string ...." ; /** * A test byte array. * "A short byte array ...." * */ public static final byte[] TEST_BYTES = { 0x41, 0x20, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x20, 0x62, 0x79, 0x74, 0x65, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x20, 0x2e, 0x2e, 0x2e, 0x2e } ; /** * Our target adapter. * */ protected TreeClient adapter ; /** * Setup our test adapter. * */ protected void setTestAdapter(TreeClient adapter) { this.adapter = adapter ; } /** * Our test account. * */ protected Ivorn account ; /** * Setup our test account. * */ public void setTestAccount(Ivorn ivorn) { this.account = ivorn ; } /** * Our test password. * */ protected String password ; /** * Setup our test password. * */ public void setTestPassword(String pass) { this.password = pass ; } /** * Our target container name. * */ protected String container ; /** * Setup our container name. * */ public void setContainerName(String name) { this.container = name ; } /** * Get our container name. * */ public String getContainerName() { return this.container ; } /** * Create our container name. * This uses the current timestamp to create a unique container name for each test. * */ public void initContainerName() { this.setContainerName( "aladin-" + String.valueOf( System.currentTimeMillis() ) ) ; } /** * Check we have an adapter. * */ public void testAdapterNotNull() throws Exception { assertNotNull( adapter ) ; } /** * Check we get the right Exception for a null account. * */ public void testLoginNullAccount() throws Exception { try { adapter.login( null, password ) ; } catch (IllegalArgumentException ouch) { return ; } fail("Expected IllegalArgumentException") ; } /** * Check we get the right Exception for a null password. * */ public void testLoginNullPassword() throws Exception { try { adapter.login( account, null ) ; } catch (IllegalArgumentException ouch) { return ; } fail("Expected IllegalArgumentException") ; } /** * Check we get the right Exception for the wrong password * */ public void testLoginWrongPassword() throws Exception { try { adapter.login( account, (password + "WRONG") ) ; } catch (TreeClientLoginException ouch) { return ; } fail("Expected AladinAdapterLoginException") ; } /** * Check we can login with the right password. * */ public void testLoginValidPassword() throws Exception { // // Check we are not logged in. assertNull( adapter.getToken() ) ; // // Login using our account and password. adapter.login( account, password ) ; // // Check we are logged in. assertNotNull( adapter.getToken() ) ; } /** * Check we get the right exception if we are not logged in. * */ public void testGetRootFails() throws Exception { try { adapter.getRoot() ; } catch (TreeClientSecurityException ouch) { return ; } fail("Expected AladinAdapterSecurityException") ; } /** * Check we get the a root node if we are logged in. * */ public void testGetRoot() throws Exception { // // Login using our account and password. adapter.login( account, password ) ; // // Check we have a root node. Container root = adapter.getRoot(); assertNotNull( root ) ; assertTrue(root.isContainer()); } /** * Check the root node has the default 'workflow' node. * */ public void testWorkflowNode() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root container. Container root = adapter.getRoot() ; // // Check the child nodes for the expected defaults. Iterator iter = root.getChildNodes().iterator() ; while (iter.hasNext()) { Node next = (Node) iter.next() ; // // Check for a 'workflow' node. if ("workflow".equals(next.getName())) { return ; } } fail("Expected to find workflow container") ; } /** * Check we can add a container. * */ public void testAddContainer() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. assertNotNull( root.addContainer( this.getContainerName() ) ) ; } /** * Check we can find our a container. * */ public void testFindContainer() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. root.addContainer( this.getContainerName() ) ; // // Get an iterator for the child nodes. Node found = null ; Iterator iter = root.getChildNodes().iterator() ; while (iter.hasNext()) { Node next = (Node) iter.next() ; // // Check for a matching node. if (this.getContainerName().equals(next.getName())) { return ; } } fail("Expected to find aladin container") ; } /* * Check we get the right exception for a duplicate container. * */ public void testDuplicateContainer() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. root.addContainer( this.getContainerName() ) ; // // Try creating the same container again. try { root.addContainer( this.getContainerName() ) ; } catch (TreeClientDuplicateException ouch) { return ; } fail("Expected AladinAdapterDuplicateException") ; } /** * Check we can add a file. * */ public void testAddFile() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. Container node = root.addContainer( this.getContainerName() ) ; // // Create a new (empty) file. assertNotNull( node.addFile( "data.txt" ) ) ; } /* * Check we get the right exception for a duplicate file. * */ public void testDuplicateFile() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. Container node = root.addContainer( this.getContainerName() ) ; // // Create our new file. node.addFile( "results.txt" ) ; // // Try creating the same file again. try { node.addFile( "results.txt" ) ; } catch (TreeClientDuplicateException ouch) { return ; } fail("Expected AladinAdapterDuplicateException") ; } /** * Check a new file appears in the list of child nodes. * */ public void testFindFile() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. Container node = root.addContainer( this.getContainerName() ) ; // // Create our new file. node.addFile( "results.txt" ) ; // // Get an iterator for the child nodes. Node found = null ; Iterator iter = node.getChildNodes().iterator() ; while (iter.hasNext()) { Node next = (Node) iter.next() ; // // Check for a matching node. if ("results.txt".equals(next.getName())) { return ; } } fail("Expected to find results.txt") ; } /** * Check we can get an OutputStream for a file. * */ public void testGetOutputStream() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. Container node = root.addContainer( this.getContainerName() ) ; // // Create our new file. File file = node.addFile( "results.txt" ) ; // // Get an OutputStream for the file. assertNotNull( file.getOutputStream() ) ; } /** * Check we can transfer some data to the stream. * */ public void testImportData() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. Container node = root.addContainer( this.getContainerName() ) ; // // Create our new file. File file = node.addFile( "results.txt" ) ; // // Get an OutputStream for the file. OutputStream stream = file.getOutputStream() ; // // Transfer some data to the stream. stream.write( TEST_BYTES ) ; // // Close the stream. stream.close() ; } /** * Check we can get an InputStream for a file. * */ public void testGetInputStream() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. Container node = root.addContainer( this.getContainerName() ) ; // // Create our new file. File file = node.addFile( "results.txt" ) ; // // Get an InputStream for the file. assertNotNull( file.getInputStream() ) ; } /** * Check we can transfer some data from the stream. * */ public void testImportExportData() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. Container node = root.addContainer( this.getContainerName() ) ; // // Create our new file. File file = node.addFile( "results.txt" ) ; // // Get an OutputStream for the file. OutputStream output = file.getOutputStream() ; // // Transfer some data to the stream. output.write( TEST_BYTES ) ; // // Close the stream. output.close() ; // // Get an InputStream for the file. InputStream input = file.getInputStream() ; // // Read some data from the stream. byte[] data = new byte[TEST_BYTES.length] ; input.read(data) ; // // Check we get the same data back ... for (int i = 0 ; i < TEST_BYTES.length ; i++) { assertEquals( TEST_BYTES[i], data[i] ) ; } } /** * Check we get the right mime type for an unknown type. * */ public void testGetMimeUnknown() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. Container node = root.addContainer( this.getContainerName() ) ; // // Create our new file. File file = node.addFile( "results.unknown" ) ; // // Check the mime type. assertNull( file.getMimeType() ) ; } /** * Check we get the right mime type for an xml file. * */ public void testGetMimeXml() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. Container node = root.addContainer( this.getContainerName() ) ; // // Create our new file. File file = node.addFile( "results.xml" ) ; // // Check the mime type. assertEquals( MimeTypeUtil.MIME_TYPE_XML, file.getMimeType() ) ; } /** * Check we get the right mime type for an votable file. * */ public void testGetMimeVot() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. Container node = root.addContainer( this.getContainerName() ) ; // // Create our new file. File file = node.addFile( "results.vot" ) ; // // Check the mime type. assertEquals( MimeTypeUtil.MIME_TYPE_VOTABLE, file.getMimeType() ) ; } /** * Check we get the right mime type for an votable file. * */ public void testGetMimeVotable() throws Exception { // // Login. adapter.login( account, password ) ; // // Get the root node. Container root = adapter.getRoot() ; // // Create our new container. Container node = root.addContainer( this.getContainerName() ) ; // // Create our new file. File file = node.addFile( "results.votable" ) ; // // Check the mime type. assertEquals( MimeTypeUtil.MIME_TYPE_VOTABLE, file.getMimeType() ) ; } /** * Check we get the right exception if we logout. * */ public void testLogout() throws Exception { // // Check we get an exception if we are not logged in. try { adapter.getRoot() ; } catch (TreeClientSecurityException ouch) { return ; } fail("Expected AladinAdapterSecurityException") ; // // Login. adapter.login( account, password ) ; // // Check we can get the root node. assertNotNull( adapter.getRoot() ) ; // // Logout. adapter.logout() ; // // Check we get an exception having logged out. try { adapter.getRoot() ; } catch (TreeClientSecurityException ouch) { return ; } fail("Expected AladinAdapterSecurityException") ; } }
1a84baf271a3f12dbd1510d950ea040e30a99cd9
410459866fe4211debd6bcac37f10d14363bb369
/src/main/java/me/xhawk87/CreateYourOwnMenus/commands/menu/script/MenuScriptDeleteCommand.java
1ce660df3871e487fb06ba8f157915c175537e7b
[]
no_license
AGall0423/CreateYourOwnMenus
61054780315c05108fb3e2896a539f560ad75d1b
3deb7faf1f189345bc21c72fb2d4a0d5baa9e024
refs/heads/master
2020-12-15T20:24:23.756917
2020-01-21T03:03:38
2020-01-21T03:03:38
235,244,581
0
0
null
2020-01-21T03:02:30
2020-01-21T03:02:29
null
UTF-8
Java
false
false
2,983
java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package me.xhawk87.CreateYourOwnMenus.commands.menu.script; import java.util.ArrayList; import java.util.List; import me.xhawk87.CreateYourOwnMenus.CreateYourOwnMenus; import me.xhawk87.CreateYourOwnMenus.commands.menu.IMenuScriptCommand; import me.xhawk87.CreateYourOwnMenus.utils.ItemStackRef; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; /** * * @author XHawk87 */ public class MenuScriptDeleteCommand extends IMenuScriptCommand { public MenuScriptDeleteCommand(CreateYourOwnMenus plugin) { super(plugin); } @Override public String getUsage() { return "/menu script ([player]) delete [index] - Deletes the line with the given index (0 for first) in the held item's lore"; } @Override public String getPermission() { return "cyom.commands.menu.script.delete"; } @Override public boolean onCommand(CommandSender sender, ItemStackRef itemStackRef, Command command, String label, String[] args) { // Check the player is holding the item ItemStack held = itemStackRef.get(); if (held == null || held.getTypeId() == 0) { sender.sendMessage(plugin.translate(sender, "error-no-item-in-hand", "You must be holding a menu item")); return true; } // Get or create the lore ItemMeta meta = held.getItemMeta(); List<String> loreStrings; if (meta.hasLore()) { loreStrings = meta.getLore(); } else { loreStrings = new ArrayList<>(); } if (args.length != 1) { return false; } String indexString = args[0]; int index = getIndex(indexString, loreStrings.size(), sender); if (index == -1) { return true; } // Remove the deleted line String removedText; if (index == 0) { // Handle first-line special case String replacedWith; if (loreStrings.size() >= 2) { replacedWith = loreStrings.get(1); loreStrings.remove(1); } else { replacedWith = ""; } String firstLine = loreStrings.get(0); int lastPartIndex = firstLine.lastIndexOf('\r') + 1; removedText = firstLine.substring(lastPartIndex); loreStrings.set(0, firstLine.substring(0, lastPartIndex) + replacedWith); } else { removedText = loreStrings.remove(index); } sender.sendMessage(plugin.translate(sender, "script-line-removed", "Removed {0} from line {1} in the command list of this menu item", removedText, index)); // Update the item meta.setLore(loreStrings); held.setItemMeta(meta); return true; } }
d200474160a2137eb426a379aeab7155df1cbe2c
6bc2c70480cc3861104518f7c54af5c7768e2be2
/itmnon/src/main/java/br/itmnon/itmnon/model/Evento.java
8931293feafd5d297fc14a34937a5f10c6970d04
[]
no_license
ellenvieira/projeto_back
343c373b8dbb3008809046506d8b1f55d3d6e6f8
9ef1c238efaa6466fe9979c4a73da9672687a5e6
refs/heads/main
2023-03-03T22:25:18.269719
2021-02-12T14:07:30
2021-02-12T14:07:30
338,334,028
0
0
null
null
null
null
UTF-8
Java
false
false
1,469
java
package br.itmnon.itmnon.model; import java.time.LocalDate; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; @Entity @Table(name = "itmn_evento") public class Evento { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "num_seq") private int id; @Column(name = "data_evt",nullable = false) private LocalDate dataevt; @OneToOne @JoinColumn(name = "id_alarme") private Alarme alarme; @OneToOne @JoinColumn(name = "id_equip") //joincolumn: nome da coluna na tabela sql private Equipamento equipamento; public int getId() { return id; } public void setId(int id) { this.id = id; } public LocalDate getDataevt() { return dataevt; } public void setDataevt(LocalDate data_evt) { this.dataevt = data_evt; } public Alarme getAlarme() { return alarme; } public void setAlarme(Alarme alarme) { this.alarme = alarme; } public Equipamento getEquipamento() { return equipamento; } public void setEquipamento(Equipamento equipamento) { this.equipamento = equipamento; } }
d3306ff36ef5176e1222705b7b30818971d64b5e
3306b4bd783ae58ec0aa76663ade32b107efcbc8
/src/main/java/snownee/cuisine/plugins/jei/VesselRecipeCategory.java
24e9b3837ff17fe938dcbe5a58a3486d3fe77840
[ "MIT" ]
permissive
Snownee/Cuisine
8e43ab7453d970a68ab43a28c2a453933a8aa25a
29735bc4129a6b5d86ac19a05fb89119e9d3ed01
refs/heads/0.5
2021-06-04T11:55:07.911909
2020-04-17T14:31:18
2020-04-17T14:31:18
150,828,746
56
18
MIT
2020-02-10T07:45:07
2018-09-29T05:38:34
Java
UTF-8
Java
false
false
2,655
java
package snownee.cuisine.plugins.jei; import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiFluidStackGroup; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITooltipCallback; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeCategory; import net.minecraft.client.resources.I18n; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidStack; import snownee.cuisine.Cuisine; import snownee.cuisine.CuisineRegistry; import snownee.cuisine.util.I18nUtil; public class VesselRecipeCategory implements IRecipeCategory<VesselRecipe> { static final String UID = Cuisine.MODID + ".vessel"; private static final ITooltipCallback<FluidStack> SOLVENT_TIP = ( slotIndex, input, ingredient, tooltip ) -> tooltip.add(I18nUtil.translate("tip.solvent")); private final IDrawable background; private final String localizedName; VesselRecipeCategory(IGuiHelper guiHelper) { background = guiHelper.createDrawable(new ResourceLocation(Cuisine.MODID, "textures/gui/jei.png"), 36, 0, 130, 18); localizedName = I18n.format(CuisineRegistry.JAR.getTranslationKey() + ".name"); } @Override public String getUid() { return UID; } @Override public String getTitle() { return localizedName; } @Override public String getModName() { return Cuisine.NAME; } @Override public IDrawable getBackground() { return background; } @Override public void setRecipe(IRecipeLayout recipeLayout, VesselRecipe recipeWrapper, IIngredients ingredients) { IGuiItemStackGroup stacks = recipeLayout.getItemStacks(); IGuiFluidStackGroup fluids = recipeLayout.getFluidStacks(); stacks.init(0, true, 0, 0); stacks.init(1, true, 36, 0); stacks.init(2, false, 94, 0); fluids.init(0, true, 19, 1, 16, 16, 100, false, null); if (recipeWrapper.recipe.getOutputFluid() != null) { fluids.init(1, false, recipeWrapper.recipe.getOutput().isEmpty() ? 95 : 113, 1, 16, 16, recipeWrapper.recipe.getOutputFluid().amount, false, null); } else { fluids.addTooltipCallback(SOLVENT_TIP); } stacks.set(ingredients); fluids.set(ingredients); stacks.addTooltipCallback(JEICompat.identifierTooltip(recipeWrapper.recipe.getIdentifier())); fluids.addTooltipCallback(JEICompat.identifierTooltip(recipeWrapper.recipe.getIdentifier())); } }
b50143103a4c6d916af66b108f7d17767bd7ee16
ff0b8895bf7b4a14e7ad5894787430c1edb3c370
/HelloWorld/src/main/java/com/kan/HelloWorld.java
daee267cac4a3c02bc373d9229f9dc18a16669df
[]
no_license
kan-r/ProjectTest
e47154f9f511ba17097112a5866d1dd486862903
4b86ff11e5051b60aef53fab840a1e065f680d33
refs/heads/master
2023-06-28T23:12:30.230613
2021-07-24T00:48:26
2021-07-24T00:48:26
333,988,474
0
0
null
2021-02-05T05:14:55
2021-01-28T23:58:45
Java
UTF-8
Java
false
false
363
java
package com.kan; public class HelloWorld { public static final String HELLO_KAN = "Hello Kan Ranganathan!"; public static final String WELCOME = "Welcome"; public static void main(String[] args) { printMsg(HELLO_KAN); printMsg(WELCOME); } private static void printMsg(String msg) { System.out.println(msg); } }
95d5687e17d30a4da2fec60427a285aa5389e7ca
904256d9416a0fac8491f22a91acc8bfe57ccadc
/cms-students/src/main/java/pt/isep/cms/products/client/view/ProductsView.java
b9d08296039df28a78043b203951f932b6f3b63e
[]
no_license
Wultyc/ISEP_2021_1A1S_ODSOFT
b59a9363e277cba53dd1c46a0523e4cb1bdb9004
c1e9b479ff078e6eee5c50005f1a0652c0d3a4d7
refs/heads/master
2023-06-03T18:03:27.443154
2021-01-17T21:11:16
2021-01-17T21:11:16
376,934,038
0
0
null
null
null
null
UTF-8
Java
false
false
3,541
java
package pt.isep.cms.products.client.view; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.HasClickHandlers; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.DecoratorPanel; import com.google.gwt.user.client.ui.DockPanel; import com.google.gwt.user.client.ui.FlexTable; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HTMLTable; import com.google.gwt.user.client.ui.Widget; import pt.isep.cms.products.client.presenter.ProductsPresenter; import java.util.ArrayList; import java.util.List; public class ProductsView extends Composite implements ProductsPresenter.Display { private final Button addButton; private final Button deleteButton; private FlexTable productsTable; private final FlexTable contentTable; // private final VerticalPanel vPanel ; public ProductsView() { DecoratorPanel contentTableDecorator = new DecoratorPanel(); initWidget(contentTableDecorator); contentTableDecorator.setWidth("100%"); contentTableDecorator.setWidth("18em"); contentTable = new FlexTable(); contentTable.setWidth("100%"); contentTable.getCellFormatter().addStyleName(0, 0, "products-ListContainer"); contentTable.getCellFormatter().setWidth(0, 0, "100%"); contentTable.getFlexCellFormatter().setVerticalAlignment(0, 0, DockPanel.ALIGN_TOP); // vPanel = new VerticalPanel(); // initWidget(vPanel); // Create the menu // HorizontalPanel hPanel = new HorizontalPanel(); hPanel.setBorderWidth(0); hPanel.setSpacing(0); hPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT); addButton = new Button("Add"); hPanel.add(addButton); deleteButton = new Button("Delete"); hPanel.add(deleteButton); // vPanel.add(hPanel); contentTable.getCellFormatter().addStyleName(0, 0, "products-ListMenu"); contentTable.setWidget(0, 0, hPanel); // Create the products list // productsTable = new FlexTable(); productsTable.setCellSpacing(0); productsTable.setCellPadding(0); productsTable.setWidth("100%"); productsTable.addStyleName("products-ListContents"); productsTable.getColumnFormatter().setWidth(0, "15px"); // vPanel.add(productsTable); contentTable.setWidget(1, 0, productsTable); contentTableDecorator.add(contentTable); } public HasClickHandlers getAddButton() { return addButton; } public HasClickHandlers getDeleteButton() { return deleteButton; } public HasClickHandlers getList() { return productsTable; } public void setData(List<String> data) { productsTable.removeAllRows(); for (int i = 0; i < data.size(); ++i) { productsTable.setWidget(i, 0, new CheckBox()); productsTable.setText(i, 1, data.get(i)); } } public int getClickedRow(ClickEvent event) { int selectedRow = -1; HTMLTable.Cell cell = productsTable.getCellForEvent(event); if (cell != null) { // Suppress clicks if the user is actually selecting the // check box // if (cell.getCellIndex() > 0) { selectedRow = cell.getRowIndex(); } } return selectedRow; } public List<Integer> getSelectedRows() { List<Integer> selectedRows = new ArrayList<Integer>(); for (int i = 0; i < productsTable.getRowCount(); ++i) { CheckBox checkBox = (CheckBox) productsTable.getWidget(i, 0); if (checkBox.getValue()) { selectedRows.add(i); } } return selectedRows; } public Widget asWidget() { return this; } }
3b609745c00352aa8ff03b2e9b02659c14d82415
28d8b2bfc0ecadb414dced420d50b4e8ba78c473
/inventory/src/main/java/com/senbazuru/inventory/repository/RawMaterialRepository.java
395554eceef6315b42fca2ab8b775d6a0ea36aaf
[]
no_license
tranbinh1991/Senbazuru-Inventory-Manager
b1ed1f1b5c6e3b959fbe26b247fba638c9b9939a
c58b4cf6db0cc2c66105002112bed5dd88b226e8
refs/heads/master
2023-04-06T07:54:22.050945
2019-09-05T19:52:58
2019-09-05T19:52:58
192,179,787
0
0
null
2023-03-27T22:22:45
2019-06-16T10:49:27
HTML
UTF-8
Java
false
false
664
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 com.senbazuru.inventory.repository; import com.senbazuru.inventory.model.RawMaterial; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; /** * * @author Binh */ @Repository public interface RawMaterialRepository extends JpaRepository<RawMaterial, Long>{ List<RawMaterial> findByName(String name); List<RawMaterial> findAll(); RawMaterial findFirstById(Long id); }
85187dfe8da27250640ddee3d764b3630249993c
44252d63eb5c3cc51bb2b28c1d8a66a2ee1623c9
/FoxitGallary/FoxitGallery_source_from_JADX/com/simplemobiletools/filepicker/asynctasks/CopyMoveTask$doInBackground$2.java
fe3641ca6c6a359cfa3fc1f936f9a90bd3fa7706
[]
no_license
arunkiddo/Android
2620a7e02f5883ad1034e9ddb8c38b9521f78f89
f6221eed9f24f2349318332d86b94c4d87d253cd
refs/heads/master
2021-04-30T08:46:10.831942
2018-02-18T13:36:52
2018-02-18T13:36:52
119,573,958
0
0
null
2018-02-12T13:15:51
2018-01-30T18:03:41
null
UTF-8
Java
false
false
472
java
package com.simplemobiletools.filepicker.asynctasks; import p000a.C0055f; import p000a.p005e.p006a.C0028a; import p000a.p005e.p007b.C0037g; final class CopyMoveTask$doInBackground$2 extends C0037g implements C0028a<C0055f> { public static final CopyMoveTask$doInBackground$2 INSTANCE; static { INSTANCE = new CopyMoveTask$doInBackground$2(); } CopyMoveTask$doInBackground$2() { super(0); } public final void invoke() { } }
eb95f51931af346032851f19b7e78039d1c36dc6
c36720f673ae7e9069daaaf8ea9fe3084ad86909
/src/main/java/com/maximesoares/service/dto/package-info.java
fe22ae8b8bf5298def398487dbb33f95dd61b987
[]
no_license
maximeso/penda
539952fe5447bce5c72fb3a0c4a554cdd08e9605
748cb49b83cef2645c93faebd46d15a7e4110341
refs/heads/master
2022-08-04T11:12:45.878882
2019-08-22T18:18:57
2019-08-22T18:18:57
178,494,487
0
0
null
2022-07-07T03:55:07
2019-03-30T01:02:30
TypeScript
UTF-8
Java
false
false
72
java
/** * Data Transfer Objects. */ package com.maximesoares.service.dto;
2e3933bc5edc0ebb853ea01de626808358c0276b
474986ebbf0284f2c097385d73bbe6a829db4c0c
/Paddle/src/cz/apopt/entity/projectile/GuidedMissile.java
7847f64124c878e50c91df821fc7c43cf2b265b0
[]
no_license
Opticalll/Tanks
9cf26726f3aae4d8b9c12549529d0d458c65fec6
3cff8b38f40fb6beffba8393e67a3b5ecc2adb26
refs/heads/master
2016-09-05T14:50:41.607299
2012-11-09T17:33:42
2012-11-09T17:33:42
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,518
java
package cz.apopt.entity.projectile; import java.awt.geom.Rectangle2D; import org.lwjgl.opengl.GL11; import cz.apopt.entity.Block; import cz.apopt.entity.Collidable; import cz.apopt.entity.Entity; import cz.apopt.entity.Tank; import cz.apopt.pEngine.PVector; import cz.apopt.pEngine.Pengine; import cz.apopt.pEngine.VVector; import cz.apopt.paddleGame.PaddleGame; public class GuidedMissile implements Entity, RocketProjectile { private float x,y,vx = 0f,vy = 0f,angle,speed = 8f, width = 5.0f, height = 5.0f, lockOnRange, vangle = 4, targetangle; private float minDmg = 35.0f, maxDmg = 50.0f; Tank target = null; Tank shooter; public GuidedMissile(Tank tank) { this.shooter = tank; } public GuidedMissile(float x, float y, Tank tank) { this.x = x; this.y = y; this.shooter = tank; this.angle = 0; } public Projectile getInstance() { return new GuidedMissile(shooter); } @Override public void render() { GL11.glTranslatef(x+width/2, y+height/2, 0); GL11.glRotatef(angle, 0, 0, 1); GL11.glTranslatef(-(x+width/2), -(y+height/2), 0); PaddleGame.log("" + angle); GL11.glBegin(GL11.GL_TRIANGLES); GL11.glVertex2f(x, y+height); GL11.glVertex2f(x+width, y+height); GL11.glVertex2f(x+width/2, y); GL11.glEnd(); } private void lockOn() { for(Entity e : PaddleGame.entities) { if(e instanceof Tank) { Tank t = (Tank) e; if(t != shooter) { if(vx > 0 && (t.getX() + width/2) > x && ((t.getY() + t.getHeight()/2) <= y + lockOnRange && t.getY() >= y - lockOnRange)) target = t; else if(vx < 0 && (t.getX() + width/2) < x && ((t.getY() + t.getHeight()/2) <= y + lockOnRange && t.getY() >= y - lockOnRange)) target = t; else if(vy > 0 && (t.getY() + height/2) > y && ((t.getX() + t.getWidth()/2) <= x + lockOnRange && t.getX() >= x - lockOnRange)) target = t; else if(vy < 0 && (t.getY() + height/2) < y && ((t.getX() + t.getHeight()/2) <= x + lockOnRange && t.getX() >= x - lockOnRange)) target = t; else target = null; } else target = null; if(target != null) { PaddleGame.logT("Target Locked on X: " + target.getX() + " Y: " + target.getY() + "\n Missile Cord X: " + x + " Y: " + y); break; } } } } private float findAngle(float px1, float py1, float px2, float py2) { return (float) (Math.atan2((py2 - py1), (px2 - px1)) * 180/Math.PI); } private boolean checkPathToTarget() { for(Block b : PaddleGame.blocks.blockList) { Rectangle2D.Float block = new Rectangle2D.Float(b.getX(), b.getY(), b.getWidth(), b.getHeight()); if(block.intersectsLine(x, y, target.getX()+target.getWidth()/2, target.getY()+target.getHeight()/2)) return false; } return true; } @Override public void update() { if(target == null) lockOn(); else if(checkPathToTarget()) targetangle = findAngle(x, y, target.getX(), target.getY()); if(target != null) { if(targetangle > angle) angle += vangle; else angle -=vangle; } // angle++; vx = (float) Math.cos(Math.toRadians(90 - angle)) * speed; vy = (float) -(Math.sin(Math.toRadians(90 - angle)) * speed); PaddleGame.log("sin: " + Math.sin(angle) +"vx :" + vx + " cos: " + Math.cos(angle) +" vy: " + vy); x += vx; y += vy; Pengine eng = new Pengine(new PVector(x + width/2, y + height/2), 2, 90, null); eng.setVVector(new VVector(0.5f, 0.5f)); eng.setTime(0.05f); eng.setMinFade(0.005f); eng.setMaxFade(0.5f); eng.create(); } @Override public float getX() { return x; } @Override public float getY() { return y; } public float getDamage() { return PaddleGame.getRandom(minDmg, maxDmg); } @Override public float getWidth() { return width; } @Override public float getHeight() { return height; } @Override public void checkCollision() { for(int i = 0; i < PaddleGame.entities.size(); i++) { Entity e = PaddleGame.entities.get(i); if(e instanceof Collidable) { Collidable obj = (Collidable) e; if(obj.equals(shooter)) return; if(obj.isSolid() || obj.isDestroyable()) obj.intersects(this); } } } @Override public Tank getShooter() { return shooter; } @Override public String getName() { return "Guided"; } @Override public void fire() { angle = shooter.getAngleFromFacing(); this.x = shooter.getX() + shooter.getWidth()/2; this.y = shooter.getY() + shooter.getHeight()/2; PaddleGame.entities.add(this); } }
aacbfac1c0fe519d8757fb3420ada1fd571fc6cf
f233fd8e71e793269075daab2af2269b19706a12
/POO2/src/br/com/unicamp/entidades/CidadeOrigem.java
c8a5e5028eb66abbc73151a1fd3e076b6a0f50b2
[]
no_license
fgodoys/fluxo-aereo-2010
fcf97d43d5d05699ddaa32236624823fefa789d4
bd4516f647e484a5c6f137c2366bc4558ed66924
refs/heads/master
2021-01-16T22:18:24.896668
2016-09-17T13:35:48
2016-09-17T13:35:48
65,492,005
0
1
null
null
null
null
UTF-8
Java
false
false
655
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 br.com.unicamp.entidades; import java.util.List; /** * * @author Felipe */ public class CidadeOrigem extends Cidade { List<CidadeDestino> destinosList; public CidadeOrigem(){ } public List<CidadeDestino> getDestinosList() { return destinosList; } public void setDestinosList(List<CidadeDestino> destinosList) { this.destinosList = destinosList; } }
3738815d8e65df52c448898b365823ada8a19755
a33ed449e758c592dc3c946e7711534ebb60028e
/src/com/caterpillar/xmlrpc/core/XmlRpcCustomSerializer.java
96283955aa6e22674778f658362134a9b4c9be37
[ "Apache-2.0" ]
permissive
jamesbluecrow/android-framework-library
b490f7cfcd430d017d89587d0b4d23a56026c65e
b106a49f6fa9d35ded4da92b3699aa783ee8ffb4
refs/heads/master
2021-05-31T07:12:25.372847
2015-04-18T03:08:14
2015-04-18T03:08:14
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,273
java
/* Copyright (c) 2005 Redstone Handelsbolag This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package com.caterpillar.xmlrpc.core; import java.io.IOException; import java.io.Writer; /** * Java objects are serialized into XML-RPC values using instances of classes * implementing the XmlRpcCustomSerializer class. When processing an argument or a return * value for an XML-RPC call, the XmlRpcSerializer will look through its list of * XmlRpcCustomSerializer objects for a serializer that matches the object type of the * value. The getValueClass() returns the Class supported by that serializer. * * <p>A number of serializers for common types are already implemented, but you may * wish to add custom serializers for special types of Java objects.</p> * * @author Greger Olsson */ public interface XmlRpcCustomSerializer { /** * Returns the class of objects this serializer knows how to handle. * * @return The class of objects interpretable to this serializer. */ Class getSupportedClass(); /** * Asks the custom serializer to serialize the supplied value into the supplied * writer. The supplied value will be of the type reported in getSupportedClass() * or of a type extending therefrom. * * @param value The object to serialize. * * @param output The writer to place the serialized data. * * @param builtInSerializer The built-in serializer used by the client or the server. * * @throws XmlRpcException if the value somehow could not be serialized. Many serializers * rely on the built in serializer which also may throw this * exception. * * @throws IOException if there was an error serializing the value through the * writer. The exception is the exception thrown by the * writer, which in most cases will be a StringWriter, in which * case this exception will never occurr. XmlRpcSerializer and * custom serializers may, however, be used outside of the * XML-RPC library to encode information in XML-RPC structs, in * which case the writer potentially could be writing the * information over a socket stream for instance. */ void serialize( Object value, Writer output, XmlRpcSerializer builtInSerializer ) throws XmlRpcException, IOException; }
ade98aa110190c4a787d866e4ca69066549e93c1
c2130380c15418002ebb8ed8b446093ccff5dcaf
/app/src/main/java/com/example/wechat/adapter/ContactAdapter.java
51143bc742fe5d0ab32de68f87fb63ad37f42e53
[]
no_license
salmonzhang/WeChat
6b68285a4068e8e04a4c976d2657b6ff155cfb11
e4f913f092c404c1f0f32197b1ebd50f3102387c
refs/heads/master
2021-01-15T19:04:24.800247
2017-10-26T03:46:36
2017-10-26T03:46:36
99,805,316
3
0
null
null
null
null
UTF-8
Java
false
false
3,802
java
package com.example.wechat.adapter; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.example.wechat.R; import com.example.wechat.Utils.StringUtils; import com.example.wechat.presenter.IContactAdapter; import java.util.List; /** * author:salmonzhang * Description: * Date:2017/8/15 0015 19:33 */ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactViewHolder> implements IContactAdapter { private List<String> mContactList; public ContactAdapter(List<String> contactsList) { mContactList = contactsList; } @Override public int getItemCount() { return mContactList == null?0:mContactList.size(); } //创建布局 @Override public ContactViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_contact,parent,false); return new ContactViewHolder(view); } //绑定数据 @Override public void onBindViewHolder(ContactViewHolder holder, final int position) { final String contact = mContactList.get(position); //填充数据 holder.mTvUsername.setText(contact); //获取联系人的首字母 String firstNum = StringUtils.getInitial(contact); holder.mTvSection.setText(firstNum); /** * 1:如果position = 0,则首字母显示 * 2:如果position != 0,则判断当前位置的首字母与前一个的首字母是否相等, * 2.1 如果相等,则不显示 * 2.2 如果不相等,则显示 */ if (position == 0) { holder.mTvSection.setVisibility(View.VISIBLE); } else { String preFirstNum = StringUtils.getInitial(mContactList.get(position - 1)); if (preFirstNum.equalsIgnoreCase(firstNum)) { holder.mTvSection.setVisibility(View.GONE); } else { holder.mTvSection.setVisibility(View.VISIBLE); } } //给ItemView绑定接口回调监听 /** * 点击监听 */ holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mOnContactClickListener.onClick(contact,position); } }); /** * 长点击监听 */ holder.itemView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { mOnContactClickListener.onLongClick(contact,position); return true; } }); } //提供一个方法让RecyclerView获取适配器中的数据集合 @Override public List<String> getItems() { return mContactList; } //给RecyclerView定义回调接口 public interface onContactClickListener{ void onClick(String contact,int postion); void onLongClick(String contact,int postion); } private onContactClickListener mOnContactClickListener; public void setOnContactClickListener(onContactClickListener onContactClickListener) { mOnContactClickListener = onContactClickListener; } class ContactViewHolder extends RecyclerView.ViewHolder{ private final TextView mTvSection; private final TextView mTvUsername; public ContactViewHolder(View itemView) { super(itemView); mTvSection = (TextView) itemView.findViewById(R.id.tv_section); mTvUsername = (TextView) itemView.findViewById(R.id.tv_username); } } }
fa0a3948377c02692d324d09a64ac54d3f4fbf18
a16611c75fa0c8699bdf97ab1a9d24c442d48a57
/ucloude-framework/src/main/java/cn/uway/ucloude/support/bean/PropConverter.java
48c98dfb7970283292ccd05719f93e8ae5359ab2
[]
no_license
un-knower/yuncaiji_v4
cfaf3f18accb794901f70f7252af30280414e7ed
a4ff027e485272b73e2c6fb3f1dd098f5499086b
refs/heads/master
2020-03-17T23:14:40.121595
2017-05-21T05:55:51
2017-05-21T05:55:51
134,036,686
0
1
null
2018-05-19T06:35:12
2018-05-19T06:35:12
null
UTF-8
Java
false
false
209
java
package cn.uway.ucloude.support.bean; public interface PropConverter<Source, Output> { /** * @param source 是原对象 * @return 这个属性的值 */ Output convert(Source source); }
519a126d33c42cf9a0456c96faf977aed5225808
7940c100aef94619e28126c521081c0c8b285484
/MakeWordsInCorrectOrder.java
d1bf7bc6ebe325caca9211ae334666306dcd9330
[]
no_license
juliasad18/scratches
844924139c00293e748d9f7c054421371b5a7ead
2f78d3eae9179f0853801f2071884c385ad73cd0
refs/heads/master
2022-11-26T20:48:55.276119
2020-08-06T09:01:30
2020-08-06T09:01:30
284,707,941
0
0
null
null
null
null
UTF-8
Java
false
false
948
java
import java.util.*; class MakeWordsInCorrectOrder { public static String order(String words) { String[] splitWordsArray = words.split(" "); int sequenceNumber = 0; String characterString = ""; HashMap<Integer, String> hashMap = new HashMap<>(); for (String i : splitWordsArray) { for(int k = 0; k < i.length(); k++) { characterString = String.valueOf(i.charAt(k)); if (characterString.matches("[123456789]")) { sequenceNumber = Integer.valueOf(characterString); hashMap.put(sequenceNumber, i); } } } Collection<String> orderedWordsList = hashMap.values(); String finalString = String.join(" ", orderedWordsList); return finalString; } public static void main(String[] args) { System.out.println(order("is2 Thi1s T4est 3a")); } }
99328d9c76de3e5834788314a54602ec04b0fb09
64004938ae0dc80db897ea4b29b8ab5eae53e090
/service/service_edu/src/main/java/com/marlowe/eduservice/entity/EduTeacher.java
a8ca7f370445b03d6dd63597f52062ae33b75253
[]
no_license
XMMarlowe/onlineEducation
4af28238c5c3b42e5d37b9f3ff0f0da0c3a123bd
e3f709b373114fe352cf285b062431d3891816bf
refs/heads/master
2023-07-19T04:40:32.644910
2021-08-19T02:55:04
2021-08-19T02:55:04
386,348,462
16
1
null
null
null
null
UTF-8
Java
false
false
1,613
java
package com.marlowe.eduservice.entity; import com.baomidou.mybatisplus.annotation.*; import java.util.Date; import java.io.Serializable; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; /** * <p> * 讲师 * </p> * * @author Marlowe * @since 2021-07-16 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @ApiModel(value="EduTeacher对象", description="讲师") public class EduTeacher implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "讲师ID") @TableId(value = "id", type = IdType.ID_WORKER_STR) private String id; @ApiModelProperty(value = "讲师姓名") private String name; @ApiModelProperty(value = "讲师简介") private String intro; @ApiModelProperty(value = "讲师资历,一句话说明讲师") private String career; @ApiModelProperty(value = "头衔 1高级讲师 2首席讲师") private Integer level; @ApiModelProperty(value = "讲师头像") private String avatar; @ApiModelProperty(value = "排序") private Integer sort; @ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除") @TableLogic private Boolean isDeleted; @ApiModelProperty(value = "创建时间") @TableField(fill = FieldFill.INSERT) private Date gmtCreate; @ApiModelProperty(value = "更新时间") @TableField(fill = FieldFill.INSERT_UPDATE) private Date gmtModified; }
f4634b20fa17d5201361d0e3cc23ddf965c266ba
bd86a38063721c75e21a7ba64a088e6eca5a0e7b
/familyeducationhelp-fe/app/src/main/java/com/example/familyeducationhelp/classList/wheelpickerwidget/WheelAdapter.java
caa8cc11fa858003f517ce67ddef48c5b744ad1d
[]
no_license
HpBoss/familyEducationHelp
dd850ba5227c262958d1b3e9093b7277d463fc99
c761d2979383535ff335ff6c2f6fc687ca84eaf6
refs/heads/master
2023-05-10T21:58:25.378286
2023-05-04T08:53:13
2023-05-04T08:53:13
197,902,586
1
0
null
null
null
null
UTF-8
Java
false
false
1,591
java
package com.example.familyeducationhelp.classList.wheelpickerwidget; import androidx.annotation.NonNull; import java.util.ArrayList; import java.util.List; /** * 滚轮数据适配器 * * @author <a href="mailto:[email protected]">liyujiang</a> * @date 2019/5/14 20:02 */ @SuppressWarnings({"unused"}) public class WheelAdapter<T> { private List<T> data; public WheelAdapter() { this.data = new ArrayList<>(); } public int getItemCount() { return data.size(); } public T getItem(int position) { final int itemCount = getItemCount(); if (itemCount == 0) { return null; } int index = (position + itemCount) % itemCount; return data.get(index); } public String getItemText(int position, Formatter formatter) { T item = getItem(position); if (item == null) { return ""; } if (formatter != null) { return formatter.formatItemText(position, item); } return item.toString(); } public List<T> getData() { return data; } public void setData(List<T> data) { this.data.clear(); this.data.addAll(data); } public void addData(List<T> data) { this.data.addAll(data); } public int getItemPosition(T item) { int position = -1; if (data != null) { return data.indexOf(item); } return position; } public interface Formatter { String formatItemText(int position, @NonNull Object object); } }
58d780067403cbf02917b66d5f15cc7d97cffd9f
57267ca8d379893409325b05a4e4a1f2af4a4732
/SpringCRUDExam/src/main/java/egovframework/student/service/StudentService.java
94a0ca5f012e5f8562d3a99527f033eedcea7a0c
[]
no_license
id-remember/webpro-final2
c7f71a9e35aae53ade4494751ea89ccad3747c19
ba7ae27ad53a8d0ac0e20974d72ca0420d01e71d
refs/heads/master
2020-06-12T09:59:03.823456
2016-12-05T05:25:33
2016-12-05T05:25:33
75,590,984
0
0
null
null
null
null
UTF-8
Java
false
false
279
java
package egovframework.student.service; import java.util.List; import egovframework.student.StudentVO; public interface StudentService { void insertStudent(StudentVO vo) throws Exception; List<StudentVO> selectStudentList() throws Exception; }
[ "2_201600001@P3211-XPS15" ]
2_201600001@P3211-XPS15
ceb1fcadefb36a52e22765ad48fd7eded797601c
7c7cc5de91a9cffbf14174d7b7a3d4c4c21fe86f
/load_balancer/src/oss/distributor/DataMover.java
21647deec5bcc8177481cce146a04535b56536d4
[]
no_license
compuwizard123/csse477-simple-web-server
eb5e5e8c6ffbcaf344ea65b81f77f9426434ffa9
a7a12ec721b4cf7bca5f80186dbd5168cc19744e
refs/heads/master
2020-05-18T11:32:09.308609
2012-10-30T17:59:00
2012-10-30T17:59:00
null
0
0
null
null
null
null
UTF-8
Java
false
false
23,023
java
/* ***************************************************************************** * $Id: DataMover.java,v 1.14 2003/08/06 21:26:13 jheiss Exp $ ***************************************************************************** * This class passes data back and forth from clients and servers for * established connections through the load balancer. ***************************************************************************** * Copyright 2003 Jason Heiss * * This file is part of Distributor. * * Distributor 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. * * Distributor 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 Distributor; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************** */ package oss.distributor; import java.io.IOException; import java.net.Socket; import java.nio.ByteBuffer; import java.nio.channels.Selector; import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; import java.nio.channels.ClosedChannelException; import java.nio.channels.CancelledKeyException; import java.util.List; import java.util.LinkedList; import java.util.Map; import java.util.HashMap; import java.util.Iterator; import java.util.logging.Logger; class DataMover implements Runnable { Target target; boolean halfClose; Selector selector; Logger logger; List<DistributionAlgorithm> distributionAlgorithms; Map<SocketChannel, SocketChannel> clients; Map<SocketChannel, SocketChannel> servers; List<Connection> newConnections; List<SocketChannel> channelsToReactivate; DelayedMover delayedMover; long clientToServerByteCount; long serverToClientByteCount; Thread thread; final int BUFFER_SIZE = 128 * 1024; protected DataMover( Distributor distributor, Target target, boolean halfClose) { logger = distributor.getLogger(); distributionAlgorithms = distributor.getDistributionAlgorithms(); this.target = target; this.halfClose = halfClose; try { selector = Selector.open(); } catch (IOException e) { logger.severe("Error creating selector: " + e.getMessage()); System.exit(1); } clients = new HashMap<SocketChannel, SocketChannel>(); servers = new HashMap<SocketChannel, SocketChannel>(); newConnections = new LinkedList<Connection>(); channelsToReactivate = new LinkedList<SocketChannel>(); delayedMover = new DelayedMover(); clientToServerByteCount = 0; serverToClientByteCount = 0; // Create a thread for ourselves and start it thread = new Thread(this, toString()); thread.start(); } /* * Completed connections established by a distribution algorithm are * handed to the corresponding Target, which it turn registers them * with us via this method. */ protected void addConnection(Connection conn) { // Add connection to a list that will be processed later by // calling processNewConnections() synchronized (newConnections) { newConnections.add(conn); } // Wakeup the select so that the new connection list gets // processed selector.wakeup(); } /* * Process new connections queued up by calls to addConnection() * * Returns true if it did something (i.e. the queue wasn't empty). */ private boolean processNewConnections() { boolean didSomething = false; synchronized (newConnections) { Iterator<Connection> iter = newConnections.iterator(); while(iter.hasNext()) { Connection conn = iter.next(); iter.remove(); SocketChannel client = conn.getClient(); SocketChannel server = conn.getServer(); try { logger.finest("Setting channels to non-blocking mode"); client.configureBlocking(false); server.configureBlocking(false); clients.put(client, server); servers.put(server, client); logger.finest("Registering channels with selector"); client.register(selector, SelectionKey.OP_READ); server.register(selector, SelectionKey.OP_READ); } catch (IOException e) { logger.warning( "Error setting channels to non-blocking mode: " + e.getMessage()); try { logger.fine("Closing channels"); client.close(); server.close(); } catch (IOException ioe) { logger.warning("Error closing channels: " + ioe.getMessage()); } } didSomething = true; } } return didSomething; } /* * In the moveData() method, if we have a destination channel which * we aren't immediately able to write data to, we de-activate the * corresponding source channel from the selector until DelayedMover * is able to transmit all of that delayed data. This method is * used by DelayedMover to tell us that all of the data from a * channel has been sent to its destination, and thus that we can * re-activate the channel with the selector and read more data from * it. */ protected void addToReactivateList(SocketChannel channel) { // Add channel to a list that will be processed later by // calling processReactivateList() synchronized (channelsToReactivate) { channelsToReactivate.add(channel); } // Wakeup the select so that the list gets processed selector.wakeup(); } /* * Process channels queued up by calls to addToReactivateList() * * Returns true if it did something (i.e. the queue wasn't empty). */ private boolean processReactivateList() { boolean didSomething = false; synchronized (channelsToReactivate) { Iterator<SocketChannel> iter = channelsToReactivate.iterator(); while(iter.hasNext()) { SocketChannel channel = iter.next(); iter.remove(); SelectionKey key = channel.keyFor(selector); try { // Add OP_READ back to the interest bits key.interestOps( key.interestOps() | SelectionKey.OP_READ); } catch (CancelledKeyException e) { // The channel has been closed or something similar, // nothing we can do about it. } didSomething = true; } } return didSomething; } public void run() { int selectFailureOrZeroCount = 0; ByteBuffer buffer = ByteBuffer.allocateDirect(BUFFER_SIZE); while(true) { // Register any new connections with the selector boolean pncReturn = processNewConnections(); // Re-activate channels with the selector boolean prlReturn = processReactivateList(); // Reset the failure counter if processNewConnections() or // processReactivateList() did something, as that would // explain why select would return with zero ready channels. if (pncReturn || prlReturn) { selectFailureOrZeroCount = 0; } // If we exceed the threshold of failed selects, pause // for a bit so we don't go into a tight loop if (selectFailureOrZeroCount >= 10) { logger.warning( "select appears to be failing repeatedly, pausing"); try { Thread.sleep(500); } catch (InterruptedException e) {} selectFailureOrZeroCount = 0; } // // Now select for any channels that have data to be moved // int selectReturn = 0; try { selectReturn = selector.select(); if (selectReturn > 0) { selectFailureOrZeroCount = 0; } else { selectFailureOrZeroCount++; } } catch (IOException e) { // The only exceptions thrown by select seem to be the // occasional (fairly rare) "Interrupted system call" // which, from what I can tell, is safe to ignore. logger.warning( "Error when selecting for ready channel: " + e.getMessage()); selectFailureOrZeroCount++; continue; } logger.finest( "select reports " + selectReturn + " channels ready to read"); // Work through the list of channels that have data to read Iterator<SelectionKey> keyIter = selector.selectedKeys().iterator(); while (keyIter.hasNext()) { SelectionKey key = keyIter.next(); keyIter.remove(); // Figure out which direction this data is going and // get the SocketChannel that is the other half of // the connection. SocketChannel src = (SocketChannel) key.channel(); SocketChannel dst; boolean clientToServer; if (clients.containsKey(src)) { clientToServer = true; dst = clients.get(src); } else if (servers.containsKey(src)) { clientToServer = false; dst = servers.get(src); } else { // We've been dropped from the maps, which means the // connection has already been closed. Nothing to // do except cancel our key (just to be safe) and // move on to the next ready key. key.cancel(); continue; } try { // Loop as long as the source has data to read // and we can write it to the destination. boolean readMore = true; while (readMore) { // Assume there won't be more data readMore = false; // Try to read data buffer.clear(); int numberOfBytes = src.read(buffer); logger.finest( "Read " + numberOfBytes + " bytes from " + src); if (numberOfBytes > 0) // Data was read { if (moveData( buffer, src, dst, clientToServer, key)) { readMore = true; } } else if (numberOfBytes == -1) // EOF { handleEOF(key, src, dst, clientToServer); } } } catch (IOException e) { logger.warning( "Error moving data between channels: " + e.getMessage()); closeConnection(src, dst, clientToServer); } } } } /* * Give the distribution algorithms a chance to review the data in * buffer, then attempt to send it to dst. * * Returns true is all of the data in buffer is successfully * transmitted to dst, false if some/all of it is delayed. */ private boolean moveData( ByteBuffer buffer, SocketChannel src, SocketChannel dst, boolean clientToServer, SelectionKey sourceKey) throws IOException { buffer.flip(); if (clientToServer) { clientToServerByteCount += buffer.remaining(); } else { serverToClientByteCount += buffer.remaining(); } // Give each of the distribution algorithms a // chance to inspect/modify the data stream Iterator<DistributionAlgorithm> iter = distributionAlgorithms.iterator(); ByteBuffer reviewedBuffer = buffer; while (iter.hasNext()) { DistributionAlgorithm algo = iter.next(); if (clientToServer) { reviewedBuffer = algo.reviewClientToServerData(src, dst, reviewedBuffer); } else { reviewedBuffer = algo.reviewServerToClientData(src, dst, reviewedBuffer); } } // Make an effort to send the data on to its destination dst.write(reviewedBuffer); // If there is still data in the buffer, hand it off to // DelayedMover if (reviewedBuffer.hasRemaining()) { logger.finer("Delaying " + reviewedBuffer.remaining() + " bytes from " + src + " to " + dst); // Copy the delayed data into a temporary buffer ByteBuffer delayedBuffer = ByteBuffer.allocate(reviewedBuffer.remaining()); delayedBuffer.put(reviewedBuffer); delayedBuffer.flip(); // De-activate the source channel from the selector by // removing OP_READ from the interest bits. (This is safer // than actually canceling the key and then re-registering // the channel later, there are race condition problems with // that approach leading to CanceledKeyExceptions.) We // don't want to read any more data from the source until we // get this delayed data written to the destination. // DelayedMover will re-activate the source channel (via // addToReactivateList()) when it has written all of the // delayed data. try { sourceKey.interestOps( sourceKey.interestOps() ^ SelectionKey.OP_READ); delayedMover.addToQueue( new DelayedDataInfo( dst, delayedBuffer, src, clientToServer)); } catch (CancelledKeyException e) { // The channel has been closed or something similar, // nothing we can do about it. } return false; } else { return true; } } private void handleEOF( SelectionKey key, SocketChannel src, SocketChannel dst, boolean clientToServer) throws IOException { if (halfClose) { // Cancel this key, otherwise this channel will repeatedly // trigger select to tell us that it is at EOF. key.cancel(); Socket srcSocket = src.socket(); Socket dstSocket = dst.socket(); // If the other half of the socket is already shutdown then // go ahead and close the socket if (srcSocket.isOutputShutdown()) { logger.finer("Closing source socket"); srcSocket.close(); } // Otherwise just close down the input stream. This allows // any return traffic to continue to flow. else { logger.finest("Shutting down source input"); srcSocket.shutdownInput(); } // Do the same thing for the destination, but using the // reverse streams. if (dstSocket.isInputShutdown()) { logger.finer("Closing destination socket"); dstSocket.close(); } else { logger.finest("Shutting down dest output"); dstSocket.shutdownOutput(); } // Clean up if both halves of the connection are now closed if (srcSocket.isClosed() && dstSocket.isClosed()) { dumpState(src, dst, clientToServer); } } else { // If half close isn't enabled, just close the connection. closeConnection(src, dst, clientToServer); } } private void closeConnection( SocketChannel src, SocketChannel dst, boolean clientToServer) { SocketChannel client; SocketChannel server; if (clientToServer) { client = src; server = dst; } else { server = src; client = dst; } closeConnection(client, server); } protected void closeConnection( SocketChannel client, SocketChannel server) { // Close both channels try { logger.fine("Closing channels"); client.close(); server.close(); } catch (IOException ioe) { logger.warning("Error closing channels: " + ioe.getMessage()); } dumpState(client, server); } private void dumpState( SocketChannel src, SocketChannel dst, boolean clientToServer) { SocketChannel client; SocketChannel server; if (clientToServer) { client = src; server = dst; } else { server = src; client = dst; } dumpState(client, server); } /* * Call this method when closing a connection to remove any * associated entries from the state tracking maps. */ private void dumpState(SocketChannel client, SocketChannel server) { clients.remove(client); servers.remove(server); delayedMover.dumpDelayedState(client, server); } public long getClientToServerByteCount() { return clientToServerByteCount; } public long getServerToClientByteCount() { return serverToClientByteCount; } public String toString() { return getClass().getName() + " for " + target.getInetAddress() + ":" + target.getPort(); } protected String getMemoryStats(String indent) { String stats = indent + clients.size() + " entries in clients Map\n"; stats += indent + servers.size() + " entries in servers Map\n"; stats += indent + newConnections.size() + " entries in newConnections List\n"; stats += indent + channelsToReactivate.size() + " entries in channelsToReactivate List\n"; stats += indent + selector.keys().size() + " entries in selector key Set\n"; stats += indent + "DelayedMover:\n"; stats += delayedMover.getMemoryStats(indent); return stats; } class DelayedMover implements Runnable { Selector delayedSelector; List<DelayedDataInfo> queue; Map<SocketChannel, DelayedDataInfo> delayedInfo; Thread thread; DelayedMover() { try { delayedSelector = Selector.open(); } catch (IOException e) { logger.severe("Error creating selector: " + e.getMessage()); System.exit(1); } queue = new LinkedList<DelayedDataInfo>(); delayedInfo = new HashMap<SocketChannel, DelayedDataInfo>(); // Create a thread for ourselves and start it thread = new Thread(this, toString()); thread.start(); } /* * Used by DataMover to register a destination with us. */ void addToQueue(DelayedDataInfo info) { // Add channel to a list that will be processed later by // calling processQueue() synchronized (queue) { queue.add(info); } // Wakeup the select so that the new connection list // gets processed delayedSelector.wakeup(); } /* * Process the list created by addToQueue() */ private boolean processQueue() { boolean didSomething = false; synchronized (queue) { Iterator<DelayedDataInfo> iter = queue.iterator(); while (iter.hasNext()) { DelayedDataInfo info = iter.next(); iter.remove(); SocketChannel dst = info.getDest(); // Store the info in a map for later use synchronized (delayedInfo) { delayedInfo.put(dst, info); } // Check to see if we already have a key registered // for this channel. SelectionKey key = dst.keyFor(delayedSelector); if (key == null) { // Nope, no key already registered. Register a // new one. logger.finest( "Registering channel with selector"); try { dst.register( delayedSelector, SelectionKey.OP_WRITE); } catch (ClosedChannelException e) { // If the channel is already closed, there isn't // much else we can do to it. DataMover will // clean things up. } } else { // We already have a key registered, make sure // it has the right interest bits. try { key.interestOps( key.interestOps() | SelectionKey.OP_WRITE); } catch (CancelledKeyException e) { // The channel has been closed or something // similar, nothing we can do about it. // DataMover will clean things up. } } didSomething = true; } } return didSomething; } public void run() { int selectFailureOrZeroCount = 0; while (true) { // Register any new connections with the selector boolean pqReturn = processQueue(); // Reset the failure counter if processQueue() did // something, as that would explain why select would // return with zero ready channels. if (pqReturn) { selectFailureOrZeroCount = 0; } // If we exceed the threshold of failed selects, pause // for a bit so we don't go into a tight loop if (selectFailureOrZeroCount >= 10) { logger.warning( "select appears to be failing repeatedly, pausing"); try { Thread.sleep(500); } catch (InterruptedException e) {} selectFailureOrZeroCount = 0; } // Now select for any channels that are ready to write try { int selectReturn = delayedSelector.select(); if (selectReturn > 0) { selectFailureOrZeroCount = 0; } else { selectFailureOrZeroCount++; } logger.finest( "select reports " + selectReturn + " channels ready to write"); } catch (IOException e) { // The only exceptions thrown by select seem to be the // occasional (fairly rare) "Interrupted system call" // which, from what I can tell, is safe to ignore. logger.warning( "Error when selecting for ready channel: " + e.getMessage()); selectFailureOrZeroCount++; continue; } // Work through the list of channels that are // ready to write Iterator<SelectionKey> keyIter = delayedSelector.selectedKeys().iterator(); SelectionKey key = keyIter.next(); keyIter.remove(); SocketChannel dst = (SocketChannel) key.channel(); DelayedDataInfo info; synchronized (delayedInfo) { info = delayedInfo.get(dst); } ByteBuffer delayedBuffer = info.getBuffer(); try { int numberOfBytes = dst.write(delayedBuffer); logger.finest( "Wrote " + numberOfBytes + " delayed bytes to " + dst + ", " + delayedBuffer.remaining() + " bytes remain delayed"); // If the buffer is now empty, we're done with // this channel. if (! delayedBuffer.hasRemaining()) { // Instead of canceling the key, we just // remove OP_WRITE from the interest bits. // This avoids a race condition leading to a // CanceledKeyException if DataMover gives // the channel back to us right away. It // means we're stuck with the key in our // selector until the connection is closed, // but that seems acceptable. try { key.interestOps( key.interestOps() ^ SelectionKey.OP_WRITE); } catch (CancelledKeyException e) { // The channel has been closed or something // similar, nothing we can do about it. // DataMover will clean things up. } SocketChannel src = info.getSource(); dumpDelayedState(info.getDest()); addToReactivateList(src); } } catch (IOException e) { logger.warning( "Error writing delayed data: " + e.getMessage()); closeConnection( dst, info.getSource(), info.isClientToServer()); } } } void dumpDelayedState(SocketChannel client, SocketChannel server) { dumpDelayedState(client); dumpDelayedState(server); } private void dumpDelayedState(SocketChannel dst) { synchronized (delayedInfo) { delayedInfo.remove(dst); } } public String toString() { return getClass().getName() + " for " + target.getInetAddress() + ":" + target.getPort(); } protected String getMemoryStats(String indent) { String stats = indent + queue.size() + " entries in queue List\n"; stats = indent + delayedInfo.size() + " entries in delayedInfo Map\n"; stats += indent + delayedSelector.keys().size() + " entries in delayedSelector key Set"; return stats; } } class DelayedDataInfo { SocketChannel dst; ByteBuffer buffer; SocketChannel src; boolean clientToServer; DelayedDataInfo( SocketChannel dst, ByteBuffer buffer, SocketChannel src, boolean clientToServer) { this.dst = dst; this.buffer = buffer; this.src = src; this.clientToServer = clientToServer; } SocketChannel getDest() { return dst; } ByteBuffer getBuffer() { return buffer; } SocketChannel getSource() { return src; } boolean isClientToServer() { return clientToServer; } } }