text stringlengths 14 410k | label int32 0 9 |
|---|---|
public Tile getOtherTile(Tile currentTile){
if (currentTile == null){
throw new IllegalArgumentException("currentTile may not be null");
}
if (currentTile == tile1) return tile2;
return tile1;
} | 2 |
public int getModifiers() {
ClassFile cf = getClassFile2();
int acc = cf.getAccessFlags();
acc = AccessFlag.clear(acc, AccessFlag.SUPER);
int inner = cf.getInnerAccessFlags();
if (inner != -1 && (inner & AccessFlag.STATIC) != 0)
acc |= AccessFlag.STATIC;
retu... | 2 |
public static int svm_check_probability_model(svm_model model)
{
if (((model.param.svm_type == svm_parameter.C_SVC || model.param.svm_type == svm_parameter.NU_SVC) &&
model.probA!=null && model.probB!=null) ||
((model.param.svm_type == svm_parameter.EPSILON_SVR || model.param.svm_type == svm_parameter.NU_SVR) &&... | 7 |
public double evaluate(double x) {
if(x < 0) return 0;
return 1;
} | 1 |
public static final int StateUpdateChar(int index)
{
if (index < 4)
return 0;
if (index < 10)
return index - 3;
return index - 6;
} | 2 |
@Override
public void moveSessionToCorrectThreadGroup(final Session session, int theme)
{
final int themeDex=CMath.firstBitSetIndex(theme);
if((themeDex>=0)&&(themeDex<Area.THEME_BIT_NAMES.length))
{
final ThreadGroup privateGroup=CMProps.getPrivateOwner(Area.THEME_BIT_NAMES[themeDex]+"PLAYERS");
if((priv... | 7 |
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... | 6 |
public int firstMissingPositive(int[] A) {
int len = A.length;
for (int i =0;i<len;i++){
while (A[i]!=i+1&&A[i]<=len&&A[i]>0&&A[i]!=A[A[i]-1]){
int temp = A[A[i]-1];
A[A[i]-1] = A[i];
A[i] = temp;
}
}
for (int i =0;i... | 7 |
public void renderizarEntidad(int xp, int yp, RepresentacionEntidad rep)
{
Sprite sprite = rep.getSprite();
final int tamanio = sprite.getTamanio();
xp -= xOffset;
yp -= yOffset;
for(int y = 0; y < tamanio; y++)
{
int ya = y + yp;
if(ya < 0 || ya >= altura)
break;
for(int x = 0; x <... | 9 |
public OptionsMenu() {
super();
/*try {
displayModes = Display.getAvailableDisplayModes();
for(DisplayMode d : displayModes)
modes += d.toString() + "\n";
} catch (LWJGLException e) {
e.printStackTrace();
}*/
Label optionsLabel = new Label("Options");
optionsLabel.setPosition(() -> Camera.ge... | 6 |
private boolean isValidCard(Card playedCard) {
// Grab our player index who wishes to play this card.
int curPlayerIndex = (this.firstToPlayIndex + this.cardsPlayed.getNumCards()) % PLAYER_COUNT;
Pile curPlayerHand = this.players[curPlayerIndex].getHandPile();
// If our card isn't even in our hand, there's a... | 5 |
public static boolean areIdenticalIterative(ListNode l1, ListNode l2) {
ListNode ptr1 = l1;
ListNode ptr2 = l2;
while (true) {
if (ptr1 == null && ptr2 == null) {
return true;
}
if (ptr1 == null && ptr2 != null) {
return false;
}
if (ptr2 == null && ptr1 != null) {
r... | 8 |
public Object getMedianElement() {
if (listHolder == null) {
System.out.println("Provided list is null.");
return null;
}
if (listHolder.next() == null
&& listHolder.getElement() == null) {
System.out.println("Provided list is empty.");
... | 6 |
Component getComponent(String GComponentInterfaceClassName) {
String clazz = GComponentInterfaceClassName;
if (!(clazz == null) && !(clazz.equals(""))) {
Class t = clazz2Class(clazz);
Constructor c = null;
Object[] o = {blackboard};
try {
c... | 8 |
public void setTileCircuit2(float x, float y, int circuit, int inputID){
Vector2f temp = new Vector2f(x,y);
for(Tile tile : tileList ) {
if (TileUtil.getCoordinate(tile.getPosition()).equals(temp)){
tile.setCircuit(circuit);
tile.setInput(inputID);
}
}
} | 2 |
public void leaveUser(int userID) {
alstLeftUser.add(userID);
Match currentMatch = getCurrentMatch(userID);
if(currentMatch == null){
//
}else{
getCurrentMatch(userID).setLeftUser(alstLeftUser.toArray(new Integer[0]));
}
} | 1 |
public boolean storeImageRGBFreqsToDb(String imageFileName, long[][][] rgbBin, long totalPixels) {
StopWatch sw = new StopWatch();
sw.start();
String insert_sql = "INSERT INTO filenames(filename) values(?)";
StringBuilder sql = new StringBuilder("INSERT INTO rgb_frequ... | 7 |
public void paivitaAukiolot(Aukiolo aukiolo) throws DAOPoikkeus {
// Avataan ensin tietokantayhteys
Connection yhteys = avaaYhteys();
try {
// Suoritetaan haku
// Alustetaan sql-lause
String sql = "UPDATE Aukiolot SET arkialku=?,arkiloppu=?,vklpalku=?,vklploppu=? WHERE aukioloID=1";
PreparedStatemen... | 1 |
public void inxbuild() {
int i, j, smallpos, smallval;
int[] p;
int[] q;
int previouscol, startpos;
previouscol = 0;
startpos = 0;
for (i = 0; i < netsize; i++) {
p = network[i];
smallpos = i;
... | 7 |
public int compareTo(TailString ts) {
for(int i=s.length()-1, j=ts.s.length()-1;; i--, j--)
if(i < 0) return j < 0 ? 0 : 1;
else if(j < 0) return -1;
else if(s.charAt(i) > ts.s.charAt(j)) return -1;
else if(s.charAt(i) < ts.s.charAt(j)) return 1;
} | 6 |
private void drawTetris( Graphics g, ImageObserver imgObserver ) {
// グリッドの描画
short[][] grid = _model.getGrid();
short[][] gridColor = _model.getGridColor();
for ( int y = 0; y < Game.GRID_Y; y++ ) {
for ( int x = 0; x < Game.GRID_X; x++ ) {
if (grid[ y ][ x ] == 1) {
g.drawImag... | 6 |
public Object match(final String path) {
if (rules.containsKey(path)) {
return rules.get(path);
}
int n = path.lastIndexOf('/');
for (Iterator it = lpatterns.iterator(); it.hasNext();) {
String pattern = (String) it.next();
... | 5 |
private void initializeCurrentTransition(IWorkbenchPartReference activePart) {
currentTransition = findTransitionContaining(activePart);
if(currentTransition == null)
currentTransition = findFirstNonEmptyTransition();
if(currentTransition == null)
currentTransition = transitions.get(0);
currentTran... | 2 |
@Override
public boolean equals(Object o )
{
if(o == null)
return false;
if(o == this)
return true;
if(!(o instanceof Fertigungsplan))
return false;
Fertigungsplan f = (Fertigungsplan)o;
if(f.nr != nr || f.id != id || f.auftragNr != au... | 7 |
public void visitLdcInsn(final Object cst) {
mv.visitLdcInsn(cst);
if (constructor) {
pushValue(OTHER);
if (cst instanceof Double || cst instanceof Long) {
pushValue(OTHER);
}
}
} | 3 |
public double standardizedAverageCorrelationCoefficientsWithTotals(){
if(!this.dataPreprocessed)this.preprocessData();
if(!this.covariancesCalculated)this.covariancesAndCorrelationCoefficients();
return this.standardizedMeanRhoWithTotals;
} | 2 |
public static void main(String[] args) {
try {
ArchitectureUi dialog = new ArchitectureUi();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
} | 1 |
protected static Object checkSurrounds(
Holding holding, int upgradeLevel, boolean verbose
) {
final boolean NV = ! verbose ;
float safety = 0 - holding.base().dangerMap.longTermVal(holding.origin()) ;
if (holding.stocks.amountOf(PRESSFEED) > 0.5f) safety += 1.5f ;
if (safety < SAFETY_NEEDS[u... | 5 |
@Override
public int hashCode() {
return this.username.hashCode();
} | 0 |
public void enable() throws IOException {
// This has to be synchronized or it can collide with the check in the task.
synchronized (optOutLock) {
// Check if the server owner has already set opt-out, if not, set it.
if (isOptOut()) {
configuration.set("opt-out", false);
... | 2 |
private void handleFirstStageMessage(FirstStageMessage fsm) {
MnPeerState peerState = mnPeer.getPeerState();
if(! mnPeer.isMainPeer()) {
throw new Error("First stage message must be forwarded to main peer");
}
if(ssCache.contains(fsm.getMessageId())) {
// Can happen if a 1st stage message is re-sent
/... | 8 |
public void Collision()
{
Actor collision1 = getOneIntersectingObject(Spikyball2.class);
Actor collision2 = getOneIntersectingObject(Spikyball3.class);
Actor collision3 = getOneIntersectingObject(Ghost.class);
if(collision1 != null)//if you have not run into it
{
World myWorld = getWor... | 6 |
public void increaseKey(int i, Key key) {
if (i < 0 || i >= NMAX) throw new IndexOutOfBoundsException();
if (!contains(i)) throw new NoSuchElementException("index is not in the priority queue");
if (keys[i].compareTo(key) >= 0) throw new IllegalArgumentException("Calling increaseKey() with given... | 4 |
public EPConnectablesDialog(ElementPanel panel, Component ele) {
this.setTitle("Input Connectors");
this.setModal(true);
for (Component e : panel.getElements()) {
if (e == ele)
continue;
if (e instanceof InputStub)
continue;
for (Connector c : e.getConnectors()) {
if (c instanceof InputConne... | 7 |
public CtClass makeClassIfNew(InputStream classfile)
throws IOException, RuntimeException
{
compress();
classfile = new BufferedInputStream(classfile);
CtClass clazz = new CtClassType(classfile, this);
clazz.checkModify();
String classname = clazz.getName();
C... | 1 |
public void XbIDX9 (int n, int Dir, String Step2){
String ff;
int ln;
switch(n)
{
case 0:
Step2 = Step2.replace("xb", "E0");
ff = Integer.toHexString(Dir);
ln = ff.length();
if(ln == 1)
ff = "0" + ff;
Step2 = Step2.replace("ff", ff);
machCod2.add(Step2);
... | 8 |
protected PseudoSequencePair getFirstInstanceOfPrefixSequenceNEW(List<Itemset> prefix, int i){
int remainingToMatchFromPrefix = i;
List<Position> listPositions = new ArrayList<Position>();
int prefixItemsetPosition = 0;
// for each itemset of sequence
for(int j=0; j< size(); j++){
int itemInPrefi... | 9 |
public static Stella_Object inlinableMethodBody(MethodSlot method) {
{ Cons definition = null;
Stella_Object body = KeyValueList.dynamicSlotValue(method.dynamicSlots, Stella.SYM_STELLA_CACHED_INLINABLE_METHOD_BODY, null);
if (body == method) {
return (null);
}
if (body != null) {
... | 7 |
public void setCitta(String citta) {
this.citta = citta;
} | 0 |
public PersistenceDelegate getPersistenceDelegate(Class<?> type) {
if (type == null) {
return nullPD; // may be return a special PD?
}
// registered delegate
PersistenceDelegate registeredPD = delegates.get(type);
if (registeredPD != null) {
return regist... | 9 |
public int toInt(Piece p){
if(p.toString().charAt(1)== 'P')
return 1;
if(p.toString().charAt(1)=='N')
return 3;
if(p.toString().charAt(1)=='B')
return 4;
if(p.toString().charAt(1)== 'R')
return 5;
if(p.toString().charAt(1)== 'Q')
return 9;
if(p.toString().charAt(1)== 'K')
return 50;
if(p... | 7 |
public void stop() {
// Note: writePointer will be one ahead of the last message byte, so
// we can read it as size in this case
byte[] message = new byte[writePointer];
for(int i = 0; i < writePointer; i++) {
message[i] = currentMessage[i];
}
synchronized(messageBuffer) {
messageBuffer.add(me... | 1 |
public static void main(String[] argv) {
try {
// Retrieve a character in a Xml file
Character character = XmlMarshaller.unMarshallCharacter();
// Default localhost host and default port 1099 is used by RMI
Registry registry = LocateRegistry.getRegistry();
Registry registry2 = LocateRegistry.getRegist... | 6 |
@Override
public void run(){
try{
System.out.println("waiting for worker join in");
while(true){
Socket workerSocket = serverSocket.accept();
System.out.println("worker: "+workerSocket.getInetAddress()+":"+workerSocke... | 3 |
@Override
public void move(int x, int y, EPlayer player) {
try {
if (x >= 0 && x < super.getGameSize() && y >= 0 && y < super.getGameSize()) {
if (getField(x, y) == EField.Empty) {
super.move(x, y, player);
if(player == EPlayer.FirstPlayer ... | 8 |
@Override
public void mouseClicked(MouseEvent e) {
int sizeOfTile = this.getPreferredSize().height / drawingSize;
int x = e.getX();
int y = e.getY();
// convert coordinates to column and row
int i = (int) Math.floor((float) x / (float) sizeOfTile);
int j = (int) Math.... | 4 |
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SchoolOfficer that = (SchoolOfficer) o;
if (getType() != null ? !getType().equals(that.getType()) : that.getType() != null) return false;
if (i... | 7 |
private static boolean doCopyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException {
if (destFile.exists() && destFile.isDirectory()) {
throw new IOException("Destination '" + destFile + "' exists but is a directory");
}
FileInputStream fis = null;
F... | 6 |
public static void main(String args[]) {
/*
* Set the Nimbus look and feel
*/
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/*
* If Nimbus (introduced in Java SE 6) is not available, stay with the
* default look and fe... | 7 |
public Car getRentedCars(){
for (Car car:CARS){
if(car.isCarRented() == true){
return car;
}
}
return null;
} | 2 |
public static int ifOne(int n){
if(n==1 || n==2 || n==6)
return 3;
else if(n==3 || n==7 || n==8)
return 5;
else if(n==4 || n==5 || n==9)
return 4;
else
return 0;
} | 9 |
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other == this)
return true;
if (this.getRoom() == null)
return false;
// if (this.getMovie() == null)
// return false;
if ( !(other instanceof Seance))
return false;
Seance ... | 6 |
public static int[] getValue(Integer key) {
for (Integer i : map.keySet()) {
if (i==key) {
return map.get(i);
}
}
return null;
} | 2 |
public final NiklausParser.variabledeclaration_return variabledeclaration() throws RecognitionException {
NiklausParser.variabledeclaration_return retval = new NiklausParser.variabledeclaration_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token VAR24=null;
T... | 9 |
public void addMany(int ...elements)//parameter can be more.
{
if(manyItems + elements.length > data.length)
{
ensureCapacity((manyItems + elements.length)*2);
}
System.arraycopy(elements, 0, data, manyItems, elements.length);
manyItems += elements.length;
} | 1 |
@Override
public void start() throws ConnectorLoadException {
if (twitterFactory != null)
throw new ConnectorLoadException("Invalid state; Twitter factory already declared.");
if (twitterToken != null)
throw new ConnectorLoadException("Invalid state; Twitter OAuth tokens already declared.");
twitterFactory... | 2 |
@Override
protected void tick() {
Date currentDate = new Date();
double initialInterval = (double)(playerData.getUsedWeapon() - playerData.getstartCD());
double currentInterval = (double)(playerData.getUsedWeapon() - currentDate.getTime());
doub... | 6 |
protected void readImage() {
ix = readShort(); // (sub)image position & size
iy = readShort();
iw = readShort();
ih = readShort();
int packed = read();
lctFlag = (packed & 0x80) != 0; // 1 - local color table flag
interlace = (packed & 0x40) != 0; // 2 - inte... | 7 |
private void disconnectQuietly() {
synchronized(CONNECTION_LOCK) {
try {
//inform the server of the client's intent to disconnect
logger.finer("Sending disconnect packet");
sendPacket(Packet.createClientDisconnectPacket(clientId));
}
catch(CouldNotSendPacketException e) {
//ignore all excepti... | 1 |
@Test
public void testRollbackFail2() throws InvalidProcessStateException, ProcessExecutionException,
InterruptedException, ExecutionException, ProcessRollbackException {
for (int i = 0; i < 25; i++) {
logger.debug(String.format("Run %s/25.", i + 1));
// test executing component (execution ongoing)
IPr... | 5 |
public void displayData(List<Session> sessions, int trackCount) {
List<String> outputText = new ArrayList<String>();
Collections.sort(sessions);
String maxNetworkingTime = null;
Calendar cal = new GregorianCalendar();
SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mma");
Date d;
try {
d = dateF... | 9 |
public static void main(String[] args) {
String urlStr = null;
while (true) {
try {
System.out.println("Enter url: ");
// read from standard input
BufferedReader reader = new BufferedReader(
new InputStreamReader(System.in));
// read a line of input from the keyboard until the ENTER key is
... | 5 |
public static Class<?> getActualType(final Field field) {
Type type = field.getGenericType();
if (type instanceof ParameterizedType) {
return (Class<?>)((ParameterizedType) type).getActualTypeArguments()[0];
}
if (field.getType().isArray()) {
return field.getType().getComponentType();
}
// Field ty... | 4 |
public static void main(String[] args)
{
Fila aFila = new Fila(5); // criamos uma fila que comporta 5 itens
if (!aFila.isFull())
aFila.insert(10); // inserimos 4 itens
if (!aFila.isFull())
aFila.insert(20);
if (!aFila.isFull())
aFila.insert(30);
... | 9 |
public int getDepth()
{
return depth;
} | 0 |
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof HandTypesKey)) return false;
HandTypesKey that = (HandTypesKey) o;
if (getInt() != that.getInt()) return false;
if (getBoolean() != that.getBoolean()) return false;
return true;
} | 5 |
synchronized public static org.omg.CORBA.TypeCode type ()
{
if (__typeCode == null)
{
__typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (HelloCorba.HelloHelper.id (), "Hello");
}
return __typeCode;
} | 1 |
private static Boolean toBoolean(String paramName, Object o, boolean required) throws BadConfig {
if (o == null) {
if (required)
throw new BadConfig("Parameter \"" + paramName + "\" is required");
return null;
}
if (!(o instanceof Boolean))
throw new BadConfig("In parameter \"" + paramName + "\", val... | 3 |
@Override
public void processMessage(Privmsg privmsg) {
String[] parts = privmsg.getMessage().split(" ", 2);
int id = Integer.parseInt(parts[1]);
boolean state = false;
String action = "opened";
if (parts[0].charAt(1) == 'c') {
state = true;
action = "... | 8 |
static protected void UpdateLineColumn(char c)
{
column++;
if (prevCharIsLF)
{
prevCharIsLF = false;
line += (column = 1);
}
else if (prevCharIsCR)
{
prevCharIsCR = false;
if (c == '\n')
{
prevCharIsLF = true;
}
else
... | 6 |
public void visitStaticFieldExpr(final StaticFieldExpr expr) {
// C.f
// [declared field type] <= [C.f]
final MemberRef field = expr.field();
if (!expr.isDef()) {
start(expr, field.type());
}
} | 1 |
public int minJumpsRecursive(int[] a, int l, int h) {
/* Base case: array of length 1*/
if (l == h) {
return 0;
}
/* Base case: if no jumps out of position i */
if (a[l] == 0) {
return Integer.MAX_VALUE;
}
/* Compute the minJumps from all j rechable from l; pick the min and add 1 */
int m... | 6 |
public void buildListModel() {
if(mapPanel.backdrop != null) {
listModel.addElement(mapPanel.backdrop.toString());
}
if(!mapPanel.backgroundMusic.matches("")) {
listModel.addElement(mapPanel.backgroundMusic);
}
if(mapPanel.player != null) {
listModel.addElement(mapPanel.player.toString());
}
if(!... | 9 |
@Override
public boolean accept(File file) {
// Allow only directories, or files with ".txt" extension
return file.isDirectory() || file.getAbsolutePath().endsWith(".asm");
} | 1 |
private boolean jj_2_9(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_9(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(8, xla); }
} | 1 |
public Jason()
{
super("Jason", 8000, 300, 30, 80, as);
as.setSkill(0, "Poke", 30, 10, "Jason pokes his enemy lightly.");
as.setSkill(1, "Jab", 200, 60, "Jason jabs his enemy.");
as.setSkill(2, "Kick", 600, 100, "Jason kicks his enemy.");
as.setSkill(3, "Round-House Kick", 4500, 200, "Jason roundhouse kicks ... | 0 |
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
java.security.cert.X509Certificate[] chain = null;
try {
TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
KeyStore tks = KeyStore.getInstance("JKS");
tks.load(this.getClas... | 1 |
public void setWeapon(Weapon weapon) {
weaponIndexDirty = true;
for (int i = 0; i < getWeaponsData().size(); i++) {
if (getWeaponsData().get(i).getWeapon().equals(weapon)) {
weaponIndex = i;
break;
}
}
} | 2 |
public boolean validateTransition(MoveMessageType move, Integer playerID) {
// Ueberpruefen ob das Reinschieben der Karte gueltig ist
Position sm = new Position(move.getShiftPosition());
if (!sm.isInsertablePosition() || sm.equals(forbidden)) {
System.err.println("Warning: verbotene Position der Schiebekarte"... | 3 |
public static int maxSinglePathSum(TreeNode root, List<Integer> max) {
if (null == root) return 0;
int left = maxSinglePathSum(root.left, max);
int right = maxSinglePathSum(root.right, max);
int m = root.val;
m = m < left + root.val ? left + root.val : m;
m = m < right + root.val ? right +... | 6 |
public Object getValueAt(int row, int col) {
if(row>-1 && col>-1 && data!=null)
return data[row][col];
else
return null;
} | 3 |
private void pop(char c) throws JSONException {
if (this.top <= 0) {
throw new JSONException("Nesting error.");
}
char m = this.stack[this.top - 1] == null ? 'a' : 'k';
if (m != c) {
throw new JSONException("Nesting error.");
}
this.top -= 1;
... | 5 |
public void removePropertyChangeListener(PropertyChangeListener listener) {
propertyChangeSupport.removePropertyChangeListener(listener);
} | 0 |
public void checkPawn(){
if(color=='W'){
for(int i=0;i<8;i++){
if(aiarr[i][0].toString().charAt(1)=='P'){
aiarr[i][0]=new Queen(true);
}
}
}
if(color=='B'){
for(int i=0;i<8;i++){
if(aiarr[i][7].toString().charAt(1)=='P'){
aiarr[i][7]=new Queen(false);
}
}
}
} | 6 |
@Override
public int compareTo(TimeSeriesKey other) {
/*System.out.println("In Compareto.......");
if( this.kpi.compareTo(other.getKpi())!=0){ // compare keys
return this.kpi.compareTo(other.getKpi());
}else if (this.time.compareTo(other.getTimestamp())!=0){ //If KPI's are the same then order by time
r... | 6 |
public String getTax(){ return taxAdapter.getTaxes("20"); } | 0 |
public void leftMultiplyBy(Matrix that) {
double[][] values = new double[3][3];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
values[i][j] = that.m[i][0] * this.m[0][j] + that.m[i][1]
* this.m[1][j] + that.m[i][2] * this.m[2][j];
setComponents(values);
} | 2 |
@Override
public List<ProductModel> getProductByName(String productName)
throws WebshopAppException {
if (productName != null) {
try (Connection conn = getConnection()) {
String sql = "SELECT * FROM products WHERE name = ?";
try (PreparedStatement pstmt = conn.prepareStatement(sql)) {
setString... | 3 |
void render(Graphics2D g, Object p, boolean b) {
if (!renderable)
return;
double x = 0, y = 0, grx = -5.0, gry = -5.0, gd = 10.0;
if (p instanceof GayBerneParticle) {
GayBerneParticle gb = (GayBerneParticle) p;
x = gb.rx;
y = gb.ry;
grx += x - 0.2 * gb.breadth;
gry += y - 0.2 * gb.breadth;
... | 9 |
protected void computeCoordinates() {
final double innerRadiusValue = innerRadius.get();
final double startAngleValue = startAngle.get();
final double length = this.length.get();
final double graphicAngle = startAngleValue + (length / 2.0);
final double radiusValue = radius.get();
final double graphicRadius = in... | 4 |
public Result(PropertyTree firstMatchingNode) {
super();
nodes=new ArrayList<PropertyTree>(1);
nodes.add(firstMatchingNode);
} | 0 |
public void use(BattleFunction iface, PokeInstance user, PokeInstance target, Move move) {
PokeInstance p;
if (this.target == Target.target) {
p = target;
} else {
p = user;
}
p.battleStatus.flags[flag] = false;
if (text != null) {
text = text.replace("$target", p.getName());
if (p.battleStat... | 3 |
public void sort(double[] input) {
int N = input.length;
for (int sz = 2; sz < N*2; sz *= 2) {
for (int lo = 0; lo < N; lo += sz) {
int hi = Math.min(lo + sz, N);
int mid = lo + sz / 2;
MergeSort.merge(input, lo, mid, hi);
}
}
} | 2 |
public int match_main(String text, String pattern, int loc) {
// Check for null inputs.
if (text == null || pattern == null) {
throw new IllegalArgumentException("Null inputs. (match_main)");
}
loc = Math.max(0, Math.min(loc, text.length()));
if (text.equals(pattern)) {
// Shortcut (pot... | 6 |
public void processWeatherMultiplierConfiguration() throws ConfigurationException {
final String NO_WEATHER_STATION = "ERROR: cannot have weather_multiplier values without a weatherstation configured";
// If any of the multiplier values are configured then try and process a multiplier
// configuration.
... | 9 |
public static boolean checkHeader(ByteBuffer packet, int flag, int len, int id){
// (header s->c or c->s) [action flag | payload len | client id]
// (client id is 0 if client is sening connect request)
// parse packet
int buf_flag = packet.getInt(0);
int buf_len = packet.getInt(4);
int buf_id = packet.g... | 6 |
public static void addPrenotazioni(HttpServletRequest req, PrintWriter out) {
HttpSession s = req.getSession();
UserBean user = (UserBean) s.getAttribute("user");
String username = user.getUsername();
JSONArray jarr = null;
HashMap<String, Integer> carrello = new HashMap<>();
... | 9 |
public DefaultTokenizer() {
for (Operation op : Operation.values()) {
addOperation(op);
}
for (Function function : Function.values()) {
addFunction(function);
}
addConstant("pi", BigDecimal.valueOf(Math.PI));
addConstant("e", BigDecimal.valueOf(Ma... | 2 |
public void show(){ //Displays the Matching question.
Out.setDisp(2); //Set to Voice
Out.getDisp().renderLine(prompt);
String formL,formR; //Strings to hold left and right values to make formatting easier
for (int count = 1; count <= left.size() || count <= right.size(); count++){ //If either side still has ... | 4 |
public static String vectorCaddieToHTML(Vector<Caddie> rs){
if (rs.isEmpty())
return "<p class=\"plusbas\">Le caddie est vide.</p>";
String toReturn = "<TABLE BORDER='1' width=\"1000\">";
toReturn+="<CAPTION>Le caddie :</CAPTION>";
toReturn+="<TR>";
toReturn+="<TH> <i>Reservation n°</i></TH>";
toRet... | 3 |
Subsets and Splits
SQL Console for giganticode/java-cmpx-v1
The query retrieves a limited number of text entries within a specific length range, providing basic filtering but minimal analytical insight.