blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
7
332
content_id
stringlengths
40
40
detected_licenses
listlengths
0
50
license_type
stringclasses
2 values
repo_name
stringlengths
7
115
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
557 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
684M
star_events_count
int64
0
77.7k
fork_events_count
int64
0
48k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
82 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
5.41M
extension
stringclasses
11 values
content
stringlengths
7
5.41M
authors
listlengths
1
1
author
stringlengths
0
161
7477cdf5f29540dafaf1bde9fa6b3bce878a31be
1ec73a5c02e356b83a7b867580a02b0803316f0a
/java/bj/DesignPattern/JavaDesignPatterns/command/src/main/ShrinkSpell.java
e0d8e00564882dc641d21bb3897f9cfa6483bca2
[]
no_license
jxsd0084/JavaTrick
f2ee8ae77638b5b7654c3fcf9bceea0db4626a90
0bb835fdac3c2f6d1a29d1e6e479b553099ece35
refs/heads/master
2021-01-20T18:54:37.322832
2016-06-09T03:22:51
2016-06-09T03:22:51
60,308,161
0
1
null
null
null
null
UTF-8
Java
false
false
632
java
package bj.DesignPattern.JavaDesignPatterns.command.src.main; /** * ShrinkSpell is a concrete command */ public class ShrinkSpell extends Command { private Size oldSize; private Target target; @Override public void execute( Target target ) { oldSize = target.getSize(); target.setSize( Size.SMALL ); this.target = target; } @Override public void undo() { if ( oldSize != null && target != null ) { Size temp = target.getSize(); target.setSize( oldSize ); oldSize = temp; } } @Override public void redo() { undo(); } @Override public String toString() { return "Shrink spell"; } }
9f426bed475be5950e520a385647ae6c5952a169
a9e69dddd57a9094ce9d94555d90e80129a5232c
/src/main/java/com/znlccy/blog/controller/TagsController.java
b879f18ab40129caa22dc4b9a53e0fa226cce0bd
[]
no_license
znlccy/zc-blog
5a38d6d31ff8c432103786118233a492128c9f25
b02ce22cc551433c7dd6a1d6d9eea8ef5154625b
refs/heads/master
2020-08-03T12:57:14.999221
2019-09-30T02:39:00
2019-09-30T02:39:00
205,623,471
0
0
null
null
null
null
UTF-8
Java
false
false
476
java
package com.znlccy.blog.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; /** * Author: znlccy * Date: 2019-08-28-14:20 * Version: 1.0.0 * Comment: 标签控制器 */ @Controller @RequestMapping(value = "/tags") public class TagsController { @GetMapping(value = "") public String index() { return "tags"; } }
c81c9fafd1c0bf5a6ef1e993748afa6fcdc6dfdd
f841c70548ba6d8af6bab83320265cba7ea482cc
/src/main/java/com/example/demo/utils/SessionUtils.java
fdf03fb6e6c00a336e76474bb873f7aa3a8aed91
[]
no_license
WuHuanye/shopmall
1ff9761bb2be35cee4866c8b3a4e8effe84f4513
6d92fcd21abea2ecc67fc4438a8ee85d2de1d610
refs/heads/master
2023-04-09T23:51:46.535606
2021-04-23T11:48:56
2021-04-23T11:48:56
299,496,768
0
0
null
null
null
null
UTF-8
Java
false
false
897
java
package com.example.demo.utils; import com.example.demo.pojo.User; import com.example.demo.vo.SessionUser; import org.springframework.stereotype.Component; @Component public class SessionUtils { public static SessionUser getHeaderUser(User user){ SessionUser sessionHeaderUser = new SessionUser(); sessionHeaderUser.setUserId(user.getUserId()); sessionHeaderUser.setUsername(user.getUsername()); sessionHeaderUser.setRoleId(user.getRoleId()); //1为普通用户 2为管理员 sessionHeaderUser.setNickName(user.getNickName()); sessionHeaderUser.setHeadUrl(user.getHeadUrl()); sessionHeaderUser.setAddress(user.getAddress()); sessionHeaderUser.setBirthday(user.getBirthday()); sessionHeaderUser.setSex(user.getSex()); sessionHeaderUser.setEmail(user.getEmail()); return sessionHeaderUser; } }
b75012d0592564dcc8cb9c6477a577de20e0c471
e6e556c1d96290ea053a403c2c8c5412c72b32fe
/src/com/converter/GeoJsonConverter.java
d4f0fc79c7929daebf19996d2ada304ecaea787a
[]
no_license
Jack5s/DisasterProject
bc63fdcabac2efe52fa59f14a020cd7e0de7cdbe
801ec10befcf9fad4543a636e391719b9d69729e
refs/heads/master
2020-05-23T14:00:33.677167
2019-05-29T09:02:03
2019-05-29T09:02:03
177,116,568
0
0
null
null
null
null
UTF-8
Java
false
false
2,288
java
package com.converter; import java.lang.reflect.Field; import java.util.ArrayList; import com.disaster.Disaster; public class GeoJsonConverter { public static String toGeoJson(Disaster disaster) throws Exception { if (disaster == null) { return ""; } String geoGson = "{\"type\": \"Feature\","; geoGson += "\"geometry\": {\"type\":\"Point\",\"coordinates\": [" + disaster.longitude + "," + disaster.latitude + "]},"; geoGson += "\"properties\": {"; Field[] fieldArray = Disaster.class.getFields(); for (int i = 0; i < fieldArray.length; i++) { // Class<?> fieldType = fieldArray[i].getType(); Field field = fieldArray[i]; String fieldName = field.getName(); Object value = field.get(disaster); // System.out.println(fieldName); geoGson += "\"" + fieldName + "\":\"" + value + "\","; } geoGson = geoGson.substring(0, geoGson.length() - 1); geoGson += "}}"; return geoGson; } public static String toGeoJson(Disaster[] disasterArray) throws Exception { // String geoGson = "{\"type\": // \"FeatureCollection\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"features\": // ["; String geoGson = "{\"type\": \"FeatureCollection\",\"features\": ["; for (int i = 0; i < disasterArray.length; i++) { Disaster diasater = disasterArray[i]; String disasterGeoJson = toGeoJson(diasater); if (disasterGeoJson == "") { continue; } geoGson += disasterGeoJson + ","; } geoGson = geoGson.substring(0, geoGson.length() - 1); geoGson += "]}"; // System.out.println(geoGson); return geoGson; } public static String toGeoJson(ArrayList<Disaster> disasterList) throws Exception { // String geoGson = "{\"type\": // \"FeatureCollection\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"features\": // ["; String geoGson = "{\"type\": \"FeatureCollection\",\"features\": ["; for (Disaster disaster : disasterList) { String disasterGeoJson = toGeoJson(disaster); if (disasterGeoJson == "") { continue; } geoGson += disasterGeoJson + ","; } geoGson = geoGson.substring(0, geoGson.length() - 1); geoGson += "]}"; // System.out.println(geoGson); return geoGson; } }
73af09561d13f1845dfccddaee5ef417cb6867ce
0f995b7b560b5ea337ff1e404caf68cd5f97795a
/src/main/java/io/github/MorganeFt/exercice03/Exercice36.java
a1f699c5fb8387adf51476e5e960b71a0ce0acee
[]
no_license
MorganeFt/L3_cours
23282c72e60e893749e30a2048b769dc2c5072f7
8d9e65a078406e4aabbe03939d3d64e6807a9520
refs/heads/master
2022-12-22T03:44:29.229160
2020-09-15T16:40:18
2020-09-15T16:40:18
295,788,724
0
0
null
null
null
null
UTF-8
Java
false
false
994
java
package io.github.MorganeFt.exercice03; import java.util.Arrays; public class Exercice36 { public static void main(String[] arg) { biggestDivisor(); } static void biggestDivisor() { int numberDivisor = 0; int[] biggestNumber = new int[0]; for (int i = 1; i <= 10000; i++) { int counter = 0; for (int j = 1; j <= i; j++) { if (i % j == 0) { counter++; } } if (counter == numberDivisor) { biggestNumber = Arrays.copyOf(biggestNumber, biggestNumber.length + 1); biggestNumber[biggestNumber.length - 1] = i; } if (counter > numberDivisor) { numberDivisor = counter; biggestNumber = new int[1]; biggestNumber[0] = i; } } System.out.println("Among integers between 1 and 10000,"); System.out.println("The maximum number of divisors was " + numberDivisor); System.out.println("Numbers with that many divisors include:"); for (int i = 0; i < biggestNumber.length; i++) { System.out.println(biggestNumber[i]); } } }
e82e75e9f39567b2842e61b946b10285109c79bf
f0813057af64bb2f80eba410316afd80f249c6f3
/test/com/tomkp/california/coercion/FileCoercerTest.java
6f723f648ce5d5c958c04d8b6931267682d7156a
[]
no_license
tomkp/california
c0cc7b99904eda2c465ea7dad3d43dd3ace88690
815cc34b22c6673c872d1b0e4c085f9ec1f8dd5d
refs/heads/master
2020-05-19T14:53:35.396002
2013-04-02T14:05:34
2013-04-02T14:05:34
619,243
0
1
null
null
null
null
UTF-8
Java
false
false
900
java
package com.tomkp.california.coercion; import org.junit.Before; import org.junit.Test; import java.io.File; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class FileCoercerTest { private FileCoercer fileCoercer; @Before public void setUp() { fileCoercer = new FileCoercer(); } @Test(expected = RuntimeException.class) public void nullValueThrowsRuntimeException() { fileCoercer.coerce(null, null); } @Test(expected = RuntimeException.class) public void emptyStringThrowsRuntimeException() { fileCoercer.coerce("", null); } @Test public void coercesFile() { File file = fileCoercer.coerce("test/com/tomkp/california/coercion/FileCoercerTest.java", null); assertTrue(file.exists()); assertEquals("FileCoercerTest.java", file.getName()); } }
5f82727b68e76d10d3601b73943f47019e3e6cb9
22abd60cfadca17360b82616136525fd7526b8a1
/src/main/java/pl/mis/glycemicloadcalculator/entity/Product.java
593ba375f48e2b8678fc8fce865082a698b28a22
[]
no_license
mon-sliw/GlycemicLoadCalculator
de4e83cc761c65c6cc6f0e50219dcfce5105c8ab
4ad39eb48046a07ee7e7d0053d13847cf3e48e35
refs/heads/master
2023-05-09T23:20:38.241356
2021-05-30T15:04:47
2021-05-30T15:04:47
364,669,553
0
0
null
null
null
null
UTF-8
Java
false
false
523
java
package pl.mis.glycemicloadcalculator.entity; import lombok.Data; import javax.persistence.*; @Data @Entity @Table(name = "products") public class Product { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(name = "english_name") private String englishName; @Column(name = "polish_name") private String polishName; @Column(name = "glycemic_index") private String glycemicIndex; @Column(name = "carbohydrate") private String carbohydrate; }
5f3e0435be0ed6e3f6732f137a30271a291ec7b9
0d48af5cb8012a79b3327a1d3e7ff0e65af54ea8
/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/leader/choose/algorithms/package-info.java
e29369a215d44e6cd06f396bfbca3bc57376e6e9
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT", "LicenseRef-scancode-unknown" ]
permissive
apache/ozone
4426dd1ae18716d0585f1e846f7881970e3c4279
a3b89e73185894f905b4ad96cd6d78429497d0c9
refs/heads/master
2023-09-04T05:26:08.656890
2023-09-02T15:16:12
2023-09-02T15:16:12
212,382,406
509
386
Apache-2.0
2023-09-14T19:54:21
2019-10-02T15:56:19
Java
UTF-8
Java
false
false
917
java
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with this * work for additional information regarding copyright ownership. The ASF * licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package org.apache.hadoop.hdds.scm.pipeline.leader.choose.algorithms; // Various leader choosing algorithms.
a622dd3ffd49005c31844a371745ef0676b63572
e93a0bd007ad0418f7c5d2d03606243bc97cf50e
/src/demo/filter/LogFilter.java
54aa6cc4a36d2466a77e174fb21eb20f3772bb57
[]
no_license
vuonglam94/DemoServlet
238e269bf50e3d1da1c67fd3b41a83422b75e3e1
0ee7dedb948238fa6fd2875670d82ceedd5c4842
refs/heads/master
2022-09-22T19:22:30.541117
2020-06-02T15:35:00
2020-06-02T15:35:00
268,761,252
0
0
null
null
null
null
UTF-8
Java
false
false
1,069
java
package demo.filter; import java.io.IOException; import java.util.Date; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; public class LogFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { System.out.println("LogFilter init!"); } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; String servletPath = req.getServletPath(); System.out.println("#INFO " + new Date() + " - ServletPath :" + servletPath // + ", URL =" + req.getRequestURL()); // Cho phép request được đi tiếp. (Vượt qua Filter này). chain.doFilter(request, response); } @Override public void destroy() { System.out.println("LogFilter destroy!"); } }
51a8b6b105ac61fb469979fa634913ce3558486f
22cf6cf152e731051ebd3da902b8c16d742b697c
/app/src/main/java/com/great/picturegalleryapp/ItemAdapter.java
9bfcc4f7cf4fc67883fbf67a1856f1c7d335ce57
[]
no_license
AchinAsin/PictureGalleryApp
f093f2d0e07cebee6667bd433c12d3ba4e97170d
ee95453cd74437a8e07443958b28265e39c853e4
refs/heads/master
2023-05-14T20:09:58.997571
2021-06-03T11:21:29
2021-06-03T11:21:29
373,481,585
0
0
null
null
null
null
UTF-8
Java
false
false
3,286
java
package com.great.picturegalleryapp; import android.content.Context; import android.content.Intent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import java.util.ArrayList; import java.util.List; public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.ViewHolder> { private ArrayList<Photo> photo; private Context context; public ItemAdapter(ArrayList<Photo> photo, Context context) { this.photo = photo; this.context = context; } @NonNull @Override public ItemAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_files, viewGroup, false); return new ViewHolder(view); } @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { /*Photos positions = items.get(position); holder.textView1.setText(positions.getPage()); holder.textView2.setText(positions.getPages()); holder.textView3.setText(positions.getPerpage()); holder.textView4.setText(positions.getTotal());*/ Photo positions=photo.get(position); /*holder.textView1.setText(positions.getId()); holder.textView2.setText(positions.getTitle()); holder.textView3.setText(positions.getIsfamily()); holder.textView4.setText(positions.getUrlS());*/ holder.textView.setText(positions.getTitle()); Glide.with(context).load(positions.getUrlS()).into(holder.imageView); } @Override public int getItemCount() { return photo.size(); } public class ViewHolder extends RecyclerView.ViewHolder { /*private TextView textView1, textView2, textView3, textView4;*/ private ImageView imageView; private TextView textView; public ViewHolder(View view) { super(view); textView = (TextView) view.findViewById(R.id.textView); /*textView2 = (TextView) view.findViewById(R.id.textView2); textView3 = (TextView) view.findViewById(R.id.textView3); textView4 = (TextView) view.findViewById(R.id.textView4);*/ imageView = (ImageView) view.findViewById(R.id.imageView); //on item click view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int pos = getAdapterPosition(); if (pos != RecyclerView.NO_POSITION) { Photo clickedDataItem = photo.get(pos); Intent intent = new Intent(context, DetailActivity.class); intent.putExtra("title", photo.get(pos).getTitle()); intent.putExtra("url_s", photo.get(pos).getUrlS()); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } } }); } } }
a73ef9f26aa4071d419b8c79d2761ee347ad55e8
527e955a9fdfd1ca514478469a15af51b5fe370a
/test/MarketSourceMock.java
5a140cf877df723cce1f7ddf1ec7393815c51bbd
[]
no_license
bouskaJ/camel-k-example-knative
ca93bd9ebf775db4dd11de2366488792a2492558
748da42387f2ce2096d2ca480fb4b4e8259bbe6b
refs/heads/master
2023-03-06T07:25:12.229144
2020-05-20T16:35:24
2020-05-20T16:35:24
265,860,694
0
0
null
2020-05-21T13:50:33
2020-05-21T13:50:33
null
UTF-8
Java
false
false
865
java
package test; // camel-k: language=java import org.apache.camel.builder.RouteBuilder; public class MarketSourceMock extends RouteBuilder { @Override public void configure() throws Exception { from("timer:update?period=10000") .bean(this, "generate") .marshal().json() .log("Sending Mock BTC/USDT data to the broker: ${body}") .to("knative:event/market.btc.usdt"); } private int counter; public MockData generate() { boolean high = (this.counter++) % 2 == 0; if (high) { return new MockData(20.0); } return new MockData(10.0); } static class MockData { private double last; public MockData(double last) { this.last = last; } public double getLast() { return last; } @Override public String toString() { return "" + last; } } }
2e6e18cd57906cb8aa4ab103f27327ce7022e825
e64e86c058ba18c19178d99d7cb099ff8228aa1a
/src/main/java/org/apache/sysml/runtime/compress/ColGroupValue.java
febac4c565ad5e7648660f9a7b292324538b3a03
[ "Apache-2.0" ]
permissive
iamzken/systemml
67a1ba236dc6f173d38b84bdce09892fb6aaa2fb
3f3e927b88265be3c265fba896cb149b3aacf3e4
refs/heads/master
2021-03-27T15:16:34.150088
2017-09-04T23:08:16
2017-09-04T23:08:36
102,442,283
1
0
null
2017-09-05T06:22:07
2017-09-05T06:22:07
null
UTF-8
Java
false
false
12,211
java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.sysml.runtime.compress; import java.util.Arrays; import org.apache.sysml.runtime.DMLRuntimeException; import org.apache.sysml.runtime.functionobjects.Builtin; import org.apache.sysml.runtime.functionobjects.Builtin.BuiltinCode; import org.apache.sysml.runtime.functionobjects.KahanFunction; import org.apache.sysml.runtime.functionobjects.KahanPlus; import org.apache.sysml.runtime.instructions.cp.KahanObject; import org.apache.sysml.runtime.matrix.data.MatrixBlock; import org.apache.sysml.runtime.matrix.data.Pair; import org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator; import org.apache.sysml.runtime.matrix.operators.ScalarOperator; /** * Base class for column groups encoded with value dictionary. * */ public abstract class ColGroupValue extends ColGroup { private static final long serialVersionUID = 3786247536054353658L; public static boolean LOW_LEVEL_OPT = true; //sorting of values by physical length helps by 10-20%, especially for serial, while //slight performance decrease for parallel incl multi-threaded, hence not applied for //distributed operations (also because compression time + garbage collection increases) public static final boolean SORT_VALUES_BY_LENGTH = true; //thread-local pairs of reusable temporary vectors for positions and values private static ThreadLocal<Pair<int[], double[]>> memPool = new ThreadLocal<Pair<int[], double[]>>() { @Override protected Pair<int[], double[]> initialValue() { return new Pair<int[], double[]>(); } }; /** Distinct values associated with individual bitmaps. */ protected double[] _values; //linearized <numcol vals> <numcol vals> public ColGroupValue() { super((int[]) null, -1); } /** * Stores the headers for the individual bitmaps. * * @param colIndices * indices (within the block) of the columns included in this * column * @param numRows * total number of rows in the parent block * @param ubm * Uncompressed bitmap representation of the block */ public ColGroupValue(int[] colIndices, int numRows, UncompressedBitmap ubm) { super(colIndices, numRows); // sort values by frequency, if requested if( LOW_LEVEL_OPT && SORT_VALUES_BY_LENGTH && numRows > BitmapEncoder.BITMAP_BLOCK_SZ ) { ubm.sortValuesByFrequency(); } // extract and store distinct values (bitmaps handled by subclasses) _values = ubm.getValues(); } /** * Constructor for subclass methods that need to create shallow copies * * @param colIndices * raw column index information * @param numRows * number of rows in the block * @param values * set of distinct values for the block (associated bitmaps are * kept in the subclass) */ protected ColGroupValue(int[] colIndices, int numRows, double[] values) { super(colIndices, numRows); _values = values; } @Override public long estimateInMemorySize() { long size = super.estimateInMemorySize(); // adding the size of values size += 8; //array reference if (_values != null) { size += 32 + _values.length * 8; //values } return size; } /** * Obtain number of distinct sets of values associated with the bitmaps in this column group. * * @return the number of distinct sets of values associated with the bitmaps * in this column group */ public int getNumValues() { return _values.length / _colIndexes.length; } public double[] getValues() { return _values; } public double getValue(int k, int col) { return _values[k*getNumCols()+col]; } public MatrixBlock getValuesAsBlock() { boolean containsZeros = (this instanceof ColGroupOffset) ? ((ColGroupOffset)this)._zeros : false; int rlen = containsZeros ? _values.length+1 : _values.length; MatrixBlock ret = new MatrixBlock(rlen, 1, false); for( int i=0; i<_values.length; i++ ) ret.quickSetValue(i, 0, _values[i]); return ret; } public abstract int[] getCounts(); public abstract int[] getCounts(int rl, int ru); public int[] getCounts(boolean inclZeros) { int[] counts = getCounts(); if( inclZeros && this instanceof ColGroupOffset ) { counts = Arrays.copyOf(counts, counts.length+1); int sum = 0; for( int i=0; i<counts.length; i++ ) sum += counts[i]; counts[counts.length-1] = getNumRows()-sum; } return counts; } public MatrixBlock getCountsAsBlock() { return getCountsAsBlock(getCounts()); } public static MatrixBlock getCountsAsBlock(int[] counts) { MatrixBlock ret = new MatrixBlock(counts.length, 1, false); for( int i=0; i<counts.length; i++ ) ret.quickSetValue(i, 0, counts[i]); return ret; } protected int containsAllZeroValue() { int numVals = getNumValues(); int numCols = getNumCols(); for( int i=0, off=0; i<numVals; i++, off+=numCols ) { boolean allZeros = true; for( int j=0; j<numCols; j++ ) allZeros &= (_values[off+j] == 0); if( allZeros ) return i; } return -1; } public final double sumValues(int valIx) { final int numCols = getNumCols(); final int valOff = valIx * numCols; double val = 0.0; for( int i = 0; i < numCols; i++ ) { val += _values[valOff+i]; } return val; } public final double sumValues(int valIx, KahanFunction kplus) { return sumValues(valIx, kplus, new KahanObject(0,0)); } public final double sumValues(int valIx, KahanFunction kplus, KahanObject kbuff) { final int numCols = getNumCols(); final int valOff = valIx * numCols; kbuff.set(0, 0); for( int i = 0; i < numCols; i++ ) kplus.execute2(kbuff, _values[valOff+i]); return kbuff._sum; } protected final double[] sumAllValues(KahanFunction kplus, KahanObject kbuff) { return sumAllValues(kplus, kbuff, true); } protected final double[] sumAllValues(KahanFunction kplus, KahanObject kbuff, boolean allocNew) { //quick path: sum if( getNumCols()==1 && kplus instanceof KahanPlus ) return _values; //shallow copy of values //pre-aggregate value tuple final int numVals = getNumValues(); double[] ret = allocNew ? new double[numVals] : allocDVector(numVals, false); for( int k=0; k<numVals; k++ ) ret[k] = sumValues(k, kplus, kbuff); return ret; } protected final double sumValues(int valIx, double[] b) { final int numCols = getNumCols(); final int valOff = valIx * numCols; double val = 0; for( int i = 0; i < numCols; i++ ) { val += _values[valOff+i] * b[i]; } return val; } protected final double[] preaggValues(int numVals, double[] b) { return preaggValues(numVals, b, false); } protected final double[] preaggValues(int numVals, double[] b, boolean allocNew) { double[] ret = allocNew ? new double[numVals] : allocDVector(numVals, false); for( int k = 0; k < numVals; k++ ) ret[k] = sumValues(k, b); return ret; } /** * NOTE: Shared across OLE/RLE/DDC because value-only computation. * * @param result output matrix block * @param builtin function object * @param zeros indicator if column group contains zero values */ protected void computeMxx(MatrixBlock result, Builtin builtin, boolean zeros) { //init and 0-value handling double val = Double.MAX_VALUE * ((builtin.getBuiltinCode()==BuiltinCode.MAX)?-1:1); if( zeros ) val = builtin.execute2(val, 0); //iterate over all values only final int numVals = getNumValues(); final int numCols = getNumCols(); for (int k = 0; k < numVals; k++) for( int j=0, valOff = k*numCols; j<numCols; j++ ) val = builtin.execute2(val, _values[ valOff+j ]); //compute new partial aggregate val = builtin.execute2(val, result.quickGetValue(0, 0)); result.quickSetValue(0, 0, val); } /** * NOTE: Shared across OLE/RLE/DDC because value-only computation. * * @param result output matrix block * @param builtin function object * @param zeros indicator if column group contains zero values */ protected void computeColMxx(MatrixBlock result, Builtin builtin, boolean zeros) { final int numVals = getNumValues(); final int numCols = getNumCols(); //init and 0-value handling double[] vals = new double[numCols]; Arrays.fill(vals, Double.MAX_VALUE * ((builtin.getBuiltinCode()==BuiltinCode.MAX)?-1:1)); if( zeros ) { for( int j = 0; j < numCols; j++ ) vals[j] = builtin.execute2(vals[j], 0); } //iterate over all values only for (int k = 0; k < numVals; k++) for( int j=0, valOff=k*numCols; j<numCols; j++ ) vals[j] = builtin.execute2(vals[j], _values[ valOff+j ]); //copy results to output for( int j=0; j<numCols; j++ ) result.quickSetValue(0, _colIndexes[j], vals[j]); } //additional vector-matrix multiplication to avoid DDC uncompression public abstract void leftMultByRowVector(ColGroupDDC vector, MatrixBlock result) throws DMLRuntimeException; /** * Method for use by subclasses. Applies a scalar operation to the value * metadata stored in the superclass. * * @param op * scalar operation to perform * @return transformed copy of value metadata for this column group * @throws DMLRuntimeException if DMLRuntimeException occurs */ protected double[] applyScalarOp(ScalarOperator op) throws DMLRuntimeException { //scan over linearized values double[] ret = new double[_values.length]; for (int i = 0; i < _values.length; i++) { ret[i] = op.executeScalar(_values[i]); } return ret; } protected double[] applyScalarOp(ScalarOperator op, double newVal, int numCols) throws DMLRuntimeException { //scan over linearized values double[] ret = new double[_values.length + numCols]; for( int i = 0; i < _values.length; i++ ) { ret[i] = op.executeScalar(_values[i]); } //add new value to the end Arrays.fill(ret, _values.length, _values.length+numCols, newVal); return ret; } @Override public void unaryAggregateOperations(AggregateUnaryOperator op, MatrixBlock result) throws DMLRuntimeException { unaryAggregateOperations(op, result, 0, getNumRows()); } /** * * @param op aggregation operator * @param result output matrix block * @param rl row lower index, inclusive * @param ru row upper index, exclusive * @throws DMLRuntimeException on invalid inputs */ public abstract void unaryAggregateOperations(AggregateUnaryOperator op, MatrixBlock result, int rl, int ru) throws DMLRuntimeException; //dynamic memory management public static void setupThreadLocalMemory(int len) { Pair<int[], double[]> p = new Pair<int[], double[]>(); p.setKey(new int[len]); p.setValue(new double[len]); memPool.set(p); } public static void cleanupThreadLocalMemory() { memPool.remove(); } protected static double[] allocDVector(int len, boolean reset) { Pair<int[], double[]> p = memPool.get(); //sanity check for missing setup if( p.getValue() == null ) return new double[len]; //get and reset if necessary double[] tmp = p.getValue(); if( reset ) Arrays.fill(tmp, 0, len, 0); return tmp; } protected static int[] allocIVector(int len, boolean reset) { Pair<int[], double[]> p = memPool.get(); //sanity check for missing setup if( p.getKey() == null ) return new int[len]; //get and reset if necessary int[] tmp = p.getKey(); if( reset ) Arrays.fill(tmp, 0, len, 0); return tmp; } }
38274efb2c6428e27816630b4c4f7030724fc832
cd41353b832bb0040828443ce42fc1ad8509388f
/src/main/java/staff/Employee.java
33c36f27a181a18e67f0fefd93c899da1a7fa21d
[]
no_license
S-Mcilroy/CodeClan-Java-Inheritance
38c4a9f922e73e431674d942d4f7aef946a7b8d9
a14d1729103586f6dafc0b9fcabf0934dbf6e5ba
refs/heads/master
2021-04-18T04:28:31.362651
2020-03-23T17:54:51
2020-03-23T17:54:51
249,504,752
0
0
null
2020-10-13T20:35:46
2020-03-23T17:55:35
Java
UTF-8
Java
false
false
981
java
package staff; public abstract class Employee { private String name; private int niNumber; private double salary; public Employee(String name, int niNumber, double salary){ this.name = name; this.niNumber = niNumber; this.salary = salary; } public String getName() { return name; } public int getNiNumber() { return niNumber; } public double getSalary() { return salary; } public String raiseSalary(double increase){ if (increase <= 0 ){ return "Please Enter an Amount Greater than Zero!"; } else { this.salary += increase; return null; } } public double payBonus(){ return (this.salary/100); } public String setName(String name){ if (name == null){ return "Please Enter a Name!"; } else { this.name = name; return null; } } }
e1cd6b07a9a0583c94b9c14ac800db91d9ef3265
564d9b15804522af74e8573cb235a12af7ea6180
/src/org/densyakun/bukkit/hubspawn/HubSpawnListener.java
0047e69fbfadfb32a19858332f301cbcd7a3c059
[]
no_license
Densyakun/BukkitPlugin_HubSpawn
8b4031569f4ea3e85ed2c2c13455188f72354b24
9b03fdb53a38bae1607ed822ff9b60a7d0c6de71
refs/heads/master
2021-01-10T18:05:09.365553
2018-02-10T21:03:01
2018-02-10T21:03:01
48,908,693
1
0
null
null
null
null
UTF-8
Java
false
false
270
java
package org.densyakun.bukkit.hubspawn; import org.bukkit.entity.Player; /**Ver 1.7~*/ public interface HubSpawnListener { public void spawn(Main main, Player player); public void bed(Main main, Player player); public void home(Main main, Player player, Home home); }
c43ae1ff7fc890cdbff2090700fd421a5b0bc516
72c8e6554f6cf82c9dbde5fc6eb5d3d4b2eec964
/src/main/java/com/example/concurrentdemo/SimpleDaemons.java
d9e62114fe8b09a75680b2e771266b3d12d85e10
[]
no_license
qpxiwo1937/springboottest
697934c6fdf34c8331ac638e117bd30dec35291d
527288f69d3e15c9491e64b03715ccc6f0f0aca9
refs/heads/master
2023-01-09T09:46:08.352716
2020-11-09T03:29:26
2020-11-09T03:29:26
311,204,377
0
0
null
null
null
null
UTF-8
Java
false
false
995
java
package com.example.concurrentdemo; import java.util.concurrent.TimeUnit; /** * @author 郭文文 * @version 1.0 * @date 2020/11/1 19:38 */ public class SimpleDaemons implements Runnable { @Override public void run() { while (true) { try { TimeUnit.MILLISECONDS.sleep(100); System.out.println(Thread.currentThread() + " " + this); } catch (InterruptedException e) { e.printStackTrace(); System.out.println("sleep() interrupted"); } } } public static void main(String[] args) { for (int i = 0; i < 10; i++) { Thread thread = new Thread(new SimpleDaemons()); thread.setDaemon(true); thread.start(); } System.out.println("All daemons started"); try { TimeUnit.MILLISECONDS.sleep(300); } catch (InterruptedException e) { e.printStackTrace(); } } }
6632ce147be2f6bebe62e3dc18c7cc9176f9501b
16dfb3ab6ac4d3f5889eee6914882bd7643bcbed
/ArticleRep2/src/cp/articlerep/Worker.java
fa8d6d43443738fdb7a3bf90387e5516ca3804e4
[]
no_license
GoncaloSousaMendes/CP-mainProj
4ce4f7eb6779398dfd343e41620d462ff15bf142
b489c6aef8e39d045de6a317f6510fee70032c94
refs/heads/master
2020-04-09T23:37:24.446036
2016-12-02T11:33:22
2016-12-02T11:33:22
null
0
0
null
null
null
null
UTF-8
Java
false
false
5,885
java
package cp.articlerep; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.Random; import cp.articlerep.ds.Iterator; import cp.articlerep.ds.LinkedList; import cp.articlerep.ds.List; public class Worker { public static final boolean DO_VALIDATION = Boolean.parseBoolean(System .getProperty("cp.articlerep.validate")); private int dictSize; private String dictFile; private int put; private int del; private int get; private int authors; private int keywords; private int findList; private String[] wordArray; private Thread[] workers; private Job[] jobs; private RepositoryReadWriteLock repository; private volatile boolean running; private volatile boolean pause; private int totalOperations; /** * @param dictSize * @param dictFile * @param put * @param del * @param get * @param authors * @param keywords * @param findList */ public Worker(int dictSize, String dictFile, int put, int del, int get, int authors, int keywords, int findList) { this.dictSize = dictSize; this.dictFile = dictFile; this.put = put; this.del = del; this.get = get; this.authors = authors; this.keywords = keywords; this.findList = findList; populateWordArray(); this.workers = null; this.jobs = null; this.repository = new RepositoryReadWriteLock(dictSize); this.running = true; this.pause = true; this.totalOperations = 0; } public RepositoryReadWriteLock getRepository() { return this.repository; } private void populateWordArray() { wordArray = new String[dictSize]; try { BufferedReader br = new BufferedReader( new FileReader(this.dictFile)); String line; int i = 0; while ((line = br.readLine()) != null && i < dictSize) { wordArray[i] = line; i++; } if (i < dictSize) { dictSize = i; } br.close(); } catch (FileNotFoundException e) { e.printStackTrace(); System.exit(0); } catch (IOException e) { e.printStackTrace(); System.exit(0); } } private synchronized void updateOperations(int operations) { this.totalOperations += operations; } public synchronized int getTotalOperations() { return totalOperations; } public class Job implements Runnable { private int put; private int del; private int get; private int count; private Random rand; private volatile boolean paused; /** * @param put percentage of insert article operations * @param del percentage of remove article operations * @param get percentage of find article operations, which is * shared by findByAuthor and findByKeyword */ public Job(int put, int del, int get) { this.put = put; this.del = del; this.get = get; this.count = 0; try { Thread.sleep(100); } catch (InterruptedException e) { } this.rand = new Random(System.nanoTime()); paused = true; } private boolean contains(List<String> list, String word) { Iterator<String> it = list.iterator(); while (it.hasNext()) { if (it.next().compareTo(word) == 0) return true; } return false; } private Article generateArticle() { int i = rand.nextInt(dictSize); Article a = new Article(i, wordArray[i]); int nauthors = authors; while (nauthors > 0) { int p = rand.nextInt(dictSize); String word = wordArray[p]; if (!contains(a.getAuthors(), word)) { a.addAuthor(word); nauthors--; } } int nkeywords = keywords; while (nkeywords > 0) { int p = rand.nextInt(dictSize); String word = wordArray[p]; if (!contains(a.getKeywords(), word)) { a.addKeyword(word); nkeywords--; } } return a; } private List<String> generateListOfWords() { List<String> res = new LinkedList<String>(); int nwords = findList; while (nwords > 0) { int p = rand.nextInt(dictSize); String word = wordArray[p]; if (!contains(res, word)) { res.add(word); nwords--; } } return res; } public void run() { while (pause) { Thread.yield(); } paused = true; while (running) { if (DO_VALIDATION) { boolean done = false; while (pause) { if (!done) { //System.out.println("Thread " //+ Thread.currentThread().getId() //+ ": Stoped"); paused = true; done = true; } } paused = false; } int op = rand.nextInt(100); if (op < put) { Article a = generateArticle(); repository.insertArticle(a); } else if (op < put + del) { int id = rand.nextInt(dictSize); repository.removeArticle(id); } else if (op < put + del + (get / 2)) { List<String> list = generateListOfWords(); repository.findArticleByAuthor(list); } else { List<String> list = generateListOfWords(); repository.findArticleByKeyword(list); } count++; } updateOperations(count); } } public void spawnThread(int nthreads) { workers = new Thread[nthreads]; jobs = new Job[nthreads]; for (int i = 0; i < nthreads; i++) { jobs[i] = new Job(put, del, get); workers[i] = new Thread(jobs[i]); } for (int i = 0; i < nthreads; i++) { workers[i].start(); } } public void joinThreads() { for (int i = 0; i < workers.length; i++) { try { workers[i].join(); } catch (InterruptedException e) { e.printStackTrace(); } } } public void startTest() { this.running = true; this.pause = false; } public void stopTest() { this.running = false; this.pause = false; } public void pauseTest() { this.pause = true; while (true) { boolean ok = true; for (int i = 0; i < jobs.length; i++) if (!jobs[i].paused) { ok = false; break; } if (ok) break; } } public void restartTest() { this.pause = false; } }
c36917d695b30e9eb8766e1b423938d2232d8d88
7948cf1a23c40e7054c6172a5a11eafd8269ae74
/src/test/java/com/project/professor/allocation/repository/CourseRepositoryTest.java
e30b2c36cd72786ae86f7ef2d672ce1b4b2fe013
[]
no_license
ClaraJaborandy/professor-allocation
acda7a37178d61fd4c05a27f32fba786dc1fafee
a50add0b0babf97c8f20c025f52d574f39804b46
refs/heads/master
2023-01-02T15:20:32.115855
2020-10-30T13:30:44
2020-10-30T13:30:44
307,503,913
0
0
null
null
null
null
UTF-8
Java
false
false
1,890
java
package com.project.professor.allocation.repository; import java.util.List; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.TestPropertySource; import com.project.professor.allocation.model.Course; @DataJpaTest @AutoConfigureTestDatabase(replace = Replace.NONE) @Rollback(false) @TestPropertySource(locations = "classpath:application.properties") public class CourseRepositoryTest { @Autowired private CourseRepository courseRepository; @Test public void findAll() { List<Course> courses = courseRepository.findAll(); courses.stream().forEach(System.out::println); } @Test public void findById() { Long id = 1L; Course course = courseRepository.findById(id).orElse(null); System.out.println(course); } @Test public void findByNameContainingIgnoreCase() { String name = "Course"; List<Course> courses = courseRepository.findByNameContainingIgnoreCase(name); courses.stream().forEach(System.out::println); } @Test public void save_create() { Course course = new Course(); course.setId(null); course.setName("historia"); course = courseRepository.save(course); System.out.println(course); } @Test public void save_update() { Course course = new Course(); course.setId(1L); course.setName("geografia"); course = courseRepository.save(course); System.out.println(course); } @Test public void deleteById() { Long id = 1L; courseRepository.deleteById(id); } @Test public void deleteAll() { courseRepository.deleteAllInBatch(); } }
e87cb61cd61873fe2c7fa3789ec417985bdf5826
a53db6654155e1d4293892aa97b2945fcd66566d
/src/main/java/pages/TravelerInsurancePage.java
7f16c3fe8c3739b52996b23efdd544ead160ffd7
[]
no_license
Aslan4242/firsttest
722d5a3ae0270ee1e5079dd0a60ee0308220bd1c
f45ef3ed944c940ce0546efeeaab166ef2c757c7
refs/heads/master
2021-07-13T13:10:43.535119
2019-10-17T20:34:41
2019-10-17T20:34:41
214,268,597
1
0
null
2020-10-13T16:45:11
2019-10-10T19:29:03
Java
UTF-8
Java
false
false
1,034
java
package pages; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.Wait; import org.openqa.selenium.support.ui.WebDriverWait; import steps.BaseSteps; public class TravelerInsurancePage { @FindBy(xpath = "//div[contains(@class,'sbrf-rich-outer')]/h1") public WebElement title; @FindBy(xpath = "//a[@target]//img[contains(@src,'portal')]") public WebElement button; public TravelerInsurancePage() { PageFactory.initElements(BaseSteps.getDriver(), this); } public void waitButtonClickable(){ Wait<WebDriver> wait = new WebDriverWait(BaseSteps.getDriver(), 5, 1000); wait.until(ExpectedConditions.visibilityOf( BaseSteps.getDriver().findElement(By.xpath("//a[@target]//img[contains(@src,'portal')]")))).click(); } }
225b3024a7fb28fc4dc17b3fd49555e52b0c355e
4fc1fe1bb33ab67490c4c18c10d512a484231f6b
/src/com/lzh/MobileSafe/AtoolsActivity.java
e64f8015fcebe4e51f61e77f38860f8902b4529d
[]
no_license
illidianlv/MobileSafe
bc7b8b2319e9ecd9bcb82d833126d947d491d49a
3fd8fd10bf2a662c4374cbc4844cb4b117007e14
refs/heads/master
2020-12-23T02:30:45.920091
2016-06-27T06:11:28
2016-06-27T06:11:28
62,029,967
1
0
null
null
null
null
GB18030
Java
false
false
3,407
java
package com.lzh.MobileSafe; import com.lzh.MobileSafe.utils.SmsUtils; import com.lzh.MobileSafe.utils.SmsUtils.SmsBackupCallBack; import com.lzh.MobileSafe.utils.SmsUtils.SmsRestoreCallBack; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.ProgressBar; import android.widget.Toast; public class AtoolsActivity extends Activity { // private ProgressBar pb_sms_backup; private ProgressDialog pd; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_atools); // pb_sms_backup = (ProgressBar) findViewById(R.id.pb_sms_backup); } /** * 点击进入号码归属地查询页面 * @param view */ public void numberQuery(View view){ Intent intent = new Intent(this, NumberAddressQueryActivity.class); startActivity(intent); } /** * 点击事件,短信备份 * @param view */ public void smsBackup(View view){ pd = new ProgressDialog(this); pd.setMessage("正在备份"); pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pd.show(); new Thread(){ public void run() { try { SmsUtils.backupSms(AtoolsActivity.this,new SmsBackupCallBack() { @Override public void onSmsBackup(int process) { pd.setProgress(process); } @Override public void beforeBackup(int max) { pd.setMax(max); } }); runOnUiThread(new Runnable() { public void run() { Toast.makeText(AtoolsActivity.this, "备份成功", 0).show(); } }); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); runOnUiThread(new Runnable() { public void run() { Toast.makeText(AtoolsActivity.this, "备份失败", 0).show(); } }); }finally{ pd.dismiss(); } }; }.start(); } /** * 点击事件,短信还原 * @param view */ public void smsRestore(View view){ pd = new ProgressDialog(this); pd.setMessage("正在还原"); pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pd.show(); new Thread(){ public void run() { try { SmsUtils.restoreSms(AtoolsActivity.this,false,new SmsRestoreCallBack() { @Override public void onRestore(int process) { pd.setProgress(process); } @Override public void beforeRestore(int max) { pd.setMax(max); } }); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(AtoolsActivity.this, "还原成功", 0).show(); } }); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(AtoolsActivity.this, "还原失败", 0).show(); } }); }finally{ pd.dismiss(); } }; }.start(); // } }
[ "Administrator@SY-200901010012" ]
Administrator@SY-200901010012
5c5f02fdd090cda4590830ec884f5f0efb331eb8
4e4aef7f87801e5c1870f2250420444973a10764
/app/src/test/java/com/ixuea/coures/kanmeitu/ExampleUnitTest.java
baef8bc52d08ebdead7796899b3dec60b5a690cb
[]
no_license
lty1234-deep/KanMeiTu
14c9acc5364e26410e414a091f68fa25673a1fd9
bd1d24460d6c3b78caceec67ebae5a4cc1059685
refs/heads/master
2020-08-31T00:14:28.358947
2019-10-30T13:23:16
2019-10-30T13:23:16
218,531,406
1
0
null
null
null
null
UTF-8
Java
false
false
386
java
package com.ixuea.coures.kanmeitu; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ public class ExampleUnitTest { @Test public void addition_isCorrect() { assertEquals(4, 2 + 2); } }
b5c49482da8a7b6ce1c69ce3a2e5c9032b8911f2
40cd4da5514eb920e6a6889e82590e48720c3d38
/desktop/applis/apps/core/games/tarot/src/test/java/cards/tarot/GameTarotPlayingFourTest.java
ebd2116a2c92c0b511b647c3412c972d28f146d9
[]
no_license
Cardman/projects
02704237e81868f8cb614abb37468cebb4ef4b31
23a9477dd736795c3af10bccccb3cdfa10c8123c
refs/heads/master
2023-08-17T11:27:41.999350
2023-08-15T07:09:28
2023-08-15T07:09:28
34,724,613
4
0
null
2020-10-13T08:08:38
2015-04-28T10:39:03
Java
UTF-8
Java
false
false
7,258
java
package cards.tarot; import code.util.CustList; import org.junit.Test; import cards.consts.GameType; import cards.consts.MixCardsChoice; import cards.consts.Suit; import cards.tarot.enumerations.BidTarot; import cards.tarot.enumerations.CardTarot; import cards.tarot.enumerations.DealingTarot; public class GameTarotPlayingFourTest extends CommonTarotGame { static DealTarot initializeHands(byte _dealer) { CustList<HandTarot> hands_ = new CustList<HandTarot>(); HandTarot hand_ = new HandTarot(); hand_.ajouter(CardTarot.DIAMOND_KING); hand_.ajouter(CardTarot.CLUB_9); hand_.ajouter(CardTarot.CLUB_8); hand_.ajouter(CardTarot.DIAMOND_KNIGHT); hand_.ajouter(CardTarot.DIAMOND_JACK); hand_.ajouter(CardTarot.DIAMOND_10); hand_.ajouter(CardTarot.DIAMOND_2); hand_.ajouter(CardTarot.DIAMOND_1); hand_.ajouter(CardTarot.CLUB_7); hand_.ajouter(CardTarot.CLUB_6); hand_.ajouter(CardTarot.CLUB_5); hand_.ajouter(CardTarot.CLUB_4); hands_.add(hand_); hand_ = new HandTarot(); hand_.ajouter(CardTarot.HEART_QUEEN); hand_.ajouter(CardTarot.HEART_KNIGHT); hand_.ajouter(CardTarot.HEART_JACK); hand_.ajouter(CardTarot.HEART_3); hand_.ajouter(CardTarot.HEART_2); hand_.ajouter(CardTarot.HEART_1); hand_.ajouter(CardTarot.DIAMOND_3); hand_.ajouter(CardTarot.CLUB_10); hand_.ajouter(CardTarot.SPADE_3); hand_.ajouter(CardTarot.DIAMOND_9); hand_.ajouter(CardTarot.DIAMOND_8); hand_.ajouter(CardTarot.DIAMOND_7); hands_.add(hand_); hand_ = new HandTarot(); hand_.ajouter(CardTarot.CLUB_KING); hand_.ajouter(CardTarot.CLUB_KNIGHT); hand_.ajouter(CardTarot.CLUB_JACK); hand_.ajouter(CardTarot.CLUB_3); hand_.ajouter(CardTarot.CLUB_2); hand_.ajouter(CardTarot.CLUB_1); hand_.ajouter(CardTarot.HEART_9); hand_.ajouter(CardTarot.HEART_8); hand_.ajouter(CardTarot.HEART_7); hand_.ajouter(CardTarot.SPADE_KING); hand_.ajouter(CardTarot.CLUB_QUEEN); hand_.ajouter(CardTarot.HEART_10); hands_.add(hand_); hand_ = new HandTarot(); hand_.ajouter(CardTarot.SPADE_2); hand_.ajouter(CardTarot.SPADE_QUEEN); hand_.ajouter(CardTarot.SPADE_KNIGHT); hand_.ajouter(CardTarot.SPADE_JACK); hand_.ajouter(CardTarot.SPADE_10); hand_.ajouter(CardTarot.SPADE_9); hand_.ajouter(CardTarot.SPADE_1); hand_.ajouter(CardTarot.SPADE_5); hand_.ajouter(CardTarot.SPADE_4); hand_.ajouter(CardTarot.SPADE_8); hand_.ajouter(CardTarot.SPADE_7); hand_.ajouter(CardTarot.SPADE_6); hands_.add(hand_); hand_ = new HandTarot(); hand_.ajouter(CardTarot.EXCUSE); hand_.ajouter(CardTarot.TRUMP_21); hand_.ajouter(CardTarot.TRUMP_20); hand_.ajouter(CardTarot.TRUMP_15); hand_.ajouter(CardTarot.TRUMP_14); hand_.ajouter(CardTarot.TRUMP_13); hand_.ajouter(CardTarot.TRUMP_12); hand_.ajouter(CardTarot.TRUMP_4); hand_.ajouter(CardTarot.TRUMP_3); hand_.ajouter(CardTarot.TRUMP_2); hand_.ajouter(CardTarot.TRUMP_1); hand_.ajouter(CardTarot.HEART_KING); hands_.add(hand_); hand_ = new HandTarot(); hand_.ajouter(CardTarot.TRUMP_9); hand_.ajouter(CardTarot.TRUMP_8); hand_.ajouter(CardTarot.TRUMP_7); hand_.ajouter(CardTarot.DIAMOND_6); hand_.ajouter(CardTarot.DIAMOND_5); hand_.ajouter(CardTarot.DIAMOND_4); hand_.ajouter(CardTarot.TRUMP_11); hand_.ajouter(CardTarot.TRUMP_10); hand_.ajouter(CardTarot.TRUMP_5); hand_.ajouter(CardTarot.HEART_6); hand_.ajouter(CardTarot.HEART_5); hand_.ajouter(CardTarot.HEART_4); hands_.add(hand_); hand_ = new HandTarot(); hand_.ajouter(CardTarot.TRUMP_18); hand_.ajouter(CardTarot.TRUMP_17); hand_.ajouter(CardTarot.TRUMP_16); hand_.ajouter(CardTarot.TRUMP_19); hand_.ajouter(CardTarot.TRUMP_6); hand_.ajouter(CardTarot.DIAMOND_QUEEN); hands_.add(hand_); return new DealTarot(hands_,_dealer); } static RulesTarot initializeRulesWithBids() { RulesTarot regles_=new RulesTarot(); regles_.setDealing(DealingTarot.DEAL_2_VS_4_CALL_KING); regles_.getCommon().setMixedCards(MixCardsChoice.NEVER); regles_.allowAllBids(); return regles_; } @Test public void playableCards_beginningTrickWithConstraint1Test() { RulesTarot regles_=initializeRulesWithBids(); GameTarot game_ = new GameTarot(GameType.RANDOM, initializeHands((byte) 2), regles_); //game.resetNbPlisTotal(); biddingSix(BidTarot.GUARD_AGAINST, (byte) 4, game_); HandTarot cartesAppeler_ = new HandTarot(); cartesAppeler_.ajouter(CardTarot.SPADE_KING); game_.setCarteAppelee(cartesAppeler_); game_.initConfianceAppele(); game_.gererChienInconnu(); game_.setEntameur(game_.playerAfter(game_.getDistribution().getDealer())); game_.setPliEnCours(true); assertEq(3,game_.getEntameur()); HandTarot hand_ = game_.getDistribution().hand(game_.getEntameur()); HandTarot playableCards_ = game_.playableCards(hand_.couleurs()); assertEq(hand_.total(),playableCards_.total()); assertTrue(playableCards_.contientCartes(hand_)); assertEq(Suit.UNDEFINED,game_.getPliEnCours().couleurDemandee()); } @Test public void playableCards_beginningFreeSecondTrickWithoutCall2Test() { RulesTarot regles_=initializeRulesWithBids(); GameTarot game_ = new GameTarot(GameType.RANDOM, initializeHands((byte) 2), regles_); //game.resetNbPlisTotal(); biddingSix(BidTarot.GUARD_AGAINST, (byte) 4, game_); HandTarot cartesAppeler_ = new HandTarot(); cartesAppeler_.ajouter(CardTarot.SPADE_KING); game_.setCarteAppelee(cartesAppeler_); game_.initConfianceAppele(); game_.gererChienInconnu(); game_.setEntameur(game_.playerAfter(game_.getDistribution().getDealer())); game_.setPliEnCours(true); game_.ajouterUneCarteDansPliEnCours((byte) 3, CardTarot.SPADE_2); game_.ajouterUneCarteDansPliEnCours((byte) 4, CardTarot.TRUMP_2); game_.ajouterUneCarteDansPliEnCours((byte) 5, CardTarot.TRUMP_5); game_.ajouterUneCarteDansPliEnCours((byte) 0, CardTarot.DIAMOND_1); game_.ajouterUneCarteDansPliEnCours((byte) 1, CardTarot.SPADE_3); game_.ajouterUneCarteDansPliEnCours((byte) 2, CardTarot.SPADE_KING); game_.ajouterPetitAuBoutPliEnCours(); game_.setPliEnCours(true); assertEq(5,game_.getEntameur()); HandTarot hand_ = game_.getDistribution().hand(game_.getEntameur()); HandTarot playableCards_ = game_.playableCards(hand_.couleurs()); assertEq(hand_.total(),playableCards_.total()); assertTrue(playableCards_.contientCartes(hand_)); assertEq(Suit.UNDEFINED,game_.getPliEnCours().couleurDemandee()); } }
3c821df6f6a0abdcb0a948cd7a3e1be5492ac16e
58f20b362ae00f8fcb5ff03f690ba253dfe82465
/src/main/java/com/lingjoin/nlpir/plugin/ingest/document/pdf/Document.java
be6934d993d8c9d518485e8a1973ffb9540606dc
[ "MIT" ]
permissive
NLPIR-team/nlpir-ingest-elasticsearch-plugin
adf47825101743f51207d9277c705438b05c529d
93def7afbbdb0c48207f915d6e66785eac2e0589
refs/heads/master
2023-04-28T21:20:11.466772
2021-05-24T08:47:36
2021-05-24T08:47:36
344,755,226
0
0
null
null
null
null
UTF-8
Java
false
false
1,129
java
package com.lingjoin.nlpir.plugin.ingest.document.pdf; import com.lingjoin.nlpir.plugin.ingest.document.Element; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.text.PDFTextStripper; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class Document extends Element { private final List<Page> pages; public Document(InputStream is) throws IOException { pages = new ArrayList<>(); PDFTextStripper reader = new PDFTextStripper(); PDDocument pdd = PDDocument.load(is); int pageCount = pdd.getNumberOfPages(); for (int pageNo = 0; pageNo < pageCount; pageNo++) { reader.setStartPage(pageNo); reader.setEndPage(pageNo); String pageText = reader.getText(pdd); pages.add(new Page(pageText, pageNo)); } pdd.close(); } public Map<String, Object> toMap() { Map<String, Object> map = new HashMap<>(); this.parseList(map, "pages", pages); return map; } }
d7f085c01ee4c4dd9f3567cfb659704b681fe0a8
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/35/35_fdb264996c608f8b28aacbd0f878223c975e3e1c/ContentChecker/35_fdb264996c608f8b28aacbd0f878223c975e3e1c_ContentChecker_s.java
254bed7d2c39cc8e32656c87ac75eb639ff4e235
[]
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
6,481
java
package net.sf.buildbox.maven.contentcheck; import java.io.*; import java.util.LinkedHashSet; import java.util.Set; import java.util.UUID; import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.Manifest; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipInputStream; import org.apache.maven.plugin.logging.Log; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.DirectoryScanner; /** * The checker itself thread safe implementation. * */ public class ContentChecker { private static final String JAR_FILE_EXTENSION = "**/*.jar"; private final Log log; private final boolean ignoreVendorArchives; private final String vendorId; private final String manifestVendorEntry; private final String checkFilesPattern; public ContentChecker(Log log, boolean ignoreVendorArchives, String vendorId, String manifestVendorEntry, String checkFilesPattern) { super(); this.log = log; this.ignoreVendorArchives = ignoreVendorArchives; this.vendorId = vendorId; this.manifestVendorEntry = manifestVendorEntry; this.checkFilesPattern = checkFilesPattern; } /** * Checks an archive content according to an allowed content. * * @param listingFile a file that defines allowed content * @param archiveFile an archive to be checked * * @return the result of archive check * * @throws IOException if something very bad happen */ public CheckerOutput check(final File listingFile, final File archiveFile) throws IOException{ Set<String> allowedEntries = readListing(listingFile); Set<String> archiveContent = readArchive(archiveFile); return new CheckerOutput(allowedEntries, archiveContent); } protected Set<String> readListing(final File listingFile) throws IOException { log.info("Reading listing: " + listingFile); final Set<String> expectedPaths = new LinkedHashSet<String>(); InputStream is = new FileInputStream(listingFile); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); try { String line; while ((line = reader.readLine())!= null) { line = line.trim(); boolean ignoreLine = line.length() == 0 || line.startsWith("#");// we ignore empty and comments lines if (!ignoreLine) { if(expectedPaths.contains(line)) { log.warn("The listing file " + listingFile + " defines duplicate entry " + line); } expectedPaths.add(line); } } } finally { is.close(); reader.close(); } return expectedPaths; } protected Set<String> readArchive(final File archive) throws IOException { log.info("Reading archive: " + archive); final Set<String> archiveEntries = new LinkedHashSet<String>(); final ZipFile zipFile = new ZipFile(archive); final ZipInputStream zis = new ZipInputStream(new FileInputStream(archive)); try { ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { final String entryName = entry.getName(); if (! shouldBeChecked(entryName)) continue; if(isJarFileExtension(entryName) && ignoreVendorArchives) { InputStream archiveInputStream = zipFile.getInputStream(entry); if(isVendorArchive(entryName, archiveInputStream)) { continue; } } if (! archiveEntries.add(entryName)) { log.error("ERROR: Archive file " + archive + " contains duplicate entry: " + entryName); //TODO: should we just fail here ? or on config option ? //XXX Dagi: i don't think that the archive may have duplicit entries } } } finally { zis.close(); try { zipFile.close(); } catch(IOException e) { // ignored } } return archiveEntries; } private boolean shouldBeChecked(String path) { return DirectoryScanner.match(checkFilesPattern, path); } private boolean isJarFileExtension(String path) { return DirectoryScanner.match(JAR_FILE_EXTENSION, path); } private boolean isVendorArchive(final String jarPath, final InputStream archiveInputStream) throws IOException { File tempFile = null; try { tempFile = copyStreamToTemporaryFile(jarPath, archiveInputStream); } finally { archiveInputStream.close(); } return checkArchiveManifest(jarPath, tempFile); } /** * @param jarPath - * @param tempJAR - * @return true when vendorId matches with jar's manifest otherwise false */ private boolean checkArchiveManifest(final String jarPath, File tempJAR) { try { JarFile jarFile = new JarFile(tempJAR); Manifest manifest = jarFile.getManifest(); if(manifest != null) { Attributes mainAttributes = manifest.getMainAttributes(); if(mainAttributes != null) { String vendor = mainAttributes.getValue(manifestVendorEntry); return vendorId.equals(vendor); } } } catch (IOException e) { log.warn("Cannot check MANIFEST.MF file in JAR archive " + jarPath, e); } return false; } private File copyStreamToTemporaryFile(final String jarPath, final InputStream archiveInputStream) throws IOException { final File tempFile = File.createTempFile(UUID.randomUUID().toString(), "jar"); final FileOutputStream fos = new FileOutputStream(tempFile); try { log.debug("Checking " + jarPath + " to be a vendor archive, using tempfile " + tempFile); IOUtil.copy(archiveInputStream, fos); return tempFile; } finally { fos.close(); } } }
ef875c8d15f33f4f09455de68778967cbafe6cef
1eac15d5bcc70808b3e0b526dffd5694a558a417
/src/com/databorough/utils/MethodLogger.java
e1178d4f6807a71998299a2a534dcffe6f669204
[]
no_license
JuanCJR/XA-JAVA
0ee9c87e8c8b41ba0e1a79cb3becdf2954851849
862f6fd76ef2729811a8b6af7623c0a3e6517eac
refs/heads/master
2022-11-06T16:05:52.444537
2020-06-12T20:59:10
2020-06-12T20:59:10
271,888,879
0
0
null
null
null
null
UTF-8
Java
false
false
509
java
package com.databorough.utils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Returns a method logger. * * @author Amit Arya * @since (2012-04-13.14:36:12) */ public final class MethodLogger { public static Log appLogger = LogFactory.getLog(MethodLogger.class); /** * The MethodLogger class is not to be instantiated, only use its public * static members outside, so I'm keeping the constructor private. */ private MethodLogger() { super(); } }
82f8cc5388639f2c34f16085e1c195927226150b
017098b7b7d113dae9e586f4b4b77582df2159a8
/BankApp/src/com/cg/bankApp/servlet/ServletBank.java
32406614eb865cdba0ec29bee1c280348e38e9c9
[]
no_license
rpolu/servlets
089cbef6c0018aeffe2db05604a0c093aa792e44
a0c224a5f990d1e26bc94184e8aaf9bc29169e17
refs/heads/master
2022-07-03T21:05:52.186748
2020-08-26T03:22:56
2020-08-26T03:22:56
216,128,456
0
0
null
2022-06-21T03:49:25
2019-10-19T00:41:27
Java
UTF-8
Java
false
false
6,298
java
package com.cg.bankApp.servlet; import java.io.IOException; import java.util.Collection; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.cg.bankApp.pojo.BankAccount; import com.cg.bankApp.pojo.CurrentAccount; import com.cg.bankApp.pojo.Customer; import com.cg.bankApp.pojo.SavingsAccount; import com.cg.bankApp.services.ServicesBankApp; @WebServlet("*.bankApp") public class ServletBank extends HttpServlet { Customer customer; SavingsAccount savingsAccount; CurrentAccount currentAccount; BankAccount bankAccount; ServicesBankApp service = new ServicesBankApp(); public ServletBank() { } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RequestDispatcher rd; String action = request.getServletPath(); System.out.println(action); switch (action) { case "/addNewAccount.bankApp": response.sendRedirect("addNewAccount.jsp"); break; case "/viewAllAccounts.bankApp": String accountType; Collection<BankAccount> bankAccounts = service.viewAllAccounts(); System.out.println(bankAccounts); request.setAttribute("bankAccounts", bankAccounts); rd = request.getRequestDispatcher("viewAll.jsp"); rd.forward(request, response); break; case "/search.bankApp": break; case "/fundTransfer.bankApp": rd = request.getRequestDispatcher("fundTransfer.jsp"); rd.forward(request, response); break; case "/saveFundTransfer.bankApp": int fromAccNum = Integer.parseInt(request.getParameter("fromAccNo")); int toAccNum = Integer.parseInt(request.getParameter("toAccNo")); int balTransfer = Integer.parseInt(request.getParameter("amount")); System.out.println(fromAccNum + " " + toAccNum + " " + balTransfer); int retrievedBalance = service.withdraw(fromAccNum, balTransfer); System.out.println("ret bal"+retrievedBalance); if (retrievedBalance >= 0) { int accBal = service.deposit(toAccNum, balTransfer); if (accBal != 0) { request.setAttribute("retrievedBalance", retrievedBalance); request.setAttribute("accBal", accBal); request.setAttribute("fromAccNum", fromAccNum); request.setAttribute("toAccNum", toAccNum); request.setAttribute("balTransfer", balTransfer); rd = request.getRequestDispatcher("successFundTransfer.jsp"); rd.forward(request, response); } else { response.sendRedirect("errorAccNotFound.jsp"); } } else if (retrievedBalance == -2) response.sendRedirect("errorAccNotFound.jsp"); else if (retrievedBalance == -1) response.sendRedirect("insufficientBal.jsp"); break; case "/withdraw.bankApp": request.setAttribute("operation", "Withdraw Funds"); rd = request.getRequestDispatcher("withdraw.jsp"); rd.forward(request, response); break; case "/deposit.bankApp": request.setAttribute("operation", "Deposit Funds"); rd = request.getRequestDispatcher("deposit.jsp"); rd.forward(request, response); break; case "/saveDeposit.bankApp": int accNum = Integer.parseInt(request.getParameter("accNo")); int bal = Integer.parseInt(request.getParameter("amount")); System.out.println(request.getParameter("transactionType")); System.out.println(accNum + " " + bal); int accBal = service.deposit(accNum, bal); if (accBal != 0) { request.setAttribute("accNum", accNum); request.setAttribute("accBal", accBal); rd = request.getRequestDispatcher("successDepWith.jsp"); rd.forward(request, response); } else response.sendRedirect("errorAccNotFound.jsp"); break; case "/saveWithdraw.bankApp": int accNumb = Integer.parseInt(request.getParameter("accNo")); int balance1 = Integer.parseInt(request.getParameter("amount")); System.out.println(accNumb + " " + balance1); int accBalance = service.withdraw(accNumb, balance1); System.out.println(accBalance); if (accBalance >= 0) { request.setAttribute("accNum", accNumb); request.setAttribute("accBal", accBalance); rd = request.getRequestDispatcher("successDepWith.jsp"); rd.forward(request, response); } else if (accBalance == -2) response.sendRedirect("errorAccNotFound.jsp"); else if (accBalance == -1) response.sendRedirect("insufficientBal.jsp"); break; case "/newAccount.bankApp": int accNo = 0; String name = request.getParameter("customerName"); String emailId = request.getParameter("emailId"); String dob = request.getParameter("dob"); String phNum = request.getParameter("telephone"); String accType = request.getParameter("accType"); boolean isSalaried = Boolean.parseBoolean(request.getParameter("salaried")); String balance = request.getParameter("balance"); String odLimit = request.getParameter("odLimit"); customer = new Customer(name, emailId, dob, phNum); if (accType == "savingsAccount") { savingsAccount = new SavingsAccount(customer, Integer.parseInt(balance), isSalaried); accNo = bankAccount.getAccountNumber(); } else if (accType == "currentAccount") { currentAccount = new CurrentAccount(customer, Integer.parseInt(balance), Integer.parseInt(odLimit)); accNo = bankAccount.getAccountNumber(); } System.out.println(name + " " + emailId + " " + dob + " " + phNum + " " + accType + " " + isSalaried); System.out.println(balance + " " + odLimit); System.out.println(accNo); System.out.println(bankAccount.getAccountId()); request.setAttribute("name", name); request.setAttribute("accNo", accNo); rd = request.getRequestDispatcher("success.jsp"); rd.forward(request, response); break; case "/populate.bankApp": service.populateAccount(); rd = request.getRequestDispatcher("home.jsp"); rd.forward(request, response); break; } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }
e103e681992f83994039e86ed72c5d169b52d8dd
5a3d3b73d5f66ca07cb12aa2161983a8c17bb82b
/rendering-core-gl/src/main/java/de/javagl/rendering/core/gl/DefaultGLAttribute.java
ae12fab2e02ea56a9b6d6ede60079c01d87cba90
[ "MIT" ]
permissive
study-game-engines/opengl-object-oriented-api
235cc47378b8b4d886b516931f7f7139ceb47ce0
64a920ad2b4b9aada65489abcf2d1735b42c23c8
refs/heads/master
2023-03-16T17:12:13.808158
2016-07-05T17:14:26
2016-07-05T17:14:26
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,497
java
/* * www.javagl.de - Rendering * * Copyright 2010-2016 Marco Hutter - http://www.javagl.de * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ package de.javagl.rendering.core.gl; /** * Default implementation of a {@link GLAttribute} */ class DefaultGLAttribute implements GLAttribute { /** * The location of the attribute */ private final int location; /** * Creates a new DefaultGLAttribute with the given location * * @param location The location of the attribute */ DefaultGLAttribute(int location) { this.location = location; } @Override public int getLocation() { return location; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + location; return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; DefaultGLAttribute other = (DefaultGLAttribute)obj; if (location != other.location) return false; return true; } @Override public String toString() { return "DefaultGLAttribute[location=" + location + "]"; } }
6485e92eb71d9b4409080868245daec8e6fdd8e2
6a922edda459cbd808b4ac4a85d809775dfb93a8
/src/ModbusTester/parameter/String256Parameter.java
6499ef65128cd83e469ca8c533cf06ec0cede0f3
[]
no_license
ctaxx/ModbusTest
0360383a1fd476694ddcce9ce300423478db21f7
29ac55b2ea68ffaf295a936c45955c6c447fecb2
refs/heads/master
2021-07-14T19:34:01.236617
2021-02-19T15:47:07
2021-02-19T15:47:07
237,235,501
0
0
null
null
null
null
UTF-8
Java
false
false
2,490
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 ModbusTester.parameter; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author s.bikov */ public class String256Parameter extends Parameter { public static final String ENCODING = "Cp1251"; public static final String[] TEST_STRINGS = {"Test", "Тест", "Dev"}; @Override public String getRange() { return "String 256"; } @Override public String getValueString(int[] dataArray) { // return Arrays.stream(dataArray) // .mapToObj(v -> Character.toString((char) (v & 0xFF)) + Character.toString((char) (v >> 8))) // .collect(Collectors.joining()); byte[] resultBytes = new byte[dataArray.length * 2]; for (int i = 0; i < dataArray.length; i++) { byte[] b = ByteBuffer.allocate(4).putInt(dataArray[i]).array(); resultBytes[i * 2] = b[3]; resultBytes[i * 2 + 1] = b[2]; } try { return new String(resultBytes, ENCODING); } catch (UnsupportedEncodingException ex) { Logger.getLogger(String256Parameter.class.getName()).log(Level.SEVERE, null, ex); } return ""; } @Override public int[][] getValidValue() { try { byte[] testStringArray = TEST_STRINGS[1].getBytes(ENCODING); int[] dataToRegister = new int[16]; for (int i = 0; i < testStringArray.length; i += 2) { byte[] tmp = { 0, 0, (i + 1) < testStringArray.length ? testStringArray[i + 1] : 0, testStringArray[i] }; dataToRegister[i / 2] = ByteBuffer.wrap(tmp).getInt(); } return new int[][]{dataToRegister}; } catch (UnsupportedEncodingException ex) { Logger.getLogger(String256Parameter.class.getName()).log(Level.SEVERE, null, ex); } return new int[0][0]; } @Override public int[][] getOutOfRangeValue() { // TODO too long strings return new int[0][0]; } @Override public boolean isLogicalMatchesPhysical() { // TODO too long strings; return true; } }
103beb51f651077481ed11cfa35aadd736c3e38e
cd3a497a9389cd81e796f7f60c89b30563925c2a
/src/main/java/com/javastar920905/spider/listener/UpdateProxyListener.java
751c7cf2e9c0ff9852f6f888ce1595aee96f9730
[]
no_license
javastar920905/spider-webmagic
421bc17fc39d8dbac865f388fd322328fb5de34e
afa87f872cc445decc943f328b8545873364dc28
refs/heads/master
2021-01-19T04:48:20.636324
2017-08-28T03:35:03
2017-08-28T03:35:03
69,107,127
1
1
null
null
null
null
UTF-8
Java
false
false
2,142
java
package com.javastar920905.spider.listener; import com.alibaba.fastjson.JSONObject; import com.javastar920905.spider.util.SpiderUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import us.codecraft.webmagic.Request; import us.codecraft.webmagic.Spider; import us.codecraft.webmagic.SpiderListener; import us.codecraft.webmagic.downloader.HttpClientDownloader; import us.codecraft.webmagic.proxy.Proxy; import us.codecraft.webmagic.proxy.SimpleProxyProvider; import us.codecraft.webmagic.utils.ProxyUtils; /** * 爬虫代理监听器 */ public class UpdateProxyListener implements SpiderListener { private Logger logger = LoggerFactory.getLogger(UpdateProxyListener.class); private Spider spider; /** * 将spider 对象注入当前监听器的方式 * * Spider city58Spider =Spider.create(xx).addUrl(xx).addPipeline(xx).thread(50); * * // 将当期city58Spider对象注入 Listener中 List<SpiderListener> spiderListenerList = new ArrayList<>(); * spiderListenerList.add(new UpdateProxyListener(city58Spider)); * city58Spider.setSpiderListeners(spiderListenerList); * * //最后启动spider * * city58Spider.start(); * * @param spider */ public UpdateProxyListener(Spider spider) { this.spider = spider; } @Override public void onSuccess(Request request) { // do nothing } // 爬虫出错的时候切换IP @Override public void onError(Request request) { logger.info("=====不知道怎么回事, 突然间想换个IP(URL:" + request.getUrl() + ")====="); updateSpiderProxy(spider); } // 更新当前spider的代理 public static void updateSpiderProxy(Spider spider) { JSONObject jsonObject = SpiderUtil.SpiderProxy.getProxy(); if (jsonObject != null) { Proxy proxy = new Proxy(jsonObject.getString("ip"), jsonObject.getInteger("port")); if (ProxyUtils.validateProxy(proxy)) { HttpClientDownloader httpClientDownloader = new HttpClientDownloader(); httpClientDownloader.setProxyProvider(SimpleProxyProvider.from(proxy)); spider.setDownloader(httpClientDownloader); } } } }
1806c0ee9fb7106b3eb00ecb088007c273f32b00
d408f07c36821829c76f1cd227bcf24a363004fb
/Architect/src/architect/thread/wait/AnotherClass.java
54e8fb927720037d9c556f96340141249905e4b0
[]
no_license
fslichen/Java_Buffer
3bfdd49413aa5c563d08a3c0db0ca62dc08a4998
c7dd79de9b7c886adbe0fe2b542aaa53feda9080
refs/heads/master
2021-06-22T02:11:55.286755
2017-08-28T10:32:40
2017-08-28T10:32:40
null
0
0
null
null
null
null
UTF-8
Java
false
false
154
java
package architect.thread.wait; public class AnotherClass { public void run() { while (true) { System.out.println("Hello World"); } } }
[ "user@use1r-PC" ]
user@use1r-PC
10535b220747c7b2352998589365b432132e40b0
ee7e3493b1c3857c83f0a23f61803c1d86f7dd43
/src/main/java/xyz/mizan/springbootsecurity/boot/controller/EmployeeController.java
c26b5bae9aaaf148ca081509190b833dac4b5c5e
[]
no_license
kmmizanurrahmanjp/spring-boot-security
2a48807dced0d23bafcc7e75f57f6a6678b40e60
c49d48f679223c44b9974c5c83f1044cbdfa3204
refs/heads/master
2020-04-02T23:01:55.423243
2018-10-29T17:00:29
2018-10-29T17:00:29
154,853,355
0
0
null
null
null
null
UTF-8
Java
false
false
2,354
java
package xyz.mizan.springbootsecurity.boot.controller; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; import xyz.mizan.springbootsecurity.boot.entity.Employee; import xyz.mizan.springbootsecurity.boot.service.EmployeeServiceImp; @Controller @RequestMapping(value="/employee") public class EmployeeController { @Autowired EmployeeServiceImp employeeServiceImp; @RequestMapping(value="/list", method=RequestMethod.GET) public ModelAndView goIndex() { ModelAndView employeeModel = new ModelAndView(); Employee e = new Employee(); List<Employee> employees = employeeServiceImp.selectEmployee(); employeeModel.addObject("employeeForm", e); employeeModel.addObject("employees", employees); employeeModel.setViewName("employee"); return employeeModel; } @RequestMapping(value="/insertPage", method=RequestMethod.GET) public ModelAndView addArticle() { ModelAndView model = new ModelAndView(); Employee e = new Employee(); model.addObject("employeeForm", e); model.setViewName("employee"); return model; } @RequestMapping(value="/update/{id}", method=RequestMethod.GET) public ModelAndView addArticle(@PathVariable("id") int id) { ModelAndView model = new ModelAndView(); Employee e = employeeServiceImp.selectEmployeeById(id); List<Employee> employees = employeeServiceImp.selectEmployee(); model.addObject("employees", employees); model.addObject("employeeForm", e); model.setViewName("employee"); return model; } @RequestMapping(value="/insert", method=RequestMethod.POST) public ModelAndView insertEmployee(@ModelAttribute("employeeForm") Employee e) { employeeServiceImp.insertEmployee(e); return new ModelAndView("redirect:/employee/list"); } @RequestMapping(value="/delete/{id}", method=RequestMethod.GET) public ModelAndView deleteEmployee(@PathVariable("id") int id) { employeeServiceImp.deleteEmployee(id); return new ModelAndView("redirect:/employee/list"); } }
ecf7fcf9fb009d815176944701625bb053752845
a00a37ce993fc64fec0ce0f713b2a9065f323a89
/demo/reg/EmailDemo.java
4fbd02df8fae186d851939e95ed6f12e88d20a9e
[]
no_license
tejaswirajput/com.cg.demo
0c3ecc7191b7b56bba6f7a88950a1f45028a6f68
dc2339c84cc4784ed4214dec949c6cb9cb1fc026
refs/heads/master
2023-06-03T01:29:09.202322
2021-06-22T06:55:49
2021-06-22T06:55:49
375,003,804
0
0
null
null
null
null
UTF-8
Java
false
false
448
java
package com.cg.demo.reg; import java.util.regex.Matcher; import java.util.regex.Pattern; public class EmailDemo { public static void main(String[] args) { String email = "[email protected]"; // String regex = "[^\\d][\\w-.]+[@][^\\d][\\w]+[\\.][^\\d][\\w]+"; String regex = "[\\D][\\w-.]+[@][\\D][\\w]+[\\.][\\D][\\w]+"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(email); System.out.println(m.matches()); } }
cf8538231615e7ce787255c02985f1c1615e06ad
a7a9fcc2e8b50d4258691fdbd9a18e835c86672d
/AB-XACML/src/main/java/edu/purdue/absoa/ABAuthorization.java
f2cc79fa2372884495e073b4f1f7468e83da745a
[]
no_license
rohitranchal/pd3
332057d59c255cae3dc8f0ac8127f5f9843c1d52
1351471588bb55a0dcedef75c2040dd6394d2d0b
refs/heads/master
2020-05-30T05:24:33.215108
2015-04-02T03:44:15
2015-04-02T03:44:15
41,401,152
0
0
null
null
null
null
UTF-8
Java
false
false
2,011
java
package edu.purdue.absoa; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.Arrays; import java.util.HashMap; import java.util.List; public class ABAuthorization { public static HashMap<String, List<String>> accessPolicies; public ABAuthorization() { accessPolicies = new HashMap<String, List<String>>(); InputStream is; ABParser parser; HashMap<String, String> sMap; is = Thread.currentThread().getContextClassLoader().getResourceAsStream("ab.acl"); if (is != null) { parser = new ABParser(is); sMap = parser.processLineByLine(); for (HashMap.Entry<String, String> entry : sMap.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); String[] valList = value.split("\\s*,\\s*"); accessPolicies.put(key, Arrays.asList(valList)); } } } public boolean authorize(String dataReq, byte[] certificate) { boolean result = false; try { InputStream bis = new ByteArrayInputStream(certificate); CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); X509Certificate cert = (X509Certificate)certFactory.generateCertificate(bis); bis.close(); String subject = cert.getSubjectX500Principal().getName().split(",")[0].split("=")[1]; String apn, policy, request; for(int i=0; i<accessPolicies.get(dataReq).size(); i++) { apn = accessPolicies.get(dataReq).get(i); policy = "policy/policy-" + apn + ".xml"; request = "request/request-" + apn + ".xml"; HashMap<String, String> params = new HashMap<String, String>(); params.put("#ABRESOURCE#", dataReq); params.put("#ABCLIENT#", subject); ABXACML abx = new ABXACML(policy, request, params); String res = abx.evaluate(); if (res.contains("Permit")) { result = true; } else { return false; } } } catch(Exception e) { e.printStackTrace(); } return result; } }
9ef97cc4a00a61a94b175cbed01cd6ed839a193f
f2bc06a70baa18a5839be6ee3f54128c9f0fd69e
/app/src/androidTest/java/com/jaircadenas/cheeseapp/ExampleInstrumentedTest.java
e097b8a8842fb7fe3bed4f3129a7fb353759f396
[]
no_license
mussiojair/CheeseApp
f85c8a462b61ab8ff2883363ad28994cb6b9202c
e2c52d7c555851505e0bd78c12ca9dbb1611f969
refs/heads/master
2021-01-19T18:29:26.394248
2017-08-23T14:57:26
2017-08-23T14:57:26
101,142,780
0
0
null
null
null
null
UTF-8
Java
false
false
754
java
package com.jaircadenas.cheeseapp; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; /** * Instrumentation test, which will execute on an Android device. * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() throws Exception { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); assertEquals("com.jaircadenas.cheeseapp", appContext.getPackageName()); } }
a6bd855510788b7f3dbc8023235b8fe900eb6190
92b1f21292e0ae40d56bf872e5262faac93d9347
/app/src/main/java/com/teamarp/rahul/getwoke/MainActivity.java
31933677fada0e91bde652dc8d66f4f14ffaf8aa
[]
no_license
rahulk0127/GetWoke
23356a5f7b043672aa5b66521a62f0bfabd48d36
7561544aa0356053147af76cc074089415573fdb
refs/heads/master
2020-04-09T03:47:32.755281
2018-12-01T23:52:59
2018-12-01T23:52:59
159,996,784
0
0
null
null
null
null
UTF-8
Java
false
false
338
java
package com.teamarp.rahul.getwoke; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }
78d616ebebd4c74b24dc16d6b28e833218870091
a68b744b2011491f5ecd87f31901981aad1a346f
/Easy/numberLineJumps.java
3157a2e3d1603ffae8b81c0d5a6683e337c2490a
[]
no_license
mas-diq/Hackerrank
c1faf58377a7031477079b7a10db07d7ca78f227
b85d4f3c4c0ed3d019d31e523ebb47a33e434e25
refs/heads/main
2023-02-13T12:46:19.204618
2021-01-15T03:43:58
2021-01-15T03:43:58
325,296,030
1
0
null
null
null
null
UTF-8
Java
false
false
631
java
import java.io.IOException; import java.util.Scanner; public class numberLineJumps { public static void main(String[] args) throws IOException { Scanner s = new Scanner(System.in); int arr[] = new int[4]; int i = 0; while (i < 4){ arr[i] = s.nextInt(); i++; } int d1 = arr[0]; int d2 = arr[2]; while (d1 < d2) { d1 = d1 + arr[1]; d2 = d2 + arr[3]; } if (d1 == d2) { System.out.println("YES"); }else{ System.out.println("NO"); } s.close(); } }
4cb094a51c3f4f4882c697ca52377d317fd189f7
5e224ff6d555ee74e0fda6dfa9a645fb7de60989
/database/src/main/java/adila/db/mango_a12d810.java
279864f59f65a6b54dda87f9c81d786ac8c30439
[ "MIT" ]
permissive
karim/adila
8b0b6ba56d83f3f29f6354a2964377e6197761c4
00f262f6d5352b9d535ae54a2023e4a807449faa
refs/heads/master
2021-01-18T22:52:51.508129
2016-11-13T13:08:04
2016-11-13T13:08:04
45,054,909
3
1
null
null
null
null
UTF-8
Java
false
false
204
java
// This file is automatically generated. package adila.db; /* * Acer A1-810 * * DEVICE: mango * MODEL: A1-810 */ final class mango_a12d810 { public static final String DATA = "Acer|A1-810|"; }
c93035f6017041c5228d96f5deb04dcdc81a9476
7a50aa5767669388335c1bedac408b3d871978f1
/src/test/java/com/sustech/gamercenter/BaseTest.java
7fd1a14f699d9328921c66360ae52ddf033516e6
[ "Apache-2.0" ]
permissive
monkeyboiii/gamer-center
fb0e2ba8a852ff6e3b8cc5782eca40ee45bf68ed
62e2347ff138553aba6acc1ed7fd719692edd37c
refs/heads/master
2023-02-04T08:40:52.651761
2020-12-26T02:19:27
2020-12-26T02:19:27
296,316,925
1
3
Apache-2.0
2020-11-22T07:38:16
2020-09-17T12:16:36
Java
UTF-8
Java
false
false
6,497
java
//package com.sustech.gamercenter; // //import com.zaxxer.hikari.HikariDataSource; //import org.junit.runner.RunWith; //import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Value; //import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; //import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; //import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer; //import org.springframework.boot.test.context.TestConfiguration; //import org.springframework.context.annotation.Bean; //import org.springframework.context.annotation.Primary; //import org.springframework.core.env.Environment; //import org.springframework.orm.jpa.JpaTransactionManager; //import org.springframework.orm.jpa.JpaVendorAdapter; //import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //import org.springframework.test.context.ActiveProfiles; //import org.springframework.test.context.ContextConfiguration; //import org.springframework.test.context.TestPropertySource; //import org.springframework.test.context.junit4.SpringRunner; //import org.springframework.test.web.servlet.MockMvc; //import org.springframework.test.web.servlet.setup.MockMvcBuilders; //import org.springframework.transaction.PlatformTransactionManager; // //import javax.naming.NamingException; //import javax.persistence.EntityManagerFactory; //import javax.sql.DataSource; //import java.util.Properties; // //@RunWith(SpringRunner.class) //@ContextConfiguration(initializers = ConfigFileApplicationContextInitializer.class) //public class BaseTest { // // @TestConfiguration // @TestPropertySource(locations = "classpath:application.yml") // @ActiveProfiles("local") // public static class TestContextConfiguration { // // @Autowired // private Environment environment; // // @Value("${datasource.sampleapp.maxPoolSize:10}") // private int maxPoolSize; // // /* // * 将 application.yml 的配置填充到 SpringBoot 中的 DataSourceProperties 对象里面 // */ // @Bean // @Primary // public DataSourceProperties dataSourceProperties() { // DataSourceProperties dataSourceProperties = new DataSourceProperties(); // dataSourceProperties.setDriverClassName(environment.getRequiredProperty("datasource.sampleapp.driverClassName")); // dataSourceProperties.setUrl(environment.getRequiredProperty("datasource.sampleapp.url")); // dataSourceProperties.setUsername(environment.getRequiredProperty("datasource.sampleapp.username")); // dataSourceProperties.setPassword(environment.getRequiredProperty("datasource.sampleapp.password")); // return dataSourceProperties; // } // // /* // * 配置 HikariCP 连接池数据源. // */ // @Bean // public DataSource dataSource() { // DataSourceProperties dataSourceProperties = dataSourceProperties(); // HikariDataSource dataSource = (HikariDataSource) DataSourceBuilder // .create(dataSourceProperties.getClassLoader()) // .driverClassName(dataSourceProperties.getDriverClassName()) // .url(dataSourceProperties.getUrl()) // .username(dataSourceProperties.getUsername()) // .password(dataSourceProperties.getPassword()) // .type(HikariDataSource.class) // .build(); // dataSource.setMaximumPoolSize(maxPoolSize); // return dataSource; // } // // /* // * Entity Manager Factory 配置. // */ // @Bean // public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws NamingException { // LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); // factoryBean.setDataSource(dataSource()); // factoryBean.setPackagesToScan(new String[]{"com.ckjava.test.domain"}); // factoryBean.setJpaVendorAdapter(jpaVendorAdapter()); // factoryBean.setJpaProperties(jpaProperties()); // return factoryBean; // } // // /** // * 指定 hibernate 为 jpa 的持久化框架 // * // * @return // */ // @Bean // public JpaVendorAdapter jpaVendorAdapter() { // HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); // return hibernateJpaVendorAdapter; // } // // /* // * 从 application.yml 中读取 hibernate 相关配置 // */ // private Properties jpaProperties() { // Properties properties = new Properties(); // properties.put("hibernate.dialect", environment.getRequiredProperty("datasource.sampleapp.hibernate.dialect")); // properties.put("hibernate.hbm2ddl.auto", environment.getRequiredProperty("datasource.sampleapp.hibernate.hbm2ddl.auto")); // properties.put("hibernate.show_sql", environment.getRequiredProperty("datasource.sampleapp.hibernate.show_sql")); // properties.put("hibernate.format_sql", environment.getRequiredProperty("datasource.sampleapp.hibernate.format_sql")); // if (StringUtils.isNotEmpty(environment.getRequiredProperty("datasource.sampleapp.defaultSchema"))) { // properties.put("hibernate.default_schema", environment.getRequiredProperty("datasource.sampleapp.defaultSchema")); // } // return properties; // } // // @Bean // public PlatformTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) { // JpaTransactionManager txManager = new JpaTransactionManager(); // txManager.setEntityManagerFactory(entityManagerFactory); // return txManager; // } // // @Bean // public TaskService taskService() { // return new TaskService(); // } // // @Bean // public TaskController taskController() { // return new TaskController(); // } // // @Bean // public MockMvc mockMvc() { // Object[] contorllers = {taskController()}; // return MockMvcBuilders.standaloneSetup(contorllers).build(); // } // } // //}
54cd85cc72345da2d2437d2c7d92c11896b72adf
e2852c2ade95d47b202023609b16bd1d699716e9
/Project/src/main/java/upd/exception/UnsupportedReportTypeException.java
7cbce7c2e06aff97b1d11b11b57db1a8d7c88e21
[]
no_license
zlamaann/cvut-bp
4c9eac5cc478770e1412a773332868c9cc7d0aec
ae5c7791e55af5e64c0250bbb8116a2246ebf493
refs/heads/master
2022-10-18T06:34:54.360804
2018-05-23T22:38:14
2018-05-23T22:38:14
190,808,973
0
0
null
null
null
null
UTF-8
Java
false
false
330
java
package upd.exception; /** * Thrown for reports which are not supported by any service in the application. */ public class UnsupportedReportTypeException extends RuntimeException { public UnsupportedReportTypeException() { } public UnsupportedReportTypeException(String message) { super(message); } }
408fd9046f8e25a90e18805c3953f30699d97a16
071a9fa7cfee0d1bf784f6591cd8d07c6b2a2495
/corpus/class/sling/1364.java
a29bdf8a5a3a142fae013c23b91fcd82d7c74dc5
[ "MIT" ]
permissive
masud-technope/ACER-Replication-Package-ASE2017
41a7603117f01382e7e16f2f6ae899e6ff3ad6bb
cb7318a729eb1403004d451a164c851af2d81f7a
refs/heads/master
2021-06-21T02:19:43.602864
2021-02-13T20:44:09
2021-02-13T20:44:09
187,748,164
0
0
null
null
null
null
UTF-8
Java
false
false
1,275
java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.sling.discovery.impl.cluster; import org.apache.sling.discovery.base.its.AbstractSingleInstanceTest; import org.apache.sling.discovery.base.its.setup.VirtualInstanceBuilder; import org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder; public class SingleInstanceTest extends AbstractSingleInstanceTest { @Override protected VirtualInstanceBuilder newBuilder() { return new FullJR2VirtualInstanceBuilder(); } }
071b5a488cbdeed67951e3e7efc19057d361882b
bb11c00743a4821801eabd1301121411f442b9ff
/core/src/main/java/com/holonplatform/vaadin/internal/components/VaadinValidatorWrapper.java
c87f8878b210e6c1b078875d1a89ea5edc9d317b
[ "Apache-2.0" ]
permissive
holon-platform/holon-vaadin
27d89cf825e2b53fec6b274d16840d77794b4595
d56d6f6c8cec716636b3edb3bc57d16a6937e4be
refs/heads/master
2022-02-03T21:29:07.523021
2019-12-31T11:59:56
2019-12-31T11:59:56
93,380,833
4
3
Apache-2.0
2022-01-21T23:11:19
2017-06-05T08:11:47
Java
UTF-8
Java
false
false
2,295
java
/* * Copyright 2000-2017 Holon TDCN. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.holonplatform.vaadin.internal.components; import com.holonplatform.core.Validator; import com.holonplatform.core.internal.utils.ObjectUtils; import com.holonplatform.vaadin.components.Input; import com.vaadin.data.ValidationResult; import com.vaadin.data.ValueContext; /** * Vaadin {@link com.vaadin.data.Validator} to Holon {@link Validator} wrapper. * * @param <T> Value type * * @since 5.0.0 */ public class VaadinValidatorWrapper<T> implements Validator<T> { private static final long serialVersionUID = 3664165755542688523L; private final com.vaadin.data.Validator<T> validator; private final ValueContext context; private final Input<T> input; /** * Constructor * @param validator Vaadin validator (not null) * @param context Validation context (may be null) * @param input Input to validate (may be null) */ public VaadinValidatorWrapper(com.vaadin.data.Validator<T> validator, ValueContext context, Input<T> input) { super(); ObjectUtils.argumentNotNull(validator, "Validator must be not null"); this.validator = validator; this.context = context; this.input = input; } private ValueContext getValueContext() { if (context != null) { return context; } if (input != null && input.getComponent() != null) { return new ValueContext(input.getComponent()); } return new ValueContext(); } /* * (non-Javadoc) * @see com.holonplatform.core.Validator#validate(java.lang.Object) */ @Override public void validate(T value) throws ValidationException { ValidationResult result = validator.apply(value, getValueContext()); if (result.isError()) { throw new ValidationException(result.getErrorMessage()); } } }
c9a2004e56a269de3ce021d37ca912e173e6a8d0
d7bf5938f307052b888e843785031647f9186a45
/android-front-end/app/src/main/java/org/coursera/capstone/process/ReminderBootReceiver.java
b3d4f69e6d7139911f34db783d3345bb23b3e48d
[ "Apache-2.0" ]
permissive
abrugues/symptom-management
c8f99be6329a32065dde285a02dd8f5e903b47b5
1e611d958348463b2d6ead55ef27d5211b9683a8
refs/heads/master
2020-05-17T17:40:14.255279
2017-05-01T16:16:28
2017-05-01T16:16:28
39,410,306
0
0
null
null
null
null
UTF-8
Java
false
false
386
java
package org.coursera.capstone.process; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class ReminderBootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) { // Restart the alarms } } }
19e3f834bfb09490b7623ef201fa87d4378bdbff
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/8/8_7157eb022ee32bf339b204ca9c59ddb12e7296e6/PageTest/8_7157eb022ee32bf339b204ca9c59ddb12e7296e6_PageTest_t.java
e3b488d09298363d77c1b984e595ac920662b180
[]
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
958
java
package cz.tsl.velocity; import cz.tsl.XmlDiff; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import static junit.framework.Assert.assertTrue; /** * User: richard.sery * Date: 31.3.13 * Time: 13:42 */ @RunWith(JUnit4.class) public class PageTest extends AbstractVmTest { @Test public void pageTest() throws Exception { XmlDiff diff = runTest("pageTest/page"); assertTrue(diff.result() + " VM output: " + diff.getTestedXml(), diff.passed()); } @Test public void pageWithHeadAndBodyTest() throws Exception { XmlDiff diff = runTest("pageTest/headAndBody"); assertTrue(diff.result() + " VM output: " + diff.getTestedXml(), diff.passed()); } @Test public void pageMultipartActionTest() throws Exception { XmlDiff diff = runTest("pageTest/pageMultipartAction"); assertTrue(diff.result() + " VM output: " + diff.getTestedXml(), diff.passed()); } }
296f7fb03199b7aba1f3d06024dc14323f9aad29
faed6597916007ed59a8e14f3a5740a5152baa01
/FullTimeDs/src/arraysProgs/SearchInsertPosition.java
cd824a5c9c199154a923c52560a90fc565eac1bd
[]
no_license
neilthaker07/Data_Structure
1d01445ee28b50c39f790069c7ff38f969cc5211
680074a8f0fa7f23bf16c63a74b0e163439d5685
refs/heads/master
2020-07-13T06:22:30.259163
2019-02-11T03:03:32
2019-02-11T03:03:32
94,292,189
0
0
null
null
null
null
UTF-8
Java
false
false
465
java
package arraysProgs; public class SearchInsertPosition { public static void main(String[] args) { System.out.println(pos()); } public static int pos() { int[] a= new int[]{1,3,4,5,8,9}; int val = 6; int start = 0; int end = a.length-1; while(start<=end) { int mid = (start+end)/2; if(a[mid]==val) { return mid; } if(a[mid] > val) { end = mid-1; } else { start = mid+1; } } return start; } }
50e462c3e1dbcc0c9650d7b830b591a3a89bcb57
c3b6658e0e5ac8ae642d60c20316cc99b6e0f31d
/app/src/test/java/com/isee/banner/ExampleUnitTest.java
32ac25becaebed4cad245bd1a61e74756a164d29
[]
no_license
xiDaiDai/banner
f6463b30997be8846f0836ee2353f94725b01c3c
0ab2db16aa6509a38a60522c67edcc0a433d10b3
refs/heads/master
2021-01-21T12:59:17.376940
2016-05-26T09:55:58
2016-05-26T09:55:58
49,482,852
0
0
null
null
null
null
UTF-8
Java
false
false
308
java
package com.isee.banner; import org.junit.Test; import static org.junit.Assert.*; /** * To work on unit tests, switch the Test Artifact in the Build Variants view. */ public class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } }
0f57781c88ecd682a558531ed1304adcee68fad4
169c0e1712ff361d74c4dcf927fa71f18449aca0
/app/src/main/java/webs/sistemmanajemenkontrolproyek/InputKegiatan.java
c2cfdf0016eff750ad05d165de9934ede1f551d5
[]
no_license
fajarkekinian/tugas
028d3aebffc0baa9d11a6728dc244ea00a8a2a5d
df18eacf8ecc512961cd7417c89b79285dd1afbc
refs/heads/master
2021-01-19T03:01:33.363989
2016-06-19T13:56:17
2016-06-19T13:56:17
61,482,713
0
0
null
null
null
null
UTF-8
Java
false
false
2,873
java
package webs.sistemmanajemenkontrolproyek; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; import Setting.JsonParser; public class InputKegiatan extends AppCompatActivity implements AdapterView.OnItemSelectedListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_input_kegiatan); // Spinner element Spinner spinner1 = (Spinner) findViewById(R.id.spiner1); Spinner spinner2 = (Spinner) findViewById(R.id.spiner2); Spinner spinner3 = (Spinner) findViewById(R.id.spiner3); Spinner spinner4 = (Spinner) findViewById(R.id.spiner4); Spinner spinner5 = (Spinner) findViewById(R.id.spiner5); // Spinner click listener spinner1.setOnItemSelectedListener(this); spinner2.setOnItemSelectedListener(this); // Spinner Drop down elements List<String> categories = new ArrayList<String>(); categories.add("Pilih"); categories.add("Wawancara"); categories.add("Pengumpulan Data dan Analisi"); categories.add("Desain dan Implementasi"); categories.add("Pengujian"); categories.add("Maintenance"); // Creating adapter for spinner ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories); // Drop down layout style - list view with radio button dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // attaching data adapter to spinner spinner1.setAdapter(dataAdapter); spinner2.setAdapter(dataAdapter); spinner3.setAdapter(dataAdapter); spinner4.setAdapter(dataAdapter); spinner5.setAdapter(dataAdapter); } @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // On selecting a spinner item String item = parent.getItemAtPosition(position).toString(); // Showing selected spinner item Toast.makeText(parent.getContext(), "Selected: " + item, Toast.LENGTH_LONG).show(); } public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }
77918cc53b06b24b22c03d59589ba14415f2b3ce
0a1b158dce61e449f20553fd0cdbdaf1b7b7dd62
/src/CarlysCatering/Employee.java
c0552580cdd850027edddb88db71acd5614fd900
[]
no_license
meeramish/carlyscatering
9d8dfde892bbe0c1dafb487177d7ad01d8a72441
7fb3e2903d93ebcb7d3be06ddb5204ad9d052f94
refs/heads/master
2020-09-26T08:21:06.838395
2019-12-06T00:57:06
2019-12-06T00:57:06
226,215,231
0
0
null
null
null
null
UTF-8
Java
false
false
1,029
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 CarlysCatering; /** * * @author meera mishra */ public abstract class Employee { private String employeeNumber; private String lastName; private String firstName; protected double payRate; protected String jobTitle; public void setEmployeeNumber(String num) { employeeNumber = num; } public void setLastName(String name) { lastName = name; } public void setFirstName(String name) { firstName = name; } public String getEmployeeNumber() { return employeeNumber; } public String getName() { return firstName + " " + lastName; } public double getPayRate() { return payRate; } public String getJobTitle() { return jobTitle; } public abstract void setPayRate(double rate); public abstract void setJobTitle(); }
f1212ae4a3157354ec6fc59dff16f808dd0ac66d
b08ed78b77f6815c3f1a13f6f27c2d64cedd8313
/Session5/src/User.java
7e0dad25115e0e68929ff93f928da7bf00613b35
[]
no_license
ishantk/Edureka2018July23
703a8e49e7afc397ae6b346e4e8a3520780a108c
63b99825da9d8e892137f11a5811618f0a871785
refs/heads/master
2020-03-23T21:20:29.479821
2018-08-20T03:20:50
2018-08-20T03:20:50
142,099,214
0
1
null
null
null
null
UTF-8
Java
false
false
1,040
java
// Textual Representation how an object will look like in the memory // what the object will have in it, as in a BOX public class User { // Attributes or Data Members or State of an Object // Below Attributes they do not belong to Class, They Belong to Object !! String name; private String phone; String email; char gender; private int age; String address; // Attributes or Data Members or State of Class // Below Attributes belongs to Class, They Do Not Belong to Object !! static String companyName; // Methods // Belongs to Objects and Not to Class !! // Setter Methods -> Performs write and update operation // needed to access private data !! void setPhone(String ph){ phone = ph; } void setAge(int a){ age = a; } // Getter Methods -> Reads the data and returns back the data String getPhone(){ return phone; } int getAge(){ return age; } // Method // Belongs to Class and Not to Object !! static void showCompanyName(){ System.out.println("Company Name is: "+companyName); } }
68c9e19b36b7f51f9f70eb1674c59a24cf81fd3a
1ec1773fd62e0a48f5c042ab0c5547decc9ac11b
/presto-main/src/main/java/com/facebook/presto/sql/relational/SqlToRowExpressionTranslator.java
03019b23fa7d3811a6e6410c5654a63d4fc1e316
[ "Apache-2.0" ]
permissive
zuoyebushiwo/weiwodb
71c31a2c82c84eab959020aee9ce784ea43518cc
6768496f0b6aa1e8d6f486e71e4711a1a3432c84
refs/heads/master
2021-09-06T09:56:34.499258
2018-02-05T07:41:20
2018-02-05T07:41:20
null
0
0
null
null
null
null
UTF-8
Java
false
false
27,519
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. */ package com.facebook.presto.sql.relational; import com.facebook.presto.Session; import com.facebook.presto.metadata.FunctionKind; import com.facebook.presto.metadata.FunctionRegistry; import com.facebook.presto.metadata.Signature; import com.facebook.presto.spi.type.DecimalParseResult; import com.facebook.presto.spi.type.Decimals; import com.facebook.presto.spi.type.TimeZoneKey; import com.facebook.presto.spi.type.Type; import com.facebook.presto.spi.type.TypeManager; import com.facebook.presto.spi.type.TypeSignature; import com.facebook.presto.sql.relational.optimizer.ExpressionOptimizer; import com.facebook.presto.sql.tree.ArithmeticBinaryExpression; import com.facebook.presto.sql.tree.ArithmeticUnaryExpression; import com.facebook.presto.sql.tree.ArrayConstructor; import com.facebook.presto.sql.tree.AstVisitor; import com.facebook.presto.sql.tree.BetweenPredicate; import com.facebook.presto.sql.tree.BinaryLiteral; import com.facebook.presto.sql.tree.BooleanLiteral; import com.facebook.presto.sql.tree.Cast; import com.facebook.presto.sql.tree.CoalesceExpression; import com.facebook.presto.sql.tree.ComparisonExpression; import com.facebook.presto.sql.tree.DecimalLiteral; import com.facebook.presto.sql.tree.DereferenceExpression; import com.facebook.presto.sql.tree.DoubleLiteral; import com.facebook.presto.sql.tree.Expression; import com.facebook.presto.sql.tree.FieldReference; import com.facebook.presto.sql.tree.FunctionCall; import com.facebook.presto.sql.tree.GenericLiteral; import com.facebook.presto.sql.tree.IfExpression; import com.facebook.presto.sql.tree.InListExpression; import com.facebook.presto.sql.tree.InPredicate; import com.facebook.presto.sql.tree.IntervalLiteral; import com.facebook.presto.sql.tree.IsNotNullPredicate; import com.facebook.presto.sql.tree.IsNullPredicate; import com.facebook.presto.sql.tree.LikePredicate; import com.facebook.presto.sql.tree.LogicalBinaryExpression; import com.facebook.presto.sql.tree.LongLiteral; import com.facebook.presto.sql.tree.NotExpression; import com.facebook.presto.sql.tree.NullIfExpression; import com.facebook.presto.sql.tree.NullLiteral; import com.facebook.presto.sql.tree.Row; import com.facebook.presto.sql.tree.SearchedCaseExpression; import com.facebook.presto.sql.tree.SimpleCaseExpression; import com.facebook.presto.sql.tree.StringLiteral; import com.facebook.presto.sql.tree.SubscriptExpression; import com.facebook.presto.sql.tree.TimeLiteral; import com.facebook.presto.sql.tree.TimestampLiteral; import com.facebook.presto.sql.tree.TryExpression; import com.facebook.presto.sql.tree.WhenClause; import com.facebook.presto.type.RowType; import com.facebook.presto.type.RowType.RowField; import com.facebook.presto.type.UnknownType; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import java.util.IdentityHashMap; import java.util.List; import static com.facebook.presto.metadata.FunctionKind.SCALAR; import static com.facebook.presto.spi.type.BigintType.BIGINT; import static com.facebook.presto.spi.type.BooleanType.BOOLEAN; import static com.facebook.presto.spi.type.DoubleType.DOUBLE; import static com.facebook.presto.spi.type.IntegerType.INTEGER; import static com.facebook.presto.spi.type.TimeWithTimeZoneType.TIME_WITH_TIME_ZONE; import static com.facebook.presto.spi.type.TimestampWithTimeZoneType.TIMESTAMP_WITH_TIME_ZONE; import static com.facebook.presto.spi.type.TypeSignature.parseTypeSignature; import static com.facebook.presto.spi.type.VarbinaryType.VARBINARY; import static com.facebook.presto.spi.type.VarcharType.VARCHAR; import static com.facebook.presto.spi.type.VarcharType.createVarcharType; import static com.facebook.presto.sql.relational.Expressions.call; import static com.facebook.presto.sql.relational.Expressions.constant; import static com.facebook.presto.sql.relational.Expressions.constantNull; import static com.facebook.presto.sql.relational.Expressions.field; import static com.facebook.presto.sql.relational.Signatures.arithmeticExpressionSignature; import static com.facebook.presto.sql.relational.Signatures.arithmeticNegationSignature; import static com.facebook.presto.sql.relational.Signatures.arrayConstructorSignature; import static com.facebook.presto.sql.relational.Signatures.betweenSignature; import static com.facebook.presto.sql.relational.Signatures.castSignature; import static com.facebook.presto.sql.relational.Signatures.coalesceSignature; import static com.facebook.presto.sql.relational.Signatures.comparisonExpressionSignature; import static com.facebook.presto.sql.relational.Signatures.dereferenceSignature; import static com.facebook.presto.sql.relational.Signatures.likePatternSignature; import static com.facebook.presto.sql.relational.Signatures.likeSignature; import static com.facebook.presto.sql.relational.Signatures.logicalExpressionSignature; import static com.facebook.presto.sql.relational.Signatures.nullIfSignature; import static com.facebook.presto.sql.relational.Signatures.rowConstructorSignature; import static com.facebook.presto.sql.relational.Signatures.subscriptSignature; import static com.facebook.presto.sql.relational.Signatures.switchSignature; import static com.facebook.presto.sql.relational.Signatures.tryCastSignature; import static com.facebook.presto.sql.relational.Signatures.whenSignature; import static com.facebook.presto.type.JsonType.JSON; import static com.facebook.presto.type.LikePatternType.LIKE_PATTERN; import static com.facebook.presto.util.DateTimeUtils.parseDayTimeInterval; import static com.facebook.presto.util.DateTimeUtils.parseTimeWithTimeZone; import static com.facebook.presto.util.DateTimeUtils.parseTimeWithoutTimeZone; import static com.facebook.presto.util.DateTimeUtils.parseTimestampWithTimeZone; import static com.facebook.presto.util.DateTimeUtils.parseTimestampWithoutTimeZone; import static com.facebook.presto.util.DateTimeUtils.parseYearMonthInterval; import static com.facebook.presto.util.ImmutableCollectors.toImmutableList; import static com.facebook.presto.util.Types.checkType; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import static io.airlift.slice.SliceUtf8.countCodePoints; import static io.airlift.slice.Slices.utf8Slice; import static java.util.Objects.requireNonNull; public final class SqlToRowExpressionTranslator { private SqlToRowExpressionTranslator() {} public static RowExpression translate( Expression expression, FunctionKind functionKind, IdentityHashMap<Expression, Type> types, FunctionRegistry functionRegistry, TypeManager typeManager, Session session, boolean optimize) { RowExpression result = new Visitor(functionKind, types, typeManager, session.getTimeZoneKey()).process(expression, null); requireNonNull(result, "translated expression is null"); if (optimize) { ExpressionOptimizer optimizer = new ExpressionOptimizer(functionRegistry, typeManager, session); return optimizer.optimize(result); } return result; } private static class Visitor extends AstVisitor<RowExpression, Void> { private final FunctionKind functionKind; private final IdentityHashMap<Expression, Type> types; private final TypeManager typeManager; private final TimeZoneKey timeZoneKey; private Visitor(FunctionKind functionKind, IdentityHashMap<Expression, Type> types, TypeManager typeManager, TimeZoneKey timeZoneKey) { this.functionKind = functionKind; this.types = types; this.typeManager = typeManager; this.timeZoneKey = timeZoneKey; } @Override protected RowExpression visitExpression(Expression node, Void context) { throw new UnsupportedOperationException("not yet implemented: expression translator for " + node.getClass().getName()); } @Override protected RowExpression visitFieldReference(FieldReference node, Void context) { return field(node.getFieldIndex(), types.get(node)); } @Override protected RowExpression visitNullLiteral(NullLiteral node, Void context) { return constantNull(UnknownType.UNKNOWN); } @Override protected RowExpression visitBooleanLiteral(BooleanLiteral node, Void context) { return constant(node.getValue(), BOOLEAN); } @Override protected RowExpression visitLongLiteral(LongLiteral node, Void context) { if (node.getValue() >= Integer.MIN_VALUE && node.getValue() <= Integer.MAX_VALUE) { return constant(node.getValue(), INTEGER); } return constant(node.getValue(), BIGINT); } @Override protected RowExpression visitDoubleLiteral(DoubleLiteral node, Void context) { return constant(node.getValue(), DOUBLE); } @Override protected RowExpression visitDecimalLiteral(DecimalLiteral node, Void context) { DecimalParseResult parseResult = Decimals.parse(node.getValue()); return constant(parseResult.getObject(), parseResult.getType()); } @Override protected RowExpression visitStringLiteral(StringLiteral node, Void context) { return constant(node.getSlice(), createVarcharType(countCodePoints(node.getSlice()))); } @Override protected RowExpression visitBinaryLiteral(BinaryLiteral node, Void context) { return constant(node.getValue(), VARBINARY); } @Override protected RowExpression visitGenericLiteral(GenericLiteral node, Void context) { Type type = typeManager.getType(parseTypeSignature(node.getType())); if (type == null) { throw new IllegalArgumentException("Unsupported type: " + node.getType()); } if (JSON.equals(type)) { return call( new Signature("json_parse", SCALAR, types.get(node).getTypeSignature(), VARCHAR.getTypeSignature()), types.get(node), constant(utf8Slice(node.getValue()), VARCHAR)); } return call( castSignature(types.get(node), VARCHAR), types.get(node), constant(utf8Slice(node.getValue()), VARCHAR)); } @Override protected RowExpression visitTimeLiteral(TimeLiteral node, Void context) { long value; if (types.get(node).equals(TIME_WITH_TIME_ZONE)) { value = parseTimeWithTimeZone(node.getValue()); } else { // parse in time zone of client value = parseTimeWithoutTimeZone(timeZoneKey, node.getValue()); } return constant(value, types.get(node)); } @Override protected RowExpression visitTimestampLiteral(TimestampLiteral node, Void context) { long value; if (types.get(node).equals(TIMESTAMP_WITH_TIME_ZONE)) { value = parseTimestampWithTimeZone(timeZoneKey, node.getValue()); } else { // parse in time zone of client value = parseTimestampWithoutTimeZone(timeZoneKey, node.getValue()); } return constant(value, types.get(node)); } @Override protected RowExpression visitIntervalLiteral(IntervalLiteral node, Void context) { long value; if (node.isYearToMonth()) { value = node.getSign().multiplier() * parseYearMonthInterval(node.getValue(), node.getStartField(), node.getEndField()); } else { value = node.getSign().multiplier() * parseDayTimeInterval(node.getValue(), node.getStartField(), node.getEndField()); } return constant(value, types.get(node)); } @Override protected RowExpression visitComparisonExpression(ComparisonExpression node, Void context) { RowExpression left = process(node.getLeft(), context); RowExpression right = process(node.getRight(), context); return call( comparisonExpressionSignature(node.getType(), left.getType(), right.getType()), BOOLEAN, left, right); } @Override protected RowExpression visitFunctionCall(FunctionCall node, Void context) { List<RowExpression> arguments = node.getArguments().stream() .map(value -> process(value, context)) .collect(toImmutableList()); List<TypeSignature> argumentTypes = arguments.stream() .map(RowExpression::getType) .map(Type::getTypeSignature) .collect(toImmutableList()); Signature signature = new Signature(node.getName().getSuffix(), functionKind, types.get(node).getTypeSignature(), argumentTypes); return call(signature, types.get(node), arguments); } @Override protected RowExpression visitArithmeticBinary(ArithmeticBinaryExpression node, Void context) { RowExpression left = process(node.getLeft(), context); RowExpression right = process(node.getRight(), context); return call( arithmeticExpressionSignature(node.getType(), types.get(node), left.getType(), right.getType()), types.get(node), left, right); } @Override protected RowExpression visitArithmeticUnary(ArithmeticUnaryExpression node, Void context) { RowExpression expression = process(node.getValue(), context); switch (node.getSign()) { case PLUS: return expression; case MINUS: return call( arithmeticNegationSignature(types.get(node), expression.getType()), types.get(node), expression); } throw new UnsupportedOperationException("Unsupported unary operator: " + node.getSign()); } @Override protected RowExpression visitLogicalBinaryExpression(LogicalBinaryExpression node, Void context) { return call( logicalExpressionSignature(node.getType()), BOOLEAN, process(node.getLeft(), context), process(node.getRight(), context)); } @Override protected RowExpression visitCast(Cast node, Void context) { RowExpression value = process(node.getExpression(), context); if (node.isTypeOnly()) { return changeType(value, types.get(node)); } if (node.isSafe()) { return call(tryCastSignature(types.get(node), value.getType()), types.get(node), value); } return call(castSignature(types.get(node), value.getType()), types.get(node), value); } private RowExpression changeType(RowExpression value, Type targetType) { ChangeTypeVisitor visitor = new ChangeTypeVisitor(targetType); return value.accept(visitor, null); } private static class ChangeTypeVisitor implements RowExpressionVisitor<Void, RowExpression> { private final Type targetType; private ChangeTypeVisitor(Type targetType) { this.targetType = targetType; } @Override public RowExpression visitCall(CallExpression call, Void context) { return new CallExpression(call.getSignature(), targetType, call.getArguments()); } @Override public RowExpression visitInputReference(InputReferenceExpression reference, Void context) { return new InputReferenceExpression(reference.getField(), targetType); } @Override public RowExpression visitConstant(ConstantExpression literal, Void context) { return new ConstantExpression(literal.getValue(), targetType); } } @Override protected RowExpression visitCoalesceExpression(CoalesceExpression node, Void context) { List<RowExpression> arguments = node.getOperands().stream() .map(value -> process(value, context)) .collect(toImmutableList()); List<Type> argumentTypes = arguments.stream().map(RowExpression::getType).collect(toImmutableList()); return call(coalesceSignature(types.get(node), argumentTypes), types.get(node), arguments); } @Override protected RowExpression visitSimpleCaseExpression(SimpleCaseExpression node, Void context) { ImmutableList.Builder<RowExpression> arguments = ImmutableList.builder(); arguments.add(process(node.getOperand(), context)); for (WhenClause clause : node.getWhenClauses()) { arguments.add(call(whenSignature(types.get(clause)), types.get(clause), process(clause.getOperand(), context), process(clause.getResult(), context))); } Type returnType = types.get(node); arguments.add(node.getDefaultValue() .map((value) -> process(value, context)) .orElse(constantNull(returnType))); return call(switchSignature(returnType), returnType, arguments.build()); } @Override protected RowExpression visitSearchedCaseExpression(SearchedCaseExpression node, Void context) { /* Translates an expression like: case when cond1 then value1 when cond2 then value2 when cond3 then value3 else value4 end To: IF(cond1, value1, IF(cond2, value2, If(cond3, value3, value4))) */ RowExpression expression = node.getDefaultValue() .map((value) -> process(value, context)) .orElse(constantNull(types.get(node))); for (WhenClause clause : Lists.reverse(node.getWhenClauses())) { expression = call( Signatures.ifSignature(types.get(node)), types.get(node), process(clause.getOperand(), context), process(clause.getResult(), context), expression); } return expression; } @Override protected RowExpression visitDereferenceExpression(DereferenceExpression node, Void context) { RowType rowType = checkType(types.get(node.getBase()), RowType.class, "type"); List<RowField> fields = rowType.getFields(); int index = -1; for (int i = 0; i < fields.size(); i++) { RowField field = fields.get(i); if (field.getName().isPresent() && field.getName().get().equalsIgnoreCase(node.getFieldName())) { checkArgument(index < 0, "Ambiguous field %s in type %s", field, rowType.getDisplayName()); index = i; } } checkState(index >= 0, "could not find field name: %s", node.getFieldName()); Type returnType = types.get(node); return call(dereferenceSignature(returnType, rowType), returnType, process(node.getBase(), context), constant(index, INTEGER)); } @Override protected RowExpression visitIfExpression(IfExpression node, Void context) { ImmutableList.Builder<RowExpression> arguments = ImmutableList.builder(); arguments.add(process(node.getCondition(), context)) .add(process(node.getTrueValue(), context)); if (node.getFalseValue().isPresent()) { arguments.add(process(node.getFalseValue().get(), context)); } else { arguments.add(constantNull(types.get(node))); } return call(Signatures.ifSignature(types.get(node)), types.get(node), arguments.build()); } @Override protected RowExpression visitTryExpression(TryExpression node, Void context) { return call(Signatures.trySignature(types.get(node)), types.get(node), process(node.getInnerExpression(), context)); } @Override protected RowExpression visitInPredicate(InPredicate node, Void context) { ImmutableList.Builder<RowExpression> arguments = ImmutableList.builder(); arguments.add(process(node.getValue(), context)); InListExpression values = (InListExpression) node.getValueList(); for (Expression value : values.getValues()) { arguments.add(process(value, context)); } return call(Signatures.inSignature(), BOOLEAN, arguments.build()); } @Override protected RowExpression visitIsNotNullPredicate(IsNotNullPredicate node, Void context) { RowExpression expression = process(node.getValue(), context); return call( Signatures.notSignature(), BOOLEAN, call(Signatures.isNullSignature(expression.getType()), BOOLEAN, ImmutableList.of(expression))); } @Override protected RowExpression visitIsNullPredicate(IsNullPredicate node, Void context) { RowExpression expression = process(node.getValue(), context); return call(Signatures.isNullSignature(expression.getType()), BOOLEAN, expression); } @Override protected RowExpression visitNotExpression(NotExpression node, Void context) { return call(Signatures.notSignature(), BOOLEAN, process(node.getValue(), context)); } @Override protected RowExpression visitNullIfExpression(NullIfExpression node, Void context) { RowExpression first = process(node.getFirst(), context); RowExpression second = process(node.getSecond(), context); return call( nullIfSignature(types.get(node), first.getType(), second.getType()), types.get(node), first, second); } @Override protected RowExpression visitBetweenPredicate(BetweenPredicate node, Void context) { RowExpression value = process(node.getValue(), context); RowExpression min = process(node.getMin(), context); RowExpression max = process(node.getMax(), context); return call( betweenSignature(value.getType(), min.getType(), max.getType()), BOOLEAN, value, min, max); } @Override protected RowExpression visitLikePredicate(LikePredicate node, Void context) { RowExpression value = process(node.getValue(), context); RowExpression pattern = process(node.getPattern(), context); if (node.getEscape() != null) { RowExpression escape = process(node.getEscape(), context); return call(likeSignature(), BOOLEAN, value, call(likePatternSignature(), LIKE_PATTERN, pattern, escape)); } return call(likeSignature(), BOOLEAN, value, call(castSignature(LIKE_PATTERN, VARCHAR), LIKE_PATTERN, pattern)); } @Override protected RowExpression visitSubscriptExpression(SubscriptExpression node, Void context) { RowExpression base = process(node.getBase(), context); RowExpression index = process(node.getIndex(), context); return call( subscriptSignature(types.get(node), base.getType(), index.getType()), types.get(node), base, index); } @Override protected RowExpression visitArrayConstructor(ArrayConstructor node, Void context) { List<RowExpression> arguments = node.getValues().stream() .map(value -> process(value, context)) .collect(toImmutableList()); List<Type> argumentTypes = arguments.stream() .map(RowExpression::getType) .collect(toImmutableList()); return call(arrayConstructorSignature(types.get(node), argumentTypes), types.get(node), arguments); } @Override protected RowExpression visitRow(Row node, Void context) { List<RowExpression> arguments = node.getItems().stream() .map(value -> process(value, context)) .collect(toImmutableList()); Type returnType = types.get(node); List<Type> argumentTypes = node.getItems().stream() .map(value -> types.get(value)) .collect(toImmutableList()); return call(rowConstructorSignature(returnType, argumentTypes), returnType, arguments); } } }
cebc909ddd04c1fa6db2ef9a26f3f8319c9b2c5e
b04a8ee4acc06ee5b0c0ba1fedd312109aed52f9
/src/controller/Controller.java
27de1ff09ad42d5cdbae94a9c0793b312ed807fc
[]
no_license
hornjt/CollegeDatabase
54950683add3209253fc9f852ef9b4ae750cf2d5
615f9d86b5faba04d5aed191c306e9c1ec637a02
refs/heads/master
2021-01-10T10:03:34.375003
2016-01-29T15:40:12
2016-01-29T15:40:12
50,671,844
0
0
null
null
null
null
UTF-8
Java
false
false
2,251
java
package controller; import gui.FormEvent; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import model.Database; import model.Person; /** * * * @author Jon * This controller class handles data exchange between the * database and view sections of the program * */ public class Controller { Database db = new Database(); /** * * * @return ArrayList<Person> * This will return an arrayList with all people */ public List<Person> getPeople() { return db.getPeople(); } /** * * @param ev Event Object * adds a new person to the database * which is held in the event object */ public void addPerson(FormEvent ev) { Person person = ev.getPerson(); db.addPerson(person); } /** * @return arrayList of only full time students */ public List<Person> getFullTimeStudents() { return db.getFullTimeStudents(); } /** * @return arrayList of only part time students */ public List<Person> getPartTimeStudents() { return db.getPartTimeStudents(); } /** * @return arrayList of only full time faculty */ public List<Person> getFullTimeFaculty() { return db.getFullTimeFaculty(); } /** * @return arrayList of only adjunct faculty */ public List<Person> getAdjunctFaculty() { return db.getAdjunctFaculty(); } /** * @param idNumber takes a string id number to be * used to search an array for a match * @return ArrayList containing all matches */ public ArrayList<Person> searchAll(String idNumber) { return db.searchAll(idNumber); } /** * @param file takes a file object to be saved to the hard disk * @throws IOException if error writing to hard disk */ public void saveToFile(File file) throws IOException { db.saveToFile(file); } /** * @param file takes a file object to be loaded from the hard disk * @throws IOException if error loading the hard disk */ public void loadFromFile(File file) throws IOException { db.loadFromFile(file); } /** * @param index takes an int value holding the row number to be deleted */ public void removePerson(int index) { db.removePerson(index); // the middle man Controller uses the removePerson() method from the Database class } }
8e7b2b940ae33fcc7622d583f58a2af6a83353db
c2ab25b1c5614048cbd44399e03911942c701f7f
/app/src/main/java/me/onionpie/pandorabox/Widget/ViewPagerAnimation/FlipVerticalTransformer.java
24f25db5369245b342ba4c29a4a7334d66f7b88e
[]
no_license
stansen/pandoraboxPrototype
27ba334b12d4074dc5191bab6da5f2160b7d6d17
11e6b800bc46513cc427dcf5101dfa6602d5fbf4
refs/heads/master
2021-01-19T09:52:28.481194
2016-09-09T08:02:16
2016-09-09T08:02:16
82,149,565
0
0
null
null
null
null
UTF-8
Java
false
false
1,047
java
/* * Copyright 2014 Toxic Bakery * * 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 me.onionpie.pandorabox.Widget.ViewPagerAnimation; import android.view.View; public class FlipVerticalTransformer extends ABaseTransformer { @Override protected void onTransform(View view, float position) { final float rotation = -180f * position; view.setAlpha(rotation > 90f || rotation < -90f ? 0f : 1f); view.setPivotX(view.getWidth() * 0.5f); view.setPivotY(view.getHeight() * 0.5f); view.setRotationX(rotation); } }
a4a3b059abb66733aeb2afe210a6f39718ef2df8
a5b7853f5cce068f8da48e607e02449c7e6d722f
/src/main/java/com/bbg/beacon/config/ThymeleafConfiguration.java
381c2beefe0184612c269d7620b4a1f7153a3a92
[]
no_license
miketregan/beacon
cd52be3b118af63d1e9acff21af67981c89c52f2
0f08a6057d803c5f90f2f38c819514420e6a2899
refs/heads/master
2021-01-25T12:36:56.635794
2018-03-01T20:00:30
2018-03-01T20:00:30
123,485,785
0
0
null
null
null
null
UTF-8
Java
false
false
983
java
package com.bbg.beacon.config; import org.apache.commons.lang3.CharEncoding; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.*; import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; @Configuration public class ThymeleafConfiguration { @SuppressWarnings("unused") private final Logger log = LoggerFactory.getLogger(ThymeleafConfiguration.class); @Bean @Description("Thymeleaf template resolver serving HTML 5 emails") public ClassLoaderTemplateResolver emailTemplateResolver() { ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver(); emailTemplateResolver.setPrefix("mails/"); emailTemplateResolver.setSuffix(".html"); emailTemplateResolver.setTemplateMode("HTML5"); emailTemplateResolver.setCharacterEncoding(CharEncoding.UTF_8); emailTemplateResolver.setOrder(1); return emailTemplateResolver; } }
a9c5c3f10957b408fd6c9800af51fbd7d0f8bfbb
f84c74f7c260b526cfc5c757bcdd5fe1413414b5
/app/src/main/java/com/example/manarelsebaay/mvp_rxjava2_retrofit2/Views/Main/MoviesAdapter.java
9a79310d9fbb70353c2dc246e89bd1f45599f1e2
[]
no_license
ManarElsebaay13/MVP_RXJava2_Retrofit2
31277f80403a3a19485527ea3a88423cc97af62c
a458b84b5327784ab05ea26c5e0784f21fb86708
refs/heads/master
2022-11-15T09:58:40.532339
2020-07-07T23:39:30
2020-07-07T23:39:30
277,745,598
0
0
null
null
null
null
UTF-8
Java
false
false
1,579
java
package com.example.manarelsebaay.mvp_rxjava2_retrofit2.Views.Main; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.example.manarelsebaay.mvp_rxjava2_retrofit2.R; import com.example.manarelsebaay.mvp_rxjava2_retrofit2.Data.Movie; import com.squareup.picasso.Picasso; import java.util.List; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; public class MoviesAdapter extends RecyclerView.Adapter<MoviesAdapter.ViewHolder> { private List <Movie> movieList; public MoviesAdapter(List <Movie> list) { movieList = list; } @NonNull @Override public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_card, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { Movie movie = movieList.get(position); holder.movieName.setText(movie.getOriginal_title()); Picasso.get().load("https://image.tmdb.org/t/p/w500" + movie.getPoster_path()).into(holder.moviePoster); } @Override public int getItemCount() { return movieList.size(); } public static class ViewHolder extends RecyclerView.ViewHolder { public ViewHolder(View view) { super(view); movieName = view.findViewById(R.id.movie_name); moviePoster = view.findViewById(R.id.movie_poster); } ImageView moviePoster; TextView movieName; } }
7c56214af662bf7fee94aba3d32bcc9aea2bf2a4
00aca547db8e8c19053308612f18afa0db31d99b
/lanxum/QSGL_20140730_2014_JUL22_CLF/src/com/creationstar/bjtax/qsgl/util/NameValue.java
9bf8abca2dd7a711cb4d67eb29e4d01888223566
[]
no_license
jun33199/Study
6809c178b894d5e42a73f2f6dd964f6bed862b2a
cd8b1709716907448a3269264be8ebd455ed5298
refs/heads/master
2021-01-01T19:10:34.768352
2015-12-25T08:13:47
2015-12-25T08:13:47
25,185,940
2
1
null
null
null
null
GB18030
Java
false
false
1,926
java
package com.creationstar.bjtax.qsgl.util; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; public class NameValue implements Serializable { private String father = ""; // 父节点 private String name = ""; // 名称 private String value = ""; // 名称对应的值 public NameValue(String name, String value) { this.name = name; this.value = value; } public NameValue(String name, String value, String father) { this.name = name; this.value = value; this.father = father; } private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { ois.defaultReadObject(); } private void writeObject(ObjectOutputStream oos) throws IOException { oos.defaultWriteObject(); } /** * 获得名称属性。 * * @return 名称属性 */ public String getName() { return name; } /** * 设置名称属性。 * * @param name * 将要设置的名称属性值。 */ public void setName(String name) { this.name = name; } /** * 获得值属性。 * * @return 值属性。 */ public String getValue() { return value; } /** * 设置值属性。 * * @param value * 值属性。 */ public void setValue(String value) { this.value = value; } /** * * 返回描述该对象的字符串。 * * @return String 描述该对象的字符串。 */ public String toString() { return "<name=" + name + ", value=" + value + ",father=" + father + ">"; } public String getFather() { return father; } public void setFather(String father) { this.father = father; } }
f5573a12278154408993d2357b4248941416ac93
207dc4555cd2cc06a9acc03030cd045192e7208f
/src/main/java/com/phearun/service/impl/FeedServiceImpl.java
47f94e685c628311ae600330f837eebc11c86e7d
[]
no_license
SocketIOServerClient/spring-socketio-server-demo1
bce23ad5977417e4f8e9f328e4703d57f713693d
076910b2e9eb73aaf41d563fa456c69c10f8cc0c
refs/heads/master
2021-01-12T05:38:19.360447
2016-12-22T15:14:20
2016-12-22T15:14:20
77,154,172
0
0
null
null
null
null
UTF-8
Java
false
false
983
java
package com.phearun.service.impl; import java.util.Collection; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.phearun.model.Feed; import com.phearun.repository.FeedRepository; import com.phearun.service.FeedService; /** * Created by PHEARUN on 12/9/2016. */ @Service public class FeedServiceImpl implements FeedService { @Autowired private FeedRepository feedRepository; @Override public boolean save(Feed feed) { return feedRepository.save(feed); } @Override public boolean update(Feed feed) { return feedRepository.update(feed); } @Override public boolean remove(String id) { return feedRepository.remove(id); } @Override public Collection<Feed> findAll() { return feedRepository.findAll(); } @Override public Feed findOne(String id) { return feedRepository.findOne(id); } @Override public int updateLike(String id) { return feedRepository.updateLike(id); } }
8bb4ab6d2613c12094cc7cc02be18ea3c34e4d8e
0924c9c1a5182201cc8db8e6e0c3c7f95d4a584e
/BangunDimensi/src/bangundimensi/BangunDimensi.java
912187d5d16582c59e824df2fe92edf76e8fdbf7
[]
no_license
SidiMuhammad/OOP
c49ae1a11d151b4eb15c6e260b4ab41e5c3c8466
eacd0defe30fb74564f3c8ba7b9eef0181e1f8e0
refs/heads/master
2021-01-03T18:10:57.581428
2020-05-12T15:24:09
2020-05-12T15:24:09
240,186,065
0
0
null
null
null
null
UTF-8
Java
false
false
5,693
java
package bangundimensi; import java.util.Scanner; public class BangunDimensi { public static void main(String[] args) { Scanner scanInput = new Scanner(System.in); int pilih; int pilih2; int pilih3; int sisi; int tinggi; int jari; do { System.out.println("1. Persegi"); System.out.println("2. Lingkaran"); System.out.println("3. Segitiga"); System.out.print("Pilih : "); pilih = scanInput.nextInt(); if (pilih==1) { System.out.println("1. Dua Dimensi (Persegi)"); System.out.println("2. Tiga Dimensi (Kubus & Limas Persegi)"); System.out.print("Pilih : "); pilih2 = scanInput.nextInt(); if (pilih2==1) { System.out.print("Sisi Persegi : "); sisi = scanInput.nextInt(); Persegi P = new Persegi(sisi); P.luas(); P.keliling(); } if (pilih2==2) { System.out.println("1. Kubus"); System.out.println("2. Limas Persegi"); System.out.print("Pilih : "); pilih3 = scanInput.nextInt(); if (pilih3==1) { System.out.print("Sisi Kubus : "); sisi = scanInput.nextInt(); Kubus K = new Kubus(sisi); K.volume(); K.luasp(); } if (pilih3==2) { System.out.print("Sisi Limas Persegi : "); sisi = scanInput.nextInt(); System.out.print("Tinggi Limas Persegi : "); tinggi = scanInput.nextInt(); LimasPersegi LP = new LimasPersegi(sisi,tinggi); LP.volume(); LP.luasp(); } } } if (pilih==2) { System.out.println("1. Dua Dimensi (Lingkaran)"); System.out.println("2. Tiga Dimensi (Tabung & Kerucut)"); System.out.print("Pilih : "); pilih2 = scanInput.nextInt(); if (pilih2==1) { System.out.print("Jari-jari Lingkaran : "); jari = scanInput.nextInt(); Lingkaran L = new Lingkaran(jari); L.luas(); L.keliling(); } if (pilih2==2) { System.out.println("1. Tabung"); System.out.println("2. Kerucut"); System.out.print("Pilih : "); pilih3 = scanInput.nextInt(); if (pilih3==1) { System.out.print("Jari-jari Tabung : "); jari = scanInput.nextInt(); System.out.print("Tinggi Tabung : "); tinggi = scanInput.nextInt(); Tabung T = new Tabung(jari,tinggi); T.volume(); T.luasp(); } if (pilih3==2) { System.out.print("Jari-jari Kerucut : "); jari = scanInput.nextInt(); System.out.print("Tinggi Kerucut : "); tinggi = scanInput.nextInt(); Kerucut K = new Kerucut(jari,tinggi); K.volume(); K.luasp(); } } } if (pilih==3) { System.out.println("1. Dua Dimensi (Segitiga)"); System.out.println("2. Tiga Dimensi (Prisma Segitiga & Limas Segitiga)"); System.out.print("Pilih : "); pilih2 = scanInput.nextInt(); if (pilih2==1) { System.out.print("Sisi Segitiga : "); sisi = scanInput.nextInt(); Segitiga S = new Segitiga(sisi); S.luas(); S.keliling(); } if (pilih2==2) { System.out.println("1. Prisma Segitiga"); System.out.println("2. Limas Segitiga"); System.out.print("Pilih : "); pilih3 = scanInput.nextInt(); if (pilih3==1) { System.out.print("Sisi Prisma Segitiga : "); sisi = scanInput.nextInt(); System.out.print("Tinggi Prisma Segitiga : "); tinggi = scanInput.nextInt(); PrismaSegitiga PS = new PrismaSegitiga(sisi,tinggi); PS.volume(); PS.luasp(); } if (pilih3==2) { System.out.print("Sisi Limas Segitiga : "); sisi = scanInput.nextInt(); System.out.print("Tinggi Limas Segitiga : "); tinggi = scanInput.nextInt(); LimasSegitiga LS = new LimasSegitiga(sisi,tinggi); LS.volume(); LS.luasp(); } } } } while (pilih==1 || pilih==2 || pilih==3); } }
73900c24ad0bb78153dffe89dd489edf278b4a9b
787d212f5a4fa27b8a8fc4c42907f377b021e12a
/src/com/Softy/Random/Game.java
da5a0a3799b00afe929b34844ef306f293251754
[]
no_license
indie-dev/APCS
9d0709cbb7598897e842e94772b756fffc5f98e4
7a43c23e227940cef01f6d0409b7717cec078382
refs/heads/master
2021-01-20T03:14:51.902087
2017-05-10T15:18:46
2017-05-10T15:18:46
89,514,987
0
0
null
null
null
null
UTF-8
Java
false
false
279
java
package com.Softy.Random; import java.util.Scanner; public class Game extends Default{ public static void main(String[] args){ int x = 20; while (x < 25) { x++; System.out.println(x); } } public static void doStuff (int a) { a++; } }
f57bac5f135d510f2e10376367a6e0f82ee823dd
19291c0ae563c863e2da249ca30317c220a32ab3
/many examples(hibernate)/hibernate-intro/src/main/java/com/lti/service/AccountServices.java
e7b02651f2283c6dec3ad6ee9b682e0a4e835fb0
[]
no_license
sangeetha36/some-more-examples-on-hibernate
486338df65f8a1e0b4fca9ae7bd4318aa8235f4d
20d6824e58ea36206973e9707d970ca9b522194f
refs/heads/master
2022-02-25T04:52:48.407772
2019-07-04T13:03:15
2019-07-04T13:03:15
195,242,672
0
0
null
2022-02-10T03:33:38
2019-07-04T13:01:27
Java
UTF-8
Java
false
false
3,112
java
package com.lti.service; import java.util.Date; import java.util.List; import com.lti.dao.AccountDao; import com.lti.entity.Account; import com.lti.entity.BankTransaction; //Classes which contain business are commonly referred to as Service classes //people also use this naming convention in WebServices(SOAP/REST) public class AccountServices { public void openAccount(Account acc) { AccountDao dao= new AccountDao(); dao.save(acc); //apart from this we might write/execute the code for sending //email to the customer here } public void withdraw(long accno,double amount) { AccountDao dao = new AccountDao(); BankTransaction bt= new BankTransaction(); bt.setDate(new Date()); bt.setType("withdraw"); bt.setAmount(amount); Account acc = (Account) dao.fetchById(Account.class, accno); double balance= acc.getBalance(); if ( amount < balance) { balance=balance-amount; acc.setBalance(balance); dao.save(acc); } else { System.out.println("insufficient balance"); } } public void deposit(long accno,double amount) { AccountDao dao = new AccountDao(); Account acc = (Account) dao.fetchById(Account.class, accno); double bal=acc.getBalance()+amount; acc.setBalance(bal); dao.save(acc); BankTransaction bt= new BankTransaction(); bt.setTxno(1); bt.setDate(new Date()); bt.setType("deposite"); bt.setAmount(500); bt.setAccount(acc); dao.save(bt); } public void transfer(long fromAccno,long toAccno,double amount) { AccountDao dao = new AccountDao(); Account acc1 = (Account) dao.fetchById(Account.class, fromAccno); Account acc2= (Account) dao.fetchById(Account.class, toAccno); acc1.setBalance(acc1.getBalance()-amount); acc2.setBalance(acc2.getBalance()+amount); dao.save(acc1); dao.save(acc2); BankTransaction bt1= new BankTransaction(); bt1.setTxno(1); bt1.setDate(new Date()); bt1.setType("trasfer money"); bt1.setAmount(500); bt1.setAccount(acc1); dao.save(bt1); BankTransaction bt2= new BankTransaction(); bt2.setTxno(1); bt2.setDate(new Date()); bt2.setType("received money"); bt2.setAmount(500); bt2.setAccount(acc2); dao.save(bt2); } public double checkBalance(long accno) { AccountDao dao = new AccountDao(); Account acc = (Account) dao.fetchById(Account.class, accno); return acc.getBalance(); } public List<BankTransaction> miniStatement(long accno) { AccountDao dao = new AccountDao(); List<BankTransaction> one=dao.fetchMiniStatement(accno); return one; } public List<Account> balanceStatement(double balance){ AccountDao dao = new AccountDao(); List<Account> one=dao.balanceStatement(balance); return one; } public List<Account> fetchAccountsByActivity(String type,double amount){ AccountDao dao = new AccountDao(); List<Account> one=dao.fetchAccountsByActivity(type,amount); return one; } }
9035dafcdf7369f788133cae6d3c3e794db283ab
bfabe9f14e8f8993c424d509daece5914297494f
/GuestApp/app/src/main/java/com/mikerizzello/guestapp/managers/DataManager.java
2b8c06414357907ec24b455cf9f7af8ab4fc51f3
[]
no_license
michaelrizzello/Android-GuestApp
6128ad9e9290323ec06330d5c5a9b81946246ed5
58963915cf5caf4a9f315f6412bbbb08c75338e4
refs/heads/master
2021-06-10T15:37:21.161202
2016-12-13T14:35:45
2016-12-13T14:35:45
null
0
0
null
null
null
null
UTF-8
Java
false
false
565
java
package com.mikerizzello.guestapp.managers; import com.mikerizzello.guestapp.models.Order; /** * Created by michaelrizzello on 2016-12-12. */ public class DataManager { private static DataManager ourInstance = new DataManager(); public static DataManager getInstance() { return ourInstance; } private Order currentOrder; private DataManager() { } public Order getCurrentOrder() { return currentOrder; } public void setCurrentOrder(Order currentOrder) { this.currentOrder = currentOrder; } }
01bb37afff4cafc18e27de10ea965c2f85b402bc
8167cae705aeee792716859be89c8a168f500b6f
/src/main/java/com/mo/manager/util/RedisUtil.java
5d2b19c5bd960a753ad6280675c5cea04bdc70a4
[]
no_license
Moxiansheng/manager
f849d0195f57cb3b03493906d568982ec9ec5433
3d2748d809b0ec8998ddf3e474a266b7ecf066fe
refs/heads/master
2023-04-08T12:29:14.208734
2021-04-22T08:03:19
2021-04-22T08:03:19
360,438,384
0
0
null
null
null
null
UTF-8
Java
false
false
13,989
java
package com.mo.manager.util; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; @Component public class RedisUtil { @Autowired private RedisTemplate<String, Object> redisTemplate; public RedisUtil(RedisTemplate<String, Object> redisTemplate) { this.redisTemplate = redisTemplate; } /** * 指定缓存失效时间 * @param key 键 * @param time 时间(秒) * @return */ public boolean expire(String key,long time){ try { if(time>0){ redisTemplate.expire(key, time, TimeUnit.SECONDS); } return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * 根据key 获取过期时间 * @param key 键 不能为null * @return 时间(秒) 返回0代表为永久有效 */ public long getExpire(String key){ return redisTemplate.getExpire(key,TimeUnit.SECONDS); } /** * 判断key是否存在 * @param key 键 * @return true 存在 false不存在 */ public boolean hasKey(String key){ try { return redisTemplate.hasKey(key); } catch (Exception e) { e.printStackTrace(); return false; } } /** * 删除缓存 * @param key 可以传一个值 或多个 */ @SuppressWarnings("unchecked") public void del(String ... key){ if(key!=null&&key.length>0){ if(key.length==1){ redisTemplate.delete(key[0]); }else{ List<String> keys = new ArrayList<>(key.length); CollectionUtils.mergeArrayIntoCollection(key, keys); redisTemplate.delete(keys); } } } //============================String============================= /** * 普通缓存获取 * @param key 键 * @return 值 */ public Object get(String key){ return key==null?null:redisTemplate.opsForValue().get(key); } /** * 普通缓存放入 * @param key 键 * @param value 值 * @return true成功 false失败 */ public boolean set(String key,Object value) { try { redisTemplate.opsForValue().set(key, value); return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * 普通缓存放入并设置时间 * @param key 键 * @param value 值 * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 * @return true成功 false 失败 */ public boolean set(String key,Object value,long time){ try { if(time>0){ redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); }else{ set(key, value); } return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * 递增 * @param key 键 * @param delta 要增加几(大于0) * @return */ public long incr(String key, long delta){ if(delta<0){ throw new RuntimeException("递增因子必须大于0"); } return redisTemplate.opsForValue().increment(key, delta); } /** * 递减 * @param key 键 * @param delta 要减少几(小于0) * @return */ public long decr(String key, long delta){ if(delta<0){ throw new RuntimeException("递减因子必须大于0"); } return redisTemplate.opsForValue().increment(key, -delta); } //================================Map================================= /** * HashGet * @param key 键 不能为null * @param item 项 不能为null * @return 值 */ public Object hget(String key,String item){ return redisTemplate.opsForHash().get(key, item); } /** * 获取hashKey对应的所有键值 * @param key 键 * @return 对应的多个键值 */ public Map<Object,Object> hmget(String key){ return redisTemplate.opsForHash().entries(key); } /** * HashSet * @param key 键 * @param map 对应多个键值 * @return true 成功 false 失败 */ public boolean hmset(String key, Map<String,Object> map){ try { redisTemplate.opsForHash().putAll(key, map); return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * HashSet 并设置时间 * @param key 键 * @param map 对应多个键值 * @param time 时间(秒) * @return true成功 false失败 */ public boolean hmset(String key, Map<String,Object> map, long time){ try { redisTemplate.opsForHash().putAll(key, map); if(time>0){ expire(key, time); } return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * 向一张hash表中放入数据,如果不存在将创建 * @param key 键 * @param item 项 * @param value 值 * @return true 成功 false失败 */ public boolean hset(String key,String item,Object value) { try { redisTemplate.opsForHash().put(key, item, value); return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * 向一张hash表中放入数据,如果不存在将创建 * @param key 键 * @param item 项 * @param value 值 * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 * @return true 成功 false失败 */ public boolean hset(String key,String item,Object value,long time) { try { redisTemplate.opsForHash().put(key, item, value); if(time>0){ expire(key, time); } return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * 删除hash表中的值 * @param key 键 不能为null * @param item 项 可以使多个 不能为null */ public void hdel(String key, Object... item){ redisTemplate.opsForHash().delete(key,item); } /** * 判断hash表中是否有该项的值 * @param key 键 不能为null * @param item 项 不能为null * @return true 存在 false不存在 */ public boolean hHasKey(String key, String item){ return redisTemplate.opsForHash().hasKey(key, item); } /** * hash递增 如果不存在,就会创建一个 并把新增后的值返回 * @param key 键 * @param item 项 * @param by 要增加几(大于0) * @return */ public double hincr(String key, String item,double by){ return redisTemplate.opsForHash().increment(key, item, by); } /** * hash递减 * @param key 键 * @param item 项 * @param by 要减少记(小于0) * @return */ public double hdecr(String key, String item,double by){ return redisTemplate.opsForHash().increment(key, item,-by); } //============================set============================= /** * 根据key获取Set中的所有值 * @param key 键 * @return */ public Set<Object> sGet(String key){ try { return redisTemplate.opsForSet().members(key); } catch (Exception e) { e.printStackTrace(); return null; } } /** * 根据value从一个set中查询,是否存在 * @param key 键 * @param value 值 * @return true 存在 false不存在 */ public boolean sHasKey(String key,Object value){ try { return redisTemplate.opsForSet().isMember(key, value); } catch (Exception e) { e.printStackTrace(); return false; } } /** * 将数据放入set缓存 * @param key 键 * @param values 值 可以是多个 * @return 成功个数 */ public long sSet(String key, Object...values) { try { return redisTemplate.opsForSet().add(key, values); } catch (Exception e) { e.printStackTrace(); return 0; } } /** * 将set数据放入缓存 * @param key 键 * @param time 时间(秒) * @param values 值 可以是多个 * @return 成功个数 */ public long sSetAndTime(String key,long time,Object...values) { try { Long count = redisTemplate.opsForSet().add(key, values); if(time>0) { expire(key, time); } return count; } catch (Exception e) { e.printStackTrace(); return 0; } } /** * 获取set缓存的长度 * @param key 键 * @return */ public long sGetSetSize(String key){ try { return redisTemplate.opsForSet().size(key); } catch (Exception e) { e.printStackTrace(); return 0; } } /** * 移除值为value的 * @param key 键 * @param values 值 可以是多个 * @return 移除的个数 */ public long setRemove(String key, Object ...values) { try { Long count = redisTemplate.opsForSet().remove(key, values); return count; } catch (Exception e) { e.printStackTrace(); return 0; } } //===============================list================================= /** * 获取list缓存的内容 * @param key 键 * @param start 开始 * @param end 结束 0 到 -1代表所有值 * @return */ public List<Object> lGet(String key, long start, long end){ try { return redisTemplate.opsForList().range(key, start, end); } catch (Exception e) { e.printStackTrace(); return null; } } /** * 获取list缓存的长度 * @param key 键 * @return */ public long lGetListSize(String key){ try { return redisTemplate.opsForList().size(key); } catch (Exception e) { e.printStackTrace(); return 0; } } /** * 通过索引 获取list中的值 * @param key 键 * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 * @return */ public Object lGetIndex(String key,long index){ try { return redisTemplate.opsForList().index(key, index); } catch (Exception e) { e.printStackTrace(); return null; } } /** * 将list放入缓存 * @param key 键 * @param value 值 * @return */ public boolean lSet(String key, Object value) { try { redisTemplate.opsForList().rightPush(key, value); return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * 将list放入缓存 * @param key 键 * @param value 值 * @param time 时间(秒) * @return */ public boolean lSet(String key, Object value, long time) { try { redisTemplate.opsForList().rightPush(key, value); if (time > 0) { expire(key, time); } return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * 将list放入缓存 * @param key 键 * @param value 值 * @return */ public boolean lSet(String key, List<Object> value) { try { redisTemplate.opsForList().rightPushAll(key, value); return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * 将list放入缓存 * @param key 键 * @param value 值 * @param time 时间(秒) * @return */ public boolean lSet(String key, List<Object> value, long time) { try { redisTemplate.opsForList().rightPushAll(key, value); if (time > 0) { expire(key, time); } return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * 根据索引修改list中的某条数据 * @param key 键 * @param index 索引 * @param value 值 * @return */ public boolean lUpdateIndex(String key, long index,Object value) { try { redisTemplate.opsForList().set(key, index, value); return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * 移除N个值为value * @param key 键 * @param count 移除多少个 * @param value 值 * @return 移除的个数 */ public long lRemove(String key,long count,Object value) { try { Long remove = redisTemplate.opsForList().remove(key, count, value); return remove; } catch (Exception e) { e.printStackTrace(); return 0; } } }
a74d1ece73f62fcba9c9ee51e10c4441a4db341e
f21636e40685d17951c5d1655a02c3026798821a
/lib/java/swift-generator/src/main/java/com/facebook/swift/generator/visitors/TypeVisitor.java
0962592de18e42a29fa936ff1031043852d3f82c
[ "Apache-2.0" ]
permissive
djwatson/swift
fa91f53a98b281988ae255f2a852035020ab75fd
995de7d8d79fe45fc68076c9241fb496d834625b
refs/heads/master
2021-01-17T10:46:40.665703
2013-04-23T17:05:22
2013-04-23T17:38:06
9,609,663
0
1
null
null
null
null
UTF-8
Java
false
false
3,009
java
/* * Copyright (C) 2012 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ package com.facebook.swift.generator.visitors; import com.facebook.swift.generator.SwiftDocumentContext; import com.facebook.swift.generator.SwiftJavaType; import com.facebook.swift.generator.TypeToJavaConverter; import com.facebook.swift.generator.template.TemplateContextGenerator; import com.facebook.swift.parser.model.Typedef; import com.facebook.swift.parser.visitor.DocumentVisitor; import com.facebook.swift.parser.visitor.Nameable; import com.facebook.swift.parser.visitor.Visitable; import com.google.common.base.Preconditions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class TypeVisitor implements DocumentVisitor { private static final Logger LOG = LoggerFactory.getLogger(TypeVisitor.class); private final String javaNamespace; private final SwiftDocumentContext documentContext; public TypeVisitor(final String javaNamespace, final SwiftDocumentContext documentContext) { this.javaNamespace = javaNamespace; this.documentContext = documentContext; } @Override public boolean accept(final Visitable visitable) { return visitable instanceof Nameable; } @Override public void visit(final Visitable visitable) { final Nameable type = Nameable.class.cast(visitable); final SwiftJavaType swiftJavaType = new SwiftJavaType(documentContext.getNamespace(), TemplateContextGenerator.mangleJavatypeName(type.getName()), javaNamespace); if (visitable instanceof Typedef) { // Typedef checks must be done before the type is added to the registry. Otherwise it would be possible // to have a typedef point at itself. final Typedef typedef = Typedef.class.cast(visitable); LOG.debug("Checking typedef '{}' as '{}'.", typedef.getType(), typedef.getName()); final TypeToJavaConverter typeConverter = documentContext.getTypeConverter(); Preconditions.checkNotNull(typeConverter.convertType(typedef.getType()), "typedef %s uses unknown type %s!", typedef.getName(), typedef.getType().toString()); documentContext.getTypedefRegistry().add(swiftJavaType, typedef.getType()); } LOG.debug("Registering type '{}'", swiftJavaType); documentContext.getTypeRegistry().add(swiftJavaType); } }
ec6c1714ea6c825ec1a641d17a4d4cbee798ece7
8d688675e6afd4c97947e579d19728520b8638ee
/src/main/Individuo.java
3a6fd6efdc43f4895811787b460f063257f0feaa
[]
no_license
leandrobh9/AG
8e1bf47fe1d6bddf46d0c8cb71462979a154cbdb
db7b9012d252c23dca2d5c0e6071dd70d53f4bc0
refs/heads/master
2016-09-05T12:00:58.646527
2013-10-26T12:43:33
2013-10-26T12:43:33
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,461
java
package main; public class Individuo { private String cromossomo; private Integer distanceHamming; private Integer valorFitness; private Fracao fracao; private Integer indiceNaPopulacao; public Individuo(){} public Individuo(String cromossomo){ this.cromossomo = cromossomo; } public String getCromossomo() { return cromossomo; } public void setCromossomo(String cromossomo) { this.cromossomo = cromossomo; } public Integer getDistanceHamming() { return distanceHamming; } public void setDistanceHamming(Integer distanceHamming) { this.distanceHamming = distanceHamming; } public Integer getValorFitness() { if (distanceHamming == null) { throw new RuntimeException("Erro: Valor de distance haming esta null."); } return getCromossomo().length() - distanceHamming; } public Fracao getFracao() { if (fracao == null) { fracao = new Fracao(); } return fracao; } public void setFracao(Fracao fracao) { this.fracao = fracao; } public Integer getIndiceNaPopulacao() { return indiceNaPopulacao; } public void setIndiceNaPopulacao(Integer indiceNaPopulacao) { this.indiceNaPopulacao = indiceNaPopulacao; } @Override public String toString() { return getCromossomo(); } @Override public boolean equals(Object obj) { if (!(obj instanceof Individuo)) return false; Individuo i = (Individuo)obj; return this.getIndiceNaPopulacao().equals(i.getIndiceNaPopulacao()); } }
3e5599358e061c55b661314ff5d9bc50e75f22e8
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/15/15_9831ceeaf13ab27cb0012f595bf5f565a3a72de5/SemanticsVisitor/15_9831ceeaf13ab27cb0012f595bf5f565a3a72de5_SemanticsVisitor_t.java
fb23db1f9cb1e1fa3ef7c0fad852426197c48c50
[]
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
9,247
java
package uk.ac.ucl.comp2010.bestgroup; import java.util.*; import uk.ac.ucl.comp2010.bestgroup.AST.*; public class SemanticsVisitor extends Visitor{ LinkedList<HashMap<String, DeclNode>> symbolTables; public void error(String err, Node node) { System.out.println(err + " (line " + node.lineNumber + ", col " + node.charNumber + ")"); } public SemanticsVisitor() { symbolTables = new LinkedList<HashMap<String, DeclNode>>(); } private void insert(String id, DeclNode node){ symbolTables.getLast().put(id, node); } private void beginScope() { symbolTables.addLast(new HashMap<String, DeclNode>()); } private void endScope(){ symbolTables.removeLast(); } //Possibly change to boolean return-type? private DeclNode lookup(String id){ for(ListIterator<HashMap<String, DeclNode>> it = symbolTables.listIterator(symbolTables.size()); it.hasPrevious();){ DeclNode declaration = it.previous().get(id); if(declaration != null){ return declaration; } } return null; } private DeclNode lookupFirst(String id){ return symbolTables.getFirst().get(id); } //could possibly give more detailed error description if I change it from boolean to int or string and at least 3 returns. private boolean lookupProperty(String id, String property){ //Looks if variable has been declared DeclNode variableDecl = lookup(id); //System.out.println("Entering, looking for: " + id); if(variableDecl != null){ //System.out.println(variableDecl.toString()); } if(variableDecl instanceof VarDeclNode){ //Now need to check what type it is and if it has been declared at the top. String variableType = ((VarDeclNode) variableDecl).var.type; //System.out.println("Found: " + variableType); DeclNode customType = symbolTables.getFirst().get(variableType); if(customType != null){ if(customType instanceof DatatypeDeclNode){ return true; } } } return false; } @Override public Object visit(IntNode node) { return "int"; } @Override public Object visit(ProgramNode node){ beginScope(); //System.out.println("Beginning Scope, declaration size: " + node.declarations.size()); super.visitList(node.declarations); beginScope(); visit(node.main); endScope(); endScope(); return "programnode"; } @Override //To-do: need to check if what the variable is actually declaring, e.g. if it is calling a function, etc. exists. public Object visit(VarDeclNode node){ visitList(node.value); HashMap<String, DeclNode> latestTable = symbolTables.getLast(); if(! latestTable.containsKey(node.var.id)){ latestTable.put(node.var.id, node); }else{ error("Can't declare variable twice in same scope", node); } return "vardecl"; //for declaring variables } @Override public Object visit(FuncDeclNode node){ insert(node.id, node); beginScope(); //System.out.println("FuncDeclNode: Begin Scope"); visitList(node.args); visit(node.body); endScope(); //System.out.println("End Scope"); return "funcdecl"; // for declaring functions } @Override public Object visit(VarTypeNode node){ //System.out.println(node.id); VarDeclNode paramDecl = new VarDeclNode(node, new LinkedList<ExprNode>()); insert(node.id, paramDecl); // for declaring functions return "Bla"; } @Override public Object visit(DatatypeDeclNode node){ //System.out.println("DatatypeDeclNode:" + node.id); if(symbolTables.size() == 1){ symbolTables.getFirst().put(node.id, node); }else{ error("Error! Can't declare Datatype here. If you see this very message, some programmer has been lazy.", node); } return "datatypedecl"; // for declaring datatypes } //Question: An AccessorNode ever only has two elements in node.path, right? //TO-DO: Check the second element. E.g. if it is a tdef, check that you are accessing an element that exists. @Override public Object visit(AccessorNode node){ String variableId = node.path.getFirst(); DeclNode vardecl = lookup(variableId); if(vardecl == null && !(vardecl instanceof VarDeclNode)){ error("Variable " + variableId + " does not exit", node); return null; } else { if(node.path.size() == 1) { return ((VarDeclNode)vardecl).var.type; } else { String t = ((VarDeclNode)vardecl).var.type; DeclNode type; pathloop: for(int p=0; p<node.path.size()-1; p++) { type = lookupFirst(t); for(ListIterator<VarTypeNode> ti = ((DatatypeDeclNode)type).fields.listIterator(); ti.hasNext();) { VarTypeNode n = ti.next(); if(n.id.equals(node.path.get(p+1))) { t = n.type; continue pathloop; } } String e = node.path.getFirst(); for(int i=1; i<=p; i++) { if(i>0) {e+=".";} e += node.path.get(p); } e += " (type: " + t + ") does not have property " + node.path.get(p+1); error(e,node); return null; } return t; } } } @Override public Object visit(FuncCallExprNode node){ DeclNode fdef = lookupFirst(node.id); if(fdef == null || !(fdef instanceof FuncDeclNode)) { error("Function " + node.id + " does not exit", node); return null; } else if(node.args.size() != ((FuncDeclNode)fdef).args.size()){ error("Function " + node.id + " should take " + ((FuncDeclNode)fdef).args.size() + " argument(s) (" + node.args.size() + " given)", node); } else { for(int i=0; i<node.args.size(); i++) { String refType = (String) visit(node.args.get(i)); String declType = (String)(((FuncDeclNode)fdef).args.get(i).type); if(! isSupertype(refType, declType)) { error("Argument " + (i+1) + " of function " + node.id + " should be of type " + declType + " (" + refType + " given)", node.args.get(i)); } } } return ((FuncDeclNode)fdef).type; // for calling functions } public boolean isSupertype(String sub, String sup) { if(sub == sup) return true; if(sub == "int" || sup == "float") return true; return false; } //compares concatNodes. @Override public Object visit(ConcatNode node){ String left = (String)node.left.toString(); String right = (String)node.right.toString(); if(left.equals("tuple") && right.equals("tuple")){ return (String)"tuple"; } else if (left.equals("list") && right.equals("list")){ return (String)"list"; } return (String)"ConcatNode error"; } @Override public Object visit(NumericOperationNode node) { String leftType = (String)visit(node.left); String rightType = (String)visit(node.right); if(leftType == "int" && rightType == "int") { //System.out.println("int"); return "int"; } else if(leftType == "int" && rightType == "float" || leftType == "float" && rightType == "int" || leftType == "float" && rightType == "float"){ //System.out.println("float"); return "float"; } else { //System.out.println("Cannot understand: " + leftType + " " + node.op + " " + rightType); return null; } } @Override public Object visit(BoolNode node){ return (String)"bool"; } @Override public Object visit(CharNode node){ return (String)"char"; } @Override public Object visit(ComparisonNode node){ String left = (String)node.left.toString(); String right = (String)node.right.toString(); if((left.equals("int") && right.equals("int")) || (left.equals("float") && right.equals("float")) || (left.equals("bool") && right.equals("bool")) || (left.equals("int") && right.equals("float")) || (left.equals("int") && right.equals("bool"))){ return (String) "bool"; } return (String) "ComparisonNode error"; } @Override public Object visit(EqualsNode node){ String left = (String)node.left.toString(); String right = (String)node.right.toString(); if (left == (String)"bool" && right == (String)"bool"){ return (String)"bool"; } return (String)"EqualsNode error"; } @Override public Object visit(FloatNode node){ return (String)"float"; } /*@Override public Object visit(IfNode node){ //beginScope(); if ((node.true_block.toString() != null) || (node.false_block.toString() != null)){ for } }*/ public Object visit(String node){ return (String)"string"; } }
8d2789ac3236f825b864ecad0f9d7df4a31c5641
a151e22099770bb1a61c0697c67db4e6015b951c
/src/com/asascience/ioos/model/StationModel.java
c284517dc8d12cd8f429a6c3c1109ce045f450d9
[]
no_license
asascience-open/ioos_sos_parser
e311a8f085f1506dfcd35ed960afe453cc8e229f
90eb7b27916ec101f9131110e4dc0f22723889d2
refs/heads/master
2016-09-06T18:48:40.764166
2014-08-25T16:44:32
2014-08-25T16:44:32
10,457,631
0
0
null
2013-06-11T14:47:41
2013-06-03T15:24:06
Java
UTF-8
Java
false
false
1,894
java
package com.asascience.ioos.model; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class StationModel { String stationName; VectorModel platformLocation; //Map the sensors to the sensor model record Map<String, SensorModel> sensorIdtoSensorDataMap; List<QualityModel> stationQuality; //Map sensor short id to full id Map<String, String> sensorIdMap; public StationModel(){ sensorIdtoSensorDataMap = new HashMap<String, SensorModel>(); stationQuality = new ArrayList<QualityModel>(); sensorIdMap = new HashMap<String, String>(); platformLocation = new VectorModel(); } public VectorModel getPlatformLocation() { return platformLocation; } public void setPlatformLocation(VectorModel platformLocation) { this.platformLocation = platformLocation; } public Map<String, SensorModel> getSensorIdtoSensorDataMap() { return sensorIdtoSensorDataMap; } public void setSensorIdtoSensorDataMap( Map<String, SensorModel> sensorIdtoSensorDataMap) { this.sensorIdtoSensorDataMap = sensorIdtoSensorDataMap; } public List<QualityModel> getStationQuality() { return stationQuality; } public void setStationQuality(List<QualityModel> stationQuality) { this.stationQuality = stationQuality; } public String toString(){ String strRep = "Station: " + stationName + " Location: " + platformLocation.toString() +"\n"; for(SensorModel sensor : sensorIdtoSensorDataMap.values() ){ strRep += " sensor " + sensor.toString() + "\n"; } return strRep; } public String getStationName() { return stationName; } public void setStationName(String stationName) { this.stationName = stationName; } public Map<String, String> getSensorIdMap() { return sensorIdMap; } public void setSensorIdMap(Map<String, String> sensorIdMap) { this.sensorIdMap = sensorIdMap; } }
423f7a8bed26d1714ea555b3ab7719661f5b21c3
e75e2665885f80982d7bd8bd6e4900160f38ee73
/src/main/java/ma/nt/data/mongo/crud/controller/CommandController.java
28bc9c57d9539c3476ff0aeba9b533290ed94ab2
[]
no_license
bidoudan/companymanagement
7e427fb137b57509f8e5e34af826d4552783c584
831b71c974906f9414e53ad84ff04ffd4d550184
refs/heads/master
2022-11-20T19:48:19.849817
2020-07-23T15:55:57
2020-07-23T15:55:57
281,994,719
0
0
null
null
null
null
UTF-8
Java
false
false
1,405
java
package ma.nt.data.mongo.crud.controller; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import ma.nt.data.mongo.crud.entities.Command; import ma.nt.data.mongo.crud.repository.CommandRepository; import net.minidev.json.JSONObject; @RestController @CrossOrigin("*") public class CommandController { @Autowired private CommandRepository commandRepository; @PostMapping("/commands") public Command postCommand(@RequestBody Command command) { return commandRepository.save(command); } @GetMapping("/commands") public List<Command> getCommands(){ return commandRepository.findAll(); } @GetMapping("/commands/{year}") public List<JSONObject> getNbCommandByYear(@PathVariable int year){ System.out.println(commandRepository.getNbCommandByYear(year)); return commandRepository.getNbCommandByYear(year); } @GetMapping("commands/trimester/{year}") public List<JSONObject> getNbrCommandsByTri(@PathVariable int year){ return commandRepository.getNbrCommandsByTrimester(year); } }
cf80e4934539d3735e11e0eb8518dda467e58d71
8d0055100d66fa03c5b5d093705acbfb5645713b
/ticket-master/ticket-master/src/oop/inheritance/Real.java
c5b14536e159e313f175fcf216058df6d1a2a703
[]
no_license
ggsscc1/ticket
bf9a128615e6a2e895ebcb74560bca8fb857a27a
e682b461482a7abd0c4d753d765c39d47081e7c9
refs/heads/master
2021-03-15T12:48:42.876167
2020-03-13T14:29:02
2020-03-13T14:29:02
246,851,361
0
1
null
2020-03-12T14:12:12
2020-03-12T14:12:11
null
UTF-8
Java
false
false
48
java
package oop.inheritance; public class Real { }
1bd9665e643d444f975f58ad39b66ccde21e250f
83db305b75f734f23600ad4ae0101d8ecf784f67
/irontest-core-server/src/main/java/io/irontest/core/runner/TestcaseRunner.java
e6a2be98988816762c0829ebc2a3b7faafc86bf4
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
zxx2015/irontest
f8d7e1846286743df60a7c3216403c502a7e0fea
63fb12b944b86694992fbb59a1893707bacbd1bf
refs/heads/master
2020-05-18T04:52:22.790742
2019-04-29T13:43:22
2019-04-29T13:43:22
null
0
0
null
null
null
null
UTF-8
Java
false
false
11,832
java
package io.irontest.core.runner; import com.fasterxml.jackson.core.JsonProcessingException; import com.github.tomakehurst.wiremock.WireMockServer; import io.irontest.core.assertion.AssertionVerifier; import io.irontest.core.assertion.AssertionVerifierFactory; import io.irontest.db.TestcaseRunDAO; import io.irontest.db.UtilsDAO; import io.irontest.models.HTTPStubMapping; import io.irontest.models.TestResult; import io.irontest.models.Testcase; import io.irontest.models.assertion.*; import io.irontest.models.endpoint.Endpoint; import io.irontest.models.testrun.TestcaseRun; import io.irontest.models.testrun.TeststepRun; import io.irontest.models.teststep.HTTPStubsSetupTeststepProperties; import io.irontest.models.teststep.Teststep; import io.irontest.utils.IronTestUtils; import org.slf4j.Logger; import java.util.*; import static io.irontest.IronTestConstants.*; public abstract class TestcaseRunner { private Testcase testcase; private boolean testcaseHasWaitForProcessingCompletionAction = false; private UtilsDAO utilsDAO; private TestcaseRunDAO testcaseRunDAO; private Logger LOGGER; private TestcaseRunContext testcaseRunContext = new TestcaseRunContext(); private Set<String> udpNames; private Map<String, String> referenceableStringProperties = new HashMap<>(); private Map<String, Endpoint> referenceableEndpointProperties = new HashMap<>(); TestcaseRunner(Testcase testcase, UtilsDAO utilsDAO, TestcaseRunDAO testcaseRunDAO, Logger LOGGER, WireMockServer wireMockServer) { this.testcase = testcase; this.utilsDAO = utilsDAO; this.testcaseRunDAO = testcaseRunDAO; this.LOGGER = LOGGER; this.testcaseRunContext.setWireMockServer(wireMockServer); } protected Testcase getTestcase() { return testcase; } boolean isTestcaseHasWaitForProcessingCompletionAction() { return testcaseHasWaitForProcessingCompletionAction; } TestcaseRunDAO getTestcaseRunDAO() { return testcaseRunDAO; } TestcaseRunContext getTestcaseRunContext() { return testcaseRunContext; } Set<String> getUdpNames() { return udpNames; } Map<String, String> getReferenceableStringProperties() { return referenceableStringProperties; } Map<String, Endpoint> getReferenceableEndpointProperties() { return referenceableEndpointProperties; } public abstract TestcaseRun run() throws JsonProcessingException; // process the test case before starting to run it void preProcessing() { if (!testcase.getHttpStubMappings().isEmpty()) { // add HTTPStubsSetup step Teststep httpStubsSetupStep = new Teststep(Teststep.TYPE_HTTP_STUBS_SETUP); httpStubsSetupStep.setName("Set up HTTP stubs"); HTTPStubsSetupTeststepProperties stubsSetupTeststepProperties = new HTTPStubsSetupTeststepProperties(); stubsSetupTeststepProperties.setHttpStubMappings(testcase.getHttpStubMappings()); httpStubsSetupStep.setOtherProperties(stubsSetupTeststepProperties); testcase.getTeststeps().add(0, httpStubsSetupStep); // add HTTPStubRequestsCheck step and its assertions Teststep stubRequestsCheckStep = new Teststep(Teststep.TYPE_HTTP_STUB_REQUESTS_CHECK); testcase.getTeststeps().add(testcase.getTeststeps().size(), stubRequestsCheckStep); stubRequestsCheckStep.setName("Check HTTP stub requests"); for (HTTPStubMapping stub: testcase.getHttpStubMappings()) { Assertion stubHitAssertion = new Assertion(Assertion.TYPE_HTTP_STUB_HIT); stubHitAssertion.setName("Stub was hit"); stubHitAssertion.setOtherProperties( new HTTPStubHitAssertionProperties(stub.getNumber(), stub.getExpectedHitCount())); stubRequestsCheckStep.getAssertions().add(stubHitAssertion); } if (testcase.getHttpStubMappings().size() > 1 && testcase.isCheckHTTPStubsHitOrder()) { Assertion stubsHitInOrderAssertion = new Assertion(Assertion.TYPE_HTTP_STUBS_HIT_IN_ORDER); stubsHitInOrderAssertion.setName("Stubs were hit in order"); List<Short> expectedHitOrder = new ArrayList<>(); for (HTTPStubMapping stub: testcase.getHttpStubMappings()) { expectedHitOrder.add(stub.getNumber()); } stubsHitInOrderAssertion.setOtherProperties(new HTTPStubsHitInOrderAssertionProperties(expectedHitOrder)); stubRequestsCheckStep.getAssertions().add(stubsHitInOrderAssertion); } Assertion allStubRequestsMatchedAssertion = new Assertion(Assertion.TYPE_ALL_HTTP_STUB_REQUESTS_MATCHED); allStubRequestsMatchedAssertion.setName("All stub requests were matched"); stubRequestsCheckStep.getAssertions().add(allStubRequestsMatchedAssertion); } for (Teststep teststep : testcase.getTeststeps()) { if (Teststep.TYPE_IIB.equals(teststep.getType()) && Teststep.ACTION_WAIT_FOR_PROCESSING_COMPLETION.equals(teststep.getAction())) { // add Wait step testcaseHasWaitForProcessingCompletionAction = true; testcase.getTeststeps().add(0, new Teststep(Teststep.TYPE_WAIT)); break; } } } void startTestcaseRun(TestcaseRun testcaseRun) { Date testcaseRunStartTime = new Date(); LOGGER.info("Start running test case: " + testcase.getName()); testcaseRun.setTestcaseId(testcase.getId()); testcaseRun.setTestcaseName(testcase.getName()); testcaseRun.setTestcaseFolderPath(testcase.getFolderPath()); testcaseRun.setResult(TestResult.PASSED); testcaseRun.setStartTime(testcaseRunStartTime); testcaseRunContext.setTestcaseRunStartTime(testcaseRunStartTime); referenceableStringProperties = IronTestUtils.udpListToMap(testcase.getUdps()); udpNames = referenceableStringProperties.keySet(); referenceableStringProperties.put(IMPLICIT_PROPERTY_NAME_TEST_CASE_START_TIME, IMPLICIT_PROPERTY_DATE_TIME_FORMAT.format(testcaseRunStartTime)); } TeststepRun runTeststep(Teststep teststep) { TeststepRun teststepRun = new TeststepRun(); teststepRun.setTeststep(teststep); // test step run starts Date teststepRunStartTime = new Date(); teststepRun.setStartTime(teststepRunStartTime); referenceableStringProperties.put(IMPLICIT_PROPERTY_NAME_TEST_STEP_START_TIME, IMPLICIT_PROPERTY_DATE_TIME_FORMAT.format(teststepRunStartTime)); LOGGER.info("Start running test step: " + teststep.getName()); // run test step BasicTeststepRun basicTeststepRun; boolean exceptionOccurred = false; // use this flag instead of checking stepRun.getErrorMessage() != null, for code clarity try { basicTeststepRun = TeststepRunnerFactory.getInstance().newTeststepRunner( teststep, utilsDAO, referenceableStringProperties, referenceableEndpointProperties, testcaseRunContext).run(); LOGGER.info("Finish running test step: " + teststep.getName()); teststepRun.setResponse(basicTeststepRun.getResponse()); teststepRun.setInfoMessage(basicTeststepRun.getInfoMessage()); } catch (Exception e) { exceptionOccurred = true; String message = e.getMessage(); teststepRun.setErrorMessage(message == null ? "null" : message); // exception message could be null (though rarely) LOGGER.error(message, e); } // verify assertions if (exceptionOccurred) { teststepRun.setResult(TestResult.FAILED); } else { teststepRun.setResult(TestResult.PASSED); // initially resolve assertion input (based on test step type) Object apiResponse = teststepRun.getResponse(); Object assertionVerificationInput; switch (teststep.getType()) { case Teststep.TYPE_DB: assertionVerificationInput = ((DBAPIResponse) apiResponse).getRowsJSON(); break; case Teststep.TYPE_MQ: assertionVerificationInput = ((MQAPIResponse) apiResponse).getValue(); break; default: assertionVerificationInput = apiResponse; break; } if (Teststep.TYPE_DB.equals(teststep.getType()) && assertionVerificationInput == null) { // SQL inserts/deletes/updates, no assertion verification needed } else { Object assertionVerificationInput2 = null; // verify assertions against the inputs for (Assertion assertion : teststep.getAssertions()) { // further resolve assertion inputs if (Assertion.TYPE_STATUS_CODE_EQUAL.equals(assertion.getType())) { assertionVerificationInput = ((HTTPAPIResponse) apiResponse).getStatusCode(); } else if (Teststep.TYPE_SOAP.equals(teststep.getType()) || Teststep.TYPE_HTTP.equals(teststep.getType())) { assertionVerificationInput = ((HTTPAPIResponse) apiResponse).getHttpBody(); } else if (Assertion.TYPE_HTTP_STUB_HIT.equals(assertion.getType())) { assertionVerificationInput = ((WireMockServerAPIResponse) apiResponse).getAllServeEvents(); HTTPStubHitAssertionProperties otherProperties = (HTTPStubHitAssertionProperties) assertion.getOtherProperties(); assertionVerificationInput2 = getTestcaseRunContext().getHttpStubMappingInstanceIds().get(otherProperties.getStubNumber()); } else if (Assertion.TYPE_HTTP_STUBS_HIT_IN_ORDER.equals(assertion.getType())) { assertionVerificationInput = ((WireMockServerAPIResponse) apiResponse).getAllServeEvents(); } AssertionVerification verification = new AssertionVerification(); teststepRun.getAssertionVerifications().add(verification); verification.setAssertion(assertion); AssertionVerifier verifier = AssertionVerifierFactory.getInstance().create( assertion.getType(), referenceableStringProperties); AssertionVerificationResult verificationResult; try { verificationResult = verifier.verify(assertion, assertionVerificationInput, assertionVerificationInput2); } catch (Exception e) { LOGGER.error("Failed to verify assertion", e); verificationResult = new AssertionVerificationResult(); verificationResult.setResult(TestResult.FAILED); String message = e.getMessage(); verificationResult.setError(message == null ? "null" : message); // exception message could be null (though rarely) } verification.setVerificationResult(verificationResult); if (TestResult.FAILED == verificationResult.getResult()) { teststepRun.setResult(TestResult.FAILED); } } } } // test step run ends teststepRun.setDuration(new Date().getTime() - teststepRun.getStartTime().getTime()); return teststepRun; } }
3d616d435767158288f771b48b055291048a445e
50d16d54c2094e95af0b1f60acd0870a77f3b326
/src/Player.java
cab05c5cfe9b94d8cb8bf6ef12ced7c89160c2a5
[]
no_license
daisys/SoloProject
2e2d074ad5dcb75b554e30acebeb3f183c401f18
04e3a1787a2ad295590c0d9fb2be565e602b4bca
refs/heads/master
2021-01-25T05:15:32.381033
2014-10-05T20:22:19
2014-10-05T20:22:19
null
0
0
null
null
null
null
UTF-8
Java
false
false
69
java
/** * Created by daisyshih on 10/5/14. */ public class Player { }
98dd1ee7b04baeb055a349d0d0eba1bc39236343
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/24/24_603bb2147812e560638437e044ec0a5309ab2c90/SlaveCDImporter/24_603bb2147812e560638437e044ec0a5309ab2c90_SlaveCDImporter_t.java
79d484f45dd70b902b2e407b6746a69dfc575fd8
[]
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
12,364
java
package house.neko.media.slave; import house.neko.media.common.Media; import house.neko.media.common.MediaLocation; import house.neko.media.common.MimeType; import house.neko.media.common.MediaLibrary; import house.neko.media.common.ConfigurationManager; import java.io.File; import java.util.Vector; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.JLabel; import javax.swing.JTabbedPane; import java.awt.GridBagLayout; import java.awt.GridBagConstraints; import java.awt.Container; import java.awt.Component; import org.apache.commons.configuration.HierarchicalConfiguration; import org.apache.commons.logging.Log; public class SlaveCDImporter { private MediaLibrary library; private Log log; private HierarchicalConfiguration config; private MimeType flacMimeType; public SlaveCDImporter(MediaLibrary library) { this.library = library; this.log = ConfigurationManager.getLog(getClass()); flacMimeType = new MimeType(); flacMimeType.setFileExtension("flac"); flacMimeType.setMimeType("audio/flac"); } public void importCD() { if(log.isDebugEnabled()) { log.debug("Starting CD import"); } try { if(log.isDebugEnabled()) { log.debug("getting CDDB info"); } Process cddbExec = Runtime.getRuntime().exec("cd-info --no-cddb-cache"); java.io.BufferedReader r = new java.io.BufferedReader(new java.io.InputStreamReader(cddbExec.getInputStream())); READLOOP: { String year = ""; String discArtist = ""; String discTitle = ""; String trackCount = ""; String trackNumber = ""; String trackLength = ""; String frameOffset = ""; String trackArtist = ""; String trackTitle = ""; Vector<Vector<Media>> discs = new Vector<Vector<Media>>(); String line = r.readLine(); while(line != null) { line = line.trim(); if(line.startsWith("Year:")) { year = line.substring(6); if(log.isTraceEnabled()) { log.trace("CD year: " + year); } } else if(line.startsWith("Artist:")) { discArtist = line.substring(8).replaceAll("^'(.*)'$", "$1"); if(log.isTraceEnabled()) { log.trace("Artist: " + discArtist); } } else if(line.startsWith("Title:")) { discTitle = line.substring(7).replaceAll("^'(.*)'$", "$1"); if(log.isTraceEnabled()) { log.trace("Disc title: " + discTitle); } } else if(line.startsWith("Number of tracks:")) { discs.add(new Vector<Media>()); trackCount = line.substring(18).replaceAll("^'(.*)'$", "$1"); if(log.isTraceEnabled()) { log.trace("Track count: " + trackCount); } } else if(line.startsWith("number:")) { trackNumber = line.substring(8); if(log.isTraceEnabled()) { log.trace("Track number: " + trackNumber); } } else if(line.startsWith("frame offset:")) { frameOffset = line.substring(14); if(log.isTraceEnabled()) { log.trace("Frame offset: " + frameOffset); } } else if(line.startsWith("length:")) { trackLength= line.substring(8).replaceAll("^(.*) seconds$", "$1"); if(log.isTraceEnabled()) { log.trace("length: " + trackLength); } } else if(line.startsWith("artist:")) { trackArtist= line.substring(8).replaceAll("^'(.*)'$", "$1"); if(log.isTraceEnabled()) { log.trace("Track artist: " + trackArtist); } } else if(line.startsWith("title:")) { trackTitle = line.substring(7).replaceAll("^'(.*)'$", "$1"); if(log.isTraceEnabled()) { log.trace("Track title: " + trackTitle); } } else if(line.startsWith("Track ") && trackTitle.length() > 0) { // start next track Media m = new Media(); m.setArtist(trackArtist); m.setName(trackTitle); m.setAlbum(discTitle); try { m.setTrackNumber(Integer.parseInt(trackNumber)); } catch(NumberFormatException nfe) { } discs.lastElement().add(m); } line = r.readLine(); } if(trackTitle.length() > 0) { Media m = new Media(); m.setArtist(trackArtist); m.setName(trackTitle); m.setAlbum(discTitle); try { m.setTrackNumber(Integer.parseInt(trackNumber)); } catch(NumberFormatException nfe) { } discs.lastElement().add(m); } if(log.isInfoEnabled()) { log.info("Found " + discs.size() + " possible matches"); } if(discs.size() > 0) { // pick input pickDisc(discs); } if(discs.size() < 1) { // open input to type getInput(discs); } while(discs.size() > 1) { discs.remove(discs.size()-1); } if(discs.size() == 1 ) { // auto load! if(log.isInfoEnabled()) { log.info("auto-importing disc with " + discs.lastElement().size() + " tracks"); } for(Media m : discs.lastElement().toArray(new Media[discs.lastElement().size()])) { if(log.isInfoEnabled()) { log.info("importing track " + m.getTrackNumber() + ": " + m); } MediaLocation l = new MediaLocation(); l.setMimeType(flacMimeType); m.setLocalLocation(l); File encodedFile = library.getDefaultMediaFile(m); l.setLocationURLString(encodedFile.toURI().toURL().toString()); if(encodedFile.exists()) { if(log.isInfoEnabled()) { log.info("file already exists, skipping " + encodedFile.getAbsolutePath()); } continue; } File tmpFile = File.createTempFile("tmpMediaFlow_", "_" + m.getTrackNumber() + ".wav"); if(log.isDebugEnabled()) { log.debug("ripping track to " + tmpFile.getAbsolutePath()); } String[] cmdRip = { "cdparanoia", "-q", Integer.toString(m.getTrackNumber()), tmpFile.getAbsolutePath() }; Process execRip = Runtime.getRuntime().exec(cmdRip); if(execRip.waitFor() == 0) { // encode if(log.isDebugEnabled()) { log.debug("encoding track to " + encodedFile.getAbsolutePath()); } if(!encodedFile.getParentFile().mkdirs()) { if(log.isDebugEnabled()) { log.debug("unable to create directory " + encodedFile.getParentFile().getAbsolutePath()); } } String[] cmdEncode = { "flac", "--totally-silent", "-8", "--tag=ALBUM=" + m.getAlbum(), "--tag=TITLE=" + m.getName(), "--tag=ARTIST=" + m.getArtist(), "--tag=TRACKNUMBER=" + m.getTrackNumber(), "-o", encodedFile.getAbsolutePath(), tmpFile.getAbsolutePath() }; Process execEncode = Runtime.getRuntime().exec(cmdEncode); if(execEncode.waitFor() == 0) { // add to library l.setSize(encodedFile.length()); m.setID(Media.generateID()); if(log.isDebugEnabled()) { log.debug("adding track " + m.getTrackNumber() + ": " + m); } library.add(m); } } tmpFile.delete(); } } } if(cddbExec.waitFor() != 0) { log.error("Unable to query CDDB"); } } catch(Exception e) { log.error("unable to finish CD import", e); } if(log.isDebugEnabled()) { log.debug("Done with CD import"); } } private void pickDisc(Vector<Vector<Media>> discs) { try { JTabbedPane tp = new JTabbedPane(); for(int k = 0; k < discs.size(); k++) { Vector<Media> md = discs.elementAt(k); JPanel p = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints gc = new GridBagConstraints(); gc.weightx = 100; gc.weighty = 100; p.setLayout(gridbag); gc.anchor = GridBagConstraints.NORTHWEST; gc.ipadx = 7; int y = 0; JTextField[] title = new JTextField[md.size()]; JTextField[] artist = new JTextField[md.size()]; JTextField[] album = new JTextField[md.size()]; addLabel(p, new JLabel("Album"), gridbag, gc, 2, y); addLabel(p, new JLabel("Artist"), gridbag, gc, 4, y); addLabel(p, new JLabel("Title"), gridbag, gc, 6, y); for(int i = 0; i < md.size(); i++) { title[i] = new JTextField(20); artist[i] = new JTextField(20); album[i] = new JTextField(20); title[i].setText(md.elementAt(i).getName()); artist[i].setText(md.elementAt(i).getArtist()); album[i].setText(md.elementAt(i).getAlbum()); addLabel(p, new JLabel("Track " + (i+1)), gridbag, gc, 0, ++y); addField(p, album[i], gridbag, gc, 2, y); addField(p, artist[i], gridbag, gc, 4, y); addField(p, title[i], gridbag, gc, 6, y); } tp.addTab(md.elementAt(0).getArtist() + " - " + md.elementAt(0).getAlbum(), p); } if(JOptionPane.showConfirmDialog(null, tp, "Pick Disc", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { // pop all off except choice log.info("Picked disc #" + tp.getSelectedIndex()); for(int selectedIndex = tp.getSelectedIndex(); selectedIndex > 0; selectedIndex--) { discs.remove(0); } while(discs.size() > 1) { discs.remove(1); } } else { // pop all off log.info("Canceled picking, clearing list"); discs.clear(); } } catch(Exception e) { log.error("unable to pick titles for CD import", e); } } private void getInput(Vector<Vector<Media>> discs) { try { String[] cmdEncode = { "cdparanoia", "-Q" }; Process execQueryCD = Runtime.getRuntime().exec(cmdEncode); java.io.BufferedReader r = new java.io.BufferedReader(new java.io.InputStreamReader(execQueryCD.getErrorStream())); int count = 0; READLOOP: { Pattern p = Pattern.compile("^\\s*(\\d+)\\..*$"); String line = r.readLine(); while(line != null) { log.debug("!"+ line + "!"); Matcher m = p.matcher(line); if(m.matches()) { count = Integer.parseInt(m.group(1)); } line = r.readLine(); } if(log.isDebugEnabled()) { log.debug("Found " + count + " tracks"); } if(execQueryCD.waitFor() != 0) { log.error("Unable to query CD"); } } if(count == 0) { return; } // ask for input now { JPanel p = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints gc = new GridBagConstraints(); gc.weightx = 100; gc.weighty = 100; p.setLayout(gridbag); gc.anchor = GridBagConstraints.NORTHWEST; gc.ipadx = 7; int y = 0; JTextField[] title = new JTextField[count]; JTextField[] artist = new JTextField[count]; JTextField[] album = new JTextField[count]; addLabel(p, new JLabel("Album"), gridbag, gc, 2, y); addLabel(p, new JLabel("Artist"), gridbag, gc, 4, y); addLabel(p, new JLabel("Title"), gridbag, gc, 6, y); for(int i = 0; i < count; i++) { title[i] = new JTextField(20); artist[i] = new JTextField(20); album[i] = new JTextField(20); addLabel(p, new JLabel("Track " + (i+1)), gridbag, gc, 0, ++y); addField(p, album[i], gridbag, gc, 2, y); addField(p, artist[i], gridbag, gc, 4, y); addField(p, title[i], gridbag, gc, 6, y); } discs.add(new Vector<Media>()); if(JOptionPane.showConfirmDialog(null, p, "Input CD", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { for(int i = 0; i < count; i++) { Media m = new Media(); m.setArtist(artist[i].getText()); m.setName(title[i].getText()); m.setAlbum(album[i].getText()); m.setTrackNumber(i+1); discs.lastElement().add(m); } } else { discs.clear(); } } } catch(Exception e) { log.error("unable to get input for CD import", e); } } private void addComponent(Container p, Component c, GridBagLayout gridbag, GridBagConstraints gc, int x, int y) { gc.gridx = x; gc.gridy = y; gc.gridwidth = 1; gc.gridheight = 1; gridbag.setConstraints(c, gc); p.add(c); } private void addLabel(Container p, JLabel label, GridBagLayout gridbag, GridBagConstraints gc, int x, int y) { //gc.gridwidth = GridBagConstraints.RELATIVE; addComponent(p, label, gridbag, gc, x, y); } private void addField(Container p, JTextField field, GridBagLayout gridbag, GridBagConstraints gc, int x, int y) { //gc.gridwidth = GridBagConstraints.RELATIVE; gc.fill = GridBagConstraints.HORIZONTAL; addComponent(p, field, gridbag, gc, x, y); } }
891071321cfa40d26d422ffa53d76cda874eb82a
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/31/31_6efa8bf55bae327e705a083f0ed151f4aeaa59b8/SipHostConfig/31_6efa8bf55bae327e705a083f0ed151f4aeaa59b8_SipHostConfig_s.java
da3328f8dba8e87430379348413b993e04fbb680
[]
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
6,750
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. */ package org.mobicents.servlet.sip.startup; import java.io.File; import java.io.IOException; import java.util.jar.JarEntry; import java.util.jar.JarFile; import org.apache.catalina.Context; import org.apache.catalina.startup.HostConfig; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * @author Jean Deruelle * */ public class SipHostConfig extends HostConfig { private static final String SIP_CONTEXT_CLASS = "org.mobicents.servlet.sip.startup.SipStandardContext"; private static final String SIP_CONTEXT_CONFIG_CLASS = "org.mobicents.servlet.sip.startup.SipContextConfig"; private static transient Log logger = LogFactory .getLog(SipHostConfig.class); /** * */ public SipHostConfig() { super(); } @Override protected void deployApps() { super.deployApps(); } @Override protected void deployApps(String name) { super.deployApps(name); String docBase = getConfigFile(name); // Deploy SARs, and loop if additional descriptors are found File sar = new File(appBase, docBase + ".sar"); if (sar.exists()) { deploySAR(name, sar, docBase + ".sar"); } } /** * * @param name * @param sar * @param string */ private void deploySAR(String name, File sar, String string) { String initialHostConfigClass = host.getConfigClass(); host.setConfigClass(SIP_CONTEXT_CONFIG_CLASS); deployWAR(name, sar, string); host.setConfigClass(initialHostConfigClass); } @Override protected void deployDirectory(String contextPath, File dir, String file) { if (deploymentExists(contextPath)) return; boolean isSipServletApplication = isSipServletDirectory(dir); if(isSipServletApplication) { if(logger.isDebugEnabled()) { logger.debug(SipContextConfig.APPLICATION_SIP_XML + " found in " + dir + ". Enabling sip servlet archive deployment"); } String initialConfigClass = configClass; String initialContextClass = contextClass; host.setConfigClass(SIP_CONTEXT_CONFIG_CLASS); setConfigClass(SIP_CONTEXT_CONFIG_CLASS); setContextClass(SIP_CONTEXT_CLASS); super.deployDirectory(contextPath, dir, file); host.setConfigClass(initialConfigClass); configClass = initialConfigClass; contextClass = initialContextClass; } else { super.deployDirectory(contextPath, dir, file); } } @Override protected void deployDescriptor(String contextPath, File contextXml, String file) { super.deployDescriptor(contextPath, contextXml, file); } @Override protected void deployWARs(File appBase, String[] files) { if (files == null) return; for (int i = 0; i < files.length; i++) { if (files[i].equalsIgnoreCase("META-INF")) continue; if (files[i].equalsIgnoreCase("WEB-INF")) continue; File dir = new File(appBase, files[i]); boolean isSipServletApplication = isSipServletArchive(dir); if(isSipServletApplication) { if(logger.isDebugEnabled()) { logger.debug(SipContextConfig.APPLICATION_SIP_XML + " found in " + dir + ". Enabling sip servlet archive deployment"); } String initialConfigClass = configClass; String initialContextClass = contextClass; host.setConfigClass(SIP_CONTEXT_CONFIG_CLASS); setConfigClass(SIP_CONTEXT_CONFIG_CLASS); setContextClass(SIP_CONTEXT_CLASS); // Calculate the context path and make sure it is unique String contextPath = "/" + files[i]; int period = contextPath.lastIndexOf("."); if (period >= 0) contextPath = contextPath.substring(0, period); if (contextPath.equals("/ROOT")) contextPath = ""; if (isServiced(contextPath)) continue; String file = files[i]; deploySAR(contextPath, dir, file); host.setConfigClass(initialConfigClass); configClass = initialConfigClass; contextClass = initialContextClass; } } super.deployWARs(appBase, files); } /** * Check if the file given in parameter match a sip servlet application, i.e. * if it contains a sip.xml in its WEB-INF directory * @param file the file to check (war or sar) * @return true if the file is a sip servlet application, false otherwise */ private boolean isSipServletArchive(File file) { if (file.getName().toLowerCase().endsWith(".sar")) { return true; } else if (file.getName().toLowerCase().endsWith(".war")) { try{ JarFile jar = new JarFile(file); JarEntry entry = jar.getJarEntry(SipContextConfig.APPLICATION_SIP_XML); if(entry != null) { return true; } } catch (IOException e) { logger.error("An unexpected Exception occured " + "while trying to check if a sip.xml file exists in " + file, e); return false; } } return false; } /** * Check if the file given in parameter match a sip servlet application, i.e. * if it contains a sip.xml in its WEB-INF directory * @param file the file to check (war or sar) * @return true if the file is a sip servlet application, false otherwise */ private boolean isSipServletDirectory(File dir) { if(dir.isDirectory()) { File sipXmlFile = new File(dir.getAbsoluteFile() + SipContextConfig.APPLICATION_SIP_XML); if(sipXmlFile.exists()) { return true; } } return false; } @Override public void manageApp(Context arg0) { super.manageApp(arg0); } }
bab18d8e1073f38122dc235df064c72432b441e4
86b734085d40a0d5d14878c06c85f100473fdd58
/target/generated-sources/entity-codegen/extensions/ab/internal/domain/contact/impl/VendorEvaluationImpl.java
7dbb4e7e92f7797d8d99818316596a71c00eec1d
[]
no_license
sarathkumar-tumula/GuidewireTrainingApp
82a042e688bc565f5f5edb63ad88fc79980ceda8
31f8e82de626fc2c8055f834481353a2e243c2e2
refs/heads/master
2022-08-20T21:38:24.344269
2020-05-27T14:07:52
2020-05-27T14:07:52
267,333,642
0
0
null
null
null
null
UTF-8
Java
false
false
239
java
package extensions.ab.internal.domain.contact.impl; import extensions.ab.internal.domain.contact.gen.VendorEvaluationStub; public class VendorEvaluationImpl extends VendorEvaluationStub implements VendorEvaluationInternal { }
eb25dbe38369e93777c0543c72803ff5ee535e6e
c3a8868508ef706ffbf0292f262268cf428c9f05
/oculus/src/at/oculus/teamf/domain/entity/interfaces/IDomain.java
941230e5fe097ecd2a4068eb35b985d7ccf6ef2b
[]
no_license
dani-sc/projektteamdelta
b11f2630acf9e54524d2dae66e10feb2b589902a
a8e6ddfe076854b97e845e6f3553aaae9ddb561c
refs/heads/master
2021-06-08T21:55:47.177780
2016-11-26T23:20:59
2016-11-26T23:20:59
null
0
0
null
null
null
null
UTF-8
Java
false
false
856
java
/* * Copyright (c) 2015 Team F * * This file is part of Oculus. * Oculus is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * Oculus 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 Oculus. If not, see <http://www.gnu.org/licenses/>. */ package at.oculus.teamf.domain.entity.interfaces; /** * IDomain.java Created by oculus on 11.04.15. */ public interface IDomain { public int getId(); public void setId(int id); }
e7b5191aa295d80b1b92a11a0605e46feaf13ade
15ca1df1e136c1a6a41be7d6995b21949d0df8e6
/etc/SpringFramework_SeoulWiz/springProject1/src/main/java/com/joo/ex/BMICalculator.java
63acf554d4ee87520e5ad80de4b2f7e656ea1c8c
[]
no_license
jooly14/studyspace
b3cb80ff4a8ab8eebe8cd6ec4d9f14910f5aa808
5249efadac1cb3c3ecd4f4c1a71a8c9fd8f8200d
refs/heads/main
2023-03-25T22:22:59.051576
2021-03-28T05:27:08
2021-03-28T05:27:08
350,913,782
0
1
null
2021-03-24T02:49:01
2021-03-24T01:51:39
Java
UHC
Java
false
false
1,345
java
package com.joo.ex; public class BMICalculator { private double lowWeight; private double normal; private double overWeight; private double obesity; public void calc(double weight, double height) { double h = height* 0.01; double result = weight/(h*h); System.out.println("BMI지수 : "+(int)result); if(result>obesity){ System.out.println("비만"); }else if(result>overWeight){ System.out.println("과체중"); }else if(result>normal){ System.out.println("정상체중"); }else{ System.out.println("저체중"); } } public BMICalculator(double lowWeight, double normal, double overWeight, double obesity) { this.lowWeight = lowWeight; this.normal = normal; this.overWeight = overWeight; this.obesity = obesity; } public double getLowWeight() { return lowWeight; } public void setLowWeight(double lowWeight) { this.lowWeight = lowWeight; } public double getNormal() { return normal; } public void setNormal(double normal) { this.normal = normal; } public double getOverWeight() { return overWeight; } public void setOverWeight(double overWeight) { this.overWeight = overWeight; } public double getObesity() { return obesity; } public void setObesity(double obesity) { this.obesity = obesity; } }
da559399cd88f80ef17c25cd70d16dec103f372c
837a5cd0e8a65884067f1bd87955002af2476ddb
/src/test/java/net/v4lproik/googlanime/platform/client/redis/ConfigRedisITest.java
0292d7eafd481a9620400d23e48b1eb758fc49db
[]
no_license
julesbovet/googanime-backend
2695affcefbd5cace82c4f07979847d285abb01c
ce7c98692de9e1dc8af2d56ed43aa8cefc015c06
refs/heads/master
2020-12-25T23:18:37.047319
2015-09-26T17:45:15
2015-09-26T17:45:15
null
0
0
null
null
null
null
UTF-8
Java
false
false
731
java
package net.v4lproik.googlanime.platform.client.redis; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration( classes = { RedisTestConfiguration.class, }) @WebAppConfiguration public class ConfigRedisITest { @Autowired ConfigRedis configRedis; @Test public void test_ping_redis(){ configRedis.connectionFactory().getConnection().ping(); } }
a6b5313c8c145b65861c1319bf4046b0376bf855
ba3effa4e94c4579aeac74e9d31f3631fba479e3
/src/main/java/ru/itis/javalab/repositories/ReviewRepositoryJdbc.java
fa5b08fe0c9e98c15591649b25512cdcdabdb6be
[]
no_license
realsanya/WhiteHall
c86baa76c7b49a504793b5c738f63ce34022970d
c61f99e2d6ed2ac0edd431b7827c4e31fec8cb8b
refs/heads/master
2023-03-08T03:54:05.545428
2021-01-25T06:44:49
2021-01-25T06:44:49
314,345,744
0
0
null
2021-01-25T06:44:50
2020-11-19T19:10:18
Java
UTF-8
Java
false
false
2,345
java
package ru.itis.javalab.repositories; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import ru.itis.javalab.dto.UserDto; import ru.itis.javalab.models.Review; import ru.itis.javalab.repositories.interfaces.ReviewReposiroty; import ru.itis.javalab.services.interfaces.UserService; import javax.sql.DataSource; import java.util.List; public class ReviewRepositoryJdbc implements ReviewReposiroty { private DataSource dataSource; private final JdbcTemplate template; private UserService userService; //language=SQL private final String SQL_SELECT_ALL_BY_USER_ID = "SELECT * FROM review WHERE user_id= ? "; //language=SQL final String SQL_CREATE = "INSERT INTO review ( user_id, date, text ) VALUES (?, ?, ?)"; //language=SQL final String SQL_DELETE = "DELETE FROM review WHERE id= ?"; //language=SQL private final String SQL_SELECT_BY_ID = "SELECT * FROM review WHERE id= ?"; //language=SQL private final String SQL_SELECT_ALL = "SELECT * FROM review"; //TODO private RowMapper<Review> reviewRowMapper = (row, i) -> Review.builder() .id(row.getInt("id")) .user_id(userService.getUserById(row.getInt("user_id"))) .date(row.getDate("date")) .text(row.getString("text")) .build(); public ReviewRepositoryJdbc(DataSource dataSource, UserService userService) { this.dataSource = dataSource; this.userService = userService; this.template = new JdbcTemplate(dataSource); } //TODO @Override public List<Review> findByUserID(Integer user_id) { return template.query(SQL_SELECT_ALL_BY_USER_ID, reviewRowMapper, user_id); } @Override public void save(Review review) { template.update(SQL_CREATE, review.getUser_id(), review.getDate(), review.getText()); } @Override public void delete(Review review) { template.update(SQL_DELETE, review.getId()); } @Override public Review findById(Integer id) { List<Review> reviews = template.query(SQL_SELECT_BY_ID, reviewRowMapper, id); return reviews.isEmpty() ? reviews.get(0) : null; } @Override public List<Review> findAll() { return template.query(SQL_SELECT_ALL, reviewRowMapper); } }
384f507bd8cb874f1e7ffcf26d716acd476a9ab5
92f53cc302f2a614ea3d674f6dc2e42ebce97364
/src/main/java/fr/adaming/dao/PropDaoImpl.java
3633bf6515bc923510527f40a393fa4c5d2f09dc
[]
no_license
DavidManu/Projet_Agence_Immobiliere
9471bc779d3d4997c1b45a6cb0dcfa93bac8e778
46b3ef62a93f8d2bea31f986ca80163f89ef4f98
refs/heads/master
2020-06-02T23:10:50.138980
2017-06-16T08:01:14
2017-06-16T08:01:14
94,109,523
0
0
null
null
null
null
UTF-8
Java
false
false
1,983
java
package fr.adaming.dao; import java.util.List; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import fr.adaming.model.Conseiller; import fr.adaming.model.Proprietaire; @Repository public class PropDaoImpl implements IPropDao { @Autowired private SessionFactory sf; public void setSf(SessionFactory sf) { this.sf = sf; } @Override public Proprietaire createProprietaire(Proprietaire p) { Session s = sf.getCurrentSession(); s.save(p); return p; } @Override public List<Proprietaire> getAllProprietaire(int id) { Session s = sf.openSession(); String getAll = "FROM Proprietaire as p WHERE p.conseiller.id=:pId"; Query query = s.createQuery(getAll); query.setParameter("pId", id); return query.list(); } @Override public Proprietaire getProprietaireById(int id) { Session s = sf.getCurrentSession(); Proprietaire p = (Proprietaire) s.get(Proprietaire.class, id); return p; } @Override public Proprietaire updateProprietaire(Proprietaire p) { Session s = sf.getCurrentSession(); Proprietaire p_rec = (Proprietaire) s.get(Proprietaire.class, p.getId()); p_rec.setNom(p.getNom()); p_rec.setPrenom(p.getPrenom()); p_rec.setNumPrive(p.getNumPrive()); p_rec.setNumTravail(p.getNumTravail()); p_rec.setListeBiens(p.getListeBiens()); p_rec.setAdresse(p.getAdresse()); s.saveOrUpdate(p_rec); return p_rec; } @Override public void deleteProprietaire(int id) { Session s = sf.getCurrentSession(); Proprietaire p = (Proprietaire) s.get(Proprietaire.class, id); s.delete(p); } @Override public List<Proprietaire> getAllProprietaire() { Session s = sf.openSession(); String getAll = "FROM Proprietaire"; Query query = s.createQuery(getAll); return query.list(); } }
[ "INTI-0370@DESKTOP-GQFMHSO" ]
INTI-0370@DESKTOP-GQFMHSO
781f2d3ff4bcca05cbdfbfa92f70d88aa3c22a94
0178a990361378e006c8124b370b80e7e231b694
/Calculator/src/calculator/Calculator.java
5b8277f545f26ba8bf8892dc8b63a849b1942ccc
[]
no_license
mayankkhera/GUI-Calculator
3e63ebcb060100256c2edb798e30832b70033766
4735fffd97e341ea3720b3f1b8d76d61737dcc95
refs/heads/master
2020-09-12T06:54:21.636167
2019-11-18T02:27:04
2019-11-18T02:27:04
222,346,356
0
0
null
null
null
null
UTF-8
Java
false
false
1,701
java
package calculator; /** * File Name: Calculator.java * Author: Mayank Khera * Student ID: 040912734 * Course: CST8221 - JavaApplicationProgramming * Lab Section: 311 * Assignment: 1, Part 1 * Date: October 15, 2019 * Professor: Daniel Cormier * Purpose: This class is responsible for launching the application. * Class list: Calculator */ import java.awt.Dimension; import java.awt.EventQueue; import javax.swing.JFrame; /** * This class is responsible for launching the application. * * @author Mayank Khera * @version 1 * @see calculator * @since 1.8.0_121 * */ public class Calculator { /** * The main method to launch the frame. * @param String[] args - command line arguments * @return N/A */ public static void main(String[] args) { CalculatorSplashScreen obj = new CalculatorSplashScreen(5000); CalculatorViewController controller = new CalculatorViewController(); obj.showSplashWindow(); /** * The EventQueue.invokeLater method to invoke the frame. * @param new Runnable - to run the frame * @return N/A */ EventQueue.invokeLater(new Runnable() { /** * The run method to run the frame. * @param N/A * @return N/A */ public void run() { JFrame frame = new JFrame(); frame.setTitle("Calculator"); frame.setMinimumSize(new Dimension(380, 540)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(controller); frame.setLocationByPlatform(true); frame.pack(); frame.setVisible(true); } }); } }
5d2985d47431774b9d333387b041bbf7756d4dfd
647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4
/com.tencent.mm/classes.jar/com/tencent/mm/autogen/mmdata/rpt/lb.java
6873eac9f1af8faa6dbca6117576d52c0c648614
[]
no_license
tsuzcx/qq_apk
0d5e792c3c7351ab781957bac465c55c505caf61
afe46ef5640d0ba6850cdefd3c11badbd725a3f6
refs/heads/main
2022-07-02T10:32:11.651957
2022-02-01T12:41:38
2022-02-01T12:41:38
453,860,108
36
9
null
2022-01-31T09:46:26
2022-01-31T02:43:22
Java
UTF-8
Java
false
false
3,254
java
package com.tencent.mm.autogen.mmdata.rpt; import com.tencent.matrix.trace.core.AppMethodBeat; import com.tencent.mm.plugin.report.a; public final class lb extends a { public long iNh; public long iYG; public String iYH = ""; public String iYI = ""; public String iYJ = ""; public long ila; public long inE; public String iwI = ""; public String ixm = ""; private String ixp = ""; public final String aIE() { AppMethodBeat.i(368244); Object localObject = new StringBuffer(); ((StringBuffer)localObject).append(this.ila); ((StringBuffer)localObject).append(","); ((StringBuffer)localObject).append(this.inE); ((StringBuffer)localObject).append(","); ((StringBuffer)localObject).append(this.iNh); ((StringBuffer)localObject).append(","); ((StringBuffer)localObject).append(this.iYG); ((StringBuffer)localObject).append(","); ((StringBuffer)localObject).append(this.iwI); ((StringBuffer)localObject).append(","); ((StringBuffer)localObject).append(this.ixm); ((StringBuffer)localObject).append(","); ((StringBuffer)localObject).append(this.iYH); ((StringBuffer)localObject).append(","); ((StringBuffer)localObject).append(this.iYI); ((StringBuffer)localObject).append(","); ((StringBuffer)localObject).append(this.ixp); ((StringBuffer)localObject).append(","); ((StringBuffer)localObject).append(this.iYJ); localObject = ((StringBuffer)localObject).toString(); aUm((String)localObject); AppMethodBeat.o(368244); return localObject; } public final String aIF() { AppMethodBeat.i(368252); Object localObject = new StringBuffer(); ((StringBuffer)localObject).append("action:").append(this.ila); ((StringBuffer)localObject).append("\r\n"); ((StringBuffer)localObject).append("actionTS:").append(this.inE); ((StringBuffer)localObject).append("\r\n"); ((StringBuffer)localObject).append("duration:").append(this.iNh); ((StringBuffer)localObject).append("\r\n"); ((StringBuffer)localObject).append("DynamicState:").append(this.iYG); ((StringBuffer)localObject).append("\r\n"); ((StringBuffer)localObject).append("Contextid:").append(this.iwI); ((StringBuffer)localObject).append("\r\n"); ((StringBuffer)localObject).append("Sessionid:").append(this.ixm); ((StringBuffer)localObject).append("\r\n"); ((StringBuffer)localObject).append("POIID:").append(this.iYH); ((StringBuffer)localObject).append("\r\n"); ((StringBuffer)localObject).append("POIDetail:").append(this.iYI); ((StringBuffer)localObject).append("\r\n"); ((StringBuffer)localObject).append("finderusername:").append(this.ixp); ((StringBuffer)localObject).append("\r\n"); ((StringBuffer)localObject).append("sourceid:").append(this.iYJ); localObject = ((StringBuffer)localObject).toString(); AppMethodBeat.o(368252); return localObject; } public final int getId() { return 22116; } } /* Location: L:\local\mybackup\temp\qq_apk\com.tencent.mm\classes11.jar * Qualified Name: com.tencent.mm.autogen.mmdata.rpt.lb * JD-Core Version: 0.7.0.1 */
79b271f9bd478bea0d44facdf8c03d38ec2507b7
d369d8e856a232063d6ea58c81e45dbc188fbbc7
/app/src/main/java/com/google/android/apps/miyagi/development/utils/ImageUtils.java
0b076c49ca9f3c634e680353f5fb5fc184d9c092
[]
no_license
CarlRehabStudio/growth-engine-android-staging
3d730217ea9d9f7f466ca3551f53b104ccef1a07
648b24404a0ade5f86cb55ad7c1d38e8518e9d1f
refs/heads/master
2021-01-19T18:51:13.071191
2017-08-23T13:23:37
2017-08-23T13:23:37
101,171,705
0
0
null
null
null
null
UTF-8
Java
false
false
1,679
java
package com.google.android.apps.miyagi.development.utils; import android.content.Context; import android.widget.ImageView; import com.bumptech.glide.Glide; import com.bumptech.glide.load.resource.drawable.GlideDrawable; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.target.Target; import rx.Observable; /** * Created by marcin on 27.01.2017. */ public class ImageUtils { /** * Glide preloader observable. * * @param context the context. * @param image image url. * @return Glide preloader observable. */ public static Observable<Boolean> glideObservable(Context context, String image, ImageView imageView) { return Observable.create(subscriber -> Glide.with(context) .load(image) .dontAnimate() .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { subscriber.onNext(false); subscriber.onError(e); subscriber.onCompleted(); return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { subscriber.onNext(true); subscriber.onCompleted(); return false; } }).into(imageView) ); } }
610e689fed8b398fdb86436028649dcf004bef68
bcce2741414e95b2c862f91d6c0c728b94a69850
/src/main/java/com/szbk/Orderhandlerv2/view/WelcomeView.java
c3c9da8cdf11daec959cc19e7199e70039e7023c
[]
no_license
eootaat-sze/Orderhandlerv2
0d6a47de375ae1b07797550608942951462d531f
806629bb2fa88ee9f22c462e5af62b688e368f09
refs/heads/master
2020-03-19T12:14:37.984889
2018-11-30T14:10:23
2018-11-30T14:10:23
136,505,799
0
0
null
null
null
null
UTF-8
Java
false
false
350
java
package com.szbk.Orderhandlerv2.view; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; import com.vaadin.ui.VerticalLayout; public class WelcomeView extends VerticalLayout implements View { @Override public void enter(ViewChangeListener.ViewChangeEvent event) { System.out.println("Hello"); } }
5d19c7a088d5e94c81cf3997a6adb0fe7e122c5e
7d510e65847cba414f093e33beb811ea510a90ee
/app/src/main/java/com/example/app_abacus/Statistics.java
5a61bdd5137adaaeefff5c1a9818aa05a3a9f1e2
[]
no_license
J-Starosta/Abacus
7642d7e0153d65e922a862f0d2b9909d35e6d850
884248596fae26be97e68dad9c49616d8ee45b61
refs/heads/master
2022-12-13T05:47:09.850894
2020-09-06T09:58:51
2020-09-06T09:58:51
293,246,750
0
0
null
null
null
null
UTF-8
Java
false
false
10,259
java
package com.example.app_abacus; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.annotation.SuppressLint; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.MenuItem; import android.view.View; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ImageView; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import com.google.firebase.database.ValueEventListener; import java.util.ArrayList; import java.util.List; public class Statistics extends AppCompatActivity { private boolean checkMonth = true, checkYear = true; private ImageView buttonLogout; private BottomNavigationView bottomNavigationView; private Button buttonListaZmian; private Object Tag; private Spinner spinnerMonths, spinnerYears; private TextView valueSrednio, valueSerwis, valueWyplata, valueZmiany, valueCzasPracy, valueNapiwki; public static final String EXTRA_USER_ID = "com.example.app_abacus.EXTRA_USER_ID"; public static final String EXTRA_MONTH_SELECTED = "com.example.app_abacus.EXTRA_MONTH_SELECTED"; public static final String EXTRA_YEAR_SELECTED = "com.example.app_abacus.EXTRA_YEAR_SELECTED"; private Double napiwki = 0.0, serwis = 0.0, czasPracy = 0.0, srednio = 0.0, wyplata = 0.0, stawka = 0.0, serwisSuma = 0.0, napiwkiSuma = 0.0, czasPracySuma = 0.0; private Integer zmiany = 0; private ArrayAdapter<CharSequence> monthAdapter, yearAdapter; private String userID; private String yearSelected = ""; private String monthSelected = ""; private Intent listaZmian, listaZmianYears; //Firebase private FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance(); private DatabaseReference databaseReference; public Statistics() { } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_statistics); Intent intent = getIntent(); userID = intent.getStringExtra(MainActivity.EXTRA_USER_ID); initialize(); listaZmian = new Intent(this, ListaZmian.class); buttonLogout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FirebaseAuth.getInstance().signOut(); Intent login = new Intent(Statistics.this, Login.class); startActivity(login); } }); yearAdapter = ArrayAdapter.createFromResource(this, R.array.years, android.R.layout.simple_spinner_item); yearAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerYears.setAdapter(yearAdapter); if(checkYear){ spinnerYears.setSelection(0); checkYear = false; } spinnerYears.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { yearSelected = spinnerYears.getSelectedItem().toString(); updatingMonth(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); monthAdapter = ArrayAdapter.createFromResource(this, R.array.months, android.R.layout.simple_spinner_item); monthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerMonths.setAdapter(monthAdapter); if(checkMonth){ spinnerMonths.setSelection(0); checkMonth = false; } spinnerMonths.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { monthSelected = spinnerMonths.getSelectedItem().toString(); updatingMonth(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); Log.d((String) Tag, "Wartość yearSelected w mainie: " +yearSelected); buttonListaZmian.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { listaZmian = new Intent(getApplicationContext(), ListaZmian.class); listaZmian.putExtra(EXTRA_USER_ID, userID); listaZmian.putExtra(EXTRA_YEAR_SELECTED, yearSelected); listaZmian.putExtra(EXTRA_MONTH_SELECTED, monthSelected); startActivity(listaZmian); } }); bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.nav_home: Intent home = new Intent(Statistics.this, MainActivity.class); home.putExtra(EXTRA_USER_ID, userID); startActivity(home); break; case R.id.nav_calendar: Toast.makeText(Statistics.this, "Może dodam", Toast.LENGTH_SHORT).show(); //Intent calendar = new Intent(Statistics.this, Calendar.class); //startActivity(calendar); break; case R.id.nav_statistics: break; } return false; } }); } private void updatingMonth() { databaseReference = firebaseDatabase.getReference(userID).child("Zmiany").child(yearSelected).child(monthSelected); databaseReference.addValueEventListener(new ValueEventListener() { @SuppressLint("DefaultLocale") @Override public void onDataChange(@NonNull DataSnapshot snapshot) { List<user> arrayList = new ArrayList<>(); if(snapshot.exists()){ napiwki = serwis = czasPracy = srednio = wyplata = stawka = 0.0; zmiany = 0; for(DataSnapshot ds : snapshot.getChildren()){ if(ds.child("Serwis").getValue() != null && ds.child("Napiwki").getValue() != null && ds.child("Czas_pracy").getValue() != null && ds.child("Stawka").getValue() != null){ user userData = ds.getValue(user.class); arrayList.add(userData); napiwki = Double.parseDouble(String.valueOf(userData.getNapiwki())); serwis = Double.parseDouble(String.valueOf(userData.getSerwis())); czasPracy = Double.parseDouble(String.valueOf(userData.getCzas_pracy())); stawka = Double.parseDouble(String.valueOf(userData.getStawka())); napiwkiSuma += napiwki; serwisSuma += serwis; czasPracySuma += czasPracy; zmiany++; wyplata += (czasPracy * stawka) + (serwis * 0.5) + napiwki; srednio = wyplata / czasPracySuma; String czasPracyString, napiwkiString, serwisString, srednioString, wyplataString, zmianyString; czasPracyString = czasPracySuma.toString() + " h"; napiwkiString = napiwkiSuma.toString() + " zł"; serwisString = serwisSuma.toString() + " zł"; srednioString = String.format("%.2f", srednio) + " zł/h"; wyplataString = String.format("%.2f", wyplata) + " zł"; zmianyString = zmiany.toString(); valueCzasPracy.setText(czasPracyString); valueNapiwki.setText(napiwkiString); valueSerwis.setText(serwisString); valueSrednio.setText(srednioString); valueWyplata.setText(wyplataString); valueZmiany.setText(zmianyString); } } } else{ valueCzasPracy.setText("0 h"); valueNapiwki.setText("0 zł"); valueSerwis.setText("0 zł"); valueSrednio.setText("0 zł/h"); valueWyplata.setText("0 zł"); valueZmiany.setText("0"); } } @Override public void onCancelled(@NonNull DatabaseError error) { } }); } public void initialize() { bottomNavigationView = findViewById(R.id.bottom_navigation); spinnerMonths = findViewById(R.id.spinner_months); spinnerYears = findViewById(R.id.spinner_years); buttonListaZmian = findViewById(R.id.buttonListaZmian); valueCzasPracy = findViewById(R.id.valueCzasPracy); valueNapiwki = findViewById(R.id.valueNapiwki); valueSerwis = findViewById(R.id.valueSerwis); valueSrednio = findViewById(R.id.valueSrednio); valueWyplata = findViewById(R.id.valueWyplata); valueZmiany = findViewById(R.id.valueZmiany); buttonLogout = findViewById(R.id.buttonLogout); } }
e5bf9d7668288ed6623c24f2f359e322ba43eaf0
7e2d939c2c8aa5fc724f95d6b7c49accca09d054
/src/patterns_volosatov/state/src/main/java/calculator/StateAction.java
23e2bebf584c32fcecee414c3e1df4d67b7a234a
[]
no_license
bkalika/ITVDNJava
2be4ccd59c243b5ee33794e884f9fc8f6d0dc405
ac5f670f59d31b4a893c2ee752e6a8700ef9e590
refs/heads/main
2023-05-22T09:51:56.672777
2021-06-13T09:42:32
2021-06-13T09:42:32
324,816,867
0
0
null
null
null
null
UTF-8
Java
false
false
541
java
package calculator; public class StateAction extends State { void clear(Context context) { context.state = new StateX(); context.state.clear(context); } void digit(Context context, char key) { context.state = new StateY(); context.state.digit(context, key); } void arifm(Context context, char key) { context.o = key; } void equal(Context context) { context.y = context.x; context.state = new StateAnswer(); context.state.equal(context); } }
9b122069f7dfdfa7ec6da43a0b97fa71ab08f83e
4eb68bb498914cf04e23122b4e50dbf19fb67701
/app/src/main/java/com/projects/kevinbarassa/stylusdjawards/CatFragSeventeen.java
35eb907998d1a420aeea765fbac03b5838e831a9
[]
no_license
bqevin/StylusDeejayAwards
e2fb60cf4768cff63d56ad99f540e14f75deeafa
26e8e91949da7dd68883c23421334d5246fe63a8
refs/heads/master
2020-07-02T20:26:30.359035
2017-03-10T14:30:32
2017-03-10T14:30:32
74,285,218
0
0
null
null
null
null
UTF-8
Java
false
false
2,317
java
package com.projects.kevinbarassa.stylusdjawards; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.Toast; import static com.projects.kevinbarassa.stylusdjawards.R.id.radioGroup; import static com.projects.kevinbarassa.stylusdjawards.R.id.voteBtn; /** * Created by Kevin Barassa on 21-Nov-16. */ public class CatFragSeventeen extends Fragment{ private RadioGroup rGroup; private Button vBtn; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate( R.layout.cat_seventeen, container, false); /* Initialize Radio Group and attach click handler */ rGroup = (RadioGroup) rootView.findViewById(radioGroup); rGroup.clearCheck(); vBtn = (Button) rootView.findViewById(voteBtn); return rootView; } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* Attach CheckedChangeListener to radio group */ rGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { RadioButton rb = (RadioButton) group.findViewById(checkedId); if(null!=rb && checkedId > -1){ Toast.makeText(getActivity(), rb.getText(), Toast.LENGTH_SHORT).show(); } } }); vBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { RadioButton rb = (RadioButton) rGroup.findViewById(rGroup.getCheckedRadioButtonId()); Toast.makeText(getActivity(), "Thank you for voting "+ rb.getText(), Toast.LENGTH_SHORT).show(); ViewGroup parent = (ViewGroup) view.getParent(); parent.removeView(view); } }); } }
9b8b5e76275c170b14505712fbb7d9bbb7848006
dde4c31a330fb48561535e1966aec0792fe99bc9
/Kanvas/app/src/test/java/com/example/homay/kanvas/ExampleUnitTest.java
00695278ad4a3b857351b093d776cbafcd1271f6
[]
no_license
siriusanjan/internship-projects
d2223cf3bf5115560542e613b87ecfcaa61e7c39
f4f5868112f83085fa818f3e82f99f39775ec448
refs/heads/master
2020-06-15T01:12:56.296213
2019-02-24T07:34:13
2019-02-24T07:34:13
null
0
0
null
null
null
null
UTF-8
Java
false
false
385
java
package com.example.homay.kanvas; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ public class ExampleUnitTest { @Test public void addition_isCorrect() { assertEquals(4, 2 + 2); } }
bcfa69a7c1718af54cd518d2588c5a25ecb9c148
5c5f06e76071f5269c4f85fb37769cf8a874125c
/app/src/androidTest/java/hr/ferit/ivana/inspired/ExampleInstrumentedTest.java
ada4321cb06415aa20b192098b01467ff0eeefa4
[ "Apache-2.0" ]
permissive
IvPris/Inspired
85d3d3d9754b8fbd8c043df469e3271d2d501197
3bc19ebb00e49bee55176390d630f4d4a895da24
refs/heads/master
2021-04-09T11:30:57.443530
2018-03-29T07:44:25
2018-03-29T07:44:25
125,573,263
0
0
null
null
null
null
UTF-8
Java
false
false
747
java
package hr.ferit.ivana.inspired; 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("hr.ferit.ivana.inspired", appContext.getPackageName()); } }
338c4dc2fb118537409ae6a8c2a3089aa335d471
8be9f6fd60fb3d00341e92f6da0c7da41ff8f401
/src/Inventory/screens/ReportsScreen.java
0a9e1537ddb508f822d4ba5d0ca35ec70f3ce1c0
[]
no_license
TalBarami/SuperLee-3
c7cdeb41b77edd8068b9f3c6a01a34fe2f0955c0
c370fb1c800f263ec444de1acb7b48007e818012
refs/heads/master
2021-01-19T04:58:18.689948
2016-06-20T15:26:13
2016-06-20T15:26:13
60,256,369
0
0
null
null
null
null
UTF-8
Java
false
false
6,982
java
package Inventory.screens; import java.sql.SQLException; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT; import Inventory.program.Util; import Inventory.dbHandlers.CategoryHandler; import Inventory.dbHandlers.ProductHandler; import Inventory.dbHandlers.ProductStockHandler; import Inventory.dbHandlers.StockTicketHandler; import Inventory.entities.Category; public class ReportsScreen { private MainScreen main; private CategoryHandler catHdr; private ProductHandler proHdr; private ProductStockHandler proStkHdr; private StockTicketHandler stkTktHdr; public ReportsScreen(MainScreen main){ this.main = main; catHdr = new CategoryHandler(); proHdr = new ProductHandler(); proStkHdr = new ProductStockHandler(); stkTktHdr = new StockTicketHandler(); } public void mainScreen() { System.out.println("Select desired action: "); System.out.println("1. Report by Category"); System.out.println("2. Report by Product"); System.out.println("3. Report by minimal amount"); System.out.println("4. Report of all expired products"); System.out.println("5. Report of all non-valid products"); System.out.println("6. Report by stockTicket"); System.out.println("7. Return to main screen"); int result = Inventory.program.Util.readIntFromUser(1, 7); switch(result){ case 1: ReportByCategory(); break; case 2: ReportByProduct(); break; case 3: ReportByMinAmount(); break; case 4: ReportOfExpiredProducts(); break; case 5: ReportOfNonValidProducts(); break; case 6: ReportByStocktickets(); break; case 7: main.mainScreen(); break; } } private void ReportByCategory() { Category parentCat = null; Category currCat = null; System.out.println("Please select main category id\npress 0 to return to previous screen"); try { catHdr.PrintAllMainCategories(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } int choice = Util.readIntFromUser(0, -1); try { while((currCat = catHdr.checkIfCategoryExists(choice, 1, null)) == null && choice !=0) { System.out.println("Invalid choice please insert again"); choice = Util.readIntFromUser(-1, -1); } } catch (SQLException e) { e.printStackTrace(); } switch (choice) { case 0: mainScreen(); break; default: System.out.println("To get Report of this category press 0\n Press -1 to return to the previous screen\nOtherwise choose sub category id"); parentCat = currCat; try { catHdr.PrintAllSubCategories(choice, 2); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } choice = Util.readIntFromUser(-1, -1); try { while((currCat = catHdr.checkIfCategoryExists(choice, 2, parentCat)) == null && choice !=0 &&choice !=-1) { System.out.println("Invalid choice please insert again"); choice = Util.readIntFromUser(-1, -1); } } catch (SQLException e) { e.printStackTrace(); } switch (choice) { case -1: mainScreen(); break; case 0: try { proStkHdr.printAllProductInStockByCategory(parentCat.get_id(), 1); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } mainScreen(); break; //chose sub category default: System.out.println("To get Report of this category press 0\n Press -1 to return to the previous screen\nOtherwise choose sub sub category id"); parentCat = currCat; try { catHdr.PrintAllSubCategories(choice, 3); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } choice = Util.readIntFromUser(0, -1); try { while((currCat = catHdr.checkIfCategoryExists(choice, 3, parentCat)) == null && choice !=0 && choice !=-1) { System.out.println("Invalid choice please insert again"); choice = Util.readIntFromUser(-1, -1); } } catch (SQLException e) { e.printStackTrace(); } switch (choice) { case -1: mainScreen(); break; case 0: try { proStkHdr.printAllProductInStockByCategory(parentCat.get_id(), 2); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } mainScreen(); break; default: try { proStkHdr.printAllProductInStockByCategory(currCat.get_id(), 3); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } mainScreen(); break; } break; } break; } } private void ReportByProduct() { System.out.println("Please select id of relevant product\nOr press 0 to return to previous screen"); try { proHdr.printAllProductCatalog(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } int choice = Util.readIntFromUser(0, -1); try { while(!proHdr.checkIfProductExists(choice) && choice !=0) { System.out.println("Invalid choice please insert again"); choice = Util.readIntFromUser(0, -1); } } catch (SQLException e) { e.printStackTrace(); } try { proStkHdr.printAllProductInStock(choice); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } mainScreen(); } private void ReportByMinAmount() { try { proStkHdr.printAllMinimalAmountProductStock(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } mainScreen(); } private void ReportOfExpiredProducts() { try { proStkHdr.printAllExpiredProducts(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } mainScreen(); } private void ReportOfNonValidProducts() { try { proStkHdr.printAllNonValidProducts(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } mainScreen(); } private void ReportByStocktickets() { System.out.println("Please select relevant stock ticket ID\nPress 0 to return to the previous screen"); try { stkTktHdr.printAllStockTickets(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } int choice = Util.readIntFromUser(0, -1); try { while (!stkTktHdr.checkIfStockTicketExists(choice) && choice != 0) { System.out.println("Invalid choice, please choose again"); choice = Util.readIntFromUser(0, -1); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (choice == 0) mainScreen(); else { try { stkTktHdr.printStockTicketItemByID(choice); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } mainScreen(); } } }
20d7dfb1332224318d64b7aa334bd786044fd768
c8cf1210917925cbc362e6a3b215ebc70475253d
/src/com/questions/hackerrank/TheTimeInWords.java
c44782b0f2378e819c2ce479d57e4d0d36f4c9fe
[]
no_license
Rishi74744/MyPractice
7826ca7f6cf79306f3c6bac48ba2d050cf47beda
caa0f1e8d595d863a10d4bce8005545ba6cba324
refs/heads/master
2022-06-08T02:48:01.665567
2022-05-16T13:37:38
2022-05-16T13:37:38
81,055,099
2
0
null
null
null
null
UTF-8
Java
false
false
1,226
java
package com.questions.hackerrank; import java.util.Scanner; public class TheTimeInWords { public static void main(String[] args) { Scanner s = new Scanner(System.in); int hours = s.nextInt(); int mins = s.nextInt(); StringBuilder time = new StringBuilder(); String nums[] = { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty", "twenty one", "twenty two", "twenty three", "twenty four", "twenty five", "twenty six", "twenty seven", "twenty eight", "twenty nine" }; if(mins == 0){ time.append(nums[hours-1]+" o' clock"); }else if (mins == 15) { time.append("quarter past "+nums[hours-1]); }else if (mins == 30) { time.append("half past "+nums[hours-1]); }else if(mins == 45){ time.append("quarter to "+nums[hours]); }else{ if(mins > 30){ int x = 60 - mins; time.append(nums[x-1]+" minutes to "+nums[hours]); }else{ time.append(nums[mins-1]); if(mins > 1){ time.append(" minutes"); }else{ time.append(" minute"); } time.append(" past "+nums[hours-1]); } } System.out.println(time); } }
fc1a12d3f6e2c6d8ee79789cef4c7b647b6ced88
59b214b5b236343a7fdd736f56f8c83a6a468c7c
/common/src/main/java/com/ocean/common/exception/handler/ApiError.java
e459c6281ae625f3815dce5013ad99194b9385c7
[ "MIT" ]
permissive
Barca-LF/ocean-code-generator
a6f229e8e228e68a2801ba2a3c3c41248a95dbc9
9cfecb0811292ca1b15abfa5bb45e847274f6e99
refs/heads/master
2021-01-30T13:17:47.147366
2019-11-22T06:39:20
2019-11-22T06:39:20
null
0
0
null
null
null
null
UTF-8
Java
false
false
581
java
package com.ocean.common.exception.handler; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.time.LocalDateTime; /** * @author Ocean Bin * @date 2019-11-20 */ @Data class ApiError { private Integer status; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime timestamp; private String message; private ApiError() { timestamp = LocalDateTime.now(); } public ApiError(Integer status,String message) { this(); this.status = status; this.message = message; } }
37f261a04e6ebb3fdc412aa0a66da7175d51dad8
3ce54c144000d5896737e82b56beda2d38d72741
/ehcache-impl/src/test/java/org/ehcache/impl/config/loaderwriter/writebehind/WriteBehindProviderConfigurationTest.java
df541d270dbdbf714d606dbc293668d26cd2957c
[ "Apache-2.0" ]
permissive
andyglick/ehcache3
ca59b9a2aed3065cd7a7fee591efec197491bd83
f3c80b20413e71dbd5efa698c8799d1612ca1925
refs/heads/master
2023-09-01T08:57:34.465316
2022-01-06T16:48:40
2022-01-06T16:48:40
88,392,906
0
0
null
2017-04-16T05:21:53
2017-04-16T05:21:53
null
UTF-8
Java
false
false
1,324
java
/* * Copyright Terracotta, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.ehcache.impl.config.loaderwriter.writebehind; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsSame.sameInstance; public class WriteBehindProviderConfigurationTest { @Test public void testDeriveDetachesCorrectly() { WriteBehindProviderConfiguration configuration = new WriteBehindProviderConfiguration("foobar"); WriteBehindProviderConfiguration derived = configuration.build(configuration.derive()); assertThat(derived, is(not(sameInstance(configuration)))); assertThat(derived.getThreadPoolAlias(), is(configuration.getThreadPoolAlias())); } }
a52890dd5c5fc120c2d5241027db0c1c3c5656fe
62617291dd770d6984b529ebd328d11fe007deb6
/rankers/MatrixCalculatorRank06.java
8c646c5b193ff4d0dc3c71d73ad9b5e0869f0a5b
[]
no_license
interprism-inc/pg_contest_01
059bd2f9a07ef44401612d21ec7660a0560a9bb9
77fe20abc3078cec47802875a913e079955ccd77
refs/heads/master
2022-03-14T17:07:50.690292
2016-08-15T06:05:02
2016-08-15T06:05:02
null
0
0
null
null
null
null
UTF-8
Java
false
false
6,529
java
/* * Name: rank6 * Entry Date: 2016/4/26 00:47:37 * Runtime: 3603 ms * * ------- output ------- * * calc1: * 39 msec * * calc2: * 1334 msec * * calc3: * 2155 msec * */ package jp.co.interprism.pg_contest.matrix_calculator; import java.io.*; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * */ public class MatrixCalculator { /** * マトリクス(入力)ファイル(読み取り用) */ private String matrixFilePath = null; /** * 問題ファイル(読み取り用) */ private String problemFilePath = null; /** * 回答結果ファイル(出力用) */ private String resultFilePath = null; /** * インスタンス生成 * @param matrixFilePath マトリクス(入力)ファイル * @param problemFilePath 問題ファイル * @param resultFilePath 回答結果ファイル */ public MatrixCalculator(String matrixFilePath, String problemFilePath, String resultFilePath) { this.matrixFilePath = matrixFilePath; this.problemFilePath = problemFilePath; this.resultFilePath = resultFilePath; } /** * マトリクス(入力)ファイルと問題ファイルを読み取り、問題の回答を結果ファイルに出力する */ public void run() { List<Question> questionList = new ArrayList<>(); Map<Integer, RowMatrix> rowNumberAndMatrixMappings = new HashMap<>(); try (BufferedReader questionReader = new BufferedReader(new FileReader(new File(problemFilePath)), 200000)) { String line; while ((line = questionReader.readLine()) != null) { Question question = new Question(line); int leftRow = question.getLeft().getRow(); int rightRow = question.getRight().getRow(); if (rowNumberAndMatrixMappings.get(leftRow) == null) { rowNumberAndMatrixMappings.put(leftRow, new RowMatrix()); } rowNumberAndMatrixMappings.get(leftRow).addMatrix(question.getLeft()); if (rowNumberAndMatrixMappings.get(rightRow) == null) { rowNumberAndMatrixMappings.put(rightRow, new RowMatrix()); } rowNumberAndMatrixMappings.get(rightRow).addMatrix(question.getRight()); questionList.add(question); } } catch (IOException e) { e.printStackTrace(); } try (BufferedReader matrixReader = new BufferedReader(new FileReader(new File(matrixFilePath)), 10000000)) { int rowNumber = 0; String line; while ((line = matrixReader.readLine()) != null) { RowMatrix rowMatrix = rowNumberAndMatrixMappings.get(rowNumber); if (rowMatrix != null) { rowMatrix.setMatrixValue(line); } rowNumber++; } } catch (IOException e) { e.printStackTrace(); } try (PrintWriter resultWriter = new PrintWriter(new BufferedWriter(new FileWriter(new File(resultFilePath))))) { for (Question question : questionList) { resultWriter.println(question.answer()); } } catch (IOException e) { e.printStackTrace(); } } /** * 問題 */ private class Question { // 問題文のフォーマット private static final String FORMAT_REGEX = "^\\[(\\d+),(\\d+)\\]\\+\\[(\\d+),(\\d+)\\]"; // 加算の左辺 private final Matrix left; // 加算の右辺 private final Matrix right; public Question(String questionSentence) { Pattern p = Pattern.compile(FORMAT_REGEX); Matcher m = p.matcher(questionSentence); if (!m.find()) { System.out.println("questionSentence = [" + questionSentence + "]"); throw new RuntimeException("問題文のフォーマットが間違っています。出題者にクレームの電話を入れてください。"); } left = new Matrix(Integer.parseInt(m.group(1)), Integer.parseInt(m.group(2))); right = new Matrix(Integer.parseInt(m.group(3)), Integer.parseInt(m.group(4))); } public Matrix getRight() { return right; } public Matrix getLeft() { return left; } public int answer() { return right.getValue() + left.getValue(); } @Override public String toString() { return "left : " + left.toString() + ", right : " + right.toString(); } } /** * 問題文の計算対象となる行列 */ private class Matrix { private final int row; private final int column; private int value; public Matrix(int row, int column) { this.row = row; this.column = column; } public int getRow() { return row; } public int getColumn() { return column; } public int getValue() { return value; } public void setValue(int value) { this.value = value; } @Override public String toString() { return "[" + row + "," + column + "]"; } } /** * 行内の必要な値を管理する */ private class RowMatrix { private int maxColumnIndex; private Map<Integer, Set<Matrix>> columnNumberAndMatrixSetMappings; public RowMatrix() { maxColumnIndex = 0; columnNumberAndMatrixSetMappings = new HashMap<>(); } public void setMatrixValue(String rowString) { int index = 0; int next; int off = 0; int value; while ((next = rowString.indexOf(",", off)) != -1) { if (index <= maxColumnIndex) { if (columnNumberAndMatrixSetMappings.containsKey(index)) { value = Integer.parseInt(rowString.substring(off, next)); for (Matrix matrix : columnNumberAndMatrixSetMappings.get(index)) { matrix.setValue(value); } } off = next + 1; index++; } else { break; } } if (next == -1 && maxColumnIndex == index) { value = Integer.parseInt(rowString.substring(off)); for (Matrix matrix : columnNumberAndMatrixSetMappings.get(index)) { matrix.setValue(value); } } } public void addMatrix(Matrix matrix) { int columnIndex = matrix.getColumn(); if (columnNumberAndMatrixSetMappings.get(columnIndex) == null) { columnNumberAndMatrixSetMappings.put(columnIndex, new HashSet<>()); } columnNumberAndMatrixSetMappings.get(columnIndex).add(matrix); if (columnIndex > maxColumnIndex) { maxColumnIndex = columnIndex; } } } }
8e1fbde08c3e742e62839fd0156ea158cea3df05
8b10eaf651362904af982370452944fc4b593b14
/ZYellowPage/src/com/zdt/zyellowpage/jsonEntity/CompanyListReqEntity.java
9674f93cb67796081c9427cafb44dfa55e16611f
[]
no_license
jikeruanjian/ZYellowPage
cff546892e20ce528fcf7f3c4a47e96fd6dc0e3f
edaefa190d222fe81b7f7ec6e8e5fd223646ef18
refs/heads/master
2021-01-19T14:36:25.582161
2015-03-03T08:53:25
2015-03-03T08:53:25
17,101,241
0
0
null
null
null
null
UTF-8
Java
false
false
1,174
java
package com.zdt.zyellowpage.jsonEntity; /** * 商家列表获取参数类 * * @author Kevin * */ public class CompanyListReqEntity { private int page_number; private int max_size; private String area_id; /** * 传入关键词如下:当关键词为”list-hot”时表示获取热门商家列表,当关键词为”list-0102”表示获取某分类下的商家列表,0102 * 表示分类id,当关键词为其它内容的时候,表示搜索商家列表 */ private String keyword; public CompanyListReqEntity( int page,int max,String area,String key){ page_number= page; max_size = max; area_id = area; keyword = key; } public int getPage_number() { return page_number; } public void setPage_number(int page_number) { this.page_number = page_number; } public int getMax_size() { return max_size; } public void setMax_size(int max_size) { this.max_size = max_size; } public String getArea_id() { return area_id; } public void setArea_id(String area_id) { this.area_id = area_id; } public String getKeyword() { return keyword; } public void setKeyword(String keyword) { this.keyword = keyword; } }
d7b76049913f0bb19d8fab65737f73c306435189
3a7a97facc9a1c1d779374f3d1395dec4ea95e11
/chapter6-hystrix/src/main/java/com/ricemarch/chapter6hystrix/controller/InstanceController.java
de3f05f30ffc31c43de2d923ef202d3c38b40f22
[]
no_license
BakaRice/Advanced-SpringCloud
c6f3ed4eb6d85509a24f7972e391ea394a770b75
48db594790968111655eb4f378e3b516cd54a218
refs/heads/master
2023-03-13T09:21:21.245027
2021-03-01T02:22:11
2021-03-01T02:22:11
341,871,818
1
1
null
null
null
null
UTF-8
Java
false
false
1,487
java
package com.ricemarch.chapter6hystrix.controller; import com.ricemarch.chapter6hystrix.service.InstanceService; import com.ricemarch.chaptercommon.chapter5.dto.Instance; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; @RestController @RequestMapping("/instance") public class InstanceController { private static final Logger logger = LoggerFactory.getLogger(InstanceController.class); @Autowired InstanceService instanceService; @RequestMapping(value = "rest-template/{serviceId}", method = RequestMethod.GET) public Instance getInstanceByServiceIdWithRestTemplate(@PathVariable("serviceId") String serviceId) { logger.info("Get Instance by serviceId {}", serviceId); return instanceService.getInstanceByServiceIdWitchRestTemplate(serviceId); } @RequestMapping(value = "feign/{serviceId}", method = RequestMethod.GET) public Instance getInstanceByServiceIdWithFeign(@PathVariable("serviceId") String serviceId) { logger.info("Get Instance by serviceId {}", serviceId); return instanceService.getInstnceByServiceIdWithFeign(serviceId); } }
2b6ba4cf9c52fe2af4f22d4877485f66cb3a3ad7
1f9cc97705d9001d3cec5f7a620245e92ec71609
/src/labbd/ex4/Ex4Panel.java
0cf77da2acf51127d97451e4852d488bb256b78a
[]
no_license
andremissaglia/labbd
5684da07c733e17b88bbb38124a3060109cbcb30
89d95ccc8bdf9f2ddec969e6e9209dd0c5a4522e
refs/heads/master
2021-03-27T12:01:56.170120
2016-11-21T19:15:18
2016-11-21T19:15:18
71,821,639
0
0
null
null
null
null
UTF-8
Java
false
false
10,029
java
package labbd.ex4; import labbd.ex4.Criterios.AndCriterio; import java.util.ArrayList; import labbd.Interface; import org.bson.Document; public class Ex4Panel extends javax.swing.JPanel { private final Interface inter; private final Ex4 ex4; private AndCriterio criterio; private String collection; private static Ex4Panel obj; private Document findCriterio; /** * Creates new form Ex4Panel * * @param inter */ public Ex4Panel(Interface inter) { initComponents(); this.inter = inter; this.ex4 = new Ex4(); this.criterio = new AndCriterio(null); this.pCriterio.removeAll(); this.pCriterio.add(this.criterio); obj = this; this.findCriterio = new Document(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); cbCollections = new javax.swing.JComboBox<>(); jLabel1 = new javax.swing.JLabel(); btnAtualizar = new javax.swing.JButton(); jPanel4 = new javax.swing.JPanel(); txtFilter = new javax.swing.JTextField(); btnPesquisar = new javax.swing.JButton(); tabs = new javax.swing.JTabbedPane(); pCriterio = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); taResultado = new javax.swing.JTextArea(); setBorder(javax.swing.BorderFactory.createEtchedBorder()); jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); cbCollections.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cbCollectionsActionPerformed(evt); } }); jLabel1.setText("Coleção:"); btnAtualizar.setText("Atualizar"); btnAtualizar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAtualizarActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(cbCollections, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnAtualizar) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cbCollections, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1) .addComponent(btnAtualizar)) .addContainerGap()) ); jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder()); txtFilter.setEditable(false); btnPesquisar.setText("Pesquisar"); btnPesquisar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPesquisarActionPerformed(evt); } }); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addComponent(txtFilter) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnPesquisar) .addContainerGap()) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtFilter, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE) .addComponent(btnPesquisar)) ); pCriterio.setBorder(javax.swing.BorderFactory.createEtchedBorder()); pCriterio.setAlignmentX(0.0F); pCriterio.setAlignmentY(0.0F); pCriterio.setLayout(new javax.swing.BoxLayout(pCriterio, javax.swing.BoxLayout.PAGE_AXIS)); tabs.addTab("Critério", pCriterio); taResultado.setColumns(20); taResultado.setRows(5); jScrollPane1.setViewportView(taResultado); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 574, Short.MAX_VALUE) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE) ); tabs.addTab("Resultado", jPanel2); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(tabs) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(tabs) .addContainerGap()) ); }// </editor-fold>//GEN-END:initComponents private void btnAtualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAtualizarActionPerformed ArrayList<String> collections = this.ex4.getCollections(); cbCollections.removeAllItems(); collections.forEach((String t) -> { cbCollections.addItem(t); }); }//GEN-LAST:event_btnAtualizarActionPerformed private void cbCollectionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbCollectionsActionPerformed this.collection = (String) cbCollections.getSelectedItem(); ex4.getFields(this.collection); this.criterio = new AndCriterio(null); this.pCriterio.removeAll(); this.pCriterio.add(this.criterio); this.pCriterio.revalidate(); }//GEN-LAST:event_cbCollectionsActionPerformed private void btnPesquisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarActionPerformed inter.updateStatus("Pesquisando"); new Thread(() -> { taResultado.setText(ex4.find(collection, findCriterio)); inter.updateStatus("Pesquisa Realizada"); tabs.setSelectedIndex(1); }).start(); }//GEN-LAST:event_btnPesquisarActionPerformed public static void update() { obj.findCriterio = obj.criterio.getBson(); obj.txtFilter.setText(String.format("db.%s.find(%s)", obj.collection, obj.findCriterio.toJson())); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnAtualizar; private javax.swing.JButton btnPesquisar; private javax.swing.JComboBox<String> cbCollections; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel4; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JPanel pCriterio; private javax.swing.JTextArea taResultado; private javax.swing.JTabbedPane tabs; private javax.swing.JTextField txtFilter; // End of variables declaration//GEN-END:variables }
2bb502b198830015e63b827b48cb659de2a5eb9c
98d313cf373073d65f14b4870032e16e7d5466f0
/gradle-open-labs/example/src/main/java/se/molybden/Class11434.java
d8995d82b74d9726213fe8a8966f2a0a83667e0f
[]
no_license
Molybden/gradle-in-practice
30ac1477cc248a90c50949791028bc1cb7104b28
d7dcdecbb6d13d5b8f0ff4488740b64c3bbed5f3
refs/heads/master
2021-06-26T16:45:54.018388
2016-03-06T20:19:43
2016-03-06T20:19:43
24,554,562
0
0
null
null
null
null
UTF-8
Java
false
false
110
java
public class Class11434{ public void callMe(){ System.out.println("called"); } }
12606318733be72e66c115d71ec61650d5bc28c5
be59c0ca127a4f7041758b2709e1327bc71b6e12
/qipai/game-zp-yzphz/src/main/java/com/sy599/game/qipai/yzphz/util/zphu/ZpHuBean.java
467c87ec5af6b443f5b336b7ff64874b80fc56bf
[]
no_license
Yiwei-TEST/xxqp-server
2389dd6b12614b0a9557d59b473f88a3a59620cf
c2c683ce8060c0cbaee86c3ee550e0195e1bb7e4
refs/heads/main
2023-08-14T08:49:37.586893
2021-09-15T03:21:13
2021-09-15T03:21:13
401,583,086
1
4
null
null
null
null
UTF-8
Java
false
false
12,699
java
package com.sy599.game.qipai.yzphz.util.zphu; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 跑胡子 */ public class ZpHuBean { // 是否自摸 private boolean isSelfMo; // 不包含癞子的牌组 private int[] cardArr; // 癞子数 private int laiZiNum; // disCardVal private int disCardVal; // 是否已经使用了disCardd private boolean usedDisCard; // 所有胡牌列表 private List<ZpHuLack> huList; // 最大胡息列表 private List<ZpHuLack> maxHuList; // 打牌听牌信息 private Map<Integer, List<Integer>> daTingMap; // 听牌信息 private List<Integer> tingList; public boolean isSelfMo() { return isSelfMo; } public void setSelfMo(boolean selfMo) { isSelfMo = selfMo; } public int[] getCardArr() { return cardArr; } public void setCardArr(int[] cardArr) { this.cardArr = cardArr; } public int getDisCardVal() { return disCardVal; } public void setDisCardVal(int disCardVal) { this.disCardVal = disCardVal; } public int getLaiZiNum() { return laiZiNum; } public void setLaiZiNum(int laiZiNum) { this.laiZiNum = laiZiNum; } public boolean isUsedDisCard() { return usedDisCard; } public void setUsedDisCard(boolean usedDisCard) { this.usedDisCard = usedDisCard; } public List<ZpHuLack> getHuList() { return huList; } public void setHuList(List<ZpHuLack> huList) { this.huList = huList; } public List<ZpHuLack> getMaxHuList() { return maxHuList; } public void setMaxHuList(List<ZpHuLack> maxHuList) { this.maxHuList = maxHuList; } public Map<Integer, List<Integer>> getDaTingMap() { return daTingMap; } public void setDaTingMap(Map<Integer, List<Integer>> daTingMap) { this.daTingMap = daTingMap; } public List<Integer> getTingList() { return tingList; } public void setTingList(List<Integer> tingList) { this.tingList = tingList; } public ZpHuBean(int[] cardArr, int disCardVal, int laiZiNum, boolean isSelfMo) { this.isSelfMo = isSelfMo; this.cardArr = ZpConstant.copyArr(cardArr); this.disCardVal = disCardVal; if (disCardVal > 0) { this.cardArr[disCardVal]++; } this.laiZiNum = laiZiNum; this.huList = new ArrayList<>(); this.maxHuList = new ArrayList<>(); } public ZpHuBean(int[] cardArr, int laiZiNum) { this.isSelfMo = true; this.cardArr = ZpConstant.copyArr(cardArr); this.disCardVal = 0; if (disCardVal > 0) { this.cardArr[disCardVal]++; } this.laiZiNum = laiZiNum; this.huList = new ArrayList<>(); this.maxHuList = new ArrayList<>(); } /** * 拆对 * * @param curLack */ public void chaiDui(ZpHuLack curLack) { if (curLack.getHasPaiNum() == 0) { if (curLack.isNeedDui() && !curLack.isHasDui()) { // 没牌了,需要对,还没有对 return; } curLack.setHu(true); this.huList.add(curLack); return; } else if (curLack.getHasPaiNum() + curLack.getLzNum() == 1) { return; } if (curLack.isNeedDui() && !curLack.isHasDui()) { // 拆对 int[] cardArr = curLack.getCardArr(); for (int val = 1; val <= 20; val++) { if (cardArr[val] == 2) { // 两张作对 ZpHuLack newLack = curLack.clone(); newLack.removeVals(new int[]{val, val}); newLack.setDui(ZpShun.newDui(new int[]{val, val}, 0)); newLack.setNeedDui(false); newLack.setHasDui(true); chaiShun(newLack); } } if (curLack.getLzNum() > 0) { for (int val = 1; val <= 20; val++) { // 单张+癞子补对 if (cardArr[val] == 0 || cardArr[val] == 3) { continue; } ZpHuLack newLack = curLack.clone(); newLack.removeVals(new int[]{val}); ZpShun dui = ZpShun.newDui(new int[]{val, val}, 0); dui.setLzNum(1); dui.setLzVal(new int[]{val}); newLack.setDui(dui); newLack.setNeedDui(false); newLack.addLzNum(-1); newLack.setHasDui(true); newLack.addLzVal(new int[]{val}); chaiShun(newLack); } if (curLack.getLzNum() >= 2) { // 癞子补对 ZpHuLack newLack = curLack.clone(); ZpShun dui = ZpShun.newDui(new int[]{ZpConstant.laiZiVal, ZpConstant.laiZiVal}, 0); dui.setLzVal(new int[]{ZpConstant.laiZiVal, ZpConstant.laiZiVal}); dui.setLzNum(2); newLack.setDui(dui); newLack.setNeedDui(false); newLack.addLzNum(-2); newLack.setHasDui(true); chaiShun(newLack); } } } else { chaiShun(curLack); } } /** * 拆顺 * * @param curLack */ public void chaiShun(ZpHuLack curLack) { if (curLack.getHasPaiNum() + curLack.getLzNum() == 1) { return; } if (curLack.getHasPaiNum() == 0) { curLack.setHu(true); this.huList.add(curLack); return; } //拆顺 int val; boolean hasDisCard = false; if (!isSelfMo && !usedDisCard) { val = disCardVal; hasDisCard = true; usedDisCard = true; } else { val = curLack.getCurVal(); } int[][] paiZus = ZpConstant.getPaiZu(val); int[] rmValArr; int[] lzValArr; ZpHuLack newLack; for (int[] paiZu : paiZus) { newLack = curLack.clone(); int pzLen = paiZu.length - 1; rmValArr = new int[pzLen]; lzValArr = new int[pzLen]; int rmNum = newLack.removeVals(paiZu, rmValArr, lzValArr); if (rmNum == pzLen) { // 不需要使用癞子 ZpShun shun = ZpShun.newShun(rmValArr, paiZu[pzLen]); shun.setHasDisCard(hasDisCard); newLack.addShun(shun); if (pzLen == 4 && !newLack.isHasDui()) { newLack.setNeedDui(true); chaiDui(newLack); } else { chaiShun(newLack); } } else { if (pzLen - rmNum > newLack.getLzNum()) { // 癞子不够 continue; } else if (rmNum == 0) { continue; } else { newLack.addLzNum(rmNum - pzLen); ZpShun shun = ZpShun.newShun(ZpConstant.subArr1(paiZu), paiZu[pzLen]); shun.setLzNum(pzLen - rmNum); shun.setLzVal(lzValArr); shun.setHasDisCard(hasDisCard); newLack.addShun(shun); newLack.addLzVal(lzValArr); if (pzLen == 4 && !newLack.isHasDui()) { newLack.setNeedDui(true); chaiDui(newLack); } else { chaiShun(newLack); } } } } } /** * 计算胡息 */ public void calcHx() { if (isSelfMo) { // 自摸 for (ZpHuLack hu : huList) { if (maxHuList.size() == 0) { maxHuList.add(hu); } else if (hu.getHuXi() == maxHuList.get(0).getHuXi()) { maxHuList.add(hu); } else if (hu.getHuXi() > maxHuList.get(0).getHuXi()) { maxHuList.clear(); maxHuList.add(hu); } } return; } // 非自摸 int deltaHuXi = -3; for (ZpHuLack hu : huList) { ZpShun disCardShun = hu.getDisCardShun(); disCardShun.setHuXi(disCardShun.getHuXi() + deltaHuXi); hu.setHuXi(hu.getHuXi() + deltaHuXi); if (maxHuList.size() == 0) { maxHuList.add(hu); } else if (hu.getHuXi() == maxHuList.get(0).getHuXi()) { maxHuList.add(hu); } else if (hu.getHuXi() > maxHuList.get(0).getHuXi()) { maxHuList.clear(); maxHuList.add(hu); } } } /** * 计算胡 * * @return */ public List<ZpHuLack> calcHu() { // 提 ZpHuLack lack = new ZpHuLack(this.cardArr, this.laiZiNum); for (int i = 1; i < lack.getCardArr().length; i++) { if (lack.getCardArr()[i] == 4) { if (isSelfMo) { lack.getCardArr()[i] = 0; lack.addShun(ZpShun.newTi(new int[]{i, i, i, i}, 0)); lack.setNeedDui(true); } else { if (disCardVal > 0 && disCardVal != i) { lack.getCardArr()[i] = 0; lack.addShun(ZpShun.newTi(new int[]{i, i, i, i}, 0)); lack.setNeedDui(true); } } } } if (!lack.isNeedDui()) { // 防止后期拆到四张牌后,需要补对,先拆对 ZpHuLack clone = lack.clone(); clone.setNeedDui(true); chaiDui(clone); } chaiDui(lack); if (huList.size() > 0) { calcHx(); } return huList; } /** * 计算打牌听牌 * * @return */ public Map<Integer, List<Integer>> calcDaTingMap() { if (daTingMap == null) { daTingMap = new HashMap<>(); } for (int val = 1; val <= 20; val++) { if (cardArr[val] == 0 || cardArr[val] == 3 || cardArr[val] == 4) { continue; } if (val == ZpConstant.laiZiVal) { continue; } int[] newCardArr = ZpConstant.copyArr(cardArr); newCardArr[val] -= 1; List<ZpHuLack> huList = new ZpHuBean(newCardArr, laiZiNum + 1).calcHu(); if (huList.size() > 0) { List<Integer> tingList = new ArrayList<>(); int[] ting = new int[21]; for (ZpHuLack hu : huList) { int[] lzVal = hu.getLzVal(); for (int i = 1; i <= 20; i++) { if (lzVal[i] == 1) { ting[i] = 1; } } } for (int i = 1; i <= 20; i++) { if (ting[i] == 1) { tingList.add(i); } } daTingMap.put(val, tingList); } } return daTingMap; } /** * 计算听牌 * * @return */ public List<Integer> calcTingList() { List<Integer> tingList = new ArrayList<>(); for (int val = 1; val <= 20; val++) { if (cardArr[val] == 0 || cardArr[val] == 3 || cardArr[val] == 4) { continue; } if (val == ZpConstant.laiZiVal) { continue; } List<ZpHuLack> huList = new ZpHuBean(cardArr, laiZiNum + 1).calcHu(); if (huList.size() > 0) { int[] ting = new int[21]; for (ZpHuLack hu : huList) { int[] lzVal = hu.getLzVal(); for (int i = 1; i <= 20; i++) { if (lzVal[i] == 1) { ting[i] = 1; } } } for (int i = 1; i <= 20; i++) { if (ting[i] == 1) { tingList.add(i); } } } } return tingList; } }
112f0d0032ed31890a9d8cb316797d2982695c3c
fd95bb7d84add8a9c6116f76676d4f3ab03e085f
/library/src/main/java/com/twiceyuan/autoform/FormItemEntity.java
88bbd48fb52ddb0100c18856c99a685c6719ae27
[ "Apache-2.0" ]
permissive
ylc88/AutoForm
09c5d4cda6abbcd2ca494b322e61c079021027e5
3776378baf2566ca585b128fea5cd87f02e187b2
refs/heads/master
2021-10-20T06:27:53.022763
2019-02-26T06:29:14
2019-02-26T06:29:14
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,043
java
package com.twiceyuan.autoform; import com.twiceyuan.autoform.provider.LayoutProvider; import com.twiceyuan.autoform.provider.Validator; /** * Created by twiceYuan on 2017/7/2. * <p> * 表单字段实体 */ public class FormItemEntity { /** * 字段名称 */ public String label; /** * 排序,因为反射取到的变量集合是乱序的 */ public float order; /** * 表单生成的 Key 值 */ public String key; /** * 映射的属性名称,注意:如果是动态字段讲不会反射到实体类上,必须使用 Map 获取,因为实体中无法动态创建属性 */ public String fieldName; /** * 表单样式 */ public LayoutProvider layout; /** * 合法校验器 */ public Validator validator; /** * 提示 */ public String hint; /** * 最终用户的输入,进行数据绑定时设置观察用户输入 */ @SuppressWarnings("WeakerAccess") public Object result; }
c8ec6b3fb43d6b9d3170e1b9778b9d817b972324
c9556f9d06c57709111f77a7da8fef1d104f3e23
/app/src/main/java/com/cyris/createphoto/CheckConnection.java
451b875f88d23538c711c8eb1cd040ac9b340a8e
[]
no_license
Mr-Ajay-Singh/Meme-Photo-Editor
e2ec9e517522e79d2de4fd01a02b711391a081ed
b136e92faa4e7b1880301b843edba11340d5d5c3
refs/heads/master
2023-07-30T02:45:09.814815
2021-09-17T11:59:39
2021-09-17T11:59:39
407,405,352
2
0
null
null
null
null
UTF-8
Java
false
false
736
java
package com.cyris.createphoto; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class CheckConnection { public static boolean checkInternet(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); if(connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED || connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED) { //we are connected to a network return true; } else return false; } }
3cb8b0f772c3189a256b7a440a47818295c0d1da
0d2079efaeb5d41d6c99c45ab350eb4a501936c1
/src/main/java/mchorse/mclib/utils/PayloadASM.java
de531358d2886f4de79f4cee071f32dcf39f5c55
[ "MIT" ]
permissive
srgantmoomoo/mclib-rpc
0b302986a1e02f83ba6edc9cbfc74aee514c332e
55f4a9e0f2c2621acc49736ef3d77a7d89e5711d
refs/heads/master
2023-02-13T20:05:10.888590
2021-01-10T23:16:29
2021-01-10T23:16:29
null
0
0
null
null
null
null
UTF-8
Java
false
false
340
java
package mchorse.mclib.utils; import mchorse.mclib.McLib; public class PayloadASM { public static final int MIN_SIZE = 32767; /** * ASM hook which is used in {@link mchorse.mclib.core.transformers.CPacketCustomPayloadTransformer} */ public static int getPayloadSize() { return Math.max(MIN_SIZE, McLib.maxPacketSize.get()); } }
[ "" ]
129cd4c851da8fba2518fed9159f0d6190eb3ab6
2e02f5f83b899f2112c3808fc58721e7650346d1
/app/src/main/java/msmartpay/in/myWallet/WalletHistoryActivity.java
30331c48df5401a20bf45237ee37154a816cb10c
[]
no_license
ui-templete/msmartpay-android-agent
2f876f3c1169fe4f3ec577e64bf1ab55f708c3a0
f9233f3d2a7d57f856b7f51e6f3f9d5ee74eb0d7
refs/heads/master
2022-12-24T03:04:13.571912
2020-10-06T07:20:34
2020-10-06T07:20:34
null
0
0
null
null
null
null
UTF-8
Java
false
false
19,048
java
package msmartpay.in.myWallet; import android.app.DatePickerDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.DatePicker; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import com.android.volley.Request; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import org.json.JSONArray; import org.json.JSONObject; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Locale; import msmartpay.in.MainActivity; import msmartpay.in.R; import msmartpay.in.utility.BaseActivity; import msmartpay.in.utility.HttpURL; import msmartpay.in.utility.L; import msmartpay.in.utility.Mysingleton; public class WalletHistoryActivity extends BaseActivity { private ProgressDialog pd; private ArrayList<TransactionItems> tranList = new ArrayList<TransactionItems>(); private ListView transactionList; private String agent_id = "", txn_key = ""; private String wallet_history_url = HttpURL.STATEMENT_TRAIN; private String TranHistoryByDate= HttpURL.TranHistoryByDate; private SharedPreferences sharedPreferences; private String agentID, url; private Context context; private TextView tv_to,tv_from,tv_all,tv_in,tv_out; private LinearLayout ll_search; private StatementAdapter adapter; private DatePickerDialog fromDatePickerDialog; private SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US); private int i=0; private String toDate="",fromDate=""; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.wallet_history_activity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); setTitle("Wallet History"); overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); tv_to = findViewById(R.id.tv_to); tv_from = findViewById(R.id.tv_from); ll_search = findViewById(R.id.ll_search); tv_all = findViewById(R.id.tv_all); tv_in = findViewById(R.id.tv_in); tv_out = findViewById(R.id.tv_out); context = WalletHistoryActivity.this; sharedPreferences = getSharedPreferences("myPrefs", MODE_PRIVATE); agentID = sharedPreferences.getString("agentonlyid", null); agent_id = sharedPreferences.getString("agent_id", null); txn_key = sharedPreferences.getString("txn-key", null); txn_key = txn_key.replaceAll("~", "/"); transactionList = (ListView) findViewById(R.id.transactionList); walletHistoryRequest(); tv_to.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { i=1; setDateTimeField(tv_to); } }); tv_from.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { i=0; setDateTimeField(tv_from); } }); ll_search.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(fromDate.equalsIgnoreCase("")){ Toast.makeText(WalletHistoryActivity.this,"Select From Date", Toast.LENGTH_LONG).show(); }else if(toDate.equalsIgnoreCase("")){ Toast.makeText(WalletHistoryActivity.this,"Select From Date", Toast.LENGTH_LONG).show(); }else { ll_search.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark)); walletHistoryRequestByDate(); } } }); tv_all.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { adapter.getFilter().filter(""); tv_all.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark)); tv_in.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); tv_out.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); } }); tv_in.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { adapter.getFilter().filter("In"); tv_all.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); tv_in.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark)); tv_out.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); } }); tv_out.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { adapter.getFilter().filter("Out"); tv_all.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); tv_in.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); tv_out.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark)); } }); } private void walletHistoryRequest() { try { pd = ProgressDialog.show(context, "", "Loading. Please wait...", true); pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pd.setCancelable(false); pd.show(); JSONObject jsonObjectReq = new JSONObject() .put("agent_id", agentID) .put("txn_key", txn_key) .put("id_no", "0"); L.m2("url-quick", wallet_history_url); L.m2("Request--quick", jsonObjectReq.toString()); JsonObjectRequest objectRequest = new JsonObjectRequest(Request.Method.POST, wallet_history_url, jsonObjectReq, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject data) { pd.dismiss(); L.m2("Resp--tranHistory", data.toString()); try { if (data.get("response-code") != null && data.get("response-code").equals("0")) { if (data.get("Statement") == null) { Toast.makeText(context, "No Transaction Available! ", Toast.LENGTH_LONG).show(); startActivity(new Intent(context, MainActivity.class)); finish(); } else { final JSONArray parentArray = (JSONArray) data.get("Statement"); if (parentArray.length() > 0) { for (int i = 0; i < parentArray.length(); i++) { final JSONObject obj = (JSONObject) parentArray.get(i); TransactionItems item = new TransactionItems( obj.getString("Id_No") + "", obj.getString("tran_id") + "", obj.getString("mobile_operator") + "", obj.getString("mobile_number") + "", obj.getString("service") + "", obj.getString("Action_on_bal_amt") + "", obj.getString("tran_status") + "", obj.getString("net_amout") + "", obj.getString("DeductedAmt") + "", obj.getString("dot") + "", obj.getString("tot") + "", obj.getString("Agent_balAmt_b_Ded") + "", obj.getString("Agent_F_balAmt") + ""); tranList.add(item); } adapter=new StatementAdapter(context, tranList); transactionList.setAdapter(adapter); } else { Toast.makeText(context, "No Transaction Available! ", Toast.LENGTH_LONG).show(); startActivity(new Intent(context, MainActivity.class)); finish(); } } } else if (data.get("response-code") != null && data.get("response-code").equals("1") /*&& data.get("response-code").equals("2")*/) { Toast.makeText(context, (String) data.get("response-message"), Toast.LENGTH_SHORT).show(); startActivity(new Intent(context, MainActivity.class)); finish(); } else if (data.get("response-code") != null && data.get("response-code").equals("2")) { Toast.makeText(context, (String) data.get("response-message"), Toast.LENGTH_SHORT).show(); startActivity(new Intent(context, MainActivity.class)); finish(); } else { context = getApplicationContext(); Toast.makeText(context, "This is a server error", Toast.LENGTH_LONG).show(); startActivity(new Intent(context, MainActivity.class)); finish(); } } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { pd.dismiss(); Toast.makeText(context, error.toString(), Toast.LENGTH_LONG); } }); getSocketTimeOut(objectRequest); Mysingleton.getInstance(context).addToRequsetque(objectRequest); } catch (Exception e) { e.printStackTrace(); } } private void walletHistoryRequestByDate() { try { pd = new ProgressDialog(context); pd = ProgressDialog.show(context, "", "Loading. Please wait...", true); pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pd.setCancelable(false); JSONObject request=new JSONObject() .put("agent_id", agentID) .put("txn_key", txn_key) .put("fromDate", fromDate) .put("toDate", toDate); L.m2("called url", TranHistoryByDate); L.m2("Request--quick", request.toString()); JsonObjectRequest objectRequest = new JsonObjectRequest(Request.Method.POST, TranHistoryByDate, request, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject data) { pd.dismiss(); L.m2("Resp--tranHistory", data.toString()); try { if (data.get("response-code") != null && data.get("response-code").equals("0")) { if (data.get("Statement") == null) { Toast.makeText(context, "No Transaction Available! ", Toast.LENGTH_LONG).show(); startActivity(new Intent(context, MainActivity.class)); finish(); } else { final JSONArray parentArray = (JSONArray) data.get("Statement"); if (parentArray.length() > 0) { for (int i = 0; i < parentArray.length(); i++) { final JSONObject obj = (JSONObject) parentArray.get(i); TransactionItems item = new TransactionItems( obj.getString("Id_No") + "", obj.getString("tran_id") + "", obj.getString("mobile_operator") + "", obj.getString("mobile_number") + "", obj.getString("service") + "", obj.getString("Action_on_bal_amt") + "", obj.getString("tran_status") + "", obj.getString("net_amout") + "", obj.getString("DeductedAmt") + "", obj.getString("dot") + "", obj.getString("tot") + "", obj.getString("Agent_balAmt_b_Ded") + "", obj.getString("Agent_F_balAmt") + ""); tranList.add(item); } adapter=new StatementAdapter(context, tranList); transactionList.setAdapter(adapter); } else { Toast.makeText(context, "No Transaction Available! ", Toast.LENGTH_LONG).show(); startActivity(new Intent(context, MainActivity.class)); finish(); } } } else if (data.get("response-code") != null && data.get("response-code").equals("1") /*&& data.get("response-code").equals("2")*/) { Toast.makeText(context, (String) data.get("response-message"), Toast.LENGTH_SHORT).show(); startActivity(new Intent(context, MainActivity.class)); finish(); } else if (data.get("response-code") != null && data.get("response-code").equals("2")) { Toast.makeText(context, (String) data.get("response-message"), Toast.LENGTH_SHORT).show(); startActivity(new Intent(context, MainActivity.class)); finish(); } else { context = getApplicationContext(); Toast.makeText(context, "This is a server error", Toast.LENGTH_LONG).show(); startActivity(new Intent(context, MainActivity.class)); finish(); } } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { pd.dismiss(); Toast.makeText(context, error.toString(), Toast.LENGTH_LONG); } }); getSocketTimeOut(objectRequest); Mysingleton.getInstance(context).addToRequsetque(objectRequest); } catch (Exception e) { e.printStackTrace(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.wallet_history_refresh, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.id_refresh) { finish(); Intent i = new Intent(context, WalletHistoryActivity.class); //your class startActivity(i); } return super.onOptionsItemSelected(item); } @Override public boolean onSupportNavigateUp() { onBackPressed(); return true; } private void setDateTimeField(final TextView myview) { Calendar newCalendar = Calendar.getInstance(); fromDatePickerDialog = new DatePickerDialog(WalletHistoryActivity.this, new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Calendar newDate = Calendar.getInstance(); newDate.set(year, monthOfYear, dayOfMonth); if(i==0) { fromDate=dateFormatter.format(newDate.getTime()); myview.setText("From \n" +fromDate); } else { toDate=dateFormatter.format(newDate.getTime()); myview.setText("To \n" + toDate); } } }, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH)); fromDatePickerDialog.show(); } }
59bad5934278fd729c589e87a38de033e621b4e9
a1b9c80402f033b5eee597444da8dc8ee74a5ea7
/src/Decorator/Decorator.java
b4350ee2f6643751ea7331ac28346cbf504a5bc8
[]
no_license
IlyaBorisov75/Patterns
21a77b3a237860fca785a0f77aeccc4b6ccb0142
86fa84c76c898e1a74304480559a889367f1e939
refs/heads/master
2020-04-18T14:22:11.904900
2019-01-25T17:38:10
2019-01-25T17:38:10
167,586,575
0
0
null
null
null
null
UTF-8
Java
false
false
160
java
package Decorator; public abstract class Decorator implements Text{ Text component; public Decorator (Text component) { this.component = component; } }
724e853667e892acc9c3c1eaa45ff0ecb038fe09
af1e1d7bc9601b309d2c54750851ab94ba1cd0a7
/app/src/test/java/com/studio/emacs/emacsmusicplayer/ExampleUnitTest.java
908d15a17cd4416cb580836c1865340dffdc7392
[]
no_license
ganesh-bhat/android-material-music-player
d882a7130f77f782b861df93c2121a44913f1099
345b4a02b620dea11fd71200e74cca8193a83942
refs/heads/master
2021-07-11T02:29:42.762601
2021-04-21T13:47:57
2021-04-21T13:47:57
100,839,845
2
0
null
null
null
null
UTF-8
Java
false
false
427
java
package com.studio.emacs.emacsmusicplayer; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ public class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } }