blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
410
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
51
license_type
stringclasses
2 values
repo_name
stringlengths
5
132
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
80
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
131 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
9.45M
extension
stringclasses
32 values
content
stringlengths
3
9.45M
authors
sequencelengths
1
1
author_id
stringlengths
0
313
857efa2aa8e9c8a1e3a08106ef0bbfc4be225c66
856cddfcf6a85953e6ece70058416bb542531506
/Module_ADS/Recurssion/SeriesSumRecursion.java
a0de9341d8ab262d0d6e540103b5766c6915ac88
[]
no_license
ShrikantSonawane-KH/EDAC-May2021
b96c6784aa2f8f8a5a6006186d54803974069b8a
3e60348f46d6705ba10d236226a12e7a96877d1c
refs/heads/main
2023-06-14T18:42:24.955094
2021-07-06T15:24:44
2021-07-06T15:24:44
365,253,081
1
0
null
null
null
null
UTF-8
Java
false
false
483
java
/* 2.Sum a series of numbers with Java recursion */ class Recursion { static int i = 0; static int sum=0; static int method(int n) { if (i<=n) { sum = sum + i; i++; System.out.println("i "+ i); System.out.println("sum "+ sum); method(n); } return sum; } } class SeriesSumRecursion { public static void main(String[] agrs) { System.out.print(Recursion.method(5)); } }
ade8cb9c2370f05fba0817ab66eac0fe6ee6db40
764c94d4cf116b0e4d98a38e842e4e6a0468a666
/ebaysdkcore/src/main/java/com/ebay/soap/eBLBaseComponents/DomesticReturnsDurationCodeType.java
4fcb482f052c948faf65e3a86ec7a928c97c8c66
[]
no_license
linus87/ebaysdk
26dde361dbb75e03fca137eaf6a61c5e892f1303
2fb2cbade57ae654fa83ae1b7c5f3e4f741b1fc1
refs/heads/master
2023-07-19T10:34:02.644641
2021-06-01T13:30:36
2021-06-01T13:30:36
150,661,586
1
0
null
2023-07-18T06:53:34
2018-09-28T00:06:01
Java
UTF-8
Java
false
false
5,465
java
package com.ebay.soap.eBLBaseComponents; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyElement; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; import org.w3c.dom.Element; /** * * This type defines the available options for the return durations for domestic returns. * * * <p>Java class for DomesticReturnsDurationCodeType complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="DomesticReturnsDurationCodeType"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="DomesticReturnsDuration" type="{urn:ebay:apis:eBLBaseComponents}ReturnsDurationCodeType" maxOccurs="unbounded" minOccurs="0"/> * &lt;any/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * * Note: Per JAXB standards, underscores are added to separate words in enumerations (e.g., PayPal becomes PAY_PAL). */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "DomesticReturnsDurationCodeType", propOrder = { "domesticReturnsDuration", "any" }) public class DomesticReturnsDurationCodeType implements Serializable { private final static long serialVersionUID = 12343L; @XmlElement(name = "DomesticReturnsDuration") protected List<ReturnsDurationCodeType> domesticReturnsDuration; @XmlAnyElement(lax = true) protected List<Object> any; /** * * * @return * array of * {@link ReturnsDurationCodeType } * */ public ReturnsDurationCodeType[] getDomesticReturnsDuration() { if (this.domesticReturnsDuration == null) { return new ReturnsDurationCodeType[ 0 ] ; } return ((ReturnsDurationCodeType[]) this.domesticReturnsDuration.toArray(new ReturnsDurationCodeType[this.domesticReturnsDuration.size()] )); } /** * * * @return * one of * {@link ReturnsDurationCodeType } * */ public ReturnsDurationCodeType getDomesticReturnsDuration(int idx) { if (this.domesticReturnsDuration == null) { throw new IndexOutOfBoundsException(); } return this.domesticReturnsDuration.get(idx); } public int getDomesticReturnsDurationLength() { if (this.domesticReturnsDuration == null) { return 0; } return this.domesticReturnsDuration.size(); } /** * * * @param values * allowed objects are * {@link ReturnsDurationCodeType } * */ public void setDomesticReturnsDuration(ReturnsDurationCodeType[] values) { this._getDomesticReturnsDuration().clear(); int len = values.length; for (int i = 0; (i<len); i ++) { this.domesticReturnsDuration.add(values[i]); } } protected List<ReturnsDurationCodeType> _getDomesticReturnsDuration() { if (domesticReturnsDuration == null) { domesticReturnsDuration = new ArrayList<ReturnsDurationCodeType>(); } return domesticReturnsDuration; } /** * * * @param value * allowed object is * {@link ReturnsDurationCodeType } * */ public ReturnsDurationCodeType setDomesticReturnsDuration(int idx, ReturnsDurationCodeType value) { return this.domesticReturnsDuration.set(idx, value); } /** * * * @return * array of * {@link Object } * {@link Element } * */ public Object[] getAny() { if (this.any == null) { return new Object[ 0 ] ; } return ((Object[]) this.any.toArray(new Object[this.any.size()] )); } /** * * * @return * one of * {@link Object } * {@link Element } * */ public Object getAny(int idx) { if (this.any == null) { throw new IndexOutOfBoundsException(); } return this.any.get(idx); } public int getAnyLength() { if (this.any == null) { return 0; } return this.any.size(); } /** * * * @param values * allowed objects are * {@link Object } * {@link Element } * */ public void setAny(Object[] values) { this._getAny().clear(); int len = values.length; for (int i = 0; (i<len); i ++) { this.any.add(values[i]); } } protected List<Object> _getAny() { if (any == null) { any = new ArrayList<Object>(); } return any; } /** * * * @param value * allowed object is * {@link Object } * {@link Element } * */ public Object setAny(int idx, Object value) { return this.any.set(idx, value); } }
c796d0a577b1b476c62ba627fca08388c12a0b93
1089c9a6caef74e7e4ba2001868aad9009609698
/pet-clinic-data/src/main/java/com/springframework/cfgpetclinic/services/map/VisitMapService.java
d2e665f52aa1ab3b47da3cfc8eb71db3b0d69737
[]
no_license
Nihrom77/sfg-pet-clinic
b38050ba07f0731c11576aea25d5bdf1fbbe743f
40f82f1d21ac863c8b9c0df72d79ae0e4283e4d5
refs/heads/master
2020-12-12T15:38:14.864975
2020-10-27T19:23:13
2020-10-27T19:23:13
234,163,462
0
0
null
null
null
null
UTF-8
Java
false
false
1,121
java
package com.springframework.cfgpetclinic.services.map; import com.springframework.cfgpetclinic.model.Visit; import com.springframework.cfgpetclinic.services.VisitService; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; import java.util.Set; @Service @Profile({"default", "map"}) public class VisitMapService extends AbsctractMapService<Visit, Long> implements VisitService { @Override public Set<Visit> findAll() { return super.findAll(); } @Override public void deleteById(Long id) { super.deleteById(id); } @Override public Visit save(Visit visit) { if (visit.getPet() == null || visit.getPet().getOwner() == null || visit.getPet().getId() == null || visit.getPet().getOwner().getId() == null) { throw new RuntimeException("Invalid visit"); } return super.save(visit); } @Override public void delete(Visit object) { super.delete(object); } @Override public Visit findById(Long id) { return super.findById(id); } }
b955e66dd506297bcc74191667dfb40b33f8845e
ea673caf5bcd60871ee317547c7f1047282b462a
/mdmp-api-client/src/main/java/com/mdmp/client/ClientFactory.java
e3ec17c9bdbee04e69b8cf0fe0a926285ae1f615
[]
no_license
mac-zhenfang/mdmp-api-client
b10dd04d56b4f002347a9a6c0f1bd4a1f0feecdd
9801fdea7dd078bbd85a5282f9948041243d066c
refs/heads/master
2021-01-19T00:46:47.384262
2013-05-02T15:58:57
2013-05-02T15:58:57
null
0
0
null
null
null
null
UTF-8
Java
false
false
589
java
package com.mdmp.client; import com.mdmp.client.app.AppClient; import com.mdmp.client.report.ReportClient; import com.mdmp.client.util.Context; public class ClientFactory { static Context context = new Context(); static ReportClient reportClient = null; static AppClient appClient = null; public static ReportClient getReportClient() { if (null == reportClient) { reportClient = new ReportClient(context); } return reportClient; } public static AppClient getAppClient() { if (null == appClient) { appClient = new AppClient(context); } return appClient; } }
84ccc7184e250d20ffa3e677db67b9aeddd84527
8e7adb7cf838062e25da02d44fe48c45fba8834f
/Module 1/a36/T02.06-Exercise-AddPolish/app/src/main/java/com/example/android/datafrominternet/MainActivity.java
07db679bb060ede1c4805301be7a68784c80a205
[]
no_license
pranay0124/Mobile-Programming
35d94b28a05802e31b89bbb6b49b7e8c88e32639
ae9165c5d6cc361969d3a65f9e07a7a64b35034c
refs/heads/master
2020-04-28T03:30:18.751134
2019-03-24T19:11:39
2019-03-24T19:11:39
174,940,325
0
0
null
null
null
null
UTF-8
Java
false
false
5,296
java
/* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.android.datafrominternet; import android.os.AsyncTask; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.EditText; import android.widget.ProgressBar; import android.widget.TextView; import com.example.android.datafrominternet.utilities.NetworkUtils; import java.io.IOException; import java.net.URL; public class MainActivity extends AppCompatActivity { private EditText mSearchBoxEditText; private TextView mUrlDisplayTextView; private TextView mSearchResultsTextView; // TODO (12) Create a variable to store a reference to the error message TextView TextView errorMessageTextView; TextView mErrorMessageDisplay; // TODO (24) Create a ProgressBar variable to store a reference to the ProgressBar ProgressBar mLoadingIndicator; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSearchBoxEditText = (EditText) findViewById(R.id.et_search_box); mUrlDisplayTextView = (TextView) findViewById(R.id.tv_url_display); mSearchResultsTextView = (TextView) findViewById(R.id.tv_github_search_results_json); // TODO (13) Get a reference to the error TextView using findViewById errorMessageTextView = (TextView) findViewById(R.id.tv_error_message_display); // TODO (25) Get a reference to the ProgressBar using findViewById mLoadingIndicator = (ProgressBar) findViewById(R.id.pb_loading_indicator); } /** * This method retrieves the search text from the EditText, constructs the * URL (using {@link NetworkUtils}) for the github repository you'd like to find, displays * that URL in a TextView, and finally fires off an AsyncTask to perform the GET request using * our {@link GithubQueryTask} */ private void makeGithubSearchQuery() { String githubQuery = mSearchBoxEditText.getText().toString(); URL githubSearchUrl = NetworkUtils.buildUrl(githubQuery); mUrlDisplayTextView.setText(githubSearchUrl.toString()); new GithubQueryTask().execute(githubSearchUrl); } // TODO (14) Create a method called showJsonDataView to show the data and hide the error private void showJsonDataView() { mErrorMessageDisplay.setVisibility(View.INVISIBLE); mSearchResultsTextView.setVisibility(View.VISIBLE); } // TODO (15) Create a method called showErrorMessage to show the error and hide the data private void showErrorMessage() { mSearchResultsTextView.setVisibility(View.INVISIBLE); mErrorMessageDisplay.setVisibility(View.VISIBLE); } public class GithubQueryTask extends AsyncTask<URL, Void, String> { // TODO (26) Override onPreExecute to set the loading indicator to visible @Override protected void onPreExecute() { super.onPreExecute(); mLoadingIndicator.setVisibility(View.VISIBLE); } @Override protected String doInBackground(URL... params) { URL searchUrl = params[0]; String githubSearchResults = null; try { githubSearchResults = NetworkUtils.getResponseFromHttpUrl(searchUrl); } catch (IOException e) { e.printStackTrace(); } return githubSearchResults; } @Override protected void onPostExecute(String githubSearchResults) { // TODO (27) As soon as the loading is complete, hide the loading indicator mLoadingIndicator.setVisibility(View.INVISIBLE); if (githubSearchResults != null && !githubSearchResults.equals("")) { // TODO (17) Call showJsonDataView if we have valid, non-null results showJsonDataView(); mSearchResultsTextView.setText(githubSearchResults); } else { // TODO (16) Call showErrorMessage if the result is null in onPostExecute showErrorMessage(); } } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int itemThatWasClickedId = item.getItemId(); if (itemThatWasClickedId == R.id.action_search) { makeGithubSearchQuery(); return true; } return super.onOptionsItemSelected(item); } }
c046f0fdf5ab6f17b96f244bc5d08551a06387b3
66b3a9db808f3e4f72eb45eac245538fb92a32b8
/src/net/minecraft/client/gui/inventory/GuiInventory.java
29dec79bcab70cbfeef6104c132bbe44204780e3
[ "MIT" ]
permissive
Tominous/CoseClient
3d8865956003437154e46698df9fcb0ed5da5c44
4ef084c0ac79626f794bcac8affd103cc632ea77
refs/heads/master
2020-05-24T21:38:00.760926
2017-02-25T13:03:42
2017-02-25T13:03:42
187,479,605
1
0
null
2019-05-19T13:22:37
2019-05-19T13:22:37
null
UTF-8
Java
false
false
5,778
java
package net.minecraft.client.gui.inventory; import java.io.IOException; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.achievement.GuiAchievements; import net.minecraft.client.gui.achievement.GuiStats; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.InventoryEffectRenderer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.resources.I18n; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; public class GuiInventory extends InventoryEffectRenderer { /** The old x position of the mouse pointer */ private float oldMouseX; /** The old y position of the mouse pointer */ private float oldMouseY; private static final String __OBFID = "CL_00000761"; public GuiInventory(EntityPlayer p_i1094_1_) { super(p_i1094_1_.inventoryContainer); this.allowUserInput = true; } /** * Called from the main game loop to update the screen. */ public void updateScreen() { if (this.mc.playerController.isInCreativeMode()) { this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer)); } this.func_175378_g(); } /** * Adds the buttons (and other controls) to the screen in question. */ public void initGui() { this.buttonList.clear(); if (this.mc.playerController.isInCreativeMode()) { this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer)); } else { super.initGui(); } } /** * Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY */ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 86, 16, 4210752); } /** * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks */ public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); this.oldMouseX = (float)mouseX; this.oldMouseY = (float)mouseY; } /** * Args : renderPartialTicks, mouseX, mouseY */ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(inventoryBackground); int var4 = this.guiLeft; int var5 = this.guiTop; this.drawTexturedModalRect(var4, var5, 0, 0, this.xSize, this.ySize); drawEntityOnScreen(var4 + 51, var5 + 75, 30, (float)(var4 + 51) - this.oldMouseX, (float)(var5 + 75 - 50) - this.oldMouseY, this.mc.thePlayer); } /** * Draws the entity to the screen. Args: xPos, yPos, scale, mouseX, mouseY, entityLiving */ public static void drawEntityOnScreen(int x, int y, int scale, float mouseX, float mouseY, EntityLivingBase entity) { GlStateManager.enableColorMaterial(); GlStateManager.pushMatrix(); GlStateManager.translate((float)x, (float)y, 50.0F); GlStateManager.scale((float)(-scale), (float)scale, (float)scale); GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); float var6 = entity.renderYawOffset; float var7 = entity.rotationYaw; float var8 = entity.rotationPitch; float var9 = entity.prevRotationYawHead; float var10 = entity.rotationYawHead; GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(-((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); entity.renderYawOffset = (float)Math.atan((double)(mouseX / 40.0F)) * 20.0F; entity.rotationYaw = (float)Math.atan((double)(mouseX / 40.0F)) * 40.0F; entity.rotationPitch = -((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F; entity.rotationYawHead = entity.rotationYaw; entity.prevRotationYawHead = entity.rotationYaw; GlStateManager.translate(0.0F, 0.0F, 0.0F); RenderManager var11 = Minecraft.getMinecraft().getRenderManager(); var11.func_178631_a(180.0F); var11.func_178633_a(false); var11.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); var11.func_178633_a(true); entity.renderYawOffset = var6; entity.rotationYaw = var7; entity.rotationPitch = var8; entity.prevRotationYawHead = var9; entity.rotationYawHead = var10; GlStateManager.popMatrix(); RenderHelper.disableStandardItemLighting(); GlStateManager.disableRescaleNormal(); GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.func_179090_x(); GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); } protected void actionPerformed(GuiButton button) throws IOException { if (button.id == 0) { this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter())); } if (button.id == 1) { this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter())); } } }
e4c53fec7da4b08a4e1f586c9156adb01850174f
89340712af11bc23e74869c2fed315bc186e70ea
/main/java/fingersome/enchantedmod/EnchantedMod.java
e97595948d43db2e76a601e1181c276e0803e672
[]
no_license
fingersome/Enchanted
358f7bfc30692c99ed6592ddb3d155602426d3ce
fe4bb85c3f110edba268c5a2084fe00b97dfaf34
refs/heads/master
2021-01-23T14:13:08.402040
2017-06-03T15:50:56
2017-06-03T15:50:56
93,246,599
0
0
null
null
null
null
UTF-8
Java
false
false
2,542
java
package fingersome.enchantedmod; import fingersome.enchantedmod.block.BlockList; import fingersome.enchantedmod.config.ConfigManager; import fingersome.enchantedmod.event.EventManager; import fingersome.enchantedmod.item.ItemList; import fingersome.enchantedmod.proxy.CommonProxy; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @Mod(modid = ModInfo.MODID, version = ModInfo.VERSION) public class EnchantedMod { @SidedProxy(clientSide = "fingersome.enchantedmod.proxy.ClientProxy", serverSide = "fingersome.enchantedmod.proxy.ServerProxy") public static CommonProxy proxy; public static ItemList items; public static BlockList blocks; @Instance(ModInfo.MODID) public static EnchantedMod instance; public static CreativeTabs tab = new CreativeTabs("enchantedmod") { @Override public String getTabLabel() { return "enchantedmod"; } @Override @SideOnly(Side.CLIENT) public ItemStack getTabIconItem() { return new ItemStack(ItemList.itemTome,1); } }; @EventHandler public void preinit(FMLPreInitializationEvent event) { // DEBUG System.out.println("preInit()" + event.getModMetadata().name); MinecraftForge.EVENT_BUS.register(new ConfigManager()); MinecraftForge.EVENT_BUS.register(new EventManager()); ConfigManager.init(event.getSuggestedConfigurationFile()); items.init(); blocks.init(); proxy.preInit(event); } @EventHandler public void init(FMLInitializationEvent event) { // DEBUG System.out.println("init()"); proxy.init(event); } @EventHandler public void postinit(FMLPostInitializationEvent event) { // DEBUG System.out.println("postInit()"); proxy.postInit(event); } @EventHandler public void serverLoad(FMLServerStartingEvent event) { } }
df8599387a9be30f468d4936dbc39df6b0959b7e
42e3cafb2bfe663b6d4024201e2a94161f7daa3d
/app/src/androidTest/java/com/mdground/guest/ApplicationTest.java
f433a1d9f078d59a76abde8fdd985c2d6718bbf5
[]
no_license
Bread-Yang/BaoGuest
b14865bf483f118a14a830243219bd3d3196a4d7
7e745aa44432ca5ad1cb34e71686c903faee1045
refs/heads/master
2021-01-21T14:08:11.304066
2016-06-29T09:25:15
2016-06-29T09:25:15
56,758,257
0
0
null
null
null
null
UTF-8
Java
false
false
349
java
package com.mdground.guest; import android.app.Application; import android.test.ApplicationTestCase; /** * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> */ public class ApplicationTest extends ApplicationTestCase<Application> { public ApplicationTest() { super(Application.class); } }
1c5d3fb1254e537a3bf5a312157ed6d178fe7a7f
be23c73f1b87dc63185a9adf2b805d475845f4b1
/app/src/androidTest/java/com/giridhari/pa_android/ExampleInstrumentedTest.java
0185a7570208928f2569ef1bf9c457943707df00
[]
no_license
hariksetra/pa-android
4004f5eb429ed23802c17a30c432dccf560fd2f4
635bca7c2126632ffe3ff10fbf9f289ff1b92f21
refs/heads/master
2020-03-24T02:58:14.018591
2018-07-27T19:00:19
2018-07-27T19:00:19
142,398,537
0
0
null
null
null
null
UTF-8
Java
false
false
732
java
package com.giridhari.pa_android; 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() { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); assertEquals("com.giridhari.pa_android", appContext.getPackageName()); } }
98cfb7ee8d196deadb91fcbf8729adcf1acdbbbd
b99aa38cdc6780e5a658fbeb10f8d0f8715af627
/CollectionExamples/src/com/training/ifaces/IDonor.java
94bfcd2db9519cfba81f179fb45728000c18e25e
[]
no_license
derekhub/IndiaTrainingProgramProjects
375d2beaa24aeaf9cecedc73f25c7f06a947908a
e55ccf476b81b702631b6b8c958dba536d41d103
refs/heads/master
2020-09-24T21:02:22.668828
2016-09-16T10:55:06
2016-09-16T10:55:06
66,453,530
0
0
null
null
null
null
UTF-8
Java
false
false
284
java
package com.training.ifaces; import java.util.List; import com.training.domains.Donor; public interface IDonor { public boolean addDonor(Donor obj); public boolean addDonors(Donor...dnrList); public void printDonorList(); public List<Donor> getDonorList(); }
b48365699734b0a5b404881b27560b98e8bcbb3f
463f5f961ace83a59fb0df36b197302ccacfdbc0
/multitenancy/tenant-manager-client/src/main/java/io/apicurio/multitenant/client/exception/RegistryTenantForbiddenException.java
09a8e712634dd1291ed0481d5869de398072707e
[ "Apache-2.0" ]
permissive
EricWittmann/apicurio-registry
ab84c4ef9751bddb437255d9ae0a10594e12ecba
77885c115dc8ff29ca2b3eef94a045c06b246b68
refs/heads/main
2023-09-04T04:11:12.803162
2022-09-15T19:35:33
2022-09-15T19:35:33
202,395,236
0
1
Apache-2.0
2022-08-04T09:20:19
2019-08-14T17:21:03
Java
UTF-8
Java
false
false
944
java
/* * Copyright 2022 Red Hat * * 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 io.apicurio.multitenant.client.exception; import io.apicurio.rest.client.error.ApicurioRestClientException; public class RegistryTenantForbiddenException extends ApicurioRestClientException { private static final long serialVersionUID = 1L; public RegistryTenantForbiddenException(String message) { super(message); } }
360d49280ff39633f1156c9e4ead3db83ed5c85d
0dc67c2e497446f93d758d52bb77cfbfe34611f6
/Main.java
3f3e70a2e36e6f29dfb5bd8200d4794ab4a31718
[]
no_license
mamadzz/Main
89b95a9877364f6d363e0ae6819bd449f4595266
3cc7b667ee6be212058a00b8db80519e39c2b41d
refs/heads/master
2021-05-26T19:32:57.980755
2014-04-09T16:02:50
2014-04-09T16:02:50
null
0
0
null
null
null
null
UTF-8
Java
false
false
227
java
public class Main{ public static void main(String[] args){ public static void main(String[] args){ Calc c= new Calc(); System.out.print("version 0"); System.out.println("Multiplication :"+c.somme(3,5)); } }
7db9621b78583a63df04799475d1928228cf343a
975484ef89432415cc37207fa25028d6d2353b5a
/TicTac/src/tictac/Board2.java
659c647cbd40b28dce6b86cf2af1ae1fe2f43029
[]
no_license
NShani/TicTacToe
4b64efb93e844d6e1417dc0e077e938fd1d08bbf
1248293d4b43f1798a672c15e2c37aefd3bddc1e
refs/heads/master
2021-01-23T09:52:35.325898
2015-07-13T08:27:42
2015-07-13T08:27:42
38,559,876
0
0
null
null
null
null
UTF-8
Java
false
false
32,225
java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package tictac; import java.awt.Color; import java.sql.Connection; import java.sql.SQLException; import java.util.Random; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public class Board2 extends javax.swing.JFrame { Btn btnArr[][]=new Btn[3][3]; PlayCom pyr=new PlayCom(); DataBase db=new DataBase(); Connection con; String player; int p=0,c=0; public Board2(String player) { initComponents(); this.player=player; jLabel4.setText(player); jLabel6.setText("0"); jLabel7.setText("0"); try { con=db.connection(); } catch(Exception e) { } for(int i=0;i<3;i++) { for (int j = 0; j <3; j++) { btnArr[i][j]=new Btn(); } } btnArr[0][0].btn=jButton1; btnArr[0][1].btn=jButton2; btnArr[0][2].btn=jButton3; btnArr[1][0].btn=jButton4; btnArr[1][1].btn=jButton5; btnArr[1][2].btn=jButton6; btnArr[2][0].btn=jButton7; btnArr[2][1].btn=jButton8; btnArr[2][2].btn=jButton9; } ImageIcon img = new ImageIcon("G:\\Java\\javaPrgrm\\TicTac\\src\\tictac\\Layer 1.png"); ImageIcon img1 = new ImageIcon("G:\\Java\\javaPrgrm\\TicTac\\src\\tictac\\Layer 2.png"); @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jButton5 = new javax.swing.JButton(); jButton6 = new javax.swing.JButton(); jButton7 = new javax.swing.JButton(); jButton8 = new javax.swing.JButton(); jButton9 = new javax.swing.JButton(); jButton10 = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setPreferredSize(new java.awt.Dimension(700, 490)); setResizable(false); getContentPane().setLayout(null); jButton1.setBorderPainted(false); jButton1.setContentAreaFilled(false); jButton1.setFocusPainted(false); jButton1.setFocusable(false); jButton1.setMaximumSize(new java.awt.Dimension(80, 80)); jButton1.setPreferredSize(new java.awt.Dimension(80, 80)); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); getContentPane().add(jButton1); jButton1.setBounds(390, 30, 80, 80); jButton2.setBorderPainted(false); jButton2.setContentAreaFilled(false); jButton2.setFocusPainted(false); jButton2.setFocusable(false); jButton2.setMaximumSize(new java.awt.Dimension(80, 80)); jButton2.setPreferredSize(new java.awt.Dimension(80, 80)); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); getContentPane().add(jButton2); jButton2.setBounds(490, 30, 80, 80); jButton3.setBorderPainted(false); jButton3.setContentAreaFilled(false); jButton3.setFocusPainted(false); jButton3.setFocusable(false); jButton3.setMaximumSize(new java.awt.Dimension(80, 80)); jButton3.setPreferredSize(new java.awt.Dimension(80, 80)); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); getContentPane().add(jButton3); jButton3.setBounds(590, 30, 80, 80); jButton4.setBorderPainted(false); jButton4.setContentAreaFilled(false); jButton4.setFocusPainted(false); jButton4.setFocusable(false); jButton4.setMaximumSize(new java.awt.Dimension(80, 80)); jButton4.setPreferredSize(new java.awt.Dimension(80, 80)); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); getContentPane().add(jButton4); jButton4.setBounds(390, 130, 80, 80); jButton5.setBorderPainted(false); jButton5.setContentAreaFilled(false); jButton5.setFocusPainted(false); jButton5.setFocusable(false); jButton5.setMaximumSize(new java.awt.Dimension(80, 80)); jButton5.setPreferredSize(new java.awt.Dimension(80, 80)); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); getContentPane().add(jButton5); jButton5.setBounds(490, 130, 80, 80); jButton6.setBorderPainted(false); jButton6.setContentAreaFilled(false); jButton6.setFocusPainted(false); jButton6.setFocusable(false); jButton6.setMaximumSize(new java.awt.Dimension(80, 80)); jButton6.setPreferredSize(new java.awt.Dimension(80, 80)); jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } }); getContentPane().add(jButton6); jButton6.setBounds(590, 130, 80, 80); jButton7.setBorderPainted(false); jButton7.setContentAreaFilled(false); jButton7.setFocusPainted(false); jButton7.setFocusable(false); jButton7.setMaximumSize(new java.awt.Dimension(80, 80)); jButton7.setPreferredSize(new java.awt.Dimension(80, 80)); jButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton7ActionPerformed(evt); } }); getContentPane().add(jButton7); jButton7.setBounds(390, 230, 80, 80); jButton8.setBorderPainted(false); jButton8.setContentAreaFilled(false); jButton8.setFocusPainted(false); jButton8.setFocusable(false); jButton8.setMaximumSize(new java.awt.Dimension(80, 80)); jButton8.setPreferredSize(new java.awt.Dimension(80, 80)); jButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton8ActionPerformed(evt); } }); getContentPane().add(jButton8); jButton8.setBounds(490, 230, 80, 80); jButton9.setBorderPainted(false); jButton9.setContentAreaFilled(false); jButton9.setFocusPainted(false); jButton9.setFocusable(false); jButton9.setMaximumSize(new java.awt.Dimension(80, 80)); jButton9.setPreferredSize(new java.awt.Dimension(80, 80)); jButton9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton9ActionPerformed(evt); } }); getContentPane().add(jButton9); jButton9.setBounds(590, 230, 80, 80); jButton10.setFont(new java.awt.Font("Tempus Sans ITC", 1, 36)); // NOI18N jButton10.setText("RESTART"); jButton10.setFocusPainted(false); jButton10.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton10ActionPerformed(evt); } }); getContentPane().add(jButton10); jButton10.setBounds(100, 200, 200, 60); jLabel4.setBackground(new java.awt.Color(255, 0, 102)); jLabel4.setFont(new java.awt.Font("Tempus Sans ITC", 1, 24)); // NOI18N jLabel4.setForeground(new java.awt.Color(255, 0, 102)); jLabel4.setText("jLabel4"); jLabel4.setBorder(new javax.swing.border.MatteBorder(null)); getContentPane().add(jLabel4); jLabel4.setBounds(60, 20, 150, 40); jLabel5.setBackground(new java.awt.Color(255, 0, 102)); jLabel5.setFont(new java.awt.Font("Tempus Sans ITC", 1, 24)); // NOI18N jLabel5.setForeground(new java.awt.Color(255, 0, 102)); jLabel5.setText("Computer"); jLabel5.setBorder(new javax.swing.border.MatteBorder(null)); getContentPane().add(jLabel5); jLabel5.setBounds(220, 20, 140, 40); jLabel6.setBackground(new java.awt.Color(255, 0, 102)); jLabel6.setFont(new java.awt.Font("Tempus Sans ITC", 1, 24)); // NOI18N jLabel6.setForeground(new java.awt.Color(255, 0, 102)); getContentPane().add(jLabel6); jLabel6.setBounds(100, 70, 90, 80); jLabel7.setBackground(new java.awt.Color(255, 0, 102)); jLabel7.setFont(new java.awt.Font("Tempus Sans ITC", 1, 24)); // NOI18N jLabel7.setForeground(new java.awt.Color(255, 0, 102)); getContentPane().add(jLabel7); jLabel7.setBounds(250, 70, 90, 70); jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/tictac/Tic-Tac-Toe-Pro-icon copy.png"))); // NOI18N getContentPane().add(jLabel3); jLabel3.setBounds(380, 10, 310, 310); jLabel1.setFont(new java.awt.Font("Tempus Sans ITC", 1, 48)); // NOI18N jLabel1.setForeground(new java.awt.Color(255, 0, 51)); getContentPane().add(jLabel1); jLabel1.setBounds(200, 320, 450, 60); jLabel2.setForeground(new java.awt.Color(255, 0, 102)); jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/tictac/chicken rabbit.jpg"))); // NOI18N jLabel2.setText(" "); jLabel2.setMaximumSize(new java.awt.Dimension(2147483647, 2147483647)); jLabel2.setPreferredSize(new java.awt.Dimension(1238, 900)); getContentPane().add(jLabel2); jLabel2.setBounds(-120, -230, 1238, 900); pack(); }// </editor-fold>//GEN-END:initComponents int row=0,clm=0,rowVal=0,clmVal=0,dia=0,diaVal=0,diaNo=0; int row1[]=new int[3],clm1[]=new int[3]; int[] dia1 = new int[3]; private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: if(!btnArr[0][0].status) { btnArr[0][0].status=true; btnArr[0][0].btn.setIcon(img); btnArr[0][0].value=1; checkRow(); checkClm(); checkDiagonal(); putSign(); checkWin(); } }//GEN-LAST:event_jButton1ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: if(!btnArr[0][1].status) { btnArr[0][1].status=true; btnArr[0][1].btn.setIcon(img); btnArr[0][1].value=1; checkRow(); checkClm(); checkDiagonal(); putSign(); checkWin(); } }//GEN-LAST:event_jButton2ActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed // TODO add your handling code here: if(!btnArr[0][2].status) { btnArr[0][2].status=true; btnArr[0][2].btn.setIcon(img); btnArr[0][2].value=1; checkRow(); checkClm(); checkDiagonal(); putSign(); checkWin(); } }//GEN-LAST:event_jButton3ActionPerformed private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: if(!btnArr[1][0].status) { btnArr[1][0].status=true; btnArr[1][0].btn.setIcon(img); btnArr[1][0].value=1; checkRow(); checkClm(); checkDiagonal(); putSign(); checkWin(); } }//GEN-LAST:event_jButton4ActionPerformed private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed // TODO add your handling code here: if(!btnArr[1][1].status) { btnArr[1][1].status=true; btnArr[1][1].btn.setIcon(img); btnArr[1][1].value=1; checkRow(); checkClm(); checkDiagonal(); putSign(); } }//GEN-LAST:event_jButton5ActionPerformed private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed // TODO add your handling code here: if(!btnArr[1][2].status) { btnArr[1][2].status=true; btnArr[1][2].btn.setIcon(img); btnArr[1][2].value=1; checkRow(); checkClm(); checkDiagonal(); putSign(); checkWin(); } }//GEN-LAST:event_jButton6ActionPerformed private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed // TODO add your handling code here: if(!btnArr[2][0].status) { btnArr[2][0].status=true; btnArr[2][0].btn.setIcon(img); btnArr[2][0].value=1; checkRow(); checkClm(); checkDiagonal(); putSign(); checkWin(); } }//GEN-LAST:event_jButton7ActionPerformed private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed // TODO add your handling code here: if(!btnArr[2][1].status) { btnArr[2][1].status=true; btnArr[2][1].btn.setIcon(img); btnArr[2][1].value=1; checkRow(); checkClm(); checkDiagonal(); putSign(); checkWin(); } }//GEN-LAST:event_jButton8ActionPerformed private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed // TODO add your handling code here: if(!btnArr[2][2].status) { btnArr[2][2].status=true; btnArr[2][2].btn.setIcon(img); btnArr[2][2].value=1; checkRow(); checkClm(); checkDiagonal(); putSign(); checkWin(); } }//GEN-LAST:event_jButton9ActionPerformed private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed // TODO add your handling code here: Tic tt; tt = new Tic(); tt.setVisible(true); this.setVisible(false); }//GEN-LAST:event_jButton10ActionPerformed public boolean checkDraw() { int tot=0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if(btnArr[i][j].status) tot++; if (tot==9) { return true; } } } return false; } private void checkWin() { if((btnArr[0][0].value+btnArr[0][1].value+btnArr[0][2].value)==3 ||(btnArr[1][0].value+btnArr[1][1].value+btnArr[1][2].value)==3 || (btnArr[2][0].value+btnArr[2][1].value+btnArr[2][2].value)==3 || (btnArr[0][0].value+btnArr[1][0].value+btnArr[2][0].value)==3 || (btnArr[0][1].value+btnArr[1][1].value+btnArr[2][1].value)==3 || (btnArr[0][2].value+btnArr[1][2].value+btnArr[2][2].value)==3 || (btnArr[0][0].value+btnArr[1][1].value+btnArr[2][2].value)==3 || (btnArr[0][2].value+btnArr[1][1].value+btnArr[2][0].value)==3) { jLabel1.setText(player+" Won"); try { p++; jLabel6.setText(Integer.toString(p)); int success=db.read(con, player)+1; db.addScores(con,player, success); if(checkDraw()) { jLabel1.setBackground(Color.red); jLabel1.setText("DRAWN"); } } catch(Exception ep) { } } else if((btnArr[0][0].value+btnArr[0][1].value+btnArr[0][2].value)==-3 ||(btnArr[1][0].value+btnArr[1][1].value+btnArr[1][2].value)==-3 || (btnArr[2][0].value+btnArr[2][1].value+btnArr[2][2].value)==-3 || (btnArr[0][0].value+btnArr[1][0].value+btnArr[2][0].value)==-3 || (btnArr[0][1].value+btnArr[1][1].value+btnArr[2][1].value)==-3 || (btnArr[0][2].value+btnArr[1][2].value+btnArr[2][2].value)==-3 || (btnArr[0][0].value+btnArr[1][1].value+btnArr[2][2].value)==-3 || (btnArr[0][2].value+btnArr[1][1].value+btnArr[2][0].value)==-3) { jLabel1.setText("Computer Won"); try { c++; jLabel7.setText(Integer.toString(c)); int losses=db.readLosses(con, player)+1; db.removeScores(con, player, losses); if(checkDraw()) { jLabel1.setText("DRAWN"); } } catch(Exception ep) { } } } // private void checkWon() // { // if() // } private void putSign() { int times=0; if(rowVal>=clmVal && rowVal>=diaVal) { try { for (int i = 0; i < 3; i++) { if(!btnArr[row][i].status) { btnArr[row][i].status=true; btnArr[row][i].value=-1; btnArr[row][i].btn.setIcon(img1); System.out.println("1"); break; } } } catch(Exception e) { for (int i = 0; i < 3; i++) { if(!btnArr[i][clm].status) { btnArr[i][clm].status=true; btnArr[i][clm].value=-1; btnArr[i][clm].btn.setIcon(img1); System.out.println("2"); break; } } } } else if(clmVal>=diaVal) { try { for (int i = 0; i < 3; i++) { if(!btnArr[i][clm].status) { System.out.println("bbbb"+clm); btnArr[i][clm].status=true; btnArr[i][clm].value=-1; btnArr[i][clm].btn.setIcon(img1); System.out.println("3"); break; } } } catch(Exception e) { if(diaNo==1) { for (int i = 0; i < 3; i++) { if(!btnArr[i][i].status) { btnArr[i][i].status=true; btnArr[i][i].value=-1; btnArr[i][i].btn.setIcon(img1); System.out.println("4"); //times++; break; } } } else { for (int i = 0; i < 3; i++) { for (int j = 2; j >=0; j--) { if(!btnArr[i][j].status) { btnArr[i][j].status=true; btnArr[i][j].value=-1; btnArr[i][j].btn.setIcon(img1); System.out.println("5"); times++; break; } } if(times==1) { break; } } } } } else if(diaVal>rowVal && diaVal>clmVal) { if(diaNo==1) { for (int i = 0; i < 3; i++) { if(!btnArr[i][i].status) { btnArr[i][i].status=true; btnArr[i][i].value=-1; btnArr[i][i].btn.setIcon(img1); System.out.println("6"); //times++; break; } } } else { for (int i = 0; i < 3; i++) { for (int j = 2; j >=0; j--) { if(!btnArr[i][j].status) { btnArr[i][j].status=true; btnArr[i][j].value=-1; btnArr[i][j].btn.setIcon(img1); System.out.println("7"); times++; break; } } if(times==1) { break; } } } } else { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { btnArr[i][j].status=true; btnArr[i][j].value=-1; btnArr[i][j].btn.setIcon(img1); System.out.println("8"); times++; break; } if(times==1) { break; } } } // btnArr[row-1][i].status=true; // btnArr[row-1][i].btn.setIcon(img1); // btnArr[row-1][i].value=-1; // btnArr[row-1][i].status=true; // break; // } // } // } // // else if(clmVal > diaVal && clm!=0){ // for(int i=0;i<3;i++){ // if(!(btnArr[i][clm-1].status)){ // btnArr[i][clm-1].status=true; // btnArr[i][clm-1].btn.setIcon(img1); // btnArr[i][clm-1].value=-1; // btnArr[i][clm-1].status=true; // break; // } // } // } // // else { // for(int i=0;i<3;i++){ // for(int j=0;j<3;j++){ // if(diaNo==1){ // if(i==j ){ // if(!(btnArr[i][j].status)){ // btnArr[i][j].status=true; // btnArr[i][j].btn.setIcon(img1); // btnArr[i][j].value=-1; // btnArr[i][j].status=true; // times++; // break; // } // } // } // else if((i==0 && j==2) || (i==2 && j==0) || (i==1 && j==1)){ // if(!(btnArr[i][j].status)){ // btnArr[i][j].status=true; // btnArr[i][j].btn.setIcon(img1); // btnArr[i][j].value=-1; // btnArr[i][j].status=true; // times++; // break; // } // } // // } // if(times==1) // { // break; // } // } // } } private int checkRow() { int tot[]=new int[3]; tot[0]=0; tot[1]=0; tot[2]=0; int max=0; int totr2=0,totr3=0,tot1=0,numOfTrue=0; for(int i=0;i<3;i++) { for (int j = 0; j < 3; j++) { if (btnArr[i][j].value==1) { tot[i]++; } } if(tot[i]>max) { max=tot[i]; row=i; rowVal=max; } } // if(btnArr[0][i].value==-1){ // numOfTrue++; // } // // if(numOfTrue==2){ // totr1=0; // break; // } // if(btnArr[0][i].value>0) // totr1 += btnArr[0][i].value; // } // numOfTrue=0; // for(int i=0;i<3;i++){ // // if(btnArr[1][i].status){ // numOfTrue++; // } // // if(numOfTrue==3){ // totr2=0; // break; // } // if(btnArr[1][i].value>0) // totr2 += btnArr[1][i].value; // } // numOfTrue=0; // for(int i=0;i<3;i++){ // // if(btnArr[2][i].status){ // numOfTrue++; // } // // if(numOfTrue==3){ // totr3=0; // break; // } // if(btnArr[2][i].value>0) // totr3 += btnArr[2][i].value; // } // //if(totr1>totr2 && totr1>totr3){ // tot=totr1; //}else if(totr2>totr1 && totr2>totr3){ // tot=totr2; //}else{ // tot=totr3; //} //rowVal=tot; // // if(tot==totr1){ // return 1;} // else if(tot==totr2){ // return 2;} // else if(tot==totr3){ // return 3; // // } // else return 0; } private int checkClm() { int tot[]=new int[3]; tot[0]=0; tot[1]=0; tot[2]=0; int max=0; int totr2=0,totr3=0,tot1=0,numOfTrue=0; for(int i=0;i<3;i++) { for (int j = 0; j < 3; j++) { if (btnArr[j][i].value==1) { tot[i]++; } } if(tot[i]>max) { max=tot[i]; System.out.println(max+"fxfh"+i); clm=i; clmVal=max; } } // int totc1=0,totc2=0,totc3=0,tot=0,numOfTrue=0; // for(int i=0;i<3;i++){ // // if(btnArr[i][0].status){ // numOfTrue++; // } // // if(numOfTrue==3){ // totc1=0; // break; // } // if(btnArr[i][0].value>0) // totc1 += btnArr[i][0].value; // } // numOfTrue=0; // for(int i=0;i<3;i++){ // // if(btnArr[i][1].status){ // numOfTrue++; // } // // if(numOfTrue==3){ // totc2=0; // break; // } // if(btnArr[i][1].value>0) // totc2 += btnArr[i][1].value; // } // numOfTrue=0; // for(int i=0;i<3;i++){ // // if(btnArr[i][2].status){ // numOfTrue++; // } // // if(numOfTrue==3){ // totc3=0; // break; // } // if(btnArr[i][2].value>0) // totc3 += btnArr[i][2].value; // } // //if(totc1>totc2 && totc1>totc3){ // tot=totc1; //}else if(totc2>totc1 && totc2>totc3){ // tot=totc2; //}else{ // tot=totc3; //} //clmVal=tot; // // // if(tot==totc1){ // return 1;} // else if(tot==totc2){ // return 2;} // else if(tot==totc3){ // return 3; // // } // else return 0; } public int checkDiagonal() { int dia1=0,dia2=0; for (int i = 0; i < 3; i++) { if (btnArr[i][i].value==1) { dia1++; } } // for (int i = 0; i < 3; i++) // { int i=0,j=0; for (i=0,j = 2; j >=0; i++,j--) { if (btnArr[i][i].value==1) { dia2++; } } if(dia1>dia2) { diaVal=dia1; diaNo=1; dia=i; } else { diaVal=dia2; diaNo=2; dia=i; } // } // int totd1=0,totd2=0,totd3=0,tot=0,numOfTrue=0; // for(int i=0;i<3;i++){ // for(int j=0;j<3;j++){ // if(i==j){ // if(btnArr[i][j].status){ // numOfTrue++; // } // // // // // if(numOfTrue==3){ // totd1=0; // break; // } // // if(btnArr[i][j].value>0) // totd1 += btnArr[i][j].value; // } // } // // } // numOfTrue=0; // for(int i=0;i<3;i++){ // for(int j=0;j<3;j++){ // if((i==0 && j==2) || (i==1 && j==1) || (i==2 && j==0)){ // // if(btnArr[i][j].status){ // numOfTrue++; // } // // if(numOfTrue==3){ // totd2=0; // break; // } // if(btnArr[i][j].value>0) // totd2 += btnArr[i][j].value; // } // // } // } // //if(totd1>totd2 ){ // tot=totd1; //}else { // tot=totd2; //} //diaVal=tot; // // // if(tot==totd1){ // return 1;} // else if(tot==totd2){ // return 2;} // // else return 0; } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton10; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JButton jButton7; private javax.swing.JButton jButton8; private javax.swing.JButton jButton9; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; // End of variables declaration//GEN-END:variables } class Btn { JButton btn=new JButton(); boolean status=false; int value=0; } class PlayCom { String name; int val=1; }
c5aceebfae7c1a2edaf3ca359f83ad4ee507827b
ce64e5230d8885868b0cb42b971517db3ef439ad
/src/Collection/CollectionIterator.java
e14196f1d8dd735bc0de40431127d53c999675b9
[]
no_license
yoghurts-sy/JavaBasic
a5746c4bddc00d041107744e06e863a895b895aa
9e0150d2ae8b305fc6e21c0392a67e6b3a744f78
refs/heads/master
2021-05-25T13:02:50.363981
2020-07-05T07:18:10
2020-07-05T07:18:10
253,765,054
0
0
null
null
null
null
GB18030
Java
false
false
1,219
java
package Collection; import java.util.Iterator; import java.util.ArrayList; import java.util.Collection; import java.util.ListIterator; /*`Iterator`主要用于迭代访问(即遍历)`Collection`中的元素 * 因此`Iterator`对象也被称为迭代器 * * Iterator接口的常用方法如下: * * `public E next()`:返回迭代的下一个元素。 * `public boolean hasNext()`:如果仍有元素可以迭代,则返回 true。 */ /* * 迭代器原理: * 在调用Iterator的next方法之前,迭代器的索引位指向第一个元素之前 * 当调用一次next时,迭代器的索引会向后移一位,以此类推,达到集合末尾。 * 当索引已经指向结尾,再使用next会报错:NoSuchElementException */ public class CollectionIterator { public static void main(String[] args) { /* * 使用多态创建对象 */ Collection<String> coll = new ArrayList<String>(); coll.add("南宁"); coll.add("是我的家乡"); coll.add("她有绿城的美誉"); Iterator<String> it = coll.iterator(); while (it.hasNext()) { String msg = it.next(); System.out.println(msg); } /*System.out.println(it.next());*/ } }
53376f1afd4d696a6d329fa285bc722dd8153282
8ea665ba731b5eb77ec06f1ba0459d984e104944
/app/src/main/java/com/example/hasna2/soccifillia/BluetoothActivity.java
9d4b62c8d6fa91c26f6b0c9301ce8fd36e4a0db3
[]
no_license
7asna2/I-Tracker
6abe08ca73ac3a588fb7961111b74e846d1a1b62
5537a160dea95c1eecf601d20d7ba5386c48d236
refs/heads/master
2021-01-16T18:28:46.629872
2016-09-20T22:00:18
2016-09-20T22:00:18
68,756,666
0
0
null
null
null
null
UTF-8
Java
false
false
5,135
java
package com.example.hasna2.soccifillia; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.content.ComponentName; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.os.Bundle; import android.os.IBinder; import android.os.Parcelable; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import java.util.ArrayList; import java.util.Set; public class BluetoothActivity extends AppCompatActivity { private BluetoothAdapter BA; private Set<BluetoothDevice> pairedDevices; private ArrayList<BluetoothDevice>Devices; private BluetoothDevice device; private ListView listView; private ServiceStatusUpdate bluetoothService; private boolean isbound= false; final private String LOG_TAG = "BluetoothActivity"; // private TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_bluetooth); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); BA = BluetoothAdapter.getDefaultAdapter(); // textView = (TextView)findViewById(R.id.connected_device); listView = (ListView)findViewById(R.id.bluetoothList); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { device = Devices.get(position); Toast.makeText(getApplicationContext(), "Device registered", Toast.LENGTH_LONG).show(); Intent serviceIntent = new Intent(getApplicationContext(),ServiceStatusUpdate.class); serviceIntent.putExtra(Intent.EXTRA_TEXT,(Parcelable)device); startService(serviceIntent); } }); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { list(); } }); getSupportActionBar().setDisplayHomeAsUpEnabled(true); on(); IntentFilter filter = new IntentFilter(); filter.addAction("android.bluetooth.device.action.ACTION_ACL_CONNECTED"); filter.addAction("android.bluetooth.device.action.ACTION_ACL_DISCONNECTED"); filter.addAction("android.bluetooth.device.action.ACTION_ACL_DISCONNECT_REQUESTED"); // registerReceiver(BTReceiver,filter); } public void list(){ pairedDevices = BA.getBondedDevices(); ArrayList list = new ArrayList(); Devices = new ArrayList<>(); for(BluetoothDevice bt : pairedDevices) { list.add(bt.getName()); Devices.add(bt); } Toast.makeText(getApplicationContext(),"Showing Paired Devices",Toast.LENGTH_SHORT).show(); final ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1, list); listView.setAdapter(adapter); } public void on() { if (!BA.isEnabled()) { Intent turnOn = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(turnOn, 0); Toast.makeText(getApplicationContext(), "Turning on", Toast.LENGTH_LONG).show(); } else { Toast.makeText(getApplicationContext(), "Already on", Toast.LENGTH_LONG).show(); } } private ServiceConnection serviceConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { ServiceStatusUpdate.LocalBinder binder = (ServiceStatusUpdate.LocalBinder)service; bluetoothService=binder.getService(); isbound=true; } @Override public void onServiceDisconnected(ComponentName name) { isbound=false; } }; // // public final BroadcastReceiver BTReceiver = new BroadcastReceiver() { // @Override // public void onReceive(Context context, Intent intent) { // String action = intent.getAction(); // // if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) { // //Do something if connected // textView.setText(device.getName()); // } // else if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)||BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED.equals(action)) { // //Do something if disconnected // textView.setText("NOO"); // Toast.makeText(getApplicationContext(), "BT Disconnected", Toast.LENGTH_SHORT).show(); // } // //else if... // } // }; }
f861ec02e0b07eb100677803340222d16ac3416a
32891723020ee2f45b96f61094dc8fd1f829f57a
/demotools/src/main/java/com/ukelink/um/handle/netty/EncodeHandler.java
edb8be33a5a20f22e4570ebb75f6c3d390b9ed96
[]
no_license
flam-flam-flam/tools
8c21d1d1d2503cd3f37cb689f8c7e9e5be324ca3
bf752a58d6c37db779c6308ba1b2603725b017bf
refs/heads/master
2023-09-04T02:57:02.340567
2023-09-04T01:57:46
2023-09-04T01:57:46
199,966,946
0
0
null
2022-10-04T23:54:24
2019-08-01T03:09:02
Java
UTF-8
Java
false
false
1,220
java
package com.ukelink.um.handle.netty; import com.ukelink.um.bean.LongLinkMessage; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageCodec; import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.codec.MessageToByteEncoder; import okio.Buffer; import java.nio.charset.Charset; import java.util.List; import static java.nio.charset.StandardCharsets.UTF_8; public class EncodeHandler extends MessageToByteEncoder<Buffer> { public void encode(ChannelHandlerContext ctx, Buffer msg, ByteBuf out) throws Exception { //out.add(doEncode(ctx.alloc(), msg)); System.out.println("2222 endcode"); // buffer.writeShort(12); // buffer.writeShort(18); // buffer.writeInt(40); // buffer.writeShort(11); // buffer.writeInt(22); // buffer.writeString("1111", Charset.forName("utf-8")); out.writeInt(40); out.writeShort(18); out.writeShort(11); out.writeShort(3); out.writeInt(22); out.writeBytes("1111".getBytes(UTF_8)); // out. //out.writeBytes(msg.getLongLinkBody()); } }
b85c5155201c17ad448910f95a7515b390765097
98750a80a42f585cbf70f23ab5f965234b10e3e4
/src/gui/CustomerPane.java
404ae4befb99a79293d51246a5fef7fadfbe99f3
[]
no_license
jacobtornqvist/FoJaJo
cdacf5789c4a021d110ac9980798f8392fc6a388
675448bd78bd70bbe18d3058da573e4cc2d046bb
refs/heads/master
2020-04-04T10:06:17.959182
2018-11-14T09:57:08
2018-11-14T09:57:08
155,842,954
0
0
null
null
null
null
ISO-8859-1
Java
false
false
7,041
java
package gui; import java.text.DecimalFormat; import Exceptions.ErrorHandler; import controller.Controller; import javafx.beans.binding.Bindings; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx.event.ActionEvent; import javafx.geometry.HPos; import javafx.geometry.Insets; import javafx.geometry.VPos; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TableColumn; import javafx.scene.control.TableRow; import javafx.scene.control.TableView; import javafx.scene.control.TextField; import javafx.scene.layout.GridPane; import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; import javafx.scene.text.Font; import model.BankAccount; import model.Customer; public class CustomerPane extends GridPane { private Controller cont; private AppContext appContext; private CreateAccountPane createAccPane; private Label customerNameLbl, bankAccountLbl; private TableView<BankAccount> bankAccountsTable; private Button logoutBtn, addAccountBtn, removeAccountBtn; public CustomerPane(Controller cont, AppContext appContext) { this.cont = cont; this.appContext = appContext; initComponents(); initListeners(); loadCustomer(cont.getCurrentCustomer()); } private void initComponents() { customerNameLbl = new Label("Användarnamn"); customerNameLbl.setFont(Font.font(30)); bankAccountLbl = new Label("Bankkonton"); logoutBtn = new Button("Logga ut"); addAccountBtn = new Button("Lägg till konto"); removeAccountBtn = new Button("Ta bort konto"); bankAccountsTable = new TableView<BankAccount>(); TableColumn<BankAccount, String> nameCol = new TableColumn<BankAccount, String>("Kontonamn"); nameCol.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getAccountName())); TableColumn<BankAccount, Number> idCol = new TableColumn<BankAccount, Number>("Kontonummer"); idCol.setCellValueFactory(data -> new SimpleIntegerProperty(data.getValue().getAccountNbr())); TableColumn<BankAccount, String> amountCol = new TableColumn<BankAccount, String>("Saldo"); DecimalFormat df = new DecimalFormat("#.##"); amountCol.setCellValueFactory(data -> new SimpleStringProperty(df.format(data.getValue().getBalance()) + " kr")); bankAccountsTable.getColumns().add(nameCol); bankAccountsTable.getColumns().add(idCol); bankAccountsTable.getColumns().add(amountCol); bankAccountsTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); setPadding(new Insets(10)); setVgap(5); setHgap(5); add(customerNameLbl, 0, 0); add(logoutBtn, 1, 0); GridPane.setHalignment(logoutBtn, HPos.RIGHT); GridPane.setHgrow(logoutBtn, Priority.ALWAYS); add(bankAccountLbl, 0, 1); add(bankAccountsTable, 0, 5, 2, 1); add(addAccountBtn, 0, 6); GridPane.setHgrow(addAccountBtn, Priority.ALWAYS); addAccountBtn.setMaxWidth(Double.MAX_VALUE); add(removeAccountBtn, 1, 6); GridPane.setHgrow(removeAccountBtn, Priority.ALWAYS); removeAccountBtn.setMaxWidth(Double.MAX_VALUE); removeAccountBtn.disableProperty().bind(Bindings.isNull(bankAccountsTable.getSelectionModel().selectedItemProperty())); GridPane.setValignment(bankAccountsTable, VPos.BOTTOM); GridPane.setVgrow(bankAccountsTable, Priority.ALWAYS); } private void initListeners() { logoutBtn.setOnAction(e -> { cont.setCurrentCustomer(null); }); cont.getCurrentCustomerProperty().addListener((observable, oldValue, newValue) -> { loadCustomer(newValue); }); bankAccountsTable.setRowFactory(tv -> { TableRow<BankAccount> row = new TableRow<>(); row.setOnMouseClicked(event -> { if (event.getClickCount() == 2 && (!row.isEmpty())) { cont.setCurrentBankAccount(row.getItem()); } }); return row; }); addAccountBtn.setOnAction(e -> { getChildren().remove(createAccPane); createAccPane = new CreateAccountPane(); add(createAccPane, 0, 7, 2, 1); }); removeAccountBtn.setOnAction(x -> { try { cont.deleteBankAccount(bankAccountsTable.getSelectionModel().getSelectedItem().getAccountNbr()); bankAccountsTable.setItems(FXCollections.observableArrayList(cont.getAllBankAccounts())); appContext.setSuccess("Kontot har tagits bort."); }catch (Exception e) { appContext.setError(ErrorHandler.handleException(e)); } }); } private void loadCustomer(Customer c) { customerNameLbl.setText(c == null ? "" : c.getUsername()); try { bankAccountsTable.setItems(c == null ? null : FXCollections.observableArrayList(cont.getAllBankAccounts())); } catch (Exception e) { appContext.setError(ErrorHandler.handleException(e)); } } private class CreateAccountPane extends GridPane { private Label titleLabel; private Button addButton, closeButton; private TextField accNameInput, accNbrInput; protected CreateAccountPane() { super(); init(); setStyle("-fx-border-color: -fx-text-box-border"); setPadding(new Insets(20)); } public void init() { setHgap(10); setVgap(10); setMinHeight(USE_PREF_SIZE); setPadding(new Insets(20, 0, 0, 0)); titleLabel = new Label("Skapa nytt konto"); titleLabel.setStyle("-fx-font-weight: bold;"); add(titleLabel, 0, 0, 2, 1); Label accNameLabel = new Label("Kontonamn (*):"); accNameInput = new TextField(); accNameInput.setMaxWidth(Double.MAX_VALUE); GridPane.setHgrow(accNameInput, Priority.ALWAYS); Label accNbrLabel = new Label("Kontonummer (*):"); accNbrInput = new TextField(); accNbrInput.setMaxWidth(Double.MAX_VALUE); GridPane.setHgrow(accNbrInput, Priority.ALWAYS); add(accNameLabel, 0, 1); add(accNameInput, 1, 1); add(accNbrLabel, 0, 2); add(accNbrInput, 1, 2); addButton = new Button("Lägg till"); addButton.setMaxWidth(Double.MAX_VALUE); closeButton = new Button("X"); add(addButton, 1, 5); add(closeButton, 3, 0); addButton.addEventFilter(ActionEvent.ACTION, actionEvent -> { if (!isValid()) { actionEvent.consume(); appContext.setError(getValidationErrorMessage()); } }); addButton.setOnAction(x -> { try { cont.createBankAccount(accNameInput.getText(), Integer.valueOf(accNbrInput.getText())); bankAccountsTable.setItems(FXCollections.observableArrayList(cont.getAllBankAccounts())); appContext.setSuccess("Kontot med namn: " + accNameInput.getText() + " och kontonummer: " + accNbrInput.getText() + " har skapats."); } catch (Exception e) { appContext.setError(ErrorHandler.handleException(e)); } }); closeButton.setOnAction(e -> { ((Pane) getParent()).getChildren().remove(this); }); } private boolean isValid() { try { Integer.valueOf(accNbrInput.getText()); } catch (Exception e) { return false; } return !(accNameInput.getText().isEmpty() || accNbrInput.getText().isEmpty()); } protected String getValidationErrorMessage() { return "Vänligen kontrollera att alla fält är korrekt ifyllda."; } } }
d1874f00308cf5f703e907ea0ddd5bed57b17fef
9bc5ca247ababe2b7447243bbe1ebf4847cee615
/src/basic/HandlingallControls.java
906d821df4b022988f09c5c1d7126ff2be1a16ea
[]
no_license
AGdivya/edurekaSiteFirstProjectRepo
a68454ab14fc33131a5e1b77244bf15dc21b189c
2b0437dbdde13da495ff82c48f7400220cbc7328
refs/heads/master
2020-06-12T22:03:41.265709
2019-06-29T19:22:50
2019-06-29T19:22:50
194,440,472
0
0
null
null
null
null
UTF-8
Java
false
false
2,247
java
package basic; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Actions; import org.testng.annotations.*; public class HandlingallControls { WebDriver driver; @BeforeTest void invokeBrowser() { System.setProperty("webdriver.chrome.driver", "C:\\Users\\AGRAMIT\\Downloads\\Divya\\selenium\\chromedriver_win32\\chromedriver.exe"); driver = new ChromeDriver(); driver.manage().deleteAllCookies(); driver.manage().window().maximize(); driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS); driver.manage().timeouts().implicitlyWait(70, TimeUnit.SECONDS); driver.get("https://www.edureka.co/"); try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); System.out.println("Interrupted Exception Occur"); } System.out.println("landed to Edureka portal"); } @Test public void SignUp() { driver.findElement(By.linkText("Sign Up")).click(); try { Thread.sleep(400); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); System.out.println("Signup Exception"); } driver.findElement(By.id("sg_popup_email")).click(); driver.findElement(By.id("sg_popup_email")).sendKeys("[email protected]"); driver.findElement(By.id("sg_popup_phone_no")).click(); driver.findElement(By.id("sg_popup_phone_no")).sendKeys("9764719206"); Actions action = new Actions(driver); //action.moveToElement(driver.findElement(By.id("new_sign_up_mode"))); action.moveToElement(driver.findElement(By.xpath("//*[@id='new_sign_up_mode']/div/div/div[2]/div[1]/form/button"))); action.click(); System.out.println("Passed>>>>>"); try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } Actions action1 = new Actions(driver); action1.moveToElement(driver.findElement(By.xpath("//*[@type='password' or @name='data[User][password]']"))); action1.sendKeys("12345678"); action1.click(); System.out.println("Hello"); //*[@id="new_sign_up_mode"]/div/div/div[2]/div[2]/form/button } }
d59c72ca123249a739f795e948677d95d6cb63ae
f675f1e75830897ac5b15747bba59c16388bb617
/Trees/src/GenericTree/DiameterOfGenericTree.java
71c209bdeb1cd5701e1f23f51da43f6de237af0f
[]
no_license
tarunsraina/Generic-Tree
cc0438e0f6535654772a69af97d0d5b5127faa0b
8f3c9b2739c60427c683b2e26abc1cee6d238aa4
refs/heads/master
2023-07-31T10:11:58.169132
2021-06-29T09:07:46
2021-06-29T09:07:46
380,307,846
0
0
null
null
null
null
UTF-8
Java
false
false
1,702
java
package GenericTree; import java.util.ArrayList; import java.util.Stack; /*Maximum # of edges between any two nodes is considered as diameter*/ /*calculating diameter,but in recursive call we return height(calculate something,return something) * * we need diameter(declare as static),so we are calculating diameter,but in recursive call we are returning height * to get the deepest and second deepest childs in a tree. */ public class DiameterOfGenericTree { static int dia=0; public static class Node{ int data; ArrayList<Node> children=new ArrayList<>(); } public static void main(String[] args) { int arr[]= {10,20,50,-1,60,-1,-1,30,70,-1,80,110,-1,120,-1,-1,90,-1,-1,40,100,-1,-1,-1}; Stack<Node> st=new Stack<>(); Node root=null; for(int i=0;i<arr.length;i++) { if(arr[i]==-1) { st.pop(); } else { Node temp=new Node(); temp.data=arr[i]; if(st.size()>0) { st.peek().children.add(temp); } else { root=temp; } st.push(temp); } } diameterOftree(root); //even though it returns height,we dont need that System.out.println(dia); } private static int diameterOftree(Node node) { int deepestHeight=-1; int secondDeepestHeight=-1; for(Node child:node.children) { int childHeight=diameterOftree(child); if(childHeight>deepestHeight) { secondDeepestHeight=deepestHeight; deepestHeight=childHeight; } else if(childHeight>secondDeepestHeight) { secondDeepestHeight=childHeight; } } if(deepestHeight+secondDeepestHeight+2>dia) { dia=deepestHeight+secondDeepestHeight+2; } deepestHeight+=1; return deepestHeight; } }
d5024eddc702a9cdd15b6483a587170eacc483ab
252e30b0e393723f80f580065ede30b91ac68cf6
/src/main/java/com/space/book/service/mapper/UserMapper.java
29e0ff152967ba603335a171a5c90d674902c601
[]
no_license
trsorsimo96/SpaceBook
04931c91e4d82dc00d0df65c88cd3354b409e1d1
65dda83f38e36efda33198e57431eb5267fdad45
refs/heads/master
2021-04-09T10:14:36.454250
2018-03-16T07:49:02
2018-03-16T07:49:02
125,482,022
0
1
null
2020-09-18T12:24:52
2018-03-16T07:48:58
Java
UTF-8
Java
false
false
2,306
java
package com.space.book.service.mapper; import com.space.book.domain.Authority; import com.space.book.domain.User; import com.space.book.service.dto.UserDTO; import org.springframework.stereotype.Service; import java.util.*; import java.util.stream.Collectors; /** * Mapper for the entity User and its DTO called UserDTO. * * Normal mappers are generated using MapStruct, this one is hand-coded as MapStruct * support is still in beta, and requires a manual step with an IDE. */ @Service public class UserMapper { public UserDTO userToUserDTO(User user) { return new UserDTO(user); } public List<UserDTO> usersToUserDTOs(List<User> users) { return users.stream() .filter(Objects::nonNull) .map(this::userToUserDTO) .collect(Collectors.toList()); } public User userDTOToUser(UserDTO userDTO) { if (userDTO == null) { return null; } else { User user = new User(); user.setId(userDTO.getId()); user.setLogin(userDTO.getLogin()); user.setFirstName(userDTO.getFirstName()); user.setLastName(userDTO.getLastName()); user.setEmail(userDTO.getEmail()); user.setImageUrl(userDTO.getImageUrl()); user.setActivated(userDTO.isActivated()); user.setLangKey(userDTO.getLangKey()); Set<Authority> authorities = this.authoritiesFromStrings(userDTO.getAuthorities()); if (authorities != null) { user.setAuthorities(authorities); } return user; } } public List<User> userDTOsToUsers(List<UserDTO> userDTOs) { return userDTOs.stream() .filter(Objects::nonNull) .map(this::userDTOToUser) .collect(Collectors.toList()); } public User userFromId(Long id) { if (id == null) { return null; } User user = new User(); user.setId(id); return user; } public Set<Authority> authoritiesFromStrings(Set<String> strings) { return strings.stream().map(string -> { Authority auth = new Authority(); auth.setName(string); return auth; }).collect(Collectors.toSet()); } }
7dbeb92e9572b98f61b2b838972b3424b4af94c7
4e390e1d3ee8db4277d7e86c74e67730a3583a1b
/components/limewire_components_sources/component-1/limewire/limewire/components/core-api/src/main/java/org/limewire/core/api/connection/FirewallTransferStatusEvent.java
6276cd568430ddc440e658fc104a5044d1d9f840
[]
no_license
WasteService/WasteService.github.io
6dd28b9673895dc53c00bfee751a0378d684813a
fefe1185e6c7a53806f28e759f5104904a80db01
refs/heads/master
2023-01-05T09:56:28.057174
2020-10-28T10:13:53
2020-10-28T10:13:53
307,663,150
0
0
null
null
null
null
UTF-8
Java
false
false
328
java
package org.limewire.core.api.connection; import org.limewire.listener.DefaultEvent; public class FirewallTransferStatusEvent extends DefaultEvent<FirewallTransferStatus, FWTStatusReason> { public FirewallTransferStatusEvent(FirewallTransferStatus status, FWTStatusReason reason) { super(status, reason); } }
[ "" ]
311384f3cd8354c24c354f52ff85f8a1e1ae2f1c
1450b21a393c4683373a8f8e6791e29986b8647d
/src/model/ImageBag.java
9cb1a1ec46a8228585887f7ee1220af735c71b2e
[]
no_license
jiacy061/QQPlug-InToPreventTheWithdrawal-withoutLock
de8765fb399ff0e74db7b7e0f66f37748a8cfcdc
e6a3265d2899c5aa6154c1b098a99af218400e97
refs/heads/master
2021-01-19T12:25:26.007470
2017-08-29T13:26:57
2017-08-29T13:26:57
100,784,909
1
0
null
null
null
null
UTF-8
Java
false
false
1,040
java
package model; import java.awt.Image; import java.io.File; import java.util.Date; public class ImageBag { private Date date; private boolean isWithdrawal; private File file; private String fromPath; public ImageBag(File file, String fromPath) { super(); this.file = file; this.fromPath = fromPath; date = new Date(file.lastModified()); isWithdrawal = false; } public Date getDate() { return date; } public Long getMillis() { return file.lastModified(); } public boolean isWithdrawal() { return isWithdrawal; } public void setWithdrawal(boolean isWithdrawal) { this.isWithdrawal = isWithdrawal; } public Image getImage() { return null; } public String getImageName() { return file.getName(); } public String getImagePath() { return file.getAbsolutePath(); } public File getFile() { return file; } public boolean isAppointedPath(String path) { if(path.contains(fromPath)) return true; else if(fromPath.contains(path)) return true; else return false; } }
d435bf06cd130116cb0282cc848ff8a91f4e55e5
c1888ef5fa99eb7aa78383edb755f812366ee403
/getspring/src/main/java/org/getspring/beans/BeanDefinition.java
5c509720c2d6e83257ea9da13b49d34268703a82
[]
no_license
windyoffice1/getspring
725728644eb682cfb34bcc982affbe2ff25e8e88
eba8c3745e84c39bc6a9fad1c73a3d646a2fbdda
refs/heads/master
2021-06-26T23:34:22.523801
2019-08-14T04:16:33
2019-08-14T04:16:33
159,523,869
0
0
null
2020-10-13T11:03:56
2018-11-28T15:31:20
Java
UTF-8
Java
false
false
446
java
package org.getspring.beans; import java.util.List; public interface BeanDefinition { public static final String SCOPE_SINGLETON="singleton"; public static final String SCOPE_PROTOTYE="prototype"; public static final String SCOPE_DEFAULT = ""; public boolean isSingleton(); public boolean isPrototype(); String getScope(); public void setScope(String scope); String getBeanClassName(); List<PropertyValue> getPropertyValues(); }
2c0bd4f8a5d2b39972e7ac2961f64becce5c083f
5e4a1c90655047938abe1adfc786d46263ea8e37
/src/main/java/com/lqr/test/FlieTest.java
35b0c4f9f836f135d9da267f356ba96d2efad59c
[]
no_license
luoqiren/spring-base
d91c0348658222db04d97d33addd0fe73bec9f2b
ee9aca411ca709fca470cffdbfc9170dfc459963
refs/heads/master
2022-12-28T10:00:24.478854
2020-10-12T01:11:16
2020-10-12T01:11:19
102,484,133
0
0
null
2022-12-16T06:17:31
2017-09-05T13:24:41
Java
WINDOWS-1252
Java
false
false
741
java
package com.lqr.test; import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; public class FlieTest { public static void main(String[] args) throws IOException { File f = new File("D:\\a.tmp"); if(!f.exists()){ f.createNewFile(); } FileOutputStream out = new FileOutputStream(f, true); OutputStreamWriter osw = new OutputStreamWriter(out, "GBK"); BufferedWriter bw = new BufferedWriter(osw); bw.write("AAA,°¡°¡°¡°¡, ɵ±Æ°¡, !!!, ÖÐÎÄ"); bw.write("AAA,°¡°¡°¡°¡, ɵ±Æ°¡, !!!, ÖÐÎÄ"); bw.write("AAA,°¡°¡°¡°¡, ɵ±Æ°¡, !!!, ÖÐÎÄ"); bw.flush(); bw.close(); } }
7b67f45a7399450691ec5544b6b80f05b9e4e287
c44cc584efb8590dd352ebfe75b0ce9baa46f37d
/app/src/androidTest/java/com/janson/liveencyclopedia/ApplicationTest.java
bc26cdcdb8a9b4f7c4d425852905c98453d53e5e
[ "Apache-2.0" ]
permissive
jansonjoan/LiveEncyclopedia
7b883b4dbd52e1f857f13b49ba546122d22f2a8b
3269834377ff7e37782dccf41761c3169249e52c
refs/heads/master
2021-01-10T10:32:53.732903
2015-12-14T09:43:52
2015-12-14T09:43:52
47,953,362
0
0
null
null
null
null
UTF-8
Java
false
false
358
java
package com.janson.liveencyclopedia; import android.app.Application; import android.test.ApplicationTestCase; /** * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> */ public class ApplicationTest extends ApplicationTestCase<Application> { public ApplicationTest() { super(Application.class); } }
3a2077f6212a5cffaa8f04cdffab65e1f0621c50
74b47b895b2f739612371f871c7f940502e7165b
/aws-java-sdk-sagemaker/src/main/java/com/amazonaws/services/sagemaker/model/transform/TrialComponentSourceJsonUnmarshaller.java
893b928cb7fd57ca8d89f7305e614817d5121315
[ "Apache-2.0" ]
permissive
baganda07/aws-sdk-java
fe1958ed679cd95b4c48f971393bf03eb5512799
f19bdb30177106b5d6394223a40a382b87adf742
refs/heads/master
2022-11-09T21:55:43.857201
2022-10-24T21:08:19
2022-10-24T21:08:19
221,028,223
0
0
Apache-2.0
2019-11-11T16:57:12
2019-11-11T16:57:11
null
UTF-8
Java
false
false
3,049
java
/* * Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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.amazonaws.services.sagemaker.model.transform; import java.math.*; import javax.annotation.Generated; import com.amazonaws.services.sagemaker.model.*; import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; import com.amazonaws.transform.*; import com.fasterxml.jackson.core.JsonToken; import static com.fasterxml.jackson.core.JsonToken.*; /** * TrialComponentSource JSON Unmarshaller */ @Generated("com.amazonaws:aws-java-sdk-code-generator") public class TrialComponentSourceJsonUnmarshaller implements Unmarshaller<TrialComponentSource, JsonUnmarshallerContext> { public TrialComponentSource unmarshall(JsonUnmarshallerContext context) throws Exception { TrialComponentSource trialComponentSource = new TrialComponentSource(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (token == VALUE_NULL) { return null; } while (true) { if (token == null) break; if (token == FIELD_NAME || token == START_OBJECT) { if (context.testExpression("SourceArn", targetDepth)) { context.nextToken(); trialComponentSource.setSourceArn(context.getUnmarshaller(String.class).unmarshall(context)); } if (context.testExpression("SourceType", targetDepth)) { context.nextToken(); trialComponentSource.setSourceType(context.getUnmarshaller(String.class).unmarshall(context)); } } else if (token == END_ARRAY || token == END_OBJECT) { if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) { if (context.getCurrentDepth() <= originalDepth) break; } } token = context.nextToken(); } return trialComponentSource; } private static TrialComponentSourceJsonUnmarshaller instance; public static TrialComponentSourceJsonUnmarshaller getInstance() { if (instance == null) instance = new TrialComponentSourceJsonUnmarshaller(); return instance; } }
[ "" ]
0d190767089304bcf592e650e7c9b7c8e4cd2035
5744e7d52ec44ad69e1b430cc026a4b663449c2d
/app/src/androidTest/java/com/ama3azi/takepon/tabview/ExampleInstrumentedTest.java
44f844aefea2344a91c392bdfa9ca1fe22e636f1
[]
no_license
amahub/TabView
6c71e1078e857948370b1c5dbad00dd790df12a0
5e16778a3545f5d28b9377e14bbf7b29ad473a6d
refs/heads/master
2021-01-21T06:18:12.081025
2017-02-26T11:32:02
2017-02-26T11:32:02
83,203,756
0
0
null
null
null
null
UTF-8
Java
false
false
758
java
package com.ama3azi.takepon.tabview; 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.ama3azi.takepon.tabview", appContext.getPackageName()); } }
7bff981b113239298d0670ddbbfb64432967e0a0
08bae5c8b200ac106fcd466ec1b3f8cdd1829455
/app/src/main/java/com/example/tsukasa/robohon/MainActivity.java
f432b7fce29e0202bf2abe02e72042e79264445f
[]
no_license
yuuki-takaya/Drive_with_RoBoHon
dc405b47c69a175c900db34a63657a92824498d9
e85fa0fcd992bd5a4f9e7bcf007582874704fac7
refs/heads/master
2020-03-28T20:19:47.575866
2017-06-17T09:40:46
2017-06-17T09:40:46
94,611,027
0
0
null
2017-06-17T09:40:47
2017-06-17T08:34:42
Java
UTF-8
Java
false
false
19,247
java
package com.example.tsukasa.robohon; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.os.PowerManager; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.Toolbar; import java.util.List; import java.util.Locale; import com.example.tsukasa.robohon.customize.ScenarioDefinitions; import com.example.tsukasa.robohon.util.VoiceUIManagerUtil; import com.example.tsukasa.robohon.util.VoiceUIVariableUtil.VoiceUIVariableListHelper; import jp.co.sharp.android.rb.projectormanager.ProjectorManagerServiceUtil; import jp.co.sharp.android.voiceui.VoiceUIManager; import jp.co.sharp.android.voiceui.VoiceUIVariable; import jp.co.sharp.android.rb.camera.FaceDetectionUtil; import jp.co.sharp.android.rb.camera.ShootMediaUtil; import jp.co.sharp.android.rb.rbdance.DanceUtil; public class MainActivity extends Activity implements MainActivityVoiceUIListener.MainActivityScenarioCallback { public static final String TAG = MainActivity.class.getSimpleName(); /** * 顔認識結果通知Action定義. */ public static final String ACTION_RESULT_FACE_DETECTION = "com.example.tsukasa.robohon.action.RESULT_FACE_DETECTION"; /** * 写真/動画撮影結果通知Action定義. */ public static final String ACTION_RESULT_TAKE_PICTURE = "com.example.tsukasa.robohon.action.RESULT_TAKE_PICTURE"; /** * 動画撮影結果通知Action定義. */ public static final String ACTION_RESULT_REC_MOVIE = "com.example.tsukasa.robohon.action.RESULT_REC_MOVIE"; /** * ダンス実行結果通知用Action定義. */ public static final String ACTION_RESULT_DANCE = "com.example.tsukasa.robohon.action.RESULT_DANCE"; /** * 音声UI制御. */ private VoiceUIManager mVoiceUIManager = null; /** * 音声UIイベントリスナー. */ private MainActivityVoiceUIListener mMainActivityVoiceUIListener = null; /** * 音声UIの再起動イベント検知. */ private VoiceUIStartReceiver mVoiceUIStartReceiver = null; /** * ホームボタンイベント検知. */ private HomeEventReceiver mHomeEventReceiver; /** * プロジェクター状態変化イベント検知. */ private ProjectorEventReceiver mProjectorEventReceiver; /** * プロジェクタ照射中のWakelock. */ private android.os.PowerManager.WakeLock mWakelock; /** * 排他制御用. */ private Object mLock = new Object(); /** * プロジェクタ照射状態. */ private boolean isProjected = false; /** * カメラ結果取得用. */ private CameraResultReceiver mCameraResultReceiver; /** * ダンス実行結果取得用. */ private DanceResultReceiver mDanceResultReceiver; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.v(TAG, "onCreate()"); setContentView(R.layout.activity_main); //タイトルバー設定. setupTitleBar(); //ホームボタンの検知登録. mHomeEventReceiver = new HomeEventReceiver(); IntentFilter filterHome = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); registerReceiver(mHomeEventReceiver, filterHome); //VoiceUI再起動の検知登録. mVoiceUIStartReceiver = new VoiceUIStartReceiver(); IntentFilter filter = new IntentFilter(VoiceUIManager.ACTION_VOICEUI_SERVICE_STARTED); registerReceiver(mVoiceUIStartReceiver, filter); //TODO プロジェクタイベントの検知登録(プロジェクター利用時のみ). //setProjectorEventReceiver(); //TODO カメラ連携起動結果取得用レシーバー登録(カメラ利用時のみ). //mCameraResultReceiver = new CameraResultReceiver(); //IntentFilter filterCamera = new IntentFilter(ACTION_RESULT_TAKE_PICTURE); //filterCamera.addAction(ACTION_RESULT_REC_MOVIE); //filterCamera.addAction(ACTION_RESULT_FACE_DETECTION); //registerReceiver(mCameraResultReceiver, filterCamera); //TODO ダンス連携起動結果取得用レシーバー登録(ダンス利用時のみ). //mDanceResultReceiver = new DanceResultReceiver(); //IntentFilter filterDance = new IntentFilter(ACTION_RESULT_DANCE); //registerReceiver(mDanceResultReceiver, filterDance); //発話ボタンの実装. Button Button = (Button) findViewById(R.id.accost); Button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mVoiceUIManager != null) { VoiceUIVariableListHelper helper = new VoiceUIVariableListHelper().addAccost(ScenarioDefinitions.ACC_Judge); VoiceUIManagerUtil.updateAppInfo(mVoiceUIManager, helper.getVariableList(), true); } } }); } @Override public void onResume() { super.onResume(); Log.v(TAG, "onResume()"); //VoiceUIManagerのインスタンス取得. if (mVoiceUIManager == null) { mVoiceUIManager = VoiceUIManager.getService(getApplicationContext()); } //MainActivityVoiceUIListener生成. if (mMainActivityVoiceUIListener == null) { mMainActivityVoiceUIListener = new MainActivityVoiceUIListener(this); } //VoiceUIListenerの登録. VoiceUIManagerUtil.registerVoiceUIListener(mVoiceUIManager, mMainActivityVoiceUIListener); //Scene有効化. VoiceUIManagerUtil.enableScene(mVoiceUIManager, ScenarioDefinitions.SCENE_COMMON); VoiceUIManagerUtil.enableScene(mVoiceUIManager, ScenarioDefinitions.JudgeMode); } @Override public void onPause() { super.onPause(); Log.v(TAG, "onPause()"); //バックに回ったら発話を中止する. VoiceUIManagerUtil.stopSpeech(); //VoiceUIListenerの解除. VoiceUIManagerUtil.unregisterVoiceUIListener(mVoiceUIManager, mMainActivityVoiceUIListener); //Scene無効化. VoiceUIManagerUtil.disableScene(mVoiceUIManager, ScenarioDefinitions.SCENE_COMMON); VoiceUIManagerUtil.disableScene(mVoiceUIManager, ScenarioDefinitions.JudgeMode); //デフォルトの言語設定に戻す Locale locale = Locale.getDefault(); VoiceUIManagerUtil.setAsr(mVoiceUIManager, locale); VoiceUIManagerUtil.setTts(mVoiceUIManager, locale); } @Override protected void onDestroy() { super.onDestroy(); Log.v(TAG, "onDestroy()"); //ホームボタンの検知破棄. this.unregisterReceiver(mHomeEventReceiver); //VoiceUI再起動の検知破棄. this.unregisterReceiver(mVoiceUIStartReceiver); //TODO プロジェクタイベントの検知破棄(プロジェクター利用時のみ). //this.unregisterReceiver(mProjectorEventReceiver); //TODO カメラ連携起動結果取得用レシーバー破棄(カメラ利用時のみ). //this.unregisterReceiver(mCameraResultReceiver); //TODO ダンス結果用レシーバーの破棄(ダンス利用時のみ). //this.unregisterReceiver(mDanceResultReceiver); //インスタンスのごみ掃除. mVoiceUIManager = null; mMainActivityVoiceUIListener = null; mProjectorEventReceiver = null; } /** * VoiceUIListenerクラスからのコールバックを実装する. */ @Override public void onExecCommand(String command, List<VoiceUIVariable> variables) { Log.v(TAG, "onExecCommand() : " + command); switch (command) { case ScenarioDefinitions.FUNC_END_APP: finish(); break; case ScenarioDefinitions.FUNC_START_PROJECTOR: //TODO プロジェクタマネージャの開始(プロジェクター利用時のみ). //if(!isProjected) { // startService(getIntentForProjector()); //} break; default: break; } } /** * タイトルバーを設定する. */ private void setupTitleBar() { Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setActionBar(toolbar); } /** * プロジェクターマネージャーの開始/停止用のIntentを設定する. */ private Intent getIntentForProjector() { Intent intent = new Intent(); ComponentName componentName = new ComponentName( ProjectorManagerServiceUtil.PACKAGE_NAME, ProjectorManagerServiceUtil.CLASS_NAME); //逆方向で照射する intent.putExtra(ProjectorManagerServiceUtil.EXTRA_PROJECTOR_OUTPUT, ProjectorManagerServiceUtil.EXTRA_PROJECTOR_OUTPUT_VAL_REVERSE); //足元に照射する intent.putExtra(ProjectorManagerServiceUtil.EXTRA_PROJECTOR_DIRECTION, ProjectorManagerServiceUtil.EXTRA_PROJECTOR_DIRECTION_VAL_UNDER); intent.setComponent(componentName); return intent; } /** * プロジェクターの状態変化イベントを受け取るためのレシーバーをセットする. */ private void setProjectorEventReceiver() { Log.v(TAG, "setProjectorEventReceiver()"); if (mProjectorEventReceiver == null) { mProjectorEventReceiver = new ProjectorEventReceiver(); } else { return; } IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ProjectorManagerServiceUtil.ACTION_PROJECTOR_PREPARE); intentFilter.addAction(ProjectorManagerServiceUtil.ACTION_PROJECTOR_START); intentFilter.addAction(ProjectorManagerServiceUtil.ACTION_PROJECTOR_PAUSE); intentFilter.addAction(ProjectorManagerServiceUtil.ACTION_PROJECTOR_RESUME); intentFilter.addAction(ProjectorManagerServiceUtil.ACTION_PROJECTOR_END); intentFilter.addAction(ProjectorManagerServiceUtil.ACTION_PROJECTOR_END_ERROR); intentFilter.addAction(ProjectorManagerServiceUtil.ACTION_PROJECTOR_END_FATAL_ERROR); intentFilter.addAction(ProjectorManagerServiceUtil.ACTION_PROJECTOR_TERMINATE); registerReceiver(mProjectorEventReceiver, intentFilter); } /** * WakeLockを取得する. */ private void acquireWakeLock() { Log.v(TAG, "acquireWakeLock()"); PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE); synchronized (mLock) { if (mWakelock == null || !mWakelock.isHeld()) { mWakelock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, MainActivity.class.getName()); mWakelock.acquire(); } } } /** * WakeLockを開放する. */ private void releaseWakeLock() { Log.v(TAG, "releaseWakeLock()"); synchronized (mLock) { if (mWakelock != null && mWakelock.isHeld()) { mWakelock.release(); mWakelock = null; } } } /** * 顔検出実行用インテント取得関数 * * @param swing String型でTRUE or FALSE * @return 顔検出実行用intent */ private Intent getIntentForFaceDetection(String swing) { Intent intent = new Intent(FaceDetectionUtil.ACTION_FACE_DETECTION_MODE); intent.setPackage(FaceDetectionUtil.PACKAGE); intent.putExtra(FaceDetectionUtil.EXTRA_REPLYTO_ACTION, ACTION_RESULT_FACE_DETECTION); intent.putExtra(FaceDetectionUtil.EXTRA_REPLYTO_PKG, getPackageName()); intent.putExtra(FaceDetectionUtil.EXTRA_FACE_DETECTION_LENGTH, FaceDetectionUtil.EXTRA_FACE_DETECTION_LENGTH_NORMAL); intent.putExtra(FaceDetectionUtil.EXTRA_MOVE_HEAD, swing); return intent; } /** * 写真撮影実行用インテント取得関数 * * @param facedetect boolean型 * @return 写真撮影実行用intent */ private Intent getIntentForPhoto(boolean facedetect) { Intent intent = new Intent(ShootMediaUtil.ACTION_SHOOT_IMAGE); intent.setPackage(ShootMediaUtil.PACKAGE); intent.putExtra(ShootMediaUtil.EXTRA_FACE_DETECTION, facedetect); intent.putExtra(ShootMediaUtil.EXTRA_REPLYTO_ACTION, ACTION_RESULT_TAKE_PICTURE); intent.putExtra(ShootMediaUtil.EXTRA_REPLYTO_PKG, getPackageName()); //TODO 撮影対象指定する場合はContactIDを指定 //intent.putExtra(ShootMediaUtil.EXTRA_CONTACTID, ShootMediaUtil.EXTRA_CONTACTID_OWNER); return intent; } /** * 動画撮影実行用インテント取得関数 * * @param time int型(sec) * @return 動画撮影実行用intent */ private Intent getIntentForVideo(int time) { Intent intent = new Intent(ShootMediaUtil.ACTION_SHOOT_MOVIE); intent.setPackage(ShootMediaUtil.PACKAGE); intent.putExtra(ShootMediaUtil.EXTRA_MOVIE_LENGTH, time); intent.putExtra(ShootMediaUtil.EXTRA_REPLYTO_ACTION, ACTION_RESULT_REC_MOVIE); intent.putExtra(ShootMediaUtil.EXTRA_REPLYTO_PKG, getPackageName()); return intent; } /** * ダンス開始用のIntentを設定する. */ private Intent getIntentForDance(String type) { Intent intent = new Intent(DanceUtil.ACTION_REQUEST_DANCE); intent.putExtra(DanceUtil.EXTRA_REPLYTO_ACTION, ACTION_RESULT_DANCE); intent.putExtra(DanceUtil.EXTRA_REPLYTO_PKG, getPackageName()); intent.putExtra(DanceUtil.EXTRA_TYPE, type); if (type.equals(DanceUtil.EXTRA_TYPE_ASSIGN)) { intent.putExtra(DanceUtil.EXTRA_REQUEST_ID, 1); } return intent; } /** * ホームボタンの押下イベントを受け取るためのBroadcastレシーバークラス.<br> * <p/> * アプリは必ずホームボタンで終了する.. */ private class HomeEventReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.v(TAG, "Receive Home button pressed"); // ホームボタン押下でアプリ終了する. finish(); } } /** * 音声UI再起動イベントを受け取るためのBroadcastレシーバークラス.<br> * <p/> * 稀に音声UIのServiceが再起動することがあり、その場合アプリはVoiceUIの再取得とListenerの再登録をする. */ private class VoiceUIStartReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (VoiceUIManager.ACTION_VOICEUI_SERVICE_STARTED.equals(action)) { Log.d(TAG, "VoiceUIStartReceiver#onReceive():VOICEUI_SERVICE_STARTED"); //VoiceUIManagerのインスタンス取得. mVoiceUIManager = VoiceUIManager.getService(getApplicationContext()); if (mMainActivityVoiceUIListener == null) { mMainActivityVoiceUIListener = new MainActivityVoiceUIListener(getApplicationContext()); } //VoiceUIListenerの登録. VoiceUIManagerUtil.registerVoiceUIListener(mVoiceUIManager, mMainActivityVoiceUIListener); } } } /** * プロジェクターの状態変化時のイベントを受け取るためのBroadcastレシーバークラス.<br> * <p/> * 照射開始時にはWakeLockの取得、終了時にはWakeLockの開放する.<br> * アプリ仕様に応じて必要な処理があれば実装すること. */ private class ProjectorEventReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.v(TAG, "ProjectorEventReceiver#onReceive():" + intent.getAction()); switch (intent.getAction()) { case ProjectorManagerServiceUtil.ACTION_PROJECTOR_PREPARE: case ProjectorManagerServiceUtil.ACTION_PROJECTOR_PAUSE: case ProjectorManagerServiceUtil.ACTION_PROJECTOR_RESUME: break; case ProjectorManagerServiceUtil.ACTION_PROJECTOR_START: acquireWakeLock(); isProjected = true; break; case ProjectorManagerServiceUtil.ACTION_PROJECTOR_END: case ProjectorManagerServiceUtil.ACTION_PROJECTOR_END_FATAL_ERROR: case ProjectorManagerServiceUtil.ACTION_PROJECTOR_END_ERROR: case ProjectorManagerServiceUtil.ACTION_PROJECTOR_TERMINATE: releaseWakeLock(); isProjected = false; break; default: break; } } } /** * カメラ連携の結果を受け取るためのBroadcastレシーバー クラス.<br> * <p/> * それぞれの結果毎に処理を行う. */ private class CameraResultReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); Log.d(TAG, "CameraResultReceiver#onReceive() : " + action); switch (action) { case ACTION_RESULT_FACE_DETECTION: int result = intent.getIntExtra(FaceDetectionUtil.EXTRA_RESULT_CODE, FaceDetectionUtil.RESULT_CANCELED); break; case ACTION_RESULT_TAKE_PICTURE: result = intent.getIntExtra(ShootMediaUtil.EXTRA_RESULT_CODE, ShootMediaUtil.RESULT_CANCELED); break; case ACTION_RESULT_REC_MOVIE: result = intent.getIntExtra(ShootMediaUtil.EXTRA_RESULT_CODE, ShootMediaUtil.RESULT_CANCELED); break; default: break; } } } /** * ダンス実行結果を受け取るためのBroadcastレシーバー クラス.<br> * <p/> */ private class DanceResultReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { int result = intent.getIntExtra(DanceUtil.EXTRA_RESULT_CODE, DanceUtil.RESULT_CANCELED); if (result == DanceUtil.RESULT_OK) { // 正常に完了した場合. int id = intent.getIntExtra(DanceUtil.EXTRA_RESULT_ID, -1); String name = intent.getStringExtra(DanceUtil.EXTRA_RESULT_NAME); } } } }
52f6eff16d093d4646e044d5fb28d1fb32d7e2f5
40482d6955faf33cfa71122cc080fb3fbd7d5331
/src/test/java/org/wecancodeit/librarydemo/WebLayerTest.java
11ef0caf48f836a946931c6fde2502d66648d6c0
[]
no_license
CaitlynSendelbach/ReviewSiteFullStack
fac07a1271b706b174198a0e9d4e67d9eaa1dc02
97bb1eb9359a6678bb40df31cc46cb75fa9f0be7
refs/heads/master
2022-11-08T12:05:53.127945
2020-06-22T22:33:01
2020-06-22T22:33:01
274,255,666
0
0
null
null
null
null
UTF-8
Java
false
false
3,583
java
package org.wecancodeit.librarydemo; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import org.wecancodeit.librarydemo.models.Actor; import org.wecancodeit.librarydemo.models.Category; import org.wecancodeit.librarydemo.models.Review; import org.wecancodeit.librarydemo.repositories.ActorRepository; import org.wecancodeit.librarydemo.repositories.ReviewRepository; import org.wecancodeit.librarydemo.repositories.CategoryRepository; import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @ExtendWith(SpringExtension.class) @WebMvcTest public class WebLayerTest { @MockBean private CategoryRepository categoryRepo; @MockBean private ReviewRepository reviewRepo; @MockBean private ActorRepository actorRepo; @Autowired private MockMvc mockMvc; @Test public void categoriesShouldBeOkAndReturnCategoriesViewWithCategoriesModelAttribute() throws Exception { mockMvc.perform(get("/categories")) .andDo(print()) .andExpect(status().isOk()) .andExpect(view().name("categoriesView")) .andExpect(model().attributeExists("categories")); } @Test public void reviewsShouldBeOkAndReturnReviewsViewWithReviewsModelAttribute() throws Exception { mockMvc.perform(get("/reviews")) .andDo(print()) .andExpect(status().isOk()) .andExpect(view().name("reviewsView")) .andExpect(model().attributeExists("reviews")); } @Test public void actorsShouldBeOkAndReturnActorsViewWithActorsModelAttribute() throws Exception { mockMvc.perform(get("/actors")) .andDo(print()) .andExpect(status().isOk()) .andExpect(view().name("actorsView")) .andExpect(model().attributeExists("actors")); } @Test public void shouldBeOkForASingleCategoryEndpointWithCategoryViewAndCategoryModelAttribute() throws Exception { Category testCategory = new Category("Original"); when(categoryRepo.findCategoryByLocation("Original")).thenReturn(testCategory); mockMvc.perform(get("/category/Original")) .andExpect(status().isOk()) .andExpect(view().name("categoryView")) .andExpect(model().attributeExists("category")); } @Test public void shouldBeOkForASingleReviewEndpointWithReviewViewAndReviewModelAttribute() throws Exception { Category testCategory = new Category("Prequel"); Actor testActor = new Actor("First", "Last"); Review testReview = new Review("Title", "Description", testCategory, "Content", testActor); when(reviewRepo.findById(1L)).thenReturn(java.util.Optional.of(testReview)); mockMvc.perform(get("/reviews/1")) .andExpect(status().isOk()) .andExpect(view().name("reviewView")) .andExpect(model().attributeExists("review")); } }
6d41b44c7bfdf136af4939fa75f61a8a496d54d1
af3583bdee48e95649a4c72d5f97bb9f02ec17a4
/MyApplication/src/main/java/com/app/service/UserServiceImpl.java
66efda3b1e21d94a299568826a2b29d2bf0621e5
[]
no_license
akshayInfo/git-github
bda151381d3138cacf1f48797d422217e9b3814c
e97c7249e309a3e0527b343a43485b7696a11e40
refs/heads/master
2020-03-07T10:45:26.134679
2018-04-08T15:38:36
2018-04-08T15:38:36
127,438,965
1
4
null
2018-04-08T15:38:37
2018-03-30T14:46:19
Java
UTF-8
Java
false
false
957
java
package com.app.service; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.app.dao.UserDAO; import com.app.model.User; @Service public class UserServiceImpl implements UserService { @Autowired private UserDAO userDAO; @Override @Transactional public User add(User p){ System.out.println("in dao implemention"); User addedUser = this.userDAO.add(p); return addedUser; } @Override @Transactional public User update(User p){ User updatedUser = this.userDAO.update(p); return updatedUser; } @Override @Transactional public List<User> list() { return this.userDAO.list(); } @Override @Transactional public User getById(int id) { return this.userDAO.getById(id); } @Override @Transactional public User remove(int id) { return this.userDAO.remove(id); } }
32fbb62f6ffe6d0ab6bcfbe93ddeb001fc5ed4c9
53ab804baef1e5be358d6e265b4d48393ec58a4a
/src/main/java/org/modelio/microservicesnetcore/impl/MicroserviceDotnetCoreModule.java
7c4b12933f934fe381ab3d8930a132ae27c5a9d1
[]
no_license
geogeocutcut/microservicesnetcore
cac24b4d0bd4007f836c0522f9d8fcc925d2ac02
f89c4f76878694de3aecf6fa9054e2afedb0beb1
refs/heads/master
2022-12-16T09:01:09.770593
2019-07-05T15:32:28
2019-07-05T15:32:28
156,298,687
0
0
null
2022-12-08T04:45:50
2018-11-05T23:44:25
Java
UTF-8
Java
false
false
3,578
java
package org.modelio.microservicesnetcore.impl; import org.modelio.api.module.AbstractJavaModule; import org.modelio.api.module.context.IModuleContext; import org.modelio.api.module.lifecycle.IModuleLifeCycleHandler; import org.modelio.api.module.parameter.IParameterEditionModel; /** * Implementation of the IModule interface. * <br>All Modelio java modules should inherit from this class. * */ public class MicroserviceDotnetCoreModule extends AbstractJavaModule { private MicroserviceDotnetCorePeerModule peerModule = null; private MicroserviceDotnetCoreLifeCycleHandler lifeCycleHandler = null; private static MicroserviceDotnetCoreModule instance; public static MicroserviceDotnetCoreModule getInstance() { return instance; } @Override public MicroserviceDotnetCorePeerModule getPeerModule() { return this.peerModule; } /** * Return the lifecycle handler attached to the current module. * <p> * <p> * This handler is used to manage the module lifecycle by declaring the * desired implementation on start, select... methods. */ @Override public IModuleLifeCycleHandler getLifeCycleHandler() { return this.lifeCycleHandler; } /** * Method automatically called just after the creation of the module. * <p> * <p> * The module is automatically instanciated at the beginning of the MDA * lifecycle and constructor implementation is not accessible to the module * developer. * <p> * <p> * The <code>init</code> method allows the developer to execute the desired initialization code at this step. For * example, this is the perfect place to register any IViewpoint this module provides. * * * @see org.modelio.api.module.AbstractJavaModule#init() */ @Override public void init() { // Add the module initialization code super.init(); } /** * Method automatically called just before the disposal of the module. * <p> * <p> * * * The <code>uninit</code> method allows the developer to execute the desired un-initialization code at this step. * For example, if IViewpoints have been registered in the {@link #init()} method, this method is the perfect place * to remove them. * <p> * <p> * * This method should never be called by the developer because it is already invoked by the tool. * * @see org.modelio.api.module.AbstractJavaModule#uninit() */ @Override public void uninit() { // Add the module un-initialization code super.uninit(); } /** * Builds a new module. * <p> * <p> * This constructor must not be called by the user. It is automatically * invoked by Modelio when the module is installed, selected or started. * @param moduleContext context of the module, needed to access Modelio features. */ public MicroserviceDotnetCoreModule(IModuleContext moduleContext) { super(moduleContext); MicroserviceDotnetCoreModule.instance = this; this.lifeCycleHandler = new MicroserviceDotnetCoreLifeCycleHandler(this); this.peerModule = new MicroserviceDotnetCorePeerModule(this, moduleContext.getPeerConfiguration()); } /** * @see org.modelio.api.module.AbstractJavaModule#getParametersEditionModel() */ @Override public IParameterEditionModel getParametersEditionModel() { if (this.parameterEditionModel == null) { this.parameterEditionModel = super.getParametersEditionModel(); } return this.parameterEditionModel; } @Override public String getModuleImagePath() { return "/res/icons/module_16.png"; } }
50e098fb1ee89c1ce1e383eabddfab10babdf422
698ccaaf4e4bbae6a7e13f62180278e3a07e9791
/programming/strings/string-simulation/LongestCommonPrefix.java
71a4261e46f336a07d19d2efed43982967f19b58
[ "MIT" ]
permissive
Ankit-555/Interview-Bit-1
3e3cc905b23f94977cea843d4612890c2bd9a553
735e625c2bae0922dd3e80dd2facefb3da98e86b
refs/heads/master
2020-08-29T09:31:31.732592
2019-10-28T08:04:36
2019-10-28T08:04:36
217,994,363
0
0
MIT
2019-10-28T08:00:22
2019-10-28T08:00:22
null
UTF-8
Java
false
false
748
java
// https://www.interviewbit.com/problems/longest-common-prefix/ public class Solution { public String longestCommonPrefix(ArrayList<String> A) { if (A.size() == 0) return ""; if (A.size() == 1) return A.get(0); StringBuilder sb = new StringBuilder(); for (int i = 0; ; i++) { if (i >= A.get(0).length()) break; char c = A.get(0).charAt(i); int j = 1; for (; j < A.size(); j++) { if (i >= A.get(j).length() || A.get(j).charAt(i) != c) break; } if (j == A.size()) sb.append(c); else break; } return sb.toString(); } }
e38639a92fe43ac78ed7ee1ba83171f2959d3335
74d739caf1a2ac7ee5de9eccdd0a4b395fdf3546
/src/leetcode/problem_62.java
ae8f69bf1d99cce081ac77db9ea783b12a630f37
[]
no_license
tongtongdi/myword
e64fab85e50e6c5fd12f7a5dd0e94cc2a8ed7f53
cf7eb1834484199b028537941a4de27f05d12435
refs/heads/master
2021-06-14T12:03:34.106295
2021-06-05T12:55:36
2021-06-05T12:55:36
195,362,719
0
0
null
null
null
null
UTF-8
Java
false
false
414
java
package leetcode; /** * @Description: * @Date: 2019/7/22 * @Author 王通 * @Version 1.0 */ public class problem_62 { public static int uniquePaths(int m, int n) { if(n==1) return 1; if(m==1) return 1; return uniquePaths(m-1,n)+uniquePaths(m,n-1); } public static void main(String[] args) { System.out.println(uniquePaths(7,3)); } }
49d819d2a82f1e01b68b7d042894861f09177f8a
662b6ef8fd0eeab67303b0322a0404145c924a6b
/src/org/demo/custon_view/NinePointLineView.java
1b94dfae21582d66a10d349e106bd3a299468f69
[]
no_license
jialong-google/keykeeper
197ef12078de032e21972ed753a31590a1c2d64f
a20e794f4040ffc09e590f4b9f5920fc4272d858
refs/heads/master
2021-10-29T08:05:28.925137
2014-01-16T16:14:01
2014-01-16T16:14:01
null
0
0
null
null
null
null
UTF-8
Java
false
false
14,712
java
package org.demo.custon_view; import org.demo.custon_view.GesturePassActivity.ImageAdapter; import org.demo.utils.MLog; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.BitmapFactory.Options; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Paint.Cap; import android.graphics.Rect; import android.graphics.Typeface; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; public class NinePointLineView extends View { Paint linePaint = new Paint(); Paint whiteLinePaint = new Paint(); Paint textPaint = new Paint(); // 由于两个图片都是正方形,所以获取一个长度就行了 // Bitmap defaultBitmap = BitmapFactory.decodeResource(getResources(), // R.drawable.pattern_grid_normal); Bitmap defaultBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.lock); int defaultBitmapRadius = defaultBitmap.getWidth() / 2; // 初始化被选中图片的直径、半径 Bitmap selectedBitmap = scaleBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.indicator_lock_area),0.8f,0.8f); // Bitmap selectedBitmap = BitmapFactory.decodeResource(getResources(), // R.drawable.pattern_grid_focused); int selectedBitmapDiameter = selectedBitmap.getWidth(); int selectedBitmapRadius = selectedBitmapDiameter / 2; // 定义好9个点的数组 PointInfo[] points = new PointInfo[9]; // 相应ACTION_DOWN的那个点 PointInfo startPoint = null; // 屏幕的宽高 int width, height; // 当ACTION_MOVE时获取的X,Y坐标 int moveX, moveY; // 是否发生ACTION_UP boolean isUp = false; // 最终生成的用户锁序列 StringBuffer lockString = new StringBuffer(); //尝试的次数 int inputCount=4; public NinePointLineView(Context context) { super(context); this.setBackgroundColor(Color.WHITE); initPaint(); } /*private byte[] Bitmap2Bytes(Bitmap bm){ ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100, baos); return baos.toByteArray(); } */ public static Bitmap getBitmap(byte[] data, int scale) { Options opts = new Options(); opts.inSampleSize = scale; return BitmapFactory.decodeByteArray(data, 0, data.length, opts); } private Bitmap scaleBitmap(Bitmap bm,float scaleX,float scaleY){ Matrix matrix=new Matrix(); matrix.setScale(scaleX, scaleY); return Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(),matrix,true); } public NinePointLineView(Context context, AttributeSet attrs) { super(context, attrs); SharedPreferences preferences = context.getSharedPreferences( "angellpay", context.MODE_WORLD_READABLE); pass=preferences.getString("gesturePass", null); if(pass!=null)System.out.println(pass); this.setBackgroundColor(Color.WHITE); initPaint(); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { MLog.i("onMeasure"); // 初始化屏幕大小 width = getWidth(); height = getHeight(); if (width != 0 && height != 0) { initPoints(points); } MLog.i("width、height = " + width + "、" + height); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } @Override protected void onLayout(boolean changed, int left, int top, int right,int bottom) { MLog.i("onLayout"); super.onLayout(changed, left, top, right, bottom); } private int startX = 0, startY = 0; boolean show=false; boolean isWrong=false; boolean isWrong1=false; boolean isDownIn=false; boolean isUpIn=false; String pass=null; //////////!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @Override protected void onDraw(Canvas canvas) { if(isDownIn&&isUpIn){ isUpIn=false; /*isTouch=false;*/ String text=""; int textWidth=0; //设置密码 if((show||isWrong)){//长度小于四show或密码改写错误isWrong text="设置的密码长度最小是4,请重绘"; Rect rect=new Rect(); if(isWrong){//长度不小于四,只是密码改写错误,立马切换text内容 text="两次设定结果不相同,请输入初次修改的密码"; } textPaint.getTextBounds(text, 0, text.length(), rect); textWidth=rect.width(); // canvas.drawText("用户的滑动顺序:" + lockString, 0, 40, textPaint); // canvas.drawText(text, (width-textWidth)/2, 40, textPaint); isWrong=false; } //验证密码////////////////////////// else if((isWrong1||show)){ Rect rect=new Rect(); //text="设置的密码长度最小是4,请重绘!"; if(isWrong1 ){ text="密码错误,还可以再输入"+(inputCount--)+"次!"; if(inputCount==3) text=" "; } textPaint.getTextBounds(text, 0, text.length(), rect); textWidth=rect.width(); isWrong1=false; } canvas.drawText(text, (width-textWidth)/2, 40, textPaint); } if (moveX != 0 && moveY != 0 && startX != 0 && startY != 0) { // 绘制当前活动的线段 drawLine(canvas, startX, startY, moveX, moveY); } drawNinePoint(canvas); super.onDraw(canvas); } ////////!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! private ImageAdapter adapter; public void setAdapter(ImageAdapter adapter){ this.adapter=adapter; } // 记住,这个DOWN和MOVE、UP是成对的,如果没从UP释放,就不会再获得DOWN; // 而获得DOWN时,一定要确认消费该事件,否则MOVE和UP不会被这个View的onTouchEvent接收 @Override public boolean onTouchEvent(MotionEvent event) { boolean flag = true; if (isUp) {// 如果已滑完,重置每个点的属性和lockString /*finishDraw(); // 当UP后,要返回false,把事件释放给系统,否则无法获得Down事件 flag = false;*/ } else {// 没滑完,则继续绘制 handlingEvent(event); // 这里要返回true,代表该View消耗此事件,否则不会收到MOVE和UP事件 flag = true; } return flag; } private void handlingEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_MOVE: moveX = (int) event.getX(); moveY = (int) event.getY(); MLog.i("onMove:" + moveX + "、" + moveY); for (PointInfo temp : points) { if (temp.isInMyPlace(moveX, moveY) && temp.isNotSelected()) { temp.setSelected(true); startX = temp.getCenterX(); startY = temp.getCenterY(); int len = lockString.length(); if (len != 0) { int preId = lockString.charAt(len - 1) - 48; points[preId].setNextId(temp.getId()); } lockString.append(temp.getId()); break; } } invalidate(0, height - width, width, height); break; case MotionEvent.ACTION_DOWN: int downX = (int) event.getX(); int downY = (int) event.getY(); MLog.i("onDown:" + downX + "、" + downY); isDownIn=false; for (PointInfo temp : points) { if (temp.isInMyPlace(downX, downY)) { System.out.println("ISDownIn "+isDownIn); isDownIn=true; temp.setSelected(true); startPoint = temp; startX = temp.getCenterX(); startY = temp.getCenterY(); lockString.append(temp.getId()); break; } } invalidate(0, height - width, width, height); break; case MotionEvent.ACTION_UP: MLog.i("onUp"); isUpIn=isDownIn; System.out.println("asf:"+isDownIn+" "+isUpIn); startX = startY = moveX = moveY = 0; isUp = true; invalidate(); int result=0; System.out.println(pass+" "+lockString.toString()); if(inputCount<=0){//不允许再次输入! //SharedPreferences preferences = getContext().getSharedPreferences("angellpay", getContext().MODE_WORLD_READABLE); //SharedPreferences.Editor editor = preferences.edit(); //editor.putString("gesturePass", null);////////销毁密码? //editor.commit(); Intent intent=new Intent(getContext(), MainActivity.class); if(activity!=null){ activity.startActivity(intent); activity.finish(); } return ; } if(pass!=null&&pass.equals(lockString.toString())&&inputCount>0){ // Toast.makeText(getContext(), "输入成功", 1).show(); Intent intent=new Intent(getContext(), SecondActivity.class); if(activity!=null){ activity.startActivity(intent); activity.finish(); } } if(pass!=null && !pass.equals(lockString.toString())){ isWrong1=true;//pass不为空 且pass不等于lockString 即错误 }else{ isWrong1=false; } if(adapter!=null) result=adapter.change(new StringBuffer(lockString.toString()));//用lockString来改写密码。 if(result==-1){//change的结果不对。 isWrong=true;//此时应该显示两次设定结果不相同 }else{ isWrong=false; } if(lockString.length()<4){ show=true;//长度小于4的非法锁屏序列 } else{ show=false; } finishDraw(); break; default: MLog.i("收到其他事件!!"); break; } } Activity activity; public void setActivity(Activity activity){ this.activity=activity; } private void finishDraw() { for (PointInfo temp : points) { temp.setSelected(false); temp.setNextId(temp.getId()); } lockString.delete(0, lockString.length()); isUp = false; isFinishDraw=true; invalidate(); } boolean isFinishDraw=false; private void initPoints(PointInfo[] points) { int len = points.length; int seletedSpacing = (width - selectedBitmapDiameter * 3) / 4; // 被选择时显示图片的左上角坐标 int seletedX = seletedSpacing; int seletedY = height - width + seletedSpacing; // 没被选时图片的左上角坐标 int defaultX = seletedX + selectedBitmapRadius - defaultBitmapRadius; int defaultY = seletedY + selectedBitmapRadius - defaultBitmapRadius; // 绘制好每个点 for (int i = 0; i < len; i++) { if (i == 3 || i == 6) { seletedX = seletedSpacing; seletedY += selectedBitmapDiameter + seletedSpacing; defaultX = seletedX + selectedBitmapRadius - defaultBitmapRadius; defaultY += selectedBitmapDiameter + seletedSpacing; } points[i] = new PointInfo(i, defaultX, defaultY, seletedX, seletedY); seletedX += selectedBitmapDiameter + seletedSpacing; defaultX += selectedBitmapDiameter + seletedSpacing; } } private void initPaint() { initLinePaint(linePaint); initTextPaint(textPaint); initWhiteLinePaint(whiteLinePaint); } /** * 初始化文本画笔 * @param paint */ private void initTextPaint(Paint paint) { textPaint.setTextSize(24); textPaint.setColor(Color.RED); textPaint.setAntiAlias(true); textPaint.setTypeface(Typeface.MONOSPACE); } /** * 初始化黑线画笔 * * @param paint */ private void initLinePaint(Paint paint) { paint.setColor(Color.GRAY); paint.setStrokeWidth(defaultBitmap.getWidth()); paint.setAntiAlias(true); paint.setStrokeCap(Cap.ROUND); } /** * 初始化白线画笔 * * @param paint */ private void initWhiteLinePaint(Paint paint) { paint.setColor(Color.WHITE); paint.setStrokeWidth(defaultBitmap.getWidth() - 5); paint.setAntiAlias(true); paint.setStrokeCap(Cap.ROUND); } /** * 绘制已完成的部分 * * @param canvas */ private void drawNinePoint(Canvas canvas) { if (startPoint != null) { drawEachLine(canvas, startPoint); } try { if(points!=null&&points.length!=0) // 绘制每个点的图片 for (PointInfo pointInfo : points) { if (pointInfo!=null&&pointInfo.isSelected()) {// 绘制大圈 canvas.drawBitmap(selectedBitmap, pointInfo.getSeletedX(), pointInfo.getSeletedY(), null); } // 绘制点 canvas.drawBitmap(defaultBitmap, pointInfo.getDefaultX(), pointInfo.getDefaultY(), null); } } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } /** * 递归绘制每两个点之间的线段 * * @param canvas * @param point */ private void drawEachLine(Canvas canvas, PointInfo point) { if (point.hasNextId()) { int n = point.getNextId(); drawLine(canvas, point.getCenterX(), point.getCenterY(), points[n].getCenterX(), points[n].getCenterY()); // 递归 drawEachLine(canvas, points[n]); } } /** * 先绘制黑线,再在上面绘制白线,达到黑边白线的效果 * * @param canvas * @param startX * @param startY * @param stopX * @param stopY */ private void drawLine(Canvas canvas, float startX, float startY, float stopX, float stopY) { canvas.drawLine(startX, startY, stopX, stopY, linePaint); canvas.drawLine(startX, startY, stopX, stopY, whiteLinePaint); } /** * 用来表示一个点 * * @author zkwlx * */ private class PointInfo { // 一个点的ID private int id; // 当前点所指向的下一个点的ID,当没有时为自己ID private int nextId; // 是否被选中 private boolean selected; // 默认时图片的左上角X坐标 private int defaultX; // 默认时图片的左上角Y坐标 private int defaultY; // 被选中时图片的左上角X坐标 private int seletedX; // 被选中时图片的左上角Y坐标 private int seletedY; public PointInfo(int id, int defaultX, int defaultY, int seletedX, int seletedY) { this.id = id; this.nextId = id; this.defaultX = defaultX; this.defaultY = defaultY; this.seletedX = seletedX; this.seletedY = seletedY; } public boolean isSelected() { return selected; } public boolean isNotSelected() { return !isSelected(); } public void setSelected(boolean selected) { this.selected = selected; } public int getId() { return id; } public int getDefaultX() { return defaultX; } public int getDefaultY() { return defaultY; } public int getSeletedX() { return seletedX; } public int getSeletedY() { return seletedY; } public int getCenterX() { return seletedX + selectedBitmapRadius; } public int getCenterY() { return seletedY + selectedBitmapRadius; } public boolean hasNextId() { return nextId != id; } public int getNextId() { return nextId; } public void setNextId(int nextId) { this.nextId = nextId; } /** * 坐标(x,y)是否在当前点的范围内 * * @param x * @param y * @return */ public boolean isInMyPlace(int x, int y) { boolean inX = x > seletedX && x < (seletedX + selectedBitmapDiameter); boolean inY = y > seletedY && y < (seletedY + selectedBitmapDiameter); return (inX && inY); } } }
7553bec547c06efc27f780bf0cf4559ccf8db508
b187dc8bd7f3d589f2c3fa970808016aec94e8a9
/src/main/java/com/example/wap/models/Enrollment.java
1ba7d4584fb8e165e409357a7b3b5e06b31e2940
[]
no_license
averywpx/CS3200-fall20-Wang-Peixin
9c8d72aa50701e768a3689634708d793b07f59d0
170fdc2ac5f9878e4bed5bb333db8c3ca6ccd1ae
refs/heads/master
2023-02-01T13:51:34.161610
2020-12-18T20:30:08
2020-12-18T20:30:08
319,148,761
0
0
null
null
null
null
UTF-8
Java
false
false
1,330
java
package com.example.wap.models; import com.fasterxml.jackson.annotation.JsonIgnore; import javax.persistence.*; @Entity @Table(name="enrollments") @IdClass(EnrollmentId.class) public class Enrollment { @Id private Integer studentId; @Id private Integer clubId; private boolean isPresident; @ManyToOne @PrimaryKeyJoinColumn(name="studentId", referencedColumnName="studentId") @JsonIgnore private Student student; @ManyToOne @PrimaryKeyJoinColumn(name="clubId", referencedColumnName="clubId") @JsonIgnore private Club club; public Integer getStudentId() { return studentId; } public void setStudentId(Integer studentId) { this.studentId = studentId; } public Integer getClubId() { return clubId; } public void setClubId(Integer clubId) { this.clubId = clubId; } public Student getStudent() { return student; } public void setStudent(Student student) { this.student = student; } public Club getClub() { return club; } public void setClub(Club club) { this.club = club; } public boolean isPresident() { return isPresident; } public void setPresident(boolean president) { isPresident = president; } }
7cdf68f69079c882be426bd948b44524aafe5906
e042a9e77c3e1a3c3ccae2cd9131bf27d1177ae6
/moduleSystem/DropdownModListGui.java
4447e8191bb9a485f48319844aeb979c36455b4d
[]
no_license
mcModderMan/Skybot
ccc84f821e50b9434951389fa469a04ed2277cca
cbb7bd189e5f771c54f55700f9bea50e87c73132
refs/heads/master
2022-12-01T08:27:56.891432
2020-08-19T09:29:27
2020-08-19T09:29:27
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,050
java
package inowen.moduleSystem; import inowen.SkyBotMod; import net.minecraft.client.Minecraft; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; /** * Shows a gui with the toggled modules. * * @author PrinceChaos */ @Mod.EventBusSubscriber(modid= SkyBotMod.MOD_ID, value= Dist.CLIENT, bus= Mod.EventBusSubscriber.Bus.FORGE) public class DropdownModListGui { private static Minecraft mc = Minecraft.getInstance(); @SubscribeEvent public static void showModsDropdown(RenderGameOverlayEvent event) { // Draw big title mc.fontRenderer.drawStringWithShadow("SkyBot", 1, 1, 0x0000aa); int currentY = 11; for (Module m : ModuleManager.getModules()) { if (m.isToggled()) { mc.fontRenderer.drawString(m.name, 1, currentY, 0xffffff); currentY += mc.fontRenderer.FONT_HEIGHT; } } } }
c1b801a61fffb3284083dd10ff337006f5ebafbf
21202f4e01dada37ab89e2d0c97e61571fa4597a
/app/src/main/java/com/handen/trends/ClientInterface.java
b94580c08dd48b83ce2547d52b8d1c71d39f6701
[]
no_license
IvanPletinskiy/ytrmfd
8854e5f5cba6e07ed8941ccc891c26bff770ee1e
ea5fa96ac1cd53e2b55ae4d9d0e1176f2770cf9a
refs/heads/master
2021-09-06T22:17:46.611138
2018-02-12T11:36:53
2018-02-12T11:36:53
null
0
0
null
null
null
null
UTF-8
Java
false
false
8,030
java
package com.handen.trends; import com.handen.trends.data.Category; import com.handen.trends.data.Comment; import com.handen.trends.data.Post; import com.handen.trends.data.User; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.HashSet; /** * Created by Vanya on 21.10.2017. */ public class ClientInterface { public static ArrayList<Post> postsTable; public static ArrayList<User> usersTable; public static ArrayList<Comment> commentsTable = new ArrayList<>(); public static ArrayList<Category> categoriesTable; /** * Первый аргумент userId, второй postId */ public static HashMap<Long, HashSet<Long>> likesTable = new HashMap<>(); /** * Первый аргумент userId, второй postId */ public static HashMap<Long, HashSet<Long>> viewsTable = new HashMap<>(); public static int lastPostId = 49; public static int currentUserId = 1; public static final int POST_BONUS = 25; public static final float POST_IS24BONUS = 1.5f; static { postsTable = new ArrayList<>(); Category category = new Category("Обо всём"); usersTable = new ArrayList<>(); usersTable.add(new User(1, 1, "Профиль 1", new Date())); usersTable.get(0).setDescription("Это описание #1"); usersTable.add(new User(2, 2, "Профиль 2", new Date())); usersTable.get(1).setDescription("Это описание #2"); usersTable.add(new User(3, 3, "Профиль 2", new Date())); usersTable.get(2).setDescription("Это описание #3"); usersTable.add(new User(2, 0, "Профиль 0", new Date())); usersTable.get(2).setDescription("Одмен"); categoriesTable = new ArrayList<>(); categoriesTable.add(new Category("Котики")); categoriesTable.add(new Category("Дни рождения")); categoriesTable.add(new Category("Dota 2")); categoriesTable.add(new Category("Политика")); categoriesTable.add(new Category("Экономика")); for (int i = 0; i < 20; i++) { int random = (int) (Math.random() * 100); postsTable.add(new Post( Integer.toString(random), categoriesTable.get((int) (Math.random() * categoriesTable.size())), Integer.toString(random), new ArrayList<>(Arrays.asList(Integer.toString(random))), true, 24 + i, 1, random, random)); for(int j = 0; j < 3; j++) { int id = i * 3 + j; commentsTable.add(new Comment("Это коммент №" + Integer.toString(id), new Date(), id,24 + i, j)); } } } static public ArrayList<Post> getPosts(int region) { ArrayList<Post> ret = new ArrayList<>(); //Если возвращаем посты для всех регионов if (region == 0) { ret = postsTable; } else { for (Post post : postsTable) { long userId = post.getUserId(); // User user = usersTable.get((int) (userId)); //TODO происходит преобразование long в int if (getUser(userId).getRegion() == region) ret.add(post); } } return ret; } static public ArrayList<Post> getSubscribedPosts() { return postsTable; } static public ArrayList<Post> getUserPosts(long userId) { ArrayList<Post> ret = new ArrayList<>(); for (Post post : postsTable) { if (post.getUserId() == userId) ret.add(post); } return ret; } static public void likePost(long postId) { if (likesTable.containsKey((long) currentUserId)) { likesTable.get((long) currentUserId).add(postId); } else { HashSet<Long> set = new HashSet<>(); set.add(postId); likesTable.put((long) currentUserId, set); } for (Post post : postsTable) { if (post.getId() == postId) { post.setLikes(post.getLikes() + 1); } } } static public void unlikePost(long postId) { likesTable.get((long) currentUserId).remove(postId); for (Post post : postsTable) { if (post.getId() == postId) { post.setLikes(post.getLikes() - 1); } } } static public void viewPost(long postId) { if (viewsTable.containsKey((long) currentUserId)) { viewsTable.get((long) currentUserId).add(postId); } else { HashSet<Long> set = new HashSet<>(); set.add(postId); viewsTable.put((long) currentUserId, set); } for (Post post : postsTable) { if (post.getId() == postId) { post.setViews(post.getViews() + 1); } } } static public boolean isLiked(long postId) { boolean isFound = false; if (likesTable.containsKey((long) currentUserId) && likesTable.get((long) currentUserId).contains(postId)) { isFound = true; } return isFound; } static public boolean isViewed(long postId) { boolean isFound = false; if (viewsTable.containsKey((long) currentUserId) && viewsTable.get((long) currentUserId).contains(postId)) { isFound = true; } return isFound; } static public ArrayList<Post> getLiked() { ArrayList<Post> ret = new ArrayList<>(); HashSet<Long> set = likesTable.get((long) currentUserId); if (set == null || set.size() == 0) return ret; for (Long postId : set) { for (Post post : postsTable) { if (postId == post.getId()) ret.add(post); } } return ret; } static public void deletePost(long postId) { int deletingPostIndex = -1; for (Post post : postsTable) { if (post.getId() == postId) { deletingPostIndex = postsTable.indexOf(post); break; } } postsTable.remove(deletingPostIndex); } //TODO 30.12.2017 Добавить Category и Tags в этот метод static public void updatePost(long postId, String title, String text) { for (Post post : postsTable) { if (post.getId() == postId) { post.setTitle(title); post.setText(text); } } } static public ArrayList<Comment> getComments(long postId) { ArrayList<Comment> ret = new ArrayList<>(); for(Comment comment : commentsTable) { if(comment.getPostId() == postId) ret.add(comment); } return ret; } static public void writeComment(long postId, Comment comment) { } static public void likeComment(long commentId) { } static public String register(String nickName, String email, String password) { return "OK"; } static public String signIn(String email, String password) { return "OK"; } static public void logout() { } static public void writePost(String title, Category category, String text, ArrayList<String> tags, boolean is24hours) { postsTable.add(new Post(title, category, text, tags, is24hours, ++lastPostId, currentUserId)); } static public String subscribe(int userId) { return "OK"; } static public ArrayList<Category> getCategories() { return categoriesTable; } static public User getUser(long userId) { for (User user : usersTable) { if (user.getId() == userId) return user; } return null; } }
4d2d5872f65b9f4fcd6d49058be05a8cab41254b
5313da0fe742f03a4b065f28354bdf1d30d68886
/src/main/java/com/angejia/dw/hive/udtf/UdtfDemo.java
8d1f1ff6ce217e8386fc42ec517f892283f7ad41
[]
no_license
fanzw123/dw_hive_udf
dcd4ef96f841575518f1396f65aeba08e7281092
5fa915a221b60fa2d573b208ffeb55bedf8767bf
refs/heads/master
2020-12-30T14:19:18.108246
2017-02-10T09:07:54
2017-02-10T09:07:54
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,242
java
package com.angejia.dw.hive.udtf; import java.util.ArrayList; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.metadata.HiveException; import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory; import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; /** * @author Jason * 原理思路 * 1. 继承 GenericUDTF 实现 initialize, process, close 三个方法 * 2. UDTF 首先会调用 initialize 方法,此方法返回 UDTF 的返回行的信息(返回个数,类型) * 3. initialize 后, 会调用 process 方法, 真正的处理过程在 process 函数中 * 在 process 中每一次 forward() 调用产生一行;如果产生多列可以将多个列的值放在一个数组中,然后将该数组传入到 forward() 函数 * 4. 最后 close() 方法调用,对需要清理的方法进行清理。 * * hive 中使用的案例 * 1. 添加 jar 和 临时函数 * add jar /path/xxx.jar; * create temporary function udtf_demo as 'com.angejia.dw.hive.udtf.UdtfDemo'; * 2. 创建测试数据 * create table dw_db_temp.src AS select "a:1-b:2" AS properties; * 3. 测试 * 测试列转行 * select udtf_demo('a:1-b:2') as (key,value); * * 测试表字段列转行 * select key,value from dw_db_temp.src lateral view udtf_demo(properties) now_list AS key, value ; * */ public class UdtfDemo extends GenericUDTF { /** * 返回 UDTF 的返回行的信息(字段名,字段类型) * */ @Override public StructObjectInspector initialize(ObjectInspector[] args) throws UDFArgumentException { if (args.length != 1) { throw new UDFArgumentLengthException("ExplodeMap takes only one argument"); } if (args[0].getCategory() != ObjectInspector.Category.PRIMITIVE) { throw new UDFArgumentException("ExplodeMap takes string as a parameter"); } // 保存字段名 ArrayList<String> fieldNames = new ArrayList<String>(); // 保存字段家 ArrayList<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>(); // 增加字段名为 col1 的字段 fieldNames.add("col1"); // 字段名 fieldOIs.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector); // 字段类型 // 以下是重复的套路!!! fieldNames.add("col2"); fieldOIs.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector); // 最后返回 (字段名, 字段类型) return ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames, fieldOIs); } /** * 具体干活的小伙子! * process 方法, 真正的处理过程在 process 函数中 * 在 process 中每一次 forward() 调用产生一行;如果产生多列可以将多个列的值放在一个数组中,然后将该数组传入到 forward() 函数 */ @Override public void process(Object[] args) throws HiveException { String input = args[0].toString(); // 按照 ; 号分割 String[] test = input.split("-"); for(int i=0; i<test.length; i++) { try { String[] result = test[i].split(":"); // System.out.println(result); // 生成一行 forward(result); } catch (Exception e) { continue; } } } /** * 处理完成后的关闭流程 */ @Override public void close() throws HiveException { } public static void main(String[] args) throws Exception{ // 获取传入的值, key:value;key:value; Object[] argdss = {"key:value-key:value"}; UdtfDemo obj = new UdtfDemo(); obj.process(argdss); } }
bed03ec7962d99d97262689b7e3b1fb31816512b
fd948cb5a4b449148193eb997eceaf96bca1bd60
/java/4.referance/src/enumType/Week.java
d4833ce5ae0c87f39e1e94fa26d3388608fe3359
[]
no_license
minje94/kitri
a6659b728b636a61955877cfb8101564d16704d0
993e2723f380bbe2d64d8f39824ec49825a6939f
refs/heads/master
2022-09-23T07:13:23.482725
2020-05-28T11:46:44
2020-05-28T11:46:44
256,954,883
0
0
null
null
null
null
UHC
Java
false
false
171
java
package enumType; // enum은 상수를 한번에 갖고있는 용도로 사용 public enum Week { MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY; }
cc60a200ae0025226228b4138983213768424ce7
45e5b8e8690e80d05e9e7764a572ee2ddf2928c5
/src/main/java/tristi/general/web/listitem/SalesordercorrectionListItem.java
4794c41ce79423acbedb5c129785004727fba7d0
[]
no_license
tristi/GeneralFoundation
7aa45c2d7f0e30bf8c535b05d143f33cef73baf0
9b3073a74d6dd09db1ccc589687afd459f0a772f
refs/heads/master
2021-01-20T02:47:22.054094
2016-04-16T05:05:19
2016-04-16T05:05:19
null
0
0
null
null
null
null
UTF-8
Java
false
false
694
java
/* * Created on 6 Dec 2015 */ package tristi.general.web.listitem; import tristi.general.bean.Salesordercorrection; import tristi.general.web.ListItem; public class SalesordercorrectionListItem implements ListItem { private final String value ; private final String label ; public SalesordercorrectionListItem(Salesordercorrection salesordercorrection) { super(); this.value = "" + salesordercorrection.getSalesordercorrectionid() ; //TODO : Define here the attributes to be displayed as the label this.label = salesordercorrection.toString(); } @Override public String getValue() { return value; } @Override public String getLabel() { return label; } }
66c26efd32a38197c2ae7e8c3d387a80f1707f25
b3075432aaeb909385f2a27aef365208ab9c002a
/app/src/main/java/com/google/firebase/quickstart/database/NotesActivity.java
6cd5a067c20d087d6f77918a779625b5e0319570
[ "Apache-2.0" ]
permissive
bouhendfaycal/choapp
91fada6a3876d032222d905169d8eb25b2260312
5e4757e05655ad9380dea7d537a48f048f32d39f
refs/heads/master
2020-05-05T05:50:20.701717
2019-04-05T23:20:06
2019-04-05T23:20:06
179,766,955
0
0
null
null
null
null
UTF-8
Java
false
false
1,902
java
package com.google.firebase.quickstart.database; import android.content.Context; import android.content.SharedPreferences; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; public class NotesActivity extends DrawerActivity { Button savenote; TextView textnote; Context context; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.note); context = this; LinearLayout contentFrameLayout = (LinearLayout) findViewById(R.id.content); //Remember this is the FrameLayout area within your activity_main.xml getLayoutInflater().inflate(R.layout.activity_notes, contentFrameLayout); super.setDrawer(false); savenote = findViewById(R.id.note_save); textnote = findViewById(R.id.note_text); SharedPreferences sharedPref = getSharedPreferences( getString(R.string.note_preference_file_key), MODE_PRIVATE); String note_text = sharedPref.getString(getString(R.string.note_preference_key), ""); textnote.setText(note_text); savenote.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { SharedPreferences sharedPref = getSharedPreferences( getString(R.string.note_preference_file_key), MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putString(getString(R.string.note_preference_key), textnote.getText().toString()); editor.commit(); Toast.makeText(context, getString(R.string.operation_done), Toast.LENGTH_LONG).show(); } }); } }
8f1f7f27b209bfa64618bc05f035699c99b28deb
37a30835fcea9664afa873871e479cd28e280378
/app/src/main/java/com/duy/pascal/interperter/declaration/classunit/ClassConstructor.java
f2cff1457081a84fe0c558d57cb0c1b7e8560ec6
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
DereckySany/pascalnide
2e2ad859ff91809a52817f2a61dac92f048ece85
c7f3f79ecf4cf6a81b32c7d389aad7f4034c8f01
refs/heads/master
2022-01-03T08:00:37.935504
2018-03-18T14:02:17
2018-03-18T14:02:17
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,667
java
/* * Copyright (c) 2017 Tran Le Duy * * 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.duy.pascal.interperter.declaration.classunit; import android.support.annotation.Nullable; import com.duy.pascal.ui.debug.CallStack; import com.duy.pascal.interperter.ast.codeunit.RuntimeExecutableCodeUnit; import com.duy.pascal.interperter.ast.codeunit.RuntimePascalClass; import com.duy.pascal.interperter.ast.expressioncontext.ExpressionContext; import com.duy.pascal.interperter.ast.node.CompoundNode; import com.duy.pascal.interperter.ast.runtime.value.ClassConstructorCall; import com.duy.pascal.interperter.ast.runtime.value.RuntimeValue; import com.duy.pascal.interperter.ast.variablecontext.FunctionOnStack; import com.duy.pascal.interperter.ast.variablecontext.VariableContext; import com.duy.pascal.interperter.declaration.Name; import com.duy.pascal.interperter.declaration.lang.function.FunctionDeclaration; import com.duy.pascal.interperter.declaration.lang.types.PascalClassType; import com.duy.pascal.interperter.declaration.lang.types.Type; import com.duy.pascal.interperter.exceptions.runtime.RuntimePascalException; import com.duy.pascal.interperter.linenumber.LineNumber; import com.duy.pascal.interperter.tokens.grouping.GrouperToken; import java.util.List; /** * Created by Duy on 17-Jun-17. */ public class ClassConstructor extends FunctionDeclaration { private PascalClassType classType; public ClassConstructor(PascalClassType classType, Name name, ExpressionContext parent, GrouperToken grouperToken, boolean isProcedure) throws Exception { super(name, parent, grouperToken, isProcedure); this.classType = classType; } public ClassConstructor(PascalClassType classType, Name name, ExpressionContext parent, GrouperToken grouperToken, boolean isProcedure, LineNumber startLine) throws Exception { super(name, parent, grouperToken, isProcedure, startLine); this.classType = classType; } public ClassConstructor(PascalClassType classType, ExpressionContext parent) throws Exception { super(parent); this.classType = classType; this.name = Name.create("create"); this.instructions = new CompoundNode(new LineNumber(0, "system")); } public ClassConstructor(PascalClassType classType, ExpressionContext parent, GrouperToken grouperToken, boolean isProcedure) throws Exception { super(parent, grouperToken, isProcedure); this.classType = classType; } public Object call(RuntimeExecutableCodeUnit<?> main, Object[] arguments, Name idName) throws RuntimePascalException { RuntimePascalClass classVarContext = new RuntimePascalClass(classType.getDeclaration()); main.addPascalClassContext(idName, classVarContext); FunctionOnStack functionOnStack = new FunctionOnStack(classVarContext, main, this, arguments); if (main.isDebug()) { main.getDebugListener().onValueVariableChanged(new CallStack(functionOnStack)); } return functionOnStack.visit(); } @Override public Object visit(VariableContext f, RuntimeExecutableCodeUnit<?> main, Object[] arguments) throws RuntimePascalException { return new RuntimePascalClass(classType.getDeclaration()); } @Override public ClassConstructorCall generateCall(LineNumber line, List<RuntimeValue> values, ExpressionContext f) throws Exception { RuntimeValue[] args = formatArgs(values, f); if (args == null) { return null; } return new ClassConstructorCall(this, args, line); } @Override public ClassConstructorCall generatePerfectFitCall(LineNumber line, List<RuntimeValue> values, ExpressionContext f) throws Exception { RuntimeValue[] args = perfectMatch(values, f); if (args == null) { return null; } return new ClassConstructorCall(this, args, line); } @Nullable @Override public Type returnType() { return classType; } }
e3af7b868237aa70c84375ad667534a7007ee632
3f957f6506220bd162a682ccea9ce474cfa75c0f
/src/service/CustomerService.java
37ff16cd3c06954e0bb397936214cccfa1542e45
[]
no_license
nguyen-graykhoa/hotelReservation
74d10dc2086da8b98fe9dbc4810eb2d77ea3bc06
36c24037a79fa7d0dd041e1e728c49156d27eed9
refs/heads/master
2023-03-20T02:04:12.906239
2021-03-18T20:45:41
2021-03-18T20:45:41
349,106,318
0
0
null
null
null
null
UTF-8
Java
false
false
981
java
package service; import model.Customer; import java.util.*; public class CustomerService { private static CustomerService customerService; public static List<Customer> customers = new ArrayList<Customer>(); public static Map<String, Customer> mapOfCustomers = new HashMap<String, Customer>(); private CustomerService() { } public void addCustomer(String firstName, String lastName, String email) { Customer customer = new Customer(firstName, lastName, email); customers.add(customer); mapOfCustomers.put(email, customer); } public Customer getCustomer(String customerEmail) { return mapOfCustomers.get(customerEmail); } public List<Customer> getAllCustomers() { return customers; } public static CustomerService getCustomerServiceInstance() { if(customerService == null) { customerService = new CustomerService(); } return customerService; } }
f32519265b35cfd24989667888fdf6a91b14f2ea
9e7d0ca7713720f596cefc06951c69c9e5af07e1
/pet-clinic-data/src/main/java/guru/springframework/sfgpetclinc/service/map/OwnerServiceMap.java
5c1bb02c9b7dce473253e5343f366d4eeaea0d4a
[]
no_license
ahmeed83/sfg-pet-clinic
b0f1402212730bb5bc62ae6b625a50c31b2516c3
d6e9a29498af9136a84fc9ecf68f18cfa2e08cf2
refs/heads/master
2020-04-03T04:41:36.839494
2018-10-31T07:05:01
2018-10-31T07:05:01
155,020,799
0
0
null
null
null
null
UTF-8
Java
false
false
939
java
package guru.springframework.sfgpetclinc.service.map; import guru.springframework.sfgpetclinc.model.Owner; import guru.springframework.sfgpetclinc.service.OwnerService; import org.springframework.stereotype.Service; import java.util.Set; @Service public class OwnerServiceMap extends AbstractMapService<Owner, Long> implements OwnerService { @Override public Set<Owner> findAll() { return super.findAll(); } @Override public Owner findById(final Long id) { return super.findById(id); } @Override public Owner save(final Owner object) { return super.save(object.getId(), object); } @Override public void delete(final Owner object) { super.delete(object); } @Override public void deleteById(final Long id) { super.deleteById(id); } @Override public Owner findByLastName(final String lastName) { return null; } }
379ab22e902e4f592acc5fe98624b4fa0a117e63
4a67af1fe5de4222f79e12570c139450f76fc33c
/app/src/main/java/com/example/daidaijie/syllabusapplication/ModuleInfo/dymatic/postDymatic/PostDymaticModule.java
ef4ef3b01a3390d7085dcef30d3f6911bf615552
[]
no_license
zhkHorizon/SyllabusApplicationV1
4a56cdcf9dee87c10be7e2d6105eb20f9df468c7
a79aaa7163d206143d6ddddf58f50c160874e994
refs/heads/master
2020-03-30T00:33:39.337068
2019-03-22T15:59:48
2019-03-22T15:59:48
150,530,636
1
1
null
null
null
null
UTF-8
Java
false
false
1,154
java
package com.example.daidaijie.syllabusapplication.ModuleInfo.dymatic.postDymatic; import com.example.daidaijie.syllabusapplication.di.qualifier.retrofitQualifier.SchoolRetrofit; import com.example.daidaijie.syllabusapplication.di.qualifier.user.LoginUser; import com.example.daidaijie.syllabusapplication.di.scope.PerActivity; import com.example.daidaijie.syllabusapplication.retrofitApi.PostActivityApi; import com.example.daidaijie.syllabusapplication.user.IUserModel; import dagger.Module; import dagger.Provides; import retrofit2.Retrofit; /** * Created by daidaijie on 2016/10/31. */ @Module public class PostDymaticModule { PostDymaticContract.view mView; public PostDymaticModule(PostDymaticContract.view view) { mView = view; } @PerActivity @Provides PostDymaticContract.view provideView() { return mView; } @PerActivity @Provides IPostDymaticModel getIPostDymaticModel(@SchoolRetrofit Retrofit retrofit, @LoginUser IUserModel userModel) { return new PostDymaticModel(retrofit.create(PostActivityApi.class), userModel); } }
cc81d3d63ca772b5d1bff182e290cf89b01b36dd
a3be1c6045c32fccad5832e7f672babb29f9a102
/src/test/java/com/gismat/test/repository/CustomAuditEventRepositoryIntTest.java
b35f20dec1fa0510db7ab551947aac5de0b489eb
[ "MIT" ]
permissive
BulkSecurityGeneratorProject/spring-firebase-authentication
fd10f8ed89a08f5df4eac5e7a707aa683645692f
818f6149268494608a65d8900284d6f35fb4f1a4
refs/heads/master
2022-12-10T22:12:34.396040
2017-12-05T13:34:32
2017-12-05T13:34:32
296,556,936
0
0
MIT
2020-09-18T08:10:58
2020-09-18T08:10:57
null
UTF-8
Java
false
false
11,588
java
package com.gismat.test.repository; import com.gismat.test.TestprojectmonolithicApp; import com.gismat.test.config.Constants; import com.gismat.test.config.audit.AuditEventConverter; import com.gismat.test.domain.PersistentAuditEvent; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.audit.AuditEvent; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpSession; import org.springframework.security.web.authentication.WebAuthenticationDetails; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpSession; import java.time.Instant; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; import static com.gismat.test.repository.CustomAuditEventRepository.EVENT_DATA_COLUMN_MAX_LENGTH; /** * Test class for the CustomAuditEventRepository class. * * @see CustomAuditEventRepository */ @RunWith(SpringRunner.class) @SpringBootTest(classes = TestprojectmonolithicApp.class) @Transactional public class CustomAuditEventRepositoryIntTest { @Autowired private PersistenceAuditEventRepository persistenceAuditEventRepository; @Autowired private AuditEventConverter auditEventConverter; private CustomAuditEventRepository customAuditEventRepository; private PersistentAuditEvent testUserEvent; private PersistentAuditEvent testOtherUserEvent; private PersistentAuditEvent testOldUserEvent; @Before public void setup() { customAuditEventRepository = new CustomAuditEventRepository(persistenceAuditEventRepository, auditEventConverter); persistenceAuditEventRepository.deleteAll(); Instant oneHourAgo = Instant.now().minusSeconds(3600); testUserEvent = new PersistentAuditEvent(); testUserEvent.setPrincipal("test-user"); testUserEvent.setAuditEventType("test-type"); testUserEvent.setAuditEventDate(oneHourAgo); Map<String, String> data = new HashMap<>(); data.put("test-key", "test-value"); testUserEvent.setData(data); testOldUserEvent = new PersistentAuditEvent(); testOldUserEvent.setPrincipal("test-user"); testOldUserEvent.setAuditEventType("test-type"); testOldUserEvent.setAuditEventDate(oneHourAgo.minusSeconds(10000)); testOtherUserEvent = new PersistentAuditEvent(); testOtherUserEvent.setPrincipal("other-test-user"); testOtherUserEvent.setAuditEventType("test-type"); testOtherUserEvent.setAuditEventDate(oneHourAgo); } @Test public void testFindAfter() { persistenceAuditEventRepository.save(testUserEvent); persistenceAuditEventRepository.save(testOldUserEvent); List<AuditEvent> events = customAuditEventRepository.find(Date.from(testUserEvent.getAuditEventDate().minusSeconds(3600))); assertThat(events).hasSize(1); AuditEvent event = events.get(0); assertThat(event.getPrincipal()).isEqualTo(testUserEvent.getPrincipal()); assertThat(event.getType()).isEqualTo(testUserEvent.getAuditEventType()); assertThat(event.getData()).containsKey("test-key"); assertThat(event.getData().get("test-key").toString()).isEqualTo("test-value"); assertThat(event.getTimestamp()).isEqualTo(Date.from(testUserEvent.getAuditEventDate())); } @Test public void testFindByPrincipal() { persistenceAuditEventRepository.save(testUserEvent); persistenceAuditEventRepository.save(testOldUserEvent); persistenceAuditEventRepository.save(testOtherUserEvent); List<AuditEvent> events = customAuditEventRepository .find("test-user", Date.from(testUserEvent.getAuditEventDate().minusSeconds(3600))); assertThat(events).hasSize(1); AuditEvent event = events.get(0); assertThat(event.getPrincipal()).isEqualTo(testUserEvent.getPrincipal()); assertThat(event.getType()).isEqualTo(testUserEvent.getAuditEventType()); assertThat(event.getData()).containsKey("test-key"); assertThat(event.getData().get("test-key").toString()).isEqualTo("test-value"); assertThat(event.getTimestamp()).isEqualTo(Date.from(testUserEvent.getAuditEventDate())); } @Test public void testFindByPrincipalNotNullAndAfterIsNull() { persistenceAuditEventRepository.save(testUserEvent); persistenceAuditEventRepository.save(testOtherUserEvent); List<AuditEvent> events = customAuditEventRepository.find("test-user", null); assertThat(events).hasSize(1); assertThat(events.get(0).getPrincipal()).isEqualTo("test-user"); } @Test public void testFindByPrincipalIsNullAndAfterIsNull() { persistenceAuditEventRepository.save(testUserEvent); persistenceAuditEventRepository.save(testOtherUserEvent); List<AuditEvent> events = customAuditEventRepository.find(null, null); assertThat(events).hasSize(2); assertThat(events).extracting("principal") .containsExactlyInAnyOrder("test-user", "other-test-user"); } @Test public void findByPrincipalAndType() { persistenceAuditEventRepository.save(testUserEvent); persistenceAuditEventRepository.save(testOldUserEvent); testOtherUserEvent.setAuditEventType(testUserEvent.getAuditEventType()); persistenceAuditEventRepository.save(testOtherUserEvent); PersistentAuditEvent testUserOtherTypeEvent = new PersistentAuditEvent(); testUserOtherTypeEvent.setPrincipal(testUserEvent.getPrincipal()); testUserOtherTypeEvent.setAuditEventType("test-other-type"); testUserOtherTypeEvent.setAuditEventDate(testUserEvent.getAuditEventDate()); persistenceAuditEventRepository.save(testUserOtherTypeEvent); List<AuditEvent> events = customAuditEventRepository.find("test-user", Date.from(testUserEvent.getAuditEventDate().minusSeconds(3600)), "test-type"); assertThat(events).hasSize(1); AuditEvent event = events.get(0); assertThat(event.getPrincipal()).isEqualTo(testUserEvent.getPrincipal()); assertThat(event.getType()).isEqualTo(testUserEvent.getAuditEventType()); assertThat(event.getData()).containsKey("test-key"); assertThat(event.getData().get("test-key").toString()).isEqualTo("test-value"); assertThat(event.getTimestamp()).isEqualTo(Date.from(testUserEvent.getAuditEventDate())); } @Test public void addAuditEvent() { Map<String, Object> data = new HashMap<>(); data.put("test-key", "test-value"); AuditEvent event = new AuditEvent("test-user", "test-type", data); customAuditEventRepository.add(event); List<PersistentAuditEvent> persistentAuditEvents = persistenceAuditEventRepository.findAll(); assertThat(persistentAuditEvents).hasSize(1); PersistentAuditEvent persistentAuditEvent = persistentAuditEvents.get(0); assertThat(persistentAuditEvent.getPrincipal()).isEqualTo(event.getPrincipal()); assertThat(persistentAuditEvent.getAuditEventType()).isEqualTo(event.getType()); assertThat(persistentAuditEvent.getData()).containsKey("test-key"); assertThat(persistentAuditEvent.getData().get("test-key")).isEqualTo("test-value"); assertThat(persistentAuditEvent.getAuditEventDate()).isEqualTo(event.getTimestamp().toInstant()); } @Test public void addAuditEventTruncateLargeData() { Map<String, Object> data = new HashMap<>(); StringBuilder largeData = new StringBuilder(); for (int i = 0; i < EVENT_DATA_COLUMN_MAX_LENGTH + 10; i++) { largeData.append("a"); } data.put("test-key", largeData); AuditEvent event = new AuditEvent("test-user", "test-type", data); customAuditEventRepository.add(event); List<PersistentAuditEvent> persistentAuditEvents = persistenceAuditEventRepository.findAll(); assertThat(persistentAuditEvents).hasSize(1); PersistentAuditEvent persistentAuditEvent = persistentAuditEvents.get(0); assertThat(persistentAuditEvent.getPrincipal()).isEqualTo(event.getPrincipal()); assertThat(persistentAuditEvent.getAuditEventType()).isEqualTo(event.getType()); assertThat(persistentAuditEvent.getData()).containsKey("test-key"); String actualData = persistentAuditEvent.getData().get("test-key"); assertThat(actualData.length()).isEqualTo(EVENT_DATA_COLUMN_MAX_LENGTH); assertThat(actualData).isSubstringOf(largeData); assertThat(persistentAuditEvent.getAuditEventDate()).isEqualTo(event.getTimestamp().toInstant()); } @Test public void testAddEventWithWebAuthenticationDetails() { HttpSession session = new MockHttpSession(null, "test-session-id"); MockHttpServletRequest request = new MockHttpServletRequest(); request.setSession(session); request.setRemoteAddr("1.2.3.4"); WebAuthenticationDetails details = new WebAuthenticationDetails(request); Map<String, Object> data = new HashMap<>(); data.put("test-key", details); AuditEvent event = new AuditEvent("test-user", "test-type", data); customAuditEventRepository.add(event); List<PersistentAuditEvent> persistentAuditEvents = persistenceAuditEventRepository.findAll(); assertThat(persistentAuditEvents).hasSize(1); PersistentAuditEvent persistentAuditEvent = persistentAuditEvents.get(0); assertThat(persistentAuditEvent.getData().get("remoteAddress")).isEqualTo("1.2.3.4"); assertThat(persistentAuditEvent.getData().get("sessionId")).isEqualTo("test-session-id"); } @Test public void testAddEventWithNullData() { Map<String, Object> data = new HashMap<>(); data.put("test-key", null); AuditEvent event = new AuditEvent("test-user", "test-type", data); customAuditEventRepository.add(event); List<PersistentAuditEvent> persistentAuditEvents = persistenceAuditEventRepository.findAll(); assertThat(persistentAuditEvents).hasSize(1); PersistentAuditEvent persistentAuditEvent = persistentAuditEvents.get(0); assertThat(persistentAuditEvent.getData().get("test-key")).isEqualTo("null"); } @Test public void addAuditEventWithAnonymousUser() { Map<String, Object> data = new HashMap<>(); data.put("test-key", "test-value"); AuditEvent event = new AuditEvent(Constants.ANONYMOUS_USER, "test-type", data); customAuditEventRepository.add(event); List<PersistentAuditEvent> persistentAuditEvents = persistenceAuditEventRepository.findAll(); assertThat(persistentAuditEvents).hasSize(0); } @Test public void addAuditEventWithAuthorizationFailureType() { Map<String, Object> data = new HashMap<>(); data.put("test-key", "test-value"); AuditEvent event = new AuditEvent("test-user", "AUTHORIZATION_FAILURE", data); customAuditEventRepository.add(event); List<PersistentAuditEvent> persistentAuditEvents = persistenceAuditEventRepository.findAll(); assertThat(persistentAuditEvents).hasSize(0); } }
f5c72b4c4a778d20df239c31dd0956c05b8ab012
ebf8e61490de101d9a272df6399e992751f5a2ba
/backend/src/main/java/com/andrezasecon/app/repositories/CategoryRepository.java
02878ca7b148ed64806f5b2e1092be3ff31a0e6f
[]
no_license
andrezasecon/dscatalog-bootcamp
e80597eb025bd441b3abeb71f2a2f354f8d2b2d3
346a6a5b02035a8a017c05f728e42596d28d617a
refs/heads/master
2023-08-14T09:33:57.081365
2021-09-08T04:44:58
2021-09-08T04:44:58
368,257,079
1
0
null
null
null
null
UTF-8
Java
false
false
294
java
package com.andrezasecon.app.repositories; import com.andrezasecon.app.entities.Category; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface CategoryRepository extends JpaRepository<Category, Long> { }
f223be96334c6abe6687ae7e2390ca1caa8768e0
569314434028eb92ebba9356f33e431ebd20ae0f
/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/export/SecondPrometheusTest.java
079318c35890013ad41e1d13046131804365b27e
[ "Apache-2.0" ]
permissive
dteleguin/quarkus
0566a81a2f5acbe7dca5112cd632698410759ee0
ecf8d24cd11b1921d0cf91f7b7ca762f7ac843c4
refs/heads/master
2023-03-17T10:44:35.658992
2020-10-14T09:54:49
2020-10-14T09:54:49
212,834,913
1
0
Apache-2.0
2023-03-09T20:18:54
2019-10-04T14:33:31
Java
UTF-8
Java
false
false
1,588
java
package io.quarkus.micrometer.deployment.export; import java.util.Set; import javax.inject.Inject; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.composite.CompositeMeterRegistry; import io.quarkus.test.QuarkusUnitTest; public class SecondPrometheusTest { @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest() .withConfigurationResource("test-logging.properties") .overrideConfigKey("quarkus.micrometer.export.prometheus.enabled", "true") .overrideConfigKey("quarkus.micrometer.registry-enabled-default", "false") .overrideConfigKey("quarkus.micrometer.binder-enabled-default", "false") .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) .addClass(PrometheusRegistryProcessor.REGISTRY_CLASS) .addClass(SecondPrometheusProvider.class)); @Inject MeterRegistry registry; @Test public void testMeterRegistryPresent() { // We want a composite that contains both registries. Assertions.assertNotNull(registry, "A registry should be configured"); Set<MeterRegistry> subRegistries = ((CompositeMeterRegistry) registry).getRegistries(); Assertions.assertEquals(2, subRegistries.size(), "Should be two sub registries"); } }
af9db69ac2243ee6a7c024cda841fae81e134311
a8f8afc43a6ff2b756eab4184ae98e5c0d439543
/projects/EJULOK/Java/prognyelvek/src/main/java/bence/prognyelvek/transition/Transition.java
f929361296982f21e0d8db55d3b6eb19ebfc2c3c
[ "MIT" ]
permissive
ndr-113-hub/langs-and-paradigms
acb7ebed767a386f6a3c1849263195317e9e194e
ee4d00dfc85ffa76fa89c1e0cb19a47ebaed1291
refs/heads/master
2022-09-26T00:08:42.270731
2015-05-11T20:34:57
2015-05-11T20:34:57
null
0
0
null
null
null
null
UTF-8
Java
false
false
814
java
package bence.prognyelvek.transition; import bence.prognyelvek.transition.actions.Action; import bence.prognyelvek.transition.conditions.Condition; import bence.prognyelvek.transition.states.State; public class Transition<T, O> { private final Condition<T, O> condition; private final Action<T, O> action; private final State<T, O> destination; public Transition(final Condition<T, O> condition, final Action<T, O> action, final State<T, O> destination) { this.condition = condition; this.action = action; this.destination = destination; } public Condition<T, O> getCondition() { return condition; } public Action<T, O> getAction() { return action; } public State<T, O> getDestination() { return destination; } }
266c098cfa7dd2be28c7868c40257dcefae8439b
4501e44f5423064d479c36a45af70fcc44daa969
/app/src/main/java/com/seeyetech/MVP/seeye/MovableFloatingActionButton.java
076618534eee34d22512469e46827a8afa02c6b0
[]
no_license
Dododododoit/SEEYE_ANDROID
df4d4e91b9428266a9573c017ca98c6b1f0d19e5
12eb7307d549b259413aeafc782b70169bd362f9
refs/heads/master
2020-04-18T15:07:16.848940
2019-02-26T22:29:41
2019-02-26T22:29:41
167,604,855
0
0
null
null
null
null
UTF-8
Java
false
false
3,209
java
package com.seeyetech.MVP.seeye; import android.content.Context; import android.support.design.widget.FloatingActionButton; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; /** * Created by kaitao on 1/25/19. */ public class MovableFloatingActionButton extends FloatingActionButton implements View.OnTouchListener { private final static float CLICK_DRAG_TOLERANCE = 10; // Often, there will be a slight, unintentional, drag when the user taps the FAB, so we need to account for this. private float downRawX, downRawY; private float dX, dY; public MovableFloatingActionButton(Context context) { super(context); init(); } public MovableFloatingActionButton(Context context, AttributeSet attrs) { super(context, attrs); init(); } public MovableFloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } private void init() { setOnTouchListener(this); } @Override public boolean onTouch(View view, MotionEvent motionEvent){ int action = motionEvent.getAction(); if (action == MotionEvent.ACTION_DOWN) { downRawX = motionEvent.getRawX(); downRawY = motionEvent.getRawY(); dX = view.getX() - downRawX; dY = view.getY() - downRawY; return true; // Consumed } else if (action == MotionEvent.ACTION_MOVE) { int viewWidth = view.getWidth(); int viewHeight = view.getHeight(); View viewParent = (View)view.getParent(); int parentWidth = viewParent.getWidth(); int parentHeight = viewParent.getHeight(); float newX = motionEvent.getRawX() + dX; newX = Math.max(0, newX); // Don't allow the FAB past the left hand side of the parent newX = Math.min(parentWidth - viewWidth, newX); // Don't allow the FAB past the right hand side of the parent float newY = motionEvent.getRawY() + dY; newY = Math.max(0, newY); // Don't allow the FAB past the top of the parent newY = Math.min(parentHeight - viewHeight - 150, newY); // Don't allow the FAB past the bottom of the parent view.animate() .x(newX) .y(newY) .setDuration(0) .start(); MyProperties instance = MyProperties.getInstance(); instance.pinX = newX; instance.pinY = newY; return true; // Consumed } else if (action == MotionEvent.ACTION_UP) { float upRawX = motionEvent.getRawX(); float upRawY = motionEvent.getRawY(); float upDX = upRawX - downRawX; float upDY = upRawY - downRawY; if (Math.abs(upDX) < CLICK_DRAG_TOLERANCE && Math.abs(upDY) < CLICK_DRAG_TOLERANCE) { // A click return performClick(); } else { // A drag return true; // Consumed } } else { return super.onTouchEvent(motionEvent); } } }
4a784ee20885a27ae070946b7199ef9cd456e288
57b4d145897cf510a1bfb216b697b96ab8dca3b5
/spring-boot-app/src/main/java/com/cdac/service/CustomerService.java
19917bd0ded1365a2ffd5708b310b42dfb5e1f96
[]
no_license
majrul/cdac-2021-jan-backend-repo
fcb93df471323fada271466ad0493e425ec3b936
ab397b11d1a8337affb291694bb692b130d55bc2
refs/heads/master
2023-02-17T07:47:05.907042
2021-01-21T08:07:08
2021-01-21T08:07:08
331,231,181
1
1
null
null
null
null
UTF-8
Java
false
false
1,433
java
package com.cdac.service; import org.springframework.beans.factory.annotation.Autowired;import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.cdac.dto.Login; import com.cdac.entity.Customer; import com.cdac.exception.CustomerServiceException; import com.cdac.repository.CustomerRepository; @Service @Transactional public class CustomerService { @Autowired private CustomerRepository customerRepository; public int register(Customer customer) { if(!customerRepository.isCustomerPresent(customer.getEmail())) { return customerRepository.save(customer); //suppose we want to send an email confirmation //then that code will be here.. } else throw new CustomerServiceException("Customer already registered!"); } public Customer login(Login login) { try { if(customerRepository.isCustomerPresent(login.getEmail())) { int id = customerRepository.fetch(login.getEmail(), login.getPassword()); Customer customer = customerRepository.fetch(id); return customer; } else throw new CustomerServiceException("Customer does not exist!"); } catch(EmptyResultDataAccessException e) { throw new CustomerServiceException("Incorrect Email/Password"); } } public Customer get(int customerId) { return customerRepository.fetch(customerId); } }
[ "majrul@localhost" ]
majrul@localhost
7821cfb59d84c45acca43ee26a3794eec6169a5c
ae0d886ca3f39cca6cbabcb0fe42478621740bde
/demos/demo-tanklab/src/main/java/migway/demos/tanklab/MapperRoute.java
bc0340cee693eaa489c656a393016bdd44c3ad21
[ "Apache-2.0" ]
permissive
rikigeek/migway
f14a86211f25e0a3c0406ad0cc2ddcf78a14374f
63343d7e3bca8713900b176da335a9df97813fd2
refs/heads/master
2020-06-29T19:02:38.827379
2016-11-21T23:58:16
2016-11-21T23:58:16
74,413,528
1
0
null
null
null
null
UTF-8
Java
false
false
1,001
java
package migway.demos.tanklab; import java.util.Map; import org.apache.camel.Headers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MapperRoute { private static final Logger LOG = LoggerFactory.getLogger(MapperRoute.class); /** * Bean method to choose next route depending on POJO class * * @param body * @return */ @org.apache.camel.InOnly public String route(Object body, @org.apache.camel.Properties Map<String, Object> properties, @Headers Map<String, Object> headers) { try { Boolean skip = (Boolean) properties.get("SKIPMAPPING"); LOG.debug("Route selection - Skip = {}", skip); if (skip != null && skip) return "direct:stop"; } catch (ClassCastException e) { // Ignore not valid property } String bodyType = body.getClass().getName(); LOG.debug("Send to direct:{}", bodyType); return "direct:" + bodyType; } }
5f11dfa96fb75be6477232b39cae5eeef5e10502
48103eaedbbe9bf074a34f53ad5a0883679e3e9e
/lab01/app/src/main/java/com/example/a52951/firstapp/TargetActivity.java
cd4d41f4476914e98eed8594555f085e7ce2fe70
[]
no_license
DorisA01701221/mobiles
74bc8a9ddd043f291018fd15986ed1ff9d8ac052
9f5e6710d16649c1c27c0f19dc2c48bdd2d753ad
refs/heads/master
2020-04-20T04:26:41.538061
2019-02-06T02:08:22
2019-02-06T02:08:22
168,627,670
0
0
null
null
null
null
UTF-8
Java
false
false
769
java
package com.example.a52951.firstapp; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class TargetActivity extends AppCompatActivity { TextView myTextView; Intent currentIntent; String myIntentVar; int myIntegerVar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_target); currentIntent = getIntent(); myIntentVar = currentIntent.getStringExtra("stringToSend"); myIntegerVar = currentIntent.getIntExtra("myInteger",0); myTextView = findViewById(R.id.textView); myTextView.setText(myIntentVar); } }
d7edc6d646c8ed63d16eadfa63bdbee20f9c0aea
c5efbb658746cc0f467322e954f3de72bea4f8f5
/parent/monitor/src/main/java/org/david/rain/monitor/monitor/domain/DataAttrSetting.java
dace9480ba40a522b51ac66e3e7f81b604377867
[]
no_license
xfworld/rain
2eb24d7d858da27df6cac102e6834e523cd0454c
ec45611543916617c695b1e5a2e35f2d43601381
refs/heads/master
2022-08-31T22:59:07.065108
2022-08-11T06:51:47
2022-08-11T06:51:47
71,985,629
0
0
null
2022-08-11T08:42:56
2016-10-26T09:04:07
JavaScript
UTF-8
Java
false
false
1,815
java
package org.david.rain.monitor.monitor.domain; /** * Created by czw on 14-2-24. */ public class DataAttrSetting { private Integer itemId; private String attrName; private String chName; private String memo; private String sql; private String dataSource; private Integer status; public static final int USE = 1; public static final int NO_USE = 0; public Integer getItemId() { return itemId; } public void setItemId(Integer itemId) { this.itemId = itemId; } public String getAttrName() { return attrName; } public void setAttrName(String attrName) { this.attrName = attrName; } public String getChName() { return chName; } public void setChName(String chName) { this.chName = chName; } public String getMemo() { return memo; } public void setMemo(String memo) { this.memo = memo; } public String getSql() { return sql; } public void setSql(String sql) { this.sql = sql; } public Integer getStatus() { return status; } public String getDataSource() { return dataSource; } public void setDataSource(String dataSource) { this.dataSource = dataSource; } public void setStatus(Integer status) { this.status = status; } @Override public String toString() { return "DataAttrSetting{" + "itemId=" + itemId + ", attrName='" + attrName + '\'' + ", chName='" + chName + '\'' + ", memo='" + memo + '\'' + ", sql='" + sql + '\'' + ", dataSource='" + dataSource + '\'' + ", status=" + status + '}'; } }
b3bfb4dd81ed758572e2b8ca0b867bdec6b2a86b
79b0ef804526d8eaf9d53e4fb4b3736b7eae9e33
/src/main/java/com/dh/mapperte/utils/ExelReadeUtils.java
0d3e23259d2de9f6cf1129c1b2e3f70f5469415f
[]
no_license
dhpath/mapperte
76b581aea980a2e5da46e9cac3c617804adfa04f
c92d4977ca4dc218f77f8d8689d76e577e89a642
refs/heads/master
2020-05-07T16:49:57.384665
2019-04-27T09:12:28
2019-04-27T09:12:28
180,700,553
0
0
null
null
null
null
UTF-8
Java
false
false
2,677
java
package com.dh.mapperte.utils; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.*; import org.apache.poi.util.IOUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.junit.Test; import java.io.FileInputStream; public class ExelReadeUtils { @Test public void TestExcel(){ String filename = "E:\\成绩.xls"; readExcel(filename); } public void readExcel(String sourceFilePath) { Workbook workbook = null; try { workbook = getReadWorkBookType(sourceFilePath); if (workbook == null){ System.out.println("文件错误"); return; } //获取第一个sheet Sheet sheet = workbook.getSheetAt(0); //第0行是表名,忽略,从第二行开始读取 for (int rowNum = 0; rowNum <= sheet.getLastRowNum(); rowNum++) { Row row = sheet.getRow(rowNum); Cell cell = row.getCell(0); String trim = getCellStringVal(cell).trim(); System.out.println(trim); } } finally { IOUtils.closeQuietly(workbook); } } private Workbook getReadWorkBookType(String filePath) { //xls-2003, xlsx-2007 FileInputStream is = null; try { is = new FileInputStream(filePath); if (filePath.toLowerCase().endsWith("xlsx")) { return new XSSFWorkbook(is); } else if (filePath.toLowerCase().endsWith("xls")) { return new HSSFWorkbook(is); } else { // 抛出自定义的业务异常 System.out.println("文件格式错误"); return null; } } catch (Exception e) { // 抛出自定义的业务异常 System.out.println("文件格式错误"); return null; } } private String getCellStringVal(Cell cell) { CellType cellType = cell.getCellTypeEnum(); switch (cellType) { case NUMERIC: cell.setCellType(Cell.CELL_TYPE_STRING); return cell.getStringCellValue(); case STRING: return cell.getStringCellValue(); case BOOLEAN: return String.valueOf(cell.getBooleanCellValue()); case FORMULA: return cell.getCellFormula(); case BLANK: return ""; case ERROR: return String.valueOf(cell.getErrorCellValue()); default: return null; } } }
b782683d6851b9ffb8afc40bc643ea41fe1a0923
f3d0d9104c2d9c13f521e57ce82ed3d494807dc0
/thread/src/threadus/Thread03.java
58f18faad779eb1f435025489161fb87d80db7b7
[]
no_license
beautxiang/thread
8abd9f36568f3d5d1aaeec2bf078a1cbcc5113f7
963a0e3e958e55383d27832907976db9de34f414
refs/heads/master
2023-06-02T01:51:50.230599
2021-06-19T07:35:34
2021-06-19T07:35:34
378,345,437
0
0
null
null
null
null
UTF-8
Java
false
false
1,219
java
package threadus; public class Thread03 { public static void main(String[] args) { T1 t1 = new T1(); T2 t2 = new T2(); Thread thread1 = new Thread(t1); Thread thread2 = new Thread(t2); thread1.start(); thread2.start(); System.out.println("main正在运行中"); } } class T1 implements Runnable { int times = 0; @Override public void run() { while (true) { System.out.println("hi" + Thread.currentThread().getName() + "+" + ++times); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } if (times == 10) { break; } } } } class T2 implements Runnable { int times = 0; @Override public void run() { while (true) { System.out.println("hello world" + Thread.currentThread().getName() + "+" + ++times); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } if (times == 10) { break; } } } }
2ebc304c4e7108ae4709dec4bdd745d8c043c67f
1b6a269d889bb6ef300fce834702e2d63dafb992
/Sunny/src/java/com/ybt/service/work/QrcodeService.java
06f113ee51728eedc0bb59237ced7e2659210239
[]
no_license
244522645/demo
b77690f3034ded577e92f88fa8d3b1fd92b96169
231013391c8c58aefee9dc65253f3975d43ebfe2
refs/heads/master
2021-01-23T18:58:06.544798
2017-04-17T05:25:18
2017-04-17T05:25:18
83,005,616
0
0
null
null
null
null
UTF-8
Java
false
false
1,279
java
package com.ybt.service.work; import java.util.List; import org.springframework.stereotype.Component; import com.ybt.common.bean.Result; import com.ybt.model.work.SunQrcode; import com.ybt.service.base.IBaseService; /** * 推广二维码 逻辑 * @author AndyBao * @version 4.0, 2016年11月3日 下午4:08:21 */ @Component public interface QrcodeService extends IBaseService<SunQrcode, String> { /** * 永久二维码 * @return * @author AndyBao * @version V4.0, 2016年11月3日 下午4:04:33 */ public List<SunQrcode> getQrcodeListByFinal(); /** 临时二维码 * @return * @author AndyBao * @version V4.0, 2016年11月3日 下午4:04:57 */ public List<SunQrcode> getQrcodeListByTemp(); /** * 通过value 查询 * @return * @author AndyBao * @version V4.0, 2016年11月3日 下午4:04:57 */ public SunQrcode getQrcodeByValue(Long value); /** * 通过id 查询 * @return * @author lhq * @version */ public SunQrcode getQrcodeById(String id); /** * 生成临时二维码 过期需要重新生成 * @return * @author AndyBao * @version V4.0, 2016年11月3日 下午4:05:42 */ public Result<SunQrcode> createTempQrcode(String content, Long value, String name); }
f9d12e99a3ddbb4d887b3786823beda868226b2b
b96d4ddf58e5d38754c1afed079051ac6bbcef95
/arrays/ArrayBinarySearch.java
b9c87a1c1757abd3d1b8e9cebbabd5cdd545e585
[]
no_license
nikkiumar1993/JavaCodes
82f60c683d8ef188d1f8ece25d61e594d3092e52
1851d55af5815b39993660508c309bf719bd497a
refs/heads/master
2021-01-01T23:34:04.396352
2020-02-10T00:14:32
2020-02-10T00:14:32
239,392,423
0
0
null
null
null
null
UTF-8
Java
false
false
968
java
package arrays; import java.sql.Array; import java.util.Arrays; import java.util.Scanner; public class ArrayBinarySearch { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter a number that will be the size of your array"); int size = input.nextInt(); int [] arr= new int[size]; for (int i = 0; i <size ; i++) { System.out.println("Enter for your array"); arr[i] = input.nextInt(); } int[] firstHalf = new int[size/2]; int[] secondHalf = new int[size/2]; for (int i = 0; i <size/2 ; i++) { firstHalf[i] = arr[i]; } for (int i = (size/2),j=0; i <size ; j++,i++) { secondHalf[j] = arr[i]; } System.out.println(Arrays.toString(arr)); System.out.println(Arrays.toString(firstHalf)); System.out.println(Arrays.toString(secondHalf)); } }
1967c0d9f938a6903044a0b47bf62c5bd746cee1
5ef627ab366436bc698a8fe2e644407152f06c8a
/src/seleniumPractice/Locator3.java
a8168558f713edce9781fee308cbfcc7bbdeb072
[]
no_license
vibha14-dotcom/vibha14-dotcom
99612296d816b313dde12bde1800e9fee31a62a3
6ab6b1402c5f348f17512c6938b2dda92946f5dd
refs/heads/master
2023-08-19T20:27:37.426562
2021-10-29T10:47:13
2021-10-29T10:57:24
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,643
java
package seleniumPractice; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class Locator3 { public static void main(String [] args) throws InterruptedException{ System.setProperty("webdriver.chrome.driver", "E:\\Software Testing\\Selenium S_W\\Chrome Documentation\\chromedriver_win32\\chromedriver.exe"); WebDriver d = new ChromeDriver(); d.manage().window().maximize(); d.navigate().to("file:///E:/myjava/vibha1.html"); Thread.sleep(3000); // 1. Relative xpath Regular- //Tagname d.findElement(By.xpath("//input")).sendKeys("Relative"); // 2.Relative Xpath by Index - //Tagname[Index] d.findElement(By.xpath("//input[4]")).sendKeys("8421477626"); //3.Relative Xpath by Index using signature-- //Xpath[Index] d.findElement(By.xpath("//input[3]")).sendKeys("MAHARASHTRA"); d.findElement(By.xpath("//input[6]")).click(); //4.Relative Xpath By Attribute - //Tagname[@Attributename='Attributevalue'] d.findElement(By.xpath("//input[@id='pwd1']")).sendKeys("Suru@13"); //5.Relative Xpath By Text Function - //Tagname[Text()='textvalue'] d.findElement(By.xpath("//a[text()='Forgotten account?']")).click(); d.navigate().back(); //6.Relative Xpath By Contains for Attribute - //Tagname[contains(@Attributename,'Attributevalue')] d.findElement(By.xpath("//input[contains(@maxlength,'8')]")).sendKeys("baba"); //7.Relative Xpath By Contains for Text Function - //Tagname[contains(Text(),'Textvalue')] } }
c1a79e3270b0f6ff0df43d0a515eabd87857d6f5
d0994997c7f6a3d6552220d8d396b9ff1fd5b715
/tophlc/src/main/java/com/toobei/common/view/Util.java
50dd115319b681e3eb9c4359552d30a86769c345
[ "MIT" ]
permissive
liqimoon/xiubit-android
65ab6f1a56b9f89e86530401f07a8cf16c6c2efd
5723b5a8187a14909f605605b42fb3e7a8c3d768
refs/heads/master
2020-06-28T09:40:01.876486
2018-09-21T05:50:49
2018-09-21T05:50:49
null
0
0
null
null
null
null
UTF-8
Java
false
false
598
java
package com.toobei.common.view; import android.content.Context; public class Util { public static int getScreenWidth(Context context) { return context.getResources().getDisplayMetrics().widthPixels; } public static int getScreenHeight(Context context) { return context.getResources().getDisplayMetrics().heightPixels; } public static float getScreenDensity(Context context) { return context.getResources().getDisplayMetrics().density; } public static int dip2px(Context context, float px) { final float scale = getScreenDensity(context); return (int) (px * scale + 0.5); } }
06bdd6b071761069003252640b37d129fb2697a7
744e0db20e032382b1fa625c9036882ae34bb5b2
/app/src/main/java/com/example/home/appgenda/utilidades/Utilidades.java
fb3ab60534769cbbec1317e93849a3ffca56c678
[]
no_license
DemianBallesteros/Appgenda
574415a7b7091f1882bea788bb2a0a0bd5960d95
f602b43fe2cf6792d56d4b43ce332daba4c55d84
refs/heads/master
2020-03-10T15:38:50.728731
2018-08-18T10:46:31
2018-08-18T10:46:31
129,451,831
0
0
null
null
null
null
UTF-8
Java
false
false
555
java
package com.example.home.appgenda.utilidades; public class Utilidades { //tabla public static final String TABLA_CLIENTE="cliente"; public static final String CAMPO_ID="id"; public static final String CAMPO_NOMBRE="nombre"; public static final String CAMPO_TELEFONO="telefono"; public static final String CAMPO_INFORMACION="informacion"; public static final String CREAR_TABLA_CLIENTE="CREATE TABLE "+TABLA_CLIENTE+" ("+CAMPO_ID+" INTEGER, "+CAMPO_NOMBRE+" TEXT, "+CAMPO_TELEFONO+" TEXT, "+CAMPO_INFORMACION+" TEXT)"; }
[ "Chamo-07" ]
Chamo-07
98a90f9c7d5c773b58da1b10868c28f08c5ff04f
bc0f99c36dd89530e49347b519c399608be10955
/tianfang/tianfang-order/src/test/java/org/tianfang/order/AppTest.java
cec9bba751a28ab80ded71ce1ca739445fb2b4c8
[]
no_license
jamyin/ken-tianfang
7eed073fe715c8f171362664c26a29fe65c95778
f35f6b61cfba6cdf85a3274cb06682babe5667f5
refs/heads/master
2016-09-14T00:55:59.958381
2016-03-31T03:39:55
2016-03-31T03:39:55
56,197,030
0
1
null
null
null
null
UTF-8
Java
false
false
646
java
package org.tianfang.order; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Unit test for simple App. */ public class AppTest extends TestCase { /** * Create the test case * * @param testName name of the test case */ public AppTest( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ public static Test suite() { return new TestSuite( AppTest.class ); } /** * Rigourous Test :-) */ public void testApp() { assertTrue( true ); } }
6b52ed866604ca782d7b677980e3af5697d93b47
17a5538f95356a7d8e848744f93280b13ed217f8
/Java_AOP_Anno/src/test/aspect/WritingAspect.java
a295773985206081cc00ea721c7bbf3d7f8ab462
[]
no_license
sumi0717/ssssspring
97b972fbe777c2a62a12011ac307d4f40faf541c
e45e266fd489525041695af417f39630287c24e5
refs/heads/master
2020-03-25T01:56:49.573998
2018-09-14T07:26:45
2018-09-14T07:26:45
143,266,068
0
0
null
null
null
null
UTF-8
Java
false
false
3,012
java
package test.aspect; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.springframework.stereotype.Component; @Aspect @Component public class WritingAspect { /* 접근 지정자 : public * 리턴 type : void * 메소드 명 : write로 시작하는 메소드 * 메소드에 전달되는 인자 : 없다 * * 위와 같은 모양의 메소드가 실행되기 이전에 적용되는 Advice * execution(public void write*()) =>는 전달받는 인자가 없는 메소드에서만 실행됨 * execution(public void write*(..)) => 전달받는 인자가 있든 없든 해당 메소드에서 실행됨 */ @Before("execution(public void write*(..))") public void preparePen() { System.out.println("[ 글을 쓰기 위해 펜을 준비해요 ]"); } /* * 접근 지정자 : 상관 없음 * 리턴 type : 상관 없음 * 메소드 명 : write로 시작 * 메소드에 전달되는 인자 : 없다 * * 위와 같은 메소드가 실행된 이후에 적용되는 Advice */ @After("execution(* write*())") public void endPen() { System.out.println("[ 글을 다 작성하고 펜을 닫아요 ]"); } @Around("execution(* write*(java.lang.String))") public void aroundWrite(ProceedingJoinPoint joinPoint) throws Throwable{ //메소드가 실행되기 이전 블록 | @Before 역할 //aop가 적용된 메소드에 전달된 인자를 object[]로 얻어내기 Object[] args=joinPoint.getArgs(); //반복문 돌면서 하나씩 참조해서 for(Object tmp:args) { //만일 우리가 찾는 type이면 (이 예제에서는 String type) if(tmp instanceof String) { //원하는 작업을 한다 System.out.println("aop에서 미리 조사함"); System.out.println("전달된 name:"+tmp); } } System.out.println(" [ 준비 작업을 해요 ] "); // aop가 적용된 메소드 수행 ! joinPoint.proceed(); //메소드가 실행된 이후 블록 | @After 역할 System.out.println(" [ 마무리 작업을 해요 ] "); } @Around("execution(String write*(int))") public Object aroundWrite2(ProceedingJoinPoint joinPoint) throws Throwable{ Object[] args=joinPoint.getArgs(); //전달된 인자가 1개이고 type이 정수인게 확실하기 떄문에 int num=(int)args[0]; System.out.println("인자로 전달된 숫자:"+num); //aop가 적용된 메소드를 호출하고 그 메소드가 리턴해주는 객체를 //Object type으로 받기 Object obj=joinPoint.proceed(); //return type이 String이므로 casting String result=(String)obj; System.out.println("리턴된 문자열 : "+result); //원한다면 다른 정보를 리턴해줄 수도 있다 result="에이콘"; return result; } }
e7740456c464d731d5697840b4d226a99131fb5e
f0577b8133ac2e1f80969d687eed3f270134c955
/NSP_tenant/foundation-support/src/main/java/cn/newcapec/foundation/utils/MultiDatasourceContext.java
10f9d1cf79419941255a43a2f5e0bb4e09b681f2
[]
no_license
zhangjunfang/eclipse
23d7041cfa224bd503fb5e5b1661c65ba93d1b31
853a242ac17ea7b606e287d3c8cc63ae8b4ab112
refs/heads/master
2021-01-01T19:16:44.100851
2016-11-18T06:17:50
2016-11-18T06:17:50
18,053,539
0
0
null
null
null
null
UTF-8
Java
false
false
558
java
package cn.newcapec.foundation.utils; /** * 多数据源关键字 * * @author andy.li */ public class MultiDatasourceContext { public static final String bizDataSourcePostgresql="bizDataSourcePostgresql"; public static final String bizDataSourceMysql = "bizDataSourceMysql"; public static final String bizDataSourceCardMysql = "bizDataSourceCardMysql"; public static final String bizDataSourceSqlService = "bizDataSourceSqlService"; public static final String bizDatasourceOracle = "bizDatasourceOracle"; }
a51ad6d764e7a4bc57fe8f51ef963a0e04231e34
6dd13c3bc340626abee9a183c92be9306f984610
/src/main/java/datastructures/MyLinkedList.java
4c09d7155f134ef95e1b02f7ddef7935271ff52d
[]
no_license
enderculha/Algorithmic-Practices
90937fde28d62eb379c2d37448f1c711e75ff956
f3bb64a33c86d11b933bbb934fdeaadb860de6ef
refs/heads/master
2021-04-30T13:25:48.732645
2018-04-22T22:17:14
2018-04-22T22:17:14
121,294,489
0
0
null
null
null
null
UTF-8
Java
false
false
1,121
java
package datastructures; public class MyLinkedList{ Node head; public MyLinkedList(Node head){ this.head = head; } public Node getHead() { return head; } public void setHead(Node head) { this.head = head; } public void append (int data){ Node current = head; if(current == null){ head = current; return; } while(current.next != null){ current = current.next; } Node newNode = new Node(data); newNode.prev = current; current.next = newNode; } public void prepend (int data){ Node newNode = new Node(data); head.prev = newNode; newNode.next = head; head = newNode; } public void deleteWithValue(int data){ if(head == null){ return; } Node current = head; while(current.next!=null){ if(current.next.data == data){ current.next = current.next.next; return; } current = current.next; } } }
acbdfc241bf79bc59ad7d4d4f7cdbdb0a084014f
abbf0de2df7d60d40a23049fb886c6c3e98ef8d0
/4_java_excecoes/Java-pilha/src/FluxoComErro.java
108ee47b29dea8b4c03cf0a1b28b468bd5c529d0
[]
no_license
adenilson1/Java
1b2a8236b829bbbfd7feaa58755a7598b736879d
2a811a7195ec0af1a2d098171114be714af1b406
refs/heads/master
2023-05-07T06:33:03.698883
2021-06-02T12:12:12
2021-06-02T12:12:12
367,205,316
0
0
null
null
null
null
UTF-8
Java
false
false
755
java
public class FluxoComErro { public static void main(String[] args) { System.out.println("Int do main"); try { metodo1(); }catch (ArithmeticException | NullPointerException ex){ String msg = ex.getMessage(); System.out.println("Exception " + msg); ex.printStackTrace(); } System.out.println("Fim do main"); } public static void metodo1() { System.out.println("Int do metodo1"); metodo2(); System.out.println("Fim do metodo1"); } public static void metodo2() { System.out.println("Ini do metodo 2"); metodo2(); System.out.println("Fim do metodo 2"); } }
8bd8c1c78c214c0e36e0b8cf83d16349bcc356de
bbee138b13a2547568a9cef3fb93c5331c7b5741
/Tuziemiec_api/src/main/java/pl/karpiozaury/Tuziemiec_api/Repository/AttractionRepository.java
efc508f24b9f5ce83ba259016441a0f0587fe2bb
[]
no_license
Kethableez/Tuziemiec
c702c331b439f3ea2081f6ee5bf6b229cbe7d27c
c57fa5204785c664d29613a2f0c9c83d99ef301f
refs/heads/master
2023-06-03T12:18:07.724348
2021-06-18T22:41:02
2021-06-18T22:41:02
348,335,253
0
0
null
2021-06-04T02:25:26
2021-03-16T12:15:38
Java
UTF-8
Java
false
false
573
java
package pl.karpiozaury.Tuziemiec_api.Repository; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import pl.karpiozaury.Tuziemiec_api.Model.Attraction; import java.util.List; import java.util.Optional; @Repository public interface AttractionRepository extends JpaRepository<Attraction, Long> { Optional<Attraction> findByName(String name); Optional<List<Attraction>> findAllByPlace(String place); Boolean existsByName(String name); Boolean existsByNameAndPlace(String name, String place); }
3e574b47bd19241dcb8ab21dde18736d08682405
3735cf7db134d672a6e0c8f05c704a6bc434ff5a
/src/main/java/uw/dao/SequenceFactory.java
ed38e858f49003f07362df42b154256f632ad07b
[ "Apache-2.0" ]
permissive
axeon/uw-dao
e0e864157d09c269c5faf2ef503205396062fd8e
04a3f05deed67ea7c236b89625a0f126f891370e
refs/heads/master
2021-06-04T10:25:58.337710
2020-01-10T02:06:52
2020-01-10T02:06:52
115,399,662
11
4
null
null
null
null
UTF-8
Java
false
false
6,930
java
package uw.dao; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import uw.dao.conf.DaoConfigManager; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** * sequence工厂类,可以在集群环境中可靠使用。 * incrementNum是非常重要的参数,当其为1(默认值)时,单线程tps≈(30~50),多线程略高。 * incrementNum和tps的关系公式为 tps = incrementNum*(30~50)。 * * @author zhangjin */ public class SequenceFactory { /** * 日志. */ private static final Logger logger = LoggerFactory.getLogger(SequenceFactory.class); /** * 初始化seq. */ private static final String INIT_SEQ = "insert into sys_seq (seq_name,seq_id,seq_desc,increment_num,create_date,last_update) values(?,?,?,?,now(),now())"; /** * 载入当前seq. */ private static final String LOAD_SEQ = "select seq_id,increment_num from sys_seq where seq_name=? "; /** * 确认更新seq. */ private static final String UPDATE_SEQ = "update sys_seq set seq_id=?,last_update=now() where seq_name=? and seq_id=?"; /** * 重置seq. */ private static final String RESET_SEQ = "update sys_seq set seq_id=?,increment_num=?,last_update=now() where seq_name=?"; /** * SequenceManager集合. */ private static final Map<String, SequenceFactory> seqFactory = new ConcurrentHashMap<String, SequenceFactory>(); /** * dao实例。 */ private static final DaoFactory dao = DaoFactory.getInstance(); /** * 重试次数。 */ private static final int MAX_RETRY_TIMES = 100; /** * seqName. */ private final String seqName; /** * 当前id. */ private long currentId = 0; /** * 当前可以获取的最大id. */ private long maxId = 0; /** * 增量数,高并发应用应该保持较高的增量数字。 */ private int incrementNum = 1; /** * 建立一个Sequence实例. * * @param seqName seq名称。 */ public SequenceFactory(String seqName) { this.seqName = seqName; } /** * 返回指定的表的sequenceId数值. * * @param seqName 表名 * @return 下一个值 */ public static long nextId(String seqName) { SequenceFactory manager = seqFactory.computeIfAbsent(seqName, x -> new SequenceFactory(seqName)); return manager.nextId(1); } /** * 申请一个Id号码范围,范围从当前id到id+range。 * * @param seqName 表名 * @param range 申请多少个号码 * @return 起始号码 */ public static long allocateIdRange(String seqName, int range) { SequenceFactory manager = seqFactory.computeIfAbsent(seqName, x -> new SequenceFactory(seqName)); return manager.nextId(range); } /** * 重置sequence信息。 * * @param sequenceName sequence名字 * @param initSeq 初始值。 * @param incrementNum 递增数。 * @return */ public static boolean resetSeq(String sequenceName, long initSeq, int incrementNum) { SequenceFactory manager = seqFactory.computeIfAbsent(sequenceName, x -> new SequenceFactory(sequenceName)); return manager.resetSeq(initSeq, incrementNum); } /** * 返回下一个可以取到的id值,功能上类似于数据库的自动递增字段。 * 由于集群环境下的资源竞争,系统最多会重试10s。 * 如果返回-1,则说明获取失败。 * * @param value seq值,如果=-1,则说明有问题。 */ private synchronized long nextId(int value) { if (currentId + value > maxId) { if (!getNextBlock(value)) { return -1; } } return ++currentId; } /** * 通过多次尝试获得下一组sequenceId. * * @param value 递增累加值 */ private boolean getNextBlock(int value) { for (int i = 0; i < MAX_RETRY_TIMES; i++) { if (getNextBlockImpl(value)) { return true; } logger.warn("WARNING: SequenceFactory failed to obtain Sequence[{}] next ID block . Trying {}...", this.seqName, i + 1); // 如果不成功,再次调用改方法。 try { Thread.sleep(100); } catch (InterruptedException e) { logger.error(e.getMessage(), e); } } return false; } /** * 执行一个查找下一个sequenceId的操作。步骤如下: * <ol> * <li>从当前的数据库中select出当前的Id * <li>自动递增id。 * <li>Update db row with new id where id=old_id. * <li>如果update失败,会重复执行,直至成功。 * </ol> * * @param value 递增累加值 * @return boolean */ private boolean getNextBlockImpl(int value) { boolean success = false; try { String connName = DaoConfigManager.getRouteMapping("sys_seq", "all"); // 从数据库中获取当前值。 DataSet ds = dao.queryForDataSet(connName, LOAD_SEQ, new Object[]{seqName}); if (ds.next()) { currentId = ds.getLong(1); incrementNum = ds.getInt(2); } else { initSeq(); } // 自动递增id到我们规定的递增累加值。 long nid = currentId + Math.max(incrementNum, value); int effect = dao.executeCommand(connName, UPDATE_SEQ, new Object[]{nid, seqName, currentId}); success = (effect == 1); if (success) { this.maxId = nid; } } catch (TransactionException e) { logger.error("GetNextBlock Error!", e); } return success; } /** * 重置sequence信息。 * * @param initSeq 初始值。 * @param incrementNum 递增数。 * @return */ private boolean resetSeq(long initSeq, int incrementNum) { boolean success = false; try { int effect = dao.executeCommand(DaoConfigManager.getRouteMapping("sys_seq", "all"), RESET_SEQ, new Object[]{initSeq, incrementNum, seqName}); success = (effect == 1); if (success) { this.maxId = 0; } } catch (TransactionException e) { logger.error("GetNextBlock Error!", e); } return success; } /** * 初始化序列. */ private void initSeq() { try { dao.executeCommand(DaoConfigManager.getRouteMapping("sys_seq", "all"), INIT_SEQ, new Object[]{seqName, currentId, seqName, incrementNum}); } catch (TransactionException e) { logger.error("initSeq exception!", e); } } }
e8194ccb8aee81ca972469d943b5afcf118d4a0c
17f36824a271026b6638e05c936da87b5337fbe8
/src/main/java/com/algaworks/algafood/jpa/ExclusaoCozinhaMain.java
cad83a11cc87acb8f8a682a98969ceab9e9e606b
[]
no_license
eduardopadilha22/algafood-api
621aac0620caa6eecaf8d1afd23a791bfa198786
75d6be66a8333f296569d0a73be0dca508a1f155
refs/heads/main
2023-03-04T16:47:31.338653
2021-02-18T12:36:14
2021-02-18T12:36:14
338,424,418
0
0
null
null
null
null
UTF-8
Java
false
false
812
java
package com.algaworks.algafood.jpa; import org.springframework.boot.WebApplicationType; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.ApplicationContext; import com.algaworks.algafood.AlgafoodApiApplication; import com.algaworks.algafood.domain.model.Cozinha; import com.algaworks.algafood.domain.repository.CozinhaRepository; public class ExclusaoCozinhaMain { public static void main(String[] args) { ApplicationContext applicationContext = new SpringApplicationBuilder(AlgafoodApiApplication.class) .web(WebApplicationType.NONE) .run(args); CozinhaRepository cozinhaRepository = applicationContext.getBean(CozinhaRepository.class); Cozinha cozinha = new Cozinha(); cozinha.setId(1L); cozinhaRepository.remover(id); } }
2a696bd4a4f4502d82ba5433e58276d7e1e2b2b7
68e9a7932cfe48372759737f39d0f91772dc430e
/src/test/java/ets/log330/utils/RegressionLineaireB1Tests.java
ec36156e5b309d76666cd7d911ce77d32a09dc67
[]
no_license
Zeldorine/LOG330
e0395f13ebcdbf6c380053660f05c2fb341532b4
2d80c6aa49f04262a1528b25baa96a8e3d6fabf5
refs/heads/master
2021-08-23T12:11:40.635739
2017-12-04T22:22:36
2017-12-04T22:22:36
103,463,043
0
0
null
null
null
null
UTF-8
Java
false
false
5,134
java
package ets.log330.utils; import java.util.ArrayList; import java.util.List; import org.junit.After; import org.junit.AfterClass; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; /** * * @author Zeldorine */ public class RegressionLineaireB1Tests extends MathTests { @BeforeClass public static void setUpClass() { } @AfterClass public static void tearDownClass() { } @Before public void setUp() { } @After public void tearDown() { } @Test @Override public void testNullValue() { Double result = MathHelper.calculateRegressionLineaireB1(null, null, null); assertNull(result); result = MathHelper.calculateRegressionLineaireB1(null, new Double(0), new Double(0)); assertNull(result); result = MathHelper.calculateRegressionLineaireB1(new ArrayList(0), new Double(0), null); assertNull(result); result = MathHelper.calculateRegressionLineaireB1(new ArrayList(0), new Double(0), null); assertNull(result); } @Test @Override public void testEmptyValue() { Double result = MathHelper.calculateRegressionLineaireB1(new ArrayList(0), new Double(0), new Double(0)); assertNull(result); } @Test @Override public void testBorneInferieure() { List<List<Double>> listOneColumn = new ArrayList(1); listOneColumn.add(new ArrayList(0)); Double result = MathHelper.calculateRegressionLineaireB1(listOneColumn, new Double(0), new Double(0)); assertNull(result); // Min Value List<List<Double>> data = new ArrayList(2); List<Double> column1 = new ArrayList<>(1); column1.add(Double.MIN_VALUE); List<Double> column2 = new ArrayList<>(1); column2.add(Double.MIN_VALUE); data.add(column1); data.add(column2); result = MathHelper.calculateRegressionLineaireB1(data, Double.MIN_VALUE, Double.MIN_VALUE); assertNotNull(result); assertEquals(new Double(Double.NaN), result); // Negative Infinity data = new ArrayList(2); column1 = new ArrayList<>(1); column1.add(Double.NEGATIVE_INFINITY); column2 = new ArrayList<>(1); column2.add(Double.NEGATIVE_INFINITY); data.add(column1); data.add(column2); result = MathHelper.calculateRegressionLineaireB1(data, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY); assertNotNull(result); assertEquals(new Double(Double.NaN), result); } @Test @Override public void testBorneSuperieure() { List<List<Double>> listOneColumn = new ArrayList(1); listOneColumn.add(new ArrayList(0)); listOneColumn.add(new ArrayList(0)); listOneColumn.add(new ArrayList(0)); Double result = MathHelper.calculateRegressionLineaireB1(listOneColumn, new Double(0), new Double(0)); assertNull(result); // Max Value List<List<Double>> data = new ArrayList(2); List<Double> column1 = new ArrayList<>(1); column1.add(Double.MAX_VALUE); List<Double> column2 = new ArrayList<>(1); column2.add(Double.MAX_VALUE); data.add(column1); data.add(column2); result = MathHelper.calculateRegressionLineaireB1(data, Double.MAX_VALUE, Double.MAX_VALUE); assertNotNull(result); assertEquals(new Double(Double.NaN), result); // Positive Infinity data = new ArrayList(2); column1 = new ArrayList<>(1); column1.add(Double.POSITIVE_INFINITY); column2 = new ArrayList<>(1); column2.add(Double.POSITIVE_INFINITY); data.add(column1); data.add(column2); result = MathHelper.calculateRegressionLineaireB1(data, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); assertNotNull(result); assertEquals(new Double(Double.NaN), result); } @Test @Override public void testValide() { Double result = MathHelper.calculateRegressionLineaireB1(getListTwoColumnRegressionLineaire(), 382.8, 638.9); assertNotNull(result); assertEquals(new Double(1.7279324262069864), result); } @Test @Override public void testNotANumberValue() { // NaN * NaN List<List<Double>> data = new ArrayList(2); List<Double> column1 = new ArrayList<>(1); column1.add(Double.NaN); List<Double> column2 = new ArrayList<>(1); column2.add(Double.NaN); data.add(column1); data.add(column2); Double result = MathHelper.calculateRegressionLineaireB1(data, Double.NaN, Double.NaN); assertNotNull(result); assertEquals(new Double(Double.NaN), result); } }
bfae704899434841359b9333ba237312ed88d882
b1b77bb1ed47586f96d8f2554a65bcbd0c7162cc
/NETFLIX/staash/staash-mesh/src/main/java/com/netflix/staash/mesh/jersey/JsonMessageBodyWriter.java
0be749698f6593bee6b79934d9b5adf6804c9d9a
[]
no_license
DanHefrman/stuff
b3624d7089909972ee806211666374a261c02d08
b98a5c80cfe7041d8908dcfd4230cf065c17f3f6
refs/heads/master
2023-07-10T09:47:04.780112
2021-08-13T09:55:17
2021-08-13T09:55:17
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,452
java
/******************************************************************************* * /*** * * * * Copyright 2013 Netflix, 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.netflix.staash.mesh.jersey; import java.io.IOException; import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Provider; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.annotate.JsonSerialize; /** * A MessageBodyWriter implementation that uses Jackson ObjectMapper to serialize objects to JSON. */ @Produces({"application/json"}) @Provider public class JsonMessageBodyWriter implements MessageBodyWriter<Object> { private final ObjectMapper mapper; public JsonMessageBodyWriter() { mapper = new ObjectMapper(); mapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); } public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return mapper.canSerialize(type); } public long getSize(Object data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return -1; } public void writeTo(Object data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream out) throws IOException, WebApplicationException { mapper.writeValue(out, data); out.flush(); } }
5814eb188cd765a299d31481373638084c074216
40f81f3e9171575214c5f7fd71536af3596480c9
/src/main/java/cn/com/lingnan/service/WorkorderService.java
2483a7c1c5b581a36d21a0caf25d4886126ffa25
[ "Apache-2.0" ]
permissive
chenxianda-3/wuliu
c7f8ffa1efbe2f81956fbbb9d2037211605141d4
0571ad2faa100a167e6f1ceeee8e7827ba440308
refs/heads/master
2022-12-22T21:52:50.587795
2020-07-09T00:03:16
2020-07-09T00:03:16
195,647,244
2
0
Apache-2.0
2022-12-16T07:14:20
2019-07-07T12:15:23
Java
UTF-8
Java
false
false
425
java
package cn.com.lingnan.service; import java.util.List; import cn.com.lingnan.pojo.Workorder; import cn.com.lingnan.utils.PageBean; public interface WorkorderService { public void save(Workorder workorder) ; public void deleteBatch(String ids); public Workorder findById(String id); public int update(Workorder workorder); void pageQuery(PageBean pageBean, Workorder workorder); List<Workorder> findAll(); }
[ "l" ]
l
a2de02191f30a0816e1fac74d958b5bccff9eab6
06cc87b5ea3cf8aa3e39d4f95187447daa855ba9
/src/com/logicbig/godtrue/multi/thread/ThreadSynchronization/Livelock.java
e40fbd1fdb1986c3883286810c31aac9d4fd8850
[]
no_license
WeLoveGH/JVM-JUC-Core
e918dc10fa12450a9c61f0c05f40c2421821b9c6
dc5e3dd7241e1c39f993d217a43f3f1da272c092
refs/heads/master
2020-09-03T04:56:37.010099
2019-11-04T01:24:51
2019-11-04T01:24:51
219,391,561
0
0
null
2019-11-04T01:20:54
2019-11-04T01:20:54
null
UTF-8
Java
false
false
2,283
java
package com.logicbig.godtrue.multi.thread.ThreadSynchronization; /** * @description: * @author:qianyingjie1 * @create:2019-10-25 */ public class Livelock { public static void main(String[] args) { final LivelockWorker worker1 = new LivelockWorker("LivelockWorker 1 ", true); final LivelockWorker worker2 = new LivelockWorker("LivelockWorker 2", true); final LivelockCommonResource s = new LivelockCommonResource(worker1); new Thread(() -> { worker1.work(s, worker2); }).start(); new Thread(() -> { worker2.work(s, worker1); }).start(); } } class LivelockCommonResource { private LivelockWorker owner; public LivelockCommonResource(LivelockWorker d) { owner = d; } public LivelockWorker getOwner() { return owner; } public synchronized void setOwner(LivelockWorker d) { owner = d; } } class LivelockWorker { private String name; private boolean active; public LivelockWorker(String name, boolean active) { this.name = name; this.active = active; } public String getName() { return name; } public boolean isActive() { return active; } public synchronized void work(LivelockCommonResource commonResource, LivelockWorker otherWorker) { while (active) { // wait for the resource to become available. if (commonResource.getOwner() != this) { try { wait(10); } catch (InterruptedException e) { //ignore } continue; } // If other worker is also active let it do it's work first if (otherWorker.isActive()) { System.out.println(getName() + " : handover the resource to the worker " + otherWorker.getName()); commonResource.setOwner(otherWorker); continue; } //now use the commonResource System.out.println(getName() + ": working on the common resource"); active = false; commonResource.setOwner(otherWorker); } } }
e0db083b02240ef0678126af15b66427c1aabd61
42c52755092f5678ff50c51d5ab3f6d00963bc49
/p05explicitintents_alishev/src/main/java/com/example/p05explicitintents_alishev/ChildActivity.java
89bf83b2062dc2014b61ebe01770c091b23f8fd0
[]
no_license
as1k/android-recall
ec3941040cb6129e41a7fd70be877325b30ff599
9f5a9a7f2a30889a302231256ad999fb8f235c73
refs/heads/master
2022-11-07T04:00:28.877324
2020-06-30T06:37:05
2020-06-30T06:37:05
272,595,278
0
0
null
null
null
null
UTF-8
Java
false
false
784
java
package com.example.p05explicitintents_alishev; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.widget.TextView; public class ChildActivity extends AppCompatActivity { private TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_child); textView = findViewById(R.id.tv_display); Intent intentThatStartedThisActivity = getIntent(); if(intentThatStartedThisActivity.hasExtra(Intent.EXTRA_TEXT)) { String textEntered = intentThatStartedThisActivity.getStringExtra(Intent.EXTRA_TEXT); textView.setText(textEntered); } } }
1ae1e40252cd75719fe58e450e29dc97b17dd5f9
b4094be2ae4da27404f2348a37b2b6cfb01d0587
/src/test/java/fil/iagl/opl/cocospoon/processors/SwitchInsertTest.java
5d55b87db77e96db10e713206e0af30508a35788
[]
no_license
monperrus-teaching/2015-CoCoSpoon
c66e5e63948e3415ee3856de5f0f205e10876bcc
4c02bcd54c33cd1219b4b55a054a91a58fe08a74
refs/heads/master
2020-12-25T09:18:30.056888
2016-02-14T15:34:43
2016-02-14T15:34:43
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,705
java
package fil.iagl.opl.cocospoon.processors; import java.util.stream.Collectors; import org.fest.assertions.Assertions; import org.junit.Test; import fil.iagl.opl.cocospoon.insert.Insertion; import fil.iagl.opl.cocospoon.insert.impl.SwitchInsert; import fil.iagl.opl.cocospoon.tools.ContainsSameElementFilter; import spoon.Launcher; import spoon.reflect.code.CtStatement; import spoon.reflect.declaration.CtClass; import spoon.reflect.declaration.CtElement; import spoon.reflect.visitor.filter.NameFilter; import spoon.reflect.visitor.filter.TypeFilter; public class SwitchInsertTest { @Test public void instrumentSwitchTest() throws Exception { Launcher l = new Launcher(); l.addInputResource("src/test/java/fil/iagl/opl/cocospoon/samples"); l.buildModel(); CtClass<?> sample = (CtClass<?>) l.getFactory().Package().getRootPackage().getElements(new NameFilter<>("SwitchSample")).get(0); Integer nbSwitch = 2; Integer nbStatementToInsert = 2; Insertion insertionStrategy = new SwitchInsert(); CtStatement statementToInsert = l.getFactory().Code().createCodeSnippetStatement("TO BE INSERT"); Assertions.assertThat( sample.getElements(new TypeFilter<CtElement>(CtElement.class)) .stream().filter(insertionStrategy::match).collect(Collectors.toList())) .hasSize(nbSwitch); sample.getElements(new TypeFilter<CtElement>(CtElement.class)) .stream().filter(insertionStrategy::match).forEach(element -> insertionStrategy.apply(element, statementToInsert)); System.out.println(sample); Assertions.assertThat( sample.getElements(new ContainsSameElementFilter(statementToInsert))) .hasSize(nbStatementToInsert); } }
4c52e6a3f2fb9852b154be89215849158a18e42a
4684f73508591bff96fb72943b5389942d80af08
/src/main/java/org/example/util/UserUtil.java
739da00a6b879523d6e5f34b189a3a92b719c504
[]
no_license
alishevich/restaurant
268a9dd2f4540d477a57ac67e4b5b73c5ffe7ea6
daa6b4480689185d954381336af847fb7fd6b673
refs/heads/master
2023-03-08T05:09:59.565442
2021-02-25T20:36:35
2021-02-25T20:36:35
333,806,369
0
0
null
null
null
null
UTF-8
Java
false
false
1,131
java
package org.example.util; import org.example.model.Role; import org.example.model.User; import org.example.to.UserTo; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.util.StringUtils; public class UserUtil { public static User createNewFromTo(UserTo userTo) { return new User(null, userTo.getName(), userTo.getEmail().toLowerCase(), userTo.getPassword(), Role.USER); } public static User updateFromTo(User user, UserTo userTo) { user.setName(userTo.getName()); user.setEmail(userTo.getEmail().toLowerCase()); user.setPassword(userTo.getPassword()); return user; } public static UserTo asTo(User user) { return new UserTo(user.getId(), user.getName(), user.getEmail(), user.getPassword()); } public static User prepareToSave(User user, PasswordEncoder passwordEncoder) { String password = user.getPassword(); user.setPassword(StringUtils.hasText(password) ? passwordEncoder.encode(password) : password); user.setEmail(user.getEmail().toLowerCase()); return user; } }
a36993c47a038a38baef0e24958e10026d7d848c
2685e0b7114463c9955cbdf55844e31ad75c5b40
/src/main/java/sai/service/SpringSQLDemo/controller/StudentController.java
542a18c425cca37cb05ada6c03861a69531488bb
[]
no_license
coddinginjava/mysqlaws
601bd94f57ea5d1b63caa92b100c0b2c88790227
f8a09238f1138bf375bd94d171eb7cc629d26324
refs/heads/master
2021-01-09T14:17:42.053518
2020-02-23T07:13:45
2020-02-23T07:13:45
242,334,001
0
0
null
null
null
null
UTF-8
Java
false
false
890
java
package sai.service.SpringSQLDemo.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import lombok.AllArgsConstructor; import sai.service.SpringSQLDemo.Entity.Student; import sai.service.SpringSQLDemo.service.StudentService; import java.util.List; @RestController @RequestMapping("/student") @AllArgsConstructor public class StudentController { private final StudentService studentService; @GetMapping("/{id}") public Student getStudentById(@PathVariable Integer id) { return studentService.getSudentByRollNo(id); } @GetMapping("/all") public List<Student> getAllNoExpiredList(){ return studentService.getAllNoExpiredList(); } }
dedacb3ef48e9e4b21f6f6a24f6bb03a2e3d48b6
bea3719f76cc2a349e9b49c79d484127412a72bd
/app/src/main/java/com/medvirumal/ecomstore/binding/BindingAdapters.java
0de653d78db765a951f2fc0f2885b96d99a4e9a6
[]
no_license
kpss01/medviumal
8e6a174d6fb660cb2626c3334cb0c7f60924245c
12f19d60808fb263696223b5df3e6523a84c2ad2
refs/heads/main
2023-05-02T02:09:15.688075
2021-05-23T14:55:00
2021-05-23T14:55:00
370,080,516
0
0
null
2021-05-23T14:53:27
2021-05-23T14:53:26
null
UTF-8
Java
false
false
362
java
package com.medvirumal.ecomstore.binding; import androidx.databinding.BindingAdapter; import android.view.View; /** * Data Binding adapters specific to the app. */ public class BindingAdapters { @BindingAdapter("visibleGone") public static void showHide(View view, boolean show) { view.setVisibility(show ? View.VISIBLE : View.GONE); } }
f94259d3220984523cdc3a414d4225fef88cefdf
c7c37f0c5d0a6883b0918f42f180572b63c79ee9
/src/molecule/ui/protein/quaternary/signal/ProteinQuaternarySSBondSizeRaiser.java
e0530321724fd84f306001d8caef4bd831a71fb0
[]
no_license
starteam/starbiochem_java
5b0e6f63a7786397dcb16319e58b1792f5f6e92b
b90b0ddc8dfdcb8e1f1e3a7370da0ed0690cbfc1
refs/heads/master
2021-01-13T01:45:17.651562
2013-06-20T18:44:26
2013-06-20T18:44:26
null
0
0
null
null
null
null
UTF-8
Java
false
false
187
java
package molecule.ui.protein.quaternary.signal; import star.event.Raiser; @star.annotations.Raiser public interface ProteinQuaternarySSBondSizeRaiser extends Raiser { int getValue(); }
48d0bc87a4c2fd8b9cdfb099f1ec23ec737b8ed0
0d3c86f425af255286000339570ad83e00b3248f
/strollimo/src/main/java/com/strollimo/android/services/ImageUploadTaskService.java
5cedcd1fa84795e9e579d7fe61a7fd8d43847ed9
[]
no_license
socialpercon/stroll-android
d9d5bc2acf6744b41ae0cab0a1b61f3eafe917d5
3f1fbd50b9c8098b947ebdc69cdd937148eeee9b
refs/heads/master
2020-04-10T08:28:04.063095
2013-10-23T22:48:29
2013-10-23T22:48:29
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,697
java
package com.strollimo.android.services; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.util.Log; import com.strollimo.android.StrollimoApplication; import com.strollimo.android.core.ImageUploadTask; import com.strollimo.android.core.ImageUploadTaskQueueController; public class ImageUploadTaskService extends Service implements ImageUploadTask.Callback { private static final String TAG = "Tape:ImageUploadTaskService"; private ImageUploadTaskQueueController mQueue; private boolean running; @Override public void onCreate() { super.onCreate(); mQueue = StrollimoApplication.getService(ImageUploadTaskQueueController.class); Log.i(TAG, "Service starting!"); } @Override public int onStartCommand(Intent intent, int flags, int startId) { executeNext(); return START_STICKY; } private void executeNext() { if (running) return; // Only one task at a time. ImageUploadTask task = mQueue.peek(); if (task != null) { running = true; task.execute(this); } else { Log.i(TAG, "Service stopping!"); stopSelf(); // No more tasks are present. Stop. } } @Override public void onSuccess(final String url) { Log.i(TAG, "Upload image success for url: "+url); running = false; mQueue.remove(); //here we could post an the event bus about a successful upload executeNext(); } @Override public void onFailure() { } @Override public IBinder onBind(Intent intent) { return null; } }
b69301a3c01430c6429099049ca4b2bb64737aa4
385ad4174af5b9f884d67a7467527c957162d1a0
/src/main/java/com/catas/audit/service/impl/HostgroupServiceImpl.java
b911734b1a1667ad888fdd7f513b0f59fa9dfa61
[]
no_license
Kili666/J-sparrow-
105b540dbf9f9763c5eb8fe62c806ce1ea1e9896
88e4f782f1069240e0e8cf32b1a923dbaf0d9bc8
refs/heads/main
2023-06-29T17:40:27.168912
2021-08-06T13:05:01
2021-08-06T13:05:01
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,777
java
package com.catas.audit.service.impl; import com.catas.audit.entity.Hostgroup; import com.catas.audit.mapper.HostgroupMapper; import com.catas.audit.service.IHostgroupService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.catas.audit.vo.HostGroupVo; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; import java.util.Set; /** * <p> * 服务实现类 * </p> * * @author catas * @since 2021-03-15 */ @Service public class HostgroupServiceImpl extends ServiceImpl<HostgroupMapper, Hostgroup> implements IHostgroupService { @Override public List<Map<String, Object>> getAllGroupInfo(HostGroupVo hostGroupVo) { return this.baseMapper.getAllGroupInfo(hostGroupVo); } @Override public List<Map<String, Object>> getAllGroupInfo() { return getAllGroupInfo(null); } @Override public Set<Integer> queryRelatedGroupIds(Integer id) { return this.baseMapper.queryRelatedGroupIds(id); } @Override public void updateRelatedGroups(Integer id, List<Integer> gIds) { HostgroupMapper baseMapper = this.baseMapper; baseMapper.deleteRelatedGroupByUserId(id); baseMapper.saveRelatedGroups(id, gIds); } @Override public Set<Integer> getAllRelatedBindHostIds(Integer groupId) { return this.getBaseMapper().getAllRelatedBindHostIds(groupId); } @Override public void updateRelatedBindHosts(HostGroupVo hostGroupVo) { HostgroupMapper baseMapper = this.getBaseMapper(); baseMapper.deleteAllRelatedBindHosts(hostGroupVo.getId()); baseMapper.saveRelatedBindHosts(hostGroupVo.getId(), hostGroupVo.getBindHostIds()); } }
220aef8be4ff3366d0ea2f95745e25278080d1e0
93c7f5137583f170295db5bb4160e4586143ff8e
/src/main/java/me/nithanim/gw2api/v2/api/items/details/InfusionSlot.java
86ee648f01d044c966d9c2742252dae71eeedbc6
[ "Apache-2.0" ]
permissive
gelberlaubfrosch/gw2api
253dc0163a341817763e2d5fb61344b402a46e7c
a3af0e83936a95b51fd3a3b30bd9c5c887778786
refs/heads/master
2021-01-16T00:10:27.875831
2016-02-25T19:54:24
2016-02-25T19:54:24
53,284,930
0
0
null
2016-03-07T00:56:19
2016-03-07T00:56:19
null
UTF-8
Java
false
false
1,012
java
package me.nithanim.gw2api.v2.api.items.details; import me.nithanim.gw2api.v2.common.InfusionType; import java.util.Arrays; import org.apache.commons.lang.builder.ToStringBuilder; public class InfusionSlot { private InfusionType[] flags; private int itemId; public InfusionType[] getFlags() { return flags; } public int getItemId() { return itemId; } @Override public int hashCode() { int hash = 3; hash = 47 * hash + Arrays.deepHashCode(this.flags); hash = 47 * hash + this.itemId; return hash; } @Override public boolean equals(Object obj) { if (obj == null || getClass() != obj.getClass()) { return false; } final InfusionSlot other = (InfusionSlot) obj; return Arrays.deepEquals(this.flags, other.flags) && this.itemId == other.itemId; } @Override public String toString() { return ToStringBuilder.reflectionToString(this); } }
7528797cb6a332fe10bd23c43493e2d04382b76b
b5deeddf2f01a683410bfdeccd09e0d11a96d926
/src/main/java/com/vladimir/crudblog/repository/gson/serializers/JsonRegionSerializer.java
44a19907827215739fbf3a538c8b41e421559b39
[]
no_license
wikigreen/CRUD_blog
06538522a8a62953245a3af0a1b1457ea4a4f0ed
5f5e39f36dcbd4d1abcb7f1205acae4a77d37e14
refs/heads/master
2023-02-15T15:56:49.554098
2021-01-10T12:24:36
2021-01-10T12:24:36
314,028,285
1
0
null
null
null
null
UTF-8
Java
false
false
621
java
package com.vladimir.crudblog.repository.gson.serializers; import com.google.gson.JsonElement; import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.vladimir.crudblog.model.Region; import java.lang.reflect.Type; public class JsonRegionSerializer implements JsonSerializer<Region> { @Override public JsonElement serialize(Region region, Type type, JsonSerializationContext jsonSerializationContext) { if(region == null) return new JsonPrimitive(0L); return new JsonPrimitive(region.getId()); } }
006a2e0755a1bc5f809f9933ecadb6e81258fe87
15c6d19c153fca6f23b49b2385c862612dffc3c7
/src/main/java/com/simplilearn/sportyshoes/SportyshoesAppApplication.java
d126c02eccd0eff839bbdd045e7ff9051e11d967
[]
no_license
Padhu3107/Simplilearn-Phase-III-Assessment
f8499579a0ccbc2a39720046eaca6bd4b7697e05
dff372be2da0f40c5d25b606a008cbcaba8f32d6
refs/heads/main
2023-05-25T07:15:36.390544
2021-06-10T13:06:31
2021-06-10T13:06:31
374,638,234
0
0
null
null
null
null
UTF-8
Java
false
false
799
java
package com.simplilearn.sportyshoes; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.ComponentScan; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @SpringBootApplication @ComponentScan(basePackages = {"com.simplilearn.sportyshoes.controller", "com.simplilearn.sportyshoes.service"}) @EnableJpaRepositories(basePackages = {"com.simplilearn.sportyshoes.repository"}) @EntityScan(basePackages = {"com.simplilearn.sportyshoes.vo"}) public class SportyshoesAppApplication { public static void main(String[] args) { SpringApplication.run(SportyshoesAppApplication.class, args); } }
ad388936a57bcd415e31da38ba3f5ffc5981eaa4
cc4e401a9c8536ae56b15f9428acbdfd42fdcfd6
/message-api/src/main/java/cn/com/huacloud/basic/message/constant/Constants.java
2db4b3e61a3c209d9896e2561ca0a81191f32152
[]
no_license
ccl-jluzh/basic-message
14e496445f6e1c9a28df5659ba22903ee2c49dab
c4095f8c9a946f600aea732973f7f1875d39fc12
refs/heads/main
2023-01-22T02:25:21.720851
2020-11-25T09:31:48
2020-11-25T09:31:48
315,883,644
0
0
null
null
null
null
UTF-8
Java
false
false
1,200
java
package cn.com.huacloud.basic.message.constant; /** * ClassName: Constants * Description: 公共常量 * Date: 2020/8/13 18:24 * * @Author dengchangshi */ public class Constants { public static final String BUCKET_MAX_COUNT = "MSG:BUCKET_MAX_COUNT:"; public static final String BUCKET_CURR_COUNT = "MSG:BUCKET_CURR_COUNT:"; public static final String BUCKET_RATE_LIMIT_KEY = "MSG:RATELIMIT:"; public static final String YES = "Y"; public static final String NO = "N"; public static final String PUSH_CHANNEL_MAIL = "commonMailMessageProcessor"; public static final String WEBSOCKET_USER = "WEBSOCKET_USER"; public static final String MESSAGE_SESSION = "basic.message.sessions"; public static final String USER_SET = "basic.message.users"; public static final String REDIS_PUBLISH_NOTIFY_KEY = "basic.redis.publish.notify"; public static final String COMMON_MAIL_MESSAGE_PROCESSOR = "commonMailMessageProcessor"; public static final String TAX_SMS_MESSAGE_PROCESSOR = "taxSmsMessageProcessor"; public static final String ENTERPRISE_WE_CHAT_MESSAGE_PROCESSOR = "enterpriseWeChatMessageProcessor"; }
6b45bea5cf3f93fb4b81989d818387ce67c85d82
841c9954f16baf0f444f852a6e5fc1d90647c78d
/mercury/src/mercury/main/LoggedIn.java
c66a44283c25366488fdc47885aa02ab0d9b1e31
[]
no_license
idbo-selenium/N_MercuryToursPagePattern
030da52a2beef76caafe06c5fd87168bfafff06e
cb66233195a9f653dcb3403d20b15d42e7c25796
refs/heads/master
2021-01-19T02:23:15.205787
2016-07-19T10:01:19
2016-07-19T10:01:19
63,682,733
0
0
null
null
null
null
UTF-8
Java
false
false
166
java
package mercury.main; public class LoggedIn { public boolean IsAt() { return Browser.Driver().getTitle().equals("Find a Flight: Mercury Tours:"); } }
b50222cb51939716c3c083696d040fcc8ae543f2
c66905c3cb0734d6482810b985c6924d1946ff7f
/lib/src/main/java/com/fyxt/w/base/service/BaseService.java
1123ad83b482fe78ffe369d59e983f92d20db490
[]
no_license
tianmaochang/web-app
00b6cd43935de89219000c9d23343f110a25afe3
d90851ebb6ed9313d252e6a87cd1306f3e8cb71b
refs/heads/master
2020-04-19T02:04:59.869540
2019-01-28T03:24:01
2019-01-28T03:24:01
167,891,733
0
0
null
null
null
null
UTF-8
Java
false
false
165
java
package com.fyxt.w.base.service; /** * Service 基类 * @author ZhangBo * @date 2015年7月29日 上午10:14:24 */ public abstract class BaseService { }
74497d78d04503dc8d174e4aab51826429aa78e7
a1ef97688a27507008e1b8e96f43e0326fb25972
/eSetup/src/com/example/tests/C009.java
91088ea5d10d6c656c09190331d2c403deec1682
[]
no_license
ullah003/Storpia
ff30553b6b8eec50bd745fa69b2260d439a25c07
439bbac4c5ea52e34da1196d31b94e3daa806564
refs/heads/master
2020-12-20T23:56:50.344444
2020-01-26T00:57:46
2020-01-26T00:57:46
236,248,982
0
0
null
null
null
null
UHC
Java
false
false
6,977
java
package com.example.tests; import static org.junit.Assert.fail; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.internal.seleniumemulation.IsElementPresent; public class C009 extends UserAndShare { private static StringBuffer verificationErrors = new StringBuffer(); boolean result = false; /** * @param test case no.C009 * By Double Click, user information and modification page appears normally? * 리스트 더블클릭시 해당사용자의 정보 수정 페이지가 정상 동작 하는가? */ public void C009() { // public static void main(String[] args) { // // TODO Auto-generated method stub // WebDriver web = new FirefoxDriver(); Actions action = new Actions(driver); // // // Open login page // web.get("http://gluesys01.storpia.com:9000/index.php"); // // // Enter ID and Password // WebElement element_id = web.findElement(By.id("login_userid")); // element_id.sendKeys("admin"); // // WebElement element_pass = web.findElement(By.id("login_password")); // element_pass.sendKeys("admin"); // // // Click login button // web.findElement(By.cssSelector("input.btn_login")).click(); // // // Print login success message to console // System.out.println("Successfully logged in."); // // // Wait 10 sec for main page to be loaded // web.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // // // Click eSetup icon to go to eSetup page // web.findElement(By.name("icon_esetup")).click(); // Click User menu driver.findElement(By.linkText("User")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // Create User driver.findElement(By.xpath("//button[contains(text(), 'Add')]")).click(); try{ Thread.sleep(1000); } catch (Exception e) {} //Enter user informations (Name, desc, email, password) WebElement userid = driver.findElement(By.id("cuserid")); userid.sendKeys("double"); WebElement username = driver.findElement(By.id("cuname")); username.sendKeys("user name"); WebElement useremail = driver.findElement(By.id("cemail")); useremail.sendKeys("[email protected]"); WebElement userpass = driver.findElement(By.id("cpassword")); userpass.sendKeys("user"); WebElement userpass1 = driver.findElement(By.id("cpassword1")); userpass1.sendKeys("user"); //Click next--> next driver.findElement(By.xpath("//button[contains(text(), 'Next')]")).click(); driver.findElement(By.xpath("//button[contains(text(), 'Next')]")).click(); //Click Confirm driver.findElement(By.xpath("//button[contains(text(), 'Confirm')]")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.xpath("//button[contains(text(), 'OK')]")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); //Refresh try{ Thread.sleep(1500); } catch(Exception e) {} String url = driver.getCurrentUrl(); driver.navigate().to(url); try{ Thread.sleep(1500); } catch(Exception e) {} // Click User menu driver.findElement(By.linkText("User")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // Search user WebElement element_search = driver.findElement(By.xpath("//input[@class='x-form-text x-form-field']")); element_search.sendKeys("double"); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // Search Button Click driver.findElement(By.xpath("//*[@class='x-form-trigger x-form-search-trigger']")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); try{ Thread.sleep(1000); } catch (Exception e) {} // Double Click WebElement dbc = driver.findElement(By.xpath("//div[2]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div/div/div/div[2]/div/div/div[2]/div/div/table/tbody/tr/td")); driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); action.doubleClick(dbc).perform(); driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); try { Thread.sleep(1000); } catch(Exception e) {} // check modify page if(isElementPresent(By.id("uname"))) { result = true; System.out.println("show modify page"); } else { result = false; System.out.println("cannot show modify page"); } // Enter Dec , Email, Password WebElement userDec = driver.findElement(By.id("uname")); userDec.clear(); userDec.sendKeys("doubleclick"); useremail = driver.findElement(By.id("email")); useremail.clear(); useremail.sendKeys("[email protected]"); userpass = driver.findElement(By.id("password")); userpass.sendKeys("1111"); userpass1 = driver.findElement(By.id("password1")); userpass1.sendKeys("1111"); try { Thread.sleep(1000); } catch(Exception e) {} //Click Confirm driver.findElement(By.xpath("//button[contains(text(), 'Confirm')]")).click(); driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); driver.findElement(By.xpath("//button[contains(text(), 'OK')]")).click(); driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); System.out.println("Modify Success"); // Write File try { BufferedWriter out = new BufferedWriter(new FileWriter("UserAndShare.txt", true)); out.write("*****************************************************************\r\n"); out.write("* Show modify page after double click *\r\n"); out.write("*****************************************************************\r\n"); out.write("Test C009 - User\r\n"); out.write("By Double Click, user information and modification page appears normally? \r\n" + "리스트 더블클릭시 해당사용자의 정보 수정 페이지가 정상 동작 하는가? \r\n"); out.write("=================================================================\r\n"); if(result == true) out.write("Test C009 ----------------------------> PASS \r\n"); else out.write("Test C009 ----------------------------> FAIL \r\n"); out.write("\r\n"); //out.flush(); out.close(); } catch (IOException e) {} System.out.println("Write file successfully."); // After // driver.quit(); String verificationErrorString = verificationErrors.toString(); if (!"".equals(verificationErrorString)) { fail(verificationErrorString); } } private static boolean isElementPresent(By by) { try { driver.findElement(by); return true; } catch (NoSuchElementException e) { return false; } } }
54bb2c0edcf8aa3eeacccf89a27a1467b7aaf7b1
cc05ab86b3953f58354511b76eaffa0e9ec26abf
/Кузьмичев/4/src/course/battlegame/Monster.java
43cf0cc6b48412ded3dcddc4e590aa1df96d4869
[]
no_license
Apollinary/mera_se_0620
aab359c3cea2711434b705926df25bb13dde360e
15980478791bb48d44e6b0caa6e60e19ecfb8e35
refs/heads/master
2022-12-08T21:22:52.465191
2020-09-06T18:06:03
2020-09-06T18:06:03
293,332,056
0
0
null
2020-09-06T17:53:29
2020-09-06T17:53:28
null
UTF-8
Java
false
false
1,617
java
package course.battlegame; import java.util.Random; public class Monster extends Character { private Integer power; private static Integer MIN_POWER; private static Integer MAX_POWER; { Monster.MIN_POWER = 5; Monster.MAX_POWER = 20; } public Monster(String name, Integer maxHeatPoint) { super(name, maxHeatPoint); this.power = new Random().nextInt(Monster.MAX_POWER - Monster.MIN_POWER) + Monster.MIN_POWER; } private void heatCharacter(Character character) { if(character == null) { return; } System.out.println("Monster \"" + this.getName() + "\" attack \"" + character.getName() + "\" on " + this.power + " hp"); character.changeHitPoints(this, -this.power); } @Override void step(Position[] positions) { if(positions == null) { return; } Integer randomCharacter; while (true) { randomCharacter = new Random().nextInt(positions.length); if (positions[randomCharacter].getCharacter() != this) { break; } } heatCharacter(positions[randomCharacter].getCharacter()); } @Override protected void changeHitPoints(Character character, Integer hitPoints) { if(character == null){ return; } this.hitPoints += hitPoints; if (this.hitPoints > this.maxHitPoint) { this.hitPoints = this.maxHitPoint; return; } if (this.hitPoints < 0) { this.hitPoints = 0; } } }
834cdc73601beb62c890424e920b36d74e5bbf7d
76b764be1fcf4adc108bdb9f11dc3b01ec922d46
/MyFirstProject/src/Variabile.java
20f4d34f134aaefcf16b3664283f44ecbab2a8e8
[]
no_license
VladMihai7/MyFirstJavaProject
1ec1b7c6817f7602b04f6f6e21f0f7008b9c877f
ab474854b69afdb266a9b81d13833ec2199c5912
refs/heads/master
2022-12-19T22:13:06.699008
2020-10-01T13:22:07
2020-10-01T13:22:07
300,286,456
0
0
null
null
null
null
UTF-8
Java
false
false
610
java
public class Variabile { public static void main(String[] args) { int first = 1; int second = 2; int adding = first + second; System.out.println(adding); } } class Variabile2 { static int one = 123; public static void main(String[] args) { final int finalVar = 10; int finalAdding = 2 + one +finalVar; System.out.println(finalAdding); } } class Test { public static void main(String args[]) { Integer x = 5; // x = x + 10; System.out.println(x); } }
9cc214b790468b0c9c5de632e1f423d5695d8f98
be73270af6be0a811bca4f1710dc6a038e4a8fd2
/crash-reproduction-moho/results/XWIKI-13372-1-30-FEMO-WeightedSum:TestLen:CallDiversity/com/xpn/xwiki/objects/BaseProperty_ESTest.java
7aa061b34f4a7df8b2212e62984237bbd8a6e7d7
[]
no_license
STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application
cf118b23ecb87a8bf59643e42f7556b521d1f754
3bb39683f9c343b8ec94890a00b8f260d158dfe3
refs/heads/master
2022-07-29T14:44:00.774547
2020-08-10T15:14:49
2020-08-10T15:14:49
285,804,495
0
0
null
null
null
null
UTF-8
Java
false
false
552
java
/* * This file was automatically generated by EvoSuite * Sat Apr 04 06:23:12 UTC 2020 */ package com.xpn.xwiki.objects; import org.junit.Test; import static org.junit.Assert.*; import org.evosuite.runtime.EvoRunner; import org.evosuite.runtime.EvoRunnerParameters; import org.junit.runner.RunWith; @RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true) public class BaseProperty_ESTest extends BaseProperty_ESTest_scaffolding { @Test public void notGeneratedAnyTest() { // EvoSuite did not generate any tests } }
7ab4acad1e345065ad27eba933f85c41763b97cb
be73270af6be0a811bca4f1710dc6a038e4a8fd2
/crash-reproduction-moho/results/MATH-1b-1-25-MOEAD-WeightedSum:TestLen:CallDiversity/org/apache/commons/math3/fraction/BigFraction_ESTest_scaffolding.java
78d57cf964afb4e1ce2bb34d800e0e7e90563aba
[]
no_license
STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application
cf118b23ecb87a8bf59643e42f7556b521d1f754
3bb39683f9c343b8ec94890a00b8f260d158dfe3
refs/heads/master
2022-07-29T14:44:00.774547
2020-08-10T15:14:49
2020-08-10T15:14:49
285,804,495
0
0
null
null
null
null
UTF-8
Java
false
false
3,127
java
/** * Scaffolding file used to store all the setups needed to run * tests automatically generated by EvoSuite * Wed Apr 08 08:58:35 UTC 2020 */ package org.apache.commons.math3.fraction; import org.evosuite.runtime.annotation.EvoSuiteClassExclude; import org.junit.BeforeClass; import org.junit.Before; import org.junit.After; @EvoSuiteClassExclude public class BigFraction_ESTest_scaffolding { @org.junit.Rule public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); @BeforeClass public static void initEvoSuiteFramework() { org.evosuite.runtime.RuntimeSettings.className = "org.apache.commons.math3.fraction.BigFraction"; org.evosuite.runtime.GuiSupport.initialize(); org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; org.evosuite.runtime.Runtime.getInstance().resetRuntime(); } @Before public void initTestCase(){ threadStopper.storeCurrentThreads(); threadStopper.startRecordingTime(); org.evosuite.runtime.GuiSupport.setHeadless(); org.evosuite.runtime.Runtime.getInstance().resetRuntime(); org.evosuite.runtime.agent.InstrumentingAgent.activate(); } @After public void doneWithTestCase(){ threadStopper.killAndJoinClientThreads(); org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); } private static void initializeClasses() { org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(BigFraction_ESTest_scaffolding.class.getClassLoader() , "org.apache.commons.math3.fraction.BigFractionField", "org.apache.commons.math3.exception.util.ExceptionContextProvider", "org.apache.commons.math3.util.MathUtils", "org.apache.commons.math3.exception.MathIllegalNumberException", "org.apache.commons.math3.exception.util.LocalizedFormats", "org.apache.commons.math3.fraction.BigFraction", "org.apache.commons.math3.exception.ZeroException", "org.apache.commons.math3.exception.ConvergenceException", "org.apache.commons.math3.util.FastMath", "org.apache.commons.math3.FieldElement", "org.apache.commons.math3.exception.util.Localizable", "org.apache.commons.math3.exception.util.ArgUtils", "org.apache.commons.math3.exception.MathArithmeticException", "org.apache.commons.math3.exception.MathIllegalStateException", "org.apache.commons.math3.fraction.FractionConversionException", "org.apache.commons.math3.exception.util.ExceptionContext", "org.apache.commons.math3.exception.NullArgumentException", "org.apache.commons.math3.Field", "org.apache.commons.math3.exception.NotFiniteNumberException", "org.apache.commons.math3.exception.MathIllegalArgumentException" ); } }
db9a737773efb71c5ac2c08087ded45f5fdec4fe
31b608f50f8da4a1a31726977940f9b6c54e4966
/src/julius/judge/JudgeResult.java
e8ef7a9ce3a7a0c004412b899dfa69216947b785
[ "Apache-2.0" ]
permissive
jasonyu1996/julius
9a31ca5452c595536eea675b90037f5857991d82
4920b3542ea0f6b5bdda49975642cb8a6b1511b7
refs/heads/master
2020-08-25T05:11:39.867821
2015-02-19T13:50:40
2015-02-19T13:50:40
30,830,164
0
0
null
null
null
null
UTF-8
Java
false
false
1,927
java
package julius.judge; import julius.judge.compile.CompileResult; /** * A representation of the result of a judge routine. * * <p>It consists of compile results and testcase results.</p> * <p>When the compilation is not successful, the testcase results may be null.</p> * @author jason_yu * @since Julius1.0 * */ public class JudgeResult { private int totalScore; private TestcaseResult[] testcaseResults; private CompileResult compileResult; /** * <p>Creates a JudgeResult instance with given compile result and testcase results.</p> * * @param compileResult the compile result * @param testcaseResults the results for testcases * @since Julius1.0 * */ public JudgeResult(CompileResult compileResult, TestcaseResult[] testcaseResults){ this.compileResult = compileResult; totalScore = 0; if(testcaseResults == null) this.testcaseResults = null; else this.testcaseResults = testcaseResults.clone(); if(compileResult.isCompileOk()) for(int i = 0; i < testcaseResults.length; i ++) totalScore += testcaseResults[i].getScore(); } /** * <p>Calculates the total score of the judge result.</p> * @return the total score. If the compilation is not successful, it would be 0. Otherwise, it would be the sum of score gained in each testcase. * @since Julius1.0 * */ public int getTotalScore() { return totalScore; } /** * <p>Returns the compile result in the judge result.</p> * * @return the compile result * @since Julius1.0 */ public CompileResult getCompileResult() { return compileResult; } /** * <p>Returns the testcase results in the judge result.</p> * * @return an array containing the results of testcases * @since Julius1.0 */ public TestcaseResult[] getTestcaseResults(){ if(testcaseResults == null) return null; return testcaseResults.clone(); } }
73df2be0d0b24a44c1a5458d23ad6227f88a9e67
3d1b4b816a410927466b2267c61b77dc9bad38d6
/saprkdemo/src/main/scala/cn/com/google/tree/KdTree.java
d1b366731ef38a604412a72a922e0b5366fec47e
[]
no_license
yanglilin/sparkmodel
459219df4b04d522219cd87f7bebc47092124b31
4b6ddde9c633d7cae53934c6027aa637f2e1d671
refs/heads/master
2020-05-31T14:50:53.786870
2018-02-03T05:51:47
2018-02-03T05:51:47
null
0
0
null
null
null
null
UTF-8
Java
false
false
19,154
java
package cn.com.google.tree; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.TreeSet; /** * A k-d tree (short for k-dimensional tree) is a space-partitioning data structure for organizing * points in a k-dimensional space. k-d trees are a useful data structure for several applications, * such as searches involving a multidimensional search key (e.g. range searches and nearest neighbor * searches). k-d trees are a special case of binary space partitioning trees. * <p> * http://en.wikipedia.org/wiki/K-d_tree * * @author Justin Wetherell <[email protected]> */ public class KdTree<T extends KdTree.XYZPoint> { private int k = 3; private KdNode root = null; private static final Comparator<XYZPoint> X_COMPARATOR = new Comparator<XYZPoint>() { /** * {@inheritDoc} */ @Override public int compare(XYZPoint o1, XYZPoint o2) { if (o1.x < o2.x) return -1; if (o1.x > o2.x) return 1; return 0; } }; private static final Comparator<XYZPoint> Y_COMPARATOR = new Comparator<XYZPoint>() { /** * {@inheritDoc} */ @Override public int compare(XYZPoint o1, XYZPoint o2) { if (o1.y < o2.y) return -1; if (o1.y > o2.y) return 1; return 0; } }; private static final Comparator<XYZPoint> Z_COMPARATOR = new Comparator<XYZPoint>() { /** * {@inheritDoc} */ @Override public int compare(XYZPoint o1, XYZPoint o2) { if (o1.z < o2.z) return -1; if (o1.z > o2.z) return 1; return 0; } }; protected static final int X_AXIS = 0; protected static final int Y_AXIS = 1; protected static final int Z_AXIS = 2; /** * Default constructor. */ public KdTree() { } /** * More efficient constructor. * * @param list of XYZPoints. */ public KdTree(List<XYZPoint> list) { root = createNode(list, k, 0); } /** * Create node from list of XYZPoints. * * @param list of XYZPoints. * @param k of the tree. * @param depth depth of the node. * @return node created. */ private static KdNode createNode(List<XYZPoint> list, int k, int depth) { if (list == null || list.size() == 0) return null; int axis = depth % k; if (axis == X_AXIS) Collections.sort(list, X_COMPARATOR); else if (axis == Y_AXIS) Collections.sort(list, Y_COMPARATOR); else Collections.sort(list, Z_COMPARATOR); int mediaIndex = list.size() / 2; KdNode node = new KdNode(k, depth, list.get(mediaIndex)); if (list.size() > 0) { if ((mediaIndex - 1) >= 0) { List<XYZPoint> less = list.subList(0, mediaIndex); if (less.size() > 0) { node.lesser = createNode(less, k, depth + 1); node.lesser.parent = node; } } if ((mediaIndex + 1) <= (list.size() - 1)) { List<XYZPoint> more = list.subList(mediaIndex + 1, list.size()); if (more.size() > 0) { node.greater = createNode(more, k, depth + 1); node.greater.parent = node; } } } return node; } /** * Add value to the tree. Tree can contain multiple equal values. * * @param value T to add to the tree. * @return True if successfully added to tree. */ public boolean add(T value) { if (value == null) return false; if (root == null) { root = new KdNode(value); return true; } KdNode node = root; while (true) { if (KdNode.compareTo(node.depth, node.k, node.id, value) <= 0) { //Lesser if (node.lesser == null) { KdNode newNode = new KdNode(k, node.depth + 1, value); newNode.parent = node; node.lesser = newNode; break; } else { node = node.lesser; } } else { //Greater if (node.greater == null) { KdNode newNode = new KdNode(k, node.depth + 1, value); newNode.parent = node; node.greater = newNode; break; } else { node = node.greater; } } } return true; } /** * Does the tree contain the value. * * @param value T to locate in the tree. * @return True if tree contains value. */ public boolean contains(T value) { if (value == null) return false; KdNode node = getNode(this, value); return (node != null); } /** * Locate T in the tree. * * @param tree to search. * @param value to search for. * @return KdNode or NULL if not found */ private static final <T extends KdTree.XYZPoint> KdNode getNode(KdTree<T> tree, T value) { if (tree == null || tree.root == null || value == null) return null; KdNode node = tree.root; while (true) { if (node.id.equals(value)) { return node; } else if (KdNode.compareTo(node.depth, node.k, node.id, value) < 0) { //Greater if (node.greater == null) { return null; } else { node = node.greater; } } else { //Lesser if (node.lesser == null) { return null; } else { node = node.lesser; } } } } /** * Remove first occurrence of value in the tree. * * @param value T to remove from the tree. * @return True if value was removed from the tree. */ public boolean remove(T value) { if (value == null) return false; KdNode node = getNode(this, value); if (node == null) return false; KdNode parent = node.parent; if (parent != null) { if (parent.lesser != null && node.equals(parent.lesser)) { List<XYZPoint> nodes = getTree(node); if (nodes.size() > 0) { parent.lesser = createNode(nodes, node.k, node.depth); if (parent.lesser != null) { parent.lesser.parent = parent; } } else { parent.lesser = null; } } else { List<XYZPoint> nodes = getTree(node); if (nodes.size() > 0) { parent.greater = createNode(nodes, node.k, node.depth); if (parent.greater != null) { parent.greater.parent = parent; } } else { parent.greater = null; } } } else { //root List<XYZPoint> nodes = getTree(node); if (nodes.size() > 0) root = createNode(nodes, node.k, node.depth); else root = null; } return true; } /** * Get the (sub) tree rooted at root. * * @param root of tree to get nodes for. * @return points in (sub) tree, not including root. */ private static final List<XYZPoint> getTree(KdNode root) { List<XYZPoint> list = new ArrayList<XYZPoint>(); if (root == null) return list; if (root.lesser != null) { list.add(root.lesser.id); list.addAll(getTree(root.lesser)); } if (root.greater != null) { list.add(root.greater.id); list.addAll(getTree(root.greater)); } return list; } /** * K Nearest Neighbor search * * @param K Number of neighbors to retrieve. Can return more than K, if last nodes are equal distances. * @param value to find neighbors of. * @return collection of T neighbors. */ @SuppressWarnings("unchecked") public Collection<T> nearestNeighbourSearch(int K, T value) { if (value == null) return null; //Map used for results TreeSet<KdNode> results = new TreeSet<KdNode>(new EuclideanComparator(value)); //Find the closest leaf node KdNode prev = null; KdNode node = root; while (node != null) { if (KdNode.compareTo(node.depth, node.k, node.id, value) < 0) { //Greater prev = node; node = node.greater; } else { //Lesser prev = node; node = node.lesser; } } KdNode leaf = prev; if (leaf != null) { //Used to not re-examine nodes Set<KdNode> examined = new HashSet<KdNode>(); //Go up the tree, looking for better solutions node = leaf; while (node != null) { //Search node searchNode(value, node, K, results, examined); node = node.parent; } } //Load up the collection of the results Collection<T> collection = new ArrayList<T>(K); for (KdNode kdNode : results) { collection.add((T) kdNode.id); } return collection; } private static final <T extends KdTree.XYZPoint> void searchNode(T value, KdNode node, int K, TreeSet<KdNode> results, Set<KdNode> examined) { examined.add(node); //Search node KdNode lastNode = null; Double lastDistance = Double.MAX_VALUE; if (results.size() > 0) { lastNode = results.last(); lastDistance = lastNode.id.euclideanDistance(value); } Double nodeDistance = node.id.euclideanDistance(value); if (nodeDistance.compareTo(lastDistance) < 0) { if (results.size() == K && lastNode != null) results.remove(lastNode); results.add(node); } else if (nodeDistance.equals(lastDistance)) { results.add(node); } else if (results.size() < K) { results.add(node); } lastNode = results.last(); lastDistance = lastNode.id.euclideanDistance(value); int axis = node.depth % node.k; KdNode lesser = node.lesser; KdNode greater = node.greater; //Search children branches, if axis aligned distance is less than current distance if (lesser != null && !examined.contains(lesser)) { examined.add(lesser); double nodePoint = Double.MIN_VALUE; double valuePlusDistance = Double.MIN_VALUE; if (axis == X_AXIS) { nodePoint = node.id.x; valuePlusDistance = value.x - lastDistance; } else if (axis == Y_AXIS) { nodePoint = node.id.y; valuePlusDistance = value.y - lastDistance; } else { nodePoint = node.id.z; valuePlusDistance = value.z - lastDistance; } boolean lineIntersectsCube = ((valuePlusDistance <= nodePoint) ? true : false); //Continue down lesser branch if (lineIntersectsCube) searchNode(value, lesser, K, results, examined); } if (greater != null && !examined.contains(greater)) { examined.add(greater); double nodePoint = Double.MIN_VALUE; double valuePlusDistance = Double.MIN_VALUE; if (axis == X_AXIS) { nodePoint = node.id.x; valuePlusDistance = value.x + lastDistance; } else if (axis == Y_AXIS) { nodePoint = node.id.y; valuePlusDistance = value.y + lastDistance; } else { nodePoint = node.id.z; valuePlusDistance = value.z + lastDistance; } boolean lineIntersectsCube = ((valuePlusDistance >= nodePoint) ? true : false); //Continue down greater branch if (lineIntersectsCube) searchNode(value, greater, K, results, examined); } } /** * {@inheritDoc} */ @Override public String toString() { return TreePrinter.getString(this); } protected static class EuclideanComparator implements Comparator<KdNode> { private XYZPoint point = null; public EuclideanComparator(XYZPoint point) { this.point = point; } /** * {@inheritDoc} */ @Override public int compare(KdNode o1, KdNode o2) { Double d1 = point.euclideanDistance(o1.id); Double d2 = point.euclideanDistance(o2.id); if (d1.compareTo(d2) < 0) return -1; else if (d2.compareTo(d1) < 0) return 1; return o1.id.compareTo(o2.id); } } ; public static class KdNode implements Comparable<KdNode> { private int k = 3; private int depth = 0; private XYZPoint id = null; private KdNode parent = null; private KdNode lesser = null; private KdNode greater = null; public KdNode(XYZPoint id) { this.id = id; } public KdNode(int k, int depth, XYZPoint id) { this(id); this.k = k; this.depth = depth; } public static int compareTo(int depth, int k, XYZPoint o1, XYZPoint o2) { int axis = depth % k; if (axis == X_AXIS) return X_COMPARATOR.compare(o1, o2); return Y_COMPARATOR.compare(o1, o2); } /** * {@inheritDoc} */ @Override public boolean equals(Object obj) { if (obj == null) return false; if (!(obj instanceof KdNode)) return false; KdNode kdNode = (KdNode) obj; if (this.compareTo(kdNode) == 0) return true; return false; } /** * {@inheritDoc} */ @Override public int compareTo(KdNode o) { return compareTo(depth, k, this.id, o.id); } /** * {@inheritDoc} */ @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("k=").append(k); builder.append(" depth=").append(depth); builder.append(" id=").append(id.toString()); return builder.toString(); } } public static class XYZPoint implements Comparable<XYZPoint> { protected double x = Double.NEGATIVE_INFINITY; protected double y = Double.NEGATIVE_INFINITY; protected double z = Double.NEGATIVE_INFINITY; public XYZPoint(double x, double y) { this.x = x; this.y = y; this.z = 0; } public XYZPoint(double x, int y, double z) { this.x = x; this.y = y; this.z = z; } /** * Computes the Euclidean distance from this point to the other. * * @param o1 other point. * @return euclidean distance. */ public double euclideanDistance(XYZPoint o1) { return euclideanDistance(o1, this); } /** * Computes the Euclidean distance from one point to the other. * * @param o1 first point. * @param o2 second point. * @return euclidean distance. */ private static final double euclideanDistance(XYZPoint o1, XYZPoint o2) { return Math.sqrt(Math.pow((o1.x - o2.x), 2) + Math.pow((o1.y - o2.y), 2) + Math.pow((o1.z - o2.z), 2)); } ; /** * {@inheritDoc} */ @Override public boolean equals(Object obj) { if (obj == null) return false; if (!(obj instanceof XYZPoint)) return false; XYZPoint xyzPoint = (XYZPoint) obj; int xComp = X_COMPARATOR.compare(this, xyzPoint); if (xComp != 0) return false; int yComp = Y_COMPARATOR.compare(this, xyzPoint); return (yComp == 0); } /** * {@inheritDoc} */ @Override public int compareTo(XYZPoint o) { int xComp = X_COMPARATOR.compare(this, o); if (xComp != 0) return xComp; int yComp = Y_COMPARATOR.compare(this, o); return yComp; } /** * {@inheritDoc} */ @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("("); builder.append(x).append(", "); builder.append(y).append(", "); builder.append(z); builder.append(")"); return builder.toString(); } } protected static class TreePrinter { public static <T extends XYZPoint> String getString(KdTree<T> tree) { if (tree.root == null) return "Tree has no nodes."; return getString(tree.root, "", true); } private static <T extends Comparable<T>> String getString(KdNode node, String prefix, boolean isTail) { StringBuilder builder = new StringBuilder(); if (node.parent != null) { String side = "left"; if (node.parent.greater != null && node.id.equals(node.parent.greater.id)) side = "right"; builder.append(prefix + (isTail ? "└── " : "├── ") + "[" + side + "] " + "depth=" + node.depth + " id=" + node.id + "\n"); } else { builder.append(prefix + (isTail ? "└── " : "├── ") + "depth=" + node.depth + " id=" + node.id + "\n"); } List<KdNode> children = null; if (node.lesser != null || node.greater != null) { children = new ArrayList<KdNode>(2); if (node.lesser != null) children.add(node.lesser); if (node.greater != null) children.add(node.greater); } if (children != null) { for (int i = 0; i < children.size() - 1; i++) { builder.append(getString(children.get(i), prefix + (isTail ? " " : "│ "), false)); } if (children.size() >= 1) { builder.append(getString(children.get(children.size() - 1), prefix + (isTail ? " " : "│ "), true)); } } return builder.toString(); } } }
7e4503eddc022a7b7d7871a2221a3f4e762fa1cf
f5e7d11622d6339340df729f5361a863c9c37136
/droidparts/src/org/droidparts/contract/Constants.java
3914affd83c13de8b7037310ac8e4851f49cb1d7
[ "Apache-2.0" ]
permissive
evsward/droidparts
06c07cf997f11a051fe89abf5ec8b40d799bec63
3a2f03d915709cb29aa5dbd5a35fe989f16c9fc1
refs/heads/master
2021-01-24T22:02:53.853607
2016-08-28T11:39:41
2016-08-28T11:39:41
35,606,381
0
0
null
2015-05-14T10:53:49
2015-05-14T10:53:49
null
UTF-8
Java
false
false
723
java
/** * Copyright 2015 Alex Yanchenko * * 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.droidparts.contract; public interface Constants { String UTF8 = "utf-8"; int BUFFER_SIZE = 8 * 1024; }
59ff50ae4bae38e63e1df6691910acf6fddb20b9
07ee9b026bc35b6fe4e8f9b9d75a91171bad66f8
/src/main/java/com/thinkgem/jeesite/modules/novel/service/NuserService.java
fda38c72aca8742ab4587cc735dac433b905a294
[]
no_license
luotianwen/novel
788ca0369532e5630371e1be88ec78317b9f636e
0d1028652a87b573df9678f546006f29469e9612
refs/heads/master
2023-03-08T05:34:04.720727
2021-02-19T07:12:38
2021-02-19T07:12:38
339,988,201
0
0
null
null
null
null
UTF-8
Java
false
false
1,151
java
/** * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved. */ package com.thinkgem.jeesite.modules.novel.service; import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.thinkgem.jeesite.common.persistence.Page; import com.thinkgem.jeesite.common.service.CrudService; import com.thinkgem.jeesite.modules.novel.entity.Nuser; import com.thinkgem.jeesite.modules.novel.dao.NuserDao; /** * 用户管理Service * @author 用户管理 * @version 2021-02-19 */ @Service @Transactional(readOnly = true) public class NuserService extends CrudService<NuserDao, Nuser> { public Nuser get(String id) { return super.get(id); } public List<Nuser> findList(Nuser nuser) { return super.findList(nuser); } public Page<Nuser> findPage(Page<Nuser> page, Nuser nuser) { return super.findPage(page, nuser); } @Transactional(readOnly = false) public void save(Nuser nuser) { super.save(nuser); } @Transactional(readOnly = false) public void delete(Nuser nuser) { super.delete(nuser); } }
06ea2056937293645cc8806cc17403b577bb867f
f8ad9588180419cf306cde1db6f021d3782d7992
/src/main/java/it/unipd/tos/model/User.java
2fe569fdaf03fbb1c6deb119eae5b157f43fa8f7
[]
no_license
tpoppi/assignment2
97941ee2b48eac88589a2291b9a50b859abae5d4
c5c50434dc151709f9378d7343264b4e8a52558e
refs/heads/master
2023-01-24T09:30:51.845106
2020-12-08T23:04:11
2020-12-08T23:04:11
318,980,400
0
0
null
null
null
null
UTF-8
Java
false
false
654
java
//////////////////////////////////////////////////////////////////// // [TOMMASO] [POPPI] [1201270] //////////////////////////////////////////////////////////////////// package it.unipd.tos.model; import java.time.LocalDate; public class User { private int id; private String name; private LocalDate data_nascita; public User(int num, String nome, LocalDate data) { this.id = num; this.name = nome; this.data_nascita = data; } public String getName() { return name; } public int getId() { return id; } public LocalDate getDate() { return data_nascita; } }
ea0ce1f8e30c6695be9128c7d85b4cc8a4a742b0
1629612459b3c9411b9238e53976690e496cc11c
/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/sampleOpModes/TrackWidthTuner.java
3f02125f3764e2711b6eb836a0ae7d589755b5f1
[]
no_license
zerozerodone/FTC_2021-2022
eab9bbe4ee2510a18b3662c4544f18d3ccf93660
14f0b2a530c57f29aad0f7477e993a9a327f7512
refs/heads/master
2023-08-28T04:58:49.451853
2021-10-25T21:34:06
2021-10-25T21:34:06
421,190,996
0
1
null
null
null
null
UTF-8
Java
false
false
3,573
java
package org.firstinspires.ftc.teamcode.drive.sampleOpModes; import com.acmerobotics.dashboard.FtcDashboard; import com.acmerobotics.dashboard.config.Config; import com.acmerobotics.dashboard.telemetry.MultipleTelemetry; import com.acmerobotics.roadrunner.geometry.Pose2d; import com.acmerobotics.roadrunner.util.Angle; import com.qualcomm.robotcore.eventloop.opmode.Autonomous; import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; import com.qualcomm.robotcore.util.MovingStatistics; import org.firstinspires.ftc.robotcore.internal.system.Misc; import org.firstinspires.ftc.teamcode.drive.DriveConstants; import org.firstinspires.ftc.teamcode.drive.SampleMecanumDrive; /* * This routine determines the effective track width. The procedure works by executing a point turn * with a given angle and measuring the difference between that angle and the actual angle (as * indicated by an external IMU/gyro, track wheels, or some other localizer). The quotient * given angle / actual angle gives a multiplicative adjustment to the estimated track width * (effective track width = estimated track width * given angle / actual angle). The routine repeats * this procedure a few times and averages the values for additional accuracy. Note: a relatively * accurate track width estimate is important or else the angular constraints will be thrown off. */ @Config @Autonomous(group = "drive") public class TrackWidthTuner extends LinearOpMode { public static double ANGLE = 180; // deg public static int NUM_TRIALS = 5; public static int DELAY = 1000; // ms @Override public void runOpMode() throws InterruptedException { telemetry = new MultipleTelemetry(telemetry, FtcDashboard.getInstance().getTelemetry()); SampleMecanumDrive drive = new SampleMecanumDrive(hardwareMap); // TODO: if you haven't already, set the localizer to something that doesn't depend on // drive encoders for computing the heading telemetry.addLine("Press play to begin the track width tuner routine"); telemetry.addLine("Make sure your robot has enough clearance to turn smoothly"); telemetry.update(); waitForStart(); if (isStopRequested()) return; telemetry.clearAll(); telemetry.addLine("Running..."); telemetry.update(); MovingStatistics trackWidthStats = new MovingStatistics(NUM_TRIALS); for (int i = 0; i < NUM_TRIALS; i++) { drive.setPoseEstimate(new Pose2d()); // it is important to handle heading wraparounds double headingAccumulator = 0; double lastHeading = 0; drive.turnAsync(Math.toRadians(ANGLE)); while (!isStopRequested() && drive.isBusy()) { double heading = drive.getPoseEstimate().getHeading(); headingAccumulator += Angle.norm(heading - lastHeading); lastHeading = heading; drive.update(); } double trackWidth = DriveConstants.TRACK_WIDTH * Math.toRadians(ANGLE) / headingAccumulator; trackWidthStats.add(trackWidth); sleep(DELAY); } telemetry.clearAll(); telemetry.addLine("Tuning complete"); telemetry.addLine(Misc.formatInvariant("Effective track width = %.2f (SE = %.3f)", trackWidthStats.getMean(), trackWidthStats.getStandardDeviation() / Math.sqrt(NUM_TRIALS))); telemetry.update(); while (!isStopRequested()) { idle(); } } }
3287ab7cf759b3546323bc2785fbe3f09001b1c4
bb8739e84e457cb25355686af267e3729823b54d
/arena-gwt/tags/arena-gwt-2.1/src/main/java/org/openinsula/arena/gwt/components/client/ui/form/field/value/CheckBoxValueHandler.java
c00748eef539d91fc81dd661ba99f63cc4d58211
[]
no_license
mateusferrer/openinsula-arena
d62a86f86558e471bf4ec7b694638fb6d940213c
e52c168755472de0b5da0e237c242c366c44c193
refs/heads/master
2020-07-08T10:29:32.594695
2009-07-18T03:54:57
2009-07-18T03:54:57
35,433,033
0
1
null
null
null
null
UTF-8
Java
false
false
500
java
package org.openinsula.arena.gwt.components.client.ui.form.field.value; import com.google.gwt.user.client.ui.CheckBox; /** * @author Lucas K Mogari */ public class CheckBoxValueHandler implements FieldValueHandler<CheckBox> { @SuppressWarnings("unchecked") public <V> V getValue(CheckBox widget) { return (V) Boolean.valueOf(widget.isChecked()); } public void setValue(CheckBox widget, Object value) { widget.setChecked(value == null ? false : Boolean.valueOf(value.toString())); } }
[ "erdanielli@4e3340f0-7962-11de-bdc7-1f637afd43b1" ]
erdanielli@4e3340f0-7962-11de-bdc7-1f637afd43b1
c4ef698288f0662a19fd9f47f13e2865ba7ce7c4
e39e03ff7634373754582f37a9ab5f29158bd180
/src/main/scala/net/machinemuse/numina/geometry/MuseRect.java
6b887e999aea07e38d64f674f3bba290508b6843
[]
no_license
QMXTech/Numina
a8ac98dd1d0169044e97851542690f90cb890f96
e824c0ee1b08dfc2128358fb9dd135347e3fc2dc
refs/heads/master
2021-01-17T16:01:38.038191
2015-02-24T21:48:33
2015-02-24T21:48:33
28,331,663
1
1
null
null
null
null
UTF-8
Java
false
false
2,154
java
package net.machinemuse.numina.geometry; public class MuseRect { MusePoint2D ul; MusePoint2D wh; public MuseRect(double left, double top, double right, double bottom, boolean growFromMiddle) { ul = new MusePoint2D(left, top); wh = new MusePoint2D(right - left, bottom - top); if (growFromMiddle) { MusePoint2D center = ul.plus(wh.times(0.5)); this.ul = new FlyFromPointToPoint2D(center, ul, 200); this.wh = new FlyFromPointToPoint2D(new MusePoint2D(0, 0), wh, 200); } } public MuseRect(double left, double top, double right, double bottom) { this(left, top, right, bottom, false); } public MuseRect(MusePoint2D ul, MusePoint2D br) { this.ul = ul; this.wh = br.minus(ul); } public double left() { return ul.x(); } public double right() { return ul.x() + wh.x(); } public double top() { return ul.y(); } public double bottom() { return ul.y() + wh.y(); } public double width() { return wh.x(); } public double height() { return wh.y(); } public MuseRect setLeft(double value) { ul.x = value; return this; } public MuseRect setRight(double value) { wh.x = value - ul.x(); return this; } public MuseRect setTop(double value) { ul.y = value; return this; } public MuseRect setBottom(double value) { wh.y = value - ul.y(); return this; } public MuseRect setWidth(double value) { wh.x = value; return this; } public MuseRect setHeight(double value) { wh.y = value; return this; } public boolean equals(MuseRect other) { return ul.equals(other.ul) && wh.equals(other.wh); } public boolean containsPoint(double x, double y) { return x > left() && x < right() && y > top() && y < bottom(); } public double centerx() { return (left() + right()) / 2.0; } public double centery() { return (top() + bottom()) / 2.0; } }