blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
7
332
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
50
license_type
stringclasses
2 values
repo_name
stringlengths
7
115
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
557 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
684M
star_events_count
int64
0
77.7k
fork_events_count
int64
0
48k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
82 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
5.41M
extension
stringclasses
11 values
content
stringlengths
7
5.41M
authors
sequencelengths
1
1
author
stringlengths
0
161
c5f3ebac37bea0764c19c7f5869effcaf7c6483d
03c3dc52d2cf0fb7ac47ecc960c6d6bf91b98364
/src/main/java/net/aetherteam/aether/items/ItemVampireBlade.java
6e6c004b440c0dbb280469e885da84c8815820fb
[]
no_license
3TUSK/AE2
f2bb1fdb8b43b682eea98f676c3494591fc00132
d9813f848032fd7e7d1cb92dff4652d1b439ad82
refs/heads/master
2021-01-20T17:43:30.166937
2013-06-17T03:22:11
2013-06-17T03:22:11
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,333
java
package net.aetherteam.aether.items; import java.util.Random; import net.aetherteam.aether.Aether; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; public class ItemVampireBlade extends ItemSword { private int weaponDamage; private static Random random = new Random(); public ItemVampireBlade(int var1) { super(var1, EnumToolMaterial.EMERALD); this.maxStackSize = 1; this.setMaxDamage(EnumToolMaterial.EMERALD.getMaxUses()); this.weaponDamage = 4 + EnumToolMaterial.EMERALD.getDamageVsEntity() * 2; } /** * Returns the damage against a given entity. */ public int getDamageVsEntity(Entity var1) { return this.weaponDamage; } /** * Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if * sword */ public float getStrVsBlock(ItemStack var1, Block var2) { return 1.5F; } public Item setIconName(String var1) { return this.setUnlocalizedName("Aether:" + var1); } /** * Current implementations of this method in child classes do not use the entry argument beside ev. They just raise * the damage on the stack. */ public boolean hitEntity(ItemStack var1, EntityLiving var2, EntityLiving var3) { EntityPlayer var4 = (EntityPlayer) var3; if (Aether.getServerPlayer(var4) == null) { return true; } else { if (var4.getHealth() < Aether.getServerPlayer(var4).maxHealth && var2.hurtTime > 0 && var2.deathTime <= 0) { var4.heal(1); } var1.damageItem(1, var3); return true; } } /** * Returns True is the item is renderer in full 3D when hold. */ public boolean isFull3D() { return true; } public boolean onBlockDestroyed(ItemStack var1, int var2, int var3, int var4, int var5, EntityLiving var6) { var1.damageItem(2, var6); return true; } }
70db09d4e646dad411c919b8b819d73f864f7e07
1f20337903e51a149d9304cb05b248b8d134521f
/examples/example2/src/main/java/org/apache/camel/example/fhir/Hl7Decoder.java
31f4dfc0b887bcb276c18a2623aead63afc2ab22
[]
no_license
johnpoth/fhirdevdays2018
749fa3661d569c4009df514ac43cbd3bfa5157e8
cb7f0ef3a48626d203115dc66923083492d0bb7c
refs/heads/master
2020-04-02T06:04:18.900574
2018-11-19T14:07:51
2018-11-19T14:07:51
154,126,871
0
0
null
null
null
null
UTF-8
Java
false
false
419
java
package org.apache.camel.example.fhir; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.Produces; import javax.inject.Named; import org.apache.camel.component.hl7.HL7MLLPNettyDecoderFactory; public class Hl7Decoder { @Produces @ApplicationScoped @Named("hl7decoder") HL7MLLPNettyDecoderFactory properties() { return new HL7MLLPNettyDecoderFactory(); } }
47d04071a22c3571b17afd94f4ce421f6adc618a
862ef10d9a7155a85178f7bd39f9553cfb006573
/tarokka/src/com/patrhom/tarokka/Deck.java
2b578b0554f77b929096c079b4b8103a0a2152d0
[]
no_license
PurelyApplied/LibGdxPlayground
01a92cd371d823af9c1fa7b01b31051a6696c2d9
1f7ca8bdc3a25d8bb4cabd6ac16796fde4c1ff8f
refs/heads/master
2021-04-09T17:23:24.315858
2018-03-19T06:24:30
2018-03-19T06:24:30
125,758,385
0
0
null
null
null
null
UTF-8
Java
false
false
1,612
java
/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package com.patrhom.tarokka; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Deck { public static List<Card> buildDeck(){ List<Card> deck = buildCommonDeck(); deck.addAll(buildHighDeck()); return deck; } public static List<Card> buildCommonDeck(){ List<Card> deck = new ArrayList<Card>(); for (Suit suit: Arrays.asList(Suit.Coins, Suit.Glyphs, Suit.Stars, Suit.Swords)){ for (Integer value=0; value < 10 ; value++) { deck.add(new Card(suit, value)); } deck.add(new Card(suit)); } return deck; } public static List<Card> buildHighDeck(){ List<Card> deck = new ArrayList<Card>(); for (HighDeckValue value: HighDeckValue.values()){ deck.add(new Card(value.toString())); } return deck; } }
88cf1973d6060ef5381fa356e015295a437d43a3
01e5fd4d0fe51e5d49baf7d49c22bc74e34deee9
/tests/testprojects/org.pitest.pitclipse.testprojects.threeclasses/src/foobar/FooTest.java
75a45e6814078c628bdf4a1f611bebc499b00344
[ "Apache-2.0" ]
permissive
Bananeweizen/pitclipse
0a28d3f3fc3943aa4515e7f0eca40002e895c98b
75522acd61f23fda9e730dd2f6fcfc8943917efa
refs/heads/master
2022-10-08T08:03:00.374153
2022-09-02T08:56:43
2022-09-02T08:56:43
223,557,449
0
0
Apache-2.0
2019-11-23T08:36:46
2019-11-23T08:36:45
null
UTF-8
Java
false
false
139
java
package foobar; public class FooTest { @org.junit.Test public void badTest() { Foo1 x = new Foo1(); x.f(1); } }
d0ee91f43bf3d640c5faa63827535240504fe4af
c5d4abaea65846f9c54220028adabb32e22b59bd
/src/main/java/com/dominiks/demo/controller/HomeController.java
a2f94873445cc65ac28023e511051c35fff63d57
[]
no_license
Domi305/MRWebApi
d615038a6460084c0a33b974256a053351b36802
056a57e24f4bc9837987afab2d7749e3ee66bab7
refs/heads/master
2023-08-11T18:41:52.338324
2021-09-11T23:08:22
2021-09-11T23:08:22
405,781,596
0
0
null
null
null
null
UTF-8
Java
false
false
1,389
java
package com.dominiks.demo.controller; import com.dominiks.demo.Dto.HomeDto; import com.dominiks.demo.response.MarsRoverApiResponse; import com.dominiks.demo.service.MarsRoverApiService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.ui.ModelMap; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; @Controller public class HomeController { @Autowired private MarsRoverApiService roverApiService; @GetMapping("/") public String getHomeView(Model model, HomeDto homeDto) { //if request param is empty, then set default value if (StringUtils.isEmpty(homeDto.getMarsApiRoverData())) { homeDto.setMarsApiRoverData("Curiosity"); } if (homeDto.getMarsSol() == null) homeDto.setMarsSol(1); MarsRoverApiResponse roverData = roverApiService.getRoverData(homeDto); model.addAttribute("roverData", roverData); model.addAttribute("homeDto", homeDto); model.addAttribute("validCameras", roverApiService.getValidCameras().get(homeDto.getMarsApiRoverData())); return "index"; } }
5168f8ac85267a8091cfd04986675246bbf05e38
df40dd7a99e5521afe4acaf721e38d7996fc1d2b
/Netflix/src/org/chromium/content/browser/ContentViewCore.java
509534cb1e1fa12c33aa6d44ed03d43ef55aad28
[]
no_license
toandrew/netflix
36aed17beaf8a7449c02de718ae0fe6023412da7
39c6029bb4f78d26345bd1ccdffb3ee63b0239df
refs/heads/master
2016-09-10T20:43:29.738985
2015-01-12T04:46:22
2015-01-12T04:46:22
28,948,940
1
3
null
null
null
null
UTF-8
Java
false
false
74,250
java
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://kpdus.tripod.com/jad.html // Decompiler options: packimports(3) fieldsfirst ansi space package org.chromium.content.browser; import android.app.Activity; import android.content.ContentResolver; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.*; import android.net.Uri; import android.os.*; import android.text.Editable; import android.util.*; import android.view.*; import android.view.accessibility.*; import android.view.inputmethod.*; import android.widget.AbsoluteLayout; import android.widget.FrameLayout; import java.io.File; import java.lang.reflect.Field; import java.util.*; import org.chromium.base.WeakContext; import org.chromium.content.browser.accessibility.AccessibilityInjector; import org.chromium.content.browser.accessibility.BrowserAccessibilityManager; import org.chromium.content.browser.input.AdapterInputConnection; import org.chromium.content.browser.input.ImeAdapter; import org.chromium.content.browser.input.InputMethodManagerWrapper; import org.chromium.content.browser.input.InsertionHandleController; import org.chromium.content.browser.input.SelectPopupDialog; import org.chromium.content.browser.input.SelectionHandleController; import org.chromium.content.common.TraceEvent; import org.chromium.ui.*; import org.chromium.ui.gfx.DeviceDisplayInfo; // Referenced classes of package org.chromium.content.browser: // NavigationClient, HeapStatsLogger, RenderCoordinates, NavigationEntry, // NavigationHistory, ContentViewGestureHandler, PopupZoomer, SmoothScroller, // ContentViewClient, ZoomManager, ChildProcessLauncher, JavascriptInterface, // WebCryptoJavascriptInterface, DeviceUtils, ContentSettings, LoadUrlParams, // InterstitialPageDelegateAndroid, ContentViewDownloadDelegate, WebContentsObserverAndroid, ContentVideoViewClient, // TouchPoint public class ContentViewCore implements ContentViewGestureHandler.MotionEventDelegate, NavigationClient, android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener { public static interface GestureStateListener { public abstract void onFlingCancelGesture(); public abstract void onFlingStartGesture(int i, int j); public abstract void onPinchGestureEnd(); public abstract void onPinchGestureStart(); public abstract void onUnhandledFlingStartEvent(); } public static interface InternalAccessDelegate { public abstract boolean awakenScrollBars(); public abstract boolean drawChild(Canvas canvas, View view, long l); public abstract boolean super_awakenScrollBars(int i, boolean flag); public abstract boolean super_dispatchKeyEvent(KeyEvent keyevent); public abstract boolean super_dispatchKeyEventPreIme(KeyEvent keyevent); public abstract void super_onConfigurationChanged(Configuration configuration); public abstract boolean super_onGenericMotionEvent(MotionEvent motionevent); public abstract boolean super_onKeyUp(int i, KeyEvent keyevent); } public static interface JavaScriptCallback { public abstract void handleJavaScriptResult(String s); } public static interface UpdateFrameInfoListener { public abstract void onFrameInfoUpdated(float f, float f1, float f2); } public static interface ZoomControlsDelegate { public abstract void dismissZoomPicker(); public abstract void invokeZoomPicker(); public abstract void updateZoomControls(); } static final boolean $assertionsDisabled = false; public static final int INPUT_EVENTS_DELIVERED_AT_VSYNC = 1; public static final int INPUT_EVENTS_DELIVERED_IMMEDIATELY = 0; private static final int IS_LONG_PRESS = 1; private static final int IS_LONG_TAP = 2; private static final String TAG = "ContentViewCore"; private static final int TEXT_HANDLE_FADE_IN_DELAY = 300; private static final float ZOOM_CONTROLS_EPSILON = 0.007F; private AccessibilityInjector mAccessibilityInjector; private final AccessibilityManager mAccessibilityManager = (AccessibilityManager)getContext().getSystemService("accessibility"); private ContentObserver mAccessibilityScriptInjectionObserver; private ActionMode mActionMode; private org.chromium.content.browser.input.ImeAdapter.AdapterInputConnectionFactory mAdapterInputConnectionFactory; private boolean mAttachedToWindow; private BrowserAccessibilityManager mBrowserAccessibilityManager; private ViewGroup mContainerView; private InternalAccessDelegate mContainerViewInternals; private ContentSettings mContentSettings; private ContentViewClient mContentViewClient; private ContentViewGestureHandler mContentViewGestureHandler; private final Context mContext; private Runnable mDeferredHandleFadeInRunnable; private boolean mDidSignalVSyncUsingInputEvent; private ContentViewDownloadDelegate mDownloadDelegate; private final RenderCoordinates.NormalizedPoint mEndHandlePoint; private Runnable mFakeMouseMoveRunnable; private final Rect mFocusPreOSKViewportRect = new Rect(); private GestureStateListener mGestureStateListener; private boolean mHardwareAccelerated; private boolean mHasSelection; private ImeAdapter mImeAdapter; private AdapterInputConnection mInputConnection; private InsertionHandleController mInsertionHandleController; private final RenderCoordinates.NormalizedPoint mInsertionHandlePoint; private final Map mJavaScriptInterfaces = new HashMap(); private String mLastSelectedText; private int mNativeContentViewCore; private boolean mNeedAnimate; private boolean mNeedUpdateOrientationChanged; private int mOverdrawBottomHeightPix; private boolean mPendingRendererFrame; private int mPhysicalBackingHeightPix; private int mPhysicalBackingWidthPix; private int mPid; private PopupZoomer mPopupZoomer; private final RenderCoordinates mRenderCoordinates = new RenderCoordinates(); private final HashSet mRetainedJavaScriptObjects = new HashSet(); private boolean mScrolledAndZoomedFocusedEditableNode; private boolean mSelectionEditable; private SelectionHandleController mSelectionHandleController; private final RenderCoordinates.NormalizedPoint mStartHandlePoint; private boolean mUnfocusOnNextSizeChanged; private boolean mUnselectAllOnActionModeDismiss; private UpdateFrameInfoListener mUpdateFrameInfoListener; private VSyncManager.Listener mVSyncListener; private boolean mVSyncListenerRegistered; private VSyncManager.Provider mVSyncProvider; private int mVSyncSubscriberCount; private ViewAndroid mViewAndroid; private int mViewportHeightPix; private int mViewportSizeOffsetHeightPix; private int mViewportSizeOffsetWidthPix; private int mViewportWidthPix; private WebContentsObserverAndroid mWebContentsObserver; private WebCryptoJavascriptInterface mWebCryptoJavascriptInterface; private ZoomControlsDelegate mZoomControlsDelegate; private ZoomManager mZoomManager; public ContentViewCore(Context context) { mNativeContentViewCore = 0; mAttachedToWindow = false; mPid = 0; mFakeMouseMoveRunnable = null; mUnfocusOnNextSizeChanged = false; mScrolledAndZoomedFocusedEditableNode = false; mHardwareAccelerated = false; mPendingRendererFrame = false; mNeedAnimate = false; mContext = context; WeakContext.initializeWeakContext(context); HeapStatsLogger.init(mContext.getApplicationContext()); mAdapterInputConnectionFactory = new org.chromium.content.browser.input.ImeAdapter.AdapterInputConnectionFactory(); mRenderCoordinates.setDeviceScaleFactor(getContext().getResources().getDisplayMetrics().density); mStartHandlePoint = mRenderCoordinates.createNormalizedPoint(); mEndHandlePoint = mRenderCoordinates.createNormalizedPoint(); mInsertionHandlePoint = mRenderCoordinates.createNormalizedPoint(); } private void addToNavigationHistory(Object obj, int i, String s, String s1, String s2, String s3, Bitmap bitmap) { NavigationEntry navigationentry = new NavigationEntry(i, s, s1, s2, s3, bitmap); ((NavigationHistory)obj).addEntry(navigationentry); } private boolean allowTextHandleFadeIn() { while (mContentViewGestureHandler.isNativeScrolling() || mContentViewGestureHandler.isNativePinching() || mPopupZoomer.isShowing()) return false; return true; } private void animateIfNecessary(long l) { if (mNeedAnimate) { mNeedAnimate = onAnimate(l); if (!mNeedAnimate) setVSyncNotificationEnabled(false); } } private void confirmTouchEvent(int i) { mContentViewGestureHandler.confirmTouchEvent(i); } private ImeAdapter createImeAdapter(Context context) { return new ImeAdapter(new InputMethodManagerWrapper(context), new org.chromium.content.browser.input.ImeAdapter.ImeAdapterDelegate() { public View getAttachedView() { return mContainerView; } public ResultReceiver getNewShowKeyboardReceiver() { return new ResultReceiver(new Handler()) { public void onReceiveResult(int i, Bundle bundle) { ContentViewClient contentviewclient = getContentViewClient(); boolean flag; if (i == 2 || i == 0) flag = true; else flag = false; contentviewclient.onImeStateChangeRequested(flag); if (i == 2) { getContainerView().getWindowVisibleDisplayFrame(mFocusPreOSKViewportRect); return; } if (i == 0) { scrollFocusedEditableNodeIntoView(); return; } else { undoScrollFocusedEditableNodeIntoViewIfNeeded(false); return; } } }; } public void onDismissInput() { getContentViewClient().onImeStateChangeRequested(false); } public void onImeEvent(boolean flag) { getContentViewClient().onImeEvent(); if (!flag) { hideHandles(); undoScrollFocusedEditableNodeIntoViewIfNeeded(false); } } public void onSetFieldValue() { scrollFocusedEditableNodeIntoView(); } }); } private static Rect createRect(int i, int j, int k, int l) { return new Rect(i, j, k, l); } private SmoothScroller createSmoothScroller(boolean flag, int i, int j) { return new SmoothScroller(this, flag, i, j); } private ContentVideoViewClient getContentVideoViewClient() { return mContentViewClient.getContentVideoViewClient(); } private InsertionHandleController getInsertionHandleController() { if (mInsertionHandleController == null) { mInsertionHandleController = new InsertionHandleController(getContainerView()) { private static final int AVERAGE_LINE_HEIGHT = 14; public int getLineHeight() { return (int)Math.ceil(mRenderCoordinates.fromLocalCssToPix(14F)); } public void paste() { mImeAdapter.paste(); hideHandles(); } public void setCursorPosition(int i, int j) { if (mNativeContentViewCore != 0) nativeMoveCaret(mNativeContentViewCore, i, (float)j - mRenderCoordinates.getContentOffsetYPix()); } public void showHandle() { super.showHandle(); } }; mInsertionHandleController.hideAndDisallowAutomaticShowing(); } return mInsertionHandleController; } private SelectionHandleController getSelectionHandleController() { if (mSelectionHandleController == null) { mSelectionHandleController = new SelectionHandleController(getContainerView()) { public void selectBetweenCoordinates(int i, int j, int k, int l) { if (mNativeContentViewCore != 0 && (i != k || j != l)) nativeSelectBetweenCoordinates(mNativeContentViewCore, i, (float)j - mRenderCoordinates.getContentOffsetYPix(), k, (float)l - mRenderCoordinates.getContentOffsetYPix()); } public void showHandles(int i, int j) { super.showHandles(i, j); showSelectActionBar(); } }; mSelectionHandleController.hideAndDisallowAutomaticShowing(); } return mSelectionHandleController; } private void handleTapOrPress(long l, float f, float f1, int i, boolean flag) { // if (!mContainerView.isFocused()) // mContainerView.requestFocus(); // if (!mPopupZoomer.isShowing()) // mPopupZoomer.setLastTouch(f, f1); // if (i != 1) goto _L2; else goto _L1 //_L1: // getInsertionHandleController().allowAutomaticShowing(); // getSelectionHandleController().allowAutomaticShowing(); // if (mNativeContentViewCore != 0) // nativeLongPress(mNativeContentViewCore, l, f, f1, false); //_L4: // return; //_L2: // if (i != 2) // break; /* Loop/switch isn't completed */ // getInsertionHandleController().allowAutomaticShowing(); // getSelectionHandleController().allowAutomaticShowing(); // if (mNativeContentViewCore != 0) // { // nativeLongTap(mNativeContentViewCore, l, f, f1, false); // return; // } // if (true) goto _L4; else goto _L3 //_L3: // if (!flag && mNativeContentViewCore != 0) // nativeShowPressState(mNativeContentViewCore, l, f, f1); // if (mSelectionEditable) // getInsertionHandleController().allowAutomaticShowing(); // if (mNativeContentViewCore != 0) // { // nativeSingleTap(mNativeContentViewCore, l, f, f1, false); // return; // } // if (true) goto _L4; else goto _L5 //_L5: } public static boolean hasHardwareAcceleration(Activity activity) { return false; // Window window = activity.getWindow(); // if (window == null || (0x1000000 & window.getAttributes().flags) == 0) goto _L2; else goto _L1 //_L1: // int i; // return true; //_L2: // if (((i = activity.getPackageManager().getActivityInfo(activity.getComponentName(), 0).flags) & 0x200) != 0) goto _L1; else goto _L3 //_L3: // return false; // android.content.pm.PackageManager.NameNotFoundException namenotfoundexception; // namenotfoundexception; // Log.e("Chrome", "getActivityInfo(self) should not fail"); // if (true) goto _L3; else goto _L4 //_L4: } private static boolean hasHardwareAcceleration(Context context) { if (context instanceof Activity) return hasHardwareAcceleration((Activity)context); else return false; } private void hasTouchEventHandlers(boolean flag) { mContentViewGestureHandler.hasTouchEventHandlers(flag); } private void hideHandles() { if (mSelectionHandleController != null) mSelectionHandleController.hideAndDisallowAutomaticShowing(); if (mInsertionHandleController != null) mInsertionHandleController.hideAndDisallowAutomaticShowing(); } private void hidePopupDialog() { SelectPopupDialog.hide(this); hideHandles(); hideSelectActionBar(); } private void initPopupZoomer(Context context) { mPopupZoomer = new PopupZoomer(context); mPopupZoomer.setOnVisibilityChangedListener(new PopupZoomer.OnVisibilityChangedListener() { public void onPopupZoomerHidden(PopupZoomer popupzoomer) { mContainerView.post(new Runnable() { public void run() { // if (mContainerView.indexOfChild(popupzoomer) != -1) // { // mContainerView.removeView(popupzoomer); // mContainerView.invalidate(); // } else // if (!$assertionsDisabled) // throw new AssertionError("PopupZoomer should never be hidden without being shown"); } // static // { // boolean flag; // if (!org/chromium/content/browser/ContentViewCore.desiredAssertionStatus()) // flag = true; // else // flag = false; // $assertionsDisabled = flag; // } }); } public void onPopupZoomerShown(PopupZoomer popupzoomer) { mContainerView.post(new Runnable() { public void run() { // if (mContainerView.indexOfChild(zoomer) == -1) // mContainerView.addView(zoomer); // else // if (!$assertionsDisabled) // throw new AssertionError("PopupZoomer should never be shown without being hidden"); } // static // { // boolean flag; // if (!org/chromium/content/browser/ContentViewCore.desiredAssertionStatus()) // flag = true; // else // flag = false; // $assertionsDisabled = flag; // } }); } }); PopupZoomer.OnTapListener ontaplistener = new PopupZoomer.OnTapListener() { public boolean onLongPress(View view, MotionEvent motionevent) { if (mNativeContentViewCore != 0) nativeLongPress(mNativeContentViewCore, motionevent.getEventTime(), motionevent.getX(), motionevent.getY(), true); return true; } public boolean onSingleTap(View view, MotionEvent motionevent) { mContainerView.requestFocus(); if (mNativeContentViewCore != 0) nativeSingleTap(mNativeContentViewCore, motionevent.getEventTime(), motionevent.getX(), motionevent.getY(), true); return true; } }; mPopupZoomer.setOnTapListener(ontaplistener); } private void initializeContainerView(InternalAccessDelegate internalaccessdelegate, int i) { TraceEvent.begin(); mContainerViewInternals = internalaccessdelegate; mContainerView.setWillNotDraw(false); mContainerView.setFocusable(true); mContainerView.setFocusableInTouchMode(true); mContainerView.setClickable(true); mZoomManager = new ZoomManager(mContext, this); mContentViewGestureHandler = new ContentViewGestureHandler(mContext, this, mZoomManager, i); mZoomControlsDelegate = new ZoomControlsDelegate() { public void dismissZoomPicker() { } public void invokeZoomPicker() { } public void updateZoomControls() { } }; mRenderCoordinates.reset(); initPopupZoomer(mContext); mImeAdapter = createImeAdapter(mContext); TraceEvent.end(); } private boolean isInsertionHandleShowing() { return mInsertionHandleController != null && mInsertionHandleController.isShowing(); } private boolean isSelectionHandleShowing() { return mSelectionHandleController != null && mSelectionHandleController.isShowing(); } private boolean isVSyncNotificationEnabled() { return mVSyncProvider != null && mVSyncListenerRegistered; } private native void nativeAddJavascriptInterface(int i, Object obj, String s, Class class1, HashSet hashset); private native void nativeAttachExternalVideoSurface(int i, int j, Surface surface); private native boolean nativeCanGoBack(int i); private native boolean nativeCanGoForward(int i); private native boolean nativeCanGoToOffset(int i, int j); private native void nativeCancelPendingReload(int i); private native void nativeClearHistory(int i); private native void nativeClearSslPreferences(int i); private native void nativeContinuePendingReload(int i); private native boolean nativeCrashed(int i); private native void nativeDetachExternalVideoSurface(int i, int j); private native void nativeDoubleTap(int i, long l, float f, float f1); private native void nativeEvaluateJavaScript(int i, String s, JavaScriptCallback javascriptcallback); private native void nativeExitFullscreen(int i); private native void nativeFlingCancel(int i, long l); private native void nativeFlingStart(int i, long l, float f, float f1, float f2, float f3); private native int nativeGetBackgroundColor(int i); private native int nativeGetCurrentRenderProcessId(int i); private native void nativeGetDirectedNavigationHistory(int i, Object obj, boolean flag, int j); private native int nativeGetNativeImeAdapter(int i); private native int nativeGetNavigationHistory(int i, Object obj); private native String nativeGetOriginalUrlForActiveNavigationEntry(int i); private native int nativeGetPlayerCount(int i); private native String nativeGetTitle(int i); private native String nativeGetURL(int i); private native boolean nativeGetUseDesktopUserAgent(int i); private native void nativeGoBack(int i); private native void nativeGoForward(int i); private native void nativeGoToNavigationIndex(int i, int j); private native void nativeGoToOffset(int i, int j); private native int nativeInit(boolean flag, int i, int j, int k); private native boolean nativeIsIncognito(int i); private native boolean nativeIsRenderWidgetHostViewReady(int i); private native boolean nativeIsShowingInterstitialPage(int i); private native boolean nativeIsVideoPlaying(int i, int j); private native void nativeLoadUrl(int i, String s, int j, int k, int l, String s1, byte abyte0[], String s2, String s3, boolean flag); private native void nativeLongPress(int i, long l, float f, float f1, boolean flag); private native void nativeLongTap(int i, long l, float f, float f1, boolean flag); private native void nativeMoveCaret(int i, float f, float f1); private native boolean nativeNeedsReload(int i); private native boolean nativeOnAnimate(int i, long l); private native void nativeOnHide(int i); private native void nativeOnJavaContentViewCoreDestroyed(int i); private native void nativeOnShow(int i); private native void nativeOnVSync(int i, long l); private native void nativePinchBegin(int i, long l, float f, float f1); private native void nativePinchBy(int i, long l, float f, float f1, float f2, boolean flag); private native void nativePinchEnd(int i, long l); private native boolean nativePopulateBitmapFromCompositor(int i, Bitmap bitmap); private native void nativeReload(int i); private native void nativeRemoveJavascriptInterface(int i, String s); private native void nativeScrollBegin(int i, long l, float f, float f1); private native void nativeScrollBy(int i, long l, float f, float f1, float f2, float f3, boolean flag); private native void nativeScrollEnd(int i, long l); private native void nativeScrollFocusedEditableNodeIntoView(int i); private native void nativeSelectBetweenCoordinates(int i, float f, float f1, float f2, float f3); private native void nativeSelectPopupMenuItems(int i, int ai[]); private native int nativeSendMouseMoveEvent(int i, long l, float f, float f1); private native int nativeSendMouseWheelEvent(int i, long l, float f, float f1, float f2); private native void nativeSendOrientationChangeEvent(int i, int j); private native boolean nativeSendTouchEvent(int i, long l, int j, TouchPoint atouchpoint[]); private native void nativeSetAccessibilityEnabled(int i, boolean flag); private native void nativeSetFocus(int i, boolean flag); private native void nativeSetUseDesktopUserAgent(int i, boolean flag, boolean flag1); private native void nativeShowImeIfNeeded(int i); private native void nativeShowInterstitialPage(int i, String s, int j); private native void nativeShowPressCancel(int i, long l, float f, float f1); private native void nativeShowPressState(int i, long l, float f, float f1); private native void nativeSingleTap(int i, long l, float f, float f1, boolean flag); private native void nativeSingleTapUnconfirmed(int i, long l, float f, float f1); private native void nativeStopLoading(int i); private native void nativeUndoScrollFocusedEditableNodeIntoView(int i); private native void nativeUpdateTopControlsState(int i, boolean flag, boolean flag1, boolean flag2); private native void nativeUpdateVSyncParameters(int i, long l, long l1); private native void nativeWasResized(int i); private void notifyExternalSurface(int i, boolean flag, float f, float f1, float f2, float f3) { if (flag) getContentViewClient().onExternalVideoSurfaceRequested(i); getContentViewClient().onGeometryChanged(i, new RectF(f, f1, f + f2, f1 + f3)); } private boolean offerGestureToEmbedder(int i) { if (i == 5) return mContainerView.performLongClick(); else return false; } private boolean onAnimate(long l) { if (mNativeContentViewCore == 0) return false; else return nativeOnAnimate(mNativeContentViewCore, l); } private void onBackgroundColorChanged(int i) { getContentViewClient().onBackgroundColorChanged(i); } private static void onEvaluateJavaScriptResult(String s, JavaScriptCallback javascriptcallback) { javascriptcallback.handleJavaScriptResult(s); } private void onRenderProcessSwap(int i, int j) { if (!$assertionsDisabled && mPid != i && mPid != j) throw new AssertionError(); if (mAttachedToWindow && i != j) { ChildProcessLauncher.unbindAsHighPriority(i); ChildProcessLauncher.bindAsHighPriority(j); } ChildProcessLauncher.removeInitialBinding(j); mPid = j; } private void onSelectionBoundsChanged(Rect rect, int i, Rect rect1, int j, boolean flag) { // int k; // int l; // k = rect.left; // l = rect.bottom; // int i1 = rect1.left; // int j1 = rect1.bottom; // if (k != i1 || l != j1 || mSelectionHandleController != null && mSelectionHandleController.isDragging()) // { // if (mInsertionHandleController != null) // mInsertionHandleController.hide(); // if (flag) // { // mStartHandlePoint.setLocalDip(k, l); // mEndHandlePoint.setLocalDip(i1, j1); // } else // { // mStartHandlePoint.setLocalDip(i1, j1); // mEndHandlePoint.setLocalDip(k, l); // } // getSelectionHandleController().onSelectionChanged(i, j); // updateHandleScreenPositions(); // mHasSelection = true; // return; // } // mUnselectAllOnActionModeDismiss = false; // hideSelectActionBar(); // if (k == 0 || l == 0 || !mSelectionEditable) goto _L2; else goto _L1 //_L1: // if (mSelectionHandleController != null) // mSelectionHandleController.hide(); // mInsertionHandlePoint.setLocalDip(k, l); // getInsertionHandleController().onCursorPositionChanged(); // updateHandleScreenPositions(); // InputMethodManager inputmethodmanager = (InputMethodManager)getContext().getSystemService("input_method"); // if (inputmethodmanager.isWatchingCursor(mContainerView)) // { // int k1 = (int)mInsertionHandlePoint.getXPix(); // int l1 = (int)mInsertionHandlePoint.getYPix(); // inputmethodmanager.updateCursor(mContainerView, k1, l1, k1, l1); // } //_L4: // mHasSelection = false; // return; //_L2: // if (mSelectionHandleController != null) // mSelectionHandleController.hideAndDisallowAutomaticShowing(); // if (mInsertionHandleController != null) // mInsertionHandleController.hideAndDisallowAutomaticShowing(); // if (true) goto _L4; else goto _L3 //_L3: } private void onSelectionChanged(String s) { mLastSelectedText = s; } private void onTabCrash() { if (!$assertionsDisabled && mPid == 0) { throw new AssertionError(); } else { getContentViewClient().onRendererCrash(ChildProcessLauncher.isOomProtected(mPid)); mPid = 0; return; } } private void onWebContentsConnected() { if (mImeAdapter != null && !mImeAdapter.isNativeImeAdapterAttached() && mNativeContentViewCore != 0) mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentViewCore)); } private void onWebContentsSwapped() { if (mImeAdapter != null && mNativeContentViewCore != 0) mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentViewCore)); } private void onWebMediaPlayerCreated(int i) { getContentViewClient().onWebMediaPlayerCreated(i); } private void paintExternalSurface(int i, int j) { getContentViewClient().onPaintExternalSurface(i, j); } private void processImeBatchStateAck(boolean flag) { if (mInputConnection == null) { return; } else { mInputConnection.setIgnoreTextInputStateUpdates(flag); return; } } private void resetGestureDetectors() { mContentViewGestureHandler.resetGestureHandlers(); } private void resetVSyncNotification() { for (; isVSyncNotificationEnabled(); setVSyncNotificationEnabled(false)); mVSyncSubscriberCount = 0; mVSyncListenerRegistered = false; mNeedAnimate = false; } private void scheduleTextHandleFadeIn() { if (!isInsertionHandleShowing() && !isSelectionHandleShowing()) return; if (mDeferredHandleFadeInRunnable == null) mDeferredHandleFadeInRunnable = new Runnable() { public void run() { if (!allowTextHandleFadeIn()) { scheduleTextHandleFadeIn(); } else { if (isSelectionHandleShowing()) mSelectionHandleController.beginHandleFadeIn(); if (isInsertionHandleShowing()) { mInsertionHandleController.beginHandleFadeIn(); return; } } } }; mContainerView.removeCallbacks(mDeferredHandleFadeInRunnable); mContainerView.postDelayed(mDeferredHandleFadeInRunnable, 300L); } private void scrollFocusedEditableNodeIntoView() { if (mNativeContentViewCore != 0) { (new Runnable() { public void run() { if (mNativeContentViewCore != 0) nativeScrollFocusedEditableNodeIntoView(mNativeContentViewCore); } }).run(); mScrolledAndZoomedFocusedEditableNode = true; } } private void sendOrientationChangeEvent() { if (mNativeContentViewCore == 0) return; switch (((WindowManager)getContext().getSystemService("window")).getDefaultDisplay().getRotation()) { default: Log.w("ContentViewCore", "Unknown rotation!"); return; case 1: // '\001' nativeSendOrientationChangeEvent(mNativeContentViewCore, 90); return; case 2: // '\002' nativeSendOrientationChangeEvent(mNativeContentViewCore, 180); return; case 3: // '\003' nativeSendOrientationChangeEvent(mNativeContentViewCore, -90); return; case 0: // '\0' nativeSendOrientationChangeEvent(mNativeContentViewCore, 0); return; } } private void setNeedsAnimate() { if (!mNeedAnimate) { mNeedAnimate = true; setVSyncNotificationEnabled(true); } } private void setTitle(String s) { getContentViewClient().onUpdateTitle(s); } private void showDisambiguationPopup(Rect rect, Bitmap bitmap) { mPopupZoomer.setBitmap(bitmap); mPopupZoomer.show(rect); temporarilyHideTextHandles(); } private void showPastePopup(int i, int j) { mInsertionHandlePoint.setLocalDip(i, j); getInsertionHandleController().showHandle(); updateHandleScreenPositions(); getInsertionHandleController().showHandleWithPastePopup(); } private void showSelectActionBar() { if (mActionMode != null) { mActionMode.invalidate(); return; } SelectActionModeCallback.ActionHandler actionhandler = new SelectActionModeCallback.ActionHandler() { public boolean copy() { return mImeAdapter.copy(); } public boolean cut() { return mImeAdapter.cut(); } public String getSelectedText() { return ContentViewCore.this.getSelectedText(); } public boolean isSelectionEditable() { return mSelectionEditable; } public void onDestroyActionMode() { mActionMode = null; if (mUnselectAllOnActionModeDismiss) mImeAdapter.unselect(); getContentViewClient().onContextualActionBarHidden(); } public boolean paste() { return mImeAdapter.paste(); } public boolean selectAll() { return mImeAdapter.selectAll(); } }; mActionMode = null; if (mContainerView.getParent() != null) mActionMode = mContainerView.startActionMode(getContentViewClient().getSelectActionModeCallback(getContext(), actionhandler, nativeIsIncognito(mNativeContentViewCore))); mUnselectAllOnActionModeDismiss = true; if (mActionMode == null) { mImeAdapter.unselect(); return; } else { getContentViewClient().onContextualActionBarShown(); return; } } private void showSelectPopup(String as[], int ai[], boolean flag, int ai1[]) { SelectPopupDialog.show(this, as, ai, flag, ai1); } private void startContentIntent(String s) { getContentViewClient().onStartContentIntent(getContext(), s); } private void temporarilyHideTextHandles() { if (isSelectionHandleShowing()) mSelectionHandleController.setHandleVisibility(4); if (isInsertionHandleShowing()) mInsertionHandleController.setHandleVisibility(4); scheduleTextHandleFadeIn(); } private void undoScrollFocusedEditableNodeIntoViewIfNeeded(boolean flag) { if (mScrolledAndZoomedFocusedEditableNode && flag && mNativeContentViewCore != 0) (new Runnable() { public void run() { if (mNativeContentViewCore != 0) nativeUndoScrollFocusedEditableNodeIntoView(mNativeContentViewCore); } }).run(); mScrolledAndZoomedFocusedEditableNode = false; } private void unhandledFlingStartEvent() { if (mGestureStateListener != null) mGestureStateListener.onUnhandledFlingStartEvent(); } private void unregisterAccessibilityContentObserver() { if (mAccessibilityScriptInjectionObserver == null) { return; } else { getContext().getContentResolver().unregisterContentObserver(mAccessibilityScriptInjectionObserver); mAccessibilityScriptInjectionObserver = null; return; } } private void updateAfterSizeChanged() { // mPopupZoomer.hide(false); // if (mFocusPreOSKViewportRect.isEmpty()) goto _L2; else goto _L1 //_L1: // Rect rect = new Rect(); // getContainerView().getWindowVisibleDisplayFrame(rect); // if (!rect.equals(mFocusPreOSKViewportRect)) // { // scrollFocusedEditableNodeIntoView(); // mFocusPreOSKViewportRect.setEmpty(); // } //_L4: // if (mNeedUpdateOrientationChanged) // { // sendOrientationChangeEvent(); // mNeedUpdateOrientationChanged = false; // } // return; //_L2: // if (mUnfocusOnNextSizeChanged) // { // undoScrollFocusedEditableNodeIntoViewIfNeeded(true); // mUnfocusOnNextSizeChanged = false; // } // if (true) goto _L4; else goto _L3 //_L3: } private void updateFrameInfo(float f, float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, float f10, float f11) { TraceEvent.instant("ContentViewCore:updateFrameInfo"); float f12 = Math.max(f5, mRenderCoordinates.fromPixToLocalCss(mViewportWidthPix)); float f13 = Math.max(f6, mRenderCoordinates.fromPixToLocalCss(mViewportHeightPix)); float f14 = mRenderCoordinates.fromDipToPix(f10); boolean flag; boolean flag1; boolean flag2; boolean flag3; boolean flag4; boolean flag5; boolean flag6; boolean flag7; float f15; float f16; float f17; if (f12 != mRenderCoordinates.getContentWidthCss() || f13 != mRenderCoordinates.getContentHeightCss()) flag = true; else flag = false; if (f3 != mRenderCoordinates.getMinPageScaleFactor() || f4 != mRenderCoordinates.getMaxPageScaleFactor()) flag1 = true; else flag1 = false; if (f2 != mRenderCoordinates.getPageScaleFactor()) flag2 = true; else flag2 = false; if (flag2 || f != mRenderCoordinates.getScrollX() || f1 != mRenderCoordinates.getScrollY()) flag3 = true; else flag3 = false; if (f14 != mRenderCoordinates.getContentOffsetYPix()) flag4 = true; else flag4 = false; if (flag || flag3) flag5 = true; else flag5 = false; if (flag1 || flag3) flag6 = true; else flag6 = false; flag7 = flag3; if (flag5) mPopupZoomer.hide(true); if (flag2) getContentViewClient().onScaleChanged(mRenderCoordinates.getPageScaleFactor(), f2); mRenderCoordinates.updateFrameInfo(f, f1, f12, f13, f7, f8, f2, f3, f4, f14); if ((flag || flag2) && mUpdateFrameInfoListener != null) mUpdateFrameInfoListener.onFrameInfoUpdated(f12, f13, f2); if (flag7) temporarilyHideTextHandles(); if (flag6) mZoomControlsDelegate.updateZoomControls(); if (flag4) updateHandleScreenPositions(); f15 = mRenderCoordinates.getDeviceScaleFactor(); f16 = f9 * f15; f17 = f11 * f15; getContentViewClient().onOffsetsForFullscreenChanged(f16, f14, f17); mPendingRendererFrame = true; if (mBrowserAccessibilityManager != null) mBrowserAccessibilityManager.notifyFrameInfoInitialized(); getContentViewClient().onGeometryChanged(-1, null); } private void updateHandleScreenPositions() { if (isSelectionHandleShowing()) { mSelectionHandleController.setStartHandlePosition(mStartHandlePoint.getXPix(), mStartHandlePoint.getYPix()); mSelectionHandleController.setEndHandlePosition(mEndHandlePoint.getXPix(), mEndHandlePoint.getYPix()); } if (isInsertionHandleShowing()) mInsertionHandleController.setHandlePosition(mInsertionHandlePoint.getXPix(), mInsertionHandlePoint.getYPix()); } private void updateImeAdapter(int i, int j, String s, int k, int l, int i1, int j1, boolean flag) { TraceEvent.begin(); boolean flag1; if (j != ImeAdapter.getTextInputTypeNone()) flag1 = true; else flag1 = false; mSelectionEditable = flag1; if (mActionMode != null) mActionMode.invalidate(); mImeAdapter.attachAndShowIfNeeded(i, j, k, l, flag); if (mInputConnection != null) mInputConnection.setEditableText(s, k, l, i1, j1); TraceEvent.end(); } private void updateTextHandlesForGesture(int i) { switch (i) { default: return; case 1: // '\001' case 6: // '\006' case 9: // '\t' case 11: // '\013' temporarilyHideTextHandles(); break; } } private boolean zoomByDelta(float f) { if (mNativeContentViewCore == 0) { return false; } else { long l = System.currentTimeMillis(); int i = getViewportWidthPix() / 2; int j = getViewportHeightPix() / 2; getContentViewGestureHandler().pinchBegin(l, i, j); getContentViewGestureHandler().pinchBy(l, i, j, f); getContentViewGestureHandler().pinchEnd(l); return true; } } public void addJavascriptInterface(Object obj, String s) { addPossiblyUnsafeJavascriptInterface(obj, s, org.chromium.content.browser.JavascriptInterface.class); } public void addPossiblyUnsafeJavascriptInterface(Object obj, String s, Class class1) { if (mNativeContentViewCore != 0 && obj != null) { mJavaScriptInterfaces.put(s, obj); nativeAddJavascriptInterface(mNativeContentViewCore, obj, s, class1, mRetainedJavaScriptObjects); } } public void attachExternalVideoSurface(int i, Surface surface) { if (mNativeContentViewCore != 0) nativeAttachExternalVideoSurface(mNativeContentViewCore, i, surface); } public boolean awakenScrollBars(int i, boolean flag) { if (mContainerView.getScrollBarStyle() == 0) return false; else return mContainerViewInternals.super_awakenScrollBars(i, flag); } public boolean canGoBack() { return mNativeContentViewCore != 0 && nativeCanGoBack(mNativeContentViewCore); } public boolean canGoForward() { return mNativeContentViewCore != 0 && nativeCanGoForward(mNativeContentViewCore); } public boolean canGoToOffset(int i) { return mNativeContentViewCore != 0 && nativeCanGoToOffset(mNativeContentViewCore, i); } public boolean canZoomIn() { return mRenderCoordinates.getMaxPageScaleFactor() - mRenderCoordinates.getPageScaleFactor() > 0.007F; } public boolean canZoomOut() { return mRenderCoordinates.getPageScaleFactor() - mRenderCoordinates.getMinPageScaleFactor() > 0.007F; } public void cancelPendingReload() { if (mNativeContentViewCore != 0) nativeCancelPendingReload(mNativeContentViewCore); } void checkIsAlive() throws IllegalStateException { if (!isAlive()) throw new IllegalStateException("ContentView used after destroy() was called"); else return; } public void clearHistory() { if (mNativeContentViewCore != 0) nativeClearHistory(mNativeContentViewCore); } public void clearSslPreferences() { nativeClearSslPreferences(mNativeContentViewCore); } public int computeHorizontalScrollExtent() { return mRenderCoordinates.getLastFrameViewportWidthPixInt(); } public int computeHorizontalScrollOffset() { return mRenderCoordinates.getScrollXPixInt(); } public int computeHorizontalScrollRange() { return mRenderCoordinates.getContentWidthPixInt(); } public int computeVerticalScrollExtent() { return mRenderCoordinates.getLastFrameViewportHeightPixInt(); } public int computeVerticalScrollOffset() { return mRenderCoordinates.getScrollYPixInt(); } public int computeVerticalScrollRange() { return mRenderCoordinates.getContentHeightPixInt(); } public boolean consumePendingRendererFrame() { boolean flag = mPendingRendererFrame; mPendingRendererFrame = false; return flag; } public void continuePendingReload() { if (mNativeContentViewCore != 0) nativeContinuePendingReload(mNativeContentViewCore); } public void destroy() { if (mNativeContentViewCore != 0) nativeOnJavaContentViewCoreDestroyed(mNativeContentViewCore); resetVSyncNotification(); mVSyncProvider = null; if (mViewAndroid != null) mViewAndroid.destroy(); mNativeContentViewCore = 0; mContentSettings = null; mJavaScriptInterfaces.clear(); mRetainedJavaScriptObjects.clear(); unregisterAccessibilityContentObserver(); Log.d("ContentViewCore", "destroy called in ContentViewcore"); mWebCryptoJavascriptInterface.close(); } public void detachExternalVideoSurface(int i) { if (mNativeContentViewCore != 0) nativeDetachExternalVideoSurface(mNativeContentViewCore, i); } public boolean didUIStealScroll(float f, float f1) { return getContentViewClient().shouldOverrideScroll(f, f1, computeHorizontalScrollOffset(), computeVerticalScrollOffset()); } public boolean dispatchKeyEvent(KeyEvent keyevent) { if (getContentViewClient().shouldOverrideKeyEvent(keyevent)) return mContainerViewInternals.super_dispatchKeyEvent(keyevent); if (mImeAdapter.dispatchKeyEvent(keyevent)) return true; else return mContainerViewInternals.super_dispatchKeyEvent(keyevent); } public boolean dispatchKeyEventPreIme(KeyEvent keyevent) { return true; // TraceEvent.begin(); // if (keyevent.getKeyCode() != 4 || !mImeAdapter.isActive()) // break MISSING_BLOCK_LABEL_42; // mUnfocusOnNextSizeChanged = true; //_L1: // boolean flag = mContainerViewInternals.super_dispatchKeyEventPreIme(keyevent); // TraceEvent.end(); // return flag; // undoScrollFocusedEditableNodeIntoViewIfNeeded(false); // goto _L1 // Exception exception; // exception; // TraceEvent.end(); // throw exception; } public void evaluateJavaScript(String s, JavaScriptCallback javascriptcallback) throws IllegalStateException { checkIsAlive(); nativeEvaluateJavaScript(mNativeContentViewCore, s, javascriptcallback); } public void exitFullscreen() { nativeExitFullscreen(mNativeContentViewCore); } public AccessibilityNodeProvider getAccessibilityNodeProvider() { if (mBrowserAccessibilityManager != null) return mBrowserAccessibilityManager.getAccessibilityNodeProvider(); else return null; } public int getBackgroundColor() { if (mNativeContentViewCore != 0) return nativeGetBackgroundColor(mNativeContentViewCore); else return -1; } public Bitmap getBitmap() { return getBitmap(getViewportWidthPix(), getViewportHeightPix()); } public Bitmap getBitmap(int i, int j) { Bitmap bitmap; if (i == 0 || j == 0 || getViewportWidthPix() == 0 || getViewportHeightPix() == 0) { bitmap = null; } else { bitmap = Bitmap.createBitmap(i, j, android.graphics.Bitmap.Config.ARGB_8888); if (mNativeContentViewCore != 0 && nativePopulateBitmapFromCompositor(mNativeContentViewCore, bitmap)) { if (mContainerView.getChildCount() > 0) { Canvas canvas = new Canvas(bitmap); canvas.scale((float)i / (float)getViewportWidthPix(), (float)j / (float)getViewportHeightPix()); mContainerView.draw(canvas); return bitmap; } } else { return null; } } return bitmap; } public BrowserAccessibilityManager getBrowserAccessibilityManager() { return mBrowserAccessibilityManager; } public ViewGroup getContainerView() { return mContainerView; } public float getContentHeightCss() { return mRenderCoordinates.getContentHeightCss(); } public ContentSettings getContentSettings() { return mContentSettings; } ContentViewClient getContentViewClient() { if (mContentViewClient == null) mContentViewClient = new ContentViewClient(); return mContentViewClient; } ContentViewGestureHandler getContentViewGestureHandler() { return mContentViewGestureHandler; } public float getContentWidthCss() { return mRenderCoordinates.getContentWidthCss(); } public Context getContext() { return mContext; } public NavigationHistory getDirectedNavigationHistory(boolean flag, int i) { NavigationHistory navigationhistory = new NavigationHistory(); nativeGetDirectedNavigationHistory(mNativeContentViewCore, navigationhistory, flag, i); return navigationhistory; } ContentViewDownloadDelegate getDownloadDelegate() { return mDownloadDelegate; } public Editable getEditableForTest() { return mInputConnection.getEditable(); } public ImeAdapter getImeAdapterForTest() { return mImeAdapter; } public AdapterInputConnection getInputConnectionForTest() { return mInputConnection; } public InsertionHandleController getInsertionHandleControllerForTest() { return mInsertionHandleController; } public int getNativeContentViewCore() { return mNativeContentViewCore; } public int getNativeScrollXForTest() { return mRenderCoordinates.getScrollXPixInt(); } public int getNativeScrollYForTest() { return mRenderCoordinates.getScrollYPixInt(); } public NavigationHistory getNavigationHistory() { NavigationHistory navigationhistory = new NavigationHistory(); navigationhistory.setCurrentEntryIndex(nativeGetNavigationHistory(mNativeContentViewCore, navigationhistory)); return navigationhistory; } public String getOriginalUrlForActiveNavigationEntry() { return nativeGetOriginalUrlForActiveNavigationEntry(mNativeContentViewCore); } public int getOverdrawBottomHeightPix() { return mOverdrawBottomHeightPix; } public int getPhysicalBackingHeightPix() { return mPhysicalBackingHeightPix; } public int getPhysicalBackingWidthPix() { return mPhysicalBackingWidthPix; } public int getPlayerCount() { if (mNativeContentViewCore != 0) return nativeGetPlayerCount(mNativeContentViewCore); else return 0; } public RenderCoordinates getRenderCoordinates() { return mRenderCoordinates; } public float getScale() { return mRenderCoordinates.getPageScaleFactor(); } public Pair getScaledPerformanceOptimizedBitmap(int i, int j) { float f = 1.0F; if (DeviceUtils.isTablet(getContext())) f = getContext().getResources().getDisplayMetrics().density; return Pair.create(getBitmap((int)((float)i / f), (int)((float)j / f)), Float.valueOf(f)); } public String getSelectedText() { if (mHasSelection) return mLastSelectedText; else return ""; } public SelectionHandleController getSelectionHandleControllerForTest() { return mSelectionHandleController; } public String getTitle() { if (mNativeContentViewCore != 0) return nativeGetTitle(mNativeContentViewCore); else return null; } public String getUrl() { if (mNativeContentViewCore != 0) return nativeGetURL(mNativeContentViewCore); else return null; } public boolean getUseDesktopUserAgent() { if (mNativeContentViewCore != 0) return nativeGetUseDesktopUserAgent(mNativeContentViewCore); else return false; } public VSyncManager.Listener getVSyncListener(VSyncManager.Provider provider) { if (mVSyncProvider != null && mVSyncListenerRegistered) { mVSyncProvider.unregisterVSyncListener(mVSyncListener); mVSyncListenerRegistered = false; } mVSyncProvider = provider; mVSyncListener = new VSyncManager.Listener() { public void onVSync(long l) { animateIfNecessary(l); if (mDidSignalVSyncUsingInputEvent) { TraceEvent.instant("ContentViewCore::onVSync ignored"); mDidSignalVSyncUsingInputEvent = false; } else if (mNativeContentViewCore != 0) { nativeOnVSync(mNativeContentViewCore, l); return; } } public void updateVSync(long l, long l1) { if (mNativeContentViewCore != 0) nativeUpdateVSyncParameters(mNativeContentViewCore, l, l1); } }; if (mVSyncSubscriberCount > 0) { provider.registerVSyncListener(mVSyncListener); mVSyncListenerRegistered = true; } return mVSyncListener; } public ViewAndroidDelegate getViewAndroidDelegate() { return new ViewAndroidDelegate() { static final boolean $assertionsDisabled = false; public View acquireAnchorView() { View view = new View(getContext()); mContainerView.addView(view); return view; } public void releaseAnchorView(View view) { mContainerView.removeView(view); } public void setAnchorViewPosition(View view, float f, float f1, float f2, float f3) { if (!$assertionsDisabled && view.getParent() != mContainerView) throw new AssertionError(); float f4 = (float)DeviceDisplayInfo.create(getContext()).getDIPScale(); int i = Math.round(f * f4); int j = Math.round(mRenderCoordinates.getContentOffsetYPix() + f1 * f4); if (mContainerView instanceof FrameLayout) { int i1 = Math.round(f2 * f4); if (i1 + i > mContainerView.getWidth()) i1 = mContainerView.getWidth() - i; android.widget.FrameLayout.LayoutParams layoutparams = new android.widget.FrameLayout.LayoutParams(i1, Math.round(f3 * f4)); layoutparams.leftMargin = i; layoutparams.topMargin = j; view.setLayoutParams(layoutparams); return; } if (mContainerView instanceof AbsoluteLayout) { int k = i + mRenderCoordinates.getScrollXPixInt(); int l = j + mRenderCoordinates.getScrollYPixInt(); view.setLayoutParams(new android.widget.AbsoluteLayout.LayoutParams((int)f2, (int)(f3 * f4), k, l)); return; } else { Log.e("ContentViewCore", (new StringBuilder()).append("Unknown layout ").append(mContainerView.getClass().getName()).toString()); return; } } // static // { //// boolean flag; //// if (!org/chromium/content/browser/ContentViewCore.desiredAssertionStatus()) //// flag = true; //// else //// flag = false; //// $assertionsDisabled = false; // } }; } public int getViewportHeightPix() { return mViewportHeightPix; } public int getViewportSizeOffsetHeightPix() { return mViewportSizeOffsetHeightPix; } public int getViewportSizeOffsetWidthPix() { return mViewportSizeOffsetWidthPix; } public int getViewportWidthPix() { return mViewportWidthPix; } public void goBack() { if (mNativeContentViewCore != 0) nativeGoBack(mNativeContentViewCore); } public void goForward() { if (mNativeContentViewCore != 0) nativeGoForward(mNativeContentViewCore); } public void goToNavigationIndex(int i) { if (mNativeContentViewCore != 0) nativeGoToNavigationIndex(mNativeContentViewCore, i); } public void goToOffset(int i) { if (mNativeContentViewCore != 0) nativeGoToOffset(mNativeContentViewCore, i); } public boolean hasFixedPageScale() { return mRenderCoordinates.hasFixedPageScale(); } public boolean hasFocus() { return mContainerView.hasFocus(); } void hideSelectActionBar() { if (mActionMode != null) { mActionMode.finish(); mActionMode = null; } } public void initialize(ViewGroup viewgroup, InternalAccessDelegate internalaccessdelegate, int i, WindowAndroid windowandroid, int j) { mHardwareAccelerated = hasHardwareAcceleration(mContext); mContainerView = viewgroup; int k; int l; String s; if (windowandroid != null) k = windowandroid.getNativePointer(); else k = 0; l = 0; if (k != 0) { mViewAndroid = new ViewAndroid(windowandroid, getViewAndroidDelegate()); l = mViewAndroid.getNativePointer(); } mNativeContentViewCore = nativeInit(mHardwareAccelerated, i, l, k); mContentSettings = new ContentSettings(this, mNativeContentViewCore); initializeContainerView(internalaccessdelegate, j); mAccessibilityInjector = AccessibilityInjector.newInstance(this); if ((new File("/system/lib/libwebcryptotz.so")).exists()) { mWebCryptoJavascriptInterface = WebCryptoJavascriptInterface.newInstance(this); Log.w("ContentViewCore", "mWebCryptoJavascriptInterface new instance"); } else { Log.w("ContentViewCore", "TZ based NfWebcrpyto is missing from /system/lib/libwebcryptotz.so"); } s = "Web View"; // if (org.chromium.content.R.string.accessibility_content_view == 0) // Log.w("ContentViewCore", "Setting contentDescription to 'Web View' as no value was specified."); // else // s = mContext.getResources().getString(org.chromium.content.R.string.accessibility_content_view); mContainerView.setContentDescription(s); mWebContentsObserver = new WebContentsObserverAndroid(this) { public void didFinishLoad(long l1, String s1, boolean flag) { if (flag) getContentViewClient().onPageFinished(s1); } public void didStartLoading(String s1) { hidePopupDialog(); resetGestureDetectors(); } }; mPid = nativeGetCurrentRenderProcessId(mNativeContentViewCore); } public void invokeZoomPicker() { mZoomControlsDelegate.invokeZoomPicker(); } public boolean isAlive() { return mNativeContentViewCore != 0; } public boolean isCrashed() { if (mNativeContentViewCore == 0) return false; else return nativeCrashed(mNativeContentViewCore); } public boolean isDeviceAccessibilityScriptInjectionEnabled() { boolean flag = true; if (!mContentSettings.getJavaScriptEnabled()) return false; int i; if (getContext().checkCallingOrSelfPermission("android.permission.INTERNET") != 0) return true; Field field = null;//android/provider/Settings$Secure.getField("ACCESSIBILITY_SCRIPT_INJECTION"); field.setAccessible(true); String s = null;//(String)field.get(null); ContentResolver contentresolver = getContext().getContentResolver(); if (mAccessibilityScriptInjectionObserver == null) { ContentObserver contentobserver = new ContentObserver(new Handler()) { public void onChange(boolean flag1, Uri uri) { setAccessibilityState(mAccessibilityManager.isEnabled()); } }; contentresolver.registerContentObserver(android.provider.Settings.Secure.getUriFor(s), false, contentobserver); mAccessibilityScriptInjectionObserver = contentobserver; } i = android.provider.Settings.Secure.getInt(contentresolver, s, 0); return flag; // IllegalAccessException illegalaccessexception; // illegalaccessexception; // return false; // NoSuchFieldException nosuchfieldexception; // nosuchfieldexception; // return false; } public boolean isInjectingAccessibilityScript() { return mAccessibilityInjector.accessibilityIsAvailable(); } public boolean isReady() { return nativeIsRenderWidgetHostViewReady(mNativeContentViewCore); } public boolean isSelectActionBarShowing() { return mActionMode != null; } public boolean isSelectionEditable() { if (mHasSelection) return mSelectionEditable; else return false; } public boolean isShowingInterstitialPage() { if (mNativeContentViewCore == 0) return false; else return nativeIsShowingInterstitialPage(mNativeContentViewCore); } public boolean isVideoPlaying(int i) { if (mNativeContentViewCore != 0) return nativeIsVideoPlaying(mNativeContentViewCore, i); else return false; } public void loadUrl(LoadUrlParams loadurlparams) { if (mNativeContentViewCore == 0) { return; } else { nativeLoadUrl(mNativeContentViewCore, loadurlparams.mUrl, loadurlparams.mLoadUrlType, loadurlparams.mTransitionType, loadurlparams.mUaOverrideOption, loadurlparams.getExtraHeadersString(), loadurlparams.mPostData, loadurlparams.mBaseUrlForDataUrl, loadurlparams.mVirtualUrlForDataUrl, loadurlparams.mCanLoadLocalResources); return; } } public boolean needsReload() { return mNativeContentViewCore != 0 && nativeNeedsReload(mNativeContentViewCore); } public void onAccessibilityStateChanged(boolean flag) { setAccessibilityState(flag); } public void onActivityPause() { TraceEvent.begin(); hidePopupDialog(); nativeOnHide(mNativeContentViewCore); TraceEvent.end(); } public void onActivityResume() { nativeOnShow(mNativeContentViewCore); setAccessibilityState(mAccessibilityManager.isEnabled()); } public void onAttachedToWindow() { mAttachedToWindow = true; if (mNativeContentViewCore != 0) { if (!$assertionsDisabled && mPid != nativeGetCurrentRenderProcessId(mNativeContentViewCore)) throw new AssertionError(); ChildProcessLauncher.bindAsHighPriority(mPid); ChildProcessLauncher.removeInitialBinding(mPid); } setAccessibilityState(mAccessibilityManager.isEnabled()); } public boolean onCheckIsTextEditor() { return mImeAdapter.hasTextInputType(); } public void onConfigurationChanged(Configuration configuration) { TraceEvent.begin(); if (configuration.keyboard != 1) { mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentViewCore), ImeAdapter.getTextInputTypeNone(), -1, -1); ((InputMethodManager)getContext().getSystemService("input_method")).restartInput(mContainerView); } mContainerViewInternals.super_onConfigurationChanged(configuration); mNeedUpdateOrientationChanged = true; TraceEvent.end(); } public InputConnection onCreateInputConnection(EditorInfo editorinfo) { if (!mImeAdapter.hasTextInputType()) editorinfo.imeOptions = 0x2000000; mInputConnection = mAdapterInputConnectionFactory.get(mContainerView, mImeAdapter, editorinfo); return mInputConnection; } public void onDetachedFromWindow() { mAttachedToWindow = false; if (mNativeContentViewCore != 0) { if (!$assertionsDisabled && mPid != nativeGetCurrentRenderProcessId(mNativeContentViewCore)) throw new AssertionError(); ChildProcessLauncher.unbindAsHighPriority(mPid); } setInjectedAccessibility(false); hidePopupDialog(); mZoomControlsDelegate.dismissZoomPicker(); unregisterAccessibilityContentObserver(); } public void onFocusChanged(boolean flag) { if (!flag) getContentViewClient().onImeStateChangeRequested(false); if (mNativeContentViewCore != 0) nativeSetFocus(mNativeContentViewCore, flag); } public boolean onGenericMotionEvent(MotionEvent motionevent) { return true; // if ((2 & motionevent.getSource()) == 0) goto _L2; else goto _L1 //_L1: // motionevent.getAction(); // JVM INSTR tableswitch 8 8: default 32 // // 8 43; // goto _L2 _L3 //_L2: // return mContainerViewInternals.super_onGenericMotionEvent(motionevent); //_L3: // nativeSendMouseWheelEvent(mNativeContentViewCore, motionevent.getEventTime(), motionevent.getX(), motionevent.getY(), motionevent.getAxisValue(9)); // mContainerView.removeCallbacks(mFakeMouseMoveRunnable); // mFakeMouseMoveRunnable = new Runnable() { // // public void run() // { // onHoverEvent(eventFakeMouseMove); // } // // // { // this$0 = ContentViewCore.this; // eventFakeMouseMove = motionevent; // super(); // } // }; // mContainerView.postDelayed(mFakeMouseMoveRunnable, 250L); // return true; } public void onHide() { hidePopupDialog(); setInjectedAccessibility(false); Log.d("ContentViewCore", "onhide called for ContentViewCore"); mWebCryptoJavascriptInterface.close(); nativeOnHide(mNativeContentViewCore); } public boolean onHoverEvent(MotionEvent motionevent) { TraceEvent.begin("onHoverEvent"); mContainerView.removeCallbacks(mFakeMouseMoveRunnable); if (mBrowserAccessibilityManager != null) return mBrowserAccessibilityManager.onHoverEvent(motionevent); if (mNativeContentViewCore != 0) nativeSendMouseMoveEvent(mNativeContentViewCore, motionevent.getEventTime(), motionevent.getX(), motionevent.getY()); TraceEvent.end("onHoverEvent"); return true; } public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityevent) { int i; int j; boolean flag; label0: { accessibilityevent.setClassName(getClass().getName()); accessibilityevent.setScrollX(mRenderCoordinates.getScrollXPixInt()); accessibilityevent.setScrollY(mRenderCoordinates.getScrollYPixInt()); i = Math.max(0, mRenderCoordinates.getMaxHorizontalScrollPixInt()); j = Math.max(0, mRenderCoordinates.getMaxVerticalScrollPixInt()); if (i <= 0) { flag = false; if (j <= 0) break label0; } flag = true; } accessibilityevent.setScrollable(flag); if (android.os.Build.VERSION.SDK_INT >= 15) { accessibilityevent.setMaxScrollX(i); accessibilityevent.setMaxScrollY(j); } } public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilitynodeinfo) { mAccessibilityInjector.onInitializeAccessibilityNodeInfo(accessibilitynodeinfo); } public boolean onKeyUp(int i, KeyEvent keyevent) { if (mPopupZoomer.isShowing() && i == 4) { mPopupZoomer.hide(true); return true; } else { return mContainerViewInternals.super_onKeyUp(i, keyevent); } } void onNativeContentViewCoreDestroyed(int i) { if (!$assertionsDisabled && i != mNativeContentViewCore) { throw new AssertionError(); } else { mNativeContentViewCore = 0; return; } } public void onOverdrawBottomHeightChanged(int i) { if (mOverdrawBottomHeightPix != i) { mOverdrawBottomHeightPix = i; if (mNativeContentViewCore != 0) { nativeWasResized(mNativeContentViewCore); return; } } } public void onPhysicalBackingSizeChanged(int i, int j) { if (mPhysicalBackingWidthPix != i || mPhysicalBackingHeightPix != j) { mPhysicalBackingWidthPix = i; mPhysicalBackingHeightPix = j; if (mNativeContentViewCore != 0) { nativeWasResized(mNativeContentViewCore); return; } } } public void onShow() { nativeOnShow(mNativeContentViewCore); setAccessibilityState(mAccessibilityManager.isEnabled()); } public void onSizeChanged(int i, int j, int k, int l) { if (getViewportWidthPix() == i && getViewportHeightPix() == j) return; mViewportWidthPix = i; mViewportHeightPix = j; if (mNativeContentViewCore != 0) nativeWasResized(mNativeContentViewCore); updateAfterSizeChanged(); } public boolean onTouchEvent(MotionEvent motionevent) { undoScrollFocusedEditableNodeIntoViewIfNeeded(false); return mContentViewGestureHandler.onTouchEvent(motionevent); } public void onVisibilityChanged(View view, int i) { if (i != 0) mZoomControlsDelegate.dismissZoomPicker(); } public boolean performAccessibilityAction(int i, Bundle bundle) { if (mAccessibilityInjector.supportsAccessibilityAction(i)) return mAccessibilityInjector.performAccessibilityAction(i, bundle); else return false; } public void reload() { mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary(); mWebCryptoJavascriptInterface.addOrRemoveWebCryptoJavascriptInterface(); if (mNativeContentViewCore != 0) nativeReload(mNativeContentViewCore); } public void removeJavascriptInterface(String s) { mJavaScriptInterfaces.remove(s); if (mNativeContentViewCore != 0) nativeRemoveJavascriptInterface(mNativeContentViewCore, s); } public void scrollBy(int i, int j) { if (mNativeContentViewCore != 0) nativeScrollBy(mNativeContentViewCore, System.currentTimeMillis(), 0.0F, 0.0F, i, j, false); } public void scrollTo(int i, int j) { if (mNativeContentViewCore != 0) { float f = mRenderCoordinates.getScrollXPix(); float f1 = mRenderCoordinates.getScrollYPix(); float f2 = (float)i - f; float f3 = (float)j - f1; if (f2 != 0.0F || f3 != 0.0F) { long l = System.currentTimeMillis(); nativeScrollBegin(mNativeContentViewCore, l, f, f1); nativeScrollBy(mNativeContentViewCore, l, f, f1, f2, f3, false); nativeScrollEnd(mNativeContentViewCore, l); return; } } } public void selectPopupMenuItems(int ai[]) { if (mNativeContentViewCore != 0) nativeSelectPopupMenuItems(mNativeContentViewCore, ai); } public boolean sendGesture(int i, long l, int j, int k, boolean flag, Bundle bundle) { if (offerGestureToEmbedder(i)) return false; if (mNativeContentViewCore == 0) return false; updateTextHandlesForGesture(i); updateGestureStateListener(i, bundle); if (flag && isVSyncNotificationEnabled()) { if (!$assertionsDisabled && i != 7 && i != 12) throw new AssertionError(); mDidSignalVSyncUsingInputEvent = true; } switch (i) { default: return false; case 0: // '\0' nativeShowPressState(mNativeContentViewCore, l, j, k); return true; case 14: // '\016' nativeShowPressCancel(mNativeContentViewCore, l, j, k); return true; case 1: // '\001' nativeDoubleTap(mNativeContentViewCore, l, j, k); return true; case 2: // '\002' nativeSingleTap(mNativeContentViewCore, l, j, k, false); return true; case 3: // '\003' handleTapOrPress(l, j, k, 0, bundle.getBoolean("ShowPress", false)); return true; case 4: // '\004' nativeSingleTapUnconfirmed(mNativeContentViewCore, l, j, k); return true; case 5: // '\005' handleTapOrPress(l, j, k, 1, false); return true; case 15: // '\017' handleTapOrPress(l, j, k, 2, false); return true; case 6: // '\006' nativeScrollBegin(mNativeContentViewCore, l, j, k); return true; case 7: // '\007' int i1 = bundle.getInt("Distance X"); int j1 = bundle.getInt("Distance Y"); nativeScrollBy(mNativeContentViewCore, l, j, k, i1, j1, flag); return true; case 8: // '\b' nativeScrollEnd(mNativeContentViewCore, l); return true; case 9: // '\t' nativeFlingStart(mNativeContentViewCore, l, j, k, bundle.getInt("Velocity X", 0), bundle.getInt("Velocity Y", 0)); return true; case 10: // '\n' nativeFlingCancel(mNativeContentViewCore, l); return true; case 11: // '\013' nativePinchBegin(mNativeContentViewCore, l, j, k); return true; case 12: // '\f' nativePinchBy(mNativeContentViewCore, l, j, k, bundle.getFloat("Delta", 0.0F), flag); return true; case 13: // '\r' nativePinchEnd(mNativeContentViewCore, l); return true; } } public boolean sendTouchEvent(long l, int i, TouchPoint atouchpoint[]) { if (mNativeContentViewCore != 0) return nativeSendTouchEvent(mNativeContentViewCore, l, i, atouchpoint); else return false; } public void setAccessibilityState(boolean flag) { boolean flag1 = false; boolean flag2 = false; if (flag) if (isDeviceAccessibilityScriptInjectionEnabled()) { flag1 = true; } else { flag2 = true; flag1 = false; } setInjectedAccessibility(flag1); setNativeAccessibilityState(flag2); } public void setAdapterInputConnectionFactory(org.chromium.content.browser.input.ImeAdapter.AdapterInputConnectionFactory adapterinputconnectionfactory) { mAdapterInputConnectionFactory = adapterinputconnectionfactory; } public void setBrowserAccessibilityManager(BrowserAccessibilityManager browseraccessibilitymanager) { mBrowserAccessibilityManager = browseraccessibilitymanager; } public void setContentViewClient(ContentViewClient contentviewclient) { if (contentviewclient == null) { throw new IllegalArgumentException("The client can't be null."); } else { mContentViewClient = contentviewclient; return; } } public void setDownloadDelegate(ContentViewDownloadDelegate contentviewdownloaddelegate) { mDownloadDelegate = contentviewdownloaddelegate; } public void setGestureStateListener(GestureStateListener gesturestatelistener) { mGestureStateListener = gesturestatelistener; } public void setInjectedAccessibility(boolean flag) { mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary(); mAccessibilityInjector.setScriptEnabled(flag); } public void setNativeAccessibilityState(boolean flag) { if (android.os.Build.VERSION.SDK_INT >= 16) nativeSetAccessibilityEnabled(mNativeContentViewCore, flag); } public void setUpdateFrameInfoListener(UpdateFrameInfoListener updateframeinfolistener) { mUpdateFrameInfoListener = updateframeinfolistener; } public void setUseDesktopUserAgent(boolean flag, boolean flag1) { if (mNativeContentViewCore != 0) nativeSetUseDesktopUserAgent(mNativeContentViewCore, flag, flag1); } void setVSyncNotificationEnabled(boolean flag) { // boolean flag1 = true; // if (!isVSyncNotificationEnabled() && flag) // mDidSignalVSyncUsingInputEvent = false; // int i; // if (mVSyncProvider != null) // if (!mVSyncListenerRegistered && flag) // { // mVSyncProvider.registerVSyncListener(mVSyncListener); // mVSyncListenerRegistered = flag1; // } else // if (mVSyncSubscriberCount == flag1 && !flag) // { // if (!$assertionsDisabled && !mVSyncListenerRegistered) // throw new AssertionError(); // mVSyncProvider.unregisterVSyncListener(mVSyncListener); // mVSyncListenerRegistered = false; // } // i = mVSyncSubscriberCount; // if (!flag) // flag1 = -1; // mVSyncSubscriberCount = flag1 + i; // if (!$assertionsDisabled && mVSyncSubscriberCount < 0) // throw new AssertionError(); // else // return; } public void setViewportSizeOffset(int i, int j) { if (i != mViewportSizeOffsetWidthPix || j != mViewportSizeOffsetHeightPix) { mViewportSizeOffsetWidthPix = i; mViewportSizeOffsetHeightPix = j; if (mNativeContentViewCore != 0) nativeWasResized(mNativeContentViewCore); } } public void setZoomControlsDelegate(ZoomControlsDelegate zoomcontrolsdelegate) { mZoomControlsDelegate = zoomcontrolsdelegate; } public void showImeIfNeeded() { if (mNativeContentViewCore != 0) nativeShowImeIfNeeded(mNativeContentViewCore); } public void showInterstitialPage(String s, InterstitialPageDelegateAndroid interstitialpagedelegateandroid) { if (mNativeContentViewCore == 0) { return; } else { nativeShowInterstitialPage(mNativeContentViewCore, s, interstitialpagedelegateandroid.getNative()); return; } } public void stopCurrentAccessibilityNotifications() { mAccessibilityInjector.onPageLostFocus(); } public void stopLoading() { if (mNativeContentViewCore != 0) nativeStopLoading(mNativeContentViewCore); } public boolean supportsAccessibilityAction(int i) { return mAccessibilityInjector.supportsAccessibilityAction(i); } void updateGestureStateListener(int i, Bundle bundle) { if (mGestureStateListener == null) return; switch (i) { case 12: // '\f' default: return; case 9: // '\t' mGestureStateListener.onFlingStartGesture(bundle.getInt("Velocity X", 0), bundle.getInt("Velocity Y", 0)); return; case 11: // '\013' mGestureStateListener.onPinchGestureStart(); return; case 13: // '\r' mGestureStateListener.onPinchGestureEnd(); return; case 10: // '\n' mGestureStateListener.onFlingCancelGesture(); return; } } public void updateMultiTouchZoomSupport(boolean flag) { mZoomManager.updateMultiTouchSupport(flag); } public void updateTopControlsState(boolean flag, boolean flag1, boolean flag2) { nativeUpdateTopControlsState(mNativeContentViewCore, flag, flag1, flag2); } public boolean zoomIn() { if (!canZoomIn()) return false; else return zoomByDelta(1.25F); } public boolean zoomOut() { if (!canZoomOut()) return false; else return zoomByDelta(0.8F); } public boolean zoomReset() { if (!canZoomOut()) return false; else return zoomByDelta(mRenderCoordinates.getMinPageScaleFactor() / mRenderCoordinates.getPageScaleFactor()); } static { // boolean flag; // if (!org/chromium/content/browser/ContentViewCore.desiredAssertionStatus()) // flag = true; // else // flag = false; //$assertionsDisabled = false; } /* static ActionMode access$2202(ContentViewCore contentviewcore, ActionMode actionmode) { contentviewcore.mActionMode = actionmode; return actionmode; } */ /* static boolean access$302(ContentViewCore contentviewcore, boolean flag) { contentviewcore.mDidSignalVSyncUsingInputEvent = flag; return flag; } */ }
bafefb7f691ee797abe7bf2e1ddf1a982b5d463b
b110be48e9db9f4abdeac311cfff90964177299b
/dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/preheat/SchemaToDataFetcherTest.java
11c6487b47e10e24a5240e60e02a2063167fa15b
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
dhis2/dhis2-core
5410b4257a023003977c4731ebc581005cd5910a
50c9aba33a36ced8b7af0d907729ef191afa280e
refs/heads/master
2023-08-31T07:48:05.369640
2023-08-31T06:48:56
2023-08-31T06:48:56
66,940,520
283
381
BSD-3-Clause
2023-09-14T19:39:31
2016-08-30T12:57:05
Java
UTF-8
Java
false
false
8,764
java
/* * Copyright (c) 2004-2022, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * Neither the name of the HISP project nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.hisp.dhis.preheat; import static java.util.stream.Collectors.toList; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.collect.Lists; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.stream.Stream; import org.hamcrest.collection.IsIterableContainingInAnyOrder; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.query.Query; import org.hisp.dhis.DhisConvenienceTest; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.schema.Property; import org.hisp.dhis.schema.Schema; import org.hisp.dhis.sms.command.SMSCommand; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; /** * @author Luciano Fiandesio */ @SuppressWarnings("unchecked") @MockitoSettings(strictness = Strictness.LENIENT) @ExtendWith(MockitoExtension.class) class SchemaToDataFetcherTest extends DhisConvenienceTest { private SchemaToDataFetcher subject; @Mock private SessionFactory sessionFactory; @Mock private Session session; @Mock private Query query; @BeforeEach public void setUp() { when(sessionFactory.getCurrentSession()).thenReturn(session); subject = new SchemaToDataFetcher(sessionFactory); } @Test void verifyInput() { assertThat(subject.fetch(null), hasSize(0)); } @Test void verifyUniqueFieldsAreMappedToHibernateObject() { Schema schema = createSchema( DataElement.class, "dataElement", Stream.of( createUniqueProperty(Integer.class, "id", true, true), createProperty(String.class, "name", true, true), createUniqueProperty(String.class, "code", true, true), createProperty(Date.class, "created", true, true), createProperty(Date.class, "lastUpdated", true, true), createProperty(Integer.class, "int", true, true)) .collect(toList())); mockSession("SELECT code,id from " + schema.getKlass().getSimpleName()); List<Object[]> l = new ArrayList<>(); l.add(new Object[] {"abc", 123456}); l.add(new Object[] {"bce", 123888}); l.add(new Object[] {"def", 123999}); when(query.getResultList()).thenReturn(l); List<DataElement> result = (List<DataElement>) subject.fetch(schema); assertThat(result, hasSize(3)); assertThat( result, IsIterableContainingInAnyOrder.containsInAnyOrder( allOf(hasProperty("code", is("abc")), hasProperty("id", is(123456L))), allOf(hasProperty("code", is("bce")), hasProperty("id", is(123888L))), allOf(hasProperty("code", is("def")), hasProperty("id", is(123999L))))); } @Test void verifyUniqueFieldsAreSkippedOnReflectionError() { Schema schema = createSchema( DummyDataElement.class, "dummyDataElement", Stream.of( createUniqueProperty(String.class, "url", true, true), createUniqueProperty(String.class, "code", true, true)) .collect(toList())); mockSession("SELECT code,url from " + schema.getKlass().getSimpleName()); List<Object[]> l = new ArrayList<>(); l.add(new Object[] {"abc", "http://ok"}); l.add(new Object[] {"bce", "http://-exception"}); l.add(new Object[] {"def", "http://also-ok"}); when(query.getResultList()).thenReturn(l); List<DataElement> result = (List<DataElement>) subject.fetch(schema); assertThat(result, hasSize(2)); assertThat( result, IsIterableContainingInAnyOrder.containsInAnyOrder( allOf(hasProperty("code", is("def")), hasProperty("url", is("http://also-ok"))), allOf(hasProperty("code", is("abc")), hasProperty("url", is("http://ok"))))); } @Test void verifyUniqueFieldsAre() { Schema schema = createSchema( DummyDataElement.class, "dummyDataElement", Stream.of( createProperty(String.class, "name", true, true), createUniqueProperty(String.class, "url", true, true), createProperty(String.class, "code", true, true)) .collect(toList())); mockSession("SELECT url from " + schema.getKlass().getSimpleName()); List<Object> l = new ArrayList<>(); l.add("http://ok"); l.add("http://is-ok"); l.add("http://also-ok"); when(query.getResultList()).thenReturn(l); List<DataElement> result = (List<DataElement>) subject.fetch(schema); assertThat(result, hasSize(3)); assertThat( result, IsIterableContainingInAnyOrder.containsInAnyOrder( allOf(hasProperty("url", is("http://also-ok"))), allOf(hasProperty("url", is("http://ok"))), allOf(hasProperty("url", is("http://is-ok"))))); } @Test void verifyNoSqlWhenUniquePropertiesListIsEmpty() { Schema schema = createSchema(SMSCommand.class, "smsCommand", Lists.newArrayList()); subject.fetch(schema); verify(sessionFactory, times(0)).getCurrentSession(); } @Test void verifyNoSqlWhenNoUniquePropertyExist() { Schema schema = createSchema( SMSCommand.class, "smsCommand", Stream.of( createProperty(String.class, "name", true, true), createProperty(String.class, "id", true, true)) .collect(toList())); subject.fetch(schema); verify(sessionFactory, times(0)).getCurrentSession(); } private void mockSession(String hql) { when(session.createQuery(hql)).thenReturn(query); when(query.setReadOnly(true)).thenReturn(query); } private Schema createSchema( Class<? extends IdentifiableObject> klass, String singularName, List<Property> properties) { Schema schema = new Schema(klass, singularName, singularName + "s"); for (Property property : properties) { schema.addProperty(property); } return schema; } private Property createProperty(Class<?> klazz, String name, boolean simple, boolean persisted) { Property property = new Property(klazz); property.setName(name); property.setFieldName(name); property.setSimple(simple); property.setOwner(true); property.setPersisted(persisted); return property; } public Property createUniqueProperty( Class<?> klazz, String name, boolean simple, boolean persisted) { Property property = createProperty(klazz, name, simple, persisted); property.setUnique(true); return property; } }
64fe86d512e3f81f7a3f0d6c1d2d2868200d7e95
9168bdcb551001505c2a69616c8415a523dbb8cf
/2.- Srping Course/3.- Formularios Thymeleaf y Data Binding/10.- spring-boot-form_checkboxs_roles_property_editor/src/main/java/com/bolsadeideas/springboot/form/app/models/domain/Role.java
2268f3baede44b96bc422d099ef67f7b3431f48d
[]
no_license
danher2/TRAINING
be537469da36b5d6d78080dd2d8bfa53edaa0e65
5015e215f7cfacce11d1dfc5fb81d5f826e8ca3e
refs/heads/master
2023-08-15T15:05:55.348019
2021-10-01T16:36:20
2021-10-01T16:36:20
412,470,022
0
0
null
null
null
null
UTF-8
Java
false
false
654
java
package com.bolsadeideas.springboot.form.app.models.domain; public class Role { private Integer id; private String nombre; private String role; public Role() { } public Role(Integer id, String nombre, String role) { this.id = id; this.nombre = nombre; this.role = role; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getNombre() { return nombre; } public void setNombre(String nombre) { this.nombre = nombre; } public String getRole() { return role; } public void setRole(String role) { this.role = role; } }
400fec347de205a81722cbd250045f0cbfde9e08
6113d935ab09b0036196580619670a6ab212a09e
/Java1/src/Cn/Day_1/Game.java
0639d5f44f5a058c53e5405431bb814846f20573
[]
no_license
yang76410/yang
adcff3a5c5a8a562e84469f470d8a794b8b249ff
07479f048de8f90d4287a1cb7777af06b4584d78
refs/heads/master
2020-03-27T02:16:51.087361
2018-11-22T06:59:31
2018-11-22T06:59:31
145,778,936
0
0
null
null
null
null
UTF-8
Java
false
false
2,793
java
package Cn.Day_1; import java.util.Scanner; /** * @author 洋 * @ClassName:Game.java * @Description: * @date 创建时间:2018-6-28 下午2:36:56 */ public class Game { private People jia; private Computer yi; private int num; private Scanner input = new Scanner(System.in); public void initial(People jia,Computer yi) { this.jia=jia; this.yi=yi; num=0; System.out.println("---------------欢迎进入游戏世界----------------"); System.out.println("\t**********************" + "\n\t** 猜拳,开始 **" + "\n\t**********************\n"); System.out.println("出拳规则:1.剪刀 2.石头 3.布"); } public void startGame() { System.out.print("请选择对方角色(1:刘备 2:孙权 3:曹操):"); int k = input.nextInt(); switch (k) { case 1:this.yi.setName("刘备");break; case 2:this.yi.setName("孙权");break; case 3:this.yi.setName("曹操");break; default:break; } System.out.print("请输入你的角色名:"); this.jia.setName(input.next()); System.out.println(jia.getName() + " VS " + yi.getName() + " 对战"); System.out.print("要开始吗?(y/n):"); String str = input.next(); while(str.equals("y")){ System.out.print("请出拳:1.剪刀 2.石头 3.布(输入相应数字):"); int j=this.jia.Pk(input.nextInt()); int y=this.yi.Pk(); if(j==y){ System.out.println("结果:平局"); this.num+=1; } else if ((j==1&&y==2)||(j==2&&y==3)||(j==3&&y==1)) { System.out.println("结果:呵呵,笨笨,你输了"); this.num+=1; this.yi.setCount(this.yi.getCount()+1); } else if((j==1&&y==3)||(j==2&&y==1)||(j==3&&y==2)){ System.out.println("结果:恭喜,你赢了"); this.num+=1; this.jia.setCount(this.jia.getCount()+1); } System.out.print("是否开始下一轮?(y/n):"); str = input.next(); } } public void endGame(){ System.out.println("------------------------------"); if(this.num==0){ System.out.println("临阵脱逃啊!!!!!!!"); return; } System.out.println(jia.getName() + " VS " + yi.getName()); System.out.println("对战次数:" + this.num); System.out.println("姓名\t得分"); System.out.println(this.jia.getName() + "\t" + this.jia.getCount()); System.out.println(this.yi.getName() + "\t" + this.yi.getCount()); if(this.jia.getCount()<this.yi.getCount()){ System.out.println("你输了耶!"); } else if(this.jia.getCount()==this.yi.getCount()){ System.out.println("平局,差点就赢啦!"); } else { System.out.println("nice,赢啦赢啦!"); } } public static void main(String[] args) { Game g = new Game(); People p = new People(); Computer c = new Computer(); g.initial(p, c); g.startGame(); g.endGame(); } }
7e6aaeb4f08be2d604085d827b04d0d11dde2323
78e70dc8d3ba005bda485b067645618d18538697
/src/slipknotfind/SlipknotFind.java
3032ee7673f019d23408711609df80b21df76072
[]
no_license
shashankmucheli/slipKnotFind
2b1a62f2b27a2ee7527a44baab2a760bfc341be6
f73f6286338c960335caa5852bb63d1e227213f3
refs/heads/master
2021-01-22T16:21:14.362057
2015-07-24T14:47:10
2015-07-24T14:47:10
33,570,004
0
0
null
null
null
null
UTF-8
Java
false
false
22,417
java
/********************************************************************************************************************* * Name: Shashank Mucheli Sukumar * ID: 01442857 * Instructor: Dr. Firas Khatib. * Computer and Information Science Department. * University Of Massachusetts Dartmouth. * * FAQ * Q: What program is needed to run the code? * A: The project was built in NetBeans IDE. Download latest version of NetBeans form https://netbeans.org/downloads/ * Also, I believe you can import this project by Eclipse. * Download Eclipse form https://www.eclipse.org/downloads/packages/eclipse-standard-432/keplersr2 * * Q: Where should I place the PDB file? * A: The PDB file should be in the root director of the project. * One PDB file "1ALK_A.pdb" is provided. * * Q: How can I run my own PDB file? * A: You can run your own PDB file through modefying the static final String PDB variable inside class SlipknotFind. * Of course, you can also modify the PATH variable to your PDB folder. * * Q: Do I need to pre-process PDB file? What do you mean by "1ALK_A"? * A: PDB "1ALK" has two chains (chain A and chain B). In this case, you have to seperate the two chains into two files. * See the differences between "1ALK.pdb" and "1ALK_A.pdb" inside the project. * For more information about PDB file. http://en.wikipedia.org/wiki/Protein_Data_Bank_(file_format) * ***********************************************************************************************************************/ package slipknotfind; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.*; public class SlipknotFind { static final double TOLERANCE=0.0003; int first_atom = 0, count = 0, i = 0, last_atom = 0, k3 = 0, k2 = 0, p2_atom = 0; String chain = "X"; static List<Triangle> tri=new ArrayList(); static List<Res> res=new ArrayList(); static boolean _byArea=false; static final String PATH=""; //the path of your pdb file. e.g. PATH="PDB/"; static final String PDB="1JS1.pdb"; public static void main(String[] args) { SlipknotFind sf=new SlipknotFind(); sf.initResidual(PDB); sf.slipknotFind(res); } void initResidual(String name){ String fileName=PATH+name; File file=new File(fileName); BufferedReader reader=null; try{ reader=new BufferedReader(new FileReader(file)); String temp; while((temp=reader.readLine())!= null){ String[] s=temp.split("\\s+"); if(s[0].equals("ATOM")){ if(s[2].equals("CA")){ if(s[4].equals(chain)){ if(i == 0) { i = Integer.parseInt(s[5]); } if(first_atom == 0) { first_atom = Integer.parseInt(s[5]); } last_atom = Integer.parseInt(s[5]); Res r=new Res(); r.index=Integer.parseInt(s[5]); r.x=Double.parseDouble(s[6]); r.y=Double.parseDouble(s[7]); r.z=Double.parseDouble(s[8]); res.add(r); } } } } }catch(IOException e){ e.printStackTrace(); } System.out.println("residual.size=" + res.size()); System.out.println("first atom :" + first_atom); System.out.println("last atom :" + last_atom); // System.out.println("*****"+res.size()+" CA information**********"); // for(int i=0;i<res.size();i++){ // System.out.println(res.get(i).index+":\t"+res.get(i).x+"\t"+res.get(i).y+"\t"+res.get(i).z); // } // System.out.println("***************************************"); } public boolean knotFind(List res){ simplify(res); if(res.size()>2){ dblCheck(res); } if (res.size() == 2) { return false; } else { // System.out.println("final res.size = " + res.size()); // System.out.println("the remained chain numbers are:"); // for (int i = 0; i < res.size(); i++) { // System.out.print(res.get(i).index + " "); // } // System.out.println(); return true; } } public void slipknotFind(List<Res> res){ List<Res> r; //a part of res boolean _knotInR=false; boolean _knotInRes=true; int k_2=0; int k_3=0; while(i<=res.size()-2){ //for(int i= i ;i<res.size()-2;i++){ // if(_knotInR) break; for(int j=i+2;j<res.size();j++){ if(_knotInR) break; System.out.println("checking residues from " + i + " to "+ j +" "); r=new ArrayList(); for(int p=0;p<j+1;p++){ r.add(res.get(p)); } initTriangle(r); if(knotFind(r)){ _knotInR=true; k3=i; k2=j; System.out.println("find a knot between "+ k3 + " and "+k2); if (k_3 == 0 && k_2 == 0){ k_3 = k3; k_2 = k2; } } }if(_knotInR) break;i++; } for(int i=k3+1;i<=k2;i++){ r=new ArrayList(); for(int p=i;p<=k2;p++){ r.add(res.get(p)); } initTriangle(r); System.out.println("checking residues from " + i + " to "+ k2 +" "); if(!knotFind(r)){ k3=i-1; System.out.println("find smaller knot between "+k3 +" to "+ k2); break; } } if(_knotInR){ System.out.println("***********************************************"); System.out.println("now check if the knot could be untied eventually"); int k1=-1; for(int i=k2+1;i<res.size();i++){ System.out.println("checking residues from "+k3+" to "+ i); r=new ArrayList(); for(int p=k3;p<i;p++){ r.add(res.get(p)); } initTriangle(r); if(!knotFind(r)){ _knotInRes=false; k1=i; break; } } if(_knotInRes){ for(int i = k3 - 1; i >= 0; i--) { System.out.println("checking residues from " + i + " to " + k2); r = new ArrayList(); for (int p = k2; p >= i; p--) { r.add(res.get(p)); } initTriangle(r); if (!knotFind(r)) { _knotInRes = false; k1 = i; break; } } } if(_knotInR == true && _knotInRes == false){ System.out.println("find a slipknot: k3="+k3+" k2="+k2+" k1="+ k1+"\nNow, Lets check if there are multiple slipknots\n"); System.out.println(k_3+" , "+k_2+" , "+k1); //writeToFile(k_3,k_2,k1); i = k1+1; if( i <= res.size()-2){ count += 1; checkagain(); } } else{ System.out.println("this chain only has a knot between "+ k3+ " and "+k2); //appendk3k2(k3,k2); //writeToFile(k3,0,k2); } } else{ System.out.println("not knots, no slipknots" + "\nThere are " + count + " knots"); } //System.out.println("this chain only has a knot between "+ k3+ " and "+k2); } void checkagain(){ slipknotFind(res); } void simplify(List<Res> res){ int numInTri=0; int i = first_atom; int j = 0; ArrayList coordinates = new ArrayList(); ArrayList removed_atoms = new ArrayList(); Return_simplify Re=new Return_simplify(); while(res.size()>2){ if(numInTri>=tri.size()){ //cannot simplify any more ArrayList list = new ArrayList(); for(Res s : res){ list.add(s.index); } System.out.println(list); create_PDB(list); return; } int res1 = tri.get(numInTri).res1; Plane plane = new Plane(res,res1); Re = findIntersect(plane,res); if (!Re.bool) { deleteResidual(res, res1 + 1, removed_atoms); numInTri = 0; //int delete_value = res.get(res1).index; //System.out.println("Removed Atoms: "+delete_value); } else { numInTri++; coordinates.add(Re.value); //System.out.println(Re.value); //java.util.Collections.sort(coordinates); System.out.println(coordinates); } i++; } java.util.Collections.sort(removed_atoms); //System.out.println("Deleted Atoms: " + removed_atoms); create_PDB(coordinates); } Return_simplify findIntersect(Plane plane, List<Res> res){ Return_simplify Re=new Return_simplify(); List<Integer> trouble=new ArrayList(); int point1=0; //find all the trouble segments while(point1<res.size()-1){ int point2=point1+1; //check if point1 or point2 is part the triangle if(point1 == plane.residual || point1 == plane.residual+1 || point1 == plane.residual+2 || point2 == plane.residual){ point1++; continue; } //check if p1 and p2 are in the same side of the plane double p1Distance, p2Distance; p1Distance=plane.a*res.get(point1).x + plane.b * res.get(point1).y + plane.c * res.get(point1).z + plane.d; p2Distance=plane.a*res.get(point2).x + plane.b * res.get(point2).y + plane.c * res.get(point2).z + plane.d; //p1 and p2 are on the same side if(p1Distance>TOLERANCE && p2Distance > TOLERANCE || p1Distance < -TOLERANCE && p2Distance < -TOLERANCE){ point1++; continue; } //now find a trouble point the starting and ending point are on the different side of the plane trouble.add(point1++); } boolean _intersect=false; Re.bool = false; //check if the trouble segments are really intersect the plane for(int i=0;i<trouble.size();i++){ int p1=trouble.get(i); int p2=trouble.get(i)+1; double denom=plane.a * (res.get(p1).x - res.get(p2).x) + plane.b * (res.get(p1).y - res.get(p2).y) + plane.c * (res.get(p1).z - res.get(p2).z); if(Math.abs(denom)<TOLERANCE){ //denominator is 0. the segment is inside the plane System.out.println("****the segment is inside the plane now****"+ Math.abs(denom)); // if(segmentIntersectTriangle(plane,p1,res)){ Re.bool=true; Re.value=res.get(p1).index; return Re; } if(segmentIntersectTriangle(plane,p2,res)){ Re.bool=true; Re.value=res.get(p2).index; return Re; } } else{ //the segment crosses the plane double mu=( plane.d + plane.a * res.get(p1).x + plane.b * res.get(p1).y + plane.c * res.get(p1).z ) / denom; if( mu < TOLERANCE || mu > 1.0+TOLERANCE){ //System.out.println("mu > 1 or mu < 0 on plane: "+plane.residual+" point: "+point1); continue; } //cal the cross point Res crossPoint=new Res(); crossPoint.x=res.get(p1).x +(mu * (res.get(p2).x - res.get(p1).x)); crossPoint.y=res.get(p1).y +(mu * (res.get(p2).y - res.get(p1).y)); crossPoint.z=res.get(p1).z +(mu * (res.get(p2).z - res.get(p1).z)); crossPoint.index = res.get(p1).index; p2_atom = res.get(p2).index; //check if the cross point is inside the triangle if(crossPointInsideTriangle(plane,crossPoint,res)){ //System.out.println("cross point: \t"+crossPoint.x+"\t"+crossPoint.y+"\t"+crossPoint.z); Re.bool=true; Re.value=crossPoint.index; return Re; } } }//end check if the trouble segments are really intersect the plane return Re; } boolean segmentIntersectTriangle(Plane plane, int p1, List<Res> res){ if(crossPointInsideTriangle(plane,res.get(p1),res)) return true; if(crossPointInsideTriangle(plane,res.get(p1+1),res)) return true; return false; } boolean crossPointInsideTriangle(Plane plane, Res p, List<Res> res){ Res a=res.get(plane.residual); Res b=res.get(plane.residual+1); Res c=res.get(plane.residual+2); double ab=Math.pow(b.x-a.x,2) + Math.pow(b.y-a.y,2) + Math.pow(b.z-a.z,2); double bc=Math.pow(c.x-b.x,2) + Math.pow(c.y-b.y,2) + Math.pow(c.z-b.z,2); double ca=Math.pow(a.x-c.x,2) + Math.pow(a.y-c.y,2) + Math.pow(a.z-c.z,2); double pa=Math.pow(p.x-a.x,2) + Math.pow(p.y-a.y,2) + Math.pow(p.z-a.z,2); double pb=Math.pow(p.x-b.x,2) + Math.pow(p.y-b.y,2) + Math.pow(p.z-b.z,2); double pc=Math.pow(p.x-c.x,2) + Math.pow(p.y-c.y,2) + Math.pow(p.z-c.z,2); double temp; temp=(pb+pc-bc)/(2*Math.sqrt(pb*pc)); double bpc=Math.acos(temp); temp=(pb+pa-ab)/(2*Math.sqrt(pa*pb)); double apb=Math.acos(temp); temp=(pa+pc-ca)/(2*Math.sqrt(pa*pc)); double cpa=Math.acos(temp); double total=bpc+apb+cpa; //System.out.println("total: "+total); if(Math.abs(total-2*Math.PI) < TOLERANCE){ //System.out.println("plane:"+ plane.residual+" has crossings "); return true; } else{ //System.out.println("outside the triangle***********oh yeah"); return false; } } void deleteResidual(List<Res> res, int res2, ArrayList removed_atoms){ //delete 3 triangles int del=0; int add=0; for(int i=0;i<tri.size();i++){ if(tri.get(i).res1==res2-2){ tri.remove(i);del++; break; } } for(int i=0;i<tri.size();i++){ if(tri.get(i).res1==res2-1){ tri.remove(i);del++; break; } } for(int i=0;i<tri.size();i++){ if(tri.get(i).res1==res2){ tri.remove(i);del++; break; } } for(int i=0;i<tri.size();i++){ if(tri.get(i).res1>res2) tri.get(i).res1--; } //remove the residual from res chain //System.out.println("Deleting... "+res.get(res2).index); removed_atoms.add(res.get(res2).index); res.remove(res2); //java.util.Collections.sort(removed_atoms); //System.out.println("Removed Atoms: "+res2); if(res2>1){ //add 2 new triangles Triangle newTri1=new Triangle(); newTri1.res1=res2-2; newTri1.distance=calDistance(res, res2-2); insertIntoTri(newTri1); add++; } if(res2<res.size()-1){ Triangle newTri2=new Triangle(); newTri2.res1=res2-1; newTri2.distance=calDistance(res, res2-1); insertIntoTri(newTri2); add++; } if(del-add!=1) System.out.println("delete "+del+" triangles and add "+ add +" tri"); } void initTriangle(List<Res> res){ tri.clear(); int[] res1 = new int[res.size() - 2]; double[] distance = new double[res.size() - 2]; for(int i=first_atom;i<res.size()-2;i++){ res1[i]=i; distance[i]=calDistance(res, i); } Triangle t=new Triangle(); t.res1=res1[0]; t.distance=distance[0]; tri.add(t); //System.out.println("triangle Found SHASHANK"); for(int i=1;i<res1.length;i++){ t=new Triangle(); t.res1=res1[i]; t.distance=distance[i]; insertIntoTri(t); } } void insertIntoTri(Triangle newTri){ int index=-1; for(int i=tri.size()-1;i>=first_atom;i--){ if(newTri.distance>tri.get(i).distance){ index=i; break; } } tri.add(index+1,newTri); } double calDistance(List<Res> res, int res1){ double distance; int a=res1; int b=a+1; int c=a+2; if(!_byArea){ distance=Math.pow((res.get(a).x-res.get(c).x),2) +Math.pow((res.get(a).y-res.get(c).y),2) +Math.pow((res.get(a).z-res.get(c).z),2); } else{ double ab,bc,ca; ab=Math.sqrt( Math.pow(res.get(b).x-res.get(a).x, 2) +Math.pow(res.get(b).y-res.get(a).y,2) +Math.pow(res.get(b).z-res.get(a).z, 2)); bc=Math.sqrt( Math.pow(res.get(b).x-res.get(c).x, 2) +Math.pow(res.get(b).y-res.get(c).y,2) +Math.pow(res.get(b).z-res.get(c).z, 2)); ca=Math.sqrt( Math.pow(res.get(c).x-res.get(a).x, 2) +Math.pow(res.get(c).y-res.get(a).y,2) +Math.pow(res.get(c).z-res.get(a).z, 2)); double s=((ab+bc+ca)/2); distance=(s*(s-ab)*(s-bc)*(s-ca)); } return distance; } void dblCheck(List<Res> res){ /*System.out.println("******************************"); System.out.println("now double checking");*/ _byArea=true; initTriangle(res); simplify(res); _byArea=false; } void writeToFile( int k3, int k2, int k1 ){ String fileName=PATH+PDB; File file=new File(fileName); BufferedReader reader=null; System.out.println("k1 value : " + k1); System.out.println("k3 value : " + k3); try{ String trim_filename = PATH+"trim_"+PDB; PrintWriter writer = new PrintWriter(trim_filename, "UTF-8"); reader=new BufferedReader(new FileReader(file)); String temp; while((temp=reader.readLine())!= null){ String[] s=temp.split("\\s+"); if(s[0].equals("ATOM")){ int residue = Integer.parseInt(s[5]); if(residue >= k3 && residue <= k1){ writer.println(temp); } } } writer.close(); System.out.println("Done Creating file at :" + PATH+PDB); //System.exit(0); }catch(IOException e){ } } private void create_PDB(ArrayList coordinates) { String fileName=PATH+PDB; File file=new File(fileName); BufferedReader reader=null; BufferedReader tmp=null; /*System.out.println("k1 value : " + k1); System.out.println("k3 value : " + k3);*/ try{ String trim_filename = PATH+"knotted_"+PDB; PrintWriter writer = new PrintWriter(trim_filename, "UTF-8"); reader=new BufferedReader(new FileReader(file)); tmp=new BufferedReader(new FileReader(file)); String temp,temp1; while((temp=reader.readLine())!= null){ String[] s=temp.split("\\s+"); if(s[0].equals("ATOM")){ if(s[2].equals("CA")){ if(s[4].equals(chain)){ int residue = Integer.parseInt(s[5]); if(residue == first_atom || coordinates.contains(residue) || residue == last_atom || residue == p2_atom){ writer.println(temp); } } } } } writer.close(); //System.out.println("Done Creating file at :" + PATH+PDB); //System.exit(0); }catch(IOException e){ } } private void appendk3k2(int k3, int k2) { String fileName=PATH+PDB; File file=new File(fileName); BufferedReader reader=null; BufferedReader tmp=null; /*System.out.println("k1 value : " + k1); System.out.println("k3 value : " + k3);*/ try{ reader=new BufferedReader(new FileReader(file)); tmp=new BufferedReader(new FileReader(file)); String temp,temp1; while((temp=reader.readLine())!= null){ String[] s=temp.split("\\s+"); if(s[0].equals("ATOM")){ if(s[2].equals("CA")){ int residue = Integer.parseInt(s[5]); if(residue == k3 || residue == k2){ try(PrintWriter write = new PrintWriter(new BufferedWriter(new FileWriter(PATH+"knotted_"+PDB, true)))) { write.println(temp); } } } } } System.out.println("Done Creating file at :" + PATH+PDB); //System.exit(0); }catch (IOException e) { //exception handling left as an exercise for the reader } } } class Res{ double x; double y; double z; int index; } class Return_simplify{ boolean bool; int value; } class Triangle{ int res1; double distance; } class Plane{ double a,b,c,d; int residual; public Plane(List<Res> res, int res1){ Res p1=res.get(res1); Res p2=res.get(res1+1); Res p3=res.get(res1+2); if(res1<SlipknotFind.res.size()-2){ this.residual=res1; a=(p1.y * (p2.z - p3.z)) + (p2.y) * (p3.z - p1.z) + (p3.y) * (p1.z - p2.z); b=(p1.z * (p2.x - p3.x)) + (p2.z) * (p3.x - p1.x) + (p3.z) * (p1.x - p2.x); c=(p1.x * (p2.y - p3.y)) + (p2.x) * (p3.y - p1.y) + (p3.x) * (p1.y - p2.y); d= - ((p1.x * ((p2.y * p3.z ) - (p3.y * p2.z ))) + (p2.x * ((p3.y * p1.z ) - (p1.y * p3.z ))) + (p3.x * ((p1.y * p2.z ) - (p2.y * p1.z )))); } } }
4a385574cf16f4947acc8ddc7b147b885f724d20
e3a1e282b9e44834b561cefeae8a33a24565789f
/src/test/java/com/Lavender002_Java/ListFindFreq.java
da30b4167e426f3510001c523c38473443e67f97
[]
no_license
prkharueh12/zooHotFix
39d8e26f19b66b73448f75950be6ae7418369cce
936c118bcfc3c01df21c7e820a61dd25193e7ca3
refs/heads/main
2023-06-04T21:03:41.742426
2021-06-28T23:39:00
2021-06-28T23:39:00
381,185,772
0
0
null
null
null
null
UTF-8
Java
false
false
1,005
java
package com.Lavender002_Java; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import org.junit.Test; public class ListFindFreq { public static void main(String[] args) { Integer [] oriNum = {1,2,3,4,5,6,6,6}; List <Integer> num = new ArrayList <Integer> (Arrays.asList(oriNum)) ; for (int i = 0; i < num.size(); i++) { //System.out.println(Collections.frequency(num, num.get(i))); } String test = "[email protected]"; String email [] = test.split("@"); int len = email[0].length() ; //System.out.println(len); String emailP = ""; if (len >=1 ) { emailP = email[0].concat("****@"); } if (len >=2 ) { emailP = email[0].substring(0,2).concat("****@"); } if (len >=3 ) { emailP = email[0].substring(0,3).concat("****@"); } if (len == 0 ) { System.out.println("Invalid"); }else System.out.println(emailP + email[1]); } }
a6167284946f6a57ed310762c31a2be63dfbc23a
71c2a69042d5f788cade7a5bddf1b962c9ef0354
/src/main/java/io/github/noeppi_noeppi/mods/bongo/util/Messages.java
fc1f82153af4f54ac55d0d797506fa1e09266ee8
[ "Apache-2.0" ]
permissive
LordGrimmauld/Bongo
600470808b72d7fe2dc3b2c6e3e1f03ac08a7b32
211f5549262f9cfa8334c252179efae84f74c7be
refs/heads/master
2023-03-01T02:15:48.773304
2021-02-13T20:03:22
2021-02-13T20:03:22
293,443,032
0
0
null
2020-09-07T06:36:58
2020-09-07T06:36:57
null
UTF-8
Java
false
false
1,206
java
package io.github.noeppi_noeppi.mods.bongo.util; import io.github.noeppi_noeppi.libx.util.ServerMessages; import io.github.noeppi_noeppi.mods.bongo.data.Team; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.text.IFormattableTextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; public class Messages { public static void onJoin(World world, PlayerEntity player, Team team) { player.sendMessage(new TranslationTextComponent("bongo.cmd.team.joined").append(team.getName()), player.getUniqueID()); ServerMessages.broadcastExcept(world, player, ((IFormattableTextComponent) player.getDisplayName()).append(new TranslationTextComponent("bongo.cmd.team.joinedother").append(team.getName()))); } public static void onLeave(World world, PlayerEntity player, Team team) { player.sendMessage(new TranslationTextComponent("bongo.cmd.team.left").append(team.getName()), player.getUniqueID()); ServerMessages.broadcastExcept(world, player, ((IFormattableTextComponent) player.getDisplayName()).append(new TranslationTextComponent("bongo.cmd.team.leftother").append(team.getName()))); } }
bd4f76569de78a0d9e1b46caa79558fdc6f659fa
c2a72f4c3182e7808d90b198bcb81f803377b233
/src/lesson2/Array.java
fd1ef4ba81daf3e5823045fc72621572299859e4
[]
no_license
llensha/java.algorithms.structures
fc970f1fb5658ef62adfe1b1978407546490e4c2
000a9d9b3ae04a9518c65800cce5b376b72a48e5
refs/heads/master
2023-01-28T04:05:11.733755
2020-12-10T01:47:37
2020-12-10T01:47:37
308,186,015
0
0
null
2020-12-10T02:11:11
2020-10-29T01:35:52
Java
UTF-8
Java
false
false
541
java
package lesson2; public interface Array<E> { void add(E value); void insert(E value, int index); E get(int index); boolean remove(E value); E remove(int index); int indexOf(E value); default boolean contains(E value) { return indexOf(value) != -1; } int size(); default boolean isEmpty() { return size() == 0; } void display(); void trimToSize(); void sortBubble(); void sortSelect(); void sortInsert(); E[] toArray(); Array<E> copy(); }
128d8c39cdc92fcc56053d34b45cd93907fd1ed5
cd4e5863851f38bd762ff43923c088fbfa008910
/src/main/java/spring/session/EvalCand/entities/Evaluation.java
c95400b4c0eb90b51d11d163c4333e1e0bdf8394
[]
no_license
tarek352/backend
e720d02c7553784a613643e978001cedba8773c1
9c619467e175e83cb0c8a5e3fbf1c31456194380
refs/heads/master
2021-02-14T00:05:50.902693
2020-03-03T22:03:49
2020-03-03T22:03:49
244,748,283
0
0
null
null
null
null
UTF-8
Java
false
false
2,538
java
package spring.session.EvalCand.entities; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; @Entity public class Evaluation { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int Id_evaluation; private String Titre; private String Etat; private int Duree; @OneToMany(mappedBy = "evaluation", cascade = CascadeType.ALL) private List<QR> qr; @OneToMany(mappedBy = "evaluation", cascade = CascadeType.ALL) private List<Projet> projet; @OneToMany(mappedBy = "evaluation", cascade = CascadeType.ALL) private List<Codage> codage; @OneToMany(mappedBy = "evaluation", cascade = CascadeType.ALL) private List<Language> language; // Default constructor // --> Always define a default constructor for any entity public Evaluation() { super(); } public Evaluation(int id_evaluation, String titre, String etat, int duree, List<QR> qr, List<Projet> projet, List<Codage> codage, List<Language> language) { super(); Id_evaluation = id_evaluation; Titre = titre; Etat = etat; Duree = duree; this.qr = qr; this.projet = projet; this.codage = codage; this.language = language; } public List<Projet> getProjet() { return projet; } public void setProjet(List<Projet> projet) { this.projet = projet; } public List<Codage> getCodage() { return codage; } public void setCodage(List<Codage> codage) { this.codage = codage; } public List<Language> getLanguage() { return language; } public void setLanguage(List<Language> language) { this.language = language; } public List<QR> getQr() { return qr; } public void setQr(List<QR> qr) { this.qr = qr; } public int getId_evaluation() { return Id_evaluation; } public void setId_evaluation(int id_evaluation) { Id_evaluation = id_evaluation; } public String getTitre() { return Titre; } public void setTitre(String titre) { Titre = titre; } public String getEtat() { return Etat; } public void setEtat(String etat) { Etat = etat; } public int getDuree() { return Duree; } public void setDuree(int duree) { Duree = duree; } @Override public String toString() { return "Evaluation [Id_evaluation=" + Id_evaluation + ", Titre=" + Titre + ", Etat=" + Etat + ", Duree=" + Duree + ", qr=" + qr + ", projet=" + projet + ", codage=" + codage + ", language=" + language + "]"; } }
914a7aedaebe445cef9b1810473f3ed13b343c99
db511b7dc637e000a2c6a389af18273b780250ad
/src/demo/process/WechatServlet.java
6d414e6a5c4e443ff0b3854da26cefa4b401dda6
[]
no_license
zilonglym/WeixinProcess
802e2d5f7ebb828b124052c5af97db3bff701ed7
bcac9b8670a17d546e43e332c337b998f78b73ce
refs/heads/master
2021-01-11T05:34:46.483302
2016-10-21T11:07:38
2016-10-21T11:07:38
71,485,257
0
0
null
null
null
null
UTF-8
Java
false
false
3,436
java
package demo.process; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * 微信服务端收发消息接口 * * @author pamchen-1 * */ public class WechatServlet extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request * the request send by the client to the server * @param response * the response send by the server to the client * @throws ServletException * if an error occurred * @throws IOException * if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); /** 读取接收到的xml消息 */ StringBuffer sb = new StringBuffer(); InputStream is = request.getInputStream(); InputStreamReader isr = new InputStreamReader(is, "UTF-8"); BufferedReader br = new BufferedReader(isr); String s = ""; while ((s = br.readLine()) != null) { sb.append(s); } String xml = sb.toString(); //次即为接收到微信端发送过来的xml数据 String result = ""; /** 判断是否是微信接入激活验证,只有首次接入验证时才会收到echostr参数,此时需要把它直接返回 */ String echostr = request.getParameter("echostr"); if (echostr != null && echostr.length() > 1) { result = echostr; System.out.println("Token验证失败"); } else { System.out.println("Token验证成功"); //正常的微信处理流程 System.out.println("读取接收到的xml消息:"+xml); String projectPath = request.getSession().getServletContext().getRealPath(""); result = new WechatProcess().processWechatMag(xml,projectPath); } try { OutputStream os = response.getOutputStream(); os.write(result.getBytes("UTF-8")); os.flush(); os.close(); } catch (Exception e) { e.printStackTrace(); } } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to * post. * * @param request * the request send by the client to the server * @param response * the response send by the server to the client * @throws ServletException * if an error occurred * @throws IOException * if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }
a9bd86c780cc2bccb1bbd79530c7fd22569d49e7
f6f2805d97b72d9d894dc37e958a3aa66179b6de
/src/openocd/Main.java
e149831ec7bacb5306afab809589e8ab2d2ad45a
[]
no_license
ccmikechen/openocd
b1bd65fa780ab6b81028f228613dcf07c08493f5
056508d1b4a94986ae4bd0e99e43a9a16c2b5f4c
refs/heads/master
2020-04-24T20:21:25.369112
2019-02-01T07:35:34
2019-02-23T17:03:58
172,240,437
0
0
null
null
null
null
UTF-8
Java
false
false
880
java
package openocd; public class Main { public static void main(String[] args) throws Exception { String endian = "little"; String file = ""; for (int i = 0; i < args.length; i++) { if (args[i].equals("-l") || args[i].equals("--little")) { endian = "little"; } else if (args[i].equals("-b") || args[i].equals("--big")) { endian = "big"; } else if (file.equals("")) { file = args[i]; } else { usage(); System.exit(0); } } if (file.equals("")) { usage(); System.exit(0); } OpenocdCracker cracker = new OpenocdCracker(); cracker.dumpToFile(file, endian); } public static void usage() { System.out.println("Usage:"); System.out.println("-b --big Big endian"); System.out.println("-l --little Little endian"); System.out.println("Example:"); System.out.println("java -jar oc.jar -l dump.bin"); } }
5c19e0aedf089f3c7f30d12375dbaf2e483e7429
f7bf91b7b7dd5bfa0d26f4a9890c93ff78f70345
/JavaWcp/src/Chapter08.java
e0eb885301647a68f9080fb32cd9c96a8d678fda
[]
no_license
LenonJohn/JAVA
4e219bb8b6accbf9f3c174c4693c8d5901e46ef9
d8b2d02c463e16a3544d32126d02bc10dc6080be
refs/heads/main
2023-07-27T06:23:53.798178
2021-09-10T05:40:07
2021-09-10T05:40:07
386,210,347
0
0
null
null
null
null
UTF-8
Java
false
false
396
java
public class Chapter08 { public static void main(String[] args) { int num = 1; while (num < 5) { System.out.println(num * num); num++; } int array[] = {1, 4, 14, 25}; for (int i = 0; i < array.length; i++) { System.out.println(array[i]); } for (int val : array) { if (val % 2 == 0) { continue; } System.out.println(val); } } }
97beeaee94b9a8e541182840e73925af5cf2d9c4
67c17ceb882006cf46ee1b8dd3598bfdaa1bd113
/jagathkalyani/src/Stringprograms/Strubufex3.java
1b965715980f557ab4d51caded300d87b3cd5db2
[]
no_license
TechieFrogs-Warriors/JavaBasics
f235205bcbe557d89409bf6cb74bae1c5279ebcd
79a83f8db96fc9f57da872a0571497df4551d01b
refs/heads/main
2023-05-04T15:43:41.130753
2021-05-17T07:41:45
2021-05-17T07:41:45
321,665,844
1
0
null
2020-12-16T04:43:34
2020-12-15T12:47:49
null
UTF-8
Java
false
false
2,765
java
package Stringprograms; public class Strubufex3 { public static void main(String[] args) { //string buffer using insert() //syntax: //str.insert(int position,char x); //str.insert(int position,boolean x); //str.insert(int position,float x); // str.insert(int position,double x); //str.insert(int position,long x); //str.insert(int position,int x); //str.insert(int position,char[] x); // StringBuffer str=new StringBuffer("warriors ready to fight");// using boolean // System.out.println(" string = " + str); //str.insert(8,'true');//inserting true in 8 place //System.out.println(" after insertion = " + str); // StringBuffer str=new StringBuffer("warriors ready to fight");// using char //System.out.println(" string = " + str); //str.insert(8,'f');//inserting f in 8 place //System.out.println(" after insertion = " + str); //StringBuffer str1=new StringBuffer("warriors ready to fight");// using chararray //System.out.println(" string = " + str1); //char chararray[]={'a','b','c'}; //str1.insert(8,chararray);//inserting abc in 8 place //System.out.println(" after insertion = " + str1); //StringBuffer str=new StringBuffer("warriors ready to fight");// using float //System.out.println(" string = " + str); //str.insert(8, 89.56f);//inserting 89.56f in 8 place //System.out.println(" after insertion = " + str); // StringBuffer str=new StringBuffer("warriors ready to fight");// using long //System.out.println(" string = " + str); //str.insert(8,267945665l);//inserting 267945665l in 8 place //System.out.println(" after insertion = " + str); //StringBuffer str=new StringBuffer("warriors ready to fight");// using int //System.out.println(" string = " + str); //int x=35; //str.insert(8,x);//inserting 35 in 8 place //System.out.println(" after insertion = " + str); StringBuffer str=new StringBuffer("warriors ready to fight");// using all synatxes System.out.println(" string = " + str); int x=35;//using int str.insert(8,x); System.out.println( str); str.insert(8," for ");//using char System.out.println( str); str.insert(8,true);//using boolean System.out.println(str); str.insert(8,54.22d);//using double System.out.println(str); str.insert(8,11.2f);//using float System.out.println(str); char d_arr[]={'f','o','r'}; str.insert(8,d_arr);//using char arr System.out.println(str); } }
d2e2cc598aefb7eee980cb680d29e3b299d313b1
fb24b2ee9e35812573fef478d6458230abb253c7
/Java/Game of life/cells/src/com/cursach/live/GameFiled.java
1ba7c836ec8b37f6a12958b81afce244bac7aad2
[]
no_license
MaxElmanov/SberTech
ee3cabceb4d1dae2efa17e07c87ad1ea09659b3e
440f936bc681db54d69cabcb4f9e1b55138bb60b
refs/heads/master
2021-06-29T00:38:47.876595
2020-07-13T16:33:11
2020-07-13T16:33:11
154,541,181
0
0
null
2020-10-13T23:29:29
2018-10-24T17:28:02
Java
UTF-8
Java
false
false
4,675
java
package com.cursach.live; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class GameFiled extends JPanel implements ActionListener{ private Main main; private Timer timer; private Cell[][] cells; private Cell[][] tempCells; private final int DOT_SIZE = 15; private int countGeneration = 0; public GameFiled(Main main) { this.main = main; setBackground(Color.DARK_GRAY); initGame(); } public void initGame(){ cells = new Cell[30][30]; tempCells = new Cell[30][30]; initCells(); timer = new Timer(50, this); timer.start(); } private void initCells() { for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells[i].length; j++) { cells[i][j] = new Cell(); tempCells[i][j] = new Cell(); } } cells[9][2].setAlive(true); cells[10][3].setAlive(true); cells[11][1].setAlive(true); cells[11][2].setAlive(true); cells[11][3].setAlive(true); tempCells[9][2].setAlive(true); tempCells[10][3].setAlive(true); tempCells[11][1].setAlive(true); tempCells[11][2].setAlive(true); tempCells[11][3].setAlive(true); // cells[13][12].setAlive(true); // cells[13][10].setAlive(true); // cells[12][10].setAlive(true); // cells[11][11].setAlive(true); // cells[10][12].setAlive(true); // // tempCells[13][12].setAlive(true); // tempCells[13][10].setAlive(true); // tempCells[12][10].setAlive(true); // tempCells[11][11].setAlive(true); // tempCells[10][12].setAlive(true); } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells[i].length; j++) { if (cells[i][j].isAlive()) { g.setColor(Color.green); g.fillRect(j * DOT_SIZE, i * DOT_SIZE, DOT_SIZE, DOT_SIZE); } else{ g.setColor(Color.darkGray); g.fillRect(j * DOT_SIZE, i * DOT_SIZE, DOT_SIZE, DOT_SIZE); } } } } @Override public void actionPerformed(ActionEvent e) { main.setTitle("Cells: generation = " + countGeneration); for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells[i].length; j++) { if (cells[i][j].isAlive()) { aliveMethod(i, j); } else { deadMethod(i, j); } } } countGeneration++; resetCells(); repaint(); } private void resetCells() { for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells[i].length; j++) { cells[i][j].setAlive(tempCells[i][j].isAlive()); } } } private void aliveMethod(int row, int col) { int counterAlive = countAliveCells(row, col); if(counterAlive == 2 || counterAlive == 3){ row = BoderRow(row); col = BoderCol(col); tempCells[row][col].setAlive(true); } else if(counterAlive > 3 || counterAlive < 2){ tempCells[row][col].setAlive(false); } } private void deadMethod(int row, int col) { int counterAlive = countAliveCells(row, col ); if(counterAlive == 3){ row = BoderRow(row); col = BoderCol(col); tempCells[row][col].setAlive(true); } } private int countAliveCells(int row, int col){ int tempCounterAlive = 0, tempI = 0, tempJ = 0; for (int i = row-1; i < ((row-1)+3); i++) { for (int j = col-1; j < ((col-1)+3); j++) { if (i != row || j != col) { tempI = BoderRow(i); tempJ = BoderCol(j); if (cells[tempI][tempJ].isAlive()) { tempCounterAlive++; } } } } return tempCounterAlive; } private int BoderRow(int row){ if (row < 0){ row = 29; } else if (row > 29){ row = 0; } return row; } private int BoderCol(int col){ if (col < 0){ col = 29; } else if (col > 29){ col = 0; } return col; } }
374d926ef0d8e23602b3a999f6a661e8f2c197ac
f52d89e3adb2b7f5dc84337362e4f8930b3fe1c2
/com.fudanmed.platform.core.web/src/main/java/com/fudanmed/platform/core/web/server/service/project/MaintenamceTypeMapper.java
9da4f2fe4043ee3d39a29ebd54e62ed37a6a3f16
[]
no_license
rockguo2015/med
a4442d195e04f77c6c82c4b82b9942b6c5272892
b3db5a4943e190370a20cc4fac8faf38053ae6ae
refs/heads/master
2016-09-08T01:30:54.179514
2015-05-18T10:23:02
2015-05-18T10:23:02
34,060,096
0
0
null
null
null
null
UTF-8
Java
false
false
2,986
java
package com.fudanmed.platform.core.web.server.service.project; import com.fudanmed.platform.core.domain.RCMaintenamceType; import com.fudanmed.platform.core.web.server.service.project.MaintenamceTypeValidator; import com.fudanmed.platform.core.web.shared.project.UIMaintenamceType; import com.uniquesoft.uidl.transform.AbstractEntityMapper; import com.uniquesoft.uidl.transform.IConvertService; import edu.fudan.mylang.pf.IObjectFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component("com.fudanmed.platform.core.web.server.service.project.MaintenamceTypeMapper") public class MaintenamceTypeMapper extends AbstractEntityMapper<UIMaintenamceType,RCMaintenamceType> { @Autowired private IConvertService convertService; @Autowired private IObjectFactory entities; public RCMaintenamceType loadEntityById(final Long id) { return entities.get(RCMaintenamceType.class,id); } public RCMaintenamceType create() { return entities.create(RCMaintenamceType.class); } @Autowired private MaintenamceTypeValidator validator; public void copyToEntity(final UIMaintenamceType from, final RCMaintenamceType to) { java.util.Collection<com.uniquesoft.gwt.shared.validation.ValidationErrorItem> errors = validator.validate(from); if(errors.size()!=0)throw new com.uniquesoft.gwt.shared.validation.ValidationException(errors); to.setVersion(from.getVersion()); to.setName(convertService.toValue(java.lang.String.class,from.getName())); to.setCode(convertService.toValue(java.lang.String.class,from.getCode())); to.setParent(convertService.toValue(com.fudanmed.platform.core.domain.RCMaintenamceType.class,from.getParent())); } public UIMaintenamceType copyFromEntity(final UIMaintenamceType result, final RCMaintenamceType entity) { if(entity==null) return null; result.setId(entity.getId()); result.setVersion(entity.getVersion()); result.setProxy(entity.toProxy()); result.setClazzName(entity.getClass().getName()); result.setName(convertService.toValue(java.lang.String.class,entity.getName())); result.setCode(convertService.toValue(java.lang.String.class,entity.getCode())); result.setParent(convertService.toValue(com.fudanmed.platform.core.domain.proxy.RCMaintenamceTypeProxy.class,entity.getParent())); result.setSimplePy(convertService.toValue(java.lang.String.class,entity.getSimplePy())); return result; } public UIMaintenamceType buildFrom(final RCMaintenamceType entity) { if(entity==null) return null; com.fudanmed.platform.core.web.shared.project.UIMaintenamceType result = new com.fudanmed.platform.core.web.shared.project.UIMaintenamceType(); copyFromEntity(result,entity); return result; } public Class<?> getUIClass() { return UIMaintenamceType.class; } public Class<?> getEntityClass() { return RCMaintenamceType.class; } }
f68249555161c4d543be81915baad61ffdaab188
4adac4a5a53c6c0d5fc92f712a75104c3f18769d
/server/m1212-server-description/src/main/java/com/cfw/m1212/server/description/mapper/DescriptionMapper.java
34e1a9b2909d76fbde136a1e5faa7dffc2b92959
[]
no_license
XXMY/m1212
b0d9e4d72da9479c7592d34b1ccf845cbf3ff250
e536c999b65959fe36653ebe8016ecb79922a173
refs/heads/master
2021-05-05T13:07:59.129334
2018-01-21T08:31:20
2018-01-21T08:31:20
118,316,499
0
0
null
null
null
null
UTF-8
Java
false
false
427
java
package com.cfw.m1212.server.description.mapper; import com.cfw.m1212.model.Description; import com.cfw.plugins.database.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; /** * @author Fangwei_Cai * @time since 2016年4月8日 下午3:12:44 */ @Repository("descriptionMapper") @Mapper public interface DescriptionMapper extends BaseMapper<Description> { }
2f6b8e514193e11856a7cfb5ca7f05578b26b0ed
f86938ea6307bf6d1d89a07b5b5f9e360673d9b8
/CodeComment_Data/Code_Jam/train/Revenge_of_the_Pancakes/S/RevengeOfThePancakes(58).java
2f21113102c8435cfb30ce0983dade2adb2eec35
[]
no_license
yxh-y/code_comment_generation
8367b355195a8828a27aac92b3c738564587d36f
2c7bec36dd0c397eb51ee5bd77c94fa9689575fa
refs/heads/master
2021-09-28T18:52:40.660282
2018-11-19T14:54:56
2018-11-19T14:54:56
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,006
java
package methodEmbedding.Revenge_of_the_Pancakes.S.LYD1080; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * Created by Brijesh on 09-Apr-2016. */ public class RevengeOfThePancakes { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new FileReader("C://Users/Brijesh/Downloads/B-small-attempt0.in")); //BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; int t=Integer.parseInt(br.readLine()); for (int i=1;i<=t;i++){ int count=0; String s=br.readLine(); for(int j=1;j<s.length();j++){ if(s.charAt(j)!=s.charAt(j-1)) count++; } if(s.charAt(s.length()-1)=='-') count++; System.out.print("Case #"+i+": "); System.out.println(count); } } }
6b835c50368415b8c3b8053bea1d7439f5ba5ac6
b8b3087b72eb164fc6ba38a137b721b4b81dd595
/lxt2/client.java
b42d78d5b1d079abbd25fe79a2b2d94dbb3ca269
[]
no_license
2002310/Hello-MyJava
7b931b6f9313831e1deef74f1a09bdeea1fe31bd
4922f9088a2863a4dce553b914e2acf71dd01d34
refs/heads/main
2023-02-11T05:28:58.488931
2021-01-06T12:34:06
2021-01-06T12:34:06
324,475,930
0
0
null
null
null
null
UTF-8
Java
false
false
276
java
package lxt2; public class client { public static void main(String[] args) { game a1 = new cs(); game a2 = new lol(); game a3 = new dnf(); player b1 = new player(); b1.happy(a1); b1.happy(a2); b1.happy(a3); } }
68dd46c6df744b0d525f895c1db528d91f35c0ad
1ec73a5c02e356b83a7b867580a02b0803316f0a
/java/bj/mldn/javase01/no77/Collection/collectiondemo/setdemo/TreeSetPersonAddDemo.java
d7d6af8c6f9e5b4cc01ee36fa10f418252194fe4
[]
no_license
jxsd0084/JavaTrick
f2ee8ae77638b5b7654c3fcf9bceea0db4626a90
0bb835fdac3c2f6d1a29d1e6e479b553099ece35
refs/heads/master
2021-01-20T18:54:37.322832
2016-06-09T03:22:51
2016-06-09T03:22:51
60,308,161
0
1
null
null
null
null
UTF-8
Java
false
false
718
java
package bj.mldn.javase01.no77.Collection.collectiondemo.setdemo; import java.util.Set; import java.util.TreeSet; public class TreeSetPersonAddDemo { /** * 测试 * @param args */ public static void main( String[] args ) { Set< Person > allSet = new TreeSet< Person >(); allSet.add( new Person( "张三", 30 ) ); // 增加重复元素 allSet.add( new Person( "李四", 30 ) ); // 增加重复元素 allSet.add( new Person( "王五", 31 ) ); // 增加重复元素 allSet.add( new Person( "赵六", 32 ) ); // 增加重复元素 allSet.add( new Person( "孙七", 32 ) ); // 增加重复元素 allSet.add( new Person( "孙七", 32 ) ); // 增加重复元素 System.out.println( allSet ); } }
3258ec5b1302f4bfef05414f878357afbcb2bf85
862e0a70ae68513881eb525f33934106b13b0e32
/lmp-shiro/src/main/java/com/lmp/admin/util/IdCardInfoExtractor.java
f64ccac9b1d5f3cf882bd719cedfd7a96286338a
[]
no_license
JackpotHan/Logistics-management-platform
ae3a526aa2a1f4b172ed595d75ac8eaee7c8eac6
480e345baa4d66d7d1c79446024b34a7acd7a113
refs/heads/master
2022-07-20T23:02:38.082261
2020-07-22T06:14:10
2020-07-22T06:14:10
143,122,135
0
0
null
2022-06-17T01:55:39
2018-08-01T07:47:47
Java
UTF-8
Java
false
false
4,316
java
package com.lmp.admin.util; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; public class IdCardInfoExtractor { // 省份 private String province; // 城市 private String city; // 区县 private String region; // 年份 private int year; // 月份 private int month; // 日期 private int day; // 性别 private String gender; // 出生日期 private Date birthday; //年龄 private int age; private Map<String, String> provinceMap = new HashMap<String, String>() { { this.put("11", "北京"); this.put("12", "天津"); this.put("13", "河北"); this.put("14", "山西"); this.put("15", "内蒙古"); this.put("21", "辽宁"); this.put("22", "吉林"); this.put("23", "黑龙江"); this.put("31", "上海"); this.put("32", "江苏"); this.put("33", "浙江"); this.put("34", "安徽"); this.put("35", "福建"); this.put("36", "江西"); this.put("37", "山东"); this.put("41", "河南"); this.put("42", "湖北"); this.put("43", "湖南"); this.put("44", "广东"); this.put("45", "广西"); this.put("46", "海南"); this.put("50", "重庆"); this.put("51", "四川"); this.put("52", "贵州"); this.put("53", "云南"); this.put("54", "西藏"); this.put("61", "陕西"); this.put("62", "甘肃"); this.put("63", "青海"); this.put("64", "宁夏"); this.put("65", "新疆"); this.put("71", "台湾"); this.put("81", "香港"); this.put("82", "澳门"); this.put("91", "国外"); } }; /** * 通过构造方法初始化各个成员属性 */ public IdCardInfoExtractor(String idCard) { if (!IdCardValidatorUtil.validate(idCard)) { return; } if (idCard.length() == 15) { idCard = IdCardValidatorUtil.convert15IdCardTo18IdCard(idCard); } // 获取省份 String provinceId = idCard.substring(0, 2); Set<String> key = this.provinceMap.keySet(); for (String id : key) { if (id.equals(provinceId)) { this.province = this.provinceMap.get(id); break; } } // 获取性别 String id17 = idCard.substring(16, 17); if (Integer.parseInt(id17) % 2 != 0) { this.gender = "男"; } else { this.gender = "女"; } // 获取出生日期 String birthdayStr = idCard.substring(6, 14); try { this.birthday = new SimpleDateFormat("yyyyMMdd").parse(birthdayStr); } catch (ParseException e) { e.printStackTrace(); } GregorianCalendar currentDay = new GregorianCalendar(); currentDay.setTime(birthday); this.year = currentDay.get(Calendar.YEAR); this.month = currentDay.get(Calendar.MONTH) + 1; this.day = currentDay.get(Calendar.DAY_OF_MONTH); //获取年龄 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy"); String year = simpleDateFormat.format(new Date()); this.age = Integer.parseInt(year) - this.year; } public String getProvince() { return province; } public String getCity() { return city; } public String getRegion() { return region; } public int getYear() { return year; } public int getMonth() { return month; } public int getDay() { return day; } public String getGender() { return gender; } public Date getBirthday() { return birthday; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } @Override public String toString() { return "省份:" + this.province + ",性别:" + this.gender + ",出生日期:" + this.birthday; } }
806980a8da82eb53fc332d0ce70dbc5b5e786517
6cd8b82ea0413670c59c557e2bc17519720a90c6
/src/main/java/runnableFiles/Relocator.java
bec76a4d22de8e5fb07893c0b8f3e066a0832959
[]
no_license
kowinter/MATSim
4afab20a9c3531a29b713652d5cdf6a41f834895
71fb9e2f14d752db367aa0e10484b607565ff1a0
refs/heads/master
2020-12-24T06:16:54.496752
2020-02-06T14:17:05
2020-02-06T14:17:05
73,481,782
0
0
null
null
null
null
UTF-8
Java
false
false
30,890
java
package runnableFiles; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.PriorityQueue; import java.util.Random; import java.util.Set; import java.util.Map.Entry; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.contrib.dvrp.data.Fleet; import org.matsim.contrib.dvrp.data.Vehicle; import org.matsim.contrib.dvrp.path.VrpPathWithTravelData; import org.matsim.contrib.dvrp.path.VrpPaths; import org.matsim.contrib.dvrp.schedule.Schedule; import org.matsim.contrib.dvrp.schedule.StayTask; import org.matsim.contrib.dvrp.schedule.Task; import org.matsim.contrib.dvrp.util.LinkTimePair; import org.matsim.contrib.taxi.schedule.TaxiEmptyDriveTask; import org.matsim.contrib.taxi.schedule.TaxiStayTask; import org.matsim.contrib.taxi.schedule.TaxiTask; import org.matsim.contrib.taxi.scheduler.TaxiScheduler; import org.matsim.contrib.util.distance.DistanceCalculator; import org.matsim.contrib.util.distance.DistanceCalculators; import org.matsim.contrib.zone.ZonalSystem; import org.matsim.contrib.zone.Zone; import org.matsim.contrib.zone.util.ZoneFinder; import org.matsim.contrib.zone.util.ZoneFinderImpl; import org.matsim.core.mobsim.framework.MobsimTimer; import org.matsim.core.mobsim.qsim.QSim; import org.matsim.core.router.DijkstraFactory; import org.matsim.core.router.util.LeastCostPathCalculator; import org.matsim.core.router.util.LeastCostPathCalculator.Path; import org.matsim.core.router.util.TravelDisutility; import org.matsim.core.router.util.TravelTime; public class Relocator { //////////////////////////////////////////////////////// // Select Strategy here private static Double horizonTime = 300.0; // 5 min private static int numberOfDesiredTopZones = 3; ///////////////////////////////////////////////////// private static boolean noRelocation = false; //////////////////////////////////////////////////// private static boolean demand = true; private static boolean supply = false; private static boolean demandSupply = false; private static boolean zonal = false; ///////////////////////////////////////////////////// private static boolean cruise = false; public static boolean zoneCruise = false; public static boolean zoneDemandCruise = false; public static boolean innerCityCruise = false; public static boolean outerCityCruise = false; public static boolean networkCruise = false; public static boolean initialCruise = false; ///////////////////////////////////////////////////// public static boolean noInnerCityParking = false; public static boolean noInnerCityParkingDayTime = false; public static Double beginnDayTime = 36000.0; // 10 a.m. public static Double endDayTime = 64800.0; // 6 p.m. public static boolean timeLimitedInnerCityParking = false; public static Double timeLimitInnerCityParking = (60.0 * 60.0 - 1.0); // 60 min ///////////////////////////////////////////////////////// // inner city zones public static List<String> innerCityZones = Arrays.asList("zone.16", "zone.17", "zone.19", "zone.20", "zone.22", "zone.23", "zone.24", "zone.26", "zone.28", "zone.29", "zone.32", "zone.34", "zone.35", "zone.37", "zone.39", "zone.40", "zone.41", "zone.42", "zone.43", "zone.44", "zone.46", "zone.47", "zone.49", "zone.50", "zone.55", "zone.56", "zone.57", "zone.58", "zone.65", "zone.71"); public static List<String> outerCityZones = Arrays.asList("zone.1", "zone.2", "zone.3", "zone.4", "zone.5", "zone.6", "zone.7", "zone.8", "zone.9", "zone.10", "zone.11", "zone.12", "zone.13", "zone.14", "zone.15", "zone.18", "zone.21", "zone.25", "zone.27", "zone.30", "zone.31", "zone.33", "zone.36", "zone.38", "zone.45", "zone.48", "zone.51", "zone.52", "zone.53", "zone.54", "zone.59", "zone.60", "zone.61", "zone.62", "zone.63", "zone.64", "zone.66", "zone.67", "zone.68", "zone.69", "zone.70", "zone.72", "zone.73", "zone.74", "zone.75", "zone.76", "zone.77", "zone.78", "zone.79", "zone.80", "zone.81", "zone.82"); public static Link relocate(Vehicle veh, MobsimTimer timer, Network network, QSim qsim, Map<Id<Zone>, List<Id<Link>>> ZoneLink, Fleet fleet, ZonalSystem zonalSystem, TravelDisutility travelDisutility, TravelTime travelTime, TaxiScheduler scheduler, boolean hasToMoveFromInnerCity) { // 1. vehicles will only move if they have not just relocated Double timeStep = timer.getTimeOfDay(); Double horTime = timeStep + horizonTime; // 5 min Schedule schedule = veh.getSchedule(); TaxiTask currentTask = (TaxiTask) schedule.getCurrentTask(); Map<Id<Zone>, Zone> zones = zonalSystem.getZones(); ZoneFinder zoneFinder = new ZoneFinderImpl(zones, 1.0); Link currentLink = ((TaxiStayTask) veh.getSchedule().getCurrentTask()).getLink(); Zone currentZone = zoneFinder.findZone(currentLink.getCoord()); Map<Id<Zone>, Integer> freeParkingPerZone = Counter_ParkingVehicles.getZoneParking(); if (noRelocation == true) { return currentLink; } int counter = 0; boolean isDayTime = false; if (beginnDayTime < timeStep && timeStep < endDayTime && noInnerCityParkingDayTime == true) { isDayTime = true; } if (hasToMoveFromInnerCity == true) { noInnerCityParking = true; } for (Id<Zone> keyP : zones.keySet()) { counter = counter + freeParkingPerZone.get(keyP); if (freeParkingPerZone.get(keyP) < 1 || keyP.toString().contains("83")) { freeParkingPerZone.remove(keyP); } else { if (innerCityZones.contains(keyP.toString())) { if (noInnerCityParking == true || isDayTime == true) { if (freeParkingPerZone.containsKey(keyP)) { freeParkingPerZone.remove(keyP); } } } } } if (timer.getTimeOfDay() > 19600) { // System.out.println("Debug from here"); } // 2. Find Link according to desired strategy Id<Link> newLink = currentLink.getId(); Link futureLink = null; if (cruise == true) { futureLink = networkCruise(network); } if (demand == true) { newLink = getDemandAnticipationLink(freeParkingPerZone, timeStep, horTime, network, qsim, ZoneLink, zones,zoneFinder, currentLink, currentZone, numberOfDesiredTopZones); futureLink = network.getLinks().get(newLink); } if (supply == true) { newLink = getSupplyAnticipationLink(freeParkingPerZone, timeStep, currentLink, veh, fleet, network, horTime,ZoneLink, zones, zoneFinder, scheduler, numberOfDesiredTopZones, currentZone); futureLink = network.getLinks().get(newLink); } if (demandSupply == true) { newLink = getDemandSupplyBalancingLink(freeParkingPerZone, currentZone, timeStep, currentLink, veh, fleet,horTime, network, qsim, ZoneLink, zones, zoneFinder, scheduler, numberOfDesiredTopZones); futureLink = network.getLinks().get(newLink); } if (zonal == true) { newLink = randomLinkInZone (currentZone, network); futureLink = network.getLinks().get(newLink); } // in case no link could be found according to the selected strategy: // remain in zone or move to a random other zone if (futureLink == null) { // step1: try parking in zone Id<Link> randLinkId = null; if (zoneIsInnerCity(currentZone.getId()) == false) { randLinkId = randomLinkInZone(currentZone, network); } if (randLinkId == null) { // step2: park at closest zone ArrayList<Id<Zone>> zonesWithParking = new ArrayList<Id<Zone>>(); for (Id<Zone> key : freeParkingPerZone.keySet()) { if (!zonesWithParking.contains(key)) { zonesWithParking.add(key); } } Zone closestZone = closestZone(zonesWithParking, currentLink, zones, network, currentZone); randLinkId = randomLinkInZone(closestZone, network); futureLink = network.getLinks().get(randLinkId); Counter_ParkingVehicles.countRelocationRandomAlternative(); } else { futureLink = network.getLinks().get(randLinkId); Counter_ParkingVehicles.countRelocationZoneAlternative(); } } if (currentLink.getId().equals(futureLink.getId()) || currentLink.getToNode() == futureLink.getFromNode()) { Map<Vehicle, Link> taxisWithParkingReservation = Counter_ParkingVehicles.getTaxisWithParkingReservation(); if (taxisWithParkingReservation.containsKey(veh)) { Link linkWithReservation = taxisWithParkingReservation.get(veh); Counter_ParkingVehicles.unpark(linkWithReservation, veh); } Counter_ParkingVehicles.park(futureLink, veh, timer); return futureLink; } // 3. Find path to link LeastCostPathCalculator router = new DijkstraFactory().createPathCalculator(network, travelDisutility, travelTime); Path path = router.calcLeastCostPath(currentLink.getToNode(), futureLink.getFromNode(), timeStep + 1, null, null); VrpPathWithTravelData pathVRP = VrpPaths.createPath(currentLink, futureLink, timeStep + 1, path, travelTime); // 4. Create Task based on path TaxiEmptyDriveTask relocationTask = new TaxiEmptyDriveTask(pathVRP); double endTimeTask = relocationTask.getEndTime(); if (endTimeTask < veh.getServiceEndTime()) { // only assign parking // tasks that can be // finished in time // 5. add driveTask to schedule currentTask.setEndTime(timeStep + 1); schedule.addTask(relocationTask); // 6. add new stayTask to schedule TaxiStayTask stayTask = new TaxiStayTask(endTimeTask, endTimeTask + 1.0, futureLink); schedule.addTask(stayTask); } else { futureLink = currentLink; } Counter_ParkingVehicles.park(futureLink, veh, timer); Counter_ParkingVehicles.countRelocation(); // Counter_ParkingVehicles.updateTaxisEarliestIdleness(veh, // zoneFinder.findZone(futureLink.getCoord()), endTimeTask); return futureLink; } public static Id<Link> getDemandAnticipationLink(Map<Id<Zone>, Integer> freeParkingPerZone, double timeStep, double horizonTime, Network network, QSim qsim, Map<Id<Zone>, List<Id<Link>>> ZoneLink, Map<Id<Zone>, Zone> zones, ZoneFinder zoneFinder, Link currentLink, Zone currentZone, Integer numberOfDesiredTopZones) { // #D1: get all open requests per zone LinkedHashMap<Id<Zone>, Integer> zonalRequestCounter = new LinkedHashMap<Id<Zone>, Integer>(); for (Id<Zone> key : zones.keySet()) { zonalRequestCounter.put(key, 0); } HashMap<Integer, Map<Id<Zone>, Integer>> horReq = Counter_ParkingVehicles.getHorzionRequest(); Integer minT = (int) (timeStep / 60); Integer horT = (int) (horizonTime / 60); for (int t = minT; t < horT + 1; t++) { if (horReq.containsKey(minT)) { Map<Id<Zone>, Integer> minCount = horReq.get(minT); for (Id<Zone> key : zones.keySet()) { Integer minCountPerZone = minCount.get(key); Integer counter = zonalRequestCounter.get(key); zonalRequestCounter.put(key, counter + minCountPerZone); } } } if (horReq.isEmpty()) { return null; } // #D2: remove zones without free parking Set<Id<Zone>> keys = zones.keySet(); for (Id<Zone> keyP : keys) { Integer freeParkingInZone = Counter_ParkingVehicles.getParkingInZone(zones.get(keyP)); Integer freeParking = freeParkingPerZone.get(keyP); if (freeParking == null || freeParkingInZone == null) { zonalRequestCounter.remove(keyP); } else if (!zonalRequestCounter.containsKey(keyP) || zonalRequestCounter.get(keyP) == 0 || freeParking == 0 || freeParkingInZone == 0) { zonalRequestCounter.remove(keyP); } } if (zonalRequestCounter.isEmpty() == true) { return null; } else { if (zonalRequestCounter.size() < numberOfDesiredTopZones) { numberOfDesiredTopZones = zonalRequestCounter.size(); } } // #D3: get candidate zones zonalRequestCounter = sortedZones(zonalRequestCounter); // ArrayList<Id<Zone>> reducedZoneSet = // candidateTopZones(zonalRequestCounter, numberOfDesiredTopZones); ArrayList<Id<Zone>> reducedZoneSet = candidateBottomZones(zonalRequestCounter, numberOfDesiredTopZones); // #D4: get closest of the top zones Zone closestZone = closestZone(reducedZoneSet, currentLink, zones, network, currentZone); // #D5: get link in zones Id<Link> smartLink = randomLinkInZone(closestZone, network); return smartLink; } public static Id<Link> getSupplyAnticipationLink(Map<Id<Zone>, Integer> freeParkingPerZone, Double timeStep, Link currentLink, Vehicle vehicle, Fleet fleet, Network network, Double horizonTime, Map<Id<Zone>, List<Id<Link>>> ZoneLink, Map<Id<Zone>, Zone> zones, ZoneFinder zoneFinder, TaxiScheduler scheduler, Integer numberOfDesiredTopZones, Zone currentZone) { // #S1: initialize vehicle counter: only zones with free parking LinkedHashMap<Id<Zone>, Integer> zonalVecCounter = new LinkedHashMap<Id<Zone>, Integer>(); for (Id<Zone> key : zones.keySet()) { zonalVecCounter.put(key, 0); } Set<Id<Zone>> keys = zones.keySet(); for (Id<Zone> keyP : keys) { Integer freeParkingInZone = Counter_ParkingVehicles.getParkingInZone(zones.get(keyP)); Integer freeParking = freeParkingPerZone.get(keyP); if (freeParking == null || freeParkingInZone == null) { zonalVecCounter.remove(keyP); } else if (!zonalVecCounter.containsKey(keyP) || freeParking == 0 || freeParkingInZone == 0) { zonalVecCounter.remove(keyP); } } // #S2: get all expected free vehicles within horizon time per zone Map<Id<Vehicle>, ? extends Vehicle> vehFleet = fleet.getVehicles(); for (Map.Entry<Id<Vehicle>, ? extends Vehicle> entry : vehFleet.entrySet()) { List<? extends Task> TaskList = entry.getValue().getSchedule().getTasks(); StayTask lastTask = (StayTask) TaskList.get(TaskList.size() - 1); if (lastTask.getBeginTime() <= (horizonTime)) { Id<Zone> lastTaskZoneId = zoneFinder.findZone(lastTask.getLink().getCoord()).getId(); if (zonalVecCounter.containsKey(lastTaskZoneId)) { int vehInLastTaskZone = zonalVecCounter.get(lastTaskZoneId); zonalVecCounter.put(lastTaskZoneId, vehInLastTaskZone + 1); } } } LinkedHashMap<Id<Zone>, Integer> zonalVehicleCounter = zonalVecCounter; if (zonalVehicleCounter.isEmpty()) { return null; } else if (zonalVehicleCounter.size() < numberOfDesiredTopZones) { numberOfDesiredTopZones = zonalVehicleCounter.size(); } // #S3: sort the zones in order && get zones with lowest number of free vehicles zonalVehicleCounter = sortedZones(zonalVehicleCounter); // ArrayList<Id<Zone>> reducedZoneSet =candidateBottomZones(zonalVehicleCounter, numberOfDesiredTopZones); ArrayList<Id<Zone>> reducedZoneSet = candidateTopZones(zonalVehicleCounter, numberOfDesiredTopZones); // #S4: get closest of the top zones Zone closestZone = closestZone(reducedZoneSet, currentLink, zones, network, currentZone); // #S5: get link in zones with the largest number of free parking spots Id<Link> smartLink = randomLinkInZone(closestZone, network); return smartLink; } public static Id<Link> getDemandSupplyBalancingLink(Map<Id<Zone>, Integer> freeParkingPerZone, Zone currentZone, Double timeStep, Link currentLink, Vehicle vehicle, Fleet fleet, Double horizonTime, Network network, QSim qsim, Map<Id<Zone>, List<Id<Link>>> ZoneLink, Map<Id<Zone>, Zone> zones, ZoneFinder zoneFinder, TaxiScheduler scheduler, Integer numberOfDesiredTopZones) { // #B1: get all open requests per zone LinkedHashMap<Id<Zone>, Integer> zonalRequestCounter = new LinkedHashMap<Id<Zone>, Integer>(); for (Id<Zone> key : zones.keySet()) { zonalRequestCounter.put(key, 0); } HashMap<Integer, Map<Id<Zone>, Integer>> horReq = Counter_ParkingVehicles.getHorzionRequest(); Integer minT = (int) (timeStep / 60); Integer horT = (int) (horizonTime / 60); for (int t = minT; t < horT + 1; t++) { if (horReq.containsKey(minT)) { Map<Id<Zone>, Integer> minCount = horReq.get(minT); for (Id<Zone> key : zones.keySet()) { Integer minCountPerZone = minCount.get(key); Integer counter = zonalRequestCounter.get(key); zonalRequestCounter.put(key, counter + minCountPerZone); } } } if (horReq.isEmpty()) { return null; } // #B2: remove zones without free parking Set<Id<Zone>> keys = zones.keySet(); for (Id<Zone> keyP : keys) { Integer freeParkingInZone = Counter_ParkingVehicles.getParkingInZone(zones.get(keyP)); Integer freeParking = freeParkingPerZone.get(keyP); if (freeParking == null || freeParkingInZone == null) { zonalRequestCounter.remove(keyP); } else if (!zonalRequestCounter.containsKey(keyP) || freeParking == 0|| freeParkingInZone == 0) { zonalRequestCounter.remove(keyP); } } if (zonalRequestCounter.isEmpty() == true) { return null; } // #B3: Match requests with idle vehicles // LinkedHashMap<Id<Zone>, Integer> zonalMatchCounter =horizonRequestMatcher(fleet, zonalRequestCounter, network,timeStep, horizonTime, qsim, zoneFinder, zones); Map<Id<Vehicle>, ? extends Vehicle> vehFleet = fleet.getVehicles(); for (Map.Entry<Id<Vehicle>, ? extends Vehicle> entry : vehFleet.entrySet()) { List<? extends Task> TaskList = entry.getValue().getSchedule().getTasks(); StayTask lastTask = (StayTask) TaskList.get(TaskList.size() - 1); if (lastTask.getBeginTime() <= (horizonTime)) { Id<Zone> lastTaskZoneId = zoneFinder.findZone(lastTask.getLink().getCoord()).getId(); if (zonalRequestCounter.containsKey(lastTaskZoneId)) { int openReqInLastTaskZone = zonalRequestCounter.get(lastTaskZoneId); //if (openReqInLastTaskZone <= 0) { //zonalRequestCounter.remove(lastTaskZoneId); //} else { zonalRequestCounter.put(lastTaskZoneId, openReqInLastTaskZone - 1); //} } } } LinkedHashMap<Id<Zone>, Integer> zonalMatchCounter = zonalRequestCounter; // #B4: get Zones with the highest request-vehicle deficit if (zonalRequestCounter.isEmpty() == true) { return null; } else { if (zonalRequestCounter.size() < numberOfDesiredTopZones) { numberOfDesiredTopZones = zonalRequestCounter.size(); } } zonalMatchCounter = sortedZones(zonalMatchCounter); // ArrayList<Id<Zone>> reducedZoneSet = candidateTopZones(zonalMatchCounter, numberOfDesiredTopZones); ArrayList<Id<Zone>> reducedZoneSet = candidateBottomZones(zonalMatchCounter, numberOfDesiredTopZones); // #B5: get closest of the top zones Zone closestZone = closestZone(reducedZoneSet, currentLink, zones, network, currentZone); // #B6: get link in zones with the largest number of free parking spots if (closestZone == null) { System.out.println("Problem (Relocator l.293)"); } if (closestZone.getId().toString().contains("zone.83")) { System.out.println("Problem (Relocator l.296)"); } Id<Link> smartLink = randomLinkInZone(closestZone, network); return smartLink; } public static LinkedHashMap<Id<Zone>, Integer> horizonVehicles(Map<Id<Zone>, Integer> freeParkingPerZone, Network network, Fleet fleet, Double timeStep, Double horizonTime, Map<Id<Zone>, Zone> zones, ZoneFinder zoneFinder, TaxiScheduler scheduler) { // initialize vehicle counter: only zones with free parking LinkedHashMap<Id<Zone>, Integer> vehCounter = new LinkedHashMap<Id<Zone>, Integer>(); for (Id<Zone> key : freeParkingPerZone.keySet()) { vehCounter.put(key, 0); } // get all expected free vehicles within horizon time per zone Map<Id<Vehicle>, ? extends Vehicle> vehFleet = fleet.getVehicles(); for (Map.Entry<Id<Vehicle>, ? extends Vehicle> entry : vehFleet.entrySet()) { LinkTimePair linkTimeFree = scheduler.getEarliestIdleness(entry.getValue()); if (linkTimeFree != null) { if (linkTimeFree.time <= horizonTime) { if (vehCounter.containsKey(zoneFinder.findZone(linkTimeFree.link.getCoord()).getId())) { int vehInLastTaskZone = vehCounter .get(zoneFinder.findZone(linkTimeFree.link.getCoord()).getId()); vehCounter.put(zoneFinder.findZone(linkTimeFree.link.getCoord()).getId(), vehInLastTaskZone + 1); } } } } return vehCounter; } public static Zone closestZone(ArrayList<Id<Zone>> reducedZoneSet, Link currentLink, Map<Id<Zone>, Zone> zones, Network network, Zone currentZone) { Coord currentCoord = currentLink.getCoord(); Zone closestZone = currentZone; double OldDistance = 9999999999999.99; for (int i = 0; i < reducedZoneSet.size(); i++) { Id<Zone> zoneId = reducedZoneSet.get(i); Zone zone = zones.get(zoneId); Coord zoneCoord = zone.getCoord(); DistanceCalculator diCa = DistanceCalculators.crateFreespeedDistanceCalculator(network); double distance = diCa.calcDistance(currentCoord, zoneCoord); if (OldDistance > distance) { closestZone = zone; } } return closestZone; } public static ArrayList<Id<Zone>> candidateTopZones(LinkedHashMap<Id<Zone>, Integer> mapToBeReduced, Integer numberOfDesiredTopZones) { ArrayList<Id<Zone>> candidateZones = new ArrayList<Id<Zone>>(); int i = 0; for (Id<Zone> keyP : mapToBeReduced.keySet()) { if (i < numberOfDesiredTopZones) { candidateZones.add(keyP); i = i + 1; } else { return candidateZones; } } return candidateZones; } public static ArrayList<Id<Zone>> candidateBottomZones(LinkedHashMap<Id<Zone>, Integer> mapToBeReduced, Integer numberOfDesiredTopZones) { ArrayList<Id<Zone>> candidateZones = new ArrayList<Id<Zone>>(); int i = 0; ArrayList<Id<Zone>> alKeys = new ArrayList<Id<Zone>>(mapToBeReduced.keySet()); Collections.reverse(alKeys); for (Id<Zone> keyP : alKeys) { if (i < numberOfDesiredTopZones) { candidateZones.add(keyP); i = i + 1; } else { return candidateZones; } } return candidateZones; } public static Link networkCruise(Network network) { Map<Id<Link>, ? extends Link> links = network.getLinks(); Set<Id<Link>> keySet = links.keySet(); List<Id<Link>> keyList = new ArrayList<Id<Link>>(keySet); int r = new Random().nextInt(links.size()); Link Link = links.get(keyList.get(r)); return Link; } public static Map<Id<Link>, Zone> zonePerLink(ZonalSystem zonalSystem, Network network) { ZoneFinder zoneFinder = new ZoneFinderImpl(zonalSystem.getZones(), 1.0); Map<Id<Link>, Zone> zonePerLink = new HashMap<Id<Link>, Zone>(); Map<Id<Link>, ? extends Link> links = network.getLinks(); for (Id<Link> keyL : links.keySet()) { Coord coord = links.get(keyL).getCoord(); Zone zone = zoneFinder.findZone(coord); zonePerLink.put(keyL, zone); } return zonePerLink; } public static LinkedHashMap<Id<Zone>, Integer> horizonRequestMatcher(Fleet fleet, LinkedHashMap<Id<Zone>, Integer> zonalRequestCounter, Network network, Double timeStep, Double horizonTime, QSim qsim, ZoneFinder zoneFinder, Map<Id<Zone>, Zone> zones) { // get all expected free vehicles within horizon time per zone Map<Id<Vehicle>, ? extends Vehicle> vehFleet = fleet.getVehicles(); for (Map.Entry<Id<Vehicle>, ? extends Vehicle> entry : vehFleet.entrySet()) { List<? extends Task> TaskList = entry.getValue().getSchedule().getTasks(); StayTask lastTask = (StayTask) TaskList.get(TaskList.size() - 1); if (lastTask.getBeginTime() <= (horizonTime)) { Id<Zone> lastTaskZoneId = zoneFinder.findZone(lastTask.getLink().getCoord()).getId(); if (zonalRequestCounter.containsKey(lastTaskZoneId)) { int vehInLastTaskZone = zonalRequestCounter.get(lastTaskZoneId); zonalRequestCounter.put(lastTaskZoneId, vehInLastTaskZone - 1); } } } return zonalRequestCounter; } public static Zone getMaxZone(ZonalSystem zonalSystem, LinkedHashMap<Id<Zone>, Integer> zonalMatchCounter, Zone currentZone) { Id<Zone> zoneMaxReqId = currentZone.getId(); int maxValueInMap = (Collections.max(zonalMatchCounter.values())); for (Entry<Id<Zone>, Integer> entry : zonalMatchCounter.entrySet()) { if (entry.getValue() == maxValueInMap) { zoneMaxReqId = entry.getKey(); // this is the key which has the max value } } Zone zoneMax = (Zone) zonalSystem.getZones().get(zoneMaxReqId); return zoneMax; } public static LinkedHashMap<Id<Zone>, Integer> sortedZones(LinkedHashMap<Id<Zone>, Integer> mapToBeSorted) { List<Entry<Id<Zone>, Integer>> list = new LinkedList<>(mapToBeSorted.entrySet()); Collections.sort(list, new Comparator<Object>() { @SuppressWarnings("unchecked") public int compare(Object o1, Object o2) { return ((Comparable<Integer>) ((Map.Entry<Id<Zone>, Integer>) (o1)).getValue()) .compareTo(((Map.Entry<Id<Zone>, Integer>) (o2)).getValue()); } }); LinkedHashMap<Id<Zone>, Integer> resultingMap = new LinkedHashMap<>(); for (Iterator<Entry<Id<Zone>, Integer>> it = list.iterator(); it.hasNext();) { Map.Entry<Id<Zone>, Integer> entry = (Map.Entry<Id<Zone>, Integer>) it.next(); resultingMap.put(entry.getKey(), entry.getValue()); } return resultingMap; } public static PriorityQueue<Id<Zone>> topZonesWithParking(LinkedHashMap<Id<Zone>, Integer> zonalMatchCounter, Integer numberOfDesiredTopZones) { int n = numberOfDesiredTopZones; PriorityQueue<Id<Zone>> topN = null; if (zonalMatchCounter.size() > 1) { topN = new PriorityQueue<Id<Zone>>(n, new Comparator<Id<Zone>>() { public int compare(Id<Zone> s1, Id<Zone> s2) { return Double.compare(zonalMatchCounter.get(s1), zonalMatchCounter.get(s2)); } }); for (Id<Zone> key : zonalMatchCounter.keySet()) { if (topN.size() < n) topN.add(key); else if (zonalMatchCounter.get(topN.peek()) < zonalMatchCounter.get(key)) { topN.poll(); topN.add(key); } } } return topN; } public static Zone closestTopZone(Integer n, Network network, LinkedHashMap<Id<Zone>, Integer> zonalMatchCounter, Zone currentZone, Link currentLink, Map<Id<Zone>, Zone> zones) { Coord currentCoord = currentLink.getCoord(); Map<Id<Zone>, Integer> distancesToVehicle = new HashMap<Id<Zone>, Integer>(); if (n > zonalMatchCounter.size()) { n = zonalMatchCounter.size(); } int counter = 1; for (Id<Zone> z : zonalMatchCounter.keySet()) { if (counter <= n) { Zone zoneMin = zones.get(z); Coord zoneCoord = zoneMin.getCoord(); DistanceCalculator diCa = DistanceCalculators.crateFreespeedDistanceCalculator(network); double distance = diCa.calcDistance(currentCoord, zoneCoord); distancesToVehicle.put(z, (int) distance); counter = counter + 1; } } Id<Zone> minDistance = distancesToVehicle.entrySet().stream() .min((entry1, entry2) -> entry1.getValue() > entry2.getValue() ? 1 : -1).get().getKey(); Zone closestZone = zones.get(minDistance); return closestZone; } public static Zone zoneWithMinVeh(LinkedHashMap<Id<Zone>, Integer> vehCounter, Link currentLink, Map<Id<Zone>, Zone> zones, ZoneFinder zoneFinder) { Map<Id<Zone>, Integer> freeParkingPerZone = Counter_ParkingVehicles.getZoneParking(); // get zone with the least amount of vehicles (that has free parking space) Entry<Id<Zone>, Integer> min = null; for (Entry<Id<Zone>, Integer> entry : vehCounter.entrySet()) { if (min == null || min.getValue() > entry.getValue()) { if (freeParkingPerZone.containsKey(entry.getKey())) { if (freeParkingPerZone.get(entry.getKey()) > 0) { min = entry; } } } } return zones.get(min.getKey()); } public static Link LinkInZone(ZonalSystem zonalSystem, Zone maxZone, Link currentLink, Network network) { Link smartLink = currentLink; List<Id<Link>> linkIdsInZoneMax = new ArrayList<Id<Link>>(); Map<Id<Link>, ? extends Link> links = network.getLinks(); for (Id<Link> key : links.keySet()) { Id<Link> thisId = key; ZoneFinder zoneFinder = new ZoneFinderImpl(zonalSystem.getZones(), 1.0); Coord coord = links.get(thisId).getCoord(); Zone zone = zoneFinder.findZone(coord); if (zone != maxZone) { linkIdsInZoneMax.add(thisId); } } Random rand = new Random(); if (linkIdsInZoneMax.size() > 0) { int ListItem = rand.nextInt(linkIdsInZoneMax.size()); Id<Link> anticipatedLinkID = linkIdsInZoneMax.get(ListItem); Link anticipatedLink = links.get(anticipatedLinkID); smartLink = anticipatedLink; } else { smartLink = currentLink; } return smartLink; } public static Id<Link> randomLinkInZone(Zone closestZone, Network network) { Random rand = new Random(); Link anticipatedLink = null; List<Id<Link>> parkingInZone = Counter_ParkingVehicles.getLinksWithFreeParkingInZone(closestZone); if (parkingInZone.size() > 0) { int ListItem = rand.nextInt(parkingInZone.size()); Id<Link> anticipatedLinkID = parkingInZone.get(ListItem); int parkingOnThisLink = Counter_ParkingVehicles.getParkingOnLink(anticipatedLinkID); if (parkingOnThisLink > 0) { anticipatedLink = network.getLinks().get(anticipatedLinkID); } } else { return null; } return anticipatedLink.getId(); } public static boolean getNoReloaction() { return noRelocation; } public static boolean getTimeLimitedInnerCityParking() { return timeLimitedInnerCityParking; } public static Double getTimeLimitInnerCityParking() { return timeLimitInnerCityParking; } public static boolean getLimitInnerCityParkingDaytime(Double currentTime) { boolean isDayTimeLimitedAndDayTime = false; if (currentTime > beginnDayTime && currentTime < endDayTime && noInnerCityParkingDayTime == true) { isDayTimeLimitedAndDayTime = true; } return isDayTimeLimitedAndDayTime; } public static Double getDayStartTime() { return beginnDayTime; } public static boolean getCruise() { return cruise; } public static boolean getZonalCruise() { return zoneCruise; } public static boolean getZonalDemandCruise() { return zoneDemandCruise; } public static boolean getOuterCityCruise() { return outerCityCruise; } public static boolean getInnerCityCruise() { return innerCityCruise; } public static boolean getNetworkCruise() { return networkCruise; } public static boolean getInitialCruise() { return initialCruise; } public static boolean getNoInnerCityParking() { return noInnerCityParking; } public static boolean zoneIsInnerCity(Id<Zone> zone) { String zoneId = zone.toString(); boolean innerCity = innerCityZones.contains(zoneId); return innerCity; } public static double getParkingTimeLimitInnerCity(Double currentTime) { Double moveTime = 104400.0; if (noInnerCityParking == true || timeLimitedInnerCityParking == true) { moveTime = currentTime + timeLimitInnerCityParking; } if (noInnerCityParkingDayTime == true) { if (currentTime < beginnDayTime) { moveTime = beginnDayTime + timeLimitInnerCityParking; } else if (currentTime > (endDayTime - timeLimitInnerCityParking)) { moveTime = 104400.0; } else { moveTime = currentTime + timeLimitInnerCityParking; } } return moveTime; } }
00f011aefb428a43db56b94a9cfe8a40506aa395
917e768861915af7c69c5e2cee29e00972e0558a
/src/main/java/com/company/models/RedmineUser.java
ae2e98809d210b8c2c5022b2902032c4206c4e94
[]
no_license
AutomatizacionBmt/projectg3-appium-e2e
167822044105b4e7dadd507463c9f639f7a27bfb
56cdf55e310ffa2c7e6758934018b58104090439
refs/heads/main
2023-02-22T22:07:06.696139
2021-01-30T17:23:23
2021-01-30T17:23:23
332,220,425
0
0
null
null
null
null
UTF-8
Java
false
false
1,805
java
package com.company.models; public class RedmineUser { private String userName; private String firstName; private String lastName; private String email; private String language; private String password; private Boolean isAdministrator; public RedmineUser() { } public RedmineUser(String userName, String firstName, String lastName, String email, String language, String password, Boolean isAdministrator) { this.userName = userName; this.firstName = firstName; this.lastName = lastName; this.email = email; this.language = language; this.password = password; this.isAdministrator = isAdministrator; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getLanguage() { return language; } public void setLanguage(String language) { this.language = language; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public Boolean getAdministrator() { return isAdministrator; } public void setAdministrator(Boolean administrator) { isAdministrator = administrator; } }
bd649a714560c8ab39e4ef9c1c682978548e7298
723cfefde46782fcb1252bdd92b450abf2cd287c
/spring/mvc_part3_board/src/main/java/net/koreate/controller/SearchBoardController.java
e477d0a867fb3a235ab1a31826fb0fc955802efd
[]
no_license
cutiler/2019_BusanStudy
8c577f42b05031d788749062c616d23cb49f8aca
ac3ef3a630ce4efd88516f710b09114160ecf445
refs/heads/master
2022-12-22T03:06:45.066051
2019-08-02T03:56:54
2019-08-02T03:56:54
185,716,976
0
0
null
2022-12-16T00:57:15
2019-05-09T03:06:51
HTML
UTF-8
Java
false
false
3,546
java
package net.koreate.controller; import java.util.List; import javax.inject.Inject; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import net.koreate.service.BoardService; import net.koreate.util.PageMaker; import net.koreate.util.SearchCriteria; import net.koreate.vo.BoardVO; @Controller @RequestMapping("/sboard/*") public class SearchBoardController { @Inject BoardService service; @GetMapping("/list") /*@RequestParam(name="searchType", required=false) String searchType, @RequestParam(name="keyword", required=false) String keyword */ public String list(SearchCriteria cri, Model model) { System.out.println(cri); List<BoardVO> list = service.searchList(cri); model.addAttribute("boardList", list); model.addAttribute("cri", cri); PageMaker pageMaker = service.getPageMaker(cri); model.addAttribute("pageMaker", pageMaker); return "sboard/listPage"; } @GetMapping("/readPage") public String readpage( SearchCriteria cri, int bno, RedirectAttributes rttr) { service.updateViewCnt(bno); rttr.addAttribute("page",cri.getPage()); rttr.addAttribute("bno",bno); rttr.addAttribute("searchType",cri.getSearchType()); rttr.addAttribute("keyword",cri.getKeyword()); return "redirect:/sboard/readDetail"; } @GetMapping("/readDetail") public String readPage( @ModelAttribute("cri") SearchCriteria cri, int bno, Model model) { BoardVO board = service.read(bno); model.addAttribute("board",board); return "sboard/readPage"; } @GetMapping("/register") public void register() {} @PostMapping("/register") public String register(BoardVO board, RedirectAttributes rttr) { System.out.println("sbaord 게시글 작성 요청"); System.out.println(board); String msg = service.register(board); rttr.addFlashAttribute("result", msg); return "redirect:/sboard/list"; } @GetMapping("/modifyPage") public String modify( int bno, Model model, @ModelAttribute("cri") SearchCriteria cri) { System.out.println(cri); BoardVO board = service.read(bno); model.addAttribute("board",board); return "/sboard/modify"; } @PostMapping("/modifyPage") public String modifyPost( BoardVO board, SearchCriteria cri, RedirectAttributes rttr) { System.out.println(board); System.out.println(cri); String msg = service.modify(board); rttr.addFlashAttribute("result",msg); rttr.addAttribute("bno",board.getBno()); rttr.addAttribute("page",cri.getPage()); rttr.addAttribute("perPageNum",cri.getPerPageNum()); rttr.addAttribute("searchType",cri.getSearchType()); rttr.addAttribute("keyword",cri.getKeyword()); return "redirect:/sboard/readDetail"; } @PostMapping("remove") public String remove(int bno, SearchCriteria cri, RedirectAttributes rttr) { System.out.println("게시물 삭제요청 : "+bno); String msg = service.remove(bno); rttr.addFlashAttribute("result",msg); rttr.addAttribute("page",cri.getPage()); rttr.addAttribute("perPageNum",cri.getPerPageNum()); rttr.addAttribute("searchType",cri.getSearchType()); rttr.addAttribute("keyword",cri.getKeyword()); return "redirect:/sboard/list"; } }
6b489652da3facac9e7f2c0ece4bf6ed61178c4d
75d7d12e501ebfbcbe868023887176b17a7b1931
/2019_1_20/IDEAL/IDEAL/IDEAL-MANAGER-WEB/src/main/java/cn/ideal/manager/controller/CommodityCatController.java
e807a17c69bd81113e7904194fd083b6003ced72
[]
no_license
RZZBlackMagic/first_repository
ba48fc0934181da525ce3eb4bd5e7d405a6d6978
35774058fbec5df07c62719bbddf514e730f5125
refs/heads/master
2022-12-27T04:26:45.351129
2020-11-04T09:40:01
2020-11-04T09:40:01
156,545,713
2
0
null
2022-12-16T07:12:41
2018-11-07T12:50:01
JavaScript
UTF-8
Java
false
false
2,633
java
package cn.ideal.manager.controller; import cn.ideal.common.pojo.MessageResult; import cn.ideal.common.pojo.TableJsonResult; import cn.ideal.common.pojo.TreeJsonResult; import cn.ideal.manager.service.CommodityCatService; import cn.ideal.pojo.CommodityCat; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import java.util.List; /** * @author XINER * @create 2018-11-27 19:27 * @desc 商品分类--Controller **/ @Controller public class CommodityCatController { /** * 商品分类Mapper */ @Autowired private CommodityCatService commodityCatService; /** * 向 Bootstrap Table 填充的分类表单 * @param pid 按父类Pid检索 * @return 父类的子分类 */ @RequestMapping("/manager/initTable/commodityCategory.do") @ResponseBody public TableJsonResult getCategoryByIdForTable(String pid, int page, int limit){ return commodityCatService.getCategoryByPidForTable(Long.valueOf(pid), page, limit); } /** * 从 Bootstrap Table 接收的编辑修改请求 * * @param commodityCat 修改的分类条目信息 * @return MessageResult 反馈消息 */ @RequestMapping("/manager/bootstrap/editCommodityCategory.do") @ResponseBody public MessageResult editCategoryByPidAndFieldForTable(CommodityCat commodityCat){ return commodityCatService.editCategoryByPidAndFieldForTable(commodityCat); } /** * 向 zTree 填充分类树 * * @return 全部分类 */ @RequestMapping("/manager/ztree/commodityCate.do") @ResponseBody public List<TreeJsonResult> getCategoryListForTree(){ return commodityCatService.getCategoryListForTree(); } /** * 新增 CommodityCat 商品分类 * * @param commodityCat 商品分类表单 * @return MessageResult */ @RequestMapping("/manager/bootstrap/commodityCat.do") @ResponseBody public MessageResult insertCategory(String pid,String name){ return commodityCatService.insertCategory(name,pid); } /** * 删除 CommodityCat List 商品分类列表 * @param cidList 商品分类id的列表 * @return MessageResult */ @RequestMapping("/manager/bootstrap/removeCate.do") @ResponseBody public MessageResult deleteCategory( String id,String pid){ //将传过来的字符串切割 return commodityCatService.deleteCategory(id,pid); } }
6d2e6944388ceb98949f9336e353b7cf35f63c94
26738cd00605204493220a1e9b4b0f0bc928b84e
/src/com/esipovich/masterclass/hashcode/Labrador.java
fc82bf0c6e5dc1f1513572e8332cf9b93b5559d1
[]
no_license
esipovich92/java-masterclass
d9b4079c2cbd131e10f1a8315a0a33a386ab4c3a
e6cf8aee6275da8ca19f7c9312a492755e76f9ca
refs/heads/master
2021-04-15T06:57:42.025243
2018-04-24T18:59:31
2018-04-24T18:59:31
126,375,168
0
0
null
null
null
null
UTF-8
Java
false
false
521
java
package com.esipovich.masterclass.hashcode; /** * @author Artem Esipovich 11.04.2018 */ public class Labrador extends Dog { public Labrador(String name) { super(name); } // @Override // public boolean equals(Object obj) { // if(this == obj) { // return true; // } // // if(obj instanceof Labrador) { // String objName = ((Labrador) obj).getName(); // return this.getName().equals(objName); // } // // return false; // } }
e870871017378ec9072be4c7a74c609b24da46b6
45298a032acb1ae540c23fc40504ef713254380b
/msa-apply/src/main/java/com/example/msaapply/config/PaymentConfiguration.java
b35cc8e76866e3cab25f0619b0b01e616af64b86
[]
no_license
kklck/react_msa
a151a8970cfc47903fbf987d5ec737cdb6505b88
121862a01dd8622f46d8364b80369a75c0c99e0a
refs/heads/master
2023-07-02T10:22:48.781371
2021-08-11T05:50:42
2021-08-11T05:50:42
387,026,315
0
1
null
null
null
null
UTF-8
Java
false
false
1,251
java
package com.example.msaapply.config; import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import reactor.core.publisher.Flux; import java.util.Arrays; import java.util.List; @Configuration public class PaymentConfiguration { @Bean ServiceInstanceListSupplier serviceInstanceListSupplier() { return new DemoServiceInstanceListSuppler("msa-payment"); } } class DemoServiceInstanceListSuppler implements ServiceInstanceListSupplier { private final String serviceId; DemoServiceInstanceListSuppler(String serviceId) { this.serviceId = serviceId; } @Override public String getServiceId() { return serviceId; } @Override public Flux<List<ServiceInstance>> get() { return Flux.just(Arrays .asList(new DefaultServiceInstance(serviceId + "1", serviceId, "localhost", 8002, false), new DefaultServiceInstance(serviceId + "2", serviceId, "localhost", 7777, false))); } }
d84c170c1cbb8e2d3fe02a80a2d121b5cb3f5a10
b026c069b881b7a5ddb047982bb34dab26c0a465
/src/main/java/project/server/hibernate/services/sequrity/UsersService.java
296654cfc5d35e7c351567a0a7ec03010cf9f7d7
[]
no_license
Pirokarus/BellWeb
9f5e94b3d69117e2b7bdafafbdfa0fc4cb8516b5
e95cc517ce52e6c2f6f41449d561241e04c28473
refs/heads/master
2021-01-19T19:23:37.146096
2017-09-12T10:25:31
2017-09-12T10:25:31
101,188,514
0
0
null
null
null
null
UTF-8
Java
false
false
497
java
package project.server.hibernate.services.sequrity; import project.server.hibernate.entities.UsersEntity; import java.util.List; public interface UsersService { int getId(String login, String password); UsersEntity getUser(String login, String password); void save(UsersEntity entity); List<UsersEntity> findAll(); UsersEntity findById(int id); void deleteById(int id); void updateUser(UsersEntity entity); UsersEntity findByUsername(String username); }
2157cdc9cbe1139adc487cefaa09ddcbfbf9a8aa
b25804700d9eb9537051acf73d0d3dc85a8f51cf
/jsp/Delibird/src/Admin/RiderDetailDB.java
57448261e2eab7796cead2d285b7c167e7754799
[]
no_license
jhyuk97/Delibird
b238285d32126685def6c8624f144485e42da43e
79ce363dae5d55b7a8217096b3ef75e3bb0c4e85
refs/heads/main
2023-06-11T15:45:26.903282
2021-07-05T07:05:48
2021-07-05T07:05:48
382,993,579
0
0
null
null
null
null
UTF-8
Java
false
false
1,296
java
package Admin; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class RiderDetailDB { private Connection conn=null; private Statement stmt=null; private ResultSet rs = null; public RiderDetailDB() { try{ Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); String connectionUrl = "jdbc:sqlserver://localhost:1433; DataBaseName=DeilBird; user=sa; password=system;"; conn = DriverManager.getConnection(connectionUrl); stmt = conn.createStatement(); }catch(Exception e){ e.printStackTrace(); } } public void closeDB()throws Exception{ if(stmt != null) stmt.close(); if(conn != null) conn.close(); } private void getResultSet(String ID,String StartDate, String EndDate)throws Exception{ String sql; if(StartDate == null || StartDate == "") sql = "select * from 라이더호출 where 라이더ID = '" + ID + "'"; else sql = "select * from 라이더호출 where 라이더ID = '" + ID + "' and 호출날짜 >= '" + StartDate +"' and 호출날짜 <= '" + EndDate+ "'"; rs = stmt.executeQuery(sql); } public ResultSet getRs(String ID,String StartDate, String EndDate) throws Exception { getResultSet(ID, StartDate, EndDate); return rs; } }
40a3f3fdf63e1716e5b43342c160082b91650c7e
285ce97dcfddbe0cfc7f38ae1c7a744abd5e6037
/script-engine/src/main/java/org/ihtsdo/termserver/scripting/reports/AttributeValueOutsideRange.java
e865f0218d29b666f31fa82fd6f91355e858556b
[ "Apache-2.0" ]
permissive
kparmar1/reporting-engine
93bd1b52df58572dffa93d23246cdc7eb5a1a5c3
d28b4ce8b9d96ea0bd3453c4721c90a241ee43b6
refs/heads/master
2021-05-21T19:19:50.988330
2020-04-29T13:49:31
2020-04-29T13:49:31
252,767,060
0
0
null
2020-04-03T15:12:13
2020-04-03T15:12:12
null
UTF-8
Java
false
false
2,479
java
package org.ihtsdo.termserver.scripting.reports; import java.io.IOException; import java.io.PrintStream; import java.util.Set; import org.ihtsdo.otf.exception.TermServerScriptException; import org.ihtsdo.termserver.scripting.domain.Concept; import org.ihtsdo.termserver.scripting.domain.Relationship; /** * DRUGS-468 * Report of concepts which use a particular attribute type, but where the value * is outside of a particular range */ public class AttributeValueOutsideRange extends TermServerReport { Concept attributeType; Set<Concept> acceptableRange; Concept subHierarchy; public static void main(String[] args) throws TermServerScriptException, IOException { AttributeValueOutsideRange report = new AttributeValueOutsideRange(); try { report.additionalReportColumns = "CharacteristicType, Attribute, WhatWasInferred?"; report.init(args); report.loadProjectSnapshot(false); //Load all descriptions report.postInit(); report.runAttributeValueOutsideRangeReport(); } catch (Exception e) { info("Failed to produce ConceptsWithOrTargetsOfAttribute Report due to " + e.getMessage()); e.printStackTrace(new PrintStream(System.out)); } finally { report.finish(); } } public void postInit() throws TermServerScriptException { attributeType = gl.getConcept("732947008"); // |Has presentation strength denominator unit (attribute)| acceptableRange = gl.getConcept("732935002").getDescendents(NOT_SET, CharacteristicType.INFERRED_RELATIONSHIP, true); // | Unit of presentation (unit of presentation).") subHierarchy = gl.getConcept("373873005"); // |Pharmaceutical / biologic product (product)|" initialiseSummaryInformation("Issues reported"); super.postInit(); } private void runAttributeValueOutsideRangeReport() throws TermServerScriptException { for (Concept c : subHierarchy.getDescendents(NOT_SET)) { //If our Attribute type is present, report if the value is outside of the range for (Relationship r : c.getRelationships(CharacteristicType.STATED_RELATIONSHIP, attributeType, ActiveState.ACTIVE)) { if (!acceptableRange.contains(r.getTarget())) { report (c, "Unacceptable target value", r.toString()); incrementSummaryInformation("Issues reported"); } else { debug ("Acceptable: " + r); incrementSummaryInformation(r.getTarget().toString()); incrementSummaryInformation("Attributes within range"); } } incrementSummaryInformation("Concepts checked"); } } }
2ef646035d37cb6cd6be6376ce4117c1159553bb
84406ebefabe9c44fa88b532645fcb75ec659f16
/wear2/src/main/java/com/cavytech/wear2/util/PinYinUtils.java
87a7cc7ef273dc000494c842fc62d37b0bb0dfd9
[]
no_license
panzhihua/CavyTech
fdf5944fdca8350debfcd408690fa1d70ae12c59
b50be3b8ca80a4ef59dbf040df605f63272b4d35
refs/heads/master
2020-07-03T18:34:15.888695
2016-08-26T02:33:20
2016-08-26T02:33:20
66,608,075
0
0
null
null
null
null
UTF-8
Java
false
false
4,563
java
package com.cavytech.wear2.util; /** * Created by libin on 4/26 0026. * 邮箱:[email protected] */ import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Environment; import android.text.TextUtils; import com.cavytech.wear2.application.CommonApplication; import com.cavytech.wear2.entity.DBfriendBean; import net.sourceforge.pinyin4j.PinyinHelper; import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; import org.xutils.DbManager; import org.xutils.db.Selector; import org.xutils.x; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.regex.Pattern; /** * author zaaach on 2016/1/28. */ public class PinYinUtils { private static final String NAME = "nickname"; private static final String PINYIN = "pinyin"; /** * 获取拼音的首字母(大写) * @param pinyin * @return */ public static String getFirstLetter(final String pinyin){ if (TextUtils.isEmpty(pinyin)) return ""; String c = pinyin.substring(0, 1); Pattern pattern = Pattern.compile("^[A-Za-z]+$"); if (pattern.matcher(c).matches()){ return c.toUpperCase(); } return ""; } /** * 将汉字转换为全拼 * * @param src * @return String */ public static String getPinYin(String src) { char[] t1 = null; t1 = src.toCharArray(); // System.out.println(t1.length); String[] t2 = new String[t1.length]; // System.out.println(t2.length); // 设置汉字拼音输出的格式 HanyuPinyinOutputFormat t3 = new HanyuPinyinOutputFormat(); t3.setCaseType(HanyuPinyinCaseType.LOWERCASE); t3.setToneType(HanyuPinyinToneType.WITHOUT_TONE); t3.setVCharType(HanyuPinyinVCharType.WITH_V); String t4 = ""; int t0 = t1.length; try { for (int i = 0; i < t0; i++) { // 判断能否为汉字字符 // System.out.println(t1[i]); if (Character.toString(t1[i]).matches("[\\u4E00-\\u9FA5]+")) { t2 = PinyinHelper.toHanyuPinyinStringArray(t1[i], t3);// 将汉字的几种全拼都存到t2数组中 t4 += t2[0];// 取出该汉字全拼的第一种读音并连接到字符串t4后 } else { // 如果不是汉字字符,间接取出字符并连接到字符串t4后 t4 += Character.toString(t1[i]); } } } catch (BadHanyuPinyinOutputFormatCombination e) { e.printStackTrace(); } return t4; } /** * 将字符串转换成ASCII码 * @param cnStr * @return String */ public static String getCnASCII(String cnStr) { StringBuffer strBuf = new StringBuffer(); // 将字符串转换成字节序列 byte[] bGBK = cnStr.getBytes(); for (int i = 0; i < bGBK.length; i++) { // 将每个字符转换成ASCII码 strBuf.append(Integer.toHexString(bGBK[i] & 0xff)); } return strBuf.toString(); } /** * 通过名字或者拼音搜索 * @param keyword * @return */ public static List<DBfriendBean> searchFriend(final String keyword){ // SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(Environment.getExternalStorageDirectory().toString() + "CB_LIST.db", null); SQLiteDatabase db = CommonApplication.dm.getDatabase(); Cursor cursor = db.rawQuery("select * from " + "friend" +" where nickname like \"%" + keyword + "%\" or pinyin like \"%" + keyword + "%\"", null); List<DBfriendBean> result = new ArrayList<>(); DBfriendBean city; while (cursor.moveToNext()){ String name = cursor.getString(cursor.getColumnIndex(NAME)); String pinyin = cursor.getString(cursor.getColumnIndex(PINYIN)); city = new DBfriendBean(); city.setPinyin(pinyin); city.setNickname(name); result.add(city); } cursor.close(); // db.close(); Collections.sort(result, new PinyinComparator()); return result; } }
3b1004c11a461c3d7dd873a34f15dc10c12bd40b
b3f6c11c8145627d47aaaddc9f435b1091fa8c0b
/src/TemperatureCalculation/ThreadGenerator.java
d0b3b9020971593b9bf5280bef3a78c46b3fd0d7
[]
no_license
Lbarte/RWD.Lab.1
e9f139251720d787c14870124c85433684641b9e
438c6a3af38f4b51cc125ebcbb3f20792af81a9e
refs/heads/master
2021-05-04T09:07:44.704570
2016-11-28T16:49:01
2016-11-28T16:49:01
70,402,284
0
0
null
null
null
null
WINDOWS-1251
Java
false
false
1,438
java
package TemperatureCalculation; public class ThreadGenerator implements Runnable { private String threadName; private int sensorIndex; private int generationIndex; private int temperature; ThreadGenerator (int sensorIndex, int generationIndex) { this.sensorIndex = sensorIndex; this.generationIndex = generationIndex; threadName = String.valueOf(sensorIndex); Thread threadInstance = new Thread(this, threadName); System.out.println("Новий сенсор: " + threadInstance); threadInstance.start(); } public void run() { try { Sensor sensorInstance = new Sensor(); // клас, що генерується в окремому потоці temperature = sensorInstance.getTemperature(); // температура від давача System.out.println("Температура давача " + threadName + " = " + temperature); Thread.sleep(sensorInstance.getDelay()); // затримка на провіднику Writer writerInstance = new Writer(); System.out.println("Температура при записі = " + temperature); writerInstance.write(generationIndex + "\t" + sensorIndex + "\t" + temperature + "\n"); } catch (InterruptedException e) { System.out.println(threadName + " перерваний " + e); } catch (Exception e) { System.out.println(threadName + " з помилкою " + e); } System.out.println(threadName + " завершено."); } }
2b330f20c1cd1ad0540a834e2c7eee67b13076bb
4047d8aad819e539d61b1ff8a49c74cbcf781751
/ cz2006-mambo5/Mambo5/src/mambo5/Controller/StallController.java
4bd0d4587b31573554d15a5daed2592b8cb0754a
[]
no_license
xVertiCaLx/cz2006-mambo5
e4429e05cd76730381fb9cd28a62f5bbb77e84d2
5e1d819b198bff3af755599103d22e4a59ecd0fd
refs/heads/master
2021-01-20T09:09:37.429985
2013-11-08T11:53:43
2013-11-08T11:53:43
32,205,151
0
0
null
null
null
null
UTF-8
Java
false
false
1,505
java
package mambo5.Controller; import java.util.ArrayList; import mambo5.Database.DataStoreFactory; import mambo5.Database.DataStoreInterface; import mambo5.Database.SystemConfiguration; import mambo5.Entity.Stall; public class StallController { private DataStoreInterface dataStore; private SystemConfiguration sysConfig; public ArrayList<Stall> processRetrieveStallList(int canteenID) { sysConfig = new SystemConfiguration(); dataStore = DataStoreFactory.createDataStore(sysConfig); return dataStore.retrieveStallList(canteenID); } public int validateStallDetail(int canteenID, String stallUnit, String stallName, String stallDesc, String stallStatus){ int validate = 0; sysConfig = new SystemConfiguration(); dataStore = DataStoreFactory.createDataStore(sysConfig); validate = dataStore.createStall(canteenID, stallUnit, stallName, stallDesc, stallStatus); return validate; } public int validateStallDetail(int stallID, String stallName, String stallDesc, String stallStatus){ int validate = 0; sysConfig = new SystemConfiguration(); dataStore = DataStoreFactory.createDataStore(sysConfig); validate = dataStore.updateStallDetail(stallID, stallName, stallDesc, stallStatus); return validate; } public int processDeleteStall(int stallID) { sysConfig = new SystemConfiguration(); dataStore = DataStoreFactory.createDataStore(sysConfig); return dataStore.deleteStall(stallID); } }
[ "[email protected]@861b9790-7418-99c2-d497-464402a33044" ]
[email protected]@861b9790-7418-99c2-d497-464402a33044
5bbf1a9df444c67be61531c1c74568d9dade959e
153ff81500d06c34989b5e5fbc6294db9688ef2f
/course1/sem2/hw6/task2/src/main/java/sem2/hw6/task2/VectorSet.java
b6295cb0dc6e9099269947595af6dd49ca5903d7
[ "Unlicense" ]
permissive
Victor-Y-Fadeev/SPbSU
56342a9720efdd8b65d22820be611b6be1394b67
c3b6cfc1924728138e89f6daaf0bbd8e1819ea3d
refs/heads/master
2021-01-12T11:13:00.008337
2019-09-25T06:36:38
2019-09-25T06:36:38
72,865,243
4
4
Unlicense
2018-11-18T19:03:20
2016-11-04T16:26:01
Java
UTF-8
Java
false
false
1,677
java
package sem2.hw6.task2; import java.util.Collection; import java.util.Iterator; import java.util.Set; import java.util.Vector; /** Vector implements Set class. */ public class VectorSet<E> implements Set<E> { private Vector<E> vector; public VectorSet() { vector = new Vector<E>(); } @Override public int size() { return vector.size(); } @Override public boolean isEmpty() { return vector.isEmpty(); } @Override public boolean contains(Object o) { return vector.contains(o); } @Override public Iterator<E> iterator() { return vector.iterator(); } @Override public Object[] toArray() { return vector.toArray(); } @Override public <T> T[] toArray(T[] a) { return vector.toArray(a); } @Override public boolean add(E e) { if (contains(e)) { return false; } vector.add(e); return true; } @Override public boolean remove(Object o) { return vector.remove(o); } @Override public boolean containsAll(Collection<?> c) { return vector.containsAll(c); } @Override public boolean addAll(Collection<? extends E> c) { if (containsAll(c)) { return false; } c.forEach(value -> add(value)); return true; } @Override public boolean retainAll(Collection<?> c) { return vector.retainAll(c); } @Override public boolean removeAll(Collection<?> c) { return vector.removeAll(c); } @Override public void clear() { vector.clear(); } }
7031588e3c00ddc5278ee8d831a566a37f1d1189
f3f85c83de772c9534ceee79ee6c2da2ede319b8
/travel-agency-spring-mvc/src/main/java/cz/fi/muni/pa165/travelagency/mvc/forms/ExcursionDTOValidator.java
b803d450b4a770d98561925873d0a62dd1f64e40
[]
no_license
sabir12/travel-agency
92ec96a9f6250a89458a3b517578f5606654b9ac
26788e18efa0d9c5df1c214d3035c73f2226aed8
refs/heads/master
2021-05-10T13:39:22.274374
2016-01-29T00:25:52
2016-01-29T00:25:52
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,174
java
package cz.fi.muni.pa165.travelagency.mvc.forms; import cz.fi.muni.pa165.travelagency.dto.ExcursionDTO; import org.springframework.validation.Errors; import org.springframework.validation.Validator; import java.sql.Date; import java.util.Calendar; /** * * @author Michal Holic */ public class ExcursionDTOValidator implements Validator { @Override public boolean supports(Class<?> clazz) { return ExcursionDTO.class.isAssignableFrom(clazz); } @Override public void validate(Object target, Errors errors) { ExcursionDTO excursionDTO = (ExcursionDTO) target; Date currentDate = new Date(Calendar.getInstance().getTimeInMillis()); if (excursionDTO.getDate() == null) return; if (excursionDTO.getDuration() == null) return; if (excursionDTO.getDuration().toHours() <= 0) { errors.rejectValue("duration", null, "Duration must be at least 1 hour."); } if (excursionDTO.getDestination().equals("")) { errors.rejectValue("destination", null, "Destination can not be empty."); } if (excursionDTO.getDate().compareTo(currentDate) < 0) { errors.rejectValue("dateFrom", null, "It is not possible to add excursion with a past date."); } } }
069376fa6f7cc3702a36fa49f5a6bd110a7895b3
10127943b3a2a0decc609b1f1ab228950b6712f6
/src/model/Teacher.java
75981920c56ae3a978af767a815e2e8da010f52e
[]
no_license
Angel-Avila/Scheduler
14417c83bd3babb75a5b23ead84aafbbd5a0683c
19744f7027a34462b707e1292b5f58ee2a437b14
refs/heads/master
2021-01-17T09:52:04.724520
2016-06-08T19:13:15
2016-06-08T19:13:15
59,080,705
1
0
null
null
null
null
UTF-8
Java
false
false
923
java
package model; public class Teacher { protected String name; protected boolean barco; protected boolean bueno; protected boolean mamon; public Teacher(String name) { this.name = name; } public Teacher(String name, boolean barco, boolean bueno, boolean mamon) { this.name = name; setValues(barco, bueno, mamon); } public void setValues(boolean barco, boolean bueno, boolean mamon) { this.barco = barco; this.bueno = bueno; this.mamon = mamon; } public String getName() { return name; } public void setName(String name) { this.name = name; } public void setBarco(boolean barco) { this.barco = barco; } public void setBueno(boolean bueno) { this.bueno = bueno; } public void setMamon(boolean mamon) { this.mamon = mamon; } public boolean isBarco() { return barco; } public boolean isBueno() { return bueno; } public boolean isMamon() { return mamon; } }
2677a502b54d7b7f1222ebb8ac68cafc020096c1
abdaca2faa043f003ab0a2755d60809cef513dfc
/src/main/java/org/sid/bi/entitie/EstimationPrixDegatParDate.java
9eba33efcaec0ad6461bdd6e5c7b19180618409c
[]
no_license
marwenyounes11/transtu-services
aa1c1280366f8768a3632147dbefd7d781aa4929
893bd333c4f2eaa8a59b660de53864ca250a0fbe
refs/heads/master
2023-04-19T06:51:20.391528
2020-06-05T15:19:58
2020-06-05T15:19:58
269,678,518
0
0
null
2021-04-26T20:21:30
2020-06-05T15:10:04
Java
UTF-8
Java
false
false
1,368
java
package org.sid.bi.entitie; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @Entity public class EstimationPrixDegatParDate { @Id private String id; private int year; private String month; private Long nbrAccident; private Double estimationPrixDegat; public String getId() { return id; } public void setId(String id) { this.id = id; } public int getYear() { return year; } public void setYear(int year) { this.year = year; } public String getMonth() { return month; } public void setMonth(String month) { this.month = month; } public Long getNbrAccident() { return nbrAccident; } public void setNbrAccident(Long nbrAccident) { this.nbrAccident = nbrAccident; } public Double getEstimationPrixDegat() { return estimationPrixDegat; } public void setEstimationPrixDegat(Double estimationPrixDegat) { this.estimationPrixDegat = estimationPrixDegat; } public EstimationPrixDegatParDate() { super(); // TODO Auto-generated constructor stub } public EstimationPrixDegatParDate(String id, int year, String month, Long nbrAccident, Double estimationPrixDegat) { super(); this.id = id; this.year = year; this.month = month; this.nbrAccident = nbrAccident; this.estimationPrixDegat = estimationPrixDegat; } }
cb4702922f3b651f8afe5a1ed26a3c16038a64bd
500aebc798e40a8689865bc51ad1b2e06d01770c
/src/org/kamusi/WordAdder.java
7f120324856ce189411f1277c68e25c710172bd1
[]
no_license
arthurbuliva/kamusidesktop
6234183675af9d30b707255141d1c92bf0c89afc
120899f383c05b66618fbb764510fef90d095dd9
refs/heads/master
2020-05-17T17:14:17.549357
2010-09-13T11:56:56
2010-09-13T11:56:56
32,136,567
0
0
null
null
null
null
UTF-8
Java
false
false
33,709
java
/** * WordAdder.java * Created on Nov 23, 2009, 8:50:26 PM * @author arthur */ package org.kamusi; import javax.swing.ImageIcon; /** * class WordAdder */ public class WordAdder extends javax.swing.JFrame { /** Creates new form WordAdder */ public WordAdder() { initComponents(); setIconImage(new ImageIcon(getClass(). getResource("/org/kamusi/resources/favicon.png")).getImage()); setLocationRelativeTo(null); } /** Creates new form WordAdder * @param text * @param firstToSecond */ public WordAdder(String text, boolean firstToSecond) { initComponents(); setIconImage(new ImageIcon(getClass(). getResource("/org/kamusi/resources/favicon.png")).getImage()); setLocationRelativeTo(null); if (firstToSecond) { englishWord.setText(text); } else { swahiliWord.setText(text); } } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { cancelAddNewWordButton = new javax.swing.JButton(); addNewWordButton = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); engWordLabel = new javax.swing.JLabel(); engHeadwordLabel = new javax.swing.JLabel(); swaWordLabel = new javax.swing.JLabel(); swaHeadwordLabel = new javax.swing.JLabel(); partOfSpeechLabel = new javax.swing.JLabel(); englishWord = new javax.swing.JTextField(); englishHeadword = new javax.swing.JTextField(); swahiliWord = new javax.swing.JTextField(); swahiliHeadword = new javax.swing.JTextField(); classLabel = new javax.swing.JLabel(); partOfSpeechComboBox = new javax.swing.JComboBox(); classComboBox = new javax.swing.JComboBox(); jPanel2 = new javax.swing.JPanel(); engPluLabel = new javax.swing.JLabel(); altEngSingLabel = new javax.swing.JLabel(); altEngPluLabel = new javax.swing.JLabel(); engDefLabel = new javax.swing.JLabel(); derivedLangLabel = new javax.swing.JLabel(); relatedWordLabel = new javax.swing.JLabel(); taxonomyLabel = new javax.swing.JLabel(); engExampleLabel = new javax.swing.JLabel(); swaPluralLabel = new javax.swing.JLabel(); altSwaSingLabel = new javax.swing.JLabel(); altSwaPluLabel = new javax.swing.JLabel(); swaDefLabel = new javax.swing.JLabel(); derivedWordLabel = new javax.swing.JLabel(); noteLabel = new javax.swing.JLabel(); swahiliPlural = new javax.swing.JTextField(); alternateSwahiliSingular = new javax.swing.JTextField(); alternateSwahiliPlural = new javax.swing.JTextField(); swahiliDefinition = new javax.swing.JTextField(); derivedWord = new javax.swing.JTextField(); jScrollPane1 = new javax.swing.JScrollPane(); englishExample = new javax.swing.JTextArea(); jScrollPane2 = new javax.swing.JScrollPane(); swahiliExample = new javax.swing.JTextArea(); taxonomy = new javax.swing.JTextField(); relatedWord = new javax.swing.JTextField(); englishDefinition = new javax.swing.JTextField(); alternateEnglishPlural = new javax.swing.JTextField(); alternateEnglishSingular = new javax.swing.JTextField(); englishPlural = new javax.swing.JTextField(); jScrollPane3 = new javax.swing.JScrollPane(); note = new javax.swing.JTextArea(); dialectLabel = new javax.swing.JLabel(); terminologyLabel = new javax.swing.JLabel(); dialectComboBox = new javax.swing.JComboBox(); terminologyComboBox = new javax.swing.JComboBox(); swaExampleLabel = new javax.swing.JLabel(); derivedLanguageCombo = new javax.swing.JComboBox(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Kamusi Desktop - Word Adder"); setAlwaysOnTop(true); setResizable(false); cancelAddNewWordButton.setMnemonic('C'); cancelAddNewWordButton.setText("Cancel"); cancelAddNewWordButton.setToolTipText("Cancel the addition of a new word"); cancelAddNewWordButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelAddNewWordButtonActionPerformed(evt); } }); addNewWordButton.setMnemonic('A'); addNewWordButton.setText("ADD"); addNewWordButton.setToolTipText("Add the new word to the database"); addNewWordButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addNewWordButtonActionPerformed(evt); } }); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Required Fields")); engWordLabel.setText("Eng Word"); engHeadwordLabel.setText("Eng Headword"); swaWordLabel.setText("Swa Word"); swaHeadwordLabel.setText("Swa Headword"); partOfSpeechLabel.setText("Part Of Speech"); englishWord.setToolTipText("English word"); englishHeadword.setToolTipText("English headword"); swahiliWord.setToolTipText("Swahili word"); swahiliHeadword.setToolTipText("Swahili headword"); classLabel.setText("Class"); partOfSpeechComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "abbreviation", "adj/adv", "adjective", "adverb", "conjuction", "infix", "interjection", "interrogative", "name", "noun", "phrase", "prefix", "preposition", "pronoun", "verb", "verb subject", "verb tense", "verb relative", "verb object", "verb suffix" })); partOfSpeechComboBox.setSelectedIndex(-1); partOfSpeechComboBox.setToolTipText("Select part of speech"); classComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "applicative", "appl-assoc", "appl-assoc-caus", "appl-caus", "appl-caus-intr", "appl-caus-pass", "appl-caus-recip", "appl-caus-refl", "appl-conv", "appl-intr", "appl-inver", "appl-pass", "appl-pass-poten", "appl-poten", "appl-recip", "appl-refl", "associative", "assoc-caus", "assoc-intr", "assoc-inver", "assoc-stat", "auxiliary", "aux-det", "causative", "caus-intr", "caus-inver", "caus-pass", "caus-poten", "caus-recip", "caus-refl", "caus-stat", "caus-trans", "conjugated", "contactive", "converse", "conv-poten", "determinative", "durative", "imperative", "infinitive", "intensive", "intransitive", "intr-inver", "intr-inver-stat", "inversive", "inver-poten-trans", "negative", "passive", "pass-poten", "possessive", "potential", "poten-recip", "poten-trans", "reciprocal", "reflexive", "relative", "stative", "transitive", "1", "1/2", "2", "3", "3/4", "3/4an", "3/10", "4", "5", "5/6", "5/6an", "5/6ca", "6", "6/6", "6an", "7", "7/8", "7/8an", "8", "9", "9/10", "9/10an", "9/10ca", "9an", "10", "11", "11/4", "11/6", "11/6an", "11/8", "11/10", "11/10an", "14", "15", "16", "16/17/18", "17", "18" })); classComboBox.setSelectedIndex(-1); classComboBox.setToolTipText("Select class of word (Noun class, verb type etc.)"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(partOfSpeechLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(partOfSpeechComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 257, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(engHeadwordLabel) .addComponent(engWordLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(englishWord) .addComponent(englishHeadword, javax.swing.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE)))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(swaHeadwordLabel) .addComponent(swaWordLabel) .addComponent(classLabel)) .addGap(6, 6, 6) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(swahiliHeadword, javax.swing.GroupLayout.DEFAULT_SIZE, 305, Short.MAX_VALUE) .addComponent(swahiliWord, javax.swing.GroupLayout.DEFAULT_SIZE, 305, Short.MAX_VALUE) .addComponent(classComboBox, 0, 305, Short.MAX_VALUE)) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(engWordLabel) .addComponent(englishWord, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(swaWordLabel) .addComponent(swahiliWord, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(engHeadwordLabel) .addComponent(englishHeadword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(swaHeadwordLabel) .addComponent(swahiliHeadword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(partOfSpeechLabel) .addComponent(partOfSpeechComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(classLabel) .addComponent(classComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(19, Short.MAX_VALUE)) ); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Optional Fields")); engPluLabel.setText("Eng Plural"); altEngSingLabel.setText("Alt Eng Sing"); altEngPluLabel.setText("Alt Eng Plu"); engDefLabel.setText("Eng Def"); derivedLangLabel.setText("Derived Lang"); relatedWordLabel.setText("Related word"); taxonomyLabel.setText("Taxonomy"); engExampleLabel.setText("Eng Example"); swaPluralLabel.setText("Swa Plural"); altSwaSingLabel.setText("Alt Swa Sing"); altSwaPluLabel.setText("Alt Swa Plu"); swaDefLabel.setText("Swa Def"); derivedWordLabel.setText("Derived Word"); noteLabel.setText("Note"); swahiliPlural.setToolTipText("Swahili plural"); alternateSwahiliSingular.setToolTipText("Alternative Swahili singular word"); alternateSwahiliPlural.setToolTipText("Alternative Swahili plural word"); swahiliDefinition.setToolTipText("Swahili definition"); derivedWord.setToolTipText("Derived word"); englishExample.setColumns(20); englishExample.setLineWrap(true); englishExample.setRows(5); englishExample.setToolTipText("English example"); englishExample.setWrapStyleWord(true); jScrollPane1.setViewportView(englishExample); swahiliExample.setColumns(20); swahiliExample.setLineWrap(true); swahiliExample.setRows(5); swahiliExample.setToolTipText("Swahili Example"); swahiliExample.setWrapStyleWord(true); jScrollPane2.setViewportView(swahiliExample); taxonomy.setToolTipText("Taxonomy"); relatedWord.setToolTipText("Related word"); englishDefinition.setToolTipText("English definition"); alternateEnglishPlural.setToolTipText("Alternative English plural word"); alternateEnglishSingular.setToolTipText("Alternative English singular word"); englishPlural.setToolTipText("English plural word"); note.setColumns(20); note.setLineWrap(true); note.setRows(5); note.setToolTipText("Notes"); note.setWrapStyleWord(true); jScrollPane3.setViewportView(note); dialectLabel.setText("Dialect"); terminologyLabel.setText("Terminology"); dialectComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Kiamu", "Kimvita", "Kipemba", "Kitanga", "Kiunguja", "Sheng", "archaic", "colloquial", "dialectical", "obsolete", "recent" })); dialectComboBox.setSelectedIndex(-1); dialectComboBox.setToolTipText("Select dialect"); terminologyComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "general", "Christian", "IT-klnX", "Islamic", "agriculture", "anatomy", "anthropology", "astronomy", "automotive", "aviation", "biblical", "biology", "botany", "chemistry", "culinary", "economics", "electricity", "enclitic", "entomology", "finance", "games (cards)", "geography", "grammar", "historical", "legal", "linguistics", "literary", "marine", "mathematics", "mechanics", "medical", "meteorology", "military", "minerals", "music", "mythology", "names", "nautical", "optics", "ornithology", "pejorative", "personal", "pharmacy", "phonetics", "photography", "physics", "physiology", "poetic", "political", "polygamy", "psychology", "railway", "religious", "slang", "sport", "technology", "typography", "vulgar", "zoology" })); terminologyComboBox.setToolTipText("Select terminology"); swaExampleLabel.setText("Swa Example"); derivedLanguageCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Afrikaans", "Arabic", "Bantu", "Chinese", "English", "Farsi", "French", "German", "Gujerati", "Hebrew", "Hindi", "Japanese", "Latin", "Luganda", "Malay", "Portuguese", "Russian", "Spanish", "Turkish", "Zulu" })); derivedLanguageCombo.setSelectedIndex(-1); derivedLanguageCombo.setToolTipText("Select derived language"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(engPluLabel) .addComponent(altEngSingLabel) .addComponent(altEngPluLabel) .addComponent(engDefLabel) .addComponent(derivedLangLabel) .addComponent(relatedWordLabel) .addComponent(taxonomyLabel) .addComponent(engExampleLabel) .addComponent(dialectLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(derivedLanguageCombo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(dialectComboBox, 0, 0, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE) .addComponent(taxonomy) .addComponent(relatedWord) .addComponent(englishDefinition) .addComponent(alternateEnglishPlural) .addComponent(alternateEnglishSingular) .addComponent(englishPlural)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(terminologyLabel) .addGap(18, 18, 18) .addComponent(terminologyComboBox, 0, 290, Short.MAX_VALUE)) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(altSwaPluLabel) .addComponent(swaDefLabel) .addComponent(altSwaSingLabel) .addComponent(swaPluralLabel) .addComponent(derivedWordLabel) .addComponent(noteLabel) .addComponent(swaExampleLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE) .addComponent(derivedWord, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE) .addComponent(alternateSwahiliSingular, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE) .addComponent(swahiliDefinition, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE) .addComponent(alternateSwahiliPlural, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE) .addComponent(swahiliPlural, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)))) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(engPluLabel) .addComponent(swaPluralLabel) .addComponent(englishPlural, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(swahiliPlural, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(altEngSingLabel) .addComponent(altSwaSingLabel) .addComponent(alternateEnglishSingular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(alternateSwahiliSingular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(altEngPluLabel) .addComponent(altSwaPluLabel) .addComponent(alternateEnglishPlural, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(alternateSwahiliPlural, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(engDefLabel) .addComponent(swaDefLabel) .addComponent(englishDefinition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(swahiliDefinition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(derivedLangLabel) .addComponent(derivedWordLabel) .addComponent(derivedWord, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(derivedLanguageCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(relatedWordLabel) .addComponent(noteLabel) .addComponent(relatedWord, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(taxonomyLabel) .addComponent(taxonomy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(swaExampleLabel) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE) .addComponent(engExampleLabel))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(dialectLabel) .addComponent(dialectComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(terminologyLabel) .addComponent(terminologyComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(addNewWordButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cancelAddNewWordButton) .addGap(20, 20, 20)))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cancelAddNewWordButton) .addComponent(addNewWordButton)) .addContainerGap()) ); getAccessibleContext().setAccessibleParent(this); pack(); }// </editor-fold>//GEN-END:initComponents private void addNewWordButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_addNewWordButtonActionPerformed {//GEN-HEADEREND:event_addNewWordButtonActionPerformed if (addWord()) { MainWindow.showInfo("Word added successfully!"); dispose(); } else { } }//GEN-LAST:event_addNewWordButtonActionPerformed private void cancelAddNewWordButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_cancelAddNewWordButtonActionPerformed {//GEN-HEADEREND:event_cancelAddNewWordButtonActionPerformed dispose(); }//GEN-LAST:event_cancelAddNewWordButtonActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new WordAdder().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton addNewWordButton; private javax.swing.JLabel altEngPluLabel; private javax.swing.JLabel altEngSingLabel; private javax.swing.JLabel altSwaPluLabel; private javax.swing.JLabel altSwaSingLabel; private javax.swing.JTextField alternateEnglishPlural; private javax.swing.JTextField alternateEnglishSingular; private javax.swing.JTextField alternateSwahiliPlural; private javax.swing.JTextField alternateSwahiliSingular; private javax.swing.JButton cancelAddNewWordButton; private javax.swing.JComboBox classComboBox; private javax.swing.JLabel classLabel; private javax.swing.JLabel derivedLangLabel; private javax.swing.JComboBox derivedLanguageCombo; private javax.swing.JTextField derivedWord; private javax.swing.JLabel derivedWordLabel; private javax.swing.JComboBox dialectComboBox; private javax.swing.JLabel dialectLabel; private javax.swing.JLabel engDefLabel; private javax.swing.JLabel engExampleLabel; private javax.swing.JLabel engHeadwordLabel; private javax.swing.JLabel engPluLabel; private javax.swing.JLabel engWordLabel; private javax.swing.JTextField englishDefinition; private javax.swing.JTextArea englishExample; private javax.swing.JTextField englishHeadword; private javax.swing.JTextField englishPlural; private javax.swing.JTextField englishWord; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JTextArea note; private javax.swing.JLabel noteLabel; private javax.swing.JComboBox partOfSpeechComboBox; private javax.swing.JLabel partOfSpeechLabel; private javax.swing.JTextField relatedWord; private javax.swing.JLabel relatedWordLabel; private javax.swing.JLabel swaDefLabel; private javax.swing.JLabel swaExampleLabel; private javax.swing.JLabel swaHeadwordLabel; private javax.swing.JLabel swaPluralLabel; private javax.swing.JLabel swaWordLabel; private javax.swing.JTextField swahiliDefinition; private javax.swing.JTextArea swahiliExample; private javax.swing.JTextField swahiliHeadword; private javax.swing.JTextField swahiliPlural; private javax.swing.JTextField swahiliWord; private javax.swing.JTextField taxonomy; private javax.swing.JLabel taxonomyLabel; private javax.swing.JComboBox terminologyComboBox; private javax.swing.JLabel terminologyLabel; // End of variables declaration//GEN-END:variables /** * Adds a word to the database * @return true if word was added successfully, false otherwise */ private boolean addWord() { return new Editor().addWord(englishWord.getText().trim(), swahiliWord.getText().trim(), englishHeadword.getText().trim(), swahiliHeadword.getText().trim(), (String) partOfSpeechComboBox.getItemAt(partOfSpeechComboBox.getSelectedIndex()), String.valueOf(classComboBox.getSelectedIndex()), swahiliPlural.getText().trim(), englishPlural.getText().trim(), alternateEnglishSingular.getText().trim(), alternateSwahiliSingular.getText().trim(), alternateEnglishPlural.getText().trim(), alternateSwahiliPlural.getText().trim(), englishDefinition.getText().trim(), swahiliDefinition.getText().trim(), derivedWord.getText().trim(), (String) derivedLanguageCombo.getItemAt(derivedLanguageCombo.getSelectedIndex()), relatedWord.getText().trim(), note.getText().trim(), taxonomy.getText().trim(), englishExample.getText().trim(), swahiliExample.getText().trim(), (String) dialectComboBox.getItemAt(dialectComboBox.getSelectedIndex()), (String) terminologyComboBox.getItemAt(terminologyComboBox.getSelectedIndex())); } }
[ "arthurbuliva@2fbacd0e-6c4d-11de-9a7c-6184c298a20a" ]
arthurbuliva@2fbacd0e-6c4d-11de-9a7c-6184c298a20a
41d9095129dd7c07f0b4711deffa5da8b704d6ae
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/8/8_961f1d41f138e322941295fc8d0438f787745307/PasswordDialogPreference/8_961f1d41f138e322941295fc8d0438f787745307_PasswordDialogPreference_s.java
dfe45d09397f7d595e5aa3d1a580664079813d34
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
1,289
java
package es.ugr.swad.swadroid; import android.content.Context; import android.content.DialogInterface; import android.preference.DialogPreference; import android.util.AttributeSet; import android.view.View; import android.widget.EditText; public class PasswordDialogPreference extends DialogPreference { private EditText mEditTextPassword; public PasswordDialogPreference(Context context, AttributeSet attrs) { super(context, attrs); setPersistent(false); setDialogLayoutResource(R.layout.dialog_password); } @Override protected void onDialogClosed(boolean positiveResult) { super.onDialogClosed(positiveResult); } @Override public void onClick(DialogInterface dialog, int which) { if ( which == DialogInterface.BUTTON_POSITIVE ) { String value = mEditTextPassword.getText().toString(); callChangeListener(value); } super.onClick(dialog, which); } @Override protected void onBindDialogView(View view) { mEditTextPassword = (EditText) view.findViewById(R.id.etpPassword); mEditTextPassword.setText(""); super.onBindDialogView(view); } }
0713422543ae5ae5263cef537166cd8d3aecd347
3ba8f5576fbfccf715dd99442112f9738e4cc11d
/src/app/CacheUpdater.java
b452400195d9c899aa3d8ec517eafe604baed727
[]
no_license
BaronVladziu/Air-Condition-Parser
b865d5db5f8bf158f8b23314c7ff41bbcc02d80e
9f3c3f72126a30a9a9ab3db2354b116492f0b01a
refs/heads/master
2020-04-10T17:39:14.346824
2019-01-04T21:00:32
2019-01-04T21:00:32
161,179,915
0
0
null
null
null
null
UTF-8
Java
false
false
2,703
java
package app; import gios.Sensor; import gios.Station; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.Calendar; /** * Class for downloading data from http://powietrze.gios.gov.pl/pjp/content/api and saving it to cache and updating it from time to time. * @author Bartłomiej Kuśmirek */ public class CacheUpdater { private static final HttpGetter HTTP_GETTER = new HttpGetter(); private static final float updateAfterMinutes = 7*24*60; //seven days in minutes private final Calendar cal = Calendar.getInstance(); /** * Constructor. Creates cache directory. */ public CacheUpdater() { new File("cache").mkdirs(); } /** * Updates stations cache. */ public void updateStationCache() { this.updateFile("cache/station-findAll.txt", "http://api.gios.gov.pl/pjp-api/rest/station/findAll"); } /** * Updates sensors cache for every given station. * @param stations sensors of these stations will be updated */ public void updateSensorCache(Iterable<Station> stations) { for (Station station : stations) { this.updateFile("cache/sensors-" + station.id + ".txt", "http://api.gios.gov.pl/pjp-api/rest/station/sensors/" + station.id); } } /** * Updates data cache for every given sensor. * @param sensors data of these sensors will be updated */ public void updateDataCache(Iterable<Sensor> sensors) { for (Sensor sensor : sensors) { this.updateFile("cache/data-" + sensor.id + ".txt", "http://api.gios.gov.pl/pjp-api/rest/data/getData/" + sensor.id); } } /** * Updates index cache for every given station. * @param stations indices of these stations will be updated */ public void updateIndexCache(Iterable<Station> stations) { for (Station station : stations) { this.updateFile("cache/index-" + station.id + ".txt", "http://api.gios.gov.pl/pjp-api/rest/aqindex/getIndex/" + station.id); } } private void updateFile(String filePath, String url) { if (this.cal.getTimeInMillis() - new File(filePath).lastModified() > updateAfterMinutes * 60000) { try { System.out.println("--- Updating file: " + filePath + " ---"); PrintWriter writer = new PrintWriter(filePath, "UTF-8"); writer.print(HTTP_GETTER.getHTML(url)); writer.close(); } catch (IOException ex) { System.out.println(ex.getMessage()); } catch (Exception ex) { ex.printStackTrace(); } } } }
7ab88a20e3754f155f4e430b915ce8cc0e929d5e
238f71529804f85ae4cc78575d579bd4aeffc3f6
/src/test/resources/expectations/java/testjava/TestIgnoreGenericDto.java
07df38a61bbcd637c54319eac645dd7b863555c2
[]
no_license
Catalysts/cdoclet
c6e2e09234e16c41ba4d670f9b23f269af77a98a
d9f82a6ac6b0179bfd419e2510a6cea3b63b7e92
refs/heads/master
2016-09-06T02:44:31.551496
2015-03-15T21:16:47
2015-03-15T21:16:47
3,842,400
0
0
null
2015-03-18T12:22:54
2012-03-27T10:00:37
Java
UTF-8
Java
false
false
194
java
package testjava; /** * Generated by CDoclet from test.TestIgnoreGeneric. Do not edit. */ public class TestIgnoreGenericDto extends testjava.TestOverrideClass<testjava.TestExceptionDto> { }
a8e055b5694a4f22a15e751869ce5211504f3707
9b618b53d45543e7c06e21d018f7a67ba0ea9068
/src/main/java/job/controller/RabbitController.java
f279894e1c633c43e23cfde553c7a038607a448d
[]
no_license
mzbank/test
1d4b42aa8d719208fd7590fe153d296a09b76185
bba1206e4ab71012217a96743db4afec31693797
refs/heads/master
2020-04-29T11:37:39.743736
2019-03-17T13:53:45
2019-03-17T13:53:45
176,105,339
0
0
null
null
null
null
UTF-8
Java
false
false
517
java
package job.controller; import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @RabbitListener @Controller public class RabbitController { @RequestMapping("/receiveMsg") @ResponseBody @RabbitHandler public void receiveMsg(String content){ } }
6c4471bad71a3da5710747bdedd8566b2d3b21e0
164bf3822046cedb45fea846e8308634b43451b7
/src/main/java/com/jhipster/pustaka/web/rest/vm/ManagedUserVM.java
6d2009668a26e123adcfd61050a743a0858598eb
[]
no_license
ahmarulabdi/e-library
6ccdfc140f8c9571b5c8965681779566f5d89817
ac653027f43a26c08a94c244c5e69c168513489a
refs/heads/master
2022-12-21T07:35:36.439428
2019-10-28T17:47:09
2019-10-28T17:47:09
218,090,255
1
0
null
2022-12-16T04:40:45
2019-10-28T16:08:26
Java
UTF-8
Java
false
false
834
java
package com.jhipster.pustaka.web.rest.vm; import com.jhipster.pustaka.service.dto.UserDTO; import javax.validation.constraints.Size; /** * View Model extending the UserDTO, which is meant to be used in the user management UI. */ public class ManagedUserVM extends UserDTO { public static final int PASSWORD_MIN_LENGTH = 4; public static final int PASSWORD_MAX_LENGTH = 100; @Size(min = PASSWORD_MIN_LENGTH, max = PASSWORD_MAX_LENGTH) private String password; public ManagedUserVM() { // Empty constructor needed for Jackson. } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "ManagedUserVM{" + super.toString() + "} "; } }
69cb127ad3fe282366287909ee4617c828218c2b
439ee2b7a6bb6a377c409c3a1972b6b46d7602a8
/src/main/java/com/onroadrui/vo/ProductVO.java
f07abcc134d3b84d782e8e37e16956f5eca81bef
[]
no_license
ruicom/sell
095bf20d0c97a7d6fcfb5ff9e4fe328d607d05a6
2f16ba642bc60fb317576d6148af270df589ed4f
refs/heads/master
2021-08-15T20:06:50.170886
2017-11-18T07:28:39
2017-11-18T07:28:39
109,576,114
0
0
null
null
null
null
UTF-8
Java
false
false
289
java
package com.onroadrui.vo; import java.util.List; import lombok.Data; /** * Created by onroadrui on 17/11/3. */ @Data public class ProductVO { private String categoryName; private Integer categoryType; private Integer categoryId; private List<ProductVO> foods; }
084d0242cd76e74895e9441056d88a0fabfa4423
a2f80b34ec95cf93fb8d868dfffd2fe0c539c749
/Project1/src/test/java/com/revature/test/WorldMEmploymentTest.java
39ea394d4f203a7f172398245ae9c621e5b87eb4
[]
no_license
1809september24hadoop/gender-statistics-analysis-mkaifesh
a86a62ab0ba9000b78fc9cc8d0a7c232a174d2f8
4b25b60dc46c3dbce67f41aed4f29cdb8771a921
refs/heads/master
2020-04-01T21:55:31.110299
2018-10-28T19:45:27
2018-10-28T19:45:27
153,682,085
0
0
null
null
null
null
UTF-8
Java
false
false
4,880
java
package com.revature.test; import java.util.ArrayList; import java.util.List; import org.apache.hadoop.io.DoubleWritable; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mrunit.mapreduce.MapDriver; import org.apache.hadoop.mrunit.mapreduce.MapReduceDriver; import org.apache.hadoop.mrunit.mapreduce.ReduceDriver; import org.junit.Before; import org.junit.Test; import com.revature.map.WorldMEmploymentMapper; import com.revature.reduce.WorldMEmploymentReducer; public class WorldMEmploymentTest { private MapDriver<LongWritable, Text, Text, DoubleWritable> mapDriver; private ReduceDriver<Text, DoubleWritable, Text, Text> reduceDriver; private MapReduceDriver<LongWritable,Text,Text,DoubleWritable,Text,Text>mapReduceDriver; @Before public void setup(){ mapDriver = new MapDriver<LongWritable, Text, Text, DoubleWritable>(); reduceDriver = new ReduceDriver<Text,DoubleWritable,Text,Text>(); mapReduceDriver = new MapReduceDriver<LongWritable,Text,Text,DoubleWritable,Text,Text>(); WorldMEmploymentMapper mapper = new WorldMEmploymentMapper(); WorldMEmploymentReducer reducer = new WorldMEmploymentReducer(); mapDriver.setMapper(mapper); reduceDriver.setReducer(reducer); mapReduceDriver.setMapper(mapper); mapReduceDriver.setReducer(reducer); } @Test public void TestMapper(){ Text test = new Text("\"Colombia\",\"COL\",\"Employment to population ratio, 15+, male (%) (modeled ILO estimate)\",\"SL.EMP.TOTL.SP.MA.ZS\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"71.5189971923828\",\"72.4240036010742\",\"73.7539978027344\",\"74.1080017089844\",\"74.1350021362305\",\"72.4219970703125\",\"72.8519973754883\",\"71.427001953125\",\"68.5699996948242\",\"68.7149963378906\",\"72.2440032958984\",\"72.1070022583008\",\"73.7539978027344\",\"72.6419982910156\",\"73.7610015869141\",\"71.2760009765625\",\"71.2009963989258\",\"71.6890029907227\",\"72.7289962768555\",\"73.0350036621094\",\"73.5510025024414\",\"73.8850021362305\",\"73.9589996337891\",\"74.197998046875\",\"74.4300003051758\",\"73.8980026245117\","); mapDriver.setInput(new LongWritable(1),test); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(68.7149963378906)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(72.2440032958984)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(72.1070022583008)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(73.7539978027344)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(72.6419982910156)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(73.7610015869141)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(71.2760009765625)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(71.2009963989258)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(71.6890029907227)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(72.7289962768555)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(73.0350036621094)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(73.5510025024414)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(73.8850021362305)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(73.9589996337891)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(74.197998046875)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(74.4300003051758)); mapDriver.withOutput(new Text("Colombia"), new DoubleWritable(73.8980026245117)); mapDriver.runTest(); } @Test public void TestReducer(){ List<DoubleWritable> values = new ArrayList<>(); values.add(new DoubleWritable(10)); values.add(new DoubleWritable(30)); values.add(new DoubleWritable(5)); String expected = "10.00%, 200.00, -83.33, "; reduceDriver.withInput(new Text("Colombia"), values); reduceDriver.addOutput(new Text("Percent Change in Male Employment since 2000: Colombia"),new Text(expected)); reduceDriver.runTest(); } @Test public void TestMapReduce(){ mapReduceDriver.addInput(new LongWritable(1), new Text("\"Colombia\",\"COL\",\"Employment to population ratio, 15+, male (%) (modeled ILO estimate)\",\"SL.EMP.TOTL.SP.MA.ZS\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"10\",\"30\",\"5\",")); String expected = "10.00%, 200.00, -83.33, "; mapReduceDriver.withOutput(new Text("Percent Change in Male Employment since 2000: Colombia"), new Text(expected)); mapReduceDriver.runTest(); } }
e77bf14950a5b8b4cd571d8e0d60580bcaaddf4b
29e8fdbb6d56f6219003b26c4799502c3cdc9253
/annotation/src/main/java/cc/colorcat/kingfisher/annotation/Down.java
706ed712f06ee7ec32f8202c74cf02c7df4f9d4d
[ "Apache-2.0" ]
permissive
ccolorcat/KingFisher
485bf3fd9fc8ca6c4478f2b7034383d25a107687
bcf6f64fa05ec34bf92c564ca34d553603e81d40
refs/heads/master
2021-06-15T09:47:43.326017
2019-12-25T01:57:36
2019-12-25T01:57:36
150,848,887
2
1
null
null
null
null
UTF-8
Java
false
false
970
java
/* * Copyright 2018 cxx * * 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 cc.colorcat.kingfisher.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Author: cxx * Date: 2018-10-10 * GitHub: https://github.com/ccolorcat */ @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.SOURCE) public @interface Down { }
191549cb8067fa72c8b18c7388004d5070fb29ae
ed657210a17ce8fbe1be3f2a32263182987da177
/com.conx.logistics.kernel/com.conx.logistics.kernel.pageflow/pageflow.ui/src/main/java/com/conx/logistics/kernel/pageflow/ui/ext/form/VaadinCollapsiblePhysicalAttributeConfirmActualsFormSectionHeader.java
63fac2090ef6c0d08dab5b911cd13332bcebb55e
[]
no_license
conxgit/conxlogistics-gerrit4
e6b3becee3561899cf283b1cbd88b737de6af0f4
24885e639432ab45082060ca66d0de45d80fdd82
refs/heads/master
2021-03-12T20:12:32.324680
2012-12-18T18:17:00
2012-12-18T18:17:00
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,544
java
package com.conx.logistics.kernel.pageflow.ui.ext.form; import com.conx.logistics.kernel.ui.components.domain.form.PhysicalAttributeConfirmActualsFieldSet; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.ui.Alignment; import com.vaadin.ui.Embedded; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; public class VaadinCollapsiblePhysicalAttributeConfirmActualsFormSectionHeader extends HorizontalLayout { private static final long serialVersionUID = 1010002929298L; private Embedded arrow; private Layout layout; private String caption; private Label label; public VaadinCollapsiblePhysicalAttributeConfirmActualsFormSectionHeader(PhysicalAttributeConfirmActualsFieldSet fieldSet, Layout layout) { this.layout = layout; this.arrow = new Embedded(); this.label = new Label(fieldSet.getCaption()); setWidth("100%"); setHeight("20px"); setStyleName("conx-entity-editor-form-separator"); initialize(); } private void initialize() { this.layout.setVisible(true); HorizontalLayout leftPanel = new HorizontalLayout(); leftPanel.setHeight("25px"); leftPanel.setSpacing(true); arrow.setStyleName("conx-entity-editor-form-separator-arrow"); arrow.addStyleName("conx-entity-editor-form-separator-arrow-expanded"); arrow.setWidth("18px"); arrow.setHeight("10px"); label.setStyleName("conx-entity-editor-form-separator-caption"); label.setHeight("15px"); label.setCaption(caption); leftPanel.addComponent(arrow); leftPanel.addComponent(label); addComponent(leftPanel); setComponentAlignment(leftPanel, Alignment.TOP_LEFT); this.addListener(new LayoutClickListener() { private static final long serialVersionUID = 1L; public void layoutClick(LayoutClickEvent event) { if (isExpanded()) { setExpanded(false); } else { setExpanded(true); } } }); } public Layout getLayout() { return layout; } public void setLayout(Layout layout) { this.layout = layout; } public boolean isExpanded() { return layout.isVisible(); } public void setExpanded(boolean isExpanded) { if (isExpanded) { arrow.addStyleName("conx-entity-editor-form-separator-arrow-expanded"); } else { arrow.removeStyleName("conx-entity-editor-form-separator-arrow-expanded"); } layout.setVisible(isExpanded); } public String getCaption() { return caption; } public void setCaption(String caption) { this.caption = caption; } }
29a1870a6a895ae4fd9d4b4d53a017c4bbf6a874
6e9aae53744c46669dd61fad7cc9e0d633873d3e
/GestioneCorsi/src/it/betacom/milano/businesscomponent/idgenerator/CorsoIdGenerator.java
90ed176b8776f0b3ec2e6e89cd709af7bd118b02
[]
no_license
TurboDeveloper/GestioniCorsi
0db8bcb8a5884494625fa47b32c90272045be04f
5cdada470c5314b8f522604cda93e5603d747995
refs/heads/main
2023-02-16T09:09:20.413460
2021-01-09T17:02:30
2021-01-09T17:02:30
323,290,754
1
0
null
null
null
null
UTF-8
Java
false
false
1,165
java
package it.betacom.milano.businesscomponent.idgenerator; import java.io.IOException; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import it.betacom.milano.architetture.dao.DAOConstants; import it.betacom.milano.architetture.dao.DAOException; import it.betacom.milano.architetture.dao.DBAccess; public class CorsoIdGenerator implements IdGeneratorInterface, DAOConstants { private static CorsoIdGenerator idGenerator; private Connection conn; private Statement stmt; private ResultSet rs; private CorsoIdGenerator() throws DAOException, ClassNotFoundException, IOException { conn = DBAccess.getConnection(); } public static CorsoIdGenerator getInstace() throws DAOException, ClassNotFoundException, IOException { if(idGenerator == null) idGenerator = new CorsoIdGenerator(); return idGenerator; } @Override public long nextId() throws DAOException{ long id = 0; try { stmt = conn.createStatement(); rs = stmt.executeQuery(CORSI_SEQUENCE); rs.next(); id = rs.getLong(1); }catch (SQLException e) { throw new DAOException(e); } return id; } }
[ "Admin@DESKTOP-PLCTU1C" ]
Admin@DESKTOP-PLCTU1C
22a363a291b58c3c0fa7842c55c49bf07ffe4675
a1c5631a08c77201b0f67eab6d5c0435a7778ca0
/stress_tests/src/stressTests/SignUp.java
b0e9a4c32a869ad328ce8012dc7f9980dd6263b4
[]
no_license
hellonoam/8cookies
d38b24d04c3f05c7cbd7a19e49452ada8de080f5
274e62269f340f1e9606f605e6a45b87e2f3c4f4
refs/heads/master
2016-09-03T00:53:02.990147
2011-08-30T11:39:15
2011-08-30T11:39:15
985,199
0
0
null
null
null
null
UTF-8
Java
false
false
1,188
java
package stressTests; import java.io.IOException; import java.io.PrintWriter; import java.util.logging.Logger; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * This servlets accepts signups and send data back that is not expected and not valid to the client * in order to check if it handles it correctely * * @author Noam Szpiro */ @SuppressWarnings("serial") public class SignUp extends HttpServlet { private Logger logger = Logger.getLogger(SignUp.class.getName()); public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("AISDFG@*#&NRC(!@#CR{\"OPP{OIPUHGP'OQI}|{:'>?ASDF:LKASDF"); out.close(); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { logger.finest("inside do post"); doGet(request, response); } }
a1e64c86ab80d90f85b206b170e5449835ccb247
5b243a29a89adb5ea5c186daaf6b2df54b693534
/src/main/java/com/bow/camptotheca/dfs/FailureDetector/Message.java
36aa7997465c0448ce3e5fa36542db86cbb90c9f
[]
no_license
williamxww/camptotheca
3dfbff8e78b1f2db14030cbbaf3ea36ae0a6856c
2d56b510c600ca3f6434e0cf71c870418f92054f
refs/heads/master
2021-01-22T11:12:17.554288
2017-06-07T16:11:33
2017-06-07T16:11:33
92,675,143
0
0
null
null
null
null
UTF-8
Java
false
false
7,320
java
package com.bow.camptotheca.dfs.FailureDetector; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; /** * Class Message */ public class Message { private final char PARAM_DELIM=' '; private final char INFO_DELIM=';'; public final MessageType type; private final String [] messageParams; private List<Info> infoAttached; /** * Fields of Parameters * */ private enum ParamsFields { messageKey (0), senderID (1), destinationID (2); public final int index; ParamsFields(int index) { this.index=index; } } private Message (MessageType type, String [] params) { this.type=type; messageParams=params; infoAttached=new ArrayList<Info>(); } /** Gets bytes from message * @return bytearray of the message */ public byte [] toByteArray() { StringBuilder builder=new StringBuilder(); builder.append(type.getMessagePrefix()); for (String param : messageParams) builder.append(PARAM_DELIM).append(param); for (Info i : infoAttached) { builder.append(INFO_DELIM).append(i.toString()); } byte [] ret = builder.toString().getBytes(); assert ret.length<1024 : "FATAL ERROR ! byte overflow"; return ret; } /** Extract mesage info * @param messageBytes * @param byteLen * @return */ public static Message extractMessage(byte[] messageBytes,int byteLen) { String[] tokens=new String(messageBytes,0,byteLen).split(";"); String[] mStr=tokens[0].split(" "); MessageType type = null; try { type=MessageType.getMessageType(mStr[0].charAt(0)); } catch (IOException e) { e.printStackTrace(); System.exit(0); } String [] params = new String[mStr.length-1]; for (int i=1;i<params.length+1;i++) params[i-1]=mStr[i]; Message ret=new Message(type,params); for (int i=1;i<tokens.length;i++) { try { ret.infoAttached.add(Info.fromString(tokens[i])); } catch (IOException e) { e.printStackTrace(); } } return ret; } /** Helper function * @return Sender PID */ public String getMessageSenderID() { assert messageParams.length>ParamsFields.senderID.index : "This type of message " + "does not have senderID as param"; return messageParams[ParamsFields.senderID.index]; } /** Helper function * @return Message key */ public String getMessageKey() { assert messageParams.length>ParamsFields.messageKey.index : "This type of message " + "does not have senderID as param"; return messageParams[ParamsFields.messageKey.index]; } /** Helper function * @return Destination of message */ public String getReqDestination() { assert messageParams.length>ParamsFields.destinationID.index : "This type of message " + "does not have senderID as param"; return messageParams[ParamsFields.destinationID.index]; } /** Get info from message * @return list of parameters from information */ public List<Info> getInfoList() { return this.infoAttached; } /** * Class for building message * */ public static class MessageBuilder { private Message m; public MessageBuilder(MessageType type, String [] args) { m=new Message(type,args); } /** Construct ping message * @param messageKey * @param senderID * @return */ public static MessageBuilder buildPingMessage(String messageKey,String senderID) { String [] args=new String[2]; args[ParamsFields.messageKey.index]=messageKey; args[ParamsFields.senderID.index]=senderID; MessageBuilder newInstance=new MessageBuilder(MessageType.PING,args); return newInstance; } /** Build ping requqest message * @param messageKey * @param senderID * @param destinationID * @return */ public static MessageBuilder buildPingReqMessage(String messageKey,String senderID,String destinationID) { String [] args=new String[3]; args[ParamsFields.messageKey.index]=messageKey; args[ParamsFields.senderID.index]=senderID; args[ParamsFields.destinationID.index]=destinationID; MessageBuilder newInstance=new MessageBuilder(MessageType.PING_REQUEST,args); return newInstance; } /** Build ping ack request message * @param messageKey * @param senderID * @return */ public static MessageBuilder buildAckReqMessage(String messageKey,String senderID) { String [] args=new String[2]; args[ParamsFields.messageKey.index]=messageKey; args[ParamsFields.senderID.index]=senderID; MessageBuilder newInstance=new MessageBuilder(MessageType.ACK_REQUEST,args); return newInstance; } /** Build Ack message * @param ackID * @return */ public static MessageBuilder buildAckMessage(String ackID) { String [] args=new String[1]; args[ParamsFields.messageKey.index]=ackID; MessageBuilder newInstance=new MessageBuilder(MessageType.ACK,args); return newInstance; } /** Build not in memlist message * @return */ public static MessageBuilder buildMissingNoticeMessage() { String [] args=new String[0]; MessageBuilder newInstance=new MessageBuilder(MessageType.MISSING_NOTICE,args); return newInstance; } /** Message to end reciever * @return */ public static MessageBuilder buildEndNoticeMessage() { String [] args=new String[0]; MessageBuilder newInstance=new MessageBuilder(MessageType.END,args); return newInstance; } /** Build parameter to infolist * @param infos * @return */ public MessageBuilder addInfoFromList(Collection<Info> infos) { for (Info i : infos) { this.m.infoAttached.add(i); } return this; } /** Add join info to info list * @param joinerID * @return */ public MessageBuilder addJoinInfo(String joinerID) { this.m.infoAttached.add(new Info(Info.InfoType.JOIN, joinerID)); return this; } /** Add leave info to info list * @param leaverID * @return */ public MessageBuilder addLeaveInfo(String leaverID) { this.m.infoAttached.add(new Info(Info.InfoType.LEAVE, leaverID)); return this; } /** Get message * @return */ public final Message getMessage() { return m; } } }
a46838cee124d6557d0ca2c0c88efba37b4ff167
67967c30f422f0d34eaffbc4ba516fd07aadb92e
/Projeto1PDM/app/src/main/java/com/app/projeto1_pdm/Menu_principal.java
73b4343e582bceeb9c562afeb117d59716aee7b3
[]
no_license
jvblima11/PDM
0c9d5220fe9702ca583a076a4e72c4093fe096c1
693a02e7cff11265e3a8547e1b877b923cc421c5
refs/heads/main
2023-07-14T10:42:52.493997
2021-08-27T01:15:04
2021-08-27T01:15:04
null
0
0
null
null
null
null
UTF-8
Java
false
false
345
java
package com.app.projeto1_pdm; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; public class Menu_principal extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_menu_principal); } }
7a45573797f80d27e790a42ff8c08f5f2756dc9b
06766182e85024f73fe85bc907b91f66e512e0bc
/associations-java/src/main/java/com/rui/sys/service/LogService.java
c4de0522138500c9c03c3d0892e3c766ca7a90a1
[]
no_license
wrx1613/associations
7c14e3c0e4ae15f7ecd31be6e99ae3c4d11dcf7d
fd4bf5c7acd7993710cbd95b63f2ef81e20bd5c3
refs/heads/master
2023-06-16T12:30:15.690188
2021-07-13T06:39:15
2021-07-13T06:39:15
385,501,268
0
0
null
null
null
null
UTF-8
Java
false
false
448
java
/* package com.rui.sys.service; import com.rui.framework.service.BaseService; import com.rui.sys.dao.DictDao; import com.rui.sys.dao.LogDao; import com.rui.sys.entity.Dict; import com.rui.sys.entity.Log; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @Service @Transactional(readOnly = true) public class LogService extends BaseService<LogDao, Log> { } */
[ "wangrx123" ]
wangrx123
887a0e4446cabe12f5f297b99ff821f331d36ad1
3e19658317c3af798e53308c8a8a79e10f332d89
/src/test/java/com/strive/bazaar/BazaarApplicationTests.java
7275a221d3da838f3266a1eb4aef32812371f670
[]
no_license
baiwenbo/bazaar
06828c915913b6a5b8880029cca282a14272695b
9a32edbc09d37aff6043b2cb7f6b5637a64d5f3f
refs/heads/master
2020-04-01T10:49:20.064922
2018-10-17T16:15:56
2018-10-17T16:15:56
152,719,769
0
0
null
null
null
null
UTF-8
Java
false
false
334
java
package com.strive.bazaar; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest public class BazaarApplicationTests { @Test public void contextLoads() { } }
9f5749ffff31f6fae352996152ea5ee04a5f0b48
7eeeace1aa817f5162b06c79082f1ebb71c1602e
/sirap-common/src/main/java/com/sirap/common/command/explicit/CommandText.java
a120a7bec753abe97ea602e1c1d7fb08edc913d4
[]
no_license
hhhcommon/mas
8516e122686cdf3ea7427cc3faca7a0315eb5421
f5e7ca064cc493e9e9f925b1892062968e950383
refs/heads/master
2020-03-25T22:38:25.963266
2018-07-28T01:45:13
2018-07-28T01:45:13
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,111
java
package com.sirap.common.command.explicit; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import com.sirap.basic.domain.MexObject; import com.sirap.basic.domain.MexTextLine; import com.sirap.basic.search.TextSearcher; import com.sirap.basic.tool.C; import com.sirap.basic.util.Colls; import com.sirap.basic.util.FileUtil; import com.sirap.basic.util.IOUtil; import com.sirap.basic.util.MathUtil; import com.sirap.basic.util.OptionUtil; import com.sirap.common.command.CommandBase; import com.sirap.common.component.FileOpener; import com.sirap.common.domain.TextSearchEngine; import com.sirap.excel.MsExcelHelper; public class CommandText extends CommandBase { //group text search //text file search public boolean handle() { // 1. conduct text search in given text file // 2. print given sheet when it comes to given excel file String[] regexArr = {"(.*?)\\s+(.+)", "(.*?)\\s*,\\s*(.+)"}; String[] filepathAndCriteria = parseFilePathAndCriterias(input, regexArr); if(filepathAndCriteria != null) { String filePath = filepathAndCriteria[0]; String criteria = filepathAndCriteria[1]; if(FileOpener.isTextFile(filePath)) { List<MexObject> all = readFileIntoList(filePath); List<MexObject> items = Colls.filter(all, criteria, isCaseSensitive(), isStayCriteria()); export(Colls.items2PrintRecords(items, options)); return true; } else if(FileUtil.isAnyTypeOf(filePath, FileUtil.SUFFIXES_EXCEL)) { Integer index = MathUtil.toInteger(criteria); if(index == null) { C.pl("try index like 0, 1, 2, 3... with " + filePath); } else { List<List<String>> data = MsExcelHelper.readSheetByIndex(filePath, index); export(data); } return true; } } List<TextSearchEngine> locals = getTextSearchEngines(); for(TextSearchEngine engine:locals) { boolean isMatched = conductTextSearch(engine); if(isMatched) { return true; } } return false; } private List<TextSearchEngine> getTextSearchEngines() { List<TextSearchEngine> engines = new ArrayList<TextSearchEngine>(); List<String> items = g().getUserValuesByKeyword("text.search."); for(String engineInfo : items) { TextSearchEngine se = new TextSearchEngine(); boolean flag = se.parse(engineInfo); if(flag) { engines.add(se); } } return engines; } private boolean conductTextSearch(TextSearchEngine engine) { String regex = engine.getPrefix() + "\\s(.+?)"; String contentCriteria = parseParam(regex); if(contentCriteria != null) { String folders = engine.getFolders(); String fileCriteria = engine.getFileCriteria(); String engineOptions = engine.getOptions(); List<MexTextLine> list = TextSearcher.search(folders, fileCriteria, contentCriteria); String finalOptions = OptionUtil.mergeOptions(options, engineOptions); export(list, finalOptions); return true; } return false; } private String[] parseFilePathAndCriterias(String input, String[] regexArr) { for(int i = 0; i < regexArr.length; i++) { String[] params = parseParams(regexArr[i]); if(params != null) { String sourceName = params[0]; String criteria = params[1]; File file = parseFile(sourceName); if(file == null) { continue; } String filePath = file.getAbsolutePath(); return new String[]{filePath, criteria}; } } return null; } public List<MexObject> readFileIntoList(String fileName) { String cat = IOUtil.charsetOfTextFile(fileName); List<MexObject> list = new ArrayList<>(); try { InputStreamReader isr = new InputStreamReader(new FileInputStream(fileName), cat); BufferedReader br = new BufferedReader(isr); String record = br.readLine(); int line = 0; while (record != null) { line++; MexObject mo = new MexObject(record); mo.setPseudoOrder(line); list.add(mo); record = br.readLine(); } br.close(); } catch (Exception e) { e.printStackTrace(); } return list; } }
7fe8cd28f4fd274b3f2db352049ad0e8a2f2f2c0
9b86f1fb4e1d6e4c6e67c83355b8c218dfdfd1fe
/core/src/sigseg/game/snm/screen/ScreenManager.java
d0382b91c7e20019603f6b3d7ca71d99c21b5bce
[ "Apache-2.0" ]
permissive
johnnylambada/gdx-snm
c3b128885c7cc285ae2ff72ffb6ebd16c83c0c75
3c273c8da8e34921b4a618fbf5926dad8606d4d8
refs/heads/master
2020-05-18T05:18:18.316539
2014-05-03T16:45:58
2014-05-03T16:45:58
null
0
0
null
null
null
null
UTF-8
Java
false
false
359
java
package sigseg.game.snm.screen; public class ScreenManager { private static NullScreen nullScreen = new NullScreen(); private static Screen screen = nullScreen; public static void set(Screen newScreen) { if (screen != nullScreen) screen.dispose(); screen = newScreen; screen.create(); } public static Screen get() { return screen; } }
a7e70f74bd59ff7764635a85ad140fd0e621ec8a
9d644d70b5dbef9974426bfb7d75289804044f81
/src/main/java/com/kamustiago/kamus/services/SmtpEmailService.java
236bdaee392a4fe2fbcd0b84577aa6c5fbad9f82
[ "MIT" ]
permissive
KamusTiago/ProjetoSistemaDePedidos-backEnd2.0
498068ab37941accd34b9a50886ee79685ab8594
44dd70cb7f310a9ac5964d9718f53b03667fd07b
refs/heads/master
2023-03-16T16:16:28.085556
2021-02-26T04:46:39
2021-02-26T04:46:39
333,998,977
0
0
null
null
null
null
UTF-8
Java
false
false
933
java
package com.kamustiago.kamus.services; import javax.mail.internet.MimeMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mail.MailSender; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; public class SmtpEmailService extends AbstractEmailService{ @Autowired private MailSender mailSender; private static final Logger LOG = LoggerFactory.getLogger(SmtpEmailService.class); @Autowired private JavaMailSender javaMailSender; @Override public void sendEmail(SimpleMailMessage msg) { LOG.info("SIMULANDO ENVIO DE EMAIL"); mailSender.send(msg); LOG.info("EMAIL ENVIADO!"); } @Override public void sendHtmlEmail(MimeMessage msg) { LOG.info("SIMULANDO ENVIO DE EMAIL HTML"); javaMailSender.send(msg); LOG.info("EMAIL ENVIADO!"); } }
44eaacbb033457910928eece75bbaf626b939a93
2a1eb866d1409f1752b523711745e416a98a9f03
/fd_websocket/src/main/java/com/example/fd_websocket/SpringWebSocketConfig.java
2cb54b146eacc102c612e9059e04f5736965d143
[]
no_license
geekist/FD_WebSocket
a267a1e6f1fec901f9774b71cb2c2b6a6ba6fd03
ac7c1d5a3840bb97299907821f1ac20e99170a12
refs/heads/main
2023-07-27T16:21:27.259624
2021-09-08T14:52:12
2021-09-08T14:52:12
404,386,435
0
0
null
null
null
null
UTF-8
Java
false
false
1,149
java
package com.example.fd_websocket; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.socket.config.annotation.EnableWebSocket; import org.springframework.web.socket.config.annotation.WebSocketConfigurer; import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; @Configuration @EnableWebSocket public class SpringWebSocketConfig implements WebSocketConfigurer { public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { registry.addHandler(getSpringWebSocketHandler(), "/websocket/server") .addInterceptors(getInterceptor()).setAllowedOrigins("*"); registry.addHandler(getSpringWebSocketHandler(), "/sockjs/server").setAllowedOrigins("*") .addInterceptors(getInterceptor()).withSockJS(); } @Bean public SpringWebSocketHandler getSpringWebSocketHandler() { return new SpringWebSocketHandler(); } @Bean public SpringWebSocketHandlerInterceptor getInterceptor() { return new SpringWebSocketHandlerInterceptor(); } }
217bae8654f2c40b7cd6c533cce7b62e1bcb1696
69fc0618f3db04438c3b3a0cfa6632687fe58a6f
/hims/admical/src/main/java/hims/admical/clinic/cl_level_4/ClLevel4.java
4365d8a678f3bb774dcea1a87173d17582b222de
[]
no_license
yavindu99/hims
21dec658d82ff45ccefebea8480f1b6eabc39c85
914502f02f4f38b69c71e53992e071fdf2dff6eb
refs/heads/master
2022-07-09T16:40:50.033727
2019-12-06T07:15:06
2019-12-06T07:15:06
226,257,244
0
0
null
null
null
null
UTF-8
Java
false
false
3,021
java
package hims.admical.clinic.cl_level_4; import com.fasterxml.jackson.annotation.JsonBackReference; import hims.admical.administrative.department.departmentType.DepartmentType; import hims.admical.clinic.cl_level_3.ClLevel3; import hims.common.Confirmation; import javax.persistence.*; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.util.HashSet; import java.util.Set; @Entity @Table(name = "cl_level_4") public class ClLevel4 { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int l4id; @Column(nullable = false, unique = true) @Size(max = 255, message = "level_4_option_developer_unique_id_exceeds_max_length_of_255") private String duid; @Column(nullable = false, unique = true) @NotNull(message = "level_4_option_name_is_required") @NotEmpty(message = "level_4_option_name_cannot_be_empty") @Size(max = 255, message = "level_4_option_name_exceeds_max_length_of_255") private String name; @Size(max = 255, message = "level_4_option_description_exceeds_max_length_of_255") private String description; @Enumerated(EnumType.STRING) private Confirmation needFreeText = Confirmation.NO; @ManyToOne @JoinColumn(name = "l3id",nullable = false) @JsonBackReference private ClLevel3 clLevel3; @ManyToMany @JoinTable(name = "cl_level4_clinic", joinColumns = {@JoinColumn(name = "l4id")}, inverseJoinColumns = {@JoinColumn(name = "departmentTypeId")}) private Set<DepartmentType> clinicTypeSet = new HashSet<>(); // @Embedded // private CommonFields commonFields; public int getL4id() { return l4id; } public void setL4id(int l4id) { this.l4id = l4id; } public String getDuid() { return duid; } public void setDuid(String duid) { this.duid = duid; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public Confirmation getNeedFreeText() { return needFreeText; } public void setNeedFreeText(Confirmation needFreeText) { this.needFreeText = needFreeText; } public ClLevel3 getClLevel3() { return clLevel3; } public void setClLevel3(ClLevel3 clLevel3) { this.clLevel3 = clLevel3; } public Set<DepartmentType> getClinicTypeSet() { return clinicTypeSet; } public void setClinicTypeSet(Set<DepartmentType> clinicTypeSet) { this.clinicTypeSet = clinicTypeSet; } // public CommonFields getCommonFields() { // return commonFields; // } // // public void setCommonFields(CommonFields commonFields) { // this.commonFields = commonFields; // } }
107d00016d213775854ab563f92f887e6d2ced03
f85cdbd009a860757bc7ea8b3889f227fa5d56c3
/src/main/java/com/auth0/samples/authapi/springbootauthupdated/user/UserController.java
432eedf772da02f4ea999ec9001413cc3bb22098
[]
no_license
CombatLynx/springboot-auth-updated-
c7e8eff1f4100965abe41c6e1cf28ee042d5e65e
d567cf67ee8b7c3a259a03babeb3fc93f6ed5f12
refs/heads/master
2020-04-09T13:36:42.996455
2018-12-04T15:15:29
2018-12-04T15:15:29
160,376,406
0
2
null
null
null
null
UTF-8
Java
false
false
1,110
java
package com.auth0.samples.authapi.springbootauthupdated.user; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/users") public class UserController { private ApplicationUserRepository applicationUserRepository; private BCryptPasswordEncoder bCryptPasswordEncoder; public UserController(ApplicationUserRepository applicationUserRepository, BCryptPasswordEncoder bCryptPasswordEncoder) { this.applicationUserRepository = applicationUserRepository; this.bCryptPasswordEncoder = bCryptPasswordEncoder; } @PostMapping("/sign-up") public void signUp(@RequestBody ApplicationUser user) { user.setPassword(bCryptPasswordEncoder.encode(user.getPassword())); applicationUserRepository.save(user); } }
9173598a6a5ce11fba0dbb7895665b7f7a586f26
c4c2b7eb28abf70178c45f8aa848b02bcaf47d95
/CompleteReference/src/concurrency/utilities/SemaphoreExample.java
84a9045d30d215aa2d352f6f6119016916e19449
[]
no_license
rahul-vishwadhaar/DSA_in_Java
05ff06f9ee2f813215636fb2e0996beab1d79c7a
4758f3c21fd6b430a6aae4016b09d3718c1d6a68
refs/heads/master
2020-04-04T14:18:01.136482
2018-11-03T15:29:07
2018-11-03T15:29:07
155,993,820
0
0
null
null
null
null
UTF-8
Java
false
false
1,828
java
/** * */ package concurrency.utilities; import java.util.concurrent.Semaphore; /** * @author rahul kumar * */ public class SemaphoreExample { /** * @param args */ public static void main(String[] args) { Semaphore sem = new Semaphore(1); SemaphoreExample se = new SemaphoreExample(); se.new IncThread(sem, "A"); se.new DecThread(sem, "B"); } class IncThread implements Runnable { Semaphore sem = null; String name; IncThread(Semaphore sem, String name) { this.name = name; this.sem = sem; new Thread(this).start(); } public void run() { // TODO Auto-generated method stub System.out.println("Starting " + name); try { sem.acquire(); System.out.println(name + " gets permit"); for (int i = 0; i < 5; i++) { Shared.count++; System.out.println(name + Shared.count); Thread.sleep(100); } } catch (InterruptedException ex) { ex.printStackTrace(); } System.out.println(name + " Releasing permit"); sem.release(); } } class DecThread implements Runnable { Semaphore sem; String name; DecThread(Semaphore sem, String name) { this.sem = sem; this.name = name; new Thread(this).start(); } public void run() { System.out.println("Starting " + name); System.out.println(name + " Acquiring lock"); try { sem.acquire(); System.out.println(name + " Lock acquired"); for (int i = 0; i < 5; i++) { Shared.count--; System.out.println(name + Shared.count); Thread.sleep(100); } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println(name + " Releasing permit"); sem.release(); } } }
de2a4f42de9dfc6b7a03d1f11fa670e19ab09827
73b0b9f9e08c18de8ad396758f5afbdac79c304c
/app/src/main/java/com/example/bmicalculator/MainActivity.java
02949a3cb24281677c065c8b46084a8a722b877d
[]
no_license
talejalilov/BMICalculate
d683ec555332abf21ea6cfb9408d1566796eeaf2
6ce5ca290e6c2cdee9dabf62d6394d8ed8f4e455
refs/heads/master
2023-08-04T22:32:57.975459
2021-09-23T10:57:32
2021-09-23T10:57:32
409,554,210
0
0
null
null
null
null
UTF-8
Java
false
false
2,168
java
package com.example.bmicalculator; import androidx.appcompat.app.AppCompatActivity; import android.annotation.SuppressLint; import android.os.Bundle; import android.view.View; import android.widget.Toast; import com.example.bmicalculator.databinding.ActivityMainBinding; public class MainActivity extends AppCompatActivity { private ActivityMainBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = ActivityMainBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); binding.activityMainResultcard.setVisibility(View.GONE); binding.activityMainCalculate.setOnClickListener(view -> { if (binding.activityMainWeightkgs.length() == 0 || binding.activityMainHeightcm.length() == 0) { Toast.makeText(MainActivity.this, "Populate Weight and Height to Calculate BMI", Toast.LENGTH_SHORT).show(); } else { double heightInCms = Double.parseDouble(binding.activityMainHeightcm.getText().toString()); double weightInKgs = Double.parseDouble(binding.activityMainWeightkgs.getText().toString()); double bmi = BMICalcUtil.getInstance().calculateBMIMetric(heightInCms, weightInKgs); displayBMI(bmi); binding.activityMainCalculate.setVisibility(View.INVISIBLE); } }); binding.calculateAgain.setOnClickListener(v -> { binding.activityMainResultcard.setVisibility(View.INVISIBLE); binding.activityMainCalculate.setVisibility(View.VISIBLE); binding.activityMainWeightkgs.setText(""); binding.activityMainHeightcm.setText(""); }); } @SuppressLint("DefaultLocale") private void displayBMI(double bmi) { binding.activityMainResultcard.setVisibility(View.VISIBLE); binding.activityMainBmi.setText(String.format("%.2f", bmi)); String bmiCategory = BMICalcUtil.getInstance().classifyBMI(bmi); binding.activityMainCategory.setText(bmiCategory); } }
d3b513e9cde8ac1c230419c6401d0db7d0129078
8e589910fd161905d8cfd7879a14d51b6cd8d607
/src/main/java/com/cyj/zytjcyj/service/StatisticsService.java
5f958df0174dc866259c25d65c4b70e32107780b
[]
no_license
cuiyijie/zytj-cyj
971c933cf508cbcaca382ec679d0ac9faeacac9a
0c6c6f774ae30fae4907c79639669114de3dd8f8
refs/heads/master
2020-04-08T10:24:39.026084
2018-11-27T03:02:49
2018-11-27T03:02:49
159,267,747
1
0
null
null
null
null
UTF-8
Java
false
false
612
java
package com.cyj.zytjcyj.service; import com.cyj.zytjcyj.entity.StatisticsEntity; import org.apache.ibatis.annotations.Param; import java.util.List; public interface StatisticsService { /*** * 查询刷卡记录每日进行统计 * @return */ List<StatisticsEntity> queryStaticLogs(); /*** * 添加日统计记录 * @param statisticsEntity * @return */ Integer addStaticlogs(StatisticsEntity statisticsEntity); /*** * 查询每月的阅览室的进出人数 * @return */ List<StatisticsEntity> queryChart(@Param("year") String year); }
6c9258535e6b74e1f9d512d3d823fdf23c128f6a
dc6a7bdefdc306cfedcbee00ecd4acbfcb980b61
/quiz/day6/Quiz2.java
befc069e9d0f680744ec8595bb12743e30a2cc60
[]
no_license
Gnanika98/TY_JAVA_ABRIDGE_GNANIKA_FEB24
b116614c19463712b6f6619a2e9f35cb2fc32b07
451dd7251c29599735371c6e0dafbf42e57d599a
refs/heads/master
2021-03-06T13:54:32.328725
2020-03-10T04:45:25
2020-03-10T04:45:25
246,203,921
0
0
null
null
null
null
UTF-8
Java
false
false
485
java
package com.capgemini.quiz.day6; public class Quiz2 { Quiz2() { System.out.println("no argu constructor"); } Quiz2(String s) { System.out.println("parameters constructor"); } } class subClass extends Quiz2 { subClass() { super("HAHAHA"); System.out.println("constructor of Quiz2 with argu"); } void display() { System.out.println("hello"); } public static void main(String[] args) { subClass q = new subClass(); q.display(); } }
24bed8d4af66068ade7c18334c823b7ce6fe4b84
8f2649f5a1caeab05c37423584c9903738e6d90f
/src/main/java/com/bgw/cookbook/adapter/service/ChefDataService.java
7222f1f381f14fce5576c1ca515fd1f81d8b02dc
[]
no_license
bgw7/cookbook
a33249794715d88afc5aedd1dfde3ccc768cbbc1
ad67310e8cf33bf5058d23e6988d93d1b91a7001
refs/heads/master
2020-03-31T11:12:52.196562
2018-10-30T00:30:54
2018-10-30T00:30:54
152,167,764
0
0
null
2018-10-30T00:30:55
2018-10-09T01:14:04
Java
UTF-8
Java
false
false
566
java
package com.bgw.cookbook.adapter.service; import com.bgw.cookbook.domain.chef.Chef; import com.bgw.cookbook.domain.chef.ChefRepository; import com.bgw.cookbook.domain.chef.ChefService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class ChefDataService implements ChefService { @Autowired private ChefRepository repo; public Chef findById(Long id) { return repo.findById(id); } public void updateChef(Chef chef) { repo.updateChef(chef); } }
ffafe0eaffa59f7d55770e6666ddea1c7bedd948
eb687f3abed6f84587ad5eae54cbdd3527fd737e
/test/src/test/AddToCart.java
652a6b823fb462e1b03999252d34d7f07c6895c7
[]
no_license
anik112/Test_project_using_iReport
cb84d3476a3e201b14e4f6251c6efb7cc8b30edc
1143112a1464e85eb18dec2ac074bfe4f51fed92
refs/heads/master
2020-04-23T04:01:42.587331
2019-03-21T10:24:18
2019-03-21T10:24:18
170,896,030
0
0
null
null
null
null
UTF-8
Java
false
false
29,813
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package test; import java.util.Calendar; import java.util.List; import model.Data; import java.util.Set; import javax.swing.table.DefaultTableModel; import model.CartModel; import model.MasterData; /** * * @author anik */ public class AddToCart extends javax.swing.JFrame { private final Calendar calendar = Calendar.getInstance(); private final java.sql.Date processDate = new java.sql.Date(calendar.getTime().getTime()); /** * Creates new form MainFrom */ public AddToCart() { initComponents(); displayAuthorListInBookInfo(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel7 = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jComboBoxProductNumber = new javax.swing.JComboBox<>(); jTextClientNumber = new javax.swing.JTextField(); jTextSubmitDate = new javax.swing.JTextField(); jTextQty = new javax.swing.JTextField(); jBtnsave = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jTableShowData = new javax.swing.JTable(); jPanel2 = new javax.swing.JPanel(); jLabelHeaderTitle = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); jTextDisc = new javax.swing.JTextArea(); jLabel8 = new javax.swing.JLabel(); jBtnAdd = new javax.swing.JButton(); jComboBoxSize = new javax.swing.JComboBox<>(); jLabelShowPrice = new javax.swing.JLabel(); jLabelShowTotal = new javax.swing.JLabel(); jLabelSubTotal = new javax.swing.JLabel(); jLabelDueAmount = new javax.swing.JLabel(); jLabelShowDue = new javax.swing.JLabel(); jLabel7.setText("jLabel7"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Add To Cart"); setAlwaysOnTop(true); setResizable(false); jPanel1.setBackground(new java.awt.Color(0, 153, 0)); jPanel1.setForeground(java.awt.Color.white); jLabel1.setForeground(java.awt.Color.white); jLabel1.setText("Product number:"); jLabel2.setForeground(java.awt.Color.white); jLabel2.setText("Size:"); jLabel3.setForeground(java.awt.Color.white); jLabel3.setText("Qty:"); jLabel4.setForeground(java.awt.Color.white); jLabel4.setText("Disc:"); jLabel6.setForeground(java.awt.Color.white); jLabel6.setText("Client Number:"); jComboBoxProductNumber.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { jComboBoxProductNumberItemStateChanged(evt); } }); jComboBoxProductNumber.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jComboBoxProductNumberMouseClicked(evt); } public void mousePressed(java.awt.event.MouseEvent evt) { jComboBoxProductNumberMousePressed(evt); } }); jComboBoxProductNumber.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBoxProductNumberActionPerformed(evt); } }); jTextSubmitDate.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { jTextSubmitDateFocusLost(evt); } }); jTextQty.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { jTextQtyFocusLost(evt); } }); jBtnsave.setText("SAVE"); jBtnsave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnsaveActionPerformed(evt); } }); jTableShowData.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { }, new String [] { "Product Number", "Size", "Sub-ttl", "Qty", "Price", "Disc", "Due" } )); jTableShowData.getTableHeader().setReorderingAllowed(false); jScrollPane1.setViewportView(jTableShowData); jLabelHeaderTitle.setFont(new java.awt.Font("Ubuntu", 1, 24)); // NOI18N jLabelHeaderTitle.setForeground(new java.awt.Color(97, 155, 39)); jLabelHeaderTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabelHeaderTitle.setText("Bata Shoe Store"); jLabelHeaderTitle.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jLabelHeaderTitle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabelHeaderTitle) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jTextDisc.setColumns(20); jTextDisc.setRows(5); jScrollPane2.setViewportView(jTextDisc); jLabel8.setForeground(java.awt.Color.white); jLabel8.setText("Submit Amount:"); jBtnAdd.setText("ADD"); jBtnAdd.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnAddActionPerformed(evt); } }); jComboBoxSize.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "5", "6", "7", "8", "9", "10", "11", "12" })); jComboBoxSize.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBoxSizeActionPerformed(evt); } }); jLabelShowPrice.setForeground(new java.awt.Color(255, 255, 255)); jLabelShowPrice.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabelShowPrice.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2)); jLabelShowTotal.setForeground(new java.awt.Color(255, 255, 255)); jLabelShowTotal.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabelShowTotal.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2)); jLabelSubTotal.setForeground(new java.awt.Color(255, 255, 255)); jLabelSubTotal.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabelSubTotal.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2)); jLabelDueAmount.setForeground(new java.awt.Color(255, 255, 255)); jLabelDueAmount.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabelDueAmount.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2)); jLabelShowDue.setForeground(new java.awt.Color(255, 255, 255)); jLabelShowDue.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabelShowDue.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2)); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(12, 12, 12) .addComponent(jLabel1)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel6))) .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jTextClientNumber, javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jScrollPane2) .addComponent(jTextSubmitDate) .addComponent(jBtnAdd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jComboBoxSize, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabelShowPrice, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTextQty, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jBtnsave, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabelShowTotal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabelSubTotal, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabelDueAmount, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabelShowDue, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addComponent(jComboBoxProductNumber, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 403, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jComboBoxProductNumber, javax.swing.GroupLayout.DEFAULT_SIZE, 36, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextClientNumber, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(13, 13, 13) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE) .addComponent(jLabelShowPrice, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jComboBoxSize) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jTextQty, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabelSubTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextSubmitDate, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4))) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabelDueAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabelShowTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabelShowDue, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(8, 8, 8))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jBtnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jBtnsave, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addContainerGap()) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jComboBoxProductNumberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxProductNumberActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jComboBoxProductNumberActionPerformed private void jBtnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnAddActionPerformed // TODO add your handling code here: Data data=new Data(); // create data class object MasterData msData=new MasterData(); data.product_number_cart=Integer.parseInt(jComboBoxProductNumber.getSelectedItem().toString()); // set product name data.client_number_cart=Integer.parseInt(jTextClientNumber.getText()); // set product numebr data.size_cart=Integer.parseInt(jComboBoxSize.getSelectedItem().toString()); // set price data.qty_cart=Integer.parseInt(jTextQty.getText()); // set qty data.price_cart=Float.parseFloat(jTextSubmitDate.getText()); data.due_cart=((msData.getFinalPrice(data.product_number_cart) * data.qty_cart)-(Float.parseFloat(jTextSubmitDate.getText()))); data.disc_cart=jTextDisc.getText(); data.sub_title_cart="New Shoe"; data.terminal_number_cart=1; data.submit_by_cart="Anik"; data.submit_date_Cart=processDate; // set current date new CartModel().addData(data); // save data in database showDataIntable(data.client_number_cart); // call method which show data in table. float totalPrice=0; float totalDue=0; DefaultTableModel model= (DefaultTableModel) jTableShowData.getModel(); for(int i=0; i<model.getRowCount(); i++){ totalPrice += Float.parseFloat(model.getValueAt(i, 4).toString()); totalDue += Float.parseFloat(model.getValueAt(i, 6).toString()); } jLabelShowTotal.setText(Float.toString(totalPrice)); jLabelShowDue.setText(Float.toString(totalDue)); }//GEN-LAST:event_jBtnAddActionPerformed private void jBtnsaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnsaveActionPerformed // TODO add your handling code here: Data data=new Data(); // create data class object MasterData msData=new MasterData(); float totalPrice=0; float totalDue=0; int qtt=0; DefaultTableModel model= (DefaultTableModel) jTableShowData.getModel(); for(int i=0; i<model.getRowCount(); i++){ totalPrice += Float.parseFloat(model.getValueAt(i, 4).toString()); qtt += Integer.parseInt(model.getValueAt(i, 3).toString()); totalDue += Float.parseFloat(model.getValueAt(i, 6).toString()); } data.product_number_cart=Integer.parseInt(jComboBoxProductNumber.getSelectedItem().toString()); data.client_number_cart=Integer.parseInt(jTextClientNumber.getText()); // set product numebr data.size_cart=Integer.parseInt(jComboBoxSize.getSelectedItem().toString()); // set price data.qty_cart=qtt; data.price_cart=totalPrice; data.due_cart=totalDue; data.disc_cart=jTextDisc.getText(); data.sub_title_cart="New Shoe"; data.terminal_number_cart=1; data.submit_by_cart="Anik"; data.submit_date_Cart=processDate; // set current date new CartModel().addFinalData(data); // save data in database showDataIntable(data.client_number_cart); // call method which show data in table. clearAllField(); }//GEN-LAST:event_jBtnsaveActionPerformed // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void jComboBoxSizeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxSizeActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jComboBoxSizeActionPerformed private void jComboBoxProductNumberMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jComboBoxProductNumberMouseClicked }//GEN-LAST:event_jComboBoxProductNumberMouseClicked private void jComboBoxProductNumberMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jComboBoxProductNumberMousePressed }//GEN-LAST:event_jComboBoxProductNumberMousePressed // </editor-fold> private void jComboBoxProductNumberItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxProductNumberItemStateChanged // TODO add your handling code here: jLabelShowPrice.setText( Float.toString( new MasterData().getFinalPrice( Integer.parseInt(jComboBoxProductNumber.getSelectedItem().toString()) ) ) ); }//GEN-LAST:event_jComboBoxProductNumberItemStateChanged private void jTextQtyFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextQtyFocusLost // TODO add your handling code here: float subPrice=Float.parseFloat(jLabelShowPrice.getText()); jLabelSubTotal.setText(Float.toString(subPrice * Integer.parseInt(jTextQty.getText()))); }//GEN-LAST:event_jTextQtyFocusLost private void jTextSubmitDateFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextSubmitDateFocusLost // TODO add your handling code here: jLabelDueAmount.setText( Float.toString( Float.parseFloat(jLabelSubTotal.getText()) - Float.parseFloat(jTextSubmitDate.getText()) ) ); }//GEN-LAST:event_jTextSubmitDateFocusLost /** * this method get data from database and set in data in table */ private void showDataIntable(int clientId){ // make list variable and get data from database using getAllProductList() method. List<Data> informationList= new CartModel().getAllCartList(clientId); // get table model from swing table. DefaultTableModel model= (DefaultTableModel) jTableShowData.getModel(); // set table roe count=0. model.setRowCount(0); // make object for add col in table. Object[] row=new Object[7]; // loop for manage list index for(int i=0; i<informationList.size(); i++){ row[0]=informationList.get(i).product_number_cart; // set data in 1st col row[1]=informationList.get(i).size_cart; // set data in 2nd col row[2]=informationList.get(i).sub_title_cart; // set data in 3rd col row[3]=informationList.get(i).qty_cart; row[4]=informationList.get(i).price_cart; row[5]=informationList.get(i).disc_cart; row[6]=informationList.get(i).due_cart; model.addRow(row); // add row in table } } public void displayAuthorListInBookInfo() { MasterData msData = new MasterData(); Set<Integer> productList = msData.productList; productList.forEach((a) -> { jComboBoxProductNumber.addItem(a.toString()); }); } public void clearAllField(){ DefaultTableModel model= (DefaultTableModel) jTableShowData.getModel(); // set table row count=0. model.setRowCount(0); jTextClientNumber.setText(null); jTextDisc.setText(null); jTextQty.setText(null); jTextSubmitDate.setText(null); jLabelShowPrice.setText(null); jLabelShowTotal.setText(null); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Windows".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(AddToCart.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(AddToCart.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(AddToCart.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(AddToCart.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> //</editor-fold> //</editor-fold> //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new AddToCart().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jBtnAdd; private javax.swing.JButton jBtnsave; private javax.swing.JComboBox<String> jComboBoxProductNumber; private javax.swing.JComboBox<String> jComboBoxSize; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabelDueAmount; private javax.swing.JLabel jLabelHeaderTitle; private javax.swing.JLabel jLabelShowDue; private javax.swing.JLabel jLabelShowPrice; private javax.swing.JLabel jLabelShowTotal; private javax.swing.JLabel jLabelSubTotal; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTable jTableShowData; private javax.swing.JTextField jTextClientNumber; private javax.swing.JTextArea jTextDisc; private javax.swing.JTextField jTextQty; private javax.swing.JTextField jTextSubmitDate; // End of variables declaration//GEN-END:variables }
78a440afd9f7f2518b5ff0e138fb11183b521ba9
736fe51a6305809b6bf0d61cdfdf1127d3a1d0b1
/src/model/tactics/atomic/utilities/NamingIntroPattern.java
0388e659ac0fb9b3237f6d08eb75b140ec871274
[ "Apache-2.0" ]
permissive
tizuck/java-coq-astmanip
cf0389baac92371c7ff33968a6051c85403ea23d
d0693a295d0465990fd99e4e91a2eb17f7d19d12
refs/heads/master
2022-11-05T00:07:08.079703
2020-06-22T15:25:30
2020-06-22T15:25:30
274,138,273
0
0
null
2020-06-22T15:25:32
2020-06-22T13:02:14
Java
UTF-8
Java
false
false
1,084
java
package model.tactics.atomic.utilities; import model.term.utilities.Ident; import model.visitor.atomic.IntroPatternVisitor; import java.util.Objects; import java.util.Optional; public class NamingIntroPattern implements IntroPattern { private boolean isQuestionmark; private Optional<Ident> oIdent; public NamingIntroPattern(boolean isQuestionmark, Optional<Ident> oIdent) { this.isQuestionmark = isQuestionmark; this.oIdent = oIdent; } public boolean isQuestionmark() { return isQuestionmark; } public Optional<Ident> getoIdent() { return oIdent; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; NamingIntroPattern that = (NamingIntroPattern) o; return isQuestionmark == that.isQuestionmark && Objects.equals(oIdent, that.oIdent); } @Override public int hashCode() { return Objects.hash(isQuestionmark, oIdent); } @Override public <R, P> R accept(IntroPatternVisitor<R, P> introPatternVisitor, P p) { return introPatternVisitor.visit(this,p); } }
3433ca5e10b0603838ab38a93ce75917887a458c
43c73ff10bdf0be6fbbcbfc286af88896f83255a
/Dequeue.java
d17e84f7dd4d14773e4e015ebeb41afcf27dffc2
[]
no_license
nirvananoob/algorithm-
32687cd349b32ed10072da4854b2b1a4386964e4
9fd231c544b57c71c041debb6b1714dce1b6ed81
refs/heads/master
2021-01-10T05:43:43.448232
2016-03-23T02:24:03
2016-03-23T02:24:03
54,514,374
0
0
null
null
null
null
UTF-8
Java
false
false
2,085
java
package ladder8; import java.util.Stack; public class Dequeue { private Node head, tail; public Dequeue() { // do initialize if necessary head = tail = null; } public void push_front(int item) { // Write your code here if (head == null){ head = new Node(item); tail = head; }else{ Node temp = head; head = new Node(item); head.next = temp; temp .prev = head; } } public void push_back(int item) { // Write your code here // Write your code here if (head == null){ head = new Node(item); tail = head; }else{ Node temp = new Node(item); tail.next = temp; temp .prev = tail; tail = temp; } } public int pop_front() { // Write your code here if (head == null){ return Integer.MIN_VALUE; }else{ Node temp = head; head = head.next; if(head != null){ head.prev = null; }else{ tail = null; } return temp.val; } } public int pop_back() { // Write your code here if (tail == null){ return Integer.MIN_VALUE; } Node temp = tail; tail = tail.prev; if(tail != null){ tail.next = null;} else{ head = null; } return temp.val; } public static void main(String[] args) { Dequeue test = new Dequeue(); test.push_front(1); test.push_back(2); System.out.println(test.pop_back()); System.out.println(test.pop_back()); test.push_back(3); test.push_back(4); System.out.print(test.pop_front()); System.out.print(test.pop_front()); } } class Node { public int val ; public Node next; public Node prev; public Node(int value){ this.val = value; this.prev = this.next = null; } }
d1f038b630958660dea115901777949421300fb5
395105b27e17a0ca03615c0200dd561f4f78c8e8
/taotao-parent/taotao-manager/taotao-manager-service/src/main/java/com/taotao/manager/service/impl/ItemServiceImpl.java
e5db9971b0394eec9a4cc072fe7ec64d3e687e4f
[]
no_license
hjwnb/hjwnb
51825029583ef2e053768a816f4e4ad9cf832628
0dcb68416c258bc4827522884c55671187998ba0
refs/heads/master
2020-03-30T01:10:40.361045
2018-09-27T10:09:46
2018-09-27T10:09:46
150,563,376
0
0
null
null
null
null
UTF-8
Java
false
false
2,168
java
package com.taotao.manager.service.impl; import java.util.UUID; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.taotao.easyui.EasyUIDataGridResult; import com.taotao.exception.ItemListException; import com.taotao.exception.ItemSaveException; import com.taotao.manager.service.ItemService; import com.taotao.mapper.TbItemDescMapper; import com.taotao.mapper.TbItemMapper; import com.taotao.mapper.TbItemParamMapper; import com.taotao.pojo.TbItem; import com.taotao.pojo.TbItemDesc; import com.taotao.pojo.TbItemParam; @Service public class ItemServiceImpl implements ItemService { @Autowired private TbItemMapper itemMapper; @Autowired private TbItemParamMapper itemParamMapper; @Autowired private TbItemDescMapper itemDescMapper; @Override @Transactional(propagation=Propagation.REQUIRED,isolation=Isolation.DEFAULT,rollbackFor=Exception.class) public void save(TbItem item, TbItemParam itemParam, TbItemDesc itemDesc) { // TODO Auto-generated method stub item.setId((long)UUID.randomUUID().hashCode()); itemMapper.insertSelective(item); itemParamMapper.insertSelective(itemParam); itemDesc.setItemId(item.getId()); itemDescMapper.insertSelective(itemDesc); } @Override public EasyUIDataGridResult<TbItem> list(Integer page, Integer rows) { //PageHelper.startPage(page, rows); //List<TbItem> list = itemMapper.selectByExample(null); System.out.println("page="+page+",rows="+rows); PageInfo<TbItem> pageInfo = PageHelper.startPage(page, rows).doSelectPageInfo(()->itemMapper.selectByExample(null)); System.out.println("pageInfo="+pageInfo); EasyUIDataGridResult<TbItem> result = new EasyUIDataGridResult<>(); result.setRows(pageInfo.getList()); result.setTotal(pageInfo.getTotal()); return result; } }
0fe626b7f82a78dde1045b3b3b3c237b6f31e7ec
5d6b3ad627a778575c06850ed8a61dd42d696620
/dbflute-postgresql-example/src/main/java/com/example/dbflute/postgresql/dbflute/bsentity/dbmeta/MemberAddressDbm.java
d5376f7eed658fcd5b91de632ea61d4179a2405a
[ "Apache-2.0" ]
permissive
hajimeni/dbflute-example-database
9246ba7959b33e3b4eb470e9fd3e26aa78d0519a
66b8fdf4fec3a63eb8fce1705e86061c88a216b1
refs/heads/master
2020-12-25T14:33:48.342906
2013-10-10T16:35:24
2013-10-10T16:35:24
null
0
0
null
null
null
null
UTF-8
Java
false
false
18,699
java
package com.example.dbflute.postgresql.dbflute.bsentity.dbmeta; import java.util.List; import java.util.Map; import org.seasar.dbflute.DBDef; import org.seasar.dbflute.Entity; import org.seasar.dbflute.dbmeta.AbstractDBMeta; import org.seasar.dbflute.dbmeta.PropertyGateway; import org.seasar.dbflute.dbmeta.info.*; import org.seasar.dbflute.dbmeta.name.*; import com.example.dbflute.postgresql.dbflute.allcommon.*; import com.example.dbflute.postgresql.dbflute.exentity.*; /** * The DB meta of member_address. (Singleton) * @author DBFlute(AutoGenerator) */ public class MemberAddressDbm extends AbstractDBMeta { // =================================================================================== // Singleton // ========= private static final MemberAddressDbm _instance = new MemberAddressDbm(); private MemberAddressDbm() {} public static MemberAddressDbm getInstance() { return _instance; } // =================================================================================== // Current DBDef // ============= public DBDef getCurrentDBDef() { return DBCurrent.getInstance().currentDBDef(); } // =================================================================================== // Property Gateway // ================ protected final Map<String, PropertyGateway> _epgMap = newHashMap(); { setupEpg(_epgMap, new EpgMemberAddressId(), "memberAddressId"); setupEpg(_epgMap, new EpgMemberId(), "memberId"); setupEpg(_epgMap, new EpgValidBeginDate(), "validBeginDate"); setupEpg(_epgMap, new EpgValidEndDate(), "validEndDate"); setupEpg(_epgMap, new EpgAddress(), "address"); setupEpg(_epgMap, new EpgRegionId(), "regionId"); setupEpg(_epgMap, new EpgRegisterDatetime(), "registerDatetime"); setupEpg(_epgMap, new EpgRegisterProcess(), "registerProcess"); setupEpg(_epgMap, new EpgRegisterUser(), "registerUser"); setupEpg(_epgMap, new EpgUpdateDatetime(), "updateDatetime"); setupEpg(_epgMap, new EpgUpdateProcess(), "updateProcess"); setupEpg(_epgMap, new EpgUpdateUser(), "updateUser"); setupEpg(_epgMap, new EpgVersionNo(), "versionNo"); } public PropertyGateway findPropertyGateway(String propertyName) { return doFindEpg(_epgMap, propertyName); } public static class EpgMemberAddressId implements PropertyGateway { public Object read(Entity e) { return ((MemberAddress)e).getMemberAddressId(); } public void write(Entity e, Object v) { ((MemberAddress)e).setMemberAddressId(cti(v)); } } public static class EpgMemberId implements PropertyGateway { public Object read(Entity e) { return ((MemberAddress)e).getMemberId(); } public void write(Entity e, Object v) { ((MemberAddress)e).setMemberId(cti(v)); } } public static class EpgValidBeginDate implements PropertyGateway { public Object read(Entity e) { return ((MemberAddress)e).getValidBeginDate(); } public void write(Entity e, Object v) { ((MemberAddress)e).setValidBeginDate((java.util.Date)v); } } public static class EpgValidEndDate implements PropertyGateway { public Object read(Entity e) { return ((MemberAddress)e).getValidEndDate(); } public void write(Entity e, Object v) { ((MemberAddress)e).setValidEndDate((java.util.Date)v); } } public static class EpgAddress implements PropertyGateway { public Object read(Entity e) { return ((MemberAddress)e).getAddress(); } public void write(Entity e, Object v) { ((MemberAddress)e).setAddress((String)v); } } public static class EpgRegionId implements PropertyGateway { public Object read(Entity e) { return ((MemberAddress)e).getRegionId(); } public void write(Entity e, Object v) { ((MemberAddress)e).setRegionId(cti(v)); } } public static class EpgRegisterDatetime implements PropertyGateway { public Object read(Entity e) { return ((MemberAddress)e).getRegisterDatetime(); } public void write(Entity e, Object v) { ((MemberAddress)e).setRegisterDatetime((java.sql.Timestamp)v); } } public static class EpgRegisterProcess implements PropertyGateway { public Object read(Entity e) { return ((MemberAddress)e).getRegisterProcess(); } public void write(Entity e, Object v) { ((MemberAddress)e).setRegisterProcess((String)v); } } public static class EpgRegisterUser implements PropertyGateway { public Object read(Entity e) { return ((MemberAddress)e).getRegisterUser(); } public void write(Entity e, Object v) { ((MemberAddress)e).setRegisterUser((String)v); } } public static class EpgUpdateDatetime implements PropertyGateway { public Object read(Entity e) { return ((MemberAddress)e).getUpdateDatetime(); } public void write(Entity e, Object v) { ((MemberAddress)e).setUpdateDatetime((java.sql.Timestamp)v); } } public static class EpgUpdateProcess implements PropertyGateway { public Object read(Entity e) { return ((MemberAddress)e).getUpdateProcess(); } public void write(Entity e, Object v) { ((MemberAddress)e).setUpdateProcess((String)v); } } public static class EpgUpdateUser implements PropertyGateway { public Object read(Entity e) { return ((MemberAddress)e).getUpdateUser(); } public void write(Entity e, Object v) { ((MemberAddress)e).setUpdateUser((String)v); } } public static class EpgVersionNo implements PropertyGateway { public Object read(Entity e) { return ((MemberAddress)e).getVersionNo(); } public void write(Entity e, Object v) { ((MemberAddress)e).setVersionNo(ctl(v)); } } // =================================================================================== // Table Info // ========== protected final String _tableDbName = "member_address"; protected final String _tablePropertyName = "memberAddress"; protected final TableSqlName _tableSqlName = new TableSqlName("member_address", _tableDbName); { _tableSqlName.xacceptFilter(DBFluteConfig.getInstance().getTableSqlNameFilter()); } public String getTableDbName() { return _tableDbName; } public String getTablePropertyName() { return _tablePropertyName; } public TableSqlName getTableSqlName() { return _tableSqlName; } protected final String _tableAlias = "会員住所情報"; public String getTableAlias() { return _tableAlias; } protected final String _tableComment = "会員の住所に関する情報で、同時に有効期間ごとに履歴管理されている。\n会員を基点に考えた場合、構造的にはone-to-many だが、業務的な定型条件でone-to-one になる。このような構造を「業務的one-to-one」と呼ぶ。\n有効期間は隙間なく埋められるが、ここでは住所情報のない会員も存在し、厳密には(業務的な) \"1 : 0...1\" である。"; public String getTableComment() { return _tableComment; } // =================================================================================== // Column Info // =========== protected final ColumnInfo _columnMemberAddressId = cci("member_address_id", "member_address_id", null, "会員住所ID", true, "memberAddressId", Integer.class, true, true, "serial", 10, 0, "nextval('member_address_member_address_id_seq'::regclass)", false, null, "会員住所を識別するID。\n履歴分も含むテーブルなので、これ自体はFKではない。", null, null, null); protected final ColumnInfo _columnMemberId = cci("member_id", "member_id", null, "会員ID", true, "memberId", Integer.class, false, false, "int4", 10, 0, null, false, null, "会員を参照するID。\n履歴分を含むため、これだけではユニークにはならない。\n有効開始日と合わせて複合ユニーク制約となるが、\n厳密には完全な制約にはなっていない。\n有効期間の概念はRDBでは表現しきれないのである。", "member", null, null); protected final ColumnInfo _columnValidBeginDate = cci("valid_begin_date", "valid_begin_date", null, "有効開始日", true, "validBeginDate", java.util.Date.class, false, false, "date", 13, 0, null, false, null, "一つの有効期間の開始を示す日付。\n前の有効終了日の次の日の値が格納される。", null, null, null); protected final ColumnInfo _columnValidEndDate = cci("valid_end_date", "valid_end_date", null, "有効終了日", true, "validEndDate", java.util.Date.class, false, false, "date", 13, 0, null, false, null, "有効期間の終了日。\n次の有効開始日の一日前の値が格納される。\nただし、次の有効期間がない場合は 9999/12/31 となる。", null, null, null); protected final ColumnInfo _columnAddress = cci("address", "address", null, "住所", true, "address", String.class, false, false, "varchar", 200, 0, null, false, null, "まるごと住所", null, null, null); protected final ColumnInfo _columnRegionId = cci("region_id", "region_id", null, "地域ID", true, "regionId", Integer.class, false, false, "int4", 10, 0, null, false, null, "地域を参照するID。\nここでは特に住所の内容と連動しているわけではない。\n(業務的one-to-oneの親テーブルの表現したかっ...)", "region", null, null); protected final ColumnInfo _columnRegisterDatetime = cci("register_datetime", "register_datetime", null, null, true, "registerDatetime", java.sql.Timestamp.class, false, false, "timestamp", 26, 3, null, true, null, null, null, null, null); protected final ColumnInfo _columnRegisterProcess = cci("register_process", "register_process", null, null, true, "registerProcess", String.class, false, false, "varchar", 200, 0, null, true, null, null, null, null, null); protected final ColumnInfo _columnRegisterUser = cci("register_user", "register_user", null, null, true, "registerUser", String.class, false, false, "varchar", 200, 0, null, true, null, null, null, null, null); protected final ColumnInfo _columnUpdateDatetime = cci("update_datetime", "update_datetime", null, null, true, "updateDatetime", java.sql.Timestamp.class, false, false, "timestamp", 26, 3, null, true, null, null, null, null, null); protected final ColumnInfo _columnUpdateProcess = cci("update_process", "update_process", null, null, true, "updateProcess", String.class, false, false, "varchar", 200, 0, null, true, null, null, null, null, null); protected final ColumnInfo _columnUpdateUser = cci("update_user", "update_user", null, null, true, "updateUser", String.class, false, false, "varchar", 200, 0, null, true, null, null, null, null, null); protected final ColumnInfo _columnVersionNo = cci("version_no", "version_no", null, null, true, "versionNo", Long.class, false, false, "int8", 19, 0, null, false, OptimisticLockType.VERSION_NO, null, null, null, null); public ColumnInfo columnMemberAddressId() { return _columnMemberAddressId; } public ColumnInfo columnMemberId() { return _columnMemberId; } public ColumnInfo columnValidBeginDate() { return _columnValidBeginDate; } public ColumnInfo columnValidEndDate() { return _columnValidEndDate; } public ColumnInfo columnAddress() { return _columnAddress; } public ColumnInfo columnRegionId() { return _columnRegionId; } public ColumnInfo columnRegisterDatetime() { return _columnRegisterDatetime; } public ColumnInfo columnRegisterProcess() { return _columnRegisterProcess; } public ColumnInfo columnRegisterUser() { return _columnRegisterUser; } public ColumnInfo columnUpdateDatetime() { return _columnUpdateDatetime; } public ColumnInfo columnUpdateProcess() { return _columnUpdateProcess; } public ColumnInfo columnUpdateUser() { return _columnUpdateUser; } public ColumnInfo columnVersionNo() { return _columnVersionNo; } protected List<ColumnInfo> ccil() { List<ColumnInfo> ls = newArrayList(); ls.add(columnMemberAddressId()); ls.add(columnMemberId()); ls.add(columnValidBeginDate()); ls.add(columnValidEndDate()); ls.add(columnAddress()); ls.add(columnRegionId()); ls.add(columnRegisterDatetime()); ls.add(columnRegisterProcess()); ls.add(columnRegisterUser()); ls.add(columnUpdateDatetime()); ls.add(columnUpdateProcess()); ls.add(columnUpdateUser()); ls.add(columnVersionNo()); return ls; } { initializeInformationResource(); } // =================================================================================== // Unique Info // =========== // ----------------------------------------------------- // Primary Element // --------------- protected UniqueInfo cpui() { return hpcpui(columnMemberAddressId()); } public boolean hasPrimaryKey() { return true; } public boolean hasCompoundPrimaryKey() { return false; } // =================================================================================== // Relation Info // ============= // ----------------------------------------------------- // Foreign Property // ---------------- public ForeignInfo foreignMember() { Map<ColumnInfo, ColumnInfo> map = newLinkedHashMap(columnMemberId(), MemberDbm.getInstance().columnMemberId()); return cfi("fk_member_address_member", "member", this, MemberDbm.getInstance(), map, 0, false, false, false, false, null, null, false, "memberAddressList"); } public ForeignInfo foreignRegion() { Map<ColumnInfo, ColumnInfo> map = newLinkedHashMap(columnRegionId(), RegionDbm.getInstance().columnRegionId()); return cfi("fk_member_address_region", "region", this, RegionDbm.getInstance(), map, 1, false, false, false, false, null, null, false, "memberAddressList"); } // ----------------------------------------------------- // Referrer Property // ----------------- // =================================================================================== // Various Info // ============ public boolean hasSequence() { return true; } public String getSequenceName() { return "member_address_member_address_id_seq"; } public Integer getSequenceIncrementSize() { return 1; } public Integer getSequenceCacheSize() { return null; } public boolean hasVersionNo() { return true; } public ColumnInfo getVersionNoColumnInfo() { return _columnVersionNo; } public boolean hasCommonColumn() { return true; } public List<ColumnInfo> getCommonColumnInfoList() { return newArrayList(columnRegisterDatetime(), columnRegisterUser(), columnRegisterProcess(), columnUpdateDatetime(), columnUpdateUser(), columnUpdateProcess()); } public List<ColumnInfo> getCommonColumnInfoBeforeInsertList() { return newArrayList(columnRegisterDatetime(), columnRegisterUser(), columnRegisterProcess(), columnUpdateDatetime(), columnUpdateUser(), columnUpdateProcess()); } public List<ColumnInfo> getCommonColumnInfoBeforeUpdateList() { return newArrayList(columnUpdateDatetime(), columnUpdateUser(), columnUpdateProcess()); } // =================================================================================== // Type Name // ========= public String getEntityTypeName() { return "com.example.dbflute.postgresql.dbflute.exentity.MemberAddress"; } public String getConditionBeanTypeName() { return "com.example.dbflute.postgresql.dbflute.cbean.MemberAddressCB"; } public String getBehaviorTypeName() { return "com.example.dbflute.postgresql.dbflute.exbhv.MemberAddressBhv"; } // =================================================================================== // Object Type // =========== public Class<MemberAddress> getEntityType() { return MemberAddress.class; } // =================================================================================== // Object Instance // =============== public Entity newEntity() { return newMyEntity(); } public MemberAddress newMyEntity() { return new MemberAddress(); } // =================================================================================== // Map Communication // ================= public void acceptPrimaryKeyMap(Entity e, Map<String, ? extends Object> m) { doAcceptPrimaryKeyMap((MemberAddress)e, m); } public void acceptAllColumnMap(Entity e, Map<String, ? extends Object> m) { doAcceptAllColumnMap((MemberAddress)e, m); } public Map<String, Object> extractPrimaryKeyMap(Entity e) { return doExtractPrimaryKeyMap(e); } public Map<String, Object> extractAllColumnMap(Entity e) { return doExtractAllColumnMap(e); } }
00520398cfbd6f902752a18fe78fd8b4a0776873
534b9b6e17a8a55c7e2056a0719468cd87ae3d14
/lab-ioc/src/main/java/pl/edu/agh/school/Mark.java
de5a452d02d2cf8db8c6e68008987be54766aa9f
[]
no_license
jakubsolecki/TO
ba7eb7d61ba6b1bfbfbf533bfb1b5f45404f1555
8bc280bd44c05fdb87218f9d7e666e274113f637
refs/heads/main
2023-02-20T19:34:23.881931
2021-01-27T23:01:57
2021-01-27T23:01:57
307,323,059
0
0
null
null
null
null
UTF-8
Java
false
false
516
java
package pl.edu.agh.school; import java.io.Serializable; public class Mark implements Serializable { private static final long serialVersionUID = -8070625969786768937L; private final MarkValue value; private final Person student; public Mark(MarkValue value, Person student) { this.value = value; this.student = student; } public MarkValue getValue() { return value; } public Person getStudent() { return student; } }
13937da1a76e330d2decb274b748f0e7371158f2
475e0470f782b5aff59ba5f0a4e60013bd58ca16
/myBookStoreServelet/src/com/myBookStore/model/Order.java
0b396186d4c3c271037d2a980b01df15fd280ca4
[]
no_license
zackszhu/SE223-WebApp
d0b5eea03ccc4ff8b9540a02f833a970a8f39bdf
358fea9775e7c9d752951a9b80735350b8dfe5db
refs/heads/master
2016-09-06T03:10:36.796517
2015-07-14T09:38:04
2015-07-14T09:38:04
39,066,374
0
0
null
null
null
null
UTF-8
Java
false
false
561
java
package com.myBookStore.model; /** * Created by zacks on 15-5-9. */ public class Order { private String bookName; private String username; private String createTime; public Order(String _bookName, String _username, String _createTime) { bookName = _bookName; username = _username; createTime = _createTime; } public String getUsername() { return username; } public String getCreateTime() { return createTime; } public String getBookName() { return bookName; } }
834650665d7b83ffdee614faa3e21f9c22f4b805
79d7e5c3d96652a941c5d288a87ef4e845fcb8ae
/Edge.java
ac1b5480787a44d83b61ddfe7431e9f91272dfe3
[]
no_license
Kecheng-Ye/Shortest-Path
6676402b8b052199890130d1ffd4c986874117cc
8934c8dfefb128b921f17f9963dc6c98f676221d
refs/heads/master
2020-08-03T22:22:59.858158
2019-09-30T16:26:13
2019-09-30T16:26:13
211,903,990
0
0
null
null
null
null
UTF-8
Java
false
false
707
java
public class Edge<T> { // cited from https://codereview.stackexchange.com/questions/67970/graph-implementation-in-java-8; private Node<T> node1; private Node<T> node2; private double weight; public Edge(Node<T> node1, Node<T> node2, double weight) { this.node1 = node1; this.node2 = node2; this.weight = weight; } public double weight() { return weight; } public Node<T> fromNode() { return node1; } public Node<T> toNode() { return node2; } public boolean isBetween(Node<T> node1, Node<T> node2) { return (this.node1 == node1 && this.node2 == node2); } }
343b010f64a5445539b1a10bc86b40186bd02455
385c229c2bfc9d492f35b46e8e6b506ccc7baa6e
/JavaExercises/src/oopsConcept/Employee.java
bf2de678d9fdb054ee142626f941ed4a3ccedb12
[]
no_license
Manjula-h/JavaExercises
1bbe0707fbaf25fcc42bb76553f3e060194df4a0
cf50342fdfb01ae37b5033181ab973714dafd2c8
refs/heads/master
2023-02-24T17:01:47.061193
2021-01-23T11:06:07
2021-01-23T11:06:07
332,192,015
0
0
null
null
null
null
UTF-8
Java
false
false
260
java
package oopsConcept; public class Employee { int id; String name; float salary; void insert(int i, String n, float s) { id = i; name = n; salary = s; } void display() { System.out.println(id + " " + name + " " + salary); } }
[ "admin@Kushi-PC" ]
admin@Kushi-PC
991b278b706a4be6a9ec2a311274dbbe0d80e9ba
6b0a4d6d0f49d739b0261efe02f92ad3e3233e75
/src/main/java/br/com/ezequieljuliano/argos/business/UsuarioEventoBC.java
fe37e3580f308e21f507af1b29e1f6537f2553e3
[]
no_license
robsonperassoli/argos
5a38b89369cba8993fd430e621d47ef7ce2f1947
583d5d4eaad36f3aefd0d230e126da9d808b4f93
refs/heads/master
2020-12-25T07:22:39.473243
2013-07-18T23:29:22
2013-07-18T23:29:22
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,287
java
/* * Copyright 2012 Ezequiel Juliano Müller. * * 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 br.com.ezequieljuliano.argos.business; import br.com.ezequieljuliano.argos.domain.UsuarioEvento; import br.com.ezequieljuliano.argos.persistence.UsuarioEventoDAO; import br.gov.frameworkdemoiselle.stereotype.BusinessController; /** * * @author Ezequiel Juliano Müller */ @BusinessController public class UsuarioEventoBC extends GenericBC<UsuarioEvento, String, UsuarioEventoDAO> { private static final long serialVersionUID = 1L; public void saveOrUpdate(UsuarioEvento usuarioEvento) { if (usuarioEvento.getId() == null) { getDAO().insert(usuarioEvento); } else { getDAO().save(usuarioEvento); } } }
5fd41ea16b9066f0018c1a3ee20bc35c90473b54
3c755381525456ab2de49b49bd1aa2d7656d3fbb
/Var3.java
ac5a603d9ebeb3cf6245d11e2598d3be36f30e18
[]
no_license
williamhc99/Grade-11-Coursework
f7fbb0d984076b1092b34b6eed462bbd433cb0e1
7fd21d3e992a157af6ea26f3f59d6a3fbe93dd61
refs/heads/master
2021-05-08T17:50:15.650773
2018-01-30T05:17:00
2018-01-30T05:17:00
119,486,336
0
0
null
null
null
null
UTF-8
Java
false
false
521
java
import java.util.Scanner; /* * Name:William Chen * Date:Sept 18 2015 * Variable Exercies 3 */ class Var3 { public static void main(String args[]) { Scanner myScanner = new Scanner(System.in); String name; int age; System.out.println("Enter your name: "); name = myScanner.nextLine(); System.out.println("Enter your age: "); age = myScanner.nextInt(); System.out.println("You are " + name); System.out.println("You are " + age); } }
def7f6c9cb07ab61037cbae8f2ca10f8c40cb44f
0a137019e44fabc6fe1041f208f17e7c2ff93b32
/app/src/main/java/me/rubl/loftcoin/ui/currency/CurrencyAdapter.java
97be0f942d2f1132cc25545d0e3c578aa4010621
[]
no_license
rbln1/LoftCoin
6314a4fb3ae1572efde7dfa52796fbd353443df8
622467b7f88d2e0fbac3a813df1ee1bb2341a0b0
refs/heads/master
2022-09-15T05:17:52.021703
2020-05-30T07:53:16
2020-05-30T07:53:16
260,687,980
0
0
null
2020-05-30T07:53:18
2020-05-02T13:01:47
Java
UTF-8
Java
false
false
2,137
java
package me.rubl.loftcoin.ui.currency; import android.view.LayoutInflater; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.ListAdapter; import androidx.recyclerview.widget.RecyclerView; import java.util.Objects; import me.rubl.loftcoin.data.Currency; import me.rubl.loftcoin.databinding.ItemCurrencyBinding; public class CurrencyAdapter extends ListAdapter<Currency, CurrencyAdapter.ViewHolder> { private LayoutInflater inflater; CurrencyAdapter() { super(new DiffUtil.ItemCallback<Currency>() { @Override public boolean areItemsTheSame(@NonNull Currency oldItem, @NonNull Currency newItem) { return Objects.equals(oldItem, newItem); } @Override public boolean areContentsTheSame(@NonNull Currency oldItem, @NonNull Currency newItem) { return Objects.equals(oldItem, newItem); } }); } @Override public Currency getItem(int position) { return super.getItem(position); } @NonNull @Override public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return new ViewHolder(ItemCurrencyBinding.inflate(inflater, parent, false)); } @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { final Currency currency = getItem(position); holder.binding.itemCurrencyName.setText(String.format("%s | %s", currency.name(), currency.code())); holder.binding.itemCurrencySymbol.setText(currency.symbol()); } @Override public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) { super.onAttachedToRecyclerView(recyclerView); inflater = LayoutInflater.from(recyclerView.getContext()); } static class ViewHolder extends RecyclerView.ViewHolder { ItemCurrencyBinding binding; ViewHolder(@NonNull ItemCurrencyBinding binding) { super(binding.getRoot()); this.binding = binding; } } }
dd87d8ac98d8e8eae5ff7d5704939f00ac90745b
f82802d169ac9c751163b90db4d8c5a74636e89e
/Week5-DevOpsHibernate/1901HibernateDemo/src/main/java/com/revature/dao/CatDaoImpl.java
0539abcc82cbadf6896855f2fabbf652b9a71e0f
[]
no_license
1901-Jan14-Spark/batch-source
5b0a93dc4b13c65cd0cea600a2a0db81f263aaf6
7f80c649d218f0cef4d54531faaa1d7fbfa89ecc
refs/heads/Carolyn_Rehm
2020-04-16T16:01:00.115055
2019-04-05T21:10:56
2019-04-05T21:10:56
165,722,073
1
4
null
2019-04-13T14:00:50
2019-01-14T19:31:36
Java
UTF-8
Java
false
false
2,342
java
package com.revature.dao; import java.util.List; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.Transaction; import com.revature.beans.Cat; import com.revature.util.HibernateUtil; public class CatDaoImpl implements CatDao{ @Override public Integer insertCat(Cat c) { Session session = HibernateUtil.getSession(); //connect to db Transaction tx = null; Integer id = null; try { tx = session.beginTransaction(); //open the transaction block id = (Integer) session.save(c); //this is where the object becomes // persistent tx.commit(); // finalize the insert }catch(HibernateException e) { e.printStackTrace(); tx.rollback(); }finally { session.close(); } return id; } @Override public List<Cat> selectAllCats() { Session session = HibernateUtil.getSession(); List<Cat> cats = null; try { cats = session.createQuery("From Cat").list(); }catch(HibernateException e) { e.printStackTrace(); }finally { session.close(); } return cats; } @Override public Cat selectCatById(Integer id) { Session session = HibernateUtil.getSession(); Cat cat = null; //this object is transient try { cat = (Cat)session.get(Cat.class, id); // here the //object is persistent }catch(HibernateException e) { e.printStackTrace(); }finally { session.close(); //here the object is detached } return cat; } @Override public void updateCat(Cat change) { Session session = HibernateUtil.getSession(); Transaction tx = null; Cat cat = null; try { tx = session.beginTransaction(); cat = (Cat)session.get(Cat.class, change.getId()); if(change.getName() != null) { cat.setName(change.getName()); } if(change.getColor() != null) { cat.setColor(change.getColor()); } session.save(cat); tx.commit(); }catch(HibernateException e){ e.printStackTrace(); tx.rollback(); }finally { session.close(); } } public void deleteCatById(Integer id){ Session session = HibernateUtil.getSession(); Transaction tx = null; try{ tx = session.beginTransaction(); session.delete(session.get(Cat.class, id)); tx.commit(); }catch(HibernateException e){ e.printStackTrace(); tx.rollback(); }finally{ session.close(); } } }
dbea08030389b4ac0d01568db5faf26acf2d7411
725dac10e2e5abf3ee34e935f2c05838bfc2c56d
/src/prototypePattern/ShapeChache.java
147136a4a5c7180342167eeb867203982441ac41
[]
no_license
ShiningPho3nix/DesignPattern
61e91d441d75930d8fca463178bdfdb22d068421
431e4bec8d1c37c6670d10804c79b69fe2080cbe
refs/heads/master
2020-04-26T05:46:23.989512
2019-03-01T19:21:07
2019-03-01T19:21:07
173,343,784
0
0
null
null
null
null
UTF-8
Java
false
false
1,279
java
package prototypePattern; import java.util.Hashtable; /** * This pattern involves implementing a prototype interface which tells to * create a clone of the current object. This pattern is used when creation of * object directly is costly. For example, an object is to be created after a * costly database operation. We can cache the object, returns its clone on next * request and update the database as and when needed thus reducing database * calls. * * We're going to create an abstract class Shape and concrete classes extending * the Shape class. A class ShapeCache is defined as a next step which stores * shape objects in a Hashtable and returns their clone when requested. * * @author Steffen Dworsky * */ public class ShapeChache { private static Hashtable<String, Shape> shapeMap = new Hashtable<>(); public static Shape getShape(String shapeId) { Shape cachedShape = shapeMap.get(shapeId); return cachedShape.clone(); } public static void loadCache() { Circle circle = new Circle("1"); shapeMap.put(circle.getId(), circle); Square square = new Square("2"); shapeMap.put(square.getId(), square); Rectangle rectangle = new Rectangle("3"); shapeMap.put(rectangle.getId(), rectangle); } }
f233e06703863719c8527aa54d5de312963704b5
172dfe2a9bc8a0d68057ea68bae25530f9b31e4f
/app/src/test/java/com/example/android/latihan_sqlite/ExampleUnitTest.java
066c1bed786b126705b8b48aa9d893aa95682853
[]
no_license
baziyad48/TUGAS_PAPBL_1
70ac4e50097184b81b38efdbb4a64a4746b7fd7c
8f6a2631312afaa258b76f123e3339ca61e6f0db
refs/heads/master
2021-01-03T07:03:14.699345
2020-02-12T09:31:55
2020-02-12T09:31:55
239,971,806
0
0
null
null
null
null
UTF-8
Java
false
false
395
java
package com.example.android.latihan_sqlite; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ public class ExampleUnitTest { @Test public void addition_isCorrect() { assertEquals(4, 2 + 2); } }
af83eff249abebd7797b713681fc1ab6bb02bb53
d4b4697439379b3dc597f670ba524727dda8a4bc
/HackerRank/src/com/problemsolving/NewYearChaos.java
5854c6237e5d476f7c13b67f466c50fc8129d126
[]
no_license
tonmoysaha/ProblemSolvingWithHakerRankWithJava
b588ef290d250ff85aac8399854b4d954539d753
6ad5bdc76a50730f4bce2c1cf8b44e46085ed8f3
refs/heads/master
2022-03-04T23:26:05.623918
2022-02-17T04:01:59
2022-02-17T04:01:59
235,951,867
0
0
null
null
null
null
UTF-8
Java
false
false
490
java
package com.problemsolving; import java.util.Scanner; public class NewYearChaos { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int t = scanner.nextInt(); for (int tItr = 0; tItr < t; tItr++) { int n = scanner.nextInt(); int[] q = new int[n]; for (int i = 0; i < n; i++) { int qItem = i; q[i] = qItem; } minimumBribes(q); } scanner.close(); } static void minimumBribes(int[] q) { } }
75b2086fced4a9b9383206a35e0a7f4c997b16e6
04dca5b268ddf31e9faa61fc6282a747b28ee78f
/20180119-OOP/src/org/campus02/accounts/DemoApp.java
5eccfe31068fd66d8cc21ee3ed1dc0b4e5978c10
[]
no_license
Herb0610/PR1
41a38bdea19971b3cb8f3f4573f6addfe25b5637
0e7a14193b45f8808f47f5886b8a6cd04903032a
refs/heads/master
2021-05-10T21:32:06.683507
2018-01-20T08:48:21
2018-01-20T08:48:21
null
0
0
null
null
null
null
ISO-8859-1
Java
false
false
847
java
package org.campus02.accounts; public class DemoApp { public static void main(String[] args) { Konto k = new Konto("Max"); k.einzahlen(1000); k.auszahlen(800); System.out.println(k.getKontostand()); System.out.println("Test von Girokonto"); GiroKonto g = new GiroKonto("Susi", 1000); g.auszahlen(250); System.out.println("Giro:" + g.getKontostand()); g.auszahlen(800); System.out.println("Giro:" + g.getKontostand()); System.out.println("Test von Jugendkonto"); Konto jk = new JugendGiroKonto("junger max", 1000, 50); jk.auszahlen(40); jk.auszahlen(200); System.out.println("JK: " + jk.getKontostand()); System.out.println("Sparkonto"); Konto sparKonto = new SparKonto("fleißiger max"); sparKonto.einzahlen(1000); sparKonto.auszahlen(1001); System.out.println(sparKonto.getKontostand()); } }
85a613e85c6df6da6bcc507afa255651da55a8dd
41afa4d75ddab7d2da807a439c3794a013d446b1
/src/main/java/com/arpnetworking/commons/java/util/function/package-info.java
0dbfc0623c64f33ca9384dcfbc447fc23ef2587b
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
ArpNetworking/commons
5402a3e88ce1a2d6a00f06984ba0b759ab20874f
f8690cc63b13762991ad275a1c8eb1c01f035ac0
refs/heads/master
2023-08-30T00:26:16.764419
2023-08-28T17:45:03
2023-08-28T17:45:03
48,400,797
1
2
Apache-2.0
2023-09-11T14:48:18
2015-12-22T00:07:24
Java
UTF-8
Java
false
false
864
java
/* * Copyright 2017 Inscope Metrics, 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. */ @ParametersAreNonnullByDefault @ReturnValuesAreNonnullByDefault package com.arpnetworking.commons.java.util.function; import com.arpnetworking.commons.javax.annotation.ReturnValuesAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
36169c8a9430a0a25a2361b8bada75b78cef9dd8
5483f5a64b7cf780ed1a4575e37472f9023785d3
/src/main/java/com/wangfan/springboot/jpa/config/RedisConfig.java
c339bc140de3d6954b013916ddcc9c1fd3234cd6
[]
no_license
ChrisFynnWang/springboot-jpa
4fd6ab2bb3e8e15c6e2304c3307d1be41f7b4172
cb2d3b66770a93418865e2535b4f6843722c4ea7
refs/heads/master
2020-05-14T05:07:38.693110
2019-04-16T15:55:45
2019-04-16T15:55:45
181,699,909
0
0
null
null
null
null
UTF-8
Java
false
false
1,867
java
package com.wangfan.springboot.jpa.config; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; /** * @Author: Chris Wang * @Description: * @Url: * @Params: * @Return: * @Date:2019/4/16 * @Other: */ @Configuration public class RedisConfig { @Value("${spring.redis.host}") private String host; @Value("${spring.redis.port}") private int port; @Value("${spring.redis.timeout}") private int timeout; @Bean public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) { StringRedisTemplate template = new StringRedisTemplate(factory); setSerializer(template);//设置序列化工具 template.setEnableTransactionSupport(true); template.afterPropertiesSet(); return template; } private void setSerializer(StringRedisTemplate template) { Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer( Object.class); ObjectMapper om = new ObjectMapper(); om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); jackson2JsonRedisSerializer.setObjectMapper(om); template.setValueSerializer(jackson2JsonRedisSerializer); } }
063e10ac0aa54a9b0f0d3c351ffca86dfd01c976
d4506724ba8a4f2ae64b999d9e6631c7a149b45c
/src/main/java/yd/swig/SWIGTYPE_p_uid_t.java
37616c9bfc881f034b3e205c80cc46b13c6a50c8
[]
no_license
ydaniels/frida-java
6dc70b327ae8e8a6d808a0969e861225dcc0192b
cf3c198b2a4b7c7a3a186359b5c8c768deacb285
refs/heads/master
2022-12-08T21:28:27.176045
2019-10-24T09:51:44
2019-10-24T09:51:44
214,268,850
2
1
null
2022-11-25T19:46:38
2019-10-10T19:30:26
Java
UTF-8
Java
false
false
737
java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package yd.swig; public class SWIGTYPE_p_uid_t { private transient long swigCPtr; protected SWIGTYPE_p_uid_t(long cPtr, @SuppressWarnings("unused") boolean futureUse) { swigCPtr = cPtr; } protected SWIGTYPE_p_uid_t() { swigCPtr = 0; } protected static long getCPtr(SWIGTYPE_p_uid_t obj) { return (obj == null) ? 0 : obj.swigCPtr; } }
19e0f3a14624bcd1c3c96649fa182710983b5a1d
01cc0a43565c3e63f3fac92de171b91d0f037436
/eureka/eureka-client/src/main/java/com/netflix/discovery/converters/JsonXStream.java
5956392241e044099b6ae4b838fd2616d882357d
[ "Apache-2.0" ]
permissive
TarantulaTechnology/netflixoss-recipes-rss-with-components
502db1d2f7aca1fb0f0522b44b24e8ad5a187fdf
3174b585ba82d36b0fe522b5a01f7d9a1ed2cf0a
refs/heads/master
2016-09-01T21:16:55.596534
2013-09-15T02:07:06
2013-09-15T02:07:06
12,836,345
1
1
null
null
null
null
UTF-8
Java
false
false
2,300
java
/* * Copyright 2012 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.discovery.converters; import com.netflix.appinfo.InstanceInfo; import com.netflix.discovery.shared.Application; import com.netflix.discovery.shared.Applications; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; import com.thoughtworks.xstream.io.naming.NameCoder; import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder; /** * An <tt>Xstream</tt> specific implementation for serializing and deserializing * to/from JSON format. * * <p> * This class also allows configuration of custom serializers with Xstream. * </p> * * @author Karthik Ranganathan * */ public class JsonXStream extends XStream { private final static JsonXStream s_instance = new JsonXStream(); public JsonXStream() { super(new JettisonMappedXmlDriver() { private final NameCoder coder = new XmlFriendlyNameCoder(); protected NameCoder getNameCoder() { return this.coder; } }); registerConverter(new Converters.ApplicationConverter()); registerConverter(new Converters.ApplicationsConverter()); registerConverter(new Converters.DataCenterInfoConverter()); registerConverter(new Converters.InstanceInfoConverter()); registerConverter(new Converters.LeaseInfoConverter()); registerConverter(new Converters.MetadataConverter()); setMode(XStream.NO_REFERENCES); processAnnotations(new Class[] { InstanceInfo.class, Application.class, Applications.class }); } public static JsonXStream getInstance() { return s_instance; } }
b3a072e4dd04fa37ef691825d93cdd391b2cdf05
9180fe5ff0556b061d0d51c16ec2429cf9130842
/SistemaChurrasco/src/view/JCadCarne.java
37a57e270795a8f5c5757efcdbcac6672129d473
[ "MIT" ]
permissive
LudovicCeita/Sist.-Churrascaria
8578926676ef004ba450287f8fc508d0bc50ea00
037d5b3067900ae476114cf2ba34d7c91bc22951
refs/heads/master
2021-01-11T14:56:53.743165
2017-01-28T01:02:37
2017-01-28T01:02:37
80,258,452
0
0
null
null
null
null
UTF-8
Java
false
false
23,378
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package view; import fontedados.FabricaEntityManager; import java.awt.EventQueue; import java.beans.Beans; import java.util.ArrayList; import java.util.List; import javax.persistence.RollbackException; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JPanel; /** * * @author Notorius B.I.G */ public class JCadCarne extends JPanel { public JCadCarne() { initComponents(); if (!Beans.isDesignTime()) { entityManager.getTransaction().begin(); } } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { bindingGroup = new org.jdesktop.beansbinding.BindingGroup(); entityManager = FabricaEntityManager.getEntityManagerFactory().createEntityManager(); query = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT c FROM Carne c"); list = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList()); masterScrollPane = new javax.swing.JScrollPane(); masterTable = new javax.swing.JTable(); jPanel1 = new javax.swing.JPanel(); nomeLabel = new javax.swing.JLabel(); descricaoField = new javax.swing.JTextField(); precoField = new javax.swing.JTextField(); precoLabel = new javax.swing.JLabel(); idcarneField = new javax.swing.JTextField(); nomeField = new javax.swing.JTextField(); descricaoLabel = new javax.swing.JLabel(); idcarneLabel = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); saveButton = new javax.swing.JButton(); refreshButton = new javax.swing.JButton(); newButton = new javax.swing.JButton(); deleteButton = new javax.swing.JButton(); jPanel3 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); FormListener formListener = new FormListener(); org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, list, masterTable); org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${idcarne}")); columnBinding.setColumnName("Idcarne"); columnBinding.setColumnClass(Integer.class); columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${nome}")); columnBinding.setColumnName("Nome"); columnBinding.setColumnClass(String.class); columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${descricao}")); columnBinding.setColumnName("Descricao"); columnBinding.setColumnClass(String.class); columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${preco}")); columnBinding.setColumnName("Preco"); columnBinding.setColumnClass(java.math.BigDecimal.class); bindingGroup.addBinding(jTableBinding); masterScrollPane.setViewportView(masterTable); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados da Carne")); nomeLabel.setText("Nome:"); org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.descricao}"), descricaoField, org.jdesktop.beansbinding.BeanProperty.create("text")); binding.setSourceUnreadableValue("null"); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), descricaoField, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.preco}"), precoField, org.jdesktop.beansbinding.BeanProperty.create("text")); binding.setSourceUnreadableValue("null"); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), precoField, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); precoLabel.setText("Preco:"); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.idcarne}"), idcarneField, org.jdesktop.beansbinding.BeanProperty.create("text")); binding.setSourceUnreadableValue("null"); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), idcarneField, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.nome}"), nomeField, org.jdesktop.beansbinding.BeanProperty.create("text")); binding.setSourceUnreadableValue("null"); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), nomeField, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); descricaoLabel.setText("Descricao:"); idcarneLabel.setText("Idcarne:"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(idcarneLabel) .addComponent(nomeLabel) .addComponent(descricaoLabel) .addComponent(precoLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(descricaoField, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(nomeField, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(idcarneField, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(precoField, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(idcarneLabel) .addComponent(idcarneField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(nomeLabel) .addComponent(nomeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(descricaoLabel) .addComponent(descricaoField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(precoLabel) .addComponent(precoField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder()); saveButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Png/salvar_carne.png"))); // NOI18N saveButton.setToolTipText("Salvar"); saveButton.addActionListener(formListener); refreshButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Png/cancel_carne.png"))); // NOI18N refreshButton.setToolTipText("Cancelar"); refreshButton.addActionListener(formListener); newButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Png/add_carne.png"))); // NOI18N newButton.setToolTipText("Inserir"); newButton.addActionListener(formListener); deleteButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Png/delete_carne.png"))); // NOI18N deleteButton.setToolTipText("Delete"); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), deleteButton, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); deleteButton.addActionListener(formListener); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(refreshButton, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(saveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(deleteButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(newButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(newButton) .addGap(18, 18, 18) .addComponent(deleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(14, 14, 14) .addComponent(refreshButton, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(saveButton) .addContainerGap()) ); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Png/carne.png"))); // NOI18N jLabel2.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N jLabel2.setText("Cadastrar Carne"); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1) .addGap(18, 18, 18) .addComponent(jLabel2) .addContainerGap()) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1)) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(jLabel2))) .addContainerGap()) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(184, 184, 184)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(masterScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addGap(43, 43, 43)))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(24, 24, 24) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(masterScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(95, Short.MAX_VALUE)) ); bindingGroup.bind(); } // Code for dispatching events from components to event handlers. private class FormListener implements java.awt.event.ActionListener { FormListener() {} public void actionPerformed(java.awt.event.ActionEvent evt) { if (evt.getSource() == saveButton) { JCadCarne.this.saveButtonActionPerformed(evt); } else if (evt.getSource() == refreshButton) { JCadCarne.this.refreshButtonActionPerformed(evt); } else if (evt.getSource() == newButton) { JCadCarne.this.newButtonActionPerformed(evt); } else if (evt.getSource() == deleteButton) { JCadCarne.this.deleteButtonActionPerformed(evt); } } }// </editor-fold>//GEN-END:initComponents @SuppressWarnings("unchecked") private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshButtonActionPerformed entityManager.getTransaction().rollback(); entityManager.getTransaction().begin(); java.util.Collection data = query.getResultList(); for (Object entity : data) { entityManager.refresh(entity); } list.clear(); list.addAll(data); }//GEN-LAST:event_refreshButtonActionPerformed private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed int[] selected = masterTable.getSelectedRows(); List<model.Carne> toRemove = new ArrayList<model.Carne>(selected.length); for (int idx = 0; idx < selected.length; idx++) { model.Carne c = list.get(masterTable.convertRowIndexToModel(selected[idx])); toRemove.add(c); entityManager.remove(c); } list.removeAll(toRemove); }//GEN-LAST:event_deleteButtonActionPerformed private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed model.Carne c = new model.Carne(); entityManager.persist(c); list.add(c); int row = list.size() - 1; masterTable.setRowSelectionInterval(row, row); masterTable.scrollRectToVisible(masterTable.getCellRect(row, 0, true)); }//GEN-LAST:event_newButtonActionPerformed private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed try { entityManager.getTransaction().commit(); entityManager.getTransaction().begin(); } catch (RollbackException rex) { rex.printStackTrace(); entityManager.getTransaction().begin(); List<model.Carne> merged = new ArrayList<model.Carne>(list.size()); for (model.Carne c : list) { merged.add(entityManager.merge(c)); } list.clear(); list.addAll(merged); } }//GEN-LAST:event_saveButtonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton deleteButton; private javax.swing.JTextField descricaoField; private javax.swing.JLabel descricaoLabel; private javax.persistence.EntityManager entityManager; private javax.swing.JTextField idcarneField; private javax.swing.JLabel idcarneLabel; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private java.util.List<model.Carne> list; private javax.swing.JScrollPane masterScrollPane; private javax.swing.JTable masterTable; private javax.swing.JButton newButton; private javax.swing.JTextField nomeField; private javax.swing.JLabel nomeLabel; private javax.swing.JTextField precoField; private javax.swing.JLabel precoLabel; private javax.persistence.Query query; private javax.swing.JButton refreshButton; private javax.swing.JButton saveButton; private org.jdesktop.beansbinding.BindingGroup bindingGroup; // End of variables declaration//GEN-END:variables public static void main(String[] args) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(JCadCarne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(JCadCarne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(JCadCarne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(JCadCarne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ EventQueue.invokeLater(new Runnable() { public void run() { JDialog frame = new JDialog(new JFrame(), true); frame.setContentPane(new JCadCarne()); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } }
a063635e6906c9efe049f20a1e2841073417b389
ed2e408de3e118ab0c5135c4acefbe2ff3f1ccd3
/chapter1-2/src/main/java/com/hl/springbootdemo1/pattern/proxy/AdminService.java
21dbbf20a1cfd6946e0e78ca008fb72b5c8f3a3b
[ "Apache-2.0" ]
permissive
binglongworld/springboot-demo
93a6fd4b167570a6530627546e440da2228b2081
80f74576349e3299dc758b79a7e16823dfcdba58
refs/heads/master
2023-04-08T13:44:01.437196
2021-04-22T01:06:16
2021-04-22T01:06:16
357,899,929
1
0
null
null
null
null
UTF-8
Java
false
false
152
java
package com.hl.springbootdemo1.pattern.proxy; /** * 静态代理 */ public interface AdminService { void update(); Object find(); }
e766b916997609f72b2b3287bfc972b44dcd9350
208de73e8f64702d8df11d699fbb0477f5a19583
/Radiant_App/Java/GenericActivity.java
5042bcc59e7c4eff8cd99f5d8450ce65a2fa4c41
[]
no_license
trent-evans/portfolio
4ec110f3111ac2cfb48f7db960a081d399f32d9b
e2f6bf3363e7b4bb3fe9957401568c8286637324
refs/heads/master
2021-11-23T20:45:55.863209
2021-11-07T22:41:34
2021-11-07T22:41:34
210,508,788
0
0
null
null
null
null
UTF-8
Java
false
false
4,032
java
package com.example.knight_radiant_app; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.view.View; public class GenericActivity extends AppCompatActivity { public static Bitmap profilepic; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_generic); Intent intentData = getIntent(); String fragmentFlag = intentData.getStringExtra("flag"); if(fragmentFlag.equals("profile")){ String username = intentData.getStringExtra("username"); Bundle dataToProfileFrag = new Bundle(); dataToProfileFrag.putString("username",username); Fragment profileFrag = new ProfileFragment(); profileFrag.setArguments(dataToProfileFrag); FragmentTransaction fTrans = getSupportFragmentManager().beginTransaction(); fTrans.replace(R.id.genericFragmentPlaceholder, profileFrag).commit(); }else if(fragmentFlag.equals("bmi")){ String username = intentData.getStringExtra("username"); Bundle dataToBMIFrag = new Bundle(); dataToBMIFrag.putString("username",username); Fragment bmiFrag = new BMIFragment(); bmiFrag.setArguments(dataToBMIFrag); FragmentTransaction fTrans = getSupportFragmentManager().beginTransaction(); fTrans.replace(R.id.genericFragmentPlaceholder,bmiFrag).commit(); }else if(fragmentFlag.equals("calorie")){ String username = intentData.getStringExtra("username"); Bundle sendToCalorieFrag = new Bundle(); sendToCalorieFrag.putString("username",username); Fragment calorieFrag = new CalorieFragment(); calorieFrag.setArguments(sendToCalorieFrag); FragmentTransaction fTrans = getSupportFragmentManager().beginTransaction(); fTrans.replace(R.id.genericFragmentPlaceholder,calorieFrag).commit(); }else if(fragmentFlag.equals("hike")){ String hikeData = intentData.getStringExtra("hikeData"); Bundle sendHikeInfo = new Bundle(); sendHikeInfo.putString("hikeData",hikeData); Fragment hikeFragment = new HikeFragment(); hikeFragment.setArguments(sendHikeInfo); FragmentTransaction fTrans = getSupportFragmentManager().beginTransaction(); fTrans.replace(R.id.genericFragmentPlaceholder,hikeFragment).commit(); }else if(fragmentFlag.equals("weather")){ String weatherData = intentData.getStringExtra("weatherData"); Bundle toWeatherFrag = new Bundle(); toWeatherFrag.putString("weatherData",weatherData); Fragment fragment = new WeatherFragment(); fragment.setArguments(toWeatherFrag); FragmentTransaction fTrans = getSupportFragmentManager().beginTransaction(); fTrans.replace(R.id.genericFragmentPlaceholder,fragment).commit(); }else if(fragmentFlag.equals("new_user")){ Fragment newUserFrag = new NewUserFragment(); FragmentTransaction fTrans = getSupportFragmentManager().beginTransaction(); fTrans.replace(R.id.genericFragmentPlaceholder,newUserFrag).commit(); }else if(fragmentFlag.equals("step")){ String user = intentData.getStringExtra("name"); Bundle sendStepInfo = new Bundle(); sendStepInfo.putString("name",user); Fragment newStepFrag = new StepFragment(); FragmentTransaction fTrans = getSupportFragmentManager().beginTransaction(); fTrans.replace(R.id.genericFragmentPlaceholder,newStepFrag).commit(); } } @Override public void onBackPressed(){ finish(); } }
f5be27ae02f0b8a5e133ee1bdae49a37c2f9ad66
50c3c314b34a44ac9727b41adc731efa08e3c1d5
/End/src/main/java/Methods/Customer_functions.java
ebfb0820813403a663f61ee0de7eb7a1920c2562
[]
no_license
Tazhimurat/EndTerm
f153cd604dac908b9f7054182a63db48449e8bfc
6578203cb4ccbd14123ace6cc0dd0abb2fd10f4e
refs/heads/main
2023-03-14T13:36:59.633049
2021-03-07T15:51:47
2021-03-07T15:51:47
345,387,030
0
0
null
null
null
null
UTF-8
Java
false
false
5,235
java
package Methods; import Entities.Customers; import Entities.Customer; import PostgresDB.IDB; import java.sql.Connection; import java.sql.SQLException; import java.sql.*; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import Entities.Category; public class Customer_functions implements Customers { private final IDB db; public Customer_functions(IDB db){ this.db=db; } @Override public Customer getAddMoney(Double money,String ID) { Connection con=null; try{ con=db.getConnection(); Customer customer= new Customer(); System.out.println("Available money:"+getCustomer(ID).getMoney()); PreparedStatement st = con.prepareStatement("UPDATE customer set customer_availablemoney =customer_availablemoney+? where customer_id=?;"); st.setDouble(1, money); st.setString(2,ID); st.executeUpdate(); System.out.println("Money now:"+ getCustomer(ID).getMoney()); }catch(SQLException throwables){ throwables.printStackTrace(); }catch (ClassNotFoundException e){ e.printStackTrace(); }finally { try { con.close(); } catch (SQLException throwables) { throwables.printStackTrace(); } } return null; } @Override public List<Customer> getAllCustomers() { Connection con=null; try{ con=db.getConnection(); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("Select*from customer;"); List<Customer> customers = new LinkedList<>(); while(rs.next()){ Customer customer= new Customer(rs.getString("customer_id"),rs.getString("customer_name"),rs.getString("customer_surname"), rs.getString("customer_dateofbirth"),rs.getString("gender"),rs.getString("customer_country"),rs.getString("customer_region"), rs.getString("customer_city"),rs.getString("customer_phone"),rs.getString("customer_email"),rs.getString("customer_occupancy"), rs.getString("customer_agegroup"),rs.getDouble("customer_availablemoney")); customers.add(customer); } return customers; } catch (SQLException throwables){ throwables.printStackTrace(); } catch (ClassNotFoundException e){ e.printStackTrace();} finally { try { con.close(); } catch (SQLException throwables) { throwables.printStackTrace(); } } return null; } @Override public Customer getCustomer(String ID) { Connection con = null; try { con = db.getConnection(); String sql = "SELECT * FROM customer WHERE customer_id=?"; PreparedStatement st = con.prepareStatement(sql); st.setString(1, ID); ResultSet rs = st.executeQuery(); if (rs.next()) { Customer customer= new Customer(rs.getString("customer_id"),rs.getString("customer_name"),rs.getString("customer_surname"), rs.getString("customer_dateofbirth"),rs.getString("gender"),rs.getString("customer_country"),rs.getString("customer_region"), rs.getString("customer_city"),rs.getString("customer_phone"),rs.getString("customer_email"),rs.getString("customer_occupancy"), rs.getString("customer_agegroup"),rs.getDouble("customer_availablemoney")); return customer; } } catch (SQLException throwables) { throwables.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } finally { try { con.close(); } catch (SQLException throwables) { throwables.printStackTrace(); } } return null; } @Override public ArrayList<Category> getInterestingproductanalyzer() { Connection con = null; try { ArrayList<Category>categories=new ArrayList<>(); con = db.getConnection(); String sql = "select order_name from order_item Group by order_name order by count(order_name) desc limit 3; "; PreparedStatement st = con.prepareStatement(sql); ResultSet rs = st.executeQuery(); while (rs.next()){ Category category = new Category(rs.getString("order_name")); categories.add(category); } return categories; } catch (SQLException throwables) { throwables.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } finally { try { con.close(); } catch (SQLException throwables) { throwables.printStackTrace(); } } return null; } }
f425ce78d78a083a63d32c0cf82549e3c378401d
0975d7046a109fc20b86d78b86bf2e1d36539c7b
/app/src/main/java/com/example/coco/liveproject/model/MessageObservable.java
a7af3aead3caeb6c7657f1dca86bba82db12b6fd
[]
no_license
CocoQueen/LiveProject
e43ffffb993ebd8aa16dc535ea1f31ffd92d13f0
1781d5013d35b9f1d9ed9ea45c1d843dd0a29d67
refs/heads/master
2021-09-05T18:45:30.133724
2018-01-30T10:34:27
2018-01-30T10:34:27
115,969,070
0
0
null
null
null
null
UTF-8
Java
false
false
2,251
java
package com.example.coco.liveproject.model; import com.tencent.TIMMessage; import com.tencent.TIMUserProfile; import com.tencent.livesdk.ILVCustomCmd; import com.tencent.livesdk.ILVLiveConfig; import com.tencent.livesdk.ILVText; import java.util.LinkedList; /** * 消息观察者 */ public class MessageObservable implements ILVLiveConfig.ILVLiveMsgListener{ // 消息监听链表 private LinkedList<ILVLiveConfig.ILVLiveMsgListener> listObservers = new LinkedList<>(); // 句柄 private static MessageObservable instance; public static MessageObservable getInstance(){ if (null == instance){ synchronized (MessageObservable.class){ if (null == instance){ instance = new MessageObservable(); } } } return instance; } // 添加观察者 public void addObserver(ILVLiveConfig.ILVLiveMsgListener listener){ if (!listObservers.contains(listener)){ listObservers.add(listener); } } // 移除观察者 public void deleteObserver(ILVLiveConfig.ILVLiveMsgListener listener){ listObservers.remove(listener); } @Override public void onNewTextMsg(ILVText text, String SenderId, TIMUserProfile userProfile) { // 拷贝链表 LinkedList<ILVLiveConfig.ILVLiveMsgListener> tmpList = new LinkedList<>(listObservers); for (ILVLiveConfig.ILVLiveMsgListener listener : tmpList){ listener.onNewTextMsg(text, SenderId, userProfile); } } @Override public void onNewCustomMsg(ILVCustomCmd cmd, String id, TIMUserProfile userProfile) { // 拷贝链表 LinkedList<ILVLiveConfig.ILVLiveMsgListener> tmpList = new LinkedList<>(listObservers); for (ILVLiveConfig.ILVLiveMsgListener listener : tmpList){ listener.onNewCustomMsg(cmd, id, userProfile); } } @Override public void onNewOtherMsg(TIMMessage message) { // 拷贝链表 LinkedList<ILVLiveConfig.ILVLiveMsgListener> tmpList = new LinkedList<>(listObservers); for (ILVLiveConfig.ILVLiveMsgListener listener : tmpList){ listener.onNewOtherMsg(message); } } }
3d8089814c17761725b1949e841a2155fdb39e84
2da19ffefa23562209363b99ee08907814262cdd
/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/codemining/JavaReferencesCodeMiningProvider.java
14dbf39ccd89ca3fbc08f6cd5626be7ce8013e24
[ "MIT" ]
permissive
cucumber/cucumber-eclipse
00ba402e4fcc74511d5e905ab7eda212c6ccd8cc
a9f72bcefefc6d2d1fc4e2d96aa941b0a4fbeba2
refs/heads/main
2023-09-01T04:04:11.230463
2023-08-16T09:02:31
2023-08-16T16:13:04
6,560,370
160
167
MIT
2023-09-07T14:01:16
2012-11-06T10:29:33
Java
UTF-8
Java
false
false
8,178
java
package io.cucumber.eclipse.java.codemining; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.codemining.ICodeMining; import org.eclipse.jface.text.codemining.ICodeMiningProvider; import org.eclipse.jface.text.codemining.LineContentCodeMining; import org.eclipse.jface.text.codemining.LineHeaderCodeMining; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.window.Window; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.dialogs.ElementListSelectionDialog; import io.cucumber.eclipse.editor.SWTUtil; import io.cucumber.eclipse.java.JDTUtil; import io.cucumber.eclipse.java.plugins.MatchedHookStep; import io.cucumber.eclipse.java.plugins.MatchedStep; import io.cucumber.eclipse.java.preferences.CucumberJavaPreferences; import io.cucumber.eclipse.java.steps.JavaStepDefinitionOpener; import io.cucumber.eclipse.java.validation.CucumberGlueValidator; import io.cucumber.plugin.event.HookType; import io.cucumber.plugin.event.Location; import io.cucumber.plugin.event.TestStep; /** * Provide java specific code minings to the editor * * @author christoph * */ public class JavaReferencesCodeMiningProvider implements ICodeMiningProvider { @Override public CompletableFuture<List<? extends ICodeMining>> provideCodeMinings(ITextViewer viewer, IProgressMonitor monitor) { return CompletableFuture.supplyAsync(() -> { if (CucumberJavaPreferences.showHooks()) { try { IDocument document = viewer.getDocument(); IJavaProject javaProject = JDTUtil.getJavaProject(document); if (javaProject != null) { Collection<MatchedStep<?>> steps = CucumberGlueValidator.getMatchedSteps(document, monitor); List<ICodeMining> list = new ArrayList<>(); Map<Integer, List<MatchedHookStep>> stepByLine = steps.stream() .filter(MatchedHookStep.class::isInstance).map(MatchedHookStep.class::cast) .collect(Collectors.groupingBy(step -> step.getLocation().getLine())); for (Entry<Integer, List<MatchedHookStep>> entry : stepByLine.entrySet()) { int lineNumber = entry.getKey() - 1; Map<HookType, List<MatchedHookStep>> hooksByType = entry.getValue().stream() .collect(Collectors.groupingBy(hookStep -> hookStep.getTestStep().getHookType())); hooksByType.entrySet().stream() .sorted((e1, e2) -> e1.getKey().ordinal() - e2.getKey().ordinal()).map(e -> { try { return new HooksCodeMining(lineNumber, document, JavaReferencesCodeMiningProvider.this, e.getKey(), e.getValue(), javaProject); } catch (BadLocationException e3) { return null; } }).filter(Objects::nonNull).forEach(list::add); } return list; } } catch (OperationCanceledException e) { } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (CoreException e) { e.printStackTrace(); } } return Collections.emptyList(); }); } @Override public void dispose() { } private static final class HooksCodeMining extends LineHeaderCodeMining { private HookType hookType; private List<MatchedHookStep> list; private AtomicReference<Consumer<MouseEvent>> action = new AtomicReference<>(); private IJavaProject javaProject; public HooksCodeMining(int beforeLineNumber, IDocument document, ICodeMiningProvider provider, HookType hookType, List<MatchedHookStep> list, IJavaProject javaProject) throws BadLocationException { super(beforeLineNumber, document, provider); this.hookType = hookType; this.list = list; this.javaProject = javaProject; } @Override protected CompletableFuture<Void> doResolve(ITextViewer viewer, IProgressMonitor monitor) { return CompletableFuture.supplyAsync(() -> { String hookName; switch (hookType) { case BEFORE: hookName = "@Before"; break; case AFTER: hookName = "@After"; break; case AFTER_STEP: hookName = "@AfterStep"; break; case BEFORE_STEP: hookName = "@BeforeStep"; break; default: hookName = hookType.toString(); } int size = list.size(); setLabel(hookName + ": " + size); Set<Entry<MatchedHookStep, IMethod[]>> resolvedMethods = list.stream() .collect(Collectors.toMap(Function.identity(), step -> { try { return JDTUtil.resolveMethod(javaProject, step.getCodeLocation(), null); } catch (JavaModelException e) { return null; } })).entrySet(); action.set(event -> { Shell shell = SWTUtil.getShell(event); if (resolvedMethods.size() == 1) { Entry<MatchedHookStep, IMethod[]> entry = resolvedMethods.iterator().next(); open(entry.getKey(), entry.getValue(), shell); } else { ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new LabelProvider() { @Override public String getText(Object element) { if (element instanceof Entry<?, ?>) { Entry<?, ?> entry = (Entry<?, ?>) element; Object value = entry.getValue(); if (value instanceof IMethod) { try { return JDTUtil.getMethodName((IMethod) value); } catch (JavaModelException e) { } } Object key = entry.getKey(); if (key instanceof MatchedHookStep) { MatchedHookStep step = (MatchedHookStep) key; return step.getCodeLocation().toString(); } } return element.toString(); } }); dialog.setElements(resolvedMethods.toArray()); if (dialog.open() == Window.OK) { for (Object e : dialog.getResult()) { @SuppressWarnings("unchecked") Entry<MatchedHookStep, IMethod[]> entry = (Entry<MatchedHookStep, IMethod[]>) e; open(entry.getKey(), entry.getValue(), shell); } } } // TODO new ElementListSelectionDialog(null, null) }); return null; }); } private void open(MatchedHookStep step, IMethod[] method, Shell shell) { if (method != null && method.length > 0) { JavaStepDefinitionOpener.showMethod(method, shell); return; } MessageDialog.openInformation(shell, "Method not found", "Location " + step.getCodeLocation() + " not found"); } @Override public Consumer<MouseEvent> getAction() { return action.get(); } } private static final class JavaReferenceCodeMining extends LineContentCodeMining { private TestStep testStep; public JavaReferenceCodeMining(Position position, ICodeMiningProvider provider, TestStep testStep) { super(position, provider); this.testStep = testStep; } @Override protected CompletableFuture<Void> doResolve(ITextViewer viewer, IProgressMonitor monitor) { return CompletableFuture.supplyAsync(() -> { // TODO special handling -> resolve to java .... setLabel(testStep.getCodeLocation()); return null; }); } } private static final Position createPosition(Location location, IDocument document) throws BadLocationException { int line = location.getLine(); int offset = document.getLineOffset(line - 1); int lineLength = document.getLineLength(line - 1); return new Position(offset + lineLength - 1, 1); } }
82f46af13e35b083683ba4bc339419a56b45da12
a18868214ec84145b014e795e6944d97c018a6ee
/src/main/java/sam/backup/manager/extra/IStartOnComplete.java
321d9c62f85b62e936beb226feec5f79fb0d7c57
[]
no_license
sameerveda/backup-manager
aaa40d42d5691b4299b302536de710685f7854fe
741aac250f1293eeca7946386856daba931def84
refs/heads/master
2021-10-30T05:04:30.239691
2018-11-24T14:36:49
2018-11-24T14:36:49
null
0
0
null
null
null
null
UTF-8
Java
false
false
131
java
package sam.backup.manager.extra; public interface IStartOnComplete<E> { public void start(E e); public void onComplete(E e); }
2b511484e71e16cfb84ae3ff2b1e0c730f3a2dde
7d6b61d2b5ea9806e05f74ef92050fcfa56ade55
/src/Client.java
9998b52b6675c24b078cf8b54f98f57b72b16a43
[]
no_license
FatemehGholamzadeh/Network-Security-Project-phase-1
6b2b1d93be2ca5462c482573c3418b1108d7edea
3abd762284cd8e0f2dd1c7d909c03c620e593662
refs/heads/main
2023-06-29T20:31:32.207077
2021-08-01T11:41:02
2021-08-01T11:41:02
391,610,373
3
0
null
null
null
null
UTF-8
Java
false
false
4,123
java
package ir.aut; import java.io.*; import java.math.BigDecimal; import java.net.InetAddress; import java.net.Socket; import java.util.Base64; import java.util.Scanner; public class Client { private static byte[] sessionKey = new byte[16]; private static String privateKey = "1122334455667788"; private static byte[] IV = new byte[16]; private static byte[] sk = new byte[16]; private static String physicalKey = ""; public static void main(String[] args) throws Exception { //initialize IV for (int i = 0; i < 16; i++) { IV[i] = 0; } //create AES object AES aes = new AES(); //defining IP and port InetAddress ip = InetAddress.getLocalHost(); int port = 4444; //defining Socket Socket s = new Socket(ip, port); //dos and dis DataInputStream dis = new DataInputStream(s.getInputStream()); DataOutputStream dos = new DataOutputStream(s.getOutputStream()); //sending Request sendRequest(dos); //encrypt key encryptKey(aes); readPhysicalKey(aes); //read session key bare avval dis.readFully(sessionKey); sk = (aes.decrypt(sessionKey, physicalKey.getBytes(), IV)); // read length of incoming message int length = dis.readInt(); FileOutputStream out = new FileOutputStream(new File("D:\\download\\1.jpg"), false); byte[] message = new byte[16]; for (int i = 0; i < (length / 16 + 1); i++) { dis.read(message); String a = new String(message, "UTF-8"); if (a.contains("session")) { System.out.println("session key changed ! "); dis.read(sessionKey); sk = aes.decrypt(sessionKey, physicalKey.getBytes(), IV); dis.read(message); } message = aes.decrypt(message, sk, IV); out.write(message); } byte[] nextPhysicalKey = new byte[16]; dis.read(nextPhysicalKey); byte[] ss = aes.decrypt(nextPhysicalKey, physicalKey.getBytes(), IV); writeNextPhysical(nextPhysicalKey, ss); s.close(); } public static void encryptKey(AES aes) throws Exception { File f = new File("key2.txt"); BigDecimal bytes = new BigDecimal(f.length()); int size = bytes.intValue(); byte[] buffer = new byte[size]; if (f.exists()) { FileInputStream inputStream = new FileInputStream(f); while (inputStream.read(buffer) != -1) { buffer = aes.encrypt(buffer, privateKey.getBytes(), IV); } FileOutputStream fos = new FileOutputStream("ClientEncryptedKey.txt"); fos.write(buffer); } } public static void writeNextPhysical(byte[] buffer, byte[] ss) throws Exception { FileOutputStream fos = new FileOutputStream("nextPhysicalKey.txt"); FileOutputStream fos1 = new FileOutputStream("encryptedNextPhysicalKey.txt"); fos.write(buffer); fos1.write(ss); } public static void readPhysicalKey(AES aes) throws Exception { File f = new File("ClientEncryptedKey.txt"); BigDecimal bytes = new BigDecimal(f.length()); int size = bytes.intValue(); byte[] buffer = new byte[size]; if (f.exists()) { FileInputStream inputStream = new FileInputStream(f); while (inputStream.read(buffer) != -1) { physicalKey = new String(aes.decrypt(buffer, privateKey.getBytes(), IV), "UTF-8"); } } } public static void sendRequest(DataOutputStream dos) throws Exception { Scanner scanner = new Scanner(System.in); System.out.println("please Enter your User Name : "); String userName = scanner.nextLine(); System.out.println("we're sending your User Name ... "); dos.writeUTF(userName); } }
53434129d87437c9ccb956c33865be34d14d1fd1
4b5b6564f81e49ff909a8c2a43e3f4727cb19da3
/Navigator/src/main/java/com/nagivator/model/BasicObject.java
5652e3f04cb7fd9f6576dc00dcba039cfccd9b08
[]
no_license
ramazanfirin/navigatorNew
45fe65af27f6982c940c655696f294c03c07c20c
9c64ceeabc1c89fcdaf947d1dda035fd7790cf16
refs/heads/master
2020-02-26T14:59:35.666720
2018-10-04T09:24:47
2018-10-04T09:24:47
35,404,759
0
0
null
null
null
null
UTF-8
Java
false
false
829
java
package com.nagivator.model; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.sql.rowset.serial.SerialArray; public class BasicObject implements Serializable{ private Long id; private String name; private Boolean enabled=true; private Company company; public Company getCompany() { return company; } public void setCompany(Company company) { this.company = company; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Boolean getEnabled() { return enabled; } public void setEnabled(Boolean enabled) { this.enabled = enabled; } }
3d071d4daa8c0da9c87c85c3addfa34588bc3809
9d2573512cb4f0011921cf6ed71ddc0f0fc8af02
/src/main/java/com/github/ansonliao/selenium/factory/FirefoxFactory.java
2f90758c9dda391191fbeb6fd7a7122507096f87
[]
no_license
jiagangzhang/Selenium-Extensions
ee6f9a6c72c28b39421e5415e4bd275ea5526382
2f3e5426686903848aa6d6ee88b2111bd0f75b99
refs/heads/master
2021-08-23T02:33:27.378528
2017-11-30T07:41:03
2017-11-30T07:41:03
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,370
java
package com.github.ansonliao.selenium.factory; import com.github.ansonliao.selenium.utils.SEFilterUtils; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxBinary; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxOptions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class FirefoxFactory extends DriverManager { private static final Logger logger = LoggerFactory.getLogger(FirefoxFactory.class); private static FirefoxFactory instance = new FirefoxFactory(); private FirefoxFactory() { super(); } public synchronized static FirefoxFactory getInstance() { return instance; } @Override public WebDriver getDriver() { FirefoxBinary binary = new FirefoxBinary(); FirefoxOptions options = new FirefoxOptions(); if (isHeadless) { binary.addCommandLineOptions("--headless"); options.setBinary(binary); } if (isIncognito) { options.addArguments("--private"); } driver = new FirefoxDriver(options); return driver; } @Override public String getExportParameterKey() { return SEFilterUtils.getFirefoxDriverExportKey(); } @Override public Logger getLogger() { return logger; } }
e593d94a84d1c1e475a6e9b54162cd2f496c4596
a3eca1293df44e40cf8cc95e6f8ac3982a0e7f0f
/Java/Java Fundamentals/JavaOOP Advanced/Exercises/Ex08_InterfaceSegregation,DependencyInversion/src/models/MotorBoat.java
b8a0886e6ccad1fe30116d5c66394f9cc87f2aea
[]
no_license
StoyanZhulev/SoftUni
e88a1b522b3a5a36c0d168c5010670610d99a83e
386c304d3ffc879adbf586582cf8ae5820814cdf
refs/heads/master
2021-01-01T17:15:20.477345
2017-11-23T14:54:46
2017-11-23T14:54:46
98,035,684
0
0
null
null
null
null
UTF-8
Java
false
false
3,665
java
package models; import Utility.Constants; import Utility.Validator; import contracts.IModelable; import contracts.IRace; import java.util.List; public final class MotorBoat implements IModelable { private String model; private int weight; private int oars; private int sailEfficiency; private int cargoWeight; private List<JetEngine> jetEngines; private List<SterndriveEngine> sterndriveEngines; public Boolean isSailboat; public MotorBoat(String model, int weight, int sailEfficiency, int oars, int cargoWeight, List<JetEngine> jetEngines, List<SterndriveEngine> sterndriveEngines, Boolean isSailboat) { this.setSailEfficiency(sailEfficiency); this.cargoWeight = cargoWeight; this.setOars(oars); this.model = model; this.setWeight(weight); this.jetEngines = jetEngines; this.sterndriveEngines = sterndriveEngines; this.isSailboat = isSailboat; } @Override public String getModel() { return model; } public void setModel(String model) { Validator.ValidateModelLength(model, Constants.MinBoatModelLength); this.model = model; } public int getWeight() { return weight; } public void setWeight(int weight) { Validator.ValidatePropertyValue(weight, "Weight"); this.weight = weight; } public int getOars() { return oars; } public void setOars(int oars) { Validator.ValidatePropertyValue(oars, "Oars"); this.oars = oars; } public int getSailEfficiency() { return sailEfficiency; } public void setSailEfficiency(int sailEfficiency) { if (sailEfficiency < 1 || sailEfficiency > 100) { throw new IllegalArgumentException(Constants.IncorrectSailEfficiencyMessage); } this.sailEfficiency = sailEfficiency; } public int getCargoWeight() { return cargoWeight; } public void setCargoWeight(int cargoWeight) { Validator.ValidatePropertyValue(cargoWeight, "Cargo Weight"); this.cargoWeight = cargoWeight; } public List<JetEngine> getJetEngines() { return jetEngines; } public void setJetEngines(List<JetEngine> jetEngines) { this.jetEngines = jetEngines; } public List<SterndriveEngine> getSterndriveEngines() { return sterndriveEngines; } public void setSterndriveEngines(List<SterndriveEngine> sterndriveEngines) { this.sterndriveEngines = sterndriveEngines; } public double CalculateRaceSpeed(IRace race) { //if (this.getJetEngines().size() + this.getSterndriveEngines().size() == 2) { // var speed = this.JetEngines.Sum(x = > x.Output)+this.SterndriveEngines.Sum(x = > x.Output) // -this.Weight + (race.OceanCurrentSpeed / 5d); // return speed; //} else if (this.getJetEngines().size() + this.getSterndriveEngines().size() == 1) { // var speed = this.JetEngines.Sum(x = > x.Output)+this.SterndriveEngines.Sum(x = > x.Output) // -this.Weight - this.CargoWeight + (race.OceanCurrentSpeed / 2d); // return speed; //} else if (isSailboat) { // var speed = (race.WindSpeed * (this.SailEfficiency / 100d)) - this.Weight + (race.OceanCurrentSpeed / 2d); // return speed; //} else { // var speed = (this.Oars * 100) - this.Weight + race.OceanCurrentSpeed; // return speed; //} return 0; } }