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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c8783db75ea974f444c671fce97fbcf7157c5374 | 32e4d7a4abfaf8a7d8f8d3f971fcbbef8e3fd190 | /app/src/androidTest/java/nsutanto/bakingapp/MainActivityTest.java | 463504b1dec675ce3b380d23926ce9e18dee1b87 | [
"MIT"
] | permissive | nsutanto/android-BakingApp | 5b17b6a6d6f70d0dc9d25402c058f7174f2b0c2b | cd9a69bc36d5acdd5fb23e811d91e9581ea15b87 | refs/heads/master | 2020-03-26T15:38:21.006467 | 2018-08-23T14:15:33 | 2018-08-23T14:15:33 | 145,055,198 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,859 | java | package nsutanto.bakingapp;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.scrollTo;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import android.support.test.espresso.IdlingRegistry;
import android.support.test.espresso.IdlingResource;
import android.support.test.espresso.contrib.RecyclerViewActions;
import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity> mainActivityTestRule = new ActivityTestRule<>(MainActivity.class);
private IdlingResource idlingResource;
@Before
public void registerIdlingResource() {
idlingResource = mainActivityTestRule.getActivity().getIdlingResource();
IdlingRegistry.getInstance().register(idlingResource);
}
@Test
public void testRecipeList() {
onView(ViewMatchers.withId(R.id.rv_recipe)).perform(RecyclerViewActions.actionOnItemAtPosition(0, scrollTo()));
onView(withText("Nutella Pie")).perform(click());
onView(withId(R.id.tv_ingredient_label)).check(matches(withText("Ingredients")));
}
@After
public void unregisterIdlingResource() {
if (idlingResource != null) {
IdlingRegistry.getInstance().unregister(idlingResource);
}
}
}
| [
"[email protected]"
] | |
384eff1af4ed3429745dd8756cf74bd881e43fde | 81e95bd8d2b112ec78d8d764c2fc9f86c9233e13 | /src/main/java/spartan/util/io/ByteArrayOutputStream.java | 1b4daa266802a3e75770b72af3b64cd66ea7a409 | [
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] | permissive | tideworks/spartan-launcher | 26a7ffd646835df1d518804a8be204a332773b38 | f1976d7646ec6c3aa62b76d6cd46524f13a9d3cd | refs/heads/master | 2021-06-10T18:40:10.693008 | 2019-12-17T15:18:55 | 2019-12-17T15:18:55 | 125,890,862 | 19 | 0 | Apache-2.0 | 2021-06-07T16:40:22 | 2018-03-19T16:50:02 | C++ | UTF-8 | Java | false | false | 927 | java | /* ByteArrayOutputStream.java
Copyright 2016 - 2017 Tideworks Technology
Author: Roger D. Voss
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 spartan.util.io;
public class ByteArrayOutputStream extends java.io.ByteArrayOutputStream {
public ByteArrayOutputStream(int initAllocSize) { super(initAllocSize); }
public ByteArrayOutputStream(byte[] buf) { super(); super.buf = buf; }
public byte[] getBuffer() { return super.buf; }
}
| [
"[email protected]"
] | |
e88baf4b1fe50ff81acbd5fd3d0b74b6ed159f74 | 230f814140d340778ec642a51266bb451976dd4d | /lib/src/org/ymkm/lib/automaton/IntentAutomaton.java | eab7e85f7148c9b822c827ff39c8d84671ded31d | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | yochiro/android-ymkm-lib | da37c5c82f6f5645ad8e929889ef824367d84b5d | c7987679332787286e795ea0774b6bdd2f3a9115 | refs/heads/master | 2021-06-06T07:42:57.760102 | 2019-03-11T02:48:49 | 2019-03-11T02:48:49 | 7,617,680 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 45,838 | java | /*******************************************************************************
* Copyright 2013 Yoann Mikami <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.ymkm.lib.automaton;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.util.Log;
import android.util.SparseArray;
import org.ymkm.lib.automaton.IntentAutomaton.Runner.RunnerContext;
/**
* Defines an finite-state-machine (FSM) with transitions triggered by Intents
*
* <p>
* A FSM is composed of States and Transitions.<br>
* A Transition links two states in the FSM, the source state and the target
* state.<br>
* Two special states are typically found in a FSM : The initial state and the
* final state(s).<br>
* While there can be multiple final states, only one initial state is
* permitted.
* </p>
* <p>
* An {@code IntentAutomaton} is an abstract representation of a FSM, but does
* not do anything by itself; it needs a {@link IntentAutomaton#Runner}, which
* represents a running instance of a given FSM.<br>
* In other words, multiple Runner may run simultaneously on the same FSM; each
* will store the current state, and any other contextual data (see
* {@link IntentAutomaton.Runner.RunnerContext}), while the
* {@code IntentAutomaton} itself is mostly stateless.
* </p>
* <p>
* A State is defined by at least a state ID (UNIQUE in a given automaton), a
* name (For readability/debugging).<br>
* Optionally, a {@link StateAction} can be supplied for either or both onEnter
* and onExit events;<br>
* onEnter event will run the specified StateAction whenever a transition leads
* to it, while onExit will run the specified StateAction whenever a transition
* leaves from it to another state.
* </p>
* <p>
* A Transition is defined by at least a from state ID X, a to state ID Y and an
* intent qualifier.<br>
* This tells the automaton that whenever the specified intent is broadcast in
* the system, moves to state Y if any Runner's current state is X.<br>
* Therefore, multiple Runner may transition at the same time should they react
* on the same intent and are in the same state.<br>
* Optionally a {@link TransitionAction} may be supplied to a given Transition :
* <br>
* This will be called whenever the transition it is attached to is taken,
* irrespective of from/to states.<br>
* In addition, a {@link TransitionGuard} may be applied to a Transition :<br>
* This prevents the Runner to take the transition matching the from state and
* intent if the {@link TransitionGuard#guarded} function returns {@code true}.
* </p>
* <p>
* A given state can have multiple transitions linking to several states. While
* guards set on transitions should ideally be mutually exclusive, the system
* does not enforce this, and will take the first transition it finds that it
* can take.<br>
* <strong>Note :</strong> Incidentally, it is possible to create a FSM in which
* a Runner gets stuck into if all transitions from current state have
* TransitionGuard that all return true.<br>
* Special care must thus be taken when designing FSM with
* Transition/TransitionGuard leaving from the same state.
* </p>
* <p>
* Multiple {@link Runner} instances can process the same
* {@code IntentAutomaton} ; Each new instance will yield a new
* {@link RunnerContext} which gets passed to each {@link StateAction},
* {@link TransitionAction}, {@link TransitionGuard} callback methods; all
* instance-specific states that needs to be propagated throughout the whole run
* can be stored in the context using a simple key-value storage.<br>
* </p>
*
* @author [email protected]
*
*/
@SuppressLint("UseSparseArrays")
public class IntentAutomaton {
/*
* INTERNAL How it works : Each new intent assigned to each transition will
* be dynamically added to an IntentFilter then monitored by a
* BroadcastReceiver created by the Runner when the latter is started
* (start()). It merely delegates the work to a Handler running in the
* Runner context. The Handler checks the current state, finds transitions
* assigned, then checks against the return value of their TransitionGuard
* until one returns false. If all of them return true, the transition does
* not occur. Otherwise, fromState.onExit, transition.action(),
* toState.onEnter(), in this order, are executed.
*/
/**
* Intent sent to the system when a transition occurs
*
* The application may register this intent in a broadcast to react to state
* changes.<br/>
* The following keys are defined as intent extra data :
* <dl>
* <dt>{@link KEY_FROM_STATE}</dt>
* <dd>The state name the Runner is exiting from</dd>
* <dt>{@link KEY_TO_STATE}</dt>
* <dd>The state name the Runner is entering to</dd>
* <dt>{@link KEY_INTENT_TRANSITION}</dt>
* <dd>The intent that triggered the transition</dd>
* </dl>
*/
public final static String INTENT_AUTOMATON_STATE_CHANGE = "org.ymkm.lib.automaton.INTENT_AUTOMATON_STATE_CHANGE";
/**
* Extra data for {@link INTENT_AUTOMATON_STATE_CHANGE} : From state name
*/
public final static String KEY_FROM_STATE = "KEY_FROM_STATE";
/**
* Extra data for {@link INTENT_AUTOMATON_STATE_CHANGE} : To state name
*/
public final static String KEY_TO_STATE = "KEY_TO_STATE";
/**
* Extra data for {@link INTENT_AUTOMATON_STATE_CHANGE} : Intent that
* triggered transition
*/
public final static String KEY_INTENT_TRANSITION = "KEY_INTENT_TRANSITION";
/**
* State flag for initial state. An IntentAutomaton must have exactly one
* state with this flag defined
*/
private static final int INITIAL_STATE = 0x0;
/**
* State flag for final state. An IntentAutomaton must have AT LEAST one
* state with this flag defined
*/
private static final int FINAL_STATE = 0x1;
/**
* State flag for default states. States that are neither initial nor final
* states gets this flag
*/
private static final int DEFAULT_STATE = 0x2;
/**
* Maps State ID to State objects
*/
private Map<Integer, State> mStates;
/**
* Maps State ID to List of Transitions
*/
private SparseArray<Map<Integer, List<Transition>>> mTransitions;
/**
* Set of all intents declared in Transitions defined for this
* IntentAutomaton
*/
private Set<String> mIntents;
private final static String TAG = IntentAutomaton.class.getCanonicalName();
/**
* Represents a state in the automaton
*
* States have a unique ID, a name and an optional enter/exit action.<br>
* <br>
* They can take either of these 3 types : INITIAL, FINAL or DEFAULT.
* <p>
* StateAction supplied to enter/exit/notify events may have a delay during
* their creation.<br>
* In that case, the action will be performed upon
* entering/exiting/notifying after the specified amount of time has
* elapsed.
* </p>
*
* @author [email protected]
*/
private final static class State {
private int mStateId;
private String mName;
private int mType;
private StateAction mOnEnterAction;
private StateAction mOnExitAction;
/**
* Runnable that is ran in onEnter/onExit of a state
*
* Stores the RunnerContext and the StateAction
*
* @author [email protected]
*/
private final static class ActionRunnable implements Runnable {
StateAction mStateAction;
Runner.RunnerContext mContext;
public ActionRunnable(final StateAction saction,
Runner.RunnerContext context) {
mStateAction = saction;
mContext = context;
}
/**
* The run method wraps the StateAction's run method, but the latter
* needs a context, which cannot be given through normal Runnable.
*/
@Override
public void run() {
mStateAction.run(mContext);
}
}
/**
* Creates a new state using given automaton as its parent, with
* specified ID and name
*
* <p>
* It creates a normal state. To set this state as an initial state,
* {@code setInitialState(id)} must be called.
* </p>
* <p>
* Created state will have no enter / exit actions.
* </p>
*
* @param parent
* the automaton it gets attached to
* @param stateId
* the ID. Must be unique
* @param name
* the state name
*/
State(IntentAutomaton parent, int stateId, String name) {
mStateId = stateId;
mName = name;
mType = DEFAULT_STATE;
}
/**
* Creates a new state using given automaton as its parent, with
* specified ID, name and enter action
*
* <p>
* It creates a normal state. To set this state as an initial state,
* {@code setInitialState(id)} must be called.
* </p>
* <p>
* Specified enter action will be ran whenever this state is entered by
* a Runner.
* </p>
* <p>
* Created state will have no exit actions.
* </p>
*
* @param parent
* the automaton it gets attached to
* @param stateId
* the ID. Must be unique
* @param name
* the state name
* @param onEnterAction
* the action to perform on enter
*/
State(IntentAutomaton parent, int stateId, String name,
StateAction onEnterAction) {
this(parent, stateId, name);
mOnEnterAction = onEnterAction;
}
/**
* Creates a new state using given automaton as its parent, with
* specified ID, name and enter action
*
* <p>
* It creates a normal state. To set this state as an initial state,
* {@code setInitialState(id)} must be called.
* </p>
* <p>
* Specified enter action will be ran whenever this state is entered by
* a Runner.<br>
* Specified exit action will be ran whenever this state is left by a
* Runner.
* </p>
*
* @param parent
* the automaton it gets attached to
* @param stateId
* the ID. Must be unique
* @param name
* the state name
* @param onEnterAction
* the action to perform on enter
* @param onExitAction
* the action to perform on exit
*/
State(IntentAutomaton parent, int stateId, String name,
StateAction onEnterAction, StateAction onExitAction) {
this(parent, stateId, name, onEnterAction);
mOnExitAction = onExitAction;
}
/**
* Returns this state's ID
*
* @return the state ID
*/
public int getStateId() {
return mStateId;
}
/**
* Returns this state name
*
* @return the state name
*/
public String getName() {
return mName;
}
/**
* Returns this state type
*
* @return INITIAL_STATE|FINAL_STATE|DEFAULT
*/
public int getType() {
return mType;
}
/**
* Sets this state type
*
* @param type
* INITIAL_STATE|FINAL_STATE|DEFAULT
*/
public void setType(int type) {
mType = type;
}
/**
* Returns the enter action, or null if none
*
* @return StateAction on enter, or null
*/
public StateAction getEnterAction() {
return mOnEnterAction;
}
/**
* Returns the exit action, or null if none
*
* @return StateAction on exit, or null
*/
@SuppressWarnings("unused")
public StateAction getExitAction() {
return mOnExitAction;
}
/**
* Enter action of a state
*
* <p>
* Called by a running {@link Runner} instance, passes in its
* {@link Handler} and the current {@link RunnerContext}.
* </p>
*
* @param handler
* the running Runner Handler
* @param rContext
* the RunnerContext
* @return return value of {@link Handler#post}
*/
public boolean enter(Handler handler, Runner.RunnerContext rContext) {
boolean ret = false;
if (null != mOnEnterAction) {
if (mOnEnterAction.getDelay() > 0) {
ret = handler.postDelayed(new ActionRunnable(
mOnEnterAction, rContext), mOnEnterAction
.getDelay());
} else {
ret = handler.post(new ActionRunnable(mOnEnterAction,
rContext));
}
}
return ret;
}
/**
* Exit action of a state
*
* <p>
* Called by a running {@link Runner} instance, passes in its
* {@link Handler} and the current {@link RunnerContext}.
* </p>
*
* @param handler
* the running Runner Handler
* @param rContext
* the RunnerContext
* @return return value of {@link Handler#post}
*/
public boolean exit(Handler handler, Runner.RunnerContext rContext) {
boolean ret = false;
if (null != mOnExitAction) {
if (mOnEnterAction.getDelay() > 0) {
ret = handler.postDelayed(new ActionRunnable(mOnExitAction,
rContext), mOnExitAction.getDelay());
} else {
ret = handler.post(new ActionRunnable(mOnExitAction,
rContext));
}
}
return ret;
}
}
/**
* Represents a transition in the automaton
*
* @author [email protected]
*/
private final static class Transition {
private TransitionAction mTransitionAction;
private TransitionGuard mGuard;
private String mIntent;
/**
* Runnable that is ran in action of a transition
*
* Stores the RunnerContext, the Intent and the TransitionAction
*
* @author [email protected]
*/
private final static class ActionRunnable implements Runnable {
TransitionAction mTransitionAction;
Intent mIntent;
Runner.RunnerContext mContext;
public ActionRunnable(final TransitionAction taction,
final Intent intent, Runner.RunnerContext context) {
mTransitionAction = taction;
mIntent = intent;
mContext = context;
}
/**
* The run method wraps the TransitionAction's run method, but the
* latter needs a context, which cannot be given through normal
* Runnable.
*/
@Override
public void run() {
mTransitionAction.run(mIntent, mContext);
}
}
/**
* Creates a new Transaction reacting to given Intent and triggering
* specified TransitionAction
*
* This transition is not guarded, ie. it will be taken whenever a
* matching intent will be broadcast.<br>
* Internally, it uses a {@link NullTransitionGuard} as its
* {@link TransitionGuard}.
*
* @param intent
* The intent to react to
* @param a
* the action to perform on transition
*/
Transition(String intent, TransitionAction a) {
mTransitionAction = a;
mIntent = intent;
}
/**
* Creates a new Transaction reacting to given Intent and triggering
* specified TransitionAction if specified TransitionGuard is not
* guarded.
*
* A transition will be taken if {@link TransitionGuard#guarded} returns
* <strong>false</strong>.
*
* @param intent
* The intent to react to
* @param a
* the action to perform on transition
* @param g
* the guard condition. Returns true if transition should not
* be taken
*/
Transition(String intent, TransitionAction a, TransitionGuard g) {
this(intent, a);
mGuard = g;
}
/**
* Returns the intent registered with current transition
*
* @return the intent
*/
public String getIntent() {
return mIntent;
}
/**
* Returns true to guard the transition (i.e. transition not taken)
*
* @param intent
* Intent that wants to trigger the transition
* @param context
* the runner context
* @return true if the transition is guarded (ie. should not be taken),
* false otherwise
*/
public boolean guarded(Intent intent, Runner.RunnerContext context) {
return null != mGuard && mGuard.predicate(intent, context);
}
/**
* Action of a transition
*
* <p>
* Called by a running {@link Runner} instance, passes in its
* {@link Handler} and the current {@link RunnerContext}.
* </p>
*
* @param intent
* the intent that wants to trigger current transition
* @param handler
* the running Runner Handler
* @param rContext
* the RunnerContext
* @return return value of {@link Handler#post}
*/
public boolean action(Intent intent, Handler handler,
Runner.RunnerContext rContext) {
if (null == mTransitionAction) { return false; }
if (mTransitionAction.getDelay() > 0) {
return handler.postDelayed(new ActionRunnable(
mTransitionAction, intent, rContext), mTransitionAction
.getDelay());
} else {
return handler.post(new ActionRunnable(mTransitionAction,
intent, rContext));
}
}
}
/**
* Defines an action to perform when entering/exiting a state
*
* @author [email protected]
*/
public static abstract class StateAction {
/* Delay in ms to activate this StateAction */
private int mDelayInMs = 0;
/**
* Creates a new StateAction, with no delay
*/
public StateAction() {
}
/**
* Creates a new StateAction with given delay
*
* @param delay
* in ms, the delay after which the action is performed
*/
public StateAction(int delay) {
mDelayInMs = delay;
}
/**
* Returns the delay
*
* @return in ms, the delay
*/
public int getDelay() {
return mDelayInMs;
}
/**
* Subclasses must implement this, the action to perform on state action
*
* @param context
* the current runner context
*/
public abstract void run(Runner.RunnerContext context);
};
/**
* Defines an action to perform when traversing this transition
*
* @author [email protected]
*/
public static abstract class TransitionAction {
/* Delay in ms to activate this StateAction */
private int mDelayInMs = 0;
/**
* Creates a new TransitionAction, with no delay
*/
public TransitionAction() {
}
/**
* Creates a new TransitionAction with given delay
*
* @param delay
* in ms, the delay after which the action is performed
*/
public TransitionAction(int delay) {
mDelayInMs = delay;
}
/**
* Returns the delay
*
* @return in ms, the delay
*/
public int getDelay() {
return mDelayInMs;
}
/**
* Subclasses must implement this, the action to perform on transition
* action
*
* @param context
* the current runner context
*/
public abstract void run(Intent intent, Runner.RunnerContext context);
};
/**
* Defines a guard condition for transitions
*
* Guard : prevents from traversing the transition if the predicate returns
* true.
*/
public static abstract class TransitionGuard {
/**
* Function that should check the guard conditions when taking the
* transition
*
* @param intent
* the intent that triggered the transition
* @param context
* current runner context
* @return true if transition should not be taken, false otherwise
*/
public final boolean predicate(Intent intent,
Runner.RunnerContext context) {
return doPredicate(intent, context);
}
/**
* Subclasses must implement this
*
* @see TransitionGuard#predicate
*/
protected abstract boolean doPredicate(Intent intent,
Runner.RunnerContext context);
}
/**
* Default null transition guard (ie. does not have any guard constraints)
*
* @author [email protected]
*/
public final static class NullTransitionGuard extends TransitionGuard {
@Override
protected boolean doPredicate(Intent intent,
Runner.RunnerContext context) {
return false;
}
};
/**
* Transition guard that returns true if the decorated guard returns false
* (Inverts)
*
* @author [email protected]
*/
public final static class NotTransitionGuard extends TransitionGuard {
private TransitionGuard mGuard;
NotTransitionGuard(TransitionGuard g) {
mGuard = g;
}
@Override
protected boolean doPredicate(Intent intent,
Runner.RunnerContext context) {
return !mGuard.predicate(intent, context);
}
}
/**
* Transition guard that returns true if both decorated guard return true
*
* @author [email protected]
*/
public final static class AndTransitionGuard extends TransitionGuard {
private TransitionGuard mGuard1;
private TransitionGuard mGuard2;
public AndTransitionGuard(TransitionGuard g1, TransitionGuard g2) {
mGuard1 = g1;
mGuard2 = g2;
}
@Override
protected boolean doPredicate(Intent intent,
Runner.RunnerContext context) {
return (mGuard1.predicate(intent, context) || mGuard2.predicate(
intent, context));
}
}
/**
* Base IntentAutomaton exception
*
* @author [email protected]
*/
public abstract static class IntentAutomatonException extends Exception {
private static final long serialVersionUID = -2972101806117136770L;
public IntentAutomatonException(String string) {
super(string);
}
};
/**
* IntentAutomaton exception for state errors (static errors)
*
* @author [email protected]
*/
public final static class IntentAutomatonStateException extends
IntentAutomatonException {
private static final long serialVersionUID = -7043422581164886882L;
public IntentAutomatonStateException(String string) {
super(string);
}
};
/**
* IntentAutomaton exception related to a runner (dynamic errors)
*
* @author [email protected]
*/
public final static class IntentAutomatonRunnerException extends
IntentAutomatonException {
private static final long serialVersionUID = 4715439559246329424L;
public IntentAutomatonRunnerException(String string) {
super(string);
}
};
/**
* Defines a runner that can walk through an automaton
*
* An IntentAutomaton is stateless; a Runner is stateful. Thus, the same
* IntentAutomaton can be walked through using different Runners
* independently and concurrently, all managing their own states.
* <p>
* Each runner runs in its own thread, is managed using a Handler, and
* registers a BroadcastReceiver for all Intents listened by
* {@link Transition}s defined in managed {@link IntentAutomaton}.
* </p>
* <p>
* Each Runner can independently be started/paused/stopped/restarted, thus
* making them usable inside Activities, Fragments, or any other Android
* module that has such lifecycle.
* </p>
* <p>
* Runner can also save their own states into supplied Bundles
* (save/restoreInstanceState), provided the latter are called by the
* Activity/Fragment that manages it.<br>
* Current state can thus be restored at a later stage even if
* Activity/Fragment is destroyed/recreated.
* </p>
*
* @author [email protected]
*/
public final static class Runner {
/**
* RunnerContext provides with a shared storage among all states of an
* automaton
*
* Each runner instance holds a RunnerContext instance, which gets
* passed to every state/transition action of the automaton it is
* running onto.<br>
* This way, it is possible to keep track of data shared among different
* states/transitions (e.g. in {@link TransitionGuard}, one could handle
* different cases based on values inside the context).
*
* @author [email protected]
*
*/
public final static class RunnerContext {
private Map<String, Object> mContextValues;
public RunnerContext() {
mContextValues = new ConcurrentHashMap<String, Object>();
}
public void setInt(String key, int value) {
mContextValues.put(key, Integer.valueOf(value));
}
public void setLong(String key, long value) {
mContextValues.put(key, Long.valueOf(value));
}
public void setString(String key, String value) {
mContextValues.put(key, value);
}
public void setFloat(String key, float value) {
mContextValues.put(key, Float.valueOf(value));
}
public void setBoolean(String key, boolean value) {
mContextValues.put(key, Boolean.valueOf(value));
}
public void setObject(String key, Object value) {
mContextValues.put(key, value);
}
public int getInt(String key, int defValue) {
if (mContextValues.containsKey(key)) {
return (Integer) mContextValues.get(key);
}
return defValue;
}
public long getLong(String key, long defValue) {
if (mContextValues.containsKey(key)) {
return (Long) mContextValues.get(key);
}
return defValue;
}
public String getString(String key, String defValue) {
if (mContextValues.containsKey(key)) {
return (String) mContextValues.get(key);
}
return defValue;
}
public float getFloat(String key, float defValue) {
if (mContextValues.containsKey(key)) {
return (Float) mContextValues.get(key);
}
return defValue;
}
public boolean getBoolean(String key, boolean defValue) {
if (mContextValues.containsKey(key)) {
return (Boolean) mContextValues.get(key);
}
return defValue;
}
public Object getObject(String key, Object defValue) {
if (mContextValues.containsKey(key)) {
return mContextValues.get(key);
}
return defValue;
}
public void remove(String key) {
if (mContextValues.containsKey(key)) {
mContextValues.remove(key);
}
}
};
// The only message handled by the Runner Handler.
private final static int MSG_INTENT_RECEIVED = 0x10;
private IntentAutomaton mIntentAutomatonInstance;
private int mCurrentState;
private String mAutomatonName;
private boolean mStarted = false;
private boolean mPaused = true;
private Context mContext;
private Handler mIntentAutomatonHandler;
private HandlerThread _thread;
/**
* RunnerContext for this Runner
*/
public RunnerContext runnerContext;
/**
* Creates a new Runner on specified {@link IntentAutomaton} given
* specified {@link Context}
*
* <p>
* It performs a check for initial state on given automaton, and will
* throw an exception if there's none, or if multiple initial states are
* defined.
* </p>
*
* @param context
* the context to register BroadcastReceiver to
* @param g
* the automaton to manage
* @throws IntentAutomatonStateException
* if errors are found in the automaton
*/
private Runner(Context context, IntentAutomaton g)
throws IntentAutomatonStateException {
mIntentAutomatonInstance = g;
mCurrentState = -1;
mContext = context;
runnerContext = new RunnerContext();
init();
}
/**
* Creates a new Runner on specified {@link IntentAutomaton} given
* specified {@link Context}, using given RunnerContext
*
* <p>
* It performs a check for initial state on given automaton, and will
* throw an exception if there's none, or if multiple initial states are
* defined.
* </p>
*
* @param context
* the context to register BroadcastReceiver to
* @param g
* the automaton to manage
* @throws IntentAutomatonStateException
* if errors are found in the automaton
*/
private Runner(Context context, IntentAutomaton g,
RunnerContext rContext) throws IntentAutomatonStateException {
mIntentAutomatonInstance = g;
mCurrentState = -1;
mContext = context;
runnerContext = rContext;
init();
}
// Checks for initial state on automaton
private void init() throws IntentAutomatonStateException {
boolean initialStateFound = false;
State initialState = null;
for (Entry<Integer, State> s : mIntentAutomatonInstance.mStates
.entrySet()) {
if (INITIAL_STATE == s.getValue().getType()) {
if (initialStateFound) {
throw new IntentAutomatonStateException(
"IntentAutomaton cannot have more than one initial state");
}
initialStateFound = true;
initialState = s.getValue();
}
}
if (!initialStateFound) {
throw new IntentAutomatonStateException(
"IntentAutomaton must have an initial state");
}
mCurrentState = initialState.getStateId();
}
/**
* Sets runner name
*
* @param name
* the name to set for current Runner
*/
public void setName(String name) {
mAutomatonName = name;
}
/**
* Restores internal state of current Runner
*
* <p>
* May be called with a valid Bundle previously passed to
* {@link Runner#saveInstanceState}
* </p>
*
* @param savedInstanceState
*/
public void restoreInstanceState(Bundle savedInstanceState) {
if (null != savedInstanceState) {
mCurrentState = savedInstanceState.getInt("mAutomatonRunner_"
+ mAutomatonName + "_mCurrentState");
mStarted = savedInstanceState.getBoolean("mAutomatonRunner_"
+ mAutomatonName + "_mStarted");
mPaused = savedInstanceState.getBoolean("mAutomatonRunner_"
+ mAutomatonName + "_mPaused");
}
}
/**
* Saves current Runner state to specified Bundle
*
* <p>
* May be called by Activities or Fragments in the equivalent methods to
* react to lifecycle events.
* </p>
*
* @param outState
*/
public void saveInstanceState(Bundle outState) {
outState.putInt("mAutomatonRunner_" + mAutomatonName
+ "_mCurrentState", mCurrentState);
outState.putBoolean("mAutomatonRunner_" + mAutomatonName
+ "_mStarted", mStarted);
outState.putBoolean("mAutomatonRunner_" + mAutomatonName
+ "_mPaused", mPaused);
}
/**
* If not started, starts the current Runner and enters initial state of
* the automaton
*
* <p>
* A new thread is spawned, under which Runner's Handler gets its Looper
* from.
* </p>
*/
public void start() {
synchronized (this) {
if (!mStarted) {
_thread = new HandlerThread(
"IntentAutomaton runner instance");
_thread.start();
mIntentAutomatonHandler = new Handler(_thread.getLooper(),
_callback);
}
restart();
if (!mStarted) {
mIntentAutomatonInstance.mStates.get(mCurrentState).enter(
mIntentAutomatonHandler, runnerContext);
}
mStarted = true;
}
}
/**
* Is current Runner started
*
* @return true if started, false otherwise
*/
public boolean isStarted() {
return mStarted;
}
/**
* Is current Runner paused
*
* @return true if not started, or if {@link Runner#pause()} was
* previously called
*/
public boolean isPaused() {
return mStarted && mPaused;
}
/**
* Is current Runner running
*
* @return true if started and not paused
*/
public boolean isRunning() {
return mStarted && !mPaused;
}
/**
* Is current Runner stopped
*
* @return true if not started and paused (Runner{@link #stop()} was
* called)
*/
public boolean isStopped() {
return !mStarted && mPaused;
}
/**
* Forces enter action to be reran on current state
*/
public void reenter() {
mIntentAutomatonInstance.mStates.get(mCurrentState).enter(
mIntentAutomatonHandler, runnerContext);
}
/**
* Restarts current Runner
*
* <p>
* can Resume a Runner after a previous call to {@link Runner#pause()},
* or during {@link Runner#start()} to start the BroadcastReceiver.
* </p>
*/
public void restart() {
synchronized (this) {
IntentFilter ifilters = new IntentFilter();
for (String intent : mIntentAutomatonInstance.mIntents) {
ifilters.addAction(intent);
}
if (mPaused) {
mContext.registerReceiver(_receiver, ifilters);
mPaused = false;
}
}
}
/**
* Stops current Runner
*
* <p>
* Does nothing is Runner was not started.<br>
* Stopping a Runner will kill its internal thread, and resets all
* internal states.<br>
* <strong>A stopped Runner cannot be resumed!!</strong><br>
* A stopped Runner can be started again; in this case, current state
* will be reset to the initial state.<br>
* RunnerContext will not be reset.
* </p>
*/
public void stop() {
synchronized (this) {
pause();
if (mStarted) {
HandlerThread ht = _thread;
_thread = null;
if (null != ht) {
ht.quit();
ht.interrupt();
}
}
mStarted = false;
mPaused = true;
}
}
/**
* Pauses current Runner
*
* <p>
* Pausing a running Runner will unregister its BroadcastReceiver, until
* {@link Runner#restart()} is called.<br>
* Calling pause on a non running, non started Runner has no effect.
* </p>
*/
public void pause() {
synchronized (this) {
if (!mPaused) {
mContext.unregisterReceiver(_receiver);
}
mPaused = true;
}
}
/**
* Transitions manually.
*
* @param intent the Intent to send to running instances
*/
public void transition(Intent intent) {
mIntentAutomatonHandler
.obtainMessage(MSG_INTENT_RECEIVED, intent)
.sendToTarget();
}
// BroadcastReceiver : intercepts Intents watched by Transitions,
// then delegate to internal Handler.
private BroadcastReceiver _receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
mIntentAutomatonHandler
.obtainMessage(MSG_INTENT_RECEIVED, arg1)
.sendToTarget();
}
};
// This is the core of the Runner process :
// Each time an intent is intercepted by the BroadcastReceiver, a new
// message
// is posted to this Handler.
// It compares it to Intents registered by outgoing Transitions of
// current state
// and tries to traverse the first one it finds whose TransitionGuard
// returns false.
private class IntentAutomatonRunnerHandler implements Handler.Callback {
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case MSG_INTENT_RECEIVED:
Intent intent = (Intent) msg.obj;
Log.d(TAG, "Intent received : " + intent.getAction());
Map<Integer, List<Transition>> trList = mIntentAutomatonInstance.mTransitions
.get(mCurrentState);
if (null != trList && 0 < trList.size()) {
for (Entry<Integer, List<Transition>> trs : trList
.entrySet()) {
for (Transition tr : trs.getValue()) {
// Received intent matches expected intent for
// this transition
// Plus, the guard returned false : we perform
// the transition
if (intent.getAction().equals(tr.getIntent())) {
State from = mIntentAutomatonInstance.mStates
.get(mCurrentState);
State to = mIntentAutomatonInstance.mStates
.get(trs.getKey());
if (null == from || null == to) {
return false;
}
Log.d(TAG, "> Checking if transition " + from.getName() + " -> " + to.getName() + " is guarded");
if (tr.guarded(intent, runnerContext)) {
Log.d(TAG, ">> Transition guarded. Checking next");
continue;
}
// Transition while not in final state
if (FINAL_STATE != from.getType()) {
Log.d(TAG, ">> Transition not guarded, applying " + from.getName() + " -> " + to.getName());
from.exit(mIntentAutomatonHandler,
runnerContext);
tr.action(intent,
mIntentAutomatonHandler,
runnerContext);
to.enter(mIntentAutomatonHandler,
runnerContext);
mCurrentState = to.getStateId();
Intent i = new Intent(
INTENT_AUTOMATON_STATE_CHANGE);
i.putExtra(KEY_FROM_STATE,
from.getName());
i.putExtra(KEY_TO_STATE, to.getName());
i.putExtra(KEY_INTENT_TRANSITION,
tr.getIntent());
mContext.sendBroadcast(i);
}
if (FINAL_STATE == to.getType()) {
mIntentAutomatonHandler
.postDelayed(new Runnable() {
@Override
public void run() {
stop();
}
}, (null != to.getEnterAction())?(to.getEnterAction().getDelay()+1):0);
}
return true;
}
}
}
}
Log.d(TAG, "Automaton state after intent handling : " + mIntentAutomatonInstance.mStates.get(mCurrentState));
}
return false;
}
};
private final IntentAutomatonRunnerHandler _callback = new IntentAutomatonRunnerHandler();
};
/**
* Creates a new Runner to walk through this IntentAutomaton
*
* @see Runner#Runner(Context, IntentAutomaton)
* @param context
* @param g
* @return The new Runner instance
* @throws IntentAutomatonStateException
*/
public static Runner instantiate(Context context, IntentAutomaton g)
throws IntentAutomatonStateException {
return new Runner(context, g);
}
/**
* Creates a new Runner to walk through this IntentAutomaton, by supplying
* the RunnerContext it will use instead of letting it create its own.
*
* @see Runner#Runner(Context, IntentAutomaton,
* org.ymkm.lib.automaton.IntentAutomaton.Runner.RunnerContext)
* @param context
* @param g
* @param rContext
* @return The new Runner instance
* @throws IntentAutomatonStateException
*/
public static Runner instantiate(Context context, IntentAutomaton g,
Runner.RunnerContext rContext) throws IntentAutomatonStateException {
return new Runner(context, g, rContext);
}
/**
* Creates a new IntentAutomaton
*/
public IntentAutomaton() {
mStates = new HashMap<Integer, State>();
mTransitions = new SparseArray<Map<Integer, List<Transition>>>();
mIntents = new TreeSet<String>();
}
/*
* Public API to define states/transitions on the automaton
*/
/**
* Adds a state with specified ID and name. No enter/exit state action
*
* @see IntentAutomaton#addState(int, String, StateAction, StateAction)
* @param stateId
* the ID uniquely defining this state in current automaton
* @param name
* the automaton name
* @throws IntentAutomatonStateException
* if a state with the same ID was previously added
*/
public void addState(int stateId, String name)
throws IntentAutomatonStateException {
addState(stateId, name, null, null);
}
/**
* Adds a state with specified ID and name. No exit state action
*
* @see IntentAutomaton#addState(int, String, StateAction, StateAction)
* @param stateId
* the ID uniquely defining this state in current automaton
* @param name
* the automaton name
* @throws IntentAutomatonStateException
* if a state with the same ID was previously added
*/
public void addState(int stateId, String name, StateAction onEnterAction)
throws IntentAutomatonStateException {
addState(stateId, name, onEnterAction, null);
}
/**
* Adds a state with specified ID and name. Defines enter/exit action
*
* @param stateId
* the ID uniquely defining this state in current automaton
* @param name
* the automaton name
* @throws IntentAutomatonStateException
* if a state with the same ID was previously added
*/
public void addState(int stateId, String name, StateAction onEnterAction,
StateAction onExitAction) throws IntentAutomatonStateException {
State s;
if (mStates.containsKey(stateId)) {
throw new IntentAutomatonStateException("Error while adding state "
+ name + " : ID " + stateId + " already defined as name + "
+ mStates.get(stateId).getName());
}
if (null != onEnterAction && null != onExitAction) {
s = new State(this, stateId, name, onEnterAction, onExitAction);
} else if (null != onEnterAction) {
s = new State(this, stateId, name, onEnterAction);
} else {
s = new State(this, stateId, name);
}
mStates.put(stateId, s);
}
/**
* Defines a new transition linking "from" state to "to" state with given
* TransitionAction, reacting to specified Intent
*
* <p>
* No {@link TransitionGuard} is defined for this Transition.<br>
* Internally, it translates to a {@link NullTransitionGuard}.
* </p>
*
* @see IntentAutomaton#addTransition(int, int, String, TransitionAction,
* TransitionGuard)
* @param from
* the outgoing source state
* @param to
* the target state
* @param intent
* the Intent the Transition reacts to
* @param onTransitionAction
* the TransitionAction to perform during transition
*/
public void addTransition(int from, int to, String intent,
TransitionAction onTransitionAction) {
addTransition(from, to, intent, onTransitionAction,
new NullTransitionGuard());
}
/**
* Defines a new transition linking "from" state to "to" state,
* reacting to specified Intent. Defines a TransitionGuard.
* No action.
*
* <p>
* The transition will not be taken by the Runner if specified
* TransitionGuard returns true at the time of calling.
* </p>
*
* @see IntentAutomaton#addTransition(int, int, String, TransitionAction,
* TransitionGuard)
* @param from
* the outgoing source state
* @param to
* the target state
* @param intent
* the Intent the Transition reacts to
* @param g
* the TransitionGuard to check before traversing
*/
public void addTransition(int from, int to, String intent, TransitionGuard g) {
Map<Integer, List<Transition>> m;
List<Transition> l;
if (mTransitions.indexOfKey(from) < 0) {
l = new ArrayList<Transition>();
m = new HashMap<Integer, List<Transition>>();
m.put(to, l);
mTransitions.put(from, m);
} else {
m = mTransitions.get(from);
if (!m.containsKey(to)) {
l = new ArrayList<Transition>();
m.put(to, l);
} else {
l = m.get(to);
}
}
l.add(new Transition(intent, null, g));
// Add this intent to the list of intents to listen to
mIntents.add(intent);
}
/**
* Defines a new transition linking "from" state to "to" state with given
* TransitionAction, reacting to specified Intent. Defines a
* TransitionGuard.
*
* <p>
* The transition will not be taken by the Runner if specified
* TransitionGuard returns true at the time of calling.
* </p>
*
* @see IntentAutomaton#addTransition(int, int, String, TransitionAction,
* TransitionGuard)
* @param from
* the outgoing source state
* @param to
* the target state
* @param intent
* the Intent the Transition reacts to
* @param onTransitionAction
* the TransitionAction to perform during transition
* @param g
* the TransitionGuard to check before traversing
*/
public void addTransition(int from, int to, String intent,
TransitionAction onTransitionAction, TransitionGuard g) {
Map<Integer, List<Transition>> m;
List<Transition> l;
if (mTransitions.indexOfKey(from) < 0) {
l = new ArrayList<Transition>();
m = new HashMap<Integer, List<Transition>>();
m.put(to, l);
mTransitions.put(from, m);
} else {
m = mTransitions.get(from);
if (!m.containsKey(to)) {
l = new ArrayList<Transition>();
m.put(to, l);
} else {
l = m.get(to);
}
}
l.add(new Transition(intent, onTransitionAction, g));
// Add this intent to the list of intents to listen to
mIntents.add(intent);
}
/**
* Defines a new transition linking "from" state to "to" state,
* reacting to specified Intent. No TransitionGuard. No action.
*
* @see IntentAutomaton#addTransition(int, int, String, TransitionAction,
* TransitionGuard)
* @param from
* the outgoing source state
* @param to
* the target state
* @param intent
* the Intent the Transition reacts to
*/
public void addTransition(int from, int to, String intent) {
Map<Integer, List<Transition>> m;
List<Transition> l;
if (mTransitions.indexOfKey(from) < 0) {
l = new ArrayList<Transition>();
m = new HashMap<Integer, List<Transition>>();
m.put(to, l);
mTransitions.put(from, m);
} else {
m = mTransitions.get(from);
if (!m.containsKey(to)) {
l = new ArrayList<Transition>();
m.put(to, l);
} else {
l = m.get(to);
}
}
l.add(new Transition(intent, null, null));
// Add this intent to the list of intents to listen to
mIntents.add(intent);
}
/**
* Sets the initial state of current automaton. Must have one and only one!
*
* <p>
* The specified ID must be previously added to the automaton before this
* method is called.
* </p>
*
* @param stateId
* the state ID of the state to set as initial state.
*/
public void setInitialState(int stateId) {
if (mStates.containsKey(stateId)) {
mStates.get(stateId).setType(INITIAL_STATE);
}
}
/**
* Sets a final state on this Automaton. Can have multiple or none.
*
* <p>
* The specified ID must be previously added to the automaton before this
* method is called.
* </p>
*
* @param stateId
* the state ID of the state to set as a final state.
*/
public void setFinalState(int stateId) {
if (mStates.containsKey(stateId)) {
mStates.get(stateId).setType(FINAL_STATE);
}
}
}
| [
"[email protected]"
] | |
e4fefaddf77a863cc75e3bbcc044ebd19791e3d3 | e19d48046835e5edd1d2b18293b8b89039b41ffd | /library/src/main/java/io/jasonsparc/chemistry/internal/flasks/ReflectiveTypedFlask.java | 14f3d116ca595139252a080c0a3e4fe501796325 | [
"Apache-2.0"
] | permissive | CHH-Darick/Chemistry | 53da48e8abdf99d1780fd83cd47dc6236e80de4f | 210de9f2d78312cf092c207211a51a775f924b13 | refs/heads/master | 2021-01-17T23:33:56.527882 | 2016-07-31T12:45:09 | 2016-07-31T12:45:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 958 | java | package io.jasonsparc.chemistry.internal.flasks;
import android.support.annotation.AnyRes;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.View;
import android.view.ViewGroup;
import java.lang.reflect.Constructor;
import io.jasonsparc.chemistry.ViewType;
/**
* Created by jason on 07/07/2016.
*/
public abstract class ReflectiveTypedFlask<VH extends ViewHolder> extends TypedFlask<VH> {
@NonNull final Constructor<? extends VH> constructor;
protected ReflectiveTypedFlask(@ViewType @AnyRes int viewType, @NonNull Class<? extends VH> vhCls) {
super(viewType);
this.constructor = ReflectiveVhFactory.getConstructor(vhCls);
}
protected abstract View createView(ViewGroup parent);
@Override
public VH createViewHolder(ViewGroup parent) {
try {
return constructor.newInstance(createView(parent));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
| [
"[email protected]"
] | |
275047ed94662cf0bc8627eb7f8b63a30fd51b5a | 5afb7f3f77095ed7850646ff9e6d000eaa1fdc66 | /src/com/mobitide/common/utils/MDpUtil.java | 4bd66ae86fa4a4a4f28c11b6c9be1f4dd8f3406e | [] | no_license | 3c/MyLib | f8602bc0640c1577adddd5b39ae5ee65b8a8308a | a37ff128b662b7e9ba70297904541692ae9a7629 | refs/heads/master | 2021-01-19T08:26:07.624976 | 2014-03-23T15:54:26 | 2014-03-23T15:54:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 746 | java | /**
* Filename : DpUtil.java Author : CX Date : 2013-7-12
*
* Copyright(c) 2011-2013 Mobitide Android Team. All Rights Reserved.
*/
package com.mobitide.common.utils;
/**
* @author CX
*
*/
public class MDpUtil {
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/
public static int dip2px(float dpValue) {
float scale = MResUtil.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
/**
* 根据手机的分辨率从 px(像素) 的单位 转成为 dp
*/
public static int px2dip(float pxValue) {
float scale = MResUtil.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
}
| [
"[email protected]"
] | |
6f050eafdf62a176fe63b970744df9ee83782c97 | 35d826323cbba02486ca8ab9e95af5aeab492a5c | /moviesystem/moviesystem-model/src/main/java/com/entity/sales_record.java | 8ea86cb7d1a479ac683903bd52953368cd534531 | [] | no_license | CDT-Respository/MovieSystem | e4c0f82c12e5a1b4199e53971f7f776f38ce63c6 | 1aeb0582da877ae7db6a4fa1948884ad76d0a804 | refs/heads/master | 2021-07-20T18:05:06.735199 | 2017-10-29T13:47:20 | 2017-10-29T13:47:20 | 108,738,334 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,308 | java | package com.entity;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* Created by SChen on 2017/10/26.
* 售票记录表
*/
@Entity
@Table(name="sales_record")
public class sales_record implements Serializable{
private int sid; //售票id
private int sprice; //实收价格
private Date sales_date;//销售日期
private Movie movie; //电影
public sales_record() {
}
public sales_record(int sid, int sprice, Date sales_date) {
this.sid = sid;
this.sprice = sprice;
this.sales_date = sales_date;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public int getSid() {
return sid;
}
public void setSid(int sid) {
this.sid = sid;
}
public int getSprice() {
return sprice;
}
public void setSprice(int sprice) {
this.sprice = sprice;
}
public Date getSales_date() {
return sales_date;
}
public void setSales_date(Date sales_date) {
this.sales_date = sales_date;
}
@ManyToOne(cascade = CascadeType.REFRESH)
@JoinColumn(name = "smid")
public Movie getMovie() {
return movie;
}
public void setMovie(Movie movie) {
this.movie = movie;
}
}
| [
"[email protected]"
] | |
bfdb0589493b96bf795285c6cff3b3ea02990622 | 36d5adb5cf1faedef0e3b90f5dae9c21a83f0e7f | /src/Snake/GameLogic/BoardPosition.java | 0ae426cfbf2bcdc654c4d7c7ca4e9675a330e889 | [] | no_license | philippschiweck/RescueTrackSnake | 9d853dc5f4cb55ff0626f6a1245a573310d4f962 | 7c248db86cb99c9e5e99f6710a3ee43f3b6eb6ea | refs/heads/main | 2023-05-01T16:16:06.733237 | 2021-05-18T15:01:48 | 2021-05-18T15:01:48 | 366,400,572 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 967 | java | package Snake.GameLogic;
public class BoardPosition {
private int posX;
private int posY;
public BoardPosition(int posX, int posY){
this.posX = posX;
this.posY = posY;
}
public int getPosX() {
return posX;
}
public int getPosY() {
return posY;
}
public void setPos(int posX, int posY) {
this.posX = posX;
this.posY = posY;
}
@Override
public boolean equals(Object obj){
boolean equals;
if(obj == this){
equals = true;
}
else if(obj == null || obj.getClass() != this.getClass()){
equals = false;
} else {
BoardPosition boardPosition = (BoardPosition) obj;
if(boardPosition.getPosX() == this.posX && boardPosition.getPosY() == this.posY){
equals = true;
} else {
equals = false;
}
}
return equals;
}
}
| [
"[email protected]"
] | |
56c17389843a1caaa25d84fb2d1014bf96d7dbc1 | bff75bc953787f8dee210553916fedf38904a5f5 | /collections/src/main/java/com/gs/collections/impl/block/predicate/checked/CheckedPredicate2.java | 6e58540bc7d46bff2df3d7025ffb68913e23507e | [
"Apache-2.0"
] | permissive | paulbakker/gs-collections | ded9833a70cdb727026688fe3148527895c1761a | 378238ce3b0e13db99b2405e77ed4dd651369bea | refs/heads/master | 2020-12-11T07:32:57.596630 | 2014-09-30T22:58:34 | 2014-09-30T22:58:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,330 | java | /*
* Copyright 2011 Goldman Sachs.
*
* 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.gs.collections.impl.block.predicate.checked;
import com.gs.collections.api.block.predicate.Predicate2;
public abstract class CheckedPredicate2<T, P>
implements Predicate2<T, P>
{
private static final long serialVersionUID = 1L;
public boolean accept(T item, P param)
{
try
{
return this.safeAccept(item, param);
}
catch (RuntimeException e)
{
throw e;
}
catch (Exception e)
{
throw new RuntimeException("Checked exception caught in Predicate", e);
}
}
@SuppressWarnings("ProhibitedExceptionDeclared")
public abstract boolean safeAccept(T object, P param) throws Exception;
}
| [
"[email protected]"
] | |
7bd21c1d96443a17586f299d51a86b6b5cbf93b9 | 27a05017a11001c55bed3fc3b293328d84d84f9c | /src/servlet/SearchInsuranceServlet.java | 90ed1df5387670c3aa6139ceb94594d12f113922 | [] | no_license | mc2ion/vidamed-interfaz-vieja | c315dcf3c8e52221372c3ed3e9e11d861b47b822 | fa2ba039e3db1cb9ee418322c7132e6ad413b9a8 | refs/heads/master | 2021-07-03T14:22:33.041820 | 2021-05-26T04:29:02 | 2021-05-26T04:29:02 | 11,554,480 | 0 | 0 | null | 2021-05-20T03:26:46 | 2013-07-20T23:25:10 | Java | WINDOWS-1250 | Java | false | false | 4,072 | java | package servlet;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import command.CommandExecutor;
import domain.PaymentResponsible;
import domain.User;
/**
* Servlet implementation class SearchInsuranceServlet
*/
@WebServlet(description = "servlet to log in users", urlPatterns = { "/SearchInsuranceServlet" })
public class SearchInsuranceServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public void init() throws ServletException {
super.init();
try {
CommandExecutor.getInstance();
} catch (Exception e) {
throw new ServletException(e);
}
}
/**
* @see HttpServlet#HttpServlet()
*/
public SearchInsuranceServlet() {
super();
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
@SuppressWarnings("unchecked")
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession();
User userE = (User)session.getAttribute("user");
if(userE != null){
RequestDispatcher rd;
String function = request.getParameter("function");
String id = request.getParameter("id");
try {
ArrayList<PaymentResponsible> responsibles = (ArrayList<PaymentResponsible>) CommandExecutor.getInstance().executeDatabaseCommand(new command.GetPaymentResponsibles());
request.setAttribute("responsibles", responsibles);
request.setAttribute("function", function);
request.setAttribute("id", id);
rd = getServletContext().getRequestDispatcher("/searchInsurance.jsp");
rd.forward(request, response);
} catch (Exception e) {
}
} else {
request.setAttribute("time_out", "Su sesión ha expirado. Ingrese nuevamente"); RequestDispatcher rd = getServletContext().getRequestDispatcher("/index.jsp");
rd.forward(request, response);
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession();
User userE = (User)session.getAttribute("user");
if(userE != null){
String function = request.getParameter("function");
String id = request.getParameter("id");
String insurance = request.getParameter("paymentId");
String aval = request.getParameter("aval");
String isTitular = request.getParameter("titular");
String cedId = request.getParameter("cedId");
String cedula = request.getParameter("cedula");
String name = request.getParameter("name");
//Add Payment responsible
String identityCard = "";
if (cedula != null && !cedula.equals(""))
identityCard = cedId + cedula;
try {
int result = (Integer) CommandExecutor.getInstance().executeDatabaseCommand(
new command.AddEstimationPaymentResponsible(Long.valueOf(id), Long.valueOf(insurance), aval, isTitular, identityCard, name));
if (result == 1) {
session.setAttribute("text","Pago de responsable agregado exitosamente.");
}
else {
session.setAttribute("text","Hubo un problema al agregar el pago de responsable. Por favor intente nuevamente.");
}
if (function.equals("editHospitalization"))
response.sendRedirect(request.getContextPath() + "/EditHospitalizationServlet?id=" + id + "#tabs-2");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
request.setAttribute("time_out", "Su sesión ha expirado. Ingrese nuevamente"); RequestDispatcher rd = getServletContext().getRequestDispatcher("/index.jsp");
rd.forward(request, response);
}
}
}
| [
"[email protected]"
] | |
67838448981c9fbb7064018a24ad61debb52398f | 58f383bf7468b0e12449b80125725360091bafb9 | /UDPServer/src/Main.java | 78c3bc9e7a0ea870d6b34cb4fa2d73520cb136ed | [] | no_license | SachinBarpanda/NetWorking_Java | 1de277d2b2495ac97b5e3e1024cd8a151980897f | 1b79f2a6c3fe271f5fd8f254cdd02e57a3a9d546 | refs/heads/master | 2020-08-31T19:51:17.648058 | 2019-11-02T17:51:28 | 2019-11-02T17:51:28 | 218,770,856 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,199 | java | import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
public class Main {
public static void main(String[] args) {
try{
DatagramSocket socket = new DatagramSocket(5000);
while(true){
byte[] buffer = new byte[50];
DatagramPacket packet = new DatagramPacket(buffer,buffer.length);
socket.receive(packet);
System.out.println("Text received is : " + new String(buffer,0,packet.getLength()));
String returnString = "echo : "+new String(buffer,0 ,packet.getLength());
byte[] buffer2 = returnString.getBytes();
InetAddress address = packet.getAddress();
int port= packet.getPort();
packet = new DatagramPacket(buffer2,buffer2.length,address,port);
socket.send(packet);
}
}catch (SocketException e){
System.out.println("Socket Exception : " + e.getMessage());
}catch (IOException e){
System.out.println("IOException : " + e.getMessage());
}
}
}
| [
"[email protected]"
] | |
6482869331ee0304af2ac351779740fb01fb04b6 | 25f16bf903fd62756a4f94da64b09d6bfe61419c | /FileAuthSystem_module/src/main/java/pro/gravit/launchermodules/fileauthsystem/commands/GetUsersCommand.java | 489da11082fb202e4b7e19c3e492fa3f073af206 | [] | no_license | Taweryawer/LauncherModules | 09716698f71adf1093f423763b3f88b7aa6ff6f1 | 215fd13e8371232cb51c441d769016f4976e2c4e | refs/heads/master | 2023-03-05T22:13:11.678060 | 2021-02-15T16:40:57 | 2021-02-15T16:42:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,099 | java | package pro.gravit.launchermodules.fileauthsystem.commands;
import pro.gravit.launchermodules.fileauthsystem.FileAuthSystemModule;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public class GetUsersCommand extends Command {
private final FileAuthSystemModule module;
public GetUsersCommand(LaunchServer server, FileAuthSystemModule module) {
super(server);
this.module = module;
}
@Override
public String getArgsDescription() {
return "";
}
@Override
public String getUsageDescription() {
return "print all users data";
}
@Override
public void invoke(String... args) throws Exception {
int num = 0;
for(FileAuthSystemModule.UserEntity entity : module.getAllUsers()) {
LogHelper.info("[%s] UUID: %s | permissions %d | flags %d", entity.username, entity.uuid, entity.permissions.permissions, entity.permissions.flags);
num++;
}
LogHelper.info("Found %d users", num);
}
}
| [
"[email protected]"
] | |
d748505c5fbd489016652fe39be12f7df35f3804 | 69005ab4c8cc5d88d7996d47ac8def0b28730b95 | /android-medium/app/src/main/java/test/perf/MyPerfClass_1105.java | b982fd545f955f696565a7fcdf529c1c50309ba6 | [] | no_license | sakerbuild/performance-comparisons | ed603c9ffa0d34983a7da74f7b2b731dc3350d7e | 78cd8d7896c4b0255ec77304762471e6cab95411 | refs/heads/master | 2020-12-02T19:14:57.865537 | 2020-05-11T14:09:40 | 2020-05-11T14:09:40 | 231,092,201 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 803 | java | package test.perf;
public class MyPerfClass_1105{
private final String property;
public MyPerfClass_1105(String param) {
this.property = param;
}
public String getProperty() {
return property;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((property == null) ? 0 : property.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
MyPerfClass_1105 other = (MyPerfClass_1105) obj;
if (property == null) {
if (other.property != null)
return false;
} else if (!property.equals(other.property))
return false;
return true;
}
}
| [
"[email protected]"
] | |
d7fcedef89b871c3943e5845a7e6c995639ba9c1 | be16632b9c4bf9a4f72239779ba9510511b309db | /Current/Product/Production/Packages/FitNesse/Install/Product/FitNesse/Dev/fitnesse-plugins/src/com/targetprocess/integration/task/RetrieveAllForIterationResponse.java | d60a54e8794955f966730f8e18d2aca78632406b | [] | no_license | vardars/ci-factory | 7430c2afb577937fb598b5af3709990e674e7d05 | b83498949f48948d36dc488310cf280dbd98ecb7 | refs/heads/master | 2020-12-25T19:26:17.750522 | 2015-07-10T10:58:10 | 2015-07-10T10:58:10 | 38,868,165 | 1 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,849 | java |
package com.targetprocess.integration.task;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="RetrieveAllForIterationResult" type="{http://targetprocess.com}ArrayOfTaskDTO" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"retrieveAllForIterationResult"
})
@XmlRootElement(name = "RetrieveAllForIterationResponse")
public class RetrieveAllForIterationResponse {
@XmlElement(name = "RetrieveAllForIterationResult")
protected ArrayOfTaskDTO retrieveAllForIterationResult;
/**
* Gets the value of the retrieveAllForIterationResult property.
*
* @return
* possible object is
* {@link ArrayOfTaskDTO }
*
*/
public ArrayOfTaskDTO getRetrieveAllForIterationResult() {
return retrieveAllForIterationResult;
}
/**
* Sets the value of the retrieveAllForIterationResult property.
*
* @param value
* allowed object is
* {@link ArrayOfTaskDTO }
*
*/
public void setRetrieveAllForIterationResult(ArrayOfTaskDTO value) {
this.retrieveAllForIterationResult = value;
}
}
| [
"cifactory@571f4c53-cd24-0410-92e9-33dde47f2f63"
] | cifactory@571f4c53-cd24-0410-92e9-33dde47f2f63 |
efe73bf6eb98bcc7d18978addfcd096228e7a8ba | b54ba668cde3ce010c19eec13b79913d1ee73d38 | /spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/TaskSchedulerControllerTests.java | 3e510e0cd81826d149a3a16cd64691868ccd9850 | [
"Apache-2.0"
] | permissive | DoctusHartwald/spring-cloud-dataflow | 6246701c60805e000582d773a0a9baa94ce8fe6f | 926d1f8a4f4e05cd3a634a8119ab563de18aafa6 | refs/heads/master | 2020-03-20T02:47:30.301237 | 2018-06-04T20:21:33 | 2018-06-08T11:17:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,539 | java | /*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.dataflow.server.controller;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.dataflow.core.TaskDefinition;
import org.springframework.cloud.dataflow.server.configuration.TestDependencies;
import org.springframework.cloud.dataflow.server.repository.TaskDefinitionRepository;
import org.springframework.cloud.dataflow.server.service.SchedulerService;
import org.springframework.cloud.deployer.resource.registry.UriRegistry;
import org.springframework.cloud.scheduler.spi.core.ScheduleInfo;
import org.springframework.cloud.scheduler.spi.core.SchedulerPropertyKeys;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertEquals;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
* Tests for the {@link TaskSchedulerController}.
*
* @author Glenn Renfro
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestDependencies.class)
public class TaskSchedulerControllerTests {
@Autowired
SchedulerService schedulerService;
@Autowired
private WebApplicationContext wac;
@Autowired
private TaskDefinitionRepository repository;
@Autowired
private UriRegistry registry;
@Autowired
private TestDependencies.SimpleTestScheduler simpleTestScheduler;
private MockMvc mockMvc;
@Before
public void setupMockMVC() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(wac)
.defaultRequest(get("/").accept(MediaType.APPLICATION_JSON)).build();
}
@After
public void tearDown() {
repository.deleteAll();
assertEquals(0, repository.count());
simpleTestScheduler.getSchedules().clear();
}
@Test(expected = IllegalArgumentException.class)
public void testTaskSchedulerControllerConstructorMissingService() {
new TaskSchedulerController(null);
}
@Test
public void testListSchedules() throws Exception {
this.registry.register("task.testApp", new URI("file:src/test/resources/apps/foo-task"));
repository.save(new TaskDefinition("testDefinition", "testApp"));
createSampleSchedule("schedule1");
createSampleSchedule("schedule2");
mockMvc.perform(get("/tasks/schedules").accept(MediaType.APPLICATION_JSON)).
andDo(print()).andExpect(status().isOk()).
andExpect(jsonPath("$.content[*].scheduleName", containsInAnyOrder("schedule1","schedule2")))
.andExpect(jsonPath("$.content", hasSize(2)));
}
@Test
public void testListSchedulesByTaskDefinitionName() throws Exception {
this.registry.register("task.testApp", new URI("file:src/test/resources/apps/foo-task"));
repository.save(new TaskDefinition("foo", "testApp"));
repository.save(new TaskDefinition("bar", "testApp"));
createSampleSchedule("foo", "schedule1");
createSampleSchedule("bar", "schedule2");
mockMvc.perform(get("/tasks/schedules/instances/bar").accept(MediaType.APPLICATION_JSON)).
andDo(print()).andExpect(status().isOk()).
andExpect(jsonPath("$.content[*].scheduleName", containsInAnyOrder("schedule2")))
.andExpect(jsonPath("$.content", hasSize(1)));
}
@Test
public void testCreateSchedule() throws Exception {
this.registry.register("task.testApp", new URI("file:src/test/resources/apps/foo-task"));
repository.save(new TaskDefinition("testDefinition", "testApp"));
mockMvc.perform(post("/tasks/schedules/").param("taskDefinitionName", "testDefinition").
param("scheduleName", "mySchedule").
param("properties", "scheduler.testApp.spring.cloud.scheduler.cron.expression=* * * * *")
.accept(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isCreated());
assertEquals(1, simpleTestScheduler.list().size());
ScheduleInfo scheduleInfo = simpleTestScheduler.list().get(0);
assertEquals("mySchedule", scheduleInfo.getScheduleName());
assertEquals(1, scheduleInfo.getScheduleProperties().size());
assertEquals("* * * * *", scheduleInfo.getScheduleProperties().get("spring.cloud.scheduler.cron.expression"));
}
@Test
public void testRemoveSchedule() throws Exception {
this.registry.register("task.testApp", new URI("file:src/test/resources/apps/foo-task"));
repository.save(new TaskDefinition("testDefinition", "testApp"));
createSampleSchedule("mySchedule");
assertEquals(1, simpleTestScheduler.list().size());
mockMvc.perform(delete("/tasks/schedules/"+"mySchedule" ).accept(MediaType.APPLICATION_JSON)).andDo(print())
.andExpect(status().isOk());
assertEquals(0, simpleTestScheduler.list().size());
}
private void createSampleSchedule(String scheduleName) {
createSampleSchedule("testDefinition", scheduleName);
}
private void createSampleSchedule(String taskDefinitionName, String scheduleName) {
Map<String, String> properties = new HashMap<>();
properties.put("scheduler.testApp." + SchedulerPropertyKeys.CRON_EXPRESSION, "* * * * *");
schedulerService.schedule(scheduleName, taskDefinitionName,properties, null);
}
}
| [
"[email protected]"
] | |
f289413b80aefe8714f684cd75b4541b9561e970 | 8b2e9bcea32f23bc420ff977fdc7ca372a9e8a5e | /src/com/codegym/structural/facade/carsystem/FuelInjector.java | be015ad38524fbd0a2e661aefc852961254cb903 | [] | no_license | hoacg/Demo-Java-Design-Patterns | 2c6af3b2451df13651dac54ed317ca5ab437c956 | f4a2b9f6e82f83e68e6df5e527964a396d461e00 | refs/heads/master | 2021-03-17T19:02:17.058524 | 2020-05-13T03:30:01 | 2020-05-13T03:30:01 | 247,011,343 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 526 | java | package com.codegym.structural.facade.carsystem;
import com.codegym.creational.singleton.Logger;
public class FuelInjector {
private static final Logger LOGGER = Logger.getInstance();
private FuelPump fuelPump = new FuelPump();
public void on(){
LOGGER.info("Kim phun nhiên liệu đã sẵn sàng.");
}
public void inject() {
fuelPump.pump();
LOGGER.info("Nhiên liệu đã phun.");
}
public void off() {
LOGGER.info("Dừng phun nhiên liệu ..");
}
} | [
"[email protected]"
] | |
a7f009ffb59a844f444608723718a3e7d20f0290 | f1ea9e05998cece7d649601e82bafc38e2d48b03 | /app/src/main/java/com/yash/product_list/Product.java | bbc07b1d92ddb5350811bfe8bcee731343155529 | [] | no_license | Yash-Gupta-21/product_list | 4d149287156ef22d2c40a56ea7a6e5cf2c754e3a | f415e32116b17f07715b32f32eea3e2030ddbdc8 | refs/heads/master | 2023-08-11T09:22:42.696282 | 2021-09-15T12:50:54 | 2021-09-15T12:50:54 | 406,762,646 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 334 | java | package com.yash.product_list;
public class Product {
String name, lastMessage, country;
int imageId;
public Product(String name, String lastMessage, String country, int imageId) {
this.name = name;
this.lastMessage = lastMessage;
this.country = country;
this.imageId = imageId;
}
}
| [
"[email protected]"
] | |
55e7e7e5a485843b1e39be3f030c30f1a7189366 | 410c2b82bbd11885c60d1b8d45ea000aa6395d4c | /hello-service/src/main/java/ma/othmane/service/HelloService.java | 6ec4982bf8a589c8b30c360de6203a4b0101ead0 | [] | no_license | mothmane/undercover-spring-auto-config | 9a8f1f119c03beeb640b5643634a536bcca52015 | 31b3b5d00cdb89cf05790ae5d00fa1e5ffefd7c4 | refs/heads/master | 2020-04-13T00:34:14.407207 | 2018-12-22T23:26:47 | 2018-12-22T23:26:47 | 162,848,899 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 94 | java | package ma.othmane.service;
public interface HelloService {
public String sayHello();
}
| [
"[email protected]"
] | |
3d0877b705838b40860a593d920c859c43730e54 | 7c1f900833620da5f3f648f16aaa0f30976bcf96 | /src/main/java/com/kamadhenu/signalsusermanagement/config/SecurityConfig.java | d9bb04808ba7f5276049538645101272ddbce8ff | [] | no_license | charan490/signals-user-management | a9d242e142814f1f40b125dc82b704c0042592f2 | 7618e861ef24c6ccbf98578e45650f559217deea | refs/heads/master | 2020-09-14T00:21:08.965274 | 2019-11-20T15:34:38 | 2019-11-20T15:34:38 | 222,951,176 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,786 | java | package com.kamadhenu.signalsusermanagement.config;
import com.kamadhenu.signalsusermanagement.repository.security.UserRepository;
import com.kamadhenu.signalsusermanagement.service.domain.common.HelperService;
import com.kamadhenu.signalsusermanagement.service.domain.user.CustomUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* <h1>Custom Security Configuration</h1>
* <p>
* This custom class configures the security system for spring boot
*
* @author Kamadhenu
*/
@Configuration
@EnableJpaRepositories(basePackageClasses = UserRepository.class)
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(SecurityConfig.class);
private static final String LOGIN_URL = "/login";
private static final String LOGOUT_URL = "/logout";
private static final String LOGIN_SUCCESS_URL = "/admin/home";
private static final String LOGIN_ERROR_URL = "/login?error=true";
private static final String LOGOUT_SUCCESS_URL = "/";
private static final String USERNAME_PARAMETER = "email";
private static final String PASSWORD_PARAMETER = "password";
private static final String HOME_URL = "/admin/home/**";
private static final String API_URL = "/api/**";
private final List<String> ADMIN_URLS = new ArrayList<>(
Arrays.asList(
"/admin/security/user/**",
"/admin/home/**",
"/admin/general/**"
)
);
private final List<String> IGNORE_URLS = new ArrayList<>(
Arrays.asList(
"/resources/**",
"/static/**",
"/custom/**",
"/slim/**",
"/css/**",
"/js/**",
"/img/**",
"/xls/**",
"/lib/**"
)
);
@Autowired
private CustomUserService customUserService;
@Autowired
private HelperService helperService;
/**
* Configure security via custom user service
*
* @param auth the authentication manager
* @throws Exception the exception that is thrown
*/
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
LOGGER.debug("Configuring custom user details service");
auth.userDetailsService(customUserService).passwordEncoder(getPasswordEncoder());
}
/**
* Configure http security for various routes basis roles
*
* @param http the http security manager
* @throws Exception the exception that is thrown
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
LOGGER.debug("Configuring security");
///TODO Add logic to allow roles to be defined as constants
http.authorizeRequests()
.antMatchers(ADMIN_URLS.toArray(new String[ADMIN_URLS.size()])).hasRole("ADMIN")
.antMatchers(LOGOUT_SUCCESS_URL, LOGIN_URL, HOME_URL, API_URL).permitAll()
.anyRequest().authenticated()
.and().csrf().disable().formLogin()
.loginPage(LOGIN_URL)
.failureUrl(LOGIN_ERROR_URL)
.defaultSuccessUrl(LOGIN_SUCCESS_URL)
.successHandler(customAuthenticationSuccessHandler())
.usernameParameter(USERNAME_PARAMETER)
.passwordParameter(PASSWORD_PARAMETER)
.and().logout()
.logoutRequestMatcher(new AntPathRequestMatcher(LOGOUT_URL))
.logoutSuccessUrl(LOGOUT_SUCCESS_URL)
.deleteCookies("JSESSIONID")
.and().exceptionHandling()
.accessDeniedHandler(customAccessDeniedHandler());
}
/**
* Configure ignores for allowing access without security session
*
* @param web the web security manager
* @throws Exception the exception that is thrown
*/
@Override
public void configure(WebSecurity web) throws Exception {
LOGGER.debug("Configuring matchers for security");
web.ignoring().antMatchers(IGNORE_URLS.toArray(new String[IGNORE_URLS.size()]));
}
/**
* Custom password encoder
*
* @return the password encoder
*/
private PasswordEncoder getPasswordEncoder() {
LOGGER.debug("Configuring password encoder");
return new PasswordEncoder() {
@Override
public String encode(CharSequence charSequence) {
return charSequence.toString();
}
@Override
public boolean matches(CharSequence charSequence, String s) {
String encodedPassword = helperService.getMD5(charSequence.toString());
return encodedPassword.equals(s);
}
};
}
/**
* Login success handler bean
*
* @return the custom authentication handler
* @throws Exception the exception that is thrown
*/
public CustomAuthenticationSuccessHandler customAuthenticationSuccessHandler() throws Exception {
LOGGER.debug("Configuring custom authentication handler");
return new CustomAuthenticationSuccessHandler();
}
/**
* Custom access denied handler bean
*
* @return the custom access denied handler bean
* @throws Exception the exception that is thrown
*/
public AccessDeniedHandler customAccessDeniedHandler() throws Exception {
LOGGER.debug("Configuring custom access denied handler");
return new CustomAccessDeniedHandler();
}
}
| [
"[email protected]"
] | |
6da2ba2daf1a5c7345d06a98f9c65549ac79add3 | aae698b2aa98334ce55b97c37eca03c481f4ba20 | /app/src/main/java/com/teocfish/teoc_fish_pvt_ltd/EditProfile.java | 33086254e321b8fa637892e0022ff014a1924c58 | [] | no_license | freelanceapp/FishEcommerce | b297ccdf04951084ba8e99e27abfdc68b45cf42b | 3770dff5e3102dc2443df0f3c36cf4e6b67b241c | refs/heads/master | 2020-07-02T06:53:50.696300 | 2019-06-25T09:55:51 | 2019-06-25T09:55:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 911 | java | package com.teocfish.teoc_fish_pvt_ltd;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.widget.DrawerLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import butterknife.ButterKnife;
public class EditProfile extends Fragment {
View view;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_edit_profile, container, false);
ButterKnife.bind(this, view);
MainActivity.title.setText("Edit Profile");
return view;
}
@Override
public void onStart() {
super.onStart();
((MainActivity) getActivity()).lockUnlockDrawer(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
}
}
| [
"[email protected]"
] | |
577c397ccfd9b4bfb8951a3c4b22dd3923f919b4 | 92190acee10abcec7daff4f8cfe90198ed3f5827 | /app/src/main/java/com/rahmitufanoglu/roomdatabase/java/User2.java | 697e6b1e1b1b86d3c26b2586d0217bbce291b4a6 | [] | no_license | RahmiTufanoglu/room-sample | 1f1457f2e8673bd5158a9e1e3e1bb8cf813fa7ab | 89ff70ef7164c1bebe9b6c63cec1398bac0cd7ca | refs/heads/master | 2021-08-22T10:15:21.553218 | 2017-11-30T00:23:35 | 2017-11-30T00:23:35 | 112,543,216 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,223 | java | package com.rahmitufanoglu.roomdatabase.java;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
@Entity(tableName = "users")
public class User2 {
@PrimaryKey(autoGenerate = true)
private int id;
@ColumnInfo(name = "firstname")
private String firstname;
@ColumnInfo(name = "lastname")
private String lastname;
@ColumnInfo(name = "email")
private String email;
public User2(String firstname, String lastname, String email) {
this.firstname = firstname;
this.lastname = lastname;
this.email = email;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
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;
}
} | [
"[email protected]"
] | |
d85d9f25cbfe0da47036e6bed1889a598c3ab401 | 7e1af8ed0534fb8a3be3c2bfe1adb3708674b12c | /annotation-file-utilities/src/main/java/org/checkerframework/afu/scenelib/util/CommandLineUtils.java | 22d1f8d509516fa272702ef299a92183e9cce234 | [
"MIT"
] | permissive | typetools/annotation-tools | 497fb88af09264e837b7bd9e749ca85103d1968f | 4c6af746506285621eaa5f45eb5cfb3178dc0bd7 | refs/heads/master | 2023-09-01T23:55:58.255765 | 2023-09-01T13:07:51 | 2023-09-01T13:07:51 | 38,488,180 | 47 | 39 | MIT | 2023-09-14T16:35:05 | 2015-07-03T10:54:25 | Java | UTF-8 | Java | false | false | 1,404 | java | package org.checkerframework.afu.scenelib.util;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
/** Handle javac class {@code CommandLine} under all versions of the JDK. */
public class CommandLineUtils {
/**
* Calls {@code CommandLine.parse}, handling both JDK 8-11 (where it takes and returns arrays) and
* later JDKs, where it takes and returns a list.
*
* @param args the command line
* @return the result of calling {@code CommandLine.parse}
*/
public static String[] parseCommandLine(String[] args) {
try {
Class<?> clazz;
try {
clazz = Class.forName("com.sun.tools.javac.main.CommandLine");
} catch (ClassNotFoundException e) {
clazz = Class.forName("jdk.internal.opt.CommandLine");
}
try {
Method method = clazz.getMethod("parse", List.class);
return ((List<?>) method.invoke(null, Arrays.asList(args))).toArray(new String[0]);
} catch (NoSuchMethodException e) {
Method method = clazz.getMethod("parse", String[].class);
return (String[]) method.invoke(null, (Object) args);
}
} catch (IllegalAccessException
| NoSuchMethodException
| InvocationTargetException
| ClassNotFoundException e) {
throw new Error("Cannot access CommandLine.parse", e);
}
}
}
| [
"[email protected]"
] | |
67c81869e86680b69aa8fdce5e745118d07215d8 | 80da19b4d011cd9ad8850bf68d1724109e13a9ac | /src/main/java/pl/com/britenet/hospital/service/HospitalService.java | b60918025ce48c78521bd3afdc42367a5ae03681 | [] | no_license | piotrslowinski/hospital | eb1bcf3809e499f22c2579d4be050784b6c66e93 | 5fc81b2b096e61a3bfebed848c568644437f37db | refs/heads/master | 2020-03-28T17:30:07.073713 | 2018-09-17T08:18:10 | 2018-09-17T08:18:10 | 148,795,637 | 0 | 0 | null | 2018-09-17T08:18:11 | 2018-09-14T13:53:35 | Java | UTF-8 | Java | false | false | 6,945 | java | package pl.com.britenet.hospital.service;
import java.time.LocalDate;
import java.util.Collection;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Optional;
import javax.transaction.Transactional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pl.com.britenet.hospital.domain.Doctor;
import pl.com.britenet.hospital.domain.DoctorAssignment;
import pl.com.britenet.hospital.domain.Hospital;
import pl.com.britenet.hospital.repository.DoctorRepository;
import pl.com.britenet.hospital.repository.HospitalRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class HospitalService {
private static final Logger log = LoggerFactory.getLogger(HospitalService.class);
private final HospitalRepository hospitalRepository;
private final DoctorRepository doctorRepository;
@Autowired
public HospitalService(HospitalRepository hospitalRepository, DoctorRepository doctorRepository) {
this.hospitalRepository = hospitalRepository;
this.doctorRepository = doctorRepository;
}
public Hospital createHospital(Hospital hospital) {
Optional<Hospital> hospitalOptional = findHospitalByName(hospital.getName());
if (hospitalOptional.isPresent()) {
throw new IllegalArgumentException("hospital with this name already exists");
} else if (!isFieldValid("name", hospital.getName())) {
log.debug("field validation error");
}
Hospital newHospital = new Hospital(
hospital.getName(),
hospital.getCountry(),
hospital.getTown(),
hospital.getStreet(),
hospital.getPostalCode(),
hospital.getPhoneNumber(),
hospital.getFaxNumber(),
hospital.getNumberOfAmbulances(),
hospital.isHelicopterAccess(),
hospital.isTeachingHospital()
);
saveHospital(newHospital);
return newHospital;
}
private Optional<Hospital> findHospitalByName(String name) {
return this.hospitalRepository.findByName(name);
}
@Transactional
private void saveHospital(Hospital hospital) {
this.hospitalRepository.save(hospital);
}
public Hospital updateHospital(Long hospitalId, Hospital hospital) {
Hospital hospitalToUpdate = findHospitalById(hospitalId).get();
if (!(hospital.getName() == null)) {
hospitalToUpdate.setName(hospital.getName());
}
if (!(hospital.getCountry() == null)) {
hospitalToUpdate.setCountry(hospital.getCountry());
}
if (!(hospital.getTown() == null)) {
hospitalToUpdate.setTown(hospital.getTown());
}
if (!(hospital.getStreet() == null)) {
hospitalToUpdate.setStreet(hospital.getStreet());
}
if (!(hospital.getPostalCode() == null)) {
hospitalToUpdate.setPostalCode(hospital.getPostalCode());
}
if (!(hospital.getPhoneNumber() == null)) {
hospitalToUpdate.setPhoneNumber(hospital.getPhoneNumber());
}
if (!(hospital.getFaxNumber() == null)) {
hospitalToUpdate.setFaxNumber(hospital.getFaxNumber());
}
if (!(hospital.getNumberOfAmbulances() == 0)) {
hospitalToUpdate.setNumberOfAmbulances(hospital.getNumberOfAmbulances());
}
hospitalToUpdate.setHelicopterAccess(hospital.isHelicopterAccess());
hospitalToUpdate.setTeachingHospital(hospital.isTeachingHospital());
saveHospital(hospitalToUpdate);
return hospitalToUpdate;
}
public Optional<Hospital> findHospitalById(Long hospitalId) {
Optional<Hospital> hospitalOptional = this.hospitalRepository.findById(hospitalId);
if (!hospitalOptional.isPresent()) {
throw new NoSuchElementException("hospital with this id doesn't exist");
}
return hospitalOptional;
}
public List<Hospital> getAllHospitals() {
return this.hospitalRepository.findAll();
}
public void deleteHospital(Long hospitalId) {
Hospital hospital = findHospitalById(hospitalId).get();
this.hospitalRepository.delete(hospital);
}
public void assignNewDoctor(Long hospitalId, Long doctorId) {
Doctor doctor = findDoctorById(doctorId).get();
Hospital hospital = findHospitalById(hospitalId).get();
Optional<DoctorAssignment> assignmentOptional = getCurrentAssignments(hospital, doctor);
if (assignmentOptional.isPresent()) {
throw new IllegalArgumentException("doctor already works in this hospital");
}
assignDoctor(hospital, doctor);
saveHospital(hospital);
}
public Optional<Doctor> findDoctorById(Long doctorId) {
Optional<Doctor> doctorOptional = this.doctorRepository.findById(doctorId);
if (!doctorOptional.isPresent()) {
throw new NoSuchElementException("doctor with this id doesn't exist");
}
return doctorOptional;
}
private void assignDoctor(Hospital hospital, Doctor doctor) {
DoctorAssignment newAssignment = new DoctorAssignment(hospital, doctor);
Collection<DoctorAssignment> assignments = hospital.getDoctorAssignments();
assignments.add(newAssignment);
}
public void unassignTheDoctorFromHospital(Long hospitalId, Long doctorId) {
Doctor doctor = findDoctorById(doctorId).get();
Hospital hospital = findHospitalById(hospitalId).get();
Optional<DoctorAssignment> assignmentOptional = getCurrentAssignments(hospital, doctor);
if (!assignmentOptional.isPresent()) {
throw new IllegalArgumentException("doctor doesn't work in this hospital");
}
unassignDoctor(assignmentOptional.get());
saveHospital(hospital);
}
private void unassignDoctor(DoctorAssignment assignment) {
assignment.setContractEndDate(LocalDate.now());
}
private Optional<DoctorAssignment> getCurrentAssignments(Hospital hospital, Doctor doctor) {
return hospital.getDoctorAssignments().stream()
.filter((a) -> a.getDoctor()
.equals(doctor)).filter((assignment -> isAssignmentCurrent(assignment))).findFirst();
}
private boolean isAssignmentCurrent(DoctorAssignment assignment) {
return (assignment.getContractEndDate().isAfter(LocalDate.now()) &&
assignment.getContractStartDate().isBefore(assignment.getContractEndDate()));
}
private boolean isFieldValid(String field, String value) {
if (value == null || value.trim().length() == 0) {
throw new IllegalArgumentException(String.format("the %s field has not been filled out", field));
}
return true;
}
}
| [
"[email protected]"
] | |
acad45f4276f859fdfa21a94eb0c33fd1b1f18c3 | c1562d17a91d30af6697dfe517d52c0d64e886c3 | /02-spring-boot-static-resources1/src/main/java/com/szr/PropertiesTestBean.java | fa632df5c3f7418731548d7b007b62ce79b4ffe8 | [] | no_license | a546835886/spring-boot | 5cab0e7d8047c0f5980b4bf1872f9b36429e0714 | b8e899393053ca76969700fb837a5efeb9114f77 | refs/heads/master | 2022-06-26T00:30:04.513829 | 2019-09-28T09:15:57 | 2019-09-28T09:15:57 | 166,989,668 | 0 | 0 | null | 2022-06-17T02:28:59 | 2019-01-22T12:22:48 | Java | UTF-8 | Java | false | false | 1,013 | java | package com.szr;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* <注解读取配置文件测试类>
* <功能详细描述>
* @author wzh
* @version 2018-06-30 18:55
* @see [相关类/方法] (可选)
**/
@Component
@PropertySource(value = "classpath:static/file/test.properties",encoding = "utf-8")
public class PropertiesTestBean {
//在application.properties中的文件,直接使用@Value读取即可,applicarion的读取优先级最高
@Value("${test.name}")
private String name;
@Value("${test.sex}")
private String sex;
@Value("${test.age}")
private Long age;
//省略get set toString方法..........
@Override
public String toString() {
return "PropertiesTestBean{" +
"name='" + name + '\'' +
", sex='" + sex + '\'' +
", age=" + age +
'}';
}
} | [
"[email protected]"
] | |
21efd3b7d32629ce34579bb323ba8767443cc774 | bf690dedc85d1944284cfb11a5f526a0ec81bb26 | /src/main/java/com/job/siteapp/controller/HomeController.java | bde433d3be9adcf8309f94845fff6afb68803656 | [] | no_license | thremains/siteapp | 2c339941c3a959d71ea21eb98155456bfa382340 | fac12a13e87c886ffe9fbb7a412b96001b770e7e | refs/heads/master | 2021-01-20T22:19:05.228234 | 2016-06-01T14:45:34 | 2016-06-01T14:45:34 | 60,094,312 | 2 | 2 | null | 2016-05-31T16:17:33 | 2016-05-31T13:59:19 | Java | UTF-8 | Java | false | false | 1,056 | java | package com.job.siteapp.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.job.siteapp.common.globality.BaseController;
import com.job.siteapp.service.HomeService;
/**
* 主页相关请求
*
* @author seanwg
* 2016-6-1 下午09:10:09
*/
@Controller
public class HomeController extends BaseController {
@Resource
private HomeService homeService;
@RequestMapping(value = "index.htm", method = RequestMethod.GET)
public String home(HttpServletRequest request) {
request.setAttribute("result", homeService.sayHello());
return "index";
}
/**
* 因为要测试GET/POST方法,所以不指定该请求的类型
* @param request
* @return
*/
@RequestMapping(value = "test")
public String test(HttpServletRequest request) {
int a = 5/0;
return "index";
}
}
| [
"[email protected]"
] | |
28d843a549fa8345a487c412528b43f5ad921909 | 24d8cf871b092b2d60fc85d5320e1bc761a7cbe2 | /Jmol/rev11338-11838/left-branch-11838/src/org/openscience/jmol/app/jmolpanel/RecentFilesDialog.java | 526c264da6b9aef37360a0a829b031a397836b2b | [] | no_license | joliebig/featurehouse_fstmerge_examples | af1b963537839d13e834f829cf51f8ad5e6ffe76 | 1a99c1788f0eb9f1e5d8c2ced3892d00cd9449ad | refs/heads/master | 2016-09-05T10:24:50.974902 | 2013-03-28T16:28:47 | 2013-03-28T16:28:47 | 9,080,611 | 3 | 2 | null | null | null | null | UTF-8 | Java | false | false | 4,250 | java |
package org.openscience.jmol.app.jmolpanel;
import java.awt.event.ActionListener;
import java.awt.event.WindowListener;
import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.ListSelectionModel;
import javax.swing.JList;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import org.jmol.i18n.GT;
import org.openscience.jmol.app.jmolpanel.JmolPanel;
class RecentFilesDialog extends JDialog implements ActionListener,
WindowListener {
String selectedFileName = null;
private static final int MAX_FILES = 10;
private JButton okButton;
private JButton cancelButton;
String[] files = new String[MAX_FILES];
JList fileList;
java.util.Properties props;
public RecentFilesDialog(java.awt.Frame boss) {
super(boss, GT._("Recent Files"), true);
props = new java.util.Properties();
getFiles();
getContentPane().setLayout(new java.awt.BorderLayout());
JPanel buttonPanel = new JPanel();
okButton = new JButton(GT._("Open"));
okButton.addActionListener(this);
buttonPanel.add(okButton);
cancelButton =
new JButton(GT._("Cancel"));
cancelButton.addActionListener(this);
buttonPanel.add(cancelButton);
getContentPane().add("South", buttonPanel);
fileList = new JList(files);
fileList.setSelectedIndex(0);
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
MouseListener dblClickListener = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
int dblClickIndex = fileList.locationToIndex(e.getPoint());
if (dblClickIndex >= 0 &&
dblClickIndex < files.length &&
files[dblClickIndex] != null) {
selectedFileName = files[dblClickIndex];
close();
}
}
}
};
fileList.addMouseListener(dblClickListener);
getContentPane().add("Center", fileList);
setLocation(100, 100);
pack();
}
private void getFiles() {
props = JmolPanel.historyFile.getProperties();
for (int i = 0; i < MAX_FILES; i++) {
files[i] = props.getProperty("recentFilesFile" + i);
}
}
public void addFile(String name) {
int currentPosition = -1;
for (int i = 0; i < MAX_FILES; i++) {
if ((files[i] != null) && files[i].equals(name)) {
currentPosition = i;
}
}
if (currentPosition == 0) {
return;
}
if (currentPosition > 0) {
for (int i = currentPosition; i < MAX_FILES - 1; i++) {
files[i] = files[i + 1];
}
}
for (int j = MAX_FILES - 2; j >= 0; j--) {
files[j + 1] = files[j];
}
files[0] = name;
fileList.setListData(files);
fileList.setSelectedIndex(0);
pack();
saveList();
}
public void saveList() {
for (int i = 0; i < 10; i++) {
if (files[i] != null) {
props.setProperty("recentFilesFile" + i, files[i]);
}
}
JmolPanel.historyFile.addProperties(props);
}
public String getFile() {
return selectedFileName;
}
public void windowClosing(java.awt.event.WindowEvent e) {
cancel();
close();
}
void cancel() {
selectedFileName = null;
}
void close() {
hide();
}
public void actionPerformed(java.awt.event.ActionEvent e) {
if (e.getSource() == okButton) {
int fileIndex = fileList.getSelectedIndex();
if (fileIndex < files.length) {
selectedFileName = files[fileIndex];
close();
}
} else if (e.getSource() == cancelButton) {
cancel();
close();
}
}
public void windowClosed(java.awt.event.WindowEvent e) {
}
public void windowOpened(java.awt.event.WindowEvent e) {
}
public void windowIconified(java.awt.event.WindowEvent e) {
}
public void windowDeiconified(java.awt.event.WindowEvent e) {
}
public void windowActivated(java.awt.event.WindowEvent e) {
}
public void windowDeactivated(java.awt.event.WindowEvent e) {
}
public void notifyFileOpen(String fullPathName) {
if (fullPathName != null)
addFile(fullPathName);
}
}
| [
"[email protected]"
] | |
957694b98eee8eeb0a8ed6e072ffd34b5e3d0ca8 | dce0e8788729bc93fa9b5aaa5bb9bdb3e7df91f5 | /bot/src/main/java/commands/GutCommand.java | ee3962a1137109438b2ef9c7163166ab23ba2173 | [
"Apache-2.0"
] | permissive | SzymanskiFilip/multibot | c6ce224c7834d0c5de811e5f68de24d36ad0970b | 6cdf51a5ae227f355bcef6d2cffc24575dc1802a | refs/heads/main | 2023-07-28T19:29:43.016756 | 2021-09-06T17:17:02 | 2021-09-06T17:17:02 | 402,884,700 | 0 | 0 | Apache-2.0 | 2021-09-03T20:00:15 | 2021-09-03T20:00:15 | null | UTF-8 | Java | false | false | 322 | java | package commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
public class GutCommand {
public static void gut(GuildMessageReceivedEvent event, String message){
String args = message.replace("!gut ","");
event.getChannel().sendMessage("Toll " + args).queue();
}
}
| [
"[email protected]"
] | |
b67f0d98af5b442178b55ef065e94c3b8df5a004 | 1f91fc16e201532df0825de803cd2c5b9a27bd8d | /src/main/java/com/zust/bean/TUserRelation.java | a64b8ba669dfbcddb827e5fcd5c5a2b6e3537337 | [] | no_license | KGzooey/NoteBook | e4a8d30b75f4107dfdbf44b7d55b3c6bae976a2b | d64f6e12b71699095e48babbfe748436e19af68e | refs/heads/master | 2020-04-12T17:39:49.649999 | 2018-12-26T09:46:57 | 2018-12-26T09:46:57 | 162,652,791 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,200 | java | package com.zust.bean;
import javax.persistence.*;
import java.util.Date;
/**
* @description: 用户关注,用户黑名单
* @create: 2018-12-22 15:57
**/
@Entity
@Table(name = "user_relation")
public class TUserRelation {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column private Integer type;
@Column private Integer relater;
@Column private Integer relatered;
@Column private Date operateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getRelater() {
return relater;
}
public void setRelater(Integer relater) {
this.relater = relater;
}
public Integer getRelatered() {
return relatered;
}
public void setRelatered(Integer relatered) {
this.relatered = relatered;
}
public Date getOperateTime() {
return operateTime;
}
public void setOperateTime(Date operateTime) {
this.operateTime = operateTime;
}
}
| [
"[email protected]"
] | |
94800c815daa2b17f2748db5c708a9ab6c4df124 | d945aab9d4be063d30f1ae4bc153c1461f261927 | /app/src/main/java/sharedpreference/HistorySharedPreference.java | 9fe91f51cf0efc9720663239729722bea37e6428 | [] | no_license | joker1122/iptv | 508a86c8b7b9257c3b843afffb2a27ecb86bcb81 | 193d40ac4dacdd39265129f62fd70a4ca48b67b0 | refs/heads/master | 2020-03-09T18:26:18.198481 | 2018-04-10T12:45:51 | 2018-04-10T12:45:51 | 128,152,892 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,649 | java | package sharedpreference;
import android.content.Context;
import android.content.SharedPreferences;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
/**
* Created by PC-001 on 2018/4/9.
*/
public class HistorySharedPreference {
public static final int MAX_SIZE = 3;
private SharedPreferences mSharedPreferences;
private SharedPreferences.Editor mEditor;
private Set<String> mStringSet = new HashSet<>();
public HistorySharedPreference(Context context) {
mSharedPreferences = context.getSharedPreferences("history", Context.MODE_PRIVATE);
mEditor = mSharedPreferences.edit();
mStringSet = mSharedPreferences.getStringSet("value", new HashSet<String>());
}
public void add(String history) {
if (mStringSet.size() == MAX_SIZE) {
deleteFirst();
}
mStringSet.add(history);
mEditor.putStringSet("value", mStringSet);
}
public void delete(String value) {
mStringSet.remove(value);
mEditor.putStringSet("value", mStringSet);
}
public ArrayList<String> readSet() {
ArrayList<String> list = new ArrayList<>();
Iterator<String> iterator = mStringSet.iterator();
while (iterator.hasNext()) {
list.add(iterator.next());
}
return list;
}
private void deleteFirst() {
Iterator<String> iterator = mStringSet.iterator();
mStringSet.clear();
if (iterator.hasNext()) {
while (iterator.hasNext()) {
mStringSet.add(iterator.next());
}
}
}
}
| [
"="
] | = |
681ea870eec2d4b0b4240c7c270c9389764f1cf5 | 53870a5a683f8a3a2efaf33608b9867e675df6c2 | /ProcessPension/src/test/java/com/cognizant/processpension/model/AuthResponseTest.java | 60db4848bb3f02c5b60aa6522ea667313a30a748 | [] | no_license | TanviChandak/Cognizant-project- | 4cc81fbefc075c64c7a333ea1f226b0466fd8c3f | 84e49b4a7d0fdec9325428ba1b9e103dae62d52e | refs/heads/main | 2023-05-30T21:55:56.200219 | 2021-06-22T16:02:44 | 2021-06-22T16:02:44 | 379,198,852 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,048 | java | package com.cognizant.processpension.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.boot.test.context.SpringBootTest;
//@RunWith(SpringRunner.class)
@ExtendWith(MockitoExtension.class)
@SpringBootTest
class AuthResponseTest
{
AuthResponse authResponse=new AuthResponse();
@Test
void testAuthResponseConstructor()
{
AuthResponse response=new AuthResponse("abc", true);
assertEquals("abc",response.getUid() );
}
@Test
void testUid()
{
authResponse.setUid("abc");
authResponse.setValid(true);
assertEquals( "abc",authResponse.getUid());
}
@Test
void testIsValid()
{
authResponse.setValid(true);
assertEquals(true, authResponse.isValid() );
}
@Test
void testtoString()
{
String s = authResponse.toString();
assertEquals(authResponse.toString(), s);
}
}
| [
"[email protected]"
] | |
e0153d6c559a843e7259a2f693670d10983e6e60 | 2be9fe63065199c4123e810a2a2a0b0a998c9874 | /src/main/java/mainpackage/Person.java | 576563488aea168a77da6b8450f62821562b87c1 | [] | no_license | kharann/TDT4145_Databaseprosjekt | c661832ba08cfabe872895d37bc3561037d065bc | 746c987df95fc4f3b9a0543030f676c61c269c06 | refs/heads/master | 2021-03-12T00:29:32.471899 | 2020-03-06T18:04:55 | 2020-03-06T18:04:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,245 | java | package mainpackage;
import avtalebok.ActiveDomainObject;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
public class Person extends ActiveDomainObject {
private int personid;
private String navn;
private int fodselsaar;
private String fodselsland;
public Person(int personid) {
this.personid = personid;
}
public int getId() {
return this.personid;
}
public void initialize(Connection conn) {
try {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from person where id=" + this.personid);
if(!rs.next()) {
System.out.println("User not found!");
return;
}
rs.previous();
while (rs.next()) {
navn = rs.getString("navn");
fodselsaar = rs.getInt("fodselsaar");
fodselsland = rs.getString("fodselsland");
System.out.println(personid + " " + navn + " " + fodselsaar + " " + fodselsland);
}
} catch (Exception e) {
System.out.println("db error during select of bruker= " + e);
return;
}
}
@Override
public void refresh(Connection conn) {
initialize(conn);
}
@Override
public void save(Connection conn) {
}
}
| [
"Olaussen99"
] | Olaussen99 |
4f20b7385e841700220cb70789ba27869cff3bd6 | ddd3fa932c1273ceab6007a80288c20ea14ea1cb | /src/main/java/com/shengsiyuan/jdk8/methodreference/StudentComparator.java | 7e2286134b0854cb1a6bac958bc48b2efcccfca6 | [] | no_license | poluanjingtian/nettyAndJdk8 | 6661ba6741cc349b3001d04d03fc46089d3cbbc6 | 754306cefa76518853d7bb3e3e6e761905f4bcb9 | refs/heads/master | 2020-08-07T07:02:06.394493 | 2019-10-12T14:55:22 | 2019-10-12T14:55:22 | 213,345,114 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 469 | java | package com.shengsiyuan.jdk8.methodreference;
/**
* Created with IntelliJ IDEA.
*
* @author: renBin
* @date: 2019/4/7 1:58
* Description:
*/
public class StudentComparator {
public int compareStudentByScore(Student student1, Student student2) {
return student1.getScore() - student2.getScore();
}
public int compareStudentByName(Student student1, Student student2) {
return student1.getName().compareTo(student2.getName());
}
}
| [
"[email protected]"
] | |
0b4a72c7367ac825a4ba224e303e0565dd0c4dcf | 44c66d5641af697d3f6c79c05b8e45091970f9fc | /src/main/java/pl/polishstation/polishstationbackend/domain/fuel/fuelprice/validation/PrecisionValidator.java | f75a944b76a31d1b4a0ba28ccfcbebd384f2f8a2 | [] | no_license | Witach/PolishStationRestAPI | cf64b02d74c67178eb58373fab6fea83500aa79b | bf99faeff317e83b53238625a4977ab5a6788d2c | refs/heads/master | 2023-03-07T20:41:02.518951 | 2021-02-19T21:11:07 | 2021-02-19T21:11:07 | 295,815,507 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 639 | java | package pl.polishstation.polishstationbackend.domain.fuel.fuelprice.validation;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class PrecisionValidator implements ConstraintValidator<Precision, Double> {
public void initialize(Precision constraint) {
}
public boolean isValid(Double obj, ConstraintValidatorContext context) {
var moneyLabel = Double.toString(obj);
return !moneyLabel.contains(".") || checkForPrecision(moneyLabel);
}
private boolean checkForPrecision(String moneyLabel) {
return moneyLabel.split("\\.")[1].length() <= 2;
}
}
| [
"[email protected]"
] | |
7f6f9c5499d3ca56d71742406a209963c474553f | 1647bc072d206453f20410e21908f0958c7ac8f2 | /app/src/main/java/ro/example/myapplication/lab3/MainActivity.java | d063bafccb3f2a74b30a7754a82c0e22823bc711 | [] | no_license | DobrescuAnca/LaboratorAndroid2021 | cb260ca0cb70422523e243d8bac8a55ab02745f6 | 8c44b354204afac9b4ac9c972f38670362c9096d | refs/heads/main | 2023-03-25T08:01:28.337798 | 2021-03-23T19:16:01 | 2021-03-23T19:16:01 | 343,522,506 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,536 | java | package ro.example.myapplication.lab3;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import ro.example.myapplication.R;
public class MainActivity extends AppCompatActivity implements UserOperations {
public final static String PREFERENCES_KEY = "preferences key";
public final static String PREFERENCES_ID_KEY = "preferences id key";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_lab3);
findViewById(R.id.button).setOnClickListener(view ->
// makePreferences()
insertUsers()
);
findViewById(R.id.button_getName).setOnClickListener(view ->
new FindUserOperation(this).execute("Irina")
);
// UserDao userDao = MyApplication.getAppDatabase().userDao();
// List<User> users = userDao.getAll();
}
private void makePreferences() {
// SharedPreferences preferences = getPreferences(Context.MODE_PRIVATE);
SharedPreferences preferences = getSharedPreferences(PREFERENCES_KEY, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt(PREFERENCES_ID_KEY, 10);
editor.apply();
int id = preferences.getInt(PREFERENCES_ID_KEY, 0);
Toast.makeText(this, id, Toast.LENGTH_LONG).show();
}
private void insertUsers(){
User user1 = new User(
1,
"Irina",
"Popescu",
20
);
User user2 = new User(
2,
"Cristi",
"Andrei",
18
);
User[] userList = new User[]{user1, user2};
new InsertUserOperation(this).execute(userList);
}
@Override
public void insertUsers(String result) {
if(result.equals("success"))
Toast.makeText(this, "Users inserted in the database sucessfully", Toast.LENGTH_LONG).show();
else
Toast.makeText(this, "Users inserted in the database failed", Toast.LENGTH_LONG).show();
}
@Override
public void findUser(User user) {
if(user != null)
Toast.makeText(this, user.firstName + " is " + user.age, Toast.LENGTH_LONG).show();
else
Toast.makeText(this, "fail", Toast.LENGTH_LONG).show();
}
}
| [
"[email protected]"
] | |
f1f54f769fd88f47e91604270845d3dbcf009d58 | a040adf0c50fcdc2040a70a08b4a610dbb25a23b | /BinaryRecursiveSearch.java | 70745dd780bb597d981776ed2d16d65d6a774066 | [] | no_license | USF-CS245-09-2018/practice-assignment-02-LinXu0317 | 9b71e8520dede0eaa70087cc4af4257f1b571f37 | 7650a45eada494b8adc8c28ee2564b6cafc75675 | refs/heads/master | 2020-03-27T18:42:40.335973 | 2018-09-01T04:35:59 | 2018-09-01T04:35:59 | 146,938,413 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 677 | java | public class BinaryRecursiveSearch implements Practice2Search {
public String searchName() {
return "BinaryRecursiveSearch";
}
public int search(int [] arr, int target) {
return search( arr, target, 0, arr.length-1);
}
public int search(int [] arr, int target, int lower, int upper){
if(lower > upper){
return -1;
}
int mid = (lower + upper)/2;
if(arr[mid] == target){
return mid;
}
else if (target < arr[mid]) {
return search(arr, target, lower, mid -1);
}
else{
return search(arr, target, mid+1, upper);
}
}
}
| [
"[email protected]"
] | |
6debd1975f39efe9a7a1ddf2589792b02b715185 | 872967c9fa836eee09600f4dbd080c0da4a944c1 | /source/test/org/w3c/dom/html/HTMLUListElement.java | 69ce7c800a64bf2b1c3a68e367a81f7c0b44aad9 | [] | no_license | pangaogao/jdk | 7002b50b74042a22f0ba70a9d3c683bd616c526e | 3310ff7c577b2e175d90dec948caa81d2da86897 | refs/heads/master | 2021-01-21T02:27:18.595853 | 2018-10-22T02:45:34 | 2018-10-22T02:45:34 | 101,888,886 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,449 | java | /*
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
/*
*
*
*
*
*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
* details.
*/
package test.org.w3c.dom.html;
/**
* Unordered list. See the UL element definition in HTML 4.0.
* <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
*/
public interface HTMLUListElement extends HTMLElement {
/**
* Reduce spacing between list items. See the compact attribute
* definition in HTML 4.0. This attribute is deprecated in HTML 4.0.
*/
public boolean getCompact();
public void setCompact(boolean compact);
/**
* Bullet style. See the type attribute definition in HTML 4.0. This
* attribute is deprecated in HTML 4.0.
*/
public String getType();
public void setType(String type);
}
| [
"[email protected]"
] | |
b8b653c8507034440c0cd559e9c37465079c4993 | e9affefd4e89b3c7e2064fee8833d7838c0e0abc | /aws-java-sdk-athena/src/main/java/com/amazonaws/services/athena/model/transform/CreateCapacityReservationRequestProtocolMarshaller.java | 4d5bfb40dd7485ee348742553a546a74785a0a8c | [
"Apache-2.0"
] | permissive | aws/aws-sdk-java | 2c6199b12b47345b5d3c50e425dabba56e279190 | bab987ab604575f41a76864f755f49386e3264b4 | refs/heads/master | 2023-08-29T10:49:07.379135 | 2023-08-28T21:05:55 | 2023-08-28T21:05:55 | 574,877 | 3,695 | 3,092 | Apache-2.0 | 2023-09-13T23:35:28 | 2010-03-22T23:34:58 | null | UTF-8 | Java | false | false | 2,838 | java | /*
* Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.athena.model.transform;
import javax.annotation.Generated;
import com.amazonaws.SdkClientException;
import com.amazonaws.Request;
import com.amazonaws.http.HttpMethodName;
import com.amazonaws.services.athena.model.*;
import com.amazonaws.transform.Marshaller;
import com.amazonaws.protocol.*;
import com.amazonaws.protocol.Protocol;
import com.amazonaws.annotation.SdkInternalApi;
/**
* CreateCapacityReservationRequest Marshaller
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
@SdkInternalApi
public class CreateCapacityReservationRequestProtocolMarshaller implements
Marshaller<Request<CreateCapacityReservationRequest>, CreateCapacityReservationRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.AWS_JSON).requestUri("/")
.httpMethodName(HttpMethodName.POST).hasExplicitPayloadMember(false).hasPayloadMembers(true)
.operationIdentifier("AmazonAthena.CreateCapacityReservation").serviceName("AmazonAthena").build();
private final com.amazonaws.protocol.json.SdkJsonProtocolFactory protocolFactory;
public CreateCapacityReservationRequestProtocolMarshaller(com.amazonaws.protocol.json.SdkJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
public Request<CreateCapacityReservationRequest> marshall(CreateCapacityReservationRequest createCapacityReservationRequest) {
if (createCapacityReservationRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
final ProtocolRequestMarshaller<CreateCapacityReservationRequest> protocolMarshaller = protocolFactory.createProtocolMarshaller(
SDK_OPERATION_BINDING, createCapacityReservationRequest);
protocolMarshaller.startMarshalling();
CreateCapacityReservationRequestMarshaller.getInstance().marshall(createCapacityReservationRequest, protocolMarshaller);
return protocolMarshaller.finishMarshalling();
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
}
}
| [
""
] | |
ed0d70b2625aa234cc24a96a98fad6ffc5034744 | 1cbf679486038d6efda7022ec8870fdb08fcc767 | /EclipseTaskJuggler.dsl/src-gen/de/sos/etj/eTJ/impl/AccountRootImpl.java | 69a4b5ddd0938a56d05b8ad7ce7dacf7568315b3 | [] | no_license | Scholvac/EclipseTaskJuggler | 16c224d38fae1d4a78ae568823e3dc372b9001e3 | 9c7315150fb2704a84647eac4433797c2fc7f3fc | refs/heads/master | 2021-01-19T09:40:58.399848 | 2015-08-03T15:58:11 | 2015-08-03T15:58:11 | 40,131,999 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,628 | java | /**
*/
package de.sos.etj.eTJ.impl;
import de.sos.etj.eTJ.Account;
import de.sos.etj.eTJ.AccountRoot;
import de.sos.etj.eTJ.ETJPackage;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Account Root</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link de.sos.etj.eTJ.impl.AccountRootImpl#getAccount <em>Account</em>}</li>
* </ul>
*
* @generated
*/
public class AccountRootImpl extends ReportAttributeImpl implements AccountRoot
{
/**
* The cached value of the '{@link #getAccount() <em>Account</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAccount()
* @generated
* @ordered
*/
protected Account account;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected AccountRootImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return ETJPackage.eINSTANCE.getAccountRoot();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Account getAccount()
{
if (account != null && account.eIsProxy())
{
InternalEObject oldAccount = (InternalEObject)account;
account = (Account)eResolveProxy(oldAccount);
if (account != oldAccount)
{
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, ETJPackage.ACCOUNT_ROOT__ACCOUNT, oldAccount, account));
}
}
return account;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Account basicGetAccount()
{
return account;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setAccount(Account newAccount)
{
Account oldAccount = account;
account = newAccount;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ETJPackage.ACCOUNT_ROOT__ACCOUNT, oldAccount, account));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType)
{
switch (featureID)
{
case ETJPackage.ACCOUNT_ROOT__ACCOUNT:
if (resolve) return getAccount();
return basicGetAccount();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case ETJPackage.ACCOUNT_ROOT__ACCOUNT:
setAccount((Account)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case ETJPackage.ACCOUNT_ROOT__ACCOUNT:
setAccount((Account)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case ETJPackage.ACCOUNT_ROOT__ACCOUNT:
return account != null;
}
return super.eIsSet(featureID);
}
} //AccountRootImpl
| [
"[email protected]"
] | |
f8fdf3bc8ca8d105b581934760fc953d9a733fe3 | c1eb06b83268c1b509051a5c7493e7e3a78fd589 | /basics/06_netty_long_conn_heartbeat_detection/Share/src/main/java/com/shenrs/Constants.java | 359c5e55ce764ef2dc16dd8ffe993dc2c59c79b2 | [] | no_license | mister-shen/javalearn | cedc7e3686c4bcdf6638931d8ce5cdd8dd6542de | 8cede15fe5cfe1a8541be15e0a9c09b7b04f1520 | refs/heads/master | 2022-06-28T05:10:53.919609 | 2020-07-02T10:10:53 | 2020-07-02T10:10:53 | 146,244,925 | 0 | 0 | null | 2022-06-21T00:51:40 | 2018-08-27T03:59:09 | Java | UTF-8 | Java | false | false | 340 | java | package com.shenrs;
/**
* @author shenrs
* @Description 常量设置
* @create 2018-09-25 15:30
**/
public class Constants {
private static String clientId;
public static String getClientId(){
return clientId;
}
public static void setClientId(String clientId) {
Constants.clientId = clientId;
}
}
| [
"[email protected]"
] | |
66293d49d3ba3ed1357ee106c6b22c384da72349 | 62a950bbfcd668ec112916cbd5aa0d9f2d909b1c | /src/main/java/com/jcba/cursomc/services/validation/ClienteUpdateValidator.java | 727d99874a6eaee9388625ef0f253f1639fdbe2d | [] | no_license | juliocba/spring-boot-ionic-backend | cf20b105dd6c469311c9d00adcc0073f74c60d4d | 0da3b0ef82458b787731b7ef0017f887e38327fe | refs/heads/master | 2021-06-16T13:35:53.076903 | 2019-07-23T16:57:05 | 2019-07-23T16:57:05 | 192,735,859 | 0 | 0 | null | 2021-04-26T19:16:54 | 2019-06-19T13:17:55 | Java | UTF-8 | Java | false | false | 1,602 | java | package com.jcba.cursomc.services.validation;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerMapping;
import com.jcba.cursomc.domain.Cliente;
import com.jcba.cursomc.dto.ClienteDTO;
import com.jcba.cursomc.repositories.ClienteRepository;
import com.jcba.cursomc.resources.exception.FieldMessage;
public class ClienteUpdateValidator implements ConstraintValidator<ClienteUpdate, ClienteDTO> {
@Autowired
private HttpServletRequest request;
@Autowired
private ClienteRepository repo;
@Override
public void initialize(ClienteUpdate ann) {
}
@Override
public boolean isValid(ClienteDTO objDto, ConstraintValidatorContext context) {
@SuppressWarnings("unchecked")
Map<String, String> map = (Map<String, String>) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
Integer uriId = Integer.parseInt(map.get("id"));
List<FieldMessage> list = new ArrayList<>();
Cliente aux = repo.findByEmail(objDto.getEmail());
if (aux != null && !aux.getId().equals(uriId)) {
list.add(new FieldMessage("email", "Email já existente"));
}
for (FieldMessage e : list) {
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate(e.getMessage()).addPropertyNode(e.getFieldName())
.addConstraintViolation();
}
return list.isEmpty();
}
} | [
"[email protected]"
] | |
51039285631fb5db35e716d8aa8a87350a77eadf | 312e02ac31d750ac91e0fbe7aaf52705edcb7ab1 | /JavaSocket/src/club/banyuan/serverFile/ProUtil.java | 4d94cb9f3c2c656b94b2fc373b0751b21a346ee7 | [] | no_license | samho2008/2010JavaSE | 52f423c4c135a7ce61c62911ed62cbe2ad91c7ba | 890a4f5467aa2e325383f0e4328e6a9249815ebc | refs/heads/master | 2023-06-14T07:57:37.914624 | 2021-07-05T16:34:18 | 2021-07-05T16:34:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 760 | java | package club.banyuan.serverFile;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* @author sanye
* @version 1.0
* @date 2020/12/10 7:25 下午
*/
public class ProUtil {
private static final Properties properties=new Properties();
//程序启动就开始加载文件
static {
InputStream resourceAsStream = ProUtil.class.getClassLoader().getResourceAsStream(
"app.properties");
try {
properties.load(resourceAsStream);
} catch (IOException e) {
e.printStackTrace();
}
}
public static String getFilePath(){ //获取key
return (String)properties.get("path");
}
public static void main(String[] args) {
System.out.println(getFilePath());
}
}
| [
"[email protected]"
] | |
15c1225610c45c11417c195f03e3d2791ceeb59c | d674a6a31763a41509be5b1a0913598331b5c043 | /src/main/java/com/ae/dubaipolice/configuration/WebSocketConfig.java | 839e23e30f8e27b303c64f20c4831efcb594ba00 | [] | no_license | patelmahesh/notification | dfe4ad70b6eae3e1127b4c05c9e7c394120aa062 | b0d2335d2fc1ea4b71bc975b69bf8b5cda668e6d | refs/heads/master | 2020-04-24T09:17:45.833731 | 2019-03-26T12:03:08 | 2019-03-26T12:03:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 645 | java | package com.ae.dubaipolice.configuration;
import com.ae.dubaipolice.handlers.SocketHandler;
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 WebSocketConfig implements WebSocketConfigurer {
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(new SocketHandler(), "/ws");
}
}
| [
"[email protected]"
] | |
3010348edb48743ee903669eb9dad0df1b7ec479 | 14b2bb136de065559fbdbedcd2e58a57f46e89de | /Mouse_Listener/MouseListenerDemo.java | b11c1ac4c8fc179599731fb238c48735f1aab90b | [] | no_license | Abir-Hasan-GUB/JavaSwing | a0e52be18454a24f96b8ed349183cf41c7c85c4c | 89f87598e73d0bdc328d54d9178dfe6ce9588c00 | refs/heads/master | 2022-11-12T07:36:47.825406 | 2020-07-04T16:36:48 | 2020-07-04T16:36:48 | 277,147,715 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,889 | java |
package Mouse_Listener;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
*
* @author abirh
*/
public class MouseListenerDemo extends JFrame{
private Container c;
private JTextField tf;
private JTextArea ta;
private JScrollPane scroll;
MouseListenerDemo(){
initComponants();
}
public void initComponants(){
c = this.getContentPane();
c.setLayout(null);
c.setBackground(Color.yellow);
tf = new JTextField();
tf.setBounds(20, 20, 150, 50);
c.add(tf);
ta = new JTextArea();
ta.setBackground(Color.pink);
scroll = new JScrollPane(ta);
scroll.setBounds(10, 80, 300, 300);
c.add(scroll);
tf.addMouseListener(new MouseListener(){
@Override
public void mouseClicked(MouseEvent me) {
ta.append("Mouse Clicked\n");
}
@Override
public void mousePressed(MouseEvent me) {
ta.append("Mouse Pressed\n");
}
@Override
public void mouseReleased(MouseEvent me) {
ta.append("Mouse Released\n");
}
@Override
public void mouseEntered(MouseEvent me) {
ta.append("Mouse Entered\n");
}
@Override
public void mouseExited(MouseEvent me) {
ta.append("Mouse Exit\n");
}
});
}
public static void main(String[] args) {
MouseListenerDemo frame = new MouseListenerDemo();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBounds(900, 50, 350, 500);
frame.setResizable(false);
frame.setTitle("Mouse Listener");
}
}
| [
"[email protected]"
] | |
57268f86c65aaca76881c3133c62f569a717b891 | fa1408365e2e3f372aa61e7d1e5ea5afcd652199 | /src/testcases/CWE400_Resource_Exhaustion/s03/CWE400_Resource_Exhaustion__sleep_random_66a.java | 3134eb426e3d6c4ce5c45278704023139721406d | [] | no_license | bqcuong/Juliet-Test-Case | 31e9c89c27bf54a07b7ba547eddd029287b2e191 | e770f1c3969be76fdba5d7760e036f9ba060957d | refs/heads/master | 2020-07-17T14:51:49.610703 | 2019-09-03T16:22:58 | 2019-09-03T16:22:58 | 206,039,578 | 1 | 2 | null | null | null | null | UTF-8 | Java | false | false | 2,699 | java | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE400_Resource_Exhaustion__sleep_random_66a.java
Label Definition File: CWE400_Resource_Exhaustion__sleep.label.xml
Template File: sources-sinks-66a.tmpl.java
*/
/*
* @description
* CWE: 400 Resource Exhaustion
* BadSource: random Set count to a random value
* GoodSource: A hardcoded non-zero, non-min, non-max, even number
* Sinks:
* GoodSink: Validate count before using it as a parameter in sleep function
* BadSink : Use count as the parameter for sleep withhout checking it's size first
* Flow Variant: 66 Data flow: data passed in an array from one method to another in different source files in the same package
*
* */
package testcases.CWE400_Resource_Exhaustion.s03;
import testcasesupport.*;
import java.security.SecureRandom;
public class CWE400_Resource_Exhaustion__sleep_random_66a extends AbstractTestCase
{
public void bad() throws Throwable
{
int count;
/* POTENTIAL FLAW: Set count to a random value */
count = (new SecureRandom()).nextInt();
int[] countArray = new int[5];
countArray[2] = count;
(new CWE400_Resource_Exhaustion__sleep_random_66b()).badSink(countArray );
}
public void good() throws Throwable
{
goodG2B();
goodB2G();
}
/* goodG2B() - use goodsource and badsink */
private void goodG2B() throws Throwable
{
int count;
/* FIX: Use a hardcoded number that won't cause underflow, overflow, divide by zero, or loss-of-precision issues */
count = 2;
int[] countArray = new int[5];
countArray[2] = count;
(new CWE400_Resource_Exhaustion__sleep_random_66b()).goodG2BSink(countArray );
}
/* goodB2G() - use badsource and goodsink */
private void goodB2G() throws Throwable
{
int count;
/* POTENTIAL FLAW: Set count to a random value */
count = (new SecureRandom()).nextInt();
int[] countArray = new int[5];
countArray[2] = count;
(new CWE400_Resource_Exhaustion__sleep_random_66b()).goodB2GSink(countArray );
}
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
public static void main(String[] args) throws ClassNotFoundException,
InstantiationException, IllegalAccessException
{
mainFromParent(args);
}
}
| [
"[email protected]"
] | |
824bdb0de83025e20db5b4776c0b18fc8a9de0fd | 1dc25ab3602edd376fcf8695b697b1f0254026b4 | /app/src/main/java/com/gallopdevs/interviewtests/QuestionScoreDao.java | 50f4402ae6d0e8ee0de87e1758380f1bf2deb58e | [] | no_license | jgellatly5/InterviewTests | 36b5e016acabe3c3923341090e6bef99d309793e | ec91d6a48a61c4bdc67350ab9b04654edd5e29df | refs/heads/master | 2023-02-22T16:37:59.771549 | 2023-02-07T18:38:17 | 2023-02-07T18:38:17 | 187,510,538 | 0 | 0 | null | 2019-05-19T18:39:16 | 2019-05-19T18:00:21 | Java | UTF-8 | Java | false | false | 401 | java | package com.gallopdevs.interviewtests;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import java.util.List;
@Dao
public interface QuestionScoreDao {
@Query("SELECT * FROM questionScore")
List<QuestionScore> getScores();
@Insert
void insert(QuestionScore score);
@Delete
void delete(QuestionScore score);
}
| [
"[email protected]"
] | |
3fce5b8259dfd44e506cf7e6269db7ee7458352e | fa93c9be2923e697fb8a2066f8fb65c7718cdec7 | /sources/okhttp3/EventListener.java | 5148ca2050a3c0f00b1f6d1f7ea0ceaffa7f3bdc | [] | no_license | Auch-Auch/avito_source | b6c9f4b0e5c977b36d5fbc88c52f23ff908b7f8b | 76fdcc5b7e036c57ecc193e790b0582481768cdc | refs/heads/master | 2023-05-06T01:32:43.014668 | 2021-05-25T10:19:22 | 2021-05-25T10:19:22 | 370,650,685 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 14,360 | java | package okhttp3;
import com.avito.android.remote.model.payment.status.PaymentStateKt;
import com.facebook.imagepipeline.producers.DecodeProducer;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.List;
import kotlin.Metadata;
import kotlin.jvm.JvmField;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.avito.messenger.internal.jsonrpc.CommonKt;
import t6.r.a.j;
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000~\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\t\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0013\b&\u0018\u0000 N2\u00020\u0001:\u0002NOB\u0007¢\u0006\u0004\bL\u0010MJ\u0017\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016¢\u0006\u0004\b\u0005\u0010\u0006J\u001f\u0010\t\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\b\u001a\u00020\u0007H\u0016¢\u0006\u0004\b\t\u0010\nJ2\u0010\u000f\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\b\u001a\u00020\u00072\u0011\u0010\u000e\u001a\r\u0012\t\u0012\u00070\f¢\u0006\u0002\b\r0\u000bH\u0016¢\u0006\u0004\b\u000f\u0010\u0010J\u001f\u0010\u0013\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0012\u001a\u00020\u0011H\u0016¢\u0006\u0004\b\u0013\u0010\u0014J2\u0010\u0017\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0012\u001a\u00020\u00112\u0011\u0010\u0016\u001a\r\u0012\t\u0012\u00070\u0015¢\u0006\u0002\b\r0\u000bH\u0016¢\u0006\u0004\b\u0017\u0010\u0018J'\u0010\u001c\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u001a\u001a\u00020\u00192\u0006\u0010\u001b\u001a\u00020\fH\u0016¢\u0006\u0004\b\u001c\u0010\u001dJ\u0017\u0010\u001e\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016¢\u0006\u0004\b\u001e\u0010\u0006J!\u0010!\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\b\u0010 \u001a\u0004\u0018\u00010\u001fH\u0016¢\u0006\u0004\b!\u0010\"J1\u0010%\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u001a\u001a\u00020\u00192\u0006\u0010\u001b\u001a\u00020\f2\b\u0010$\u001a\u0004\u0018\u00010#H\u0016¢\u0006\u0004\b%\u0010&J9\u0010)\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u001a\u001a\u00020\u00192\u0006\u0010\u001b\u001a\u00020\f2\b\u0010$\u001a\u0004\u0018\u00010#2\u0006\u0010(\u001a\u00020'H\u0016¢\u0006\u0004\b)\u0010*J\u001f\u0010-\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010,\u001a\u00020+H\u0016¢\u0006\u0004\b-\u0010.J\u001f\u0010/\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010,\u001a\u00020+H\u0016¢\u0006\u0004\b/\u0010.J\u0017\u00100\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016¢\u0006\u0004\b0\u0010\u0006J\u001f\u00103\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u00102\u001a\u000201H\u0016¢\u0006\u0004\b3\u00104J\u0017\u00105\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016¢\u0006\u0004\b5\u0010\u0006J\u001f\u00108\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u00107\u001a\u000206H\u0016¢\u0006\u0004\b8\u00109J\u001f\u0010:\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010(\u001a\u00020'H\u0016¢\u0006\u0004\b:\u0010;J\u0017\u0010<\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016¢\u0006\u0004\b<\u0010\u0006J\u001f\u0010?\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010>\u001a\u00020=H\u0016¢\u0006\u0004\b?\u0010@J\u0017\u0010A\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016¢\u0006\u0004\bA\u0010\u0006J\u001f\u0010B\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u00107\u001a\u000206H\u0016¢\u0006\u0004\bB\u00109J\u001f\u0010C\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010(\u001a\u00020'H\u0016¢\u0006\u0004\bC\u0010;J\u0017\u0010D\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016¢\u0006\u0004\bD\u0010\u0006J\u001f\u0010E\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010(\u001a\u00020'H\u0016¢\u0006\u0004\bE\u0010;J\u0017\u0010F\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016¢\u0006\u0004\bF\u0010\u0006J\u001f\u0010G\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010>\u001a\u00020=H\u0016¢\u0006\u0004\bG\u0010@J\u001f\u0010H\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010>\u001a\u00020=H\u0016¢\u0006\u0004\bH\u0010@J\u0017\u0010I\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016¢\u0006\u0004\bI\u0010\u0006J\u001f\u0010K\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010J\u001a\u00020=H\u0016¢\u0006\u0004\bK\u0010@¨\u0006P"}, d2 = {"Lokhttp3/EventListener;", "", "Lokhttp3/Call;", "call", "", "callStart", "(Lokhttp3/Call;)V", "Lokhttp3/HttpUrl;", "url", "proxySelectStart", "(Lokhttp3/Call;Lokhttp3/HttpUrl;)V", "", "Ljava/net/Proxy;", "Lkotlin/jvm/JvmSuppressWildcards;", "proxies", "proxySelectEnd", "(Lokhttp3/Call;Lokhttp3/HttpUrl;Ljava/util/List;)V", "", "domainName", "dnsStart", "(Lokhttp3/Call;Ljava/lang/String;)V", "Ljava/net/InetAddress;", "inetAddressList", "dnsEnd", "(Lokhttp3/Call;Ljava/lang/String;Ljava/util/List;)V", "Ljava/net/InetSocketAddress;", "inetSocketAddress", "proxy", "connectStart", "(Lokhttp3/Call;Ljava/net/InetSocketAddress;Ljava/net/Proxy;)V", "secureConnectStart", "Lokhttp3/Handshake;", "handshake", "secureConnectEnd", "(Lokhttp3/Call;Lokhttp3/Handshake;)V", "Lokhttp3/Protocol;", "protocol", "connectEnd", "(Lokhttp3/Call;Ljava/net/InetSocketAddress;Ljava/net/Proxy;Lokhttp3/Protocol;)V", "Ljava/io/IOException;", "ioe", "connectFailed", "(Lokhttp3/Call;Ljava/net/InetSocketAddress;Ljava/net/Proxy;Lokhttp3/Protocol;Ljava/io/IOException;)V", "Lokhttp3/Connection;", "connection", "connectionAcquired", "(Lokhttp3/Call;Lokhttp3/Connection;)V", "connectionReleased", "requestHeadersStart", "Lokhttp3/Request;", "request", "requestHeadersEnd", "(Lokhttp3/Call;Lokhttp3/Request;)V", "requestBodyStart", "", DecodeProducer.EXTRA_BITMAP_BYTES, "requestBodyEnd", "(Lokhttp3/Call;J)V", "requestFailed", "(Lokhttp3/Call;Ljava/io/IOException;)V", "responseHeadersStart", "Lokhttp3/Response;", CommonKt.EXTRA_RESPONSE, "responseHeadersEnd", "(Lokhttp3/Call;Lokhttp3/Response;)V", "responseBodyStart", "responseBodyEnd", "responseFailed", "callEnd", "callFailed", PaymentStateKt.PAYMENT_STATE_CANCELED, "satisfactionFailure", "cacheHit", "cacheMiss", "cachedResponse", "cacheConditionalHit", "<init>", "()V", "Companion", "Factory", "okhttp"}, k = 1, mv = {1, 4, 0})
public abstract class EventListener {
public static final Companion Companion = new Companion(null);
@JvmField
@NotNull
public static final EventListener NONE = new EventListener() { // from class: okhttp3.EventListener$Companion$NONE$1
};
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0005\u0010\u0006R\u0016\u0010\u0003\u001a\u00020\u00028\u0006@\u0007X\u0004¢\u0006\u0006\n\u0004\b\u0003\u0010\u0004¨\u0006\u0007"}, d2 = {"Lokhttp3/EventListener$Companion;", "", "Lokhttp3/EventListener;", "NONE", "Lokhttp3/EventListener;", "<init>", "()V", "okhttp"}, k = 1, mv = {1, 4, 0})
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(j jVar) {
this();
}
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\bæ\u0001\u0018\u00002\u00020\u0001J\u0017\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H&¢\u0006\u0004\b\u0005\u0010\u0006¨\u0006\u0007"}, d2 = {"Lokhttp3/EventListener$Factory;", "", "Lokhttp3/Call;", "call", "Lokhttp3/EventListener;", "create", "(Lokhttp3/Call;)Lokhttp3/EventListener;", "okhttp"}, k = 1, mv = {1, 4, 0})
public interface Factory {
@NotNull
EventListener create(@NotNull Call call);
}
public void cacheConditionalHit(@NotNull Call call, @NotNull Response response) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(response, "cachedResponse");
}
public void cacheHit(@NotNull Call call, @NotNull Response response) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(response, CommonKt.EXTRA_RESPONSE);
}
public void cacheMiss(@NotNull Call call) {
Intrinsics.checkNotNullParameter(call, "call");
}
public void callEnd(@NotNull Call call) {
Intrinsics.checkNotNullParameter(call, "call");
}
public void callFailed(@NotNull Call call, @NotNull IOException iOException) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(iOException, "ioe");
}
public void callStart(@NotNull Call call) {
Intrinsics.checkNotNullParameter(call, "call");
}
public void canceled(@NotNull Call call) {
Intrinsics.checkNotNullParameter(call, "call");
}
public void connectEnd(@NotNull Call call, @NotNull InetSocketAddress inetSocketAddress, @NotNull Proxy proxy, @Nullable Protocol protocol) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(inetSocketAddress, "inetSocketAddress");
Intrinsics.checkNotNullParameter(proxy, "proxy");
}
public void connectFailed(@NotNull Call call, @NotNull InetSocketAddress inetSocketAddress, @NotNull Proxy proxy, @Nullable Protocol protocol, @NotNull IOException iOException) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(inetSocketAddress, "inetSocketAddress");
Intrinsics.checkNotNullParameter(proxy, "proxy");
Intrinsics.checkNotNullParameter(iOException, "ioe");
}
public void connectStart(@NotNull Call call, @NotNull InetSocketAddress inetSocketAddress, @NotNull Proxy proxy) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(inetSocketAddress, "inetSocketAddress");
Intrinsics.checkNotNullParameter(proxy, "proxy");
}
public void connectionAcquired(@NotNull Call call, @NotNull Connection connection) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(connection, "connection");
}
public void connectionReleased(@NotNull Call call, @NotNull Connection connection) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(connection, "connection");
}
public void dnsEnd(@NotNull Call call, @NotNull String str, @NotNull List<InetAddress> list) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(str, "domainName");
Intrinsics.checkNotNullParameter(list, "inetAddressList");
}
public void dnsStart(@NotNull Call call, @NotNull String str) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(str, "domainName");
}
public void proxySelectEnd(@NotNull Call call, @NotNull HttpUrl httpUrl, @NotNull List<Proxy> list) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(httpUrl, "url");
Intrinsics.checkNotNullParameter(list, "proxies");
}
public void proxySelectStart(@NotNull Call call, @NotNull HttpUrl httpUrl) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(httpUrl, "url");
}
public void requestBodyEnd(@NotNull Call call, long j) {
Intrinsics.checkNotNullParameter(call, "call");
}
public void requestBodyStart(@NotNull Call call) {
Intrinsics.checkNotNullParameter(call, "call");
}
public void requestFailed(@NotNull Call call, @NotNull IOException iOException) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(iOException, "ioe");
}
public void requestHeadersEnd(@NotNull Call call, @NotNull Request request) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(request, "request");
}
public void requestHeadersStart(@NotNull Call call) {
Intrinsics.checkNotNullParameter(call, "call");
}
public void responseBodyEnd(@NotNull Call call, long j) {
Intrinsics.checkNotNullParameter(call, "call");
}
public void responseBodyStart(@NotNull Call call) {
Intrinsics.checkNotNullParameter(call, "call");
}
public void responseFailed(@NotNull Call call, @NotNull IOException iOException) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(iOException, "ioe");
}
public void responseHeadersEnd(@NotNull Call call, @NotNull Response response) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(response, CommonKt.EXTRA_RESPONSE);
}
public void responseHeadersStart(@NotNull Call call) {
Intrinsics.checkNotNullParameter(call, "call");
}
public void satisfactionFailure(@NotNull Call call, @NotNull Response response) {
Intrinsics.checkNotNullParameter(call, "call");
Intrinsics.checkNotNullParameter(response, CommonKt.EXTRA_RESPONSE);
}
public void secureConnectEnd(@NotNull Call call, @Nullable Handshake handshake) {
Intrinsics.checkNotNullParameter(call, "call");
}
public void secureConnectStart(@NotNull Call call) {
Intrinsics.checkNotNullParameter(call, "call");
}
}
| [
"[email protected]"
] | |
d66f878c450441fa1249b10d30a4878422dba734 | a75669a70ef519de46ff873c77cc9bc20f06ff62 | /Sokoban-Client/src/controller/generic/GenericController.java | 743f1c2f86ccc2cc20b217ba23b24cb47b252f78 | [] | no_license | MaayanMash/Sokoban-Client | 86f7a7d8f9a8fba19caa999a049807aa3ae140a0 | 0f1202e38ffc0ba1e1a322a9f47d8b29d02f4c69 | refs/heads/master | 2020-12-02T08:05:39.050694 | 2017-07-10T13:12:41 | 2017-07-10T13:12:41 | 96,768,094 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,374 | java | package controller.generic;
import java.util.Observable;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
/**
* A department that runs a queue of commands in new thread
* @see public void start() Starts the queue
* @see public void stop() stop the queue
* @see public void insertCommand(iCommand c) Enters a new command to queue
*
*/
public class GenericController{
private BlockingQueue<iCommand> commandQueue;
private boolean stop;
public GenericController() {
this.commandQueue= new ArrayBlockingQueue<>(100);
this.stop=false;
}
/**
* Starts the queue
*/
public void start(){
new Thread(new Runnable() {
@Override
public void run() {
while(!stop){
try {
iCommand cm=commandQueue.poll(1, TimeUnit.SECONDS);
if(cm!=null)
cm.execute();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}).start();
}
/**
* stop the queue
*/
public void stop(){
this.stop=true;
}
/**
* Enters a new command to queue
* @param c new command
*/
public void insertCommand(iCommand c){
try {
commandQueue.put(c);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
8b0032ef6767a5a8fbc06ac95174c91c0162bea8 | a43bfae991b0b051a6934a10cfa4050a3e2953a2 | /em-server/src/main/java/ar/com/fluxit/em/config/HttpSolrContext.java | 88222cd7814d9f2c1def735fb7b87ae0f823e2cf | [
"Apache-2.0"
] | permissive | fluxitsoft/exception-manager | 99df0f3075bdcb96b02484a8ff314e4ebe9686ad | 04d27190a151e7444421e05cb75f28d38c7c92c3 | refs/heads/master | 2022-12-23T14:07:42.695011 | 2013-10-01T12:56:12 | 2013-10-01T12:56:12 | 11,642,462 | 0 | 0 | Apache-2.0 | 2022-12-16T01:57:10 | 2013-07-24T18:47:53 | JavaScript | UTF-8 | Java | false | false | 1,219 | java | package ar.com.fluxit.em.config;
import javax.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.data.solr.core.SolrTemplate;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
import org.springframework.data.solr.server.support.HttpSolrServerFactoryBean;
@Configuration
@EnableSolrRepositories("net.petrikainulainen.spring.datasolr.todo.repository.solr")
@Profile("prod")
@PropertySource("classpath:application.properties")
public class HttpSolrContext {
@Resource
private Environment environment;
@Bean
public HttpSolrServerFactoryBean solrServerFactoryBean() {
HttpSolrServerFactoryBean factory = new HttpSolrServerFactoryBean();
factory.setUrl(environment.getRequiredProperty("solr.server.url"));
return factory;
}
@Bean
public SolrTemplate solrTemplate() throws Exception {
return new SolrTemplate(solrServerFactoryBean().getObject());
}
} | [
"[email protected]"
] | |
17837b0fb1bab3acfbcfb4c0f31a30c0c53e1122 | 6f40baeb9b28bb1cb9738ab9624d8da4d07b9db3 | /week06/src/com/looper/day2/test1/SC3.java | 519e004b23ad4a9b3cf6da7d7aed7066a6bbc26e | [] | no_license | 1004032560/Java | cacf3192166dc632e91be1ce4b9600191a37916d | 10a84834bd6a300bf6bdcc91acebde351242aa9c | refs/heads/master | 2021-04-04T05:09:24.947749 | 2020-05-31T14:04:34 | 2020-05-31T14:04:34 | 248,426,820 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,001 | java | package com.looper.day2.test1;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;
public class SC3 {
public static void main(String[] args) throws UnknownHostException, IOException {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
while(true){
Socket s = new Socket("127.0.0.1",10086);
//写
OutputStream os = s.getOutputStream();
System.out.print("客户端说:");
String str2 = input.nextLine();
os.write(str2.getBytes());
if(str2.equals("exit")){
s.close();
break;
}
//读
InputStream is = s.getInputStream();
byte[] buf = new byte[1024];
int len = is.read(buf);
String str = new String(buf, 0, len);
System.out.println("服务器"+s.getRemoteSocketAddress().toString()+"发来消息:"+str);
is.close();
os.close();
}
}
}
| [
"[email protected]"
] | |
f3f6c892e457875a74333eca8198a6e03701a98d | dc431d3534e2e34cb82bd593a8ee4a1ff04abf01 | /src/com/luv2code/springdemo/entity/Position.java | 404d0a9cda41d9626aa60440700c88f4773424f7 | [] | no_license | jescor123/leantech-project | 7828d76d2f1560da856bbebd88e38695551db9bc | 1c3dbee633d9d6fb60a340170528da58e242ccbd | refs/heads/master | 2023-06-25T00:55:16.199492 | 2021-07-27T01:04:12 | 2021-07-27T01:04:12 | 389,642,203 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 868 | java | package com.luv2code.springdemo.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="position")
public class Position {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private int id;
@Column(name="name")
private String name;
public Position() {
}
public Position(int id, String name) {
super();
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "Position [id=" + id + ", name=" + name + "]";
}
}
| [
"[email protected]"
] | |
22567911c11bbdc0a5306ec4ef00a63e2d615c2a | 6296b8500a91598d6308e6b54a8b7d4a642726a3 | /AccountAnalyze/src/com/dipwater/accountAnalyze/AccountCountTest.java | 015559eaa41d1ca758fcf8596d0f67ecdef7a023 | [] | no_license | dipwater/HadoopProject | 467ac4a7d984446391f9f90dc51dbbab6ec1564c | 245fb9516bc44e9d6851133d60078fa772d4555f | refs/heads/master | 2021-01-19T10:57:34.806001 | 2014-07-31T00:59:42 | 2014-07-31T00:59:42 | 19,400,642 | 0 | 1 | null | null | null | null | GB18030 | Java | false | false | 2,065 | java | package com.dipwater.accountAnalyze;
import java.io.*;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.SequenceFile.CompressionType;
import org.apache.hadoop.io.compress.GzipCodec;
public class AccountCountTest {
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
// TODO 自动生成的方法存根
Configuration conf = new Configuration();
conf.set("mapred.job.tracker", "192.168.1.51:9001");
conf.set("fs.default.name", "hdfs://192.168.1.51:9000");
String[] ars = new String[]{"input", "accountCountOut"};
String[] otherArgs = new GenericOptionsParser(conf, ars).getRemainingArgs();
if (otherArgs.length != 2) {
System.err.println("Usage: accountcount <in> <out>");
System.exit(2);
}
Job job = new Job(conf, "Account Count");
File jarFile = EJob.createTempJar("bin");
EJob.addClasspath("/home/hadoop/hadoop-1.2.1/conf");
ClassLoader classLoder = EJob.getClassLoader();
Thread.currentThread().setContextClassLoader(classLoder);
((JobConf)job.getConfiguration()).setJar(jarFile.toString());
job.setMapperClass(AccountCountMapper.class);
//job.setCombinerClass(AccountCountReducer.class);
job.setReducerClass(AccountCountReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
}
| [
"[email protected]"
] | |
6dee4bf5d10e2f34c7ea5ab9359bab11ef197862 | 8d7f81e2aba91954e37a96db4853e217744cb969 | /src/main/java/uk/ac/ebi/ddi/task/mwxmlgenerator/model/Factor.java | 82a1240814490323a312661687f578bf31eed31b | [
"Apache-2.0"
] | permissive | OmicsDI/mw-xml-generator | d93b079c64cb0c0248ae10101b8278309d81b9e7 | 3c94ec818b2b2b2d9ff1ab820f6763f20893073e | refs/heads/dataflow | 2020-07-16T17:58:19.263347 | 2019-12-09T17:07:50 | 2019-12-09T17:07:50 | 205,837,507 | 0 | 0 | null | 2019-12-09T17:07:52 | 2019-09-02T11:00:02 | Java | UTF-8 | Java | false | false | 715 | java | package uk.ac.ebi.ddi.task.mwxmlgenerator.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author Yasset Perez-Riverol ([email protected])
* @date 19/05/2015
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class Factor {
@JsonProperty("subject_type")
private String type;
@JsonProperty("factors")
private String factors;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getFactors() {
return factors;
}
public void setFactors(String factors) {
this.factors = factors;
}
}
| [
"[email protected]"
] | |
59f19a5edd4427d5cc53aae35d4f740e2f520133 | 39ecf3e4c1d8db9ba1880df8b3b6d55499d45faf | /backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/v3/adapters/V3CpuTopologyInAdapter.java | be5de0abb4c4736d6d7983e4ab817cc875a15543 | [
"Apache-2.0"
] | permissive | chenkaibin/ovirt-engine | 78ea632bf65522307b5c7c4f1b036a73d464be5b | bb4ffa83e2117f1fb910770757aedb5816670625 | refs/heads/master | 2020-03-09T09:10:28.771762 | 2018-03-27T15:10:32 | 2018-04-08T18:43:34 | 128,706,434 | 1 | 0 | Apache-2.0 | 2018-04-09T02:58:49 | 2018-04-09T02:58:49 | null | UTF-8 | Java | false | false | 1,093 | java | /*
Copyright (c) 2016 Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.ovirt.engine.api.v3.adapters;
import org.ovirt.engine.api.model.CpuTopology;
import org.ovirt.engine.api.v3.V3Adapter;
import org.ovirt.engine.api.v3.types.V3CpuTopology;
public class V3CpuTopologyInAdapter implements V3Adapter<V3CpuTopology, CpuTopology> {
@Override
public CpuTopology adapt(V3CpuTopology from) {
CpuTopology to = new CpuTopology();
to.setCores(from.getCores());
to.setSockets(from.getSockets());
to.setThreads(from.getThreads());
return to;
}
}
| [
"[email protected]"
] | |
ef2299f03c9de417903b307897a77464b653837a | 4076950f465531772ac32d67a3fe4b5ae8ab1b71 | /myGUI/src/OtherExpenditureManager.java | a592ed58ee04bdf2e2ccf1952d3b9d7ddfc12187 | [] | no_license | KetanChaware/Database_Management | 6e4159cddb73b63758a69b865458afbc95798940 | e02036d5274971154e337fae95454f07f892b755 | refs/heads/master | 2016-09-05T20:26:48.851040 | 2015-03-27T14:52:36 | 2015-03-27T14:52:36 | 32,962,969 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,384 | 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.
*/
/**
*
* @author KETAN1
*/
public class OtherExpenditureManager extends javax.swing.JFrame {
/**
* Creates new form OtherExpenditureManager
*/
public OtherExpenditureManager() {
initComponents();
}
/**
* 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() {
label1 = new java.awt.Label();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
label1.setBackground(new java.awt.Color(255, 153, 255));
label1.setFont(new java.awt.Font("Arial", 1, 36)); // NOI18N
label1.setText("CRESCENT STEEL INDUSTRIES PVT. LTD.");
jButton1.setText("Insert New Entry");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});
jButton2.setText("Edit Entry");
jButton3.setText("Delete Entry");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label1, javax.swing.GroupLayout.DEFAULT_SIZE, 799, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(180, 180, 180)
.addComponent(jButton1)
.addGap(69, 69, 69)
.addComponent(jButton2)
.addGap(73, 73, 73)
.addComponent(jButton3)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(61, 61, 61)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2)
.addComponent(jButton3))
.addGap(0, 176, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
// TODO add your handling code here:
InsertNewExpenditureEntry iee = new InsertNewExpenditureEntry();
iee.setVisible(true);
}//GEN-LAST:event_jButton1MouseClicked
/**
* @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 ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(OtherExpenditureManager.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(OtherExpenditureManager.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(OtherExpenditureManager.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(OtherExpenditureManager.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new OtherExpenditureManager().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private java.awt.Label label1;
// End of variables declaration//GEN-END:variables
}
| [
"[email protected]"
] | |
847c2077465f75bb3fd7306ef2dec16b26082bcb | 0fe41c948364b5b3350df9cab6c4cc5c8001e5d5 | /library/src/main/java/com/flipkart/android/proteus/processor/EventProcessor.java | c9b185b07c8e5decac41d33667d9b665b4d1ade5 | [
"Apache-2.0"
] | permissive | RepoForks/proteus | 1b38113b6993ea44e94a1220e048e0e8781b6490 | 8b3d64e75b0d74409d13b22d7e8600b1c225332e | refs/heads/master | 2021-01-02T08:40:06.118299 | 2016-11-08T09:51:04 | 2016-11-08T09:51:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,660 | java | /*
* Copyright 2016 Flipkart Internet Pvt. Ltd.
*
* 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.flipkart.android.proteus.processor;
import com.flipkart.android.proteus.EventType;
import com.flipkart.android.proteus.builder.LayoutBuilderCallback;
import com.flipkart.android.proteus.view.ProteusView;
import com.google.gson.JsonElement;
/**
* Use this as the base processor for handling events like OnClick , OnLongClick , OnTouch etc.
* Created by prateek.dixit on 20/11/14.
*/
public abstract class EventProcessor<T> extends AttributeProcessor<T> {
@Override
public void handle(String key, JsonElement value, T view) {
setOnEventListener(view, value);
}
public abstract void setOnEventListener(T view, JsonElement attributeValue);
/**
* This delegates Event with required attributes to client
*/
public void fireEvent(ProteusView view, EventType eventType, JsonElement attributeValue) {
LayoutBuilderCallback layoutBuilderCallback = view.getViewManager().getLayoutBuilder().getListener();
layoutBuilderCallback.onEvent(view, attributeValue, eventType);
}
}
| [
"[email protected]"
] | |
d1f8a8822d81f3bda59c69d1f54cb3e4c05bcba2 | 0af8b92686a58eb0b64e319b22411432aca7a8f3 | /single-large-project/src/test/java/org/gradle/test/performancenull_276/Testnull_27521.java | 0a6ebc53b720d20b915b76dd11b3cda5d4160cc7 | [] | no_license | gradle/performance-comparisons | b0d38db37c326e0ce271abebdb3c91769b860799 | e53dc7182fafcf9fedf07920cbbea8b40ee4eef4 | refs/heads/master | 2023-08-14T19:24:39.164276 | 2022-11-24T05:18:33 | 2022-11-24T05:18:33 | 80,121,268 | 17 | 15 | null | 2022-09-30T08:04:35 | 2017-01-26T14:25:33 | null | UTF-8 | Java | false | false | 308 | java | package org.gradle.test.performancenull_276;
import static org.junit.Assert.*;
public class Testnull_27521 {
private final Productionnull_27521 production = new Productionnull_27521("value");
@org.junit.Test
public void test() {
assertEquals(production.getProperty(), "value");
}
} | [
"[email protected]"
] | |
52fce131cc361dac339f5d0d6714ff61729471a6 | 0691be188104c5e2fa1386729f15d919f19e06d0 | /2014spring/cs316/TJ/TJasn/symbolTable/TabRec.java | 7511e918904397b47ee8bf5a06c81e2794c5aa16 | [] | no_license | haijunsu/QC | 4bdcd07ad210cf072debc12461de2b0852dc50b7 | 7d88cd2fa32b32fb396ac3f40355faec7149eda4 | refs/heads/master | 2020-06-04T00:47:33.396804 | 2015-05-08T21:04:41 | 2015-05-08T21:04:41 | 13,135,568 | 0 | 3 | null | null | null | null | UTF-8 | Java | false | false | 589 | java | package TJasn.symbolTable;
import TJasn.TJ;
import TJasn.virtualMachine.Instruction;
public abstract class TabRec {
public final String name;
private TabRec next = null;
final TabRec getNext() {
return next;
}
TabRec(String idName, BlockRec table)
{
name = idName;
if (name != null) {
TabRec prev = table.predecessor(name);
if (prev == null) {
next = table.getFirstIdent();
table.setFirstIdent(this);
}
else {
next = prev.next;
prev.next = this;
}
}
}
}
| [
"[email protected]"
] | |
9932d18edfb12ad0afd4b8719541d358a4addd29 | ba7e617096ccc45266beb62fcf442d28cfb211d8 | /src/me/carl230690/secretdoors/SecretDoors.java | c10695cb20c806838ab6094b698bcf99d8be5a61 | [] | no_license | doragoncraft/sercetdoor | 41862b4ff93fec5cc0332fb29cb6a60a8a45d6e4 | a7263095d99f9e5fe89d13d024189d02e26b43f9 | refs/heads/master | 2016-09-10T22:17:52.612761 | 2013-09-20T17:34:11 | 2013-09-20T17:34:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,544 | java | package me.carl230690.secretdoors;
import java.util.HashMap;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import me.carl230690.secretdoors.listeners.BlockListener;
import me.carl230690.secretdoors.listeners.PlayerListener;
import me.carl230690.secretdoors.listeners.PowerListener;
public class SecretDoors extends JavaPlugin {
private HashMap<Block, SecretDoor> doors = new HashMap<Block, SecretDoor>();
private HashMap<Block, SecretTrapdoor> trapdoors = new HashMap<Block, SecretTrapdoor>();
public void onDisable() {
for (Block door : this.doors.keySet()) {
this.doors.get(door).close();
}
for (Block ladder : trapdoors.keySet()) {
trapdoors.get(ladder).close();
}
}
public void onEnable() {
getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
getServer().getPluginManager().registerEvents(new PowerListener(this), this);
getServer().getPluginManager().registerEvents(new BlockListener(this), this);
saveDefaultConfig();
}
// handles commands
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length != 1)
return false;
if (cmd.getName().equalsIgnoreCase("secretdoors")) {
if (args[0].equalsIgnoreCase("reload")) {
if (getConfig().getBoolean("use-permissions")) {
if (!sender.hasPermission("secretdoors.reload")) {
return false;
}
}
reloadConfig();
sender.sendMessage(ChatColor.RED + "Secret Doors config reloaded");
return true;
}
}
return false;
}
public SecretDoor addDoor(SecretDoor door) {
this.doors.put(door.getKey(), door);
return door;
}
public boolean isSecretDoor(Block door) {
return this.doors.containsKey(door);
}
public void closeDoor(Block door) {
if (isSecretDoor(door)) {
((SecretDoor) this.doors.get(door)).close();
this.doors.remove(door);
}
}
public void addTrapdoor(SecretTrapdoor door) {
if (door.getKey().getType() == Material.LADDER) {
trapdoors.put(door.getKey(), door);
}
}
public void closeTrapdoor(Block ladder) {
if (ladder.getType() == Material.LADDER) {
if (isSecretTrapdoor(ladder)) {
trapdoors.get(ladder).close();
trapdoors.remove(ladder);
}
}
}
public boolean isSecretTrapdoor(Block ladder) {
if (ladder.getType() == Material.LADDER) {
return trapdoors.containsKey(ladder);
}
return false;
}
} | [
"[email protected]"
] | |
0b91499106b9a2d2a63bab51421b0dca032f0a04 | 12b75ba88d14631e2c99a2fff6b3f3683aafc976 | /nts/texmf/source/nts/nts-1.00-beta/nts/node/BaseFontMetric.java | 2ffb0fc0007f66199f3d9a422ae9c0e9511b1b55 | [] | no_license | tex-other/nts | 50b4f66b3cafa870be4572dff92d23ab4321ddc8 | b4b333723326dc06a84bcd28e2672a76537d9752 | refs/heads/master | 2021-09-09T07:41:55.366960 | 2018-03-14T07:37:37 | 2018-03-14T07:37:37 | 125,165,059 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,038 | java | // Copyright 2001 by
// DANTE e.V. and any individual authors listed elsewhere in this file.
//
// This file is part of the NTS system.
// ------------------------------------
//
// It may be distributed and/or modified under the
// conditions of the NTS Public License (NTSPL), either version 1.0
// of this license or (at your option) any later version.
// The latest version of this license is in
// http://www.dante.de/projects/nts/ntspl.txt
// and version 1.0 or later is part of all distributions of NTS
// version 1.0-beta or later.
//
// The list of all files belonging to the NTS distribution is given in
// the file `manifest.txt'.
//
// Filename: nts/node/BaseFontMetric.java
// $Id: BaseFontMetric.java,v 1.1.1.1 2001/02/09 12:53:15 ksk Exp $
package nts.node;
import nts.base.Num;
import nts.base.Dimen;
import nts.base.Glue;
public abstract class BaseFontMetric implements FontMetric {
public boolean isNull() { return false; }
private Num[] numPars = new Num[NUMBER_OF_NUM_PARAMS];
{ for (int i = 0; i < numPars.length; numPars[i++] = Num.NULL); }
public Num getNumParam(int idx) {
return (0 <= idx && idx < numPars.length)
? numPars[idx] : Num.NULL;
}
public Num setNumParam(int idx, Num val) {
return (0 <= idx && idx < numPars.length)
? (numPars[idx] = val) : Num.NULL;
}
public boolean definesNumParams(int[] idxs) {
for (int i = 0; i < idxs.length; i++) {
int idx = idxs[i];
if ( idx < 0 || idx >= numPars.length
|| numPars[idx] == Num.NULL ) return false;
}
return true;
}
/*
* We make no assumptions about the order of DIMEN_PARAM constants
* therefore we simply allocate the array for all possible parameters and
* initialize each element to Dimen.NULL. Subclasses of this class can
* assign appropriate values to those parameters which they really provide
* during construction.
*/
private Dimen[] dimPars = new Dimen[NUMBER_OF_DIMEN_PARAMS];
{
for (int i = 0; i < dimPars.length; dimPars[i++] = Dimen.NULL);
final int[] params = ALL_TEXT_DIMEN_PARAMS;
for (int i = 0; i < params.length; dimPars[params[i++]] = Dimen.ZERO);
}
public Dimen getDimenParam(int idx) {
return (0 <= idx && idx < dimPars.length)
? dimPars[idx] : Dimen.NULL;
}
public Dimen setDimenParam(int idx, Dimen val) {
if (0 <= idx && idx < dimPars.length) {
normalSpace = Glue.NULL;
return dimPars[idx] = val;
}
return Dimen.NULL;
}
public boolean definesDimenParams(int[] idxs) {
for (int i = 0; i < idxs.length; i++) {
int idx = idxs[i];
if ( idx < 0 || idx >= dimPars.length
|| dimPars[idx] == Dimen.NULL ) return false;
}
return true;
}
private transient Glue normalSpace = Glue.NULL;
public Glue getNormalSpace() {
if (normalSpace == Glue.NULL)
normalSpace = Glue.valueOf( dimPars[DIMEN_PARAM_SPACE],
dimPars[DIMEN_PARAM_STRETCH],
dimPars[DIMEN_PARAM_SHRINK] );
return normalSpace;
}
}
| [
"[email protected]"
] | |
278ca9fb2fcf7d551bd3dfb82dcd7701d76ef85c | 995f73d30450a6dce6bc7145d89344b4ad6e0622 | /Mate20-9.0/src/main/java/com/android/server/wm/$$Lambda$TaskStack$0Cm5zc_NsRa5nGarFvrp2KYfUYU.java | da9855af71680d5e5630636c250f63770114d918 | [] | no_license | morningblu/HWFramework | 0ceb02cbe42585d0169d9b6c4964a41b436039f5 | 672bb34094b8780806a10ba9b1d21036fd808b8e | refs/heads/master | 2023-07-29T05:26:14.603817 | 2021-09-03T05:23:34 | 2021-09-03T05:23:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 689 | java | package com.android.server.wm;
import java.util.function.Consumer;
/* renamed from: com.android.server.wm.-$$Lambda$TaskStack$0Cm5zc_NsRa5nGarFvrp2KYfUYU reason: invalid class name */
/* compiled from: lambda */
public final /* synthetic */ class $$Lambda$TaskStack$0Cm5zc_NsRa5nGarFvrp2KYfUYU implements Consumer {
public static final /* synthetic */ $$Lambda$TaskStack$0Cm5zc_NsRa5nGarFvrp2KYfUYU INSTANCE = new $$Lambda$TaskStack$0Cm5zc_NsRa5nGarFvrp2KYfUYU();
private /* synthetic */ $$Lambda$TaskStack$0Cm5zc_NsRa5nGarFvrp2KYfUYU() {
}
public final void accept(Object obj) {
((WindowState) obj).mWinAnimator.setOffsetPositionForStackResize(true);
}
}
| [
"[email protected]"
] | |
be29d0447fda6f86474e8dc2d1aaaa104e8f0b87 | a8519eab5657c60bcd148cd25f3949af9286dd84 | /Day22_Collection/src/DAO/AddressBook.java | 43a9e22f35e1cf50556eb97510c52b2c7f9148a6 | [] | no_license | prathameshtibile/Day-22-Collection | 021bffeb23e66d31d24ccf12ab3ccfe163689579 | 4dec2828500eb56f5e1d7a4ed99c7aae1abfc83c | refs/heads/main | 2023-06-11T01:33:37.152542 | 2021-07-09T06:13:24 | 2021-07-09T06:13:24 | 384,339,259 | 0 | 0 | null | null | null | null | MacCentralEurope | Java | false | false | 14,562 | java | package DAO;
import AddressBookModel.ContactDetails;
import Util.UserInputOutput;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
public class AddressBook {
Scanner input = new Scanner(System.in);
Hashtable<String,ArrayList<ContactDetails>> contactInfo= new Hashtable<>();
ContactDetails c = null;
ArrayList<ContactDetails> cList = new ArrayList<>();
/**
* getting data from user and stores in object and returns the object
*
* @return
*/
public ContactDetails readDataFromConsole() {
ContactDetails contactDetails = new ContactDetails();
String fName = UserInputOutput.getCustomerFirstName();
contactDetails.setFirstName(fName);
String lName = UserInputOutput.getCustomerLastName();
contactDetails.setLastName(lName);
String eMail = UserInputOutput.getCustomerEmailAddress();
contactDetails.setEmailAddress(eMail);
String hAddress = UserInputOutput.getCustomerHomeAddress();
contactDetails.setHomeAddress(hAddress);
String cName = UserInputOutput.getCustomerCityName();
contactDetails.setCity(cName);
String sName = UserInputOutput.getCustomerStateName();
contactDetails.setState(sName);
String mNUmber = UserInputOutput.getCustomerMobileNumber();
contactDetails.setMobileNumber(mNUmber);
String pCode = UserInputOutput.getCustomerPinCode();
contactDetails.setPinCode(pCode);
return contactDetails;
}
/**
* Purpose : To add contact details in address book
* - ask user address book name
* - search for that particular company as its key
* - then add info to that address book arraylist if already present
* - creates new address book and then adds details in arraylist
*
* @return
*/
public Hashtable<String,ArrayList<ContactDetails>> addContactDetails() {
boolean found = false;
System.out.print("\nEnter the Address Book Name: ");
String addressBookName = input.next();
c = readDataFromConsole();
if (contactInfo.containsKey(addressBookName)) {
ArrayList<ContactDetails> value = contactInfo.get(addressBookName);
for (int j = 0; j < value.size(); j++) {
/*Purpose : Using Java Streams to search for duplicate contacts.
If duplicate contact exist, then do not insert the contact details.
Dated : 03.07.2021
*/
List<String> names = value.stream().map(ContactDetails::getFirstName).collect(Collectors.toList());
for ( int k = 0; k < names.size(); k++) {
if(names.get(j).equals(c.getFirstName())) {
found = true;
break;
}
}
}
if (found == true)
System.out.println("\nDuplicate First Name in Address Book!\n");
else {
value.add(c);
contactInfo.put(addressBookName, value);
}
}
else {
cList = new ArrayList<>();
cList.add(c);
contactInfo.put(addressBookName, cList);
}
return contactInfo;
}
/**
* Purpose : To edit contact details of person from address book
* - ask user to enter address book name
* - if present then edit details else not
*
* @param addressBookName input from user
* @param contactInfo Hashtable of Address Book
*/
public void editContactDetails(String addressBookName,Hashtable<String,ArrayList<ContactDetails>> contactInfo) {
boolean flag = findContact(addressBookName,contactInfo);
if(flag){
updateContactDetails(addressBookName,contactInfo);
} else {
System.out.println("\nNo such Address Book Found To Edit");
}
}
/**
* Purpose : To update details in address book
* - ask user to enter to first name to edit
* - if first name present then edit details else not
*
* @param addressBookName
* @param contactInfo
*/
public void updateContactDetails(String addressBookName, Hashtable<String, ArrayList<ContactDetails>> contactInfo) {
System.out.print("\nEnter the first name you want to edit the details for : ");
String fName = input.next();
ArrayList<ContactDetails> value = contactInfo.get(addressBookName);
for (int j = 0; j < value.size(); j++) {
if(value.get(j).getFirstName().equals(fName)) {
System.out.println("Choose your edit option: ");
System.out.println("1. Last Name");
System.out.println("2. Address");
System.out.println("3. City");
System.out.println("4. State");
System.out.println("5. Zip");
System.out.println("6. Phone Number");
System.out.println("7. Email");
int editOption = input.nextInt();
switch (editOption) {
case 1:
System.out.println("Enter new Last Name: ");
value.get(j).setLastName(input.next());
break;
case 2:
System.out.println("Enter new Address: ");
value.get(j).setHomeAddress(input.next());
break;
case 3:
System.out.println("Enter new City: ");
value.get(j).setCity(input.next());
break;
case 4:
System.out.println("Enter new State: ");
value.get(j).setState(input.next());
break;
case 5:
System.out.println("Enter new Pin Code: ");
value.get(j).setPinCode(input.next());
break;
case 6:
System.out.println("Enter new Phone Number: ");
value.get(j).setMobileNumber(input.next());
break;
case 7:
System.out.println("Enter new Email: ");
value.get(j).setEmailAddress(input.next());
break;
}
System.out.println("\nUpdated successfully!\n");
break;
}
else
System.out.println("\nNo First Name Found!\n");
}
}
/**
* Purpose : to delete details from address book
* - checks company name present or not
* - if present then ask user to enter name
* - if name is present then deletes from list
*
* @param addressBookName
* @param contactInfo
*/
public void deleteContactDetails(String addressBookName,Hashtable<String,ArrayList<ContactDetails>>contactInfo) {
boolean found = false;
boolean flag = findContact(addressBookName, contactInfo);
if (flag == true) {
System.out.print("\nEnter the first name you want to delete : ");
String fName = input.next();
ArrayList<ContactDetails> value = contactInfo.get(addressBookName);
for (int j = 0; j < value.size(); j++) {
if(value.get(j).getFirstName().equals(fName)) {
value.remove(j);
found = true;
break;
}
}
if( found == true) {
System.out.println("\nContact in Address Book Deleted.\n");
}
else
System.out.println("\nNo such First Name found in the Address Book.\n");
}
else
System.out.println("\nNo contacts found in the Address Book.\n");
}
/**
* Purpose : To check whether Address Book Company is present in Hashtable or not
*
* @param addressBookName
* @param contactInfo
* @return
*/
public boolean findContact(String addressBookName, Hashtable<String,ArrayList<ContactDetails>>contactInfo) {
for (int i = 0; i < contactInfo.size(); i++){
if(contactInfo.containsKey(addressBookName))
return true;
}
return false;
}
/**
* Purpose : Displays the addressBook details
*
* @param contactInfo
*/
public void display(Hashtable<String,ArrayList<ContactDetails>>contactInfo) {
contactInfo.keySet().forEach(entry -> {
System.out.println(entry + "->" + contactInfo.get(entry)+ "\n");
});
}
/**
* Purpose : To get person details of same city or state ,multiple persons can be in same city or state
*
* @Since 05-07-2021
*/
public void searchPersons() {
Hashtable<String, Hashtable<String, ArrayList<String>>> hSearch = new Hashtable<>();
AtomicInteger count = new AtomicInteger();
System.out.println("Press 1 to search person by city");
System.out.println("Press 2 to search person by state");
int choice = input.nextInt();
switch (choice) {
case 1:
System.out.print("\nEnter the city name to search: ");
String cityName = input.next();
contactInfo.keySet().forEach(entry -> {
ArrayList<ContactDetails> value = contactInfo.get(entry);
List<String> city = value.stream().map(ContactDetails::getCity).collect(Collectors.toList());
Hashtable<String, ArrayList<String>> person = new Hashtable<>();
ArrayList<String> firstName = new ArrayList<>();
for ( int k = 0; k < city.size(); k++) {
if (city.get(k).equals(cityName)) {
firstName.add(value.get(k).getFirstName());
count.getAndIncrement();
}
person.put(cityName , firstName);
}
hSearch.put(entry , person);
});
break;
case 2:
System.out.print("\nEnter the state name to search: ");
String stateName = input.next();
contactInfo.keySet().forEach(entry -> {
ArrayList<ContactDetails> value = contactInfo.get(entry);
List<String> city = value.stream().map(ContactDetails::getState).collect(Collectors.toList());
Hashtable<String, ArrayList<String>> person = new Hashtable<>();
ArrayList<String> firstName = new ArrayList<>();
for ( int k = 0; k < city.size(); k++) {
if (city.get(k).equals(stateName)) {
firstName.add(value.get(k).getFirstName());
count.getAndIncrement();
}
person.put(stateName , firstName);
}
hSearch.put(entry , person);
});
break;
}
System.out.println("\nViewing Persons by City or State\n" +hSearch);
System.out.println("\nNumber of contact persons i.e. count by City or State is : " +count +"\n");
}
/**
* Purpose : Ability to sort the entries in the address book alphabetically by
* - Personís name
* - City Name
* - State Name
* - Pin Code
*
* @Since 06-07-2021
*/
public void sortPersonsData(){
System.out.println("Press 1 to sort person by First Name");
System.out.println("Press 2 to sort person by City");
System.out.println("Press 3 to sort person by State");
System.out.println("Press 4 to sort person by Pin Code");
int choice = input.nextInt();
switch(choice) {
case 1:
System.out.println("\nSorting Address Book based on First Name");
contactInfo.keySet().forEach(entry -> {
List<ContactDetails> data = contactInfo.get(entry).stream().sorted(Comparator.comparing(ContactDetails::getFirstName)).collect(Collectors.toList());
System.out.println(data);
});
break;
case 2:
System.out.println("\nSorting Address Book based on City");
contactInfo.keySet().forEach(entry -> {
List<ContactDetails> data = contactInfo.get(entry).stream().sorted(Comparator.comparing(ContactDetails::getCity)).collect(Collectors.toList());
System.out.println(data);
});
break;
case 3:
System.out.println("\nSorting Address Book based on State");
contactInfo.keySet().forEach(entry -> {
List<ContactDetails> data = contactInfo.get(entry).stream().sorted(Comparator.comparing(ContactDetails::getState)).collect(Collectors.toList());
System.out.println(data);
});
break;
case 4:
System.out.println("\nSorting Address Book based on PinCode");
contactInfo.keySet().forEach(entry -> {
List<ContactDetails> data = contactInfo.get(entry).stream().sorted(Comparator.comparing(ContactDetails::getPinCode)).collect(Collectors.toList());
System.out.println(data);
});
break;
}
}
}
| [
"[email protected]"
] | |
5f74a12809d565f830dada19f34966d0fd3a8627 | 6f20554d1064714fdf221ded577ede187f4224c6 | /simples/simples-service/src/main/java/org/orgw/simples/service/model/TestCreateService.java | e7fb5dcc8b3af624928148a5fbd2a4cf56157ca8 | [] | no_license | selvafullstack/Emp | 9f0bba07628fd39269fdc97ded3a8ec1ec0d4b9a | 7d90026a00d73d4148ab606b9e686ea2f435b3ae | refs/heads/dev | 2023-05-01T15:35:10.271362 | 2020-03-03T04:43:43 | 2020-03-03T04:43:43 | 244,542,698 | 0 | 0 | null | 2023-04-14T17:33:02 | 2020-03-03T04:37:45 | Java | UTF-8 | Java | false | false | 3,633 | java | package org.orgw.simples.service.model;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.apache.log4j.Logger;
import org.orgw.simples.core.exception.BaseException;
import org.orgw.simples.core.exception.SimplesConstant;
import org.orgw.simples.core.exception.ValidationException;
import org.orgw.simples.core.util.UtilHelper;
import org.orgw.simples.data.CreateTestRequest;
import org.orgw.simples.data.TestResponse;
import org.orgw.simples.repository.ITestRepository;
import org.orgw.simples.repository.model.Users;
import org.orgw.simples.service.ITestCreateService;
@Service
@Transactional
public class TestCreateService implements ITestCreateService {
private final Logger log = Logger.getLogger(getClass());
@Autowired
ITestRepository testRepository;
@Override
public TestResponse addTest(CreateTestRequest request) throws BaseException {
// TODO Auto-generated method stub
try {
Users userdetails = testRepository.getbyEmpname(request.getEmployeid());
if(userdetails!=null) {
Users datas = new Users();
datas.setIp(request.getIp());
datas.setPassword(request.getPassword());
datas.setDateTime(UtilHelper.getSystemDate());
datas.setEmployeId(request.getEmployeid());
datas.setStatus("1");
testRepository.save(datas);
testRepository.refresh(datas);
return getedata(request);
}else {
throw new ValidationException(SimplesConstant.CODE_0,SimplesConstant.USERAVAILBLE);
}
}catch(Exception e) {
log.debug("addTest handleException Exception"+e);
throw new ValidationException(SimplesConstant.CODE_0,SimplesConstant.WRONG);
}
}
private TestResponse getedata(CreateTestRequest request) throws BaseException {
Users datas = testRepository.getbyEmpname(request.getEmployeid());
TestResponse entity = new TestResponse();
entity.setId(datas.getId());
entity.setPassword(datas.getPassword());
entity.setDateTime(datas.getDateTime());
entity.setStatus(datas.getStatus());
entity.setEmployeid(datas.getEmployeId());
entity.setIp(datas.getIp());
return entity;
}
@Override
public TestResponse loginUser(CreateTestRequest request) throws BaseException {
try {
Users userdetails = testRepository.getbyEmpname(request.getEmployeid());
if((userdetails.getEmployeId().equals(request.getEmployeid())) && (userdetails.getPassword().equals(request.getPassword()))) {
TestResponse entity = new TestResponse();
entity.setId(userdetails.getId());
entity.setPassword(userdetails.getPassword());
entity.setDateTime(userdetails.getDateTime());
entity.setStatus(userdetails.getStatus());
entity.setEmployeid(userdetails.getEmployeId());
entity.setIp(userdetails.getIp());
return entity;
}else {
throw new ValidationException(SimplesConstant.CODE_0,SimplesConstant.FAIL);
}
}catch(Exception e) {
throw new ValidationException(SimplesConstant.CODE_0,SimplesConstant.WRONG);
}
}
@Override
public TestResponse addUser(CreateTestRequest request) throws BaseException {
Users entity = new Users();
entity.setIp(request.getIp());
entity.setPassword(request.getPassword());
entity.setEmployeId(request.getEmployeid());
entity.setStatus("1");
testRepository.save(entity);
testRepository.refresh(entity);
return null;
}
}
| [
"[email protected]"
] | |
45c7ce7350ef89f7a8b1f19c0643c243a733ba11 | e630b370e4dc08e2208d463191cd691066f4b824 | /src/main/java/com/himi/springboot/SpringbootSkeletonApplication.java | 72e8fc71cb86b8b463b0230f12c1bfd7c600c201 | [] | no_license | himanshunamdev/springboot-starter | 1361f5707df7511aac8fb69eca0ba41a1cbc72f4 | 78575af5ea2d2e47c0947e36ccd14583b1f2699b | refs/heads/master | 2022-12-26T09:35:59.816542 | 2020-09-21T13:18:26 | 2020-09-21T13:18:26 | 297,313,823 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 348 | java | package com.himi.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringbootSkeletonApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootSkeletonApplication.class, args);
}
}
| [
"[email protected]"
] | |
46ba91bdac327d148fadb5d9ad09322290acbb36 | 6d728bf1794eea6c5c5b11420246054e8bc0f5e2 | /app/src/main/java/broadcast_reciever/MyApplication.java | ca761af851610453505311d2d3e8792e651140eb | [] | no_license | Nirmals502/FastExpressCargp | 670376b70d1b9e3429c6afe5b883bccf6729fa97 | 9fdb8a6d3d882913ea649a9cfcf244bbff1679b3 | refs/heads/master | 2021-07-11T03:53:49.042323 | 2017-10-11T11:20:57 | 2017-10-11T11:20:57 | 106,544,638 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 579 | java | package broadcast_reciever;
/**
* Created by Mr singh on 9/20/2017.
*/
import android.app.Application;
public class MyApplication extends Application {
private static MyApplication mInstance;
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
}
public static synchronized MyApplication getInstance() {
return mInstance;
}
public void setConnectivityListener(ConnectivityReceiver.ConnectivityReceiverListener listener) {
ConnectivityReceiver.connectivityReceiverListener = listener;
}
} | [
"[email protected]"
] | |
a82d00cf60f296a22353851b90acf57570904a14 | 144bb8e35e4487e2b7928029410d0ab263011b6f | /model/src/main/java/me/mmnoda/gurps/lite/domain/model/damage/DamageType.java | ae40fbf59247d0ca2673ba72f678a0dff69ec37a | [] | no_license | mmnoda/gurps-lite | 5f6ee2a7fa59649beeb906315dcde2e0c3e120f0 | c242aa795c72a3e57ed0790ee7a14674eaa5cc03 | refs/heads/master | 2020-03-28T14:57:43.457045 | 2016-12-02T18:11:21 | 2016-12-02T18:11:21 | 68,528,821 | 4 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,054 | java | package me.mmnoda.gurps.lite.domain.model.damage;
/*
* #%L
* model
* %%
* Copyright (C) 2016 Márcio Noda
* %%
* 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.
* #L%
*/
import com.google.common.collect.ImmutableSet;
import java.math.BigInteger;
import java.util.Formattable;
import java.util.Formatter;
import java.util.Set;
import static me.mmnoda.gurps.lite.domain.model.damage.DamageMultiplier.*;
/**
*/
public enum DamageType implements Formattable {
CRUSH("cr"),
CUT(ONE_DOT_FIVE, "cut"),
SMALL_PIERCING(ZERO_DOT_FIVE, "pi-"),
PIERCING("pi"),
LARGE_PIERCING(ONE_DOT_FIVE, "pi+"),
HUGE_PIERCING(DOUBLE, "pi++"),
IMPALING(DOUBLE, "imp"),
BURNING("burn"),
TOXIC("tox"),
CORROSIVE("cor"),
FATIGUE("fat");
private final DamageMultiplier multiplier;
private final String abbreviation;
private static final Set<DamageType> ALL_PIERCINGS;
static {
ALL_PIERCINGS = ImmutableSet.of(SMALL_PIERCING, PIERCING, LARGE_PIERCING, HUGE_PIERCING);
}
DamageType(DamageMultiplier multiplier, String abbreviation) {
this.multiplier = multiplier;
this.abbreviation = abbreviation;
}
DamageType(String abbreviation) {
this(NONE, abbreviation);
}
BigInteger finalValue(final Damage damage) {
return multiplier.multiply(damage.toBigInteger());
}
@Override
public final void formatTo(Formatter formatter, int flags, int width, int precision) {
formatter.format("%s", abbreviation);
}
}
| [
"[email protected]"
] | |
aaa1bbbd925327c445ccec1faee90fffc4f7cf34 | 6b3e3b510aa9b63fa5936b3f12ea8eb298753f97 | /src/main/java/com/youlb/utils/common/MatrixToImageWriter.java | d79efe88933ba2305b318950f9512e18a5c6b056 | [] | no_license | LoganSu/talk | 3517789670902a1196745fe8b0df5447609ddf4a | 6f5312d612ca1c96f6fab2cc024c75e5b7bb874e | refs/heads/master | 2021-01-19T22:49:32.325789 | 2017-04-19T03:49:30 | 2017-04-19T03:49:30 | 88,861,984 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,474 | java | package com.youlb.utils.common;
import javax.imageio.ImageIO;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.common.BitMatrix;
import java.io.File;
import java.io.OutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.awt.image.BufferedImage;
public final class MatrixToImageWriter {
private static final int BLACK = 0xFF000000;
private static final int WHITE = 0xFFFFFFFF;
private MatrixToImageWriter() {}
public static BufferedImage toBufferedImage(BitMatrix matrix) {
int width = matrix.getWidth();
int height = matrix.getHeight();
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
image.setRGB(x, y, matrix.get(x, y) ? BLACK : WHITE);
}
}
return image;
}
public static void writeToFile(BitMatrix matrix, String format, File file)
throws IOException {
BufferedImage image = toBufferedImage(matrix);
if (!ImageIO.write(image, format, file)) {
throw new IOException("Could not write an image of format " + format + " to " + file);
}
}
public static void writeToStream(BitMatrix matrix, String format, OutputStream stream)
throws IOException {
BufferedImage image = toBufferedImage(matrix);
if (!ImageIO.write(image, format, stream)) {
throw new IOException("Could not write an image of format " + format);
}
}
/**
* 生成二维码
* @param content 内容
* @param path 路径
* @param fileName 文件名
*/
public static void createQRCode(String content,String path,String fileName){
try {
MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
Map<EncodeHintType,String> hints = new HashMap<EncodeHintType,String>();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, 400, 400,hints);
File file = new File(path);
if(!file.exists()){
file.mkdirs();
}
File file1 = new File(path,fileName+".jpg");
file1.createNewFile();
writeToFile(bitMatrix, "jpg", file1);
} catch (Exception e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
a223e5789a3eb98a2ea2a9d97719883aeeb2fa4f | 71dad81a037f20c58a214cc9ca279ee6975a0d87 | /app/src/main/java/com/example/odev/DatabaseHelper.java | 72b3c9f196c83aff0e2c062c5684c8fa58340595 | [] | no_license | MuhammedTurgut-jar/mobile_programming_project1 | bade90e9bb3956c8881df2fda0d15cdd80f4671f | aac8e89f983472bed67d09525c064fd6e9a459d6 | refs/heads/master | 2023-05-05T08:39:47.951236 | 2021-05-30T19:06:37 | 2021-05-30T19:06:37 | 372,239,530 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,483 | java | package com.example.odev;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
public class DatabaseHelper extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 7;
private static final String DATABASE_NAME = "UserManager.db";
private static final String TABLE_USER = "user";
private static final String TABLE_QUESTION = "question";
private static final String TABLE_IMAGE = "image";
private static final String COLUMN_USER_ID = "user_id";
private static final String COLUMN_USER_NAME = "user_name";
private static final String COLUMN_USER_SURNAME = "user_surname";
private static final String COLUMN_USER_BIRTH = "user_birth";
private static final String COLUMN_USER_PHONE = "user_phone";
private static final String COLUMN_USER_IMG = "user_img";
private static final String COLUMN_USER_EMAIL = "user_email";
private static final String COLUMN_USER_PASSWORD = "user_password";
private static final String COLUMN_QUESTION_ID = "question_id";
private static final String COLUMN_QUESTION_QUESTION = "question_question";
private static final String COLUMN_QUESTION_A = "question_a";
private static final String COLUMN_QUESTION_B = "question_b";
private static final String COLUMN_QUESTION_C = "question_c";
private static final String COLUMN_QUESTION_D = "question_d";
private static final String COLUMN_QUESTION_ANSWER = "question_answer";
private static final String COLUMN_QUESTION_LEVEL = "question_level";
private static final String COLUMN_IMAGE_ID = "image_id";
private static final String COLUMN_IMAGE_USER_ID = "image_user_id";
private static final String COLUMN_IMAGE_IMAGE_BITMAP = "image_bitmap";
private String CREATE_USER_TABLE = "CREATE TABLE " + TABLE_USER + "("
+ COLUMN_USER_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + COLUMN_USER_NAME + " TEXT,"+ COLUMN_USER_SURNAME + " TEXT,"+ COLUMN_USER_BIRTH + " TEXT,"+ COLUMN_USER_PHONE + " TEXT," + COLUMN_USER_EMAIL + " TEXT," + COLUMN_USER_PASSWORD + " TEXT" + ")";
private String CREATE_QUESTION_TABLE = "CREATE TABLE " + TABLE_QUESTION + "("
+ COLUMN_QUESTION_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + COLUMN_QUESTION_QUESTION + " TEXT,"+ COLUMN_QUESTION_A + " TEXT,"+ COLUMN_QUESTION_B + " TEXT,"+ COLUMN_QUESTION_C + " TEXT,"+ COLUMN_QUESTION_D + " TEXT,"+ COLUMN_QUESTION_ANSWER + " TEXT,"
+ COLUMN_QUESTION_LEVEL + " TEXT" + ")";
private String CREATE_IMAGE_TABLE = "CREATE TABLE " + TABLE_IMAGE + "("
+ COLUMN_IMAGE_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + COLUMN_IMAGE_USER_ID + " INTEGER," + COLUMN_IMAGE_IMAGE_BITMAP + " BLOB" + ")";
private String DROP_USER_TABLE = "DROP TABLE IF EXISTS " + TABLE_USER;
private String DROP_QUESTION_TABLE = "DROP TABLE IF EXISTS " + TABLE_QUESTION;
private String DROP_IMAGE_TABLE = "DROP TABLE IF EXISTS " + TABLE_IMAGE;
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_USER_TABLE);
db.execSQL(CREATE_QUESTION_TABLE);
db.execSQL(CREATE_IMAGE_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL(DROP_USER_TABLE);
db.execSQL(DROP_QUESTION_TABLE);
db.execSQL(DROP_IMAGE_TABLE);
onCreate(db);
}
public void addUser(User user) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(COLUMN_USER_NAME, user.getName());
values.put(COLUMN_USER_SURNAME, user.getSurname());
values.put(COLUMN_USER_BIRTH, user.getBirth());
values.put(COLUMN_USER_PHONE, user.getPhone());
values.put(COLUMN_USER_EMAIL, user.getEmail());
values.put(COLUMN_USER_PASSWORD, user.getPassword());
db.insert(TABLE_USER, null, values);
db.close();
}
public boolean checkUser(String email) {
String[] columns = {
COLUMN_USER_ID
};
SQLiteDatabase db = this.getReadableDatabase();
String selection = COLUMN_USER_EMAIL + " = ?";
String[] selectionArgs = {email};
Cursor cursor = db.query(TABLE_USER,
columns,
selection,
selectionArgs,
null,
null,
null);
int cursorCount = cursor.getCount();
cursor.close();
db.close();
if (cursorCount > 0) {
return true;
}
return false;
}
public boolean checkUser(String email, String password) {
String[] columns = {
COLUMN_USER_ID
};
SQLiteDatabase db = this.getReadableDatabase();
String selection = COLUMN_USER_EMAIL + " = ?" + " AND " + COLUMN_USER_PASSWORD + " = ?";
String[] selectionArgs = {email, password};
Cursor cursor = db.query(TABLE_USER,
columns,
selection,
selectionArgs,
null,
null,
null);
int cursorCount = cursor.getCount();
cursor.close();
db.close();
if (cursorCount > 0) {
return true;
}
return false;
}
public User getUser(String email) {
String[] columns = {
COLUMN_USER_ID,
COLUMN_USER_NAME,
COLUMN_USER_SURNAME,
COLUMN_USER_BIRTH,
COLUMN_USER_PHONE,
COLUMN_USER_EMAIL,
COLUMN_USER_PASSWORD,
};
SQLiteDatabase db = this.getReadableDatabase();
String selection = COLUMN_USER_EMAIL + " = ?" ;
String[] selectionArgs = {email};
Cursor cursor = db.query(TABLE_USER,
columns,
selection,
selectionArgs,
null,
null,
null);
User user = new User();
if (cursor.moveToFirst()) {
do {
user.setId(Integer.parseInt(cursor.getString(cursor.getColumnIndex(COLUMN_USER_ID))));
user.setName(cursor.getString(cursor.getColumnIndex(COLUMN_USER_NAME)));
user.setSurname(cursor.getString(cursor.getColumnIndex(COLUMN_USER_SURNAME)));
user.setBirth(cursor.getString(cursor.getColumnIndex(COLUMN_USER_BIRTH)));
user.setPhone(cursor.getString(cursor.getColumnIndex(COLUMN_USER_PHONE)));
user.setEmail(cursor.getString(cursor.getColumnIndex(COLUMN_USER_EMAIL)));
user.setPassword(cursor.getString(cursor.getColumnIndex(COLUMN_USER_PASSWORD)));
} while (cursor.moveToNext());
}
cursor.close();
db.close();
return user;
}
public Question getQuestion(Integer id) {
String[] columns = {
COLUMN_QUESTION_ID,
COLUMN_QUESTION_QUESTION,
COLUMN_QUESTION_A,
COLUMN_QUESTION_B,
COLUMN_QUESTION_C,
COLUMN_QUESTION_D,
COLUMN_QUESTION_ANSWER,
COLUMN_QUESTION_LEVEL
};
SQLiteDatabase db = this.getReadableDatabase();
String selection = COLUMN_QUESTION_ID + " = ?" ;
String[] selectionArgs = {id.toString()};
Cursor cursor = db.query(TABLE_QUESTION,
columns,
selection,
selectionArgs,
null,
null,
null);
Question question = new Question();
if (cursor.moveToFirst()) {
do {
question.setId(Integer.parseInt(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_ID))));
question.setQuestion(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_QUESTION)));
question.setA(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_A)));
question.setB(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_B)));
question.setC(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_C)));
question.setD(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_D)));
question.setAnswer(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_ANSWER)));
question.setLevel(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_LEVEL)));
} while (cursor.moveToNext());
}
cursor.close();
db.close();
return question;
}
public void addQuestion(Question question) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(COLUMN_QUESTION_QUESTION, question.getQuestion());
values.put(COLUMN_QUESTION_A, question.getA());
values.put(COLUMN_QUESTION_B, question.getB());
values.put(COLUMN_QUESTION_C, question.getC());
values.put(COLUMN_QUESTION_D, question.getD());
values.put(COLUMN_QUESTION_ANSWER, question.getAnswer());
values.put(COLUMN_QUESTION_LEVEL, question.getLevel());
db.insert(TABLE_QUESTION, null, values);
db.close();
}
public void updateQuestion(Question question) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(COLUMN_QUESTION_QUESTION, question.getQuestion());
values.put(COLUMN_QUESTION_A, question.getA());
values.put(COLUMN_QUESTION_B, question.getB());
values.put(COLUMN_QUESTION_C, question.getC());
values.put(COLUMN_QUESTION_D, question.getD());
values.put(COLUMN_QUESTION_ANSWER, question.getAnswer());
values.put(COLUMN_QUESTION_LEVEL, question.getLevel());
// updating row
db.update(TABLE_QUESTION, values, COLUMN_QUESTION_ID + " = ?",
new String[]{String.valueOf(question.getId())});
db.close();
}
public void deleteQuestion(int id) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_QUESTION, COLUMN_QUESTION_ID + " = ?",
new String[]{String.valueOf(id)});
db.close();
}
public ArrayList<Question> getAllQuestion() {
String[] columns = {
COLUMN_QUESTION_ID,
COLUMN_QUESTION_QUESTION,
COLUMN_QUESTION_A,
COLUMN_QUESTION_B,
COLUMN_QUESTION_C,
COLUMN_QUESTION_D,
COLUMN_QUESTION_ANSWER,
COLUMN_QUESTION_LEVEL
};
String sortOrder =
COLUMN_QUESTION_ID + " ASC";
ArrayList<Question> questionList = new ArrayList<Question>();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_QUESTION,
columns,
null,
null,
null,
null,
sortOrder);
if (cursor.moveToFirst()) {
do {
Question question = new Question();
question.setId(Integer.parseInt(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_ID))));
question.setQuestion(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_QUESTION)));
question.setA(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_A)));
question.setB(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_B)));
question.setC(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_C)));
question.setD(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_D)));
question.setAnswer(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_ANSWER)));
question.setLevel(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_LEVEL)));
questionList.add(question);
} while (cursor.moveToNext());
}
cursor.close();
db.close();
return questionList;
}
public ArrayList<Question> getQuizQuestions(int diffLevel) {
String[] columns = {
COLUMN_QUESTION_ID,
COLUMN_QUESTION_QUESTION,
COLUMN_QUESTION_A,
COLUMN_QUESTION_B,
COLUMN_QUESTION_C,
COLUMN_QUESTION_D,
COLUMN_QUESTION_ANSWER,
COLUMN_QUESTION_LEVEL
};
String sortOrder =
COLUMN_QUESTION_ID + " ASC";
ArrayList<Question> questionList = new ArrayList<Question>();
SQLiteDatabase db = this.getReadableDatabase();
String selection = COLUMN_QUESTION_LEVEL + " = ?" ;
String[] selectionArgs = {String.valueOf(diffLevel)};
Cursor cursor = db.query(TABLE_QUESTION,
columns,
selection,
selectionArgs,
null,
null,
sortOrder);
if (cursor.moveToFirst()) {
do {
Question question = new Question();
question.setId(Integer.parseInt(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_ID))));
question.setQuestion(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_QUESTION)));
question.setA(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_A)));
question.setB(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_B)));
question.setC(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_C)));
question.setD(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_D)));
question.setAnswer(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_ANSWER)));
question.setLevel(cursor.getString(cursor.getColumnIndex(COLUMN_QUESTION_LEVEL)));
questionList.add(question);
} while (cursor.moveToNext());
}
cursor.close();
db.close();
return questionList;
}
public void storeImage (Image image) {
SQLiteDatabase db = this.getWritableDatabase();
Bitmap imageToStoreBitmap = image.getImage();
ByteArrayOutputStream byteToArray = new ByteArrayOutputStream();
imageToStoreBitmap.compress(Bitmap.CompressFormat.JPEG,100,byteToArray);
byte[] imageInBytes= byteToArray.toByteArray();
ContentValues values = new ContentValues();
values.put(COLUMN_IMAGE_ID, image.getUserId());
values.put(COLUMN_IMAGE_IMAGE_BITMAP, imageInBytes);
values.put(COLUMN_IMAGE_USER_ID,image.getUserId());
db.insert(TABLE_IMAGE, null, values);
}
public Image getImage (User user) {
String[] columns = {
COLUMN_IMAGE_ID,
COLUMN_IMAGE_USER_ID,
COLUMN_IMAGE_IMAGE_BITMAP,
};
SQLiteDatabase db = this.getReadableDatabase();
String selection = COLUMN_IMAGE_USER_ID + " = ?" ;
String[] selectionArgs = {String.valueOf(user.getId())};
Cursor cursor = db.query(TABLE_IMAGE,
columns,
selection,
selectionArgs,
null,
null,
null);
Image image = new Image();
if (cursor.moveToFirst()) {
do {
image.setImageId(Integer.parseInt(cursor.getString(cursor.getColumnIndex(COLUMN_IMAGE_ID))));
image.setUserId(Integer.parseInt(cursor.getString(cursor.getColumnIndex(COLUMN_IMAGE_USER_ID))));
byte [] bytes = cursor.getBlob(cursor.getColumnIndex(COLUMN_IMAGE_IMAGE_BITMAP));
Bitmap imageBitMap= BitmapFactory.decodeByteArray(bytes,0,bytes.length);
image.setImage(imageBitMap);
} while (cursor.moveToNext());
}
cursor.close();
db.close();
return image;
}
} | [
"[email protected]"
] | |
3e2c14a0a3b6135e046ef679a37a21390a93c944 | 58b3f206d069860c30952b41fd16ccc48056cbcf | /src/org/zkpk/hadoop/day0814/hw01/MapJoin.java | c5542b73bfa1dfca889f66760a760c1ef6b0bb88 | [] | no_license | ljmonica/hadoop-training | ebb3c6bd89b59adfa248bcc81050681f681f6cfc | 7a749b6659ed94d853ffda632998cd8021dd3355 | refs/heads/master | 2021-01-23T12:11:22.841646 | 2014-10-21T04:19:27 | 2014-10-21T04:19:27 | 25,501,472 | 0 | 1 | null | null | null | null | WINDOWS-1252 | Java | false | false | 2,998 | java | package org.zkpk.hadoop.day0814.hw01;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Hashtable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.filecache.DistributedCache;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Mapper.Context;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.KeyValueTextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
/**
* Map side join for small file using distributed cache.
* @author zkpk
*/
public class MapJoin extends Configured implements Tool {
public static class JoinMapper extends Mapper<Object, Text, Text, Text> {
private Hashtable<String, String> joinData = new Hashtable<String, String>();
@Override
protected void setup(Context context) throws IOException,
InterruptedException {
Path[] cacheFiles = DistributedCache.getLocalCacheFiles(context.getConfiguration());
if (cacheFiles != null && cacheFiles.length > 0) {
String line;
String[] tokens;
BufferedReader joinReader = new BufferedReader(
new FileReader(cacheFiles[0].toString()));
try {
while ((line = joinReader.readLine()) != null) {
tokens = line.split("\t", -1);
//add data to collection
joinData.put(tokens[0], tokens[1]);
}
} finally {
joinReader.close();
}
}
}
public void map(Object key, Text value,Context context)throws IOException,InterruptedException{
String [] arr=value.toString().split("\t",-1);
String joinValue = joinData.get(arr[1]);
if (joinValue != null) {
context.write(new Text(arr[1]),
new Text(arr[2] + "," + joinValue));
}
}
}
@Override
public int run(String[] args) throws Exception {
//using DistributedCache
Configuration conf = getConf();
DistributedCache.addCacheFile(new Path("/sogou/uid-sample.txt").toUri(), conf);
//hdfsÖеÄÎļþ
Job job = new Job(conf);
job.setJobName("MapJoin with DistributedCache");
job.setJarByClass(MapJoin.class);
job.setMapperClass(JoinMapper.class);
job.setNumReduceTasks(0);
// job.setInputFormatClass(KeyValueTextInputFormat.class);
// job.setOutputFormatClass(TextOutputFormat.class);
//job.set("key.value.separator.in.input.line", "\t");
Path in = new Path(args[0]);
Path out = new Path(args[1]);
FileInputFormat.setInputPaths(job, in);
FileOutputFormat.setOutputPath(job, out);
return job.waitForCompletion(true)?0:1;
}
public static void main(String[] args) throws Exception {
int res = ToolRunner.run(new Configuration(), new MapJoin(), args);
System.exit(res);
}
}
| [
"[email protected]"
] | |
5864b577a45a0d28e6e817b056b4179ad3be6ffb | 95effc68ec6b24ad41297376ff89f05f92fbb062 | /src/main/java/com/yandex/money/api/model/showcase/Fee.java | 14b2775dce93bf2b40c3bea295f264d52ac2ce7b | [
"MIT"
] | permissive | tsirkunov/yandex-money-sdk-java | 73af73f8111f1b78cc8b774acaad4ef0278093e0 | 3c4e8f468b5986432e152626e86d66e63af31f24 | refs/heads/master | 2021-01-18T06:20:06.517470 | 2015-09-04T10:59:13 | 2015-09-04T10:59:13 | 42,990,476 | 0 | 1 | null | 2015-09-23T09:09:16 | 2015-09-23T09:09:15 | null | UTF-8 | Java | false | false | 3,756 | java | /*
* The MIT License (MIT)
*
* Copyright (c) 2015 NBCO Yandex.Money LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.yandex.money.api.model.showcase;
import com.yandex.money.api.exceptions.IllegalAmountException;
import java.math.BigDecimal;
/**
* Fee.
*
* @author Roman Tsirulnikov ([email protected])
*/
public interface Fee {
/**
* @return {@code true} if fee is present
*/
boolean hasCommission();
/**
* @return {@code true} if fee can be calculated in application, otherwise user should be
* notified of a custom fee
*/
boolean isCalculable();
/**
* Calculates {@code amount} using {@code netAmount}.
*
* @param netAmount this sum will be received by a recipient
* @return amount
*/
BigDecimal amount(BigDecimal netAmount);
/**
* Calculates {@code netAmount} using {@code amount}.
*
* @param amount this sum will be debited from payee account
* @return net amount
* @throws IllegalAmountException if illegal amount entered
*/
BigDecimal netAmount(BigDecimal amount) throws IllegalAmountException;
/**
* @return amount type
*/
AmountType getAmountType();
/**
* No fee.
*/
Fee NO_FEE = new Fee() {
@Override
public boolean hasCommission() {
return false;
}
@Override
public boolean isCalculable() {
return true;
}
@Override
public BigDecimal amount(BigDecimal netAmount) {
return netAmount;
}
@Override
public BigDecimal netAmount(BigDecimal amount) {
return amount;
}
@Override
public AmountType getAmountType() {
return AmountType.AMOUNT;
}
@Override
public String toString() {
return "NO_FEE";
}
};
/**
* Custom fee. Cannot be calculated in an application.
*/
Fee CUSTOM_FEE = new Fee() {
@Override
public boolean hasCommission() {
return true;
}
@Override
public boolean isCalculable() {
return false;
}
@Override
public BigDecimal amount(BigDecimal netAmount) {
throw new UnsupportedOperationException();
}
@Override
public BigDecimal netAmount(BigDecimal amount) {
throw new UnsupportedOperationException();
}
@Override
public AmountType getAmountType() {
throw new UnsupportedOperationException();
}
@Override
public String toString() {
return "CUSTOM_FEE";
}
};
}
| [
"[email protected]"
] | |
b1c682886465c6649b488d3b7cc155159432bfda | 3d4349c88a96505992277c56311e73243130c290 | /Preparation/processed-dataset/god-class_4_1022/48.java | 5134b8c043fc162bb7a7c2b498fc2e9af6355369 | [] | no_license | D-a-r-e-k/Code-Smells-Detection | 5270233badf3fb8c2d6034ac4d780e9ce7a8276e | 079a02e5037d909114613aedceba1d5dea81c65d | refs/heads/master | 2020-05-20T00:03:08.191102 | 2019-05-15T11:51:51 | 2019-05-15T11:51:51 | 185,272,690 | 7 | 4 | null | null | null | null | UTF-8 | Java | false | false | 175 | java | /**
* This expunges the deleted messages from the Folder.
*/
public void expunge() throws MessagingException, OperationCancelledException {
getFolder().expunge();
}
| [
"[email protected]"
] | |
f03359ccecaeec4311fd8622f74075aab528cc11 | 0098dac330eb5a2654d8160c8816ff22b366146f | /app/src/main/java/htmltest/ignite/com/rendertest/MainActivity.java | a604ea6a7e9e353462e814ec0353ab97c5ae6aa4 | [] | no_license | jpbrabec/AndroidSample | ed8de6014331c40ef2e56ef6fd87589ac66e89a4 | 30771e6d298bb8c2cb313a69a963f005659faa0e | refs/heads/master | 2021-01-12T05:44:27.934243 | 2016-12-23T00:31:41 | 2016-12-23T00:31:41 | 77,185,225 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,559 | java | package htmltest.ignite.com.rendertest;
import android.database.Cursor;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
WebView webView;
static String TAG = "MainActivity";
Button searchButton;
EditText searchEditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
searchButton = (Button) findViewById(R.id.searchButton);
searchEditText = (EditText) findViewById(R.id.searchTextBox);
searchButton.setOnClickListener(this);
//Load some sample html data into the web view
webView = (WebView) findViewById(R.id.testView);
String inputHtml = "<html><head></head><body>Example <b>html</b> page here.</body></html>";
webView.loadData(inputHtml,"text/html",null);
//Read through user's SMS history (as an example)
checkSMS();
}
/**
* Read through all of user's past SMS messages
*/
private String checkSMS() {
//Query the SMS inbox
Uri mSmsQueryUri = Uri.parse("content://sms/inbox");
List<TextMessage> messages = new ArrayList<TextMessage>();
//Iterate over result data with a cursor
Cursor cursor = null;
try {
cursor = getContentResolver().query(mSmsQueryUri, null, null, null, null);
if (cursor == null) {
//Something bad happened
Log.i(TAG, "cursor is null. uri: " + mSmsQueryUri);
}
//Search through every entry in the result set
for (boolean hasData = cursor.moveToFirst(); hasData; hasData = cursor.moveToNext()) {
//Load data from the result set into a nice class for us to work with
final String body = cursor.getString(cursor.getColumnIndexOrThrow("body"));
final long dateLong = cursor.getLong(cursor.getColumnIndexOrThrow("date"));
TextMessage newMessage = new TextMessage();
newMessage.body = body;
newMessage.date = new Date(dateLong);
//Ignore all messages older than one hour
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.HOUR_OF_DAY, -1);
Date hourDate = calendar.getTime();
if(newMessage.date.compareTo(hourDate) > 0) {
messages.add(newMessage);
}
//TODO- Filter messages so that they are in order and only for this specific query
//TODO- You can send a unique code with each search. For example you might get three texts like this:
//TODO- [01234,0,3] This is the first message
//TODO- [01234,2,3] This is the second message
//TODO- [01234,3,3] This is the third message
//TODO- So you can filter by some unique ID code per search, and then also order the messages correctly
}
} catch (Exception e) {
//Something bad happened
Log.e(TAG, e.getMessage());
} finally {
//Close the cursor
if(cursor != null) {
cursor.close();
}
}
//Print text messages to the debug console
for(TextMessage message : messages) {
Log.d(TAG,"["+message.date.toString()+"] "+message.body);
}
//Concat these messages into a single string to be returned
StringBuilder stringBuilder = new StringBuilder();
for(TextMessage message : messages) {
stringBuilder.append(message.body);
}
//TODO- This is the data which you could render in your html view
return stringBuilder.toString();
}
@Override
public void onClick(View v) {
Log.d(TAG,"okay");
Toast.makeText(this,"Searching!",Toast.LENGTH_SHORT).show();
//TODO- Send SMS message here
//TODO- Wait a few seconds
//TODO- Call checkSMS()
}
private class TextMessage {
public String body;
public Date date;
}
}
| [
"[email protected]"
] | |
85ca0cd8907f9e0449e3b8cdc51b8f526c08bb01 | 9230ff803d94d6b732b4a51d536101b2d283297d | /02-build-a-simple-spring-boot-microservice/simple-microservice/src/main/java/com/example/demo/HelloController.java | 67b5480a3118609ad83a9d732e807f11456fc919 | [] | no_license | mayur-us/azure-spring-cloud | 6a76507addec7b68b150dd0bbe7031e95a493e4c | 09650726f74294d75604f5f836b920cd469092df | refs/heads/master | 2022-12-21T21:35:51.351475 | 2020-04-27T10:17:13 | 2020-04-27T10:17:13 | 236,571,300 | 0 | 0 | null | 2022-12-16T15:36:18 | 2020-01-27T19:11:52 | Java | UTF-8 | Java | false | false | 734 | java | /**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for
* license information.
*/
package com.example.demo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
// @GetMapping("/hello")
// public String hello() {
// return "Hello from Azure Spring Cloud\n";
// }
@Value("${application.message:Not configured by a Spring Cloud Server}")
private String message;
@GetMapping("/hello")
public String hello() {
return message;
}
}
| [
"[email protected]"
] | |
18a881dc4e6aa78fe355b69ef9d85d414086f0a5 | d15803d5b16adab18b0aa43d7dca0531703bac4a | /com/whatsapp/cc.java | 1347a14687d9380b97a05c3121ec7db8f45ff18e | [] | no_license | kenuosec/Decompiled-Whatsapp | 375c249abdf90241be3352aea38eb32a9ca513ba | 652bec1376e6cd201d54262cc1d4e7637c6334ed | refs/heads/master | 2021-12-08T15:09:13.929944 | 2016-03-23T06:04:08 | 2016-03-23T06:04:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 543 | java | package com.whatsapp;
import java.util.HashMap;
class cc implements Runnable {
final HashMap a;
final azm b;
public void run() {
boolean z = l5.s;
ael.f(this.b.a).a(this.b.b, this.b.c ? this.a : null);
for (String str : this.a.keySet()) {
ael.f(this.b.a).a(str);
ael.e(this.b.a).b(str);
if (z) {
return;
}
}
}
cc(azm com_whatsapp_azm, HashMap hashMap) {
this.b = com_whatsapp_azm;
this.a = hashMap;
}
}
| [
"[email protected]"
] | |
0246334361d1c34a67c9506dc1688048d7b361b3 | 5e968dd60047be6f89cb86794ca74688830b1f82 | /app/src/main/java/org/bugjlu/ots_trafficaid_client/chatuidemo/ui/RecorderVideoActivity.java | b96652ce0d2996443172ec1ba460616019e97760 | [] | no_license | BugJLU/OTS-TrafficAid-Client | 476dc91c526b8d88cab83eac8b3e048e4b303379 | 5039fbc79902dd593eb95c2284b95f8c940caf17 | refs/heads/master | 2020-03-12T05:33:14.508206 | 2018-05-09T07:43:38 | 2018-05-09T07:43:38 | 130,465,814 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,465 | java | /************************************************************
* * EaseMob CONFIDENTIAL
* __________________
* Copyright (C) 2016 Hyphenate Inc. All rights reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of EaseMob Technologies.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from EaseMob Technologies.
*/
package org.bugjlu.ots_trafficaid_client.chatuidemo.ui;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.PixelFormat;
import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.Size;
import android.media.MediaRecorder;
import android.media.MediaRecorder.OnErrorListener;
import android.media.MediaRecorder.OnInfoListener;
import android.media.MediaScannerConnection;
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.PowerManager;
import android.os.SystemClock;
import android.text.TextUtils;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.Chronometer;
import android.widget.ImageView;
import android.widget.Toast;
import android.widget.VideoView;
import org.bugjlu.ots_trafficaid_client.R;
import org.bugjlu.ots_trafficaid_client.chatuidemo.video.util.Utils;
import com.hyphenate.easeui.utils.EaseCommonUtils;
import com.hyphenate.util.EMLog;
import com.hyphenate.util.PathUtil;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
public class RecorderVideoActivity extends BaseActivity implements
OnClickListener, SurfaceHolder.Callback, OnErrorListener,
OnInfoListener {
private static final String TAG = "RecorderVideoActivity";
private final static String CLASS_LABEL = "RecordActivity";
private PowerManager.WakeLock mWakeLock;
private ImageView btnStart;
private ImageView btnStop;
private MediaRecorder mediaRecorder;
private VideoView mVideoView;// to display video
String localPath = "";// path to save recorded video
private Camera mCamera;
private int previewWidth = 480;
private int previewHeight = 480;
private Chronometer chronometer;
private int frontCamera = 0; // 0 is back camera,1 is front camera
private Button btn_switch;
Parameters cameraParameters = null;
private SurfaceHolder mSurfaceHolder;
int defaultVideoFrameRate = -1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);// no title
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);// full screen
// translucency mode,used in surface view
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.em_recorder_activity);
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,
CLASS_LABEL);
mWakeLock.acquire();
initViews();
}
private void initViews() {
btn_switch = (Button) findViewById(R.id.switch_btn);
btn_switch.setOnClickListener(this);
btn_switch.setVisibility(View.VISIBLE);
mVideoView = (VideoView) findViewById(R.id.mVideoView);
btnStart = (ImageView) findViewById(R.id.recorder_start);
btnStop = (ImageView) findViewById(R.id.recorder_stop);
btnStart.setOnClickListener(this);
btnStop.setOnClickListener(this);
mSurfaceHolder = mVideoView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
chronometer = (Chronometer) findViewById(R.id.chronometer);
}
public void back(View view) {
releaseRecorder();
releaseCamera();
finish();
}
@Override
protected void onResume() {
super.onResume();
if (mWakeLock == null) {
// keep screen on
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,
CLASS_LABEL);
mWakeLock.acquire();
}
}
@SuppressLint("NewApi")
private boolean initCamera() {
try {
if (frontCamera == 0) {
mCamera = Camera.open(CameraInfo.CAMERA_FACING_BACK);
} else {
mCamera = Camera.open(CameraInfo.CAMERA_FACING_FRONT);
}
Parameters camParams = mCamera.getParameters();
mCamera.lock();
mSurfaceHolder = mVideoView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mCamera.setDisplayOrientation(90);
} catch (RuntimeException ex) {
EMLog.e("video", "init Camera fail " + ex.getMessage());
return false;
}
return true;
}
private void handleSurfaceChanged() {
if (mCamera == null) {
finish();
return;
}
boolean hasSupportRate = false;
List<Integer> supportedPreviewFrameRates = mCamera.getParameters()
.getSupportedPreviewFrameRates();
if (supportedPreviewFrameRates != null
&& supportedPreviewFrameRates.size() > 0) {
Collections.sort(supportedPreviewFrameRates);
for (int i = 0; i < supportedPreviewFrameRates.size(); i++) {
int supportRate = supportedPreviewFrameRates.get(i);
if (supportRate == 15) {
hasSupportRate = true;
}
}
if (hasSupportRate) {
defaultVideoFrameRate = 15;
} else {
defaultVideoFrameRate = supportedPreviewFrameRates.get(0);
}
}
// get all resolutions which camera provide
List<Size> resolutionList = Utils.getResolutionList(mCamera);
if (resolutionList != null && resolutionList.size() > 0) {
Collections.sort(resolutionList, new Utils.ResolutionComparator());
Size previewSize = null;
boolean hasSize = false;
// use 60*480 if camera support
for (int i = 0; i < resolutionList.size(); i++) {
Size size = resolutionList.get(i);
if (size != null && size.width == 640 && size.height == 480) {
previewSize = size;
previewWidth = previewSize.width;
previewHeight = previewSize.height;
hasSize = true;
break;
}
}
// use medium resolution if camera don't support the above resolution
if (!hasSize) {
int mediumResolution = resolutionList.size() / 2;
if (mediumResolution >= resolutionList.size())
mediumResolution = resolutionList.size() - 1;
previewSize = resolutionList.get(mediumResolution);
previewWidth = previewSize.width;
previewHeight = previewSize.height;
}
}
}
@Override
protected void onPause() {
super.onPause();
if (mWakeLock != null) {
mWakeLock.release();
mWakeLock = null;
}
releaseRecorder();
releaseCamera();
finish();
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.switch_btn:
switchCamera();
break;
case R.id.recorder_start:
// start recording
if(!startRecording())
return;
Toast.makeText(this, R.string.The_video_to_start, Toast.LENGTH_SHORT).show();
btn_switch.setVisibility(View.INVISIBLE);
btnStart.setVisibility(View.INVISIBLE);
btnStart.setEnabled(false);
btnStop.setVisibility(View.VISIBLE);
chronometer.setBase(SystemClock.elapsedRealtime());
chronometer.start();
break;
case R.id.recorder_stop:
btnStop.setEnabled(false);
stopRecording();
btn_switch.setVisibility(View.VISIBLE);
chronometer.stop();
btnStart.setVisibility(View.VISIBLE);
btnStop.setVisibility(View.INVISIBLE);
new AlertDialog.Builder(this)
.setMessage(R.string.Whether_to_send)
.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
sendVideo(null);
}
})
.setNegativeButton(R.string.cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
if(localPath != null){
File file = new File(localPath);
if(file.exists())
file.delete();
}
finish();
}
}).setCancelable(false).show();
break;
default:
break;
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
mSurfaceHolder = holder;
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (mCamera == null){
if(!initCamera()){
showFailDialog();
return;
}
}
try {
mCamera.setPreviewDisplay(mSurfaceHolder);
mCamera.startPreview();
handleSurfaceChanged();
} catch (Exception e1) {
EMLog.e("video", "start preview fail " + e1.getMessage());
showFailDialog();
}
}
@Override
public void surfaceDestroyed(SurfaceHolder arg0) {
EMLog.v("video", "surfaceDestroyed");
}
public boolean startRecording(){
if (mediaRecorder == null){
if(!initRecorder())
return false;
}
mediaRecorder.setOnInfoListener(this);
mediaRecorder.setOnErrorListener(this);
mediaRecorder.start();
return true;
}
@SuppressLint("NewApi")
private boolean initRecorder(){
if(!EaseCommonUtils.isSdcardExist()){
showNoSDCardDialog();
return false;
}
if (mCamera == null) {
if(!initCamera()){
showFailDialog();
return false;
}
}
mVideoView.setVisibility(View.VISIBLE);
mCamera.stopPreview();
mediaRecorder = new MediaRecorder();
mCamera.unlock();
mediaRecorder.setCamera(mCamera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
if (frontCamera == 1) {
mediaRecorder.setOrientationHint(270);
} else {
mediaRecorder.setOrientationHint(90);
}
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
// set resolution, should be set after the format and encoder was set
mediaRecorder.setVideoSize(previewWidth, previewHeight);
mediaRecorder.setVideoEncodingBitRate(384 * 1024);
// set frame rate, should be set after the format and encoder was set
if (defaultVideoFrameRate != -1) {
mediaRecorder.setVideoFrameRate(defaultVideoFrameRate);
}
// set the path for video file
localPath = PathUtil.getInstance().getVideoPath() + "/"
+ System.currentTimeMillis() + ".mp4";
mediaRecorder.setOutputFile(localPath);
mediaRecorder.setMaxDuration(30000);
mediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
try {
mediaRecorder.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
public void stopRecording() {
if (mediaRecorder != null) {
mediaRecorder.setOnErrorListener(null);
mediaRecorder.setOnInfoListener(null);
try {
mediaRecorder.stop();
} catch (Exception e) {
EMLog.e("video", "stopRecording error:" + e.getMessage());
}
}
releaseRecorder();
if (mCamera != null) {
mCamera.stopPreview();
releaseCamera();
}
}
private void releaseRecorder() {
if (mediaRecorder != null) {
mediaRecorder.release();
mediaRecorder = null;
}
}
protected void releaseCamera() {
try {
if (mCamera != null) {
mCamera.stopPreview();
mCamera.release();
mCamera = null;
}
} catch (Exception e) {
}
}
@SuppressLint("NewApi")
public void switchCamera() {
if (mCamera == null) {
return;
}
if (Camera.getNumberOfCameras() >= 2) {
btn_switch.setEnabled(false);
if (mCamera != null) {
mCamera.stopPreview();
mCamera.release();
mCamera = null;
}
switch (frontCamera) {
case 0:
mCamera = Camera.open(CameraInfo.CAMERA_FACING_FRONT);
frontCamera = 1;
break;
case 1:
mCamera = Camera.open(CameraInfo.CAMERA_FACING_BACK);
frontCamera = 0;
break;
}
try {
mCamera.lock();
mCamera.setDisplayOrientation(90);
mCamera.setPreviewDisplay(mVideoView.getHolder());
mCamera.startPreview();
} catch (IOException e) {
mCamera.release();
mCamera = null;
}
btn_switch.setEnabled(true);
}
}
MediaScannerConnection msc = null;
ProgressDialog progressDialog = null;
public void sendVideo(View view) {
if (TextUtils.isEmpty(localPath)) {
EMLog.e("Recorder", "recorder fail please try again!");
return;
}
if(msc == null)
msc = new MediaScannerConnection(this,
new MediaScannerConnectionClient() {
@Override
public void onScanCompleted(String path, Uri uri) {
EMLog.d(TAG, "scanner completed");
msc.disconnect();
progressDialog.dismiss();
setResult(RESULT_OK, getIntent().putExtra("uri", uri));
finish();
}
@Override
public void onMediaScannerConnected() {
msc.scanFile(localPath, "video/*");
}
});
if(progressDialog == null){
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("processing...");
progressDialog.setCancelable(false);
}
progressDialog.show();
msc.connect();
}
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
EMLog.v("video", "onInfo");
if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) {
EMLog.v("video", "max duration reached");
stopRecording();
btn_switch.setVisibility(View.VISIBLE);
chronometer.stop();
btnStart.setVisibility(View.VISIBLE);
btnStop.setVisibility(View.INVISIBLE);
chronometer.stop();
if (localPath == null) {
return;
}
String st3 = getResources().getString(R.string.Whether_to_send);
new AlertDialog.Builder(this)
.setMessage(st3)
.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0,
int arg1) {
arg0.dismiss();
sendVideo(null);
}
}).setNegativeButton(R.string.cancel, null)
.setCancelable(false).show();
}
}
@Override
public void onError(MediaRecorder mr, int what, int extra) {
EMLog.e("video", "recording onError:");
stopRecording();
Toast.makeText(this,
"Recording error has occurred. Stopping the recording",
Toast.LENGTH_SHORT).show();
}
public void saveBitmapFile(Bitmap bitmap) {
File file = new File(Environment.getExternalStorageDirectory(), "a.jpg");
try {
BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream(file));
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
releaseCamera();
if (mWakeLock != null) {
mWakeLock.release();
mWakeLock = null;
}
}
@Override
public void onBackPressed() {
back(null);
}
private void showFailDialog() {
new AlertDialog.Builder(this)
.setTitle(R.string.prompt)
.setMessage(R.string.Open_the_equipment_failure)
.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
finish();
}
}).setCancelable(false).show();
}
private void showNoSDCardDialog() {
new AlertDialog.Builder(this)
.setTitle(R.string.prompt)
.setMessage("No sd card!")
.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
finish();
}
}).setCancelable(false).show();
}
}
| [
"[email protected]"
] | |
324718351b6c66d77b09839a0c6263953bffe3ff | 9ba797544c89dd4135c854d1d6500f40fde7aa62 | /src/euclideanTSP/AutoHeuristicTSP.java | 93ffb4c09fdbb47636cec9b75d44c0ffa6539446 | [] | no_license | Alton09/MSUD-CS-4050-Algorithms-Course | 3139bf62f9953756c1e8a4a16c8bc719b4915282 | fab6bab56f2373a6ed21a0197481fe36ec0ebdea | refs/heads/master | 2021-01-01T05:25:55.265443 | 2016-05-08T02:27:06 | 2016-05-08T02:27:06 | 57,043,744 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,846 | java | package euclideanTSP;
/*
automate (somewhat) the heuristic TSP algorithm
(user still has to enter cuts, branches, and notice tours)
*/
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
import java.io.*;
public class AutoHeuristicTSP extends Basic
{
//==================================================================================================
// total size of the window in pixels
private static final int pixelWidth = 700, pixelHeight = 700; // total window size in pixels
// amount to shift drawing area to the right and down to not hit the title bar or window borders
private static final int windowHorizOffset = 15, windowVertOffset = 50,
rightMargin = 5, bottomMargin = 5;
private static Color textColor = new Color( 0, 0, 255 );
private static Color gridColor = new Color( 180, 255, 180 );
private static double gridSize = 0.05;
private static final double tiny = 0.0000001;
public static double[][] points; // points for problem, globally known
//==================================================================================================
public static void main(String[] args)
{
AutoHeuristicTSP bf = new AutoHeuristicTSP("Auto Heuristic TSP", 0, 0,
pixelWidth, pixelHeight, args[0] );
}
// instance variables for the application:
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
private Node node; // the current node
private Tableau table; // the tableau currently being used
private ArrayList<Node> pq; // the priority queue (implemented crudely)
// of all unexplored nodes
private String editMode; // is "cutting" or "branching" or "regular"
private String editString; // accumulate symbols until reach stop state
private Node bestNode;
private boolean useGrid; // snap mouse to grid and show grid, or free form
private boolean showLabels; // show vertex numbers
private PrintWriter tex;
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
public AutoHeuristicTSP( String title, int ulx, int uly, int pw, int ph, String filePath )
{
super(title,ulx,uly,pw,ph);
try{
String fileName = filePath.substring(filePath.lastIndexOf('\\') + 1, filePath.lastIndexOf(".txt"));
Scanner input = new Scanner( new File( filePath ) );
tex = new PrintWriter( new File("temp" + fileName + ".tex") );
int n = input.nextInt(); input.nextLine();
// read and ignore the line that says "points" for compatibility
// with HeuristicTSP which has some options not supported here
input.nextLine();
points = new double[ n ][2];
for( int k=0; k<n; k++ )
{
points[k][0] = input.nextDouble();
points[k][1] = input.nextDouble();
}
node = new Node();
bestNode = null;
pq = new ArrayList<Node>();
pq.add( node );
branchAndBoundStep();
}
catch(Exception e)
{
System.out.println("failed to open tableau and solve LP");
e.printStackTrace();
System.exit(1);
}
useGrid = true;
showLabels = true;
editMode = "regular";
editString = "";
setBackgroundColor( new Color( 64, 64, 64 ) );
cameras.add( new Camera( windowHorizOffset, windowVertOffset,
pixelWidth - windowHorizOffset - rightMargin,
pixelHeight - windowVertOffset - bottomMargin,
-0.025, 1.025, -0.025, 1.025,
new Color( 200, 200, 200 ) ) );
// start up the animation:
super.start();
}
public void step()
{
Camera cam;
cam = cameras.get(0);
cam.activate();
// draw grid if desired
if( useGrid )
{
// draw grid to aid in selection
double x=0, y=0;
cam.setColor( gridColor );
while( x <= 1 )
{// draw vertical line at x
cam.drawLine( x, 0, x, 1 );
x += gridSize;
}
while( y <= 1 )
{// draw horizontal line at y
cam.drawLine( 0, y, 1, y );
y += gridSize;
}
}// useGrid so show grid
// draw the LP optimal
// (look for variables of form xk,j > 0, draw .5, 1 different colors)
String[] vars = node.variables;
double[] vals = node.values;
double[][] pts = points;
// draw the points
double displayScale = 100;
double vertSize = 0.005;
cam.setColor( Color.black );
for( int k=0; k<pts.length; k++ )
{
double px = pts[k][0]/displayScale, py = pts[k][1]/displayScale;
cam.fillRect( px-vertSize, py-vertSize, 2*vertSize, 2*vertSize );
if( showLabels )
{
cam.drawText( "" + (k+1), px, py+2*vertSize );
}
}
// draw the edges corresponding to xk,j > 0 (and compute the cost)
double cost = 0;
for( int m=0; m < vars.length; m++ )
{
if( vars[m].charAt(0) == 'x' &&
vals[m] > tiny
)
{// pull out the indices and draw the edge
String w = vars[m];
int comma = w.indexOf( ',' );
int k = Integer.parseInt( w.substring(1,comma) );
int j = Integer.parseInt( w.substring(comma+1) );
double x1 = pts[k-1][0]/displayScale, y1 = pts[k-1][1]/displayScale;
double x2 = pts[j-1][0]/displayScale, y2 = pts[j-1][1]/displayScale;
cost += vals[m] * Math.hypot( x1-x2, y1-y2 );
if( Math.abs( vals[m] - 0.5 ) < tiny )
cam.setColor( Color.red );
else if( Math.abs( vals[m] - 1 ) < tiny )
cam.setColor( Color.blue );
// add in colors for 1/6, 2/6, 4/6, 5/6:
else if( Math.abs( vals[m] - 0.1666666666 ) < tiny )
cam.setColor( Color.yellow );
else if( Math.abs( vals[m] - 0.3333333333 ) < tiny )
cam.setColor( Color.orange );
else if( Math.abs( vals[m] - 0.6666666666 ) < tiny )
cam.setColor( Color.green );
else if( Math.abs( vals[m] - 0.8333333333 ) < tiny )
cam.setColor( Color.magenta );
else if( vals[m] > tiny )
cam.setColor( Color.cyan ); // not fitting the color scheme
cam.drawLine( x1, y1, x2, y2 );
}
}
// show the cost and node id
cam.setColor( Color.magenta );
cam.drawText( "" + node.score, .025, 0.975 );
cam.drawText( "" + node.id, 0.975, 0.975 );
// show the "one k j" edges in black, the
// "zero k j" edges in white
// so user can see what node they are working
// with
// draw the forced to zero edges in white
cam.setColor( Color.white );
for( int k1=0; k1<node.zeros.size(); k1++ )
{
Pair p = node.zeros.get(k1);
int k=p.first-1, j=p.second-1;
cam.drawLine( pts[k][0]/displayScale, pts[k][1]/displayScale,
pts[j][0]/displayScale, pts[j][1]/displayScale );
}
// draw the forced to one edges in black
cam.setColor( Color.black );
for( int k1=0; k1<node.ones.size(); k1++ )
{
Pair p = node.ones.get(k1);
int k=p.first-1, j=p.second-1;
cam.drawLine( pts[k][0]/displayScale, pts[k][1]/displayScale,
pts[j][0]/displayScale, pts[j][1]/displayScale );
}
// show the current editString
cam.setColor( Color.black );
cam.drawText( editString, 0.05, 0.05 );
}
public void keyTyped( KeyEvent e )
{
char key = e.getKeyChar();
if( key == 'g' )
{
useGrid = !useGrid;
}
else if( key == 'l' )
{
showLabels = !showLabels;
}
else if( key == 'q' )
{// save picture to tex file and quit
tex.println("$$\n\\beginpicture");
tex.println("\\setcoordinatesystem units <1true mm,1true mm>");
String[] vars = node.variables;
double[] vals = node.values;
double[][] pts = points;
// draw the points
for( int k=0; k<pts.length; k++ )
{
double px = pts[k][0], py = pts[k][1];
tex.println("\\put {$\\bullet$} at " + px + " " + py );
tex.println("\\put {\\tinytt " + (k+1) + "} [bl] at " + (px+1) + " " + (py+1) );
}
// draw the edges corresponding to xk,j > 0
for( int m=0; m < vars.length; m++ )
{
if( vars[m].charAt(0) == 'x' &&
vals[m] > tiny
)
{// pull out the indices and draw the edge
String w = vars[m];
int comma = w.indexOf( ',' );
int k = Integer.parseInt( w.substring(1,comma) );
int j = Integer.parseInt( w.substring(comma+1) );
double x1 = pts[k-1][0], y1 = pts[k-1][1];
double x2 = pts[j-1][0], y2 = pts[j-1][1];
if( Math.abs( vals[m] - 0.5 ) < tiny )
tex.println("\\setdots <1true mm>");
else
tex.println("\\setsolid");
tex.println("\\plot " + x1 + " " + y1 + " " + x2 + " " + y2 + " /" );
}
}
tex.println("\\setsolid");
tex.println("\\endpicture\n$$");
tex.close();
System.exit(0);
}// quit
}// keyTyped
public void keyPressed( KeyEvent e )
{
int code = e.getKeyCode();
if( editMode.equals( "regular" ) )
{
if( code == KeyEvent.VK_C )
{
editMode = "cutting";
editString = "cut ";
}
else if( code == KeyEvent.VK_B )
{
editMode = "branching";
editString = "branch on ";
}
else if( code == KeyEvent.VK_T )
{// process current node/tableau as a tour
editMode = "regular"; editString = "";
// update best node using current node
// based on user's claim that this node
// represents a tour
if( bestNode == null ||
bestNode.score > node.score )
{
bestNode = node; // will never be changed again, so okay
System.out.println("Updating best node to " + node );
}
branchAndBoundStep(); // get next best node in PQ
}
}
else if( editMode.equals( "cutting" ) )
{
if( KeyEvent.VK_0 <= code && code <= KeyEvent.VK_9)
editString += "" + (code - KeyEvent.VK_0 );
else if( code == KeyEvent.VK_SPACE )
editString += " ";
else if( code == KeyEvent.VK_DELETE || code == KeyEvent.VK_BACK_SPACE )
{
if( editString.length() > 4 )
editString = editString.substring( 0, editString.length()-1 );
}
else if( code == KeyEvent.VK_ENTER )
{// finish attempted cut
if( node.addCut( editString ) )
{// is okay cut, was added to node, re-solve this node with no change to pq
node.solve();
System.out.println("\n------------------");
System.out.println("after cut, current node is " + node );
System.out.println("------------------");
}
// whether cut succeeded or not, start anew
editMode = "regular"; editString = "";
}
}// cutting mode
else if( editMode.equals( "branching" ) )
{
if( KeyEvent.VK_0 <= code && code <= KeyEvent.VK_9)
editString += "" + (code - KeyEvent.VK_0 );
else if( code == KeyEvent.VK_SPACE )
editString += " ";
else if( code == KeyEvent.VK_DELETE || code == KeyEvent.VK_BACK_SPACE )
{
if( editString.length() > 10 )
editString = editString.substring( 0, editString.length()-1 );
}
else if( code == KeyEvent.VK_ENTER )
{// finish attempted branching
Node[] branchNodes = node.branch( editString );
if( branchNodes != null )
{
pq.add( branchNodes[0] );
pq.add( branchNodes[1] );
branchAndBoundStep();
}
// whether cut succeeded or not, start anew
editMode = "regular"; editString = "";
}
}// branching mode
else if( editMode.equals( "optimal" ) )
{
if( code == KeyEvent.VK_ESCAPE )
System.exit(0);
}
}// keyPressed
// do a step of the main branch and bound algorithm
private void branchAndBoundStep()
{
System.out.println("\n-------------------- priority queue in branch and bound step ----------");
// remove all nodes with score worse than bestNode
if( bestNode != null )
{
for( int k=pq.size()-1; k>=0; k-- )
{
Node current = pq.get(k);
if( current.score > bestNode.score )
{
System.out.println("pruning node " + current.id + " with score " +
current.score );
pq.remove(k);
}
}
}
if( pq.size() == 0 )
{
System.out.println("Priority queue is empty of nodes");
if( bestNode == null )
{
System.out.println("Never found any tour???");
System.exit(0);
}
else
{
node = bestNode;
System.out.println("Best node: " + node );
editMode = "optimal";
}
}
else
{// pq is not empty
System.out.println( pq.get(0) );
// remove best node
int best = 0;
for( int k=1; k<pq.size(); k++ )
{
System.out.println( pq.get(k) );
if( pq.get(best).score > pq.get(k).score )
best = k;
}
node = pq.get(best);
System.out.println("Explore node <<< " + node.id + " >>> and remove from PQ");
pq.remove( best );
}
}
public void mouseMoved(MouseEvent e)
{
super.mouseMoved(e);
}
public void mouseDragged(MouseEvent e)
{
super.mouseDragged(e);
}
public void mouseClicked(MouseEvent e)
{
super.mouseClicked(e);
}
public void mousePressed(MouseEvent e)
{
super.mousePressed(e);
}
private int nearestInt( double a )
{
return (int) Math.round( a );
}
public void mouseReleased(MouseEvent e)
{
super.mouseReleased(e);
}
public void mouseEntered(MouseEvent e)
{
super.mouseEntered(e);
}
public void mouseExited(MouseEvent e)
{
super.mouseExited(e);
}
} | [
"[email protected]"
] | |
61e631b218e560d45d3efdf7350c1fa8ebf3de92 | 9910b65d723a7dba37ea67add90d93ebcf9b3560 | /JavaFX/src/de/julian/javafx/basics/Example001.java | 1b67904ab70424181ca3b14a4f0e89ec9522849c | [] | no_license | Jules182/JavaFX | 6558026b21ab5c268047bc3fb12e135642ee5c1a | a8150856aba2a6d6e6fe3f2538befed081a9cb76 | refs/heads/master | 2021-01-13T12:37:56.064636 | 2016-10-27T10:19:48 | 2016-10-27T10:19:48 | 72,540,579 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 923 | java | package de.julian.javafx.basics;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class Example001 extends Application {
// initialization before running the Application
public void init() {
};
// start method = entry point
public void start(Stage primaryStage) {
// set Name of stage/wndw
primaryStage.setTitle("Hello World");
// set the stage using a scene and put a basic layout on the scene
StackPane root = new StackPane();
primaryStage.setScene(new Scene(root, 400, 300));
// add text
root.getChildren().add(new Label("Hi there, I'm Julian from Germany"));
// show stage
primaryStage.show();
}
// clean up work
public void stop() {
};
// main to start application
public static void main(String[] args) {
launch(args);
}
} | [
"[email protected]"
] | |
0c3b8d9b5a52250579632ebbaaed864f8151eeda | aec71b91f92d3ae02f3b3c0d9247e9c2695fb1ce | /src/main/java/at/fhv/ubertwo/config/Constants.java | 6b48e82066e3b0b39c676cb0bf67e142ba68b2e6 | [] | no_license | valerie9/JHipster | d3ca5745689c8c959fc8adfa358e414eeb583549 | 6b379b3245cc9ee2a31af7578ee69fd4fcebf38d | refs/heads/master | 2022-12-22T08:14:05.267078 | 2020-02-05T13:34:16 | 2020-02-05T13:34:16 | 234,085,482 | 0 | 0 | null | 2022-12-16T04:43:27 | 2020-01-15T13:22:12 | Java | UTF-8 | Java | false | false | 419 | java | package at.fhv.ubertwo.config;
/**
* Application constants.
*/
public final class Constants {
// Regex for acceptable logins
public static final String LOGIN_REGEX = "^[_.@A-Za-z0-9-]*$";
public static final String SYSTEM_ACCOUNT = "system";
public static final String DEFAULT_LANGUAGE = "en";
public static final String ANONYMOUS_USER = "anonymoususer";
private Constants() {
}
}
| [
"[email protected]"
] | |
99db3bdc2b9d185ec14ce46e0558d9edb4ce9017 | e56bde2f20581f823f120501d4eaa74387750350 | /src/test/java/com/task/tests/FamilyTreeTest.java | 1836bb5b2e6ae754571eb67493fbfe275bd353d4 | [] | no_license | johnny-dash/family-tree | d85e05aa10a2da6062a8fe2c19a937f9b10c2773 | 21e5b5af1ae089e94f88d7068c5de14449768df9 | refs/heads/master | 2020-03-19T04:12:30.860270 | 2018-06-03T09:50:13 | 2018-06-03T09:50:13 | 135,805,298 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,963 | java | package com.task.test;
import static org.junit.Assert.*;
import com.task.*;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
public class FamilyTreeTest {
private FamilyTree testTree;
@Before
public void setUp() {
this.testTree = new FamilyTree();
}
@Test
public void testGetFather() {
ArrayList<String> result = this.testTree.serachRelatives("Chit", "Father");
assertEquals(result.size(), 1);
assertTrue(result.contains("King Shan"));
}
@Test
public void testGetMother() {
ArrayList<String> result = this.testTree.serachRelatives("Jata", "Mother");
assertEquals(result.size(), 1);
assertTrue(result.contains("Jaya"));
}
@Test
public void testGetChildren() {
ArrayList<String> result = this.testTree.serachRelatives("Saty", "Children");
assertEquals(result.size(), 3);
assertTrue(result.contains("Satvy"));
assertTrue(result.contains("Savya"));
assertTrue(result.contains("Saayan"));
}
@Test
public void testGetSon() {
ArrayList<String> result = this.testTree.serachRelatives("King Shan", "Son");
assertEquals(result.size(), 3);
assertTrue(result.contains("Ish"));
assertTrue(result.contains("Chit"));
assertTrue(result.contains("Vich"));
}
@Test
public void testGetDaughter() {
ArrayList<String> result = this.testTree.serachRelatives("Lika", "Daughter");
assertEquals(result.size(), 1);
assertTrue(result.contains("Chika"));
}
@Test
public void testGetCousin() {
ArrayList<String> result = this.testTree.serachRelatives("Chit", "Cousin");
assertEquals(result.size(), 3);
assertTrue(result.contains("Ish"));
assertTrue(result.contains("Saty"));
assertTrue(result.contains("Vich"));
}
@Test
public void testGetBrother() {
ArrayList<String> result = this.testTree.serachRelatives("Saayan", "Brother");
assertEquals(result.size(), 1);
assertTrue(result.contains("Savya"));
}
@Test
public void testGetSister() {
ArrayList<String> result = this.testTree.serachRelatives("Satvy", "Sister");
assertEquals(result.size(), 0);
}
@Test
public void testGetGrandSon() {
ArrayList<String> result = this.testTree.serachRelatives("King Shan", "Grand Son");
assertEquals(result.size(), 5);
assertTrue(result.contains("Drita"));
assertTrue(result.contains("Vrita"));
assertTrue(result.contains("Vila"));
assertTrue(result.contains("Savya"));
assertTrue(result.contains("Saayan"));
}
@Test
public void testGetGrandDaughter() {
ArrayList<String> result = this.testTree.serachRelatives("Lika", "Grand Daughter");
assertEquals(result.size(), 1);
assertTrue(result.contains("Lavnya"));
}
@Test
public void testGetPaternalUncle() {
ArrayList<String> result = this.testTree.serachRelatives("Jata", "Paternal Uncle");
assertEquals(result.size(), 1);
assertTrue(result.contains("Vrita"));
}
@Test
public void testGetMaternalUncle() {
ArrayList<String> result = this.testTree.serachRelatives("Satvy", "Maternal Uncle");
assertEquals(result.size(), 3);
assertTrue(result.contains("Ish"));
assertTrue(result.contains("Chit"));
assertTrue(result.contains("Vich"));
}
@Test
public void testGetPaternalAunt() {
ArrayList<String> result = this.testTree.serachRelatives("Drita", "Paternal Aunt");
assertEquals(result.size(), 1);
assertTrue(result.contains("Saty"));
}
@Test
public void testGetMaternalAunt() {
ArrayList<String> result = this.testTree.serachRelatives("Savya", "Maternal Aunt");
assertEquals(result.size(), 0);
}
@Test
public void testGetBrotherInLaw() {
ArrayList<String> result = this.testTree.serachRelatives("Ambi", "Brother In Law");
assertEquals(result.size(), 2);
assertTrue(result.contains("Ish"));
assertTrue(result.contains("Vich"));
}
@Test
public void testGetSisterInLaw() {
ArrayList<String> result = this.testTree.serachRelatives("Ambi", "Sister In Law");
assertEquals(result.size(), 1);
assertTrue(result.contains("Saty"));
}
} | [
"[email protected]"
] | |
b003d8d877363d8f2c80ae4ce05ab74de9927c38 | 2b555b360141ec625fc1d194431465cba79fac1f | /src/main/java/frc/team5332/util/PlaybackRecording.java | 7a3ab5c79b5a132d2779ca5ef7522cbdbbbca8ea | [] | no_license | ToasterTech/RobotCode2018 | 62d8ef1c3a894f2692585ca350082a48371ce178 | 6269f7e758fd4daf74bc8be547ff28de4ff63bf9 | refs/heads/master | 2018-11-21T20:45:13.280668 | 2018-09-24T20:11:16 | 2018-09-24T20:11:16 | 116,533,375 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,473 | java | package main.java.frc.team5332.util;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.command.Command;
import main.java.frc.team5332.robot.CMap;
import java.util.ArrayList;
public class PlaybackRecording extends Command{
boolean warningIssued = false;
ArrayList<Cycle> playbackCycles = new ArrayList<>();
int cycleIndex;
String fileName;
public PlaybackRecording(String file){
cycleIndex = 0;
fileName = file;
try{
playbackCycles = ToasterDVR.readPath(fileName);
} catch (Exception e){
DriverStation.reportError("Unable to Get Cycles", e.getStackTrace());
}
}
public PlaybackRecording(ArrayList<Cycle> cycles){
cycleIndex = 0;
playbackCycles = cycles;
}
@Override
protected void execute() {
if(ToasterDVR.isEnabled()) {
if (!warningIssued) {
warningIssued = true;
DriverStation.reportWarning("Playback Starting", false);
}
if (playbackCycles.size() == 0) {
try {
playbackCycles = ToasterDVR.readPath(fileName);
} catch (Exception e) {
DriverStation.reportError("Unable to Get Cycles", e.getStackTrace());
}
}
Cycle currentCycle = playbackCycles.get(cycleIndex);
CMap.drive.tankDrive(-currentCycle.leftJoystickValue, -currentCycle.rightJoystickValue);
CMap.elevator.setMotorSpeed(currentCycle.elevatorJoystickValue);
CMap.carriage.setCarriageMotor(currentCycle.getCarriageMotorValues());
CMap.intake.spinRollers(currentCycle.getIntakeMotorValues());
CMap.intake.changeIntakeArmState(Boolean.parseBoolean(currentCycle.getIntakeArmsDown()));
CMap.intake.changeOpenCloseIntakeState(currentCycle.getIntakeArmsOpen());
cycleIndex += 1;
} else {
DriverStation.reportError("Toaster DVR is Disabled. Please enable it before trying again", false);
end();
}
}
@Override
protected boolean isFinished() {
return cycleIndex >= playbackCycles.size();
}
@Override
protected void end() {
cycleIndex = 0;
playbackCycles = new ArrayList<>();
CMap.drive.tankDrive(0, 0);
CMap.elevator.setMotorSpeed(0);
System.out.println("Finished Playback");
}
}
| [
"[email protected]"
] | |
dab40e116a9267b847daeec6c7288d819c2db843 | 24a4dc6dfbd802bd0cfcb3b8d4eb686536a4c6db | /provider-demo/provider-web/src/main/java/com/vedeng/template/web/controller/KafkaController.java | abb0e7a80ba2e66524646d99445df2acf6d7331e | [] | no_license | polishgem/springcloud-template | 2ffcda38e1672411c5bc67e00cec4e56d6892d52 | 0dc429c586c7feb3e025340928a518e1e8d2115a | refs/heads/master | 2022-06-29T06:51:54.924156 | 2019-06-20T09:36:49 | 2019-06-20T09:36:49 | 175,333,958 | 0 | 0 | null | 2022-06-21T01:13:53 | 2019-03-13T02:46:46 | Java | UTF-8 | Java | false | false | 669 | java | package com.vedeng.template.web.controller;
import com.vedeng.template.service.KafkaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Description:
* @Auther: Duke.li
* @Date: 2019/3/14 21:26
*/
@RestController
@RequestMapping("kafka")
public class KafkaController {
@Autowired
private KafkaService kafkaService;
@GetMapping("/send")
public void apolloTest(String topic, String msg) {
kafkaService.send(topic, msg);
}
}
| [
"[email protected]"
] | |
52d666ef294c2e70e521d27224f95ef686f8d670 | 2a19e167248bc4e8f3a3c74fd3b22a13d2405379 | /stage/StageFactory.java | aad248ee06b9478501c96409d2f43bafa45074b2 | [] | no_license | TomasAmaro/Booger-Dance | a08dceb1af1c2816bc91d3fd1412f19a7f7886cf | 5f9c8483d89d690d36ea8239bf9c636fbe507741 | refs/heads/master | 2021-01-11T20:30:26.250250 | 2017-01-16T15:04:49 | 2017-01-16T15:04:49 | 79,129,554 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 712 | java | package org.academniadecodigo.dancedance.stage;
import org.academniadecodigo.dancedance.simplegfx.StageSgfx;
/**
* A factory of different types of stages
*/
public class StageFactory {
/**
* Creates a new stage
*
* @param stageType the type of stage to create
* @param cols the number of columns of the stage
* @param rows the number of rows of the stage
* @return the new stage
*/
public static Stage createStage(StageType stageType, int cols, int rows) {
switch (stageType) {
case SIMPLE_GFX:
return new StageSgfx(cols, rows);
default:
return new StageSgfx(cols, rows);
}
}
}
| [
"[email protected]"
] | |
1b58d314e6a9be0ddd31bd42aca16c6e039bb72d | fb33e12379f3233ff1bcb859ce4f237b0d95a180 | /src/main/java/lang/reflect/Method/ReflectMethodDemo.java | bfda8f56c757f1a2be5f55d1459d78e1871b9c4e | [] | no_license | abelzyp/JavaAPI | b2557aa84650087f22553be0aaee43c1bf5c13c3 | 82ba3b18e03141d5446c8cbadf46fe729e781a43 | refs/heads/master | 2020-04-06T06:59:52.416071 | 2020-01-15T07:18:05 | 2020-01-15T07:18:05 | 60,389,265 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,569 | java | package lang.reflect.Method;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import lang.reflect.Reflect.Person;
/*
* 通过反射获取成员方法并使用
*
* 获取所有的方法:
* public Method[] getMethods():返回一个包含某些 Method对象的数组,这些对象反映此 Class对象所表示的类或接口的公共 member方法。
* public Method[] getDeclaredMethods():返回 Method对象的一个数组,这些对象反映此 Class对象表示的类或接口声明的所有方法,包括公共、保护、默认(包)访问和私有方法,但不包括继承的方法。
* 获取单个方法:
* public Method getMethod(String name,Class<?>... parameterTypes):返回一个包含某些 Method对象的数组,这些对象反映此 Class对象所表示的类或接口的公共 member方法。
* public Method getDeclaredMethod(String name,Class<?>... parameterTypes):返回一个 Method对象,该对象反映此 Class对象所表示的类或接口的指定已声明方法。
*/
public class ReflectMethodDemo {
public static void main(String[] args) throws Exception {
// 获取字节码文件对象
Class c = Class.forName("lang.reflect.Reflect.Person");
// 获取所有的方法
// Method[] methods = c.getMethods(); // 获取自己的包括父亲的公共方法
Method[] methods = c.getDeclaredMethods(); // 获取自己的所有的方法
for (Method method : methods) {
System.out.println(method);
}
Constructor con = c.getConstructor();
Object obj = con.newInstance();
Person p = new Person();
p.show();
// 获取单个方法并使用
// public void show()
Method m1 = c.getMethod("show");
// obj.m1(); // 错误
// public Object invoke(Object obj,Object... args)
// 返回值是Object接收,第一个参数表示对象是谁,第二参数表示调用该方法的实际参数
m1.invoke(obj); // 调用obj对象的m1方法
System.out.println("----------");
// public void method(String s)
Method m2 = c.getMethod("method", String.class);
m2.invoke(obj, "hello");
System.out.println("----------");
// public String getString(String s, int i)
Method m3 = c.getMethod("getString", String.class, int.class);
Object objString = m3.invoke(obj, "hello", 100);
System.out.println(objString);
// String s = (String)m3.invoke(obj, "hello",100);
// System.out.println(s);
System.out.println("----------");
// private void function()
Method m4 = c.getDeclaredMethod("function");
m4.setAccessible(true);
m4.invoke(obj);
}
}
| [
"[email protected]"
] | |
c6427ea8f158dca89be2be327549d23b60260f09 | c885ef92397be9d54b87741f01557f61d3f794f3 | /tests-without-trycatch/Closure-114/com.google.javascript.jscomp.NameAnalyzer/BBC-F0-opt-40/26/com/google/javascript/jscomp/NameAnalyzer_ESTest.java | 28fbcb32b661b081ed646997587772fbd0442ff9 | [
"CC-BY-4.0",
"MIT"
] | permissive | pderakhshanfar/EMSE-BBC-experiment | f60ac5f7664dd9a85f755a00a57ec12c7551e8c6 | fea1a92c2e7ba7080b8529e2052259c9b697bbda | refs/heads/main | 2022-11-25T00:39:58.983828 | 2022-04-12T16:04:26 | 2022-04-12T16:04:26 | 309,335,889 | 0 | 1 | null | 2021-11-05T11:18:43 | 2020-11-02T10:30:38 | null | UTF-8 | Java | false | false | 13,366 | java | /*
* This file was automatically generated by EvoSuite
* Sat Oct 23 23:52:21 GMT 2021
*/
package com.google.javascript.jscomp;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.evosuite.runtime.EvoAssertions.*;
import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.NameAnalyzer;
import com.google.javascript.rhino.Node;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.evosuite.runtime.mock.java.io.MockPrintStream;
import org.junit.runner.RunWith;
@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true)
public class NameAnalyzer_ESTest extends NameAnalyzer_ESTest_scaffolding {
@Test(timeout = 4000)
public void test00() throws Throwable {
Compiler compiler0 = new Compiler();
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, false);
nameAnalyzer0.removeUnreferenced();
}
@Test(timeout = 4000)
public void test01() throws Throwable {
Compiler compiler0 = new Compiler();
Node node0 = new Node((-1672));
// Undeclared exception!
// try {
compiler0.parseSyntheticCode("TML", "oHci5ng");
// // fail("Expecting exception: IllegalArgumentException");
// Unstable assertion
// } catch(IllegalArgumentException e) {
// //
// // Multiple entries with same key: author=NOT_IMPLEMENTED and author=AUTHOR
// //
// verifyException("com.google.common.collect.ImmutableMap", e);
// }
}
@Test(timeout = 4000)
public void test02() throws Throwable {
Compiler compiler0 = new Compiler();
Node node0 = new Node((-1616392753));
Node node1 = new Node(86, node0, node0, node0, 30, 57);
Node node2 = new Node(86, node1, 51, 8);
Node node3 = new Node(85, node2, 971, (-3));
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
nameAnalyzer0.process(node1, node3);
assertEquals(30, node1.getLineno());
}
@Test(timeout = 4000)
public void test03() throws Throwable {
Compiler compiler0 = new Compiler();
Node node0 = new Node(35);
Node node1 = new Node((-1574), node0);
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
// Undeclared exception!
// try {
nameAnalyzer0.process(node1, node1);
// fail("Expecting exception: RuntimeException");
// } catch(RuntimeException e) {
// }
}
@Test(timeout = 4000)
public void test04() throws Throwable {
MockPrintStream mockPrintStream0 = new MockPrintStream("qUzyP@Jhu");
Compiler compiler0 = new Compiler(mockPrintStream0);
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
Node node0 = compiler0.parseSyntheticCode("com.google.javascript.jscomp.NameAnalyzer$ProcessExternals", "com.google.javascript.jscomp.NameAnalyzer$ProcessExternals");
nameAnalyzer0.process(node0, node0);
assertTrue(node0.mayMutateGlobalStateOrThrow());
}
@Test(timeout = 4000)
public void test05() throws Throwable {
Compiler compiler0 = new Compiler();
Node node0 = new Node(115, 115, (-1277));
Node node1 = new Node(4, node0, node0, node0, 64, 86);
Node node2 = new Node(114, node1, 2, 57);
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, false);
// Undeclared exception!
// try {
nameAnalyzer0.process(node0, node2);
// fail("Expecting exception: RuntimeException");
// } catch(RuntimeException e) {
// }
}
@Test(timeout = 4000)
public void test06() throws Throwable {
Compiler compiler0 = new Compiler();
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, false);
Node node0 = new Node(1147, 1147, 1147);
Node node1 = new Node(110, node0, node0, node0, 47, 39);
Node node2 = new Node(111, node1, 2, 42);
nameAnalyzer0.process(node2, node2);
assertFalse(node2.isNull());
}
@Test(timeout = 4000)
public void test07() throws Throwable {
Compiler compiler0 = new Compiler();
Node node0 = new Node(119, 119, 119);
Node node1 = new Node(119, node0, node0, node0, 4095, 1);
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, false);
nameAnalyzer0.process(node1, node1);
assertFalse(node1.isAnd());
}
@Test(timeout = 4000)
public void test08() throws Throwable {
Compiler compiler0 = new Compiler();
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
Node node0 = new Node(1147, 1147, 1147);
Node node1 = new Node(113, node0, node0, node0, 39, 46);
Node node2 = new Node(162, node1, 162, 39);
nameAnalyzer0.process(node2, node2);
assertEquals(39, node2.getCharno());
}
@Test(timeout = 4000)
public void test09() throws Throwable {
Compiler compiler0 = new Compiler();
Node node0 = new Node(115, 115, (-1277));
Node node1 = new Node(68, node0, node0, 4095, 36);
Node node2 = new Node(108, node1, 15, (-16));
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, false);
// Undeclared exception!
// try {
nameAnalyzer0.process(node0, node2);
// fail("Expecting exception: RuntimeException");
// } catch(RuntimeException e) {
// }
}
@Test(timeout = 4000)
public void test10() throws Throwable {
Compiler compiler0 = new Compiler();
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
Node node0 = new Node(1147, 1147, 1147);
Node node1 = new Node(86, node0, node0, node0, 47, 39);
Node node2 = new Node(4, node1, 3691, 46);
nameAnalyzer0.process(node1, node2);
assertTrue(node1.hasChildren());
}
@Test(timeout = 4000)
public void test11() throws Throwable {
Compiler compiler0 = new Compiler();
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, false);
Node node0 = new Node(1145, 1145, 1145);
Node node1 = Node.newString("param", (-459), 32);
node0.addChildrenToBack(node1);
Node node2 = new Node(118, node0, 47, 8);
nameAnalyzer0.process(node0, node2);
assertEquals(8, Node.FLAG_NO_THROWS);
}
@Test(timeout = 4000)
public void test12() throws Throwable {
Compiler compiler0 = new Compiler();
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, false);
Node node0 = new Node(1147, 1147, 1147);
Node node1 = new Node(118, node0, node0, node0, 1406, (-52));
nameAnalyzer0.process(node0, node1);
assertEquals(43, Node.IS_CONSTANT_NAME);
}
@Test(timeout = 4000)
public void test13() throws Throwable {
Compiler compiler0 = new Compiler();
Node node0 = Node.newString(147, "INTERFACE");
Node node1 = new Node(29, node0, node0, node0, (-207), 1138);
Node node2 = new Node(30, node1, 85, 8);
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
nameAnalyzer0.process(node2, node0);
assertFalse(node2.isOnlyModifiesArgumentsCall());
}
@Test(timeout = 4000)
public void test14() throws Throwable {
Compiler compiler0 = new Compiler();
Node node0 = new Node((-3932));
Node node1 = new Node(86, node0, node0, node0, 40, 48);
Node node2 = new Node(101, node1, 1, 38);
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, false);
nameAnalyzer0.process(node1, node1);
assertFalse(node1.isCast());
}
@Test(timeout = 4000)
public void test15() throws Throwable {
Compiler compiler0 = new Compiler();
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
Node node0 = new Node(4317);
Node node1 = new Node(86, node0, node0, node0, (-1302), (-432));
Node node2 = new Node(100, node1, (-2616), 92);
// Undeclared exception!
// try {
nameAnalyzer0.process(node0, node1);
// fail("Expecting exception: RuntimeException");
// } catch(RuntimeException e) {
// }
}
@Test(timeout = 4000)
public void test16() throws Throwable {
Compiler compiler0 = new Compiler();
Node node0 = new Node((-1616392753));
Node node1 = new Node(86, node0, node0, node0, 30, 57);
Node node2 = new Node(86, node1, 51, 8);
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
// Undeclared exception!
// try {
nameAnalyzer0.process(node1, node1);
// fail("Expecting exception: RuntimeException");
// } catch(RuntimeException e) {
// }
}
@Test(timeout = 4000)
public void test17() throws Throwable {
Compiler compiler0 = new Compiler();
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
Node node0 = new Node(1147, 1147, 1147);
Node node1 = new Node(86, node0, node0, node0, 47, 39);
Node node2 = new Node(49, node1, 32, 12);
nameAnalyzer0.process(node1, node2);
assertEquals(50, Node.FREE_CALL);
}
@Test(timeout = 4000)
public void test18() throws Throwable {
Compiler compiler0 = new Compiler();
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
Node node0 = new Node(1147, 1147, 1147);
Node node1 = new Node(86, node0, node0, node0, 47, 39);
Node node2 = new Node(38, node1, 2, 42);
// Undeclared exception!
// try {
nameAnalyzer0.process(node1, node1);
// fail("Expecting exception: RuntimeException");
// } catch(RuntimeException e) {
// }
}
@Test(timeout = 4000)
public void test19() throws Throwable {
Compiler compiler0 = new Compiler();
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
Node node0 = compiler0.parseSyntheticCode("|S#`Cv=", "Hashing");
Node node1 = new Node(40, node0, node0, 1, (-83));
Node node2 = new Node(86, node1, 172, 2);
nameAnalyzer0.process(node2, node2);
assertEquals(56, Node.CHANGE_TIME);
}
@Test(timeout = 4000)
public void test20() throws Throwable {
Compiler compiler0 = new Compiler();
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
Node node0 = compiler0.parseSyntheticCode("function JSCompiler_set(JSCompiler_set_name) { return function(JSCompiler_set_value) {this[JSCompiler_set_name] = JSCompiler_set_value}}", "function JSCompiler_set(JSCompiler_set_name) { return function(JSCompiler_set_value) {this[JSCompiler_set_name] = JSCompiler_set_value}}");
// Undeclared exception!
// try {
nameAnalyzer0.process(node0, node0);
// fail("Expecting exception: NullPointerException");
// } catch(NullPointerException e) {
// //
// // no message in exception (getMessage() returned null)
// //
// verifyException("com.google.javascript.jscomp.Compiler", e);
// }
}
@Test(timeout = 4000)
public void test21() throws Throwable {
Compiler compiler0 = new Compiler();
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, false);
Node node0 = new Node(38);
Node node1 = new Node(118, node0, node0, node0);
// Undeclared exception!
// try {
nameAnalyzer0.process(node1, node1);
// fail("Expecting exception: RuntimeException");
// } catch(RuntimeException e) {
// }
}
@Test(timeout = 4000)
public void test22() throws Throwable {
Compiler compiler0 = new Compiler();
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, false);
Node node0 = compiler0.parseSyntheticCode("window", "Hashing.md5()");
nameAnalyzer0.process(node0, node0);
assertFalse(node0.isComma());
}
@Test(timeout = 4000)
public void test23() throws Throwable {
MockPrintStream mockPrintStream0 = new MockPrintStream("qUzyP@Jhu");
Node node0 = new Node(64, (-9), 64);
Compiler compiler0 = new Compiler(mockPrintStream0);
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
nameAnalyzer0.process(node0, node0);
String string0 = nameAnalyzer0.getHtmlReport();
assertEquals("<html><body><style type=\"text/css\">body, td, p {font-family: Arial; font-size: 83%} ul {margin-top:2px; margin-left:0px; padding-left:1em;} li {margin-top:3px; margin-left:24px; padding-left:0px;padding-bottom: 4px}</style>OVERALL STATS<ul><li>Total Names: 2</li>\n<li>Total Classes: 0</li>\n<li>Total Static Functions: 2</li>\n<li>Referenced Names: 2</li>\n<li>Referenced Classes: 0</li>\n<li>Referenced Functions: 2</li>\n</ul>ALL NAMES<ul>\n<li><a name=\"Function\">Function</a><ul></li></ul></li><li><a name=\"window\">window</a><ul></li></ul></li></ul></body></html>", string0);
}
@Test(timeout = 4000)
public void test24() throws Throwable {
MockPrintStream mockPrintStream0 = new MockPrintStream("qUzyP@Jhu");
Node node0 = new Node(58, (-9), 58);
Compiler compiler0 = new Compiler(mockPrintStream0);
NameAnalyzer nameAnalyzer0 = new NameAnalyzer(compiler0, true);
nameAnalyzer0.process(node0, node0);
Node node1 = compiler0.parseSyntheticCode("|#{c:~'hM 0~lg+p+:-", "window");
nameAnalyzer0.process(node0, node1);
assertEquals(51, Node.STATIC_SOURCE_FILE);
}
}
| [
"[email protected]"
] | |
c5d5752d8338b8190d16cd8a648171982332bd09 | d11fb0d15b73a28742caa97e349dcfbe70d2563f | /server/iih_pub/iih.ci_pub/src/main/java/iih/ci/ord/content/d/CiOrLeaveHosContentFactory.java | ade5edab8ea15c7cf45b8b8d942492b6a35a9e5c | [] | no_license | fhis/order.client | 50a363fd3e4f56d95ccc5aa288e907a0a8571031 | 56cfa7877f600a10c54fdb30306a32ffa28b8217 | refs/heads/master | 2021-08-22T20:50:59.511923 | 2017-12-01T07:10:27 | 2017-12-01T07:10:27 | 112,678,072 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,439 | java | package iih.ci.ord.content.d;
import java.util.ArrayList;
import xap.mw.core.data.DOStatus;
import xap.mw.core.data.FArrayList;
import xap.mw.core.data.FMap;
import iih.ci.ord.cior.d.OrdApOutDO;
import iih.ci.ord.cior.d.OrdApTransDO;
import iih.ci.ord.ciordems.d.EmsType;
import iih.ci.ord.ems.d.CiEmsDTO;
import iih.ci.ord.ems.d.CiEmsSrvDTO;
public class CiOrLeaveHosContentFactory implements CiOrContentObjFactory {
@Override
public CiOrContentDO create(CiEmsDTO ems) {
// TODO Auto-generated method stub
if(ems==null || ems.getEmssrvs()==null || ems.getEmssrvs().size()==0){
return getNullContent(ems);
}
CiOrContentDO contentdo=new CiOrContentDO();
String sd_srvtp = ((CiEmsSrvDTO)ems.getEmssrvs().get(0)).getSd_srvtp();
if(sd_srvtp != null && sd_srvtp !=""){
contentdo.setTypeId(sd_srvtp);
}else{
contentdo.setTypeId(ICiOrContentConst.ORContent_TYPE_DEFAULT);
}
contentdo.setTitle(getTitle(ems));
contentdo.setItemInfos(getItemInfos(ems));
contentdo.setTailInfo(getTailInfos(ems));
return contentdo;
}
/**
* 获得标题数据
* @param ems
* @return
*/
private String getTitle(CiEmsDTO ems){
return ems.getName();
}
/**
* 获得表体数据
* @param ems
* @return
*/
private ArrayList<ArrayList<String>> getItemInfos(CiEmsDTO ems){
if(ems == null || ems.getEmssrvs() == null) return null;
ArrayList<ArrayList<String>> list = new ArrayList<ArrayList<String>>();
ArrayList<String> arrList = new ArrayList<String>();
FArrayList emssrvs = ems.getEmssrvs();
for(int i=0;i <emssrvs.size();i++){
CiEmsSrvDTO item = (CiEmsSrvDTO) emssrvs.get(i);
if(item.getStatus() == DOStatus.DELETED)continue;
FMap map = (FMap)ems.getOrapplysheet();
OrdApOutDO trando = (OrdApOutDO)map.get(EmsType.OUTHOSP.toString());
arrList.add("拟于"+trando.getDt_timeout() +""+ ems.getName());
}
list.add(arrList);
return list;
}
/**
* 获得表尾数据
* @param ems
* @return
*/
private ArrayList<String> getTailInfos(CiEmsDTO ems){
ArrayList<String> list = new ArrayList<String>();
list.add(ICiOrContentConst.ChangeToEscapeCharacter(ems.getName_routedes()));
return list;
}
/**
* 获得空医嘱内容
* @param ems
*/
private CiOrContentDO getNullContent(CiEmsDTO ems){
NullOrContentFactory nullfact=new NullOrContentFactory();
return nullfact.create(ems);
}
}
| [
"[email protected]"
] | |
f7ddfa8678981aac76ebb50f417a17ddcfdfff6c | ef955dbb36b0bef707166e05d7b85ec96a519111 | /src/java/DAO/DeleteCarDAO.java | 4745e7ccc44915910237bb521c298b393d066b1b | [] | no_license | PuteraSyabil/ProjectCRS | 745d2196f23bc226fd23e53a50007c4dc4502009 | 0e2f90d9508e1c0652a9b72cfa8c4892af7e9a8a | refs/heads/master | 2023-02-26T10:08:35.075833 | 2021-02-03T07:38:44 | 2021-02-03T07:38:44 | 323,645,142 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,388 | 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 DAO;
import bean.Car;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
/**
*
* @author pharveish
*/
public class DeleteCarDAO {
public String DeleteCar(Car car)
{
String carNo= String.valueOf(car.getCarNo());
String url = "jdbc:mysql://localhost:3306/CRS_project";
String uname="root";
String pass = "void";
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(url,uname,pass);
PreparedStatement pstmt = null;
pstmt=con.prepareStatement("delete from car where carNo=?");
pstmt.setString(1, carNo);
pstmt.executeUpdate();
pstmt.close();
con.close();
return "SUCCESS DELETE CAR";
}
catch(Exception e)
{
e.printStackTrace();
}
return "FAIL DELETE CAR";
}
}
| [
"[email protected]"
] | |
f413808ca7d08e519b4a8bbf8123836982e3e4d0 | 78348f3d385a2d1eddcf3d7bfee7eaf1259d3c6e | /examples/uml/fr.inria.diverse.puzzle.uml.composedLanguage/src-gen/CompleteDSLPckg/impl/LinkActionImpl.java | 593600460fab0d8769db9c6a45712e9525e3e00c | [] | no_license | damenac/puzzle | 6ac0a2fba6eb531ccfa7bec3a5ecabf6abb5795e | f74b23fd14ed5d6024667bf5fbcfe0418dc696fa | refs/heads/master | 2021-06-14T21:23:05.874869 | 2017-03-27T10:24:31 | 2017-03-27T10:24:31 | 40,361,967 | 3 | 1 | null | null | null | null | UTF-8 | Java | false | false | 4,749 | java | /**
*/
package CompleteDSLPckg.impl;
import CompleteDSLPckg.CompleteDSLPckgPackage;
import CompleteDSLPckg.InputPin;
import CompleteDSLPckg.LinkAction;
import CompleteDSLPckg.LinkEndData;
import java.util.Collection;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Link Action</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link CompleteDSLPckg.impl.LinkActionImpl#getInputValue <em>Input Value</em>}</li>
* <li>{@link CompleteDSLPckg.impl.LinkActionImpl#getEndData <em>End Data</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class LinkActionImpl extends ActionImpl implements LinkAction {
/**
* The cached value of the '{@link #getInputValue() <em>Input Value</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getInputValue()
* @generated
* @ordered
*/
protected EList<InputPin> inputValue;
/**
* The cached value of the '{@link #getEndData() <em>End Data</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getEndData()
* @generated
* @ordered
*/
protected EList<LinkEndData> endData;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected LinkActionImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CompleteDSLPckgPackage.eINSTANCE.getLinkAction();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<InputPin> getInputValue() {
if (inputValue == null) {
inputValue = new EObjectContainmentEList<InputPin>(InputPin.class, this, CompleteDSLPckgPackage.LINK_ACTION__INPUT_VALUE);
}
return inputValue;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<LinkEndData> getEndData() {
if (endData == null) {
endData = new EObjectContainmentEList<LinkEndData>(LinkEndData.class, this, CompleteDSLPckgPackage.LINK_ACTION__END_DATA);
}
return endData;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CompleteDSLPckgPackage.LINK_ACTION__INPUT_VALUE:
return ((InternalEList<?>)getInputValue()).basicRemove(otherEnd, msgs);
case CompleteDSLPckgPackage.LINK_ACTION__END_DATA:
return ((InternalEList<?>)getEndData()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case CompleteDSLPckgPackage.LINK_ACTION__INPUT_VALUE:
return getInputValue();
case CompleteDSLPckgPackage.LINK_ACTION__END_DATA:
return getEndData();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case CompleteDSLPckgPackage.LINK_ACTION__INPUT_VALUE:
getInputValue().clear();
getInputValue().addAll((Collection<? extends InputPin>)newValue);
return;
case CompleteDSLPckgPackage.LINK_ACTION__END_DATA:
getEndData().clear();
getEndData().addAll((Collection<? extends LinkEndData>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CompleteDSLPckgPackage.LINK_ACTION__INPUT_VALUE:
getInputValue().clear();
return;
case CompleteDSLPckgPackage.LINK_ACTION__END_DATA:
getEndData().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CompleteDSLPckgPackage.LINK_ACTION__INPUT_VALUE:
return inputValue != null && !inputValue.isEmpty();
case CompleteDSLPckgPackage.LINK_ACTION__END_DATA:
return endData != null && !endData.isEmpty();
}
return super.eIsSet(featureID);
}
} //LinkActionImpl
| [
"[email protected]"
] | |
84abba81bbcd60e91a49d7de8a2a6effa381bf9f | 4418eff790d98a823e5e351d863f0177a2203803 | /src/avogeom/CoordinateCollection.java | 4c2d098b82dde687dd994686952dac990c74ada5 | [] | no_license | AvoQueen/AvoGeometry | 9ca738b849d395121d150f7ff0633211b19b03f2 | 313e792d8e973ff9f04371642534115adc2ec8e3 | refs/heads/master | 2020-04-16T11:49:59.830296 | 2019-01-13T20:53:00 | 2019-01-13T20:53:00 | 165,553,174 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,061 | java | package avogeom;
import java.util.Arrays;
public class CoordinateCollection {
public Coordinate[] coordinates;
public CoordinateCollection(Coordinate... coordinates) {
this.coordinates = coordinates;
}
public CoordinateCollection() {
this.coordinates = new Coordinate[] {};
}
public CoordinateCollection(double[] coordinates) {
this.coordinates = new Coordinate[(int) coordinates.length / 2];
for (int i = 0; i < coordinates.length; i += 2) {
this.coordinates[i / 2] = new Coordinate(coordinates[i], coordinates[i + 1]);
}
}
public CoordinateCollection(double[][] coordinates) {
this.coordinates = new Coordinate[coordinates.length];
for (int i = 0; i < coordinates.length; i++) {
this.coordinates[i] = new Coordinate(coordinates[i][0], coordinates[i][1]);
}
}
public int amount() {
return coordinates.length;
}
public double[][] toArray_double() {
double[][] result = new double[coordinates.length][2];
for (int i = 0; i < coordinates.length; i++) {
result[i][0] = coordinates[i].x;
result[i][1] = coordinates[i].y;
}
return result;
}
public double[] toArray() {
double[] result = new double[coordinates.length * 2];
for (int i = 0; i < coordinates.length; i++) {
result[i * 2] = coordinates[i].x;
result[i * 2 + 1] = coordinates[i].y;
}
return result;
}
public Coordinate[] getCoordinates() {
return coordinates;
}
public void setCoordinates(Coordinate[] coordinates) {
this.coordinates = coordinates;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(coordinates);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CoordinateCollection other = (CoordinateCollection) obj;
if (!Arrays.equals(coordinates, other.coordinates))
return false;
return true;
}
}
| [
"[email protected]"
] | |
36b57e9eebca200d4de0aaddec40d8b6c41b10a9 | 8cd199f4dd1bd71e22b0ae35431149b9c3d4991d | /carpentersblocks/renderer/BlockHandlerCarpentersDoor.java | 4696e812a926a874f39e768d9505bcc514af78f7 | [] | no_license | rysson/carpentersblocks | 116a6ad7048c0334b6a1d631c593640e8d9461c6 | 916bcb045375e09ba641c79885a0aa82074c32fa | refs/heads/master | 2021-01-18T05:10:31.919288 | 2013-12-27T13:17:03 | 2013-12-27T13:17:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 36,493 | java | package carpentersblocks.renderer;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.Icon;
import carpentersblocks.block.BlockCarpentersDoor;
import carpentersblocks.data.Door;
import carpentersblocks.renderer.helper.RenderHelper;
import carpentersblocks.renderer.helper.VertexHelper;
import carpentersblocks.util.BlockProperties;
import carpentersblocks.util.registry.BlockRegistry;
import carpentersblocks.util.registry.IconRegistry;
public class BlockHandlerCarpentersDoor extends BlockDeterminantRender {
@Override
public boolean shouldRender3DInInventory()
{
return false;
}
@Override
/**
* Renders block
*/
protected boolean renderCarpentersBlock(int x, int y, int z)
{
renderBlocks.renderAllFaces = true;
Block block = BlockProperties.getCoverBlock(TE, 6);
int type = Door.getType(TE);
switch (type) {
case Door.TYPE_GLASS_TOP:
renderGlassTopDoor(block, x, y, z);
break;
case Door.TYPE_GLASS_TALL:
renderTallDoor(block, x, y, z);
break;
case Door.TYPE_PANELS:
renderPanelsDoor(block, x, y, z);
break;
case Door.TYPE_SCREEN_TALL:
renderTallDoor(block, x, y, z);
break;
case Door.TYPE_FRENCH_GLASS:
renderFrenchGlassDoor(block, x, y, z);
break;
case Door.TYPE_HIDDEN:
renderHiddenDoor(block, x, y, z);
break;
}
renderBlocks.renderAllFaces = false;
return true;
}
/**
* Renders a French glass door at the given coordinates
*/
private void renderFrenchGlassDoor(Block block, int x, int y, int z)
{
int hinge = Door.getHinge(TE);
int facing = Door.getFacing(TE);
boolean isOpen = Door.getState(TE) == Door.STATE_OPEN;
boolean isBottom = Door.getPiece(TE) == Door.PIECE_BOTTOM;
boolean path_on_x = false;
float path_offset = 0.0F;
float x_low = 0.0F;
float y_low = 0.0F;
float z_low = 0.0F;
float x_high = 1.0F;
float y_high = 1.0F;
float z_high = 1.0F;
float x_low_offset = 0.0F;
float z_low_offset = 0.0F;
float x_high_offset = 1.0F;
float z_high_offset = 1.0F;
switch (facing)
{
case Door.FACING_XN:
if (!isOpen) {
x_low = 0.8125F;
x_low_offset = x_low;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.09375F;
path_on_x = true;
} else if (hinge == Door.HINGE_RIGHT) {
z_high = 0.1875F;
z_high_offset = z_high;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.90625F;
} else {
z_low = 0.8125F;
z_low_offset = z_low;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.09375F;
}
break;
case Door.FACING_XP:
if (!isOpen) {
x_high = 0.1875F;
x_high_offset = x_high;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.90625F;
path_on_x = true;
} else if (hinge == Door.HINGE_RIGHT) {
z_low = 0.8125F;
z_low_offset = z_low;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.09375F;
} else {
z_high = 0.1875F;
z_high_offset = z_high;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.90625F;
}
break;
case Door.FACING_ZN:
if (!isOpen) {
z_low = 0.8125F;
z_low_offset = z_low;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.09375F;
} else if (hinge == Door.HINGE_RIGHT) {
x_low = 0.8125F;
x_low_offset = x_low;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.09375F;
path_on_x = true;
} else {
x_high = 0.1875F;
x_high_offset = x_high;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.90625F;
path_on_x = true;
}
break;
case Door.FACING_ZP:
if (!isOpen) {
z_high = 0.1875F;
z_high_offset = z_high;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.90625F;
} else if (hinge == Door.HINGE_RIGHT) {
x_high = 0.1875F;
x_high_offset = x_high;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.90625F;
path_on_x = true;
} else {
x_low = 0.8125F;
x_low_offset = x_low;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.09375F;
path_on_x = true;
}
break;
}
if (shouldRenderBlock(block))
{
/*
* Draw vertical pieces.
*/
renderBlocks.setRenderBounds(x_low, y_low, z_low, x_high_offset, y_high, z_high_offset);
renderBlock(block, x, y, z);
renderBlocks.setRenderBounds(x_low_offset, y_low, z_low_offset, x_high, y_high, z_high);
renderBlock(block, x, y, z);
float temp_x_low = x_low;
float temp_x_high = x_high;
float temp_z_low = z_low;
float temp_z_high = z_high;
if (path_on_x) {
temp_x_low += 0.0625F;
temp_x_high -= 0.0625F;
temp_z_low = 0.4375F;
temp_z_high = 0.5625F;
} else {
temp_z_low += 0.0625F;
temp_z_high -= 0.0625F;
temp_x_low = 0.4375F;
temp_x_high = 0.5625F;
}
lightingHelper.setLightnessOffset(REDUCED_OFFSET);
// Two center pieces
if (isBottom) {
renderBlocks.setRenderBounds(temp_x_low, 0.1875F, temp_z_low, temp_x_high, 0.5F, temp_z_high);
renderBlock(block, x, y, z);
renderBlocks.setRenderBounds(temp_x_low, 0.625F, temp_z_low, temp_x_high, 0.9375F, temp_z_high);
renderBlock(block, x, y, z);
} else {
renderBlocks.setRenderBounds(temp_x_low, 0.0625F, temp_z_low, temp_x_high, 0.375F, temp_z_high);
renderBlock(block, x, y, z);
renderBlocks.setRenderBounds(temp_x_low, 0.5F, temp_z_low, temp_x_high, 0.8125F, temp_z_high);
renderBlock(block, x, y, z);
}
lightingHelper.clearLightnessOffset();
temp_x_low = x_low;
temp_x_high = x_high;
temp_z_low = z_low;
temp_z_high = z_high;
/*
* Draw horizontal pieces.
*/
if (path_on_x) {
temp_z_low = 0.1875F;
temp_z_high = 0.8125F;
} else {
temp_x_low = 0.1875F;
temp_x_high = 0.8125F;
}
if (isBottom) {
renderBlocks.setRenderBounds(temp_x_low, 0.0F, temp_z_low, temp_x_high, 0.1875F, temp_z_high);
renderBlock(block, x, y, z);
if (path_on_x) {
temp_x_low += 0.0625F;
temp_x_high -= 0.0625F;
} else {
temp_z_low += 0.0625F;
temp_z_high -= 0.0625F;
}
lightingHelper.setLightnessOffset(REDUCED_OFFSET);
renderBlocks.setRenderBounds(temp_x_low, 0.5F, temp_z_low, temp_x_high, 0.625F, temp_z_high);
renderBlock(block, x, y, z);
renderBlocks.setRenderBounds(temp_x_low, 0.9375F, temp_z_low, temp_x_high, 1.0F, temp_z_high);
renderBlock(block, x, y, z);
lightingHelper.clearLightnessOffset();
} else {
renderBlocks.setRenderBounds(temp_x_low, 0.8125F, temp_z_low, temp_x_high, 1.0F, temp_z_high);
renderBlock(block, x, y, z);
if (path_on_x) {
temp_x_low += 0.0625F;
temp_x_high -= 0.0625F;
} else {
temp_z_low += 0.0625F;
temp_z_high -= 0.0625F;
}
lightingHelper.setLightnessOffset(REDUCED_OFFSET);
renderBlocks.setRenderBounds(temp_x_low, 0.0F, temp_z_low, temp_x_high, 0.0625F, temp_z_high);
renderBlock(block, x, y, z);
renderBlocks.setRenderBounds(temp_x_low, 0.375F, temp_z_low, temp_x_high, 0.5F, temp_z_high);
renderBlock(block, x, y, z);
lightingHelper.clearLightnessOffset();
}
}
if (shouldRenderOpaque())
{
Icon icon;
if (isBottom) {
icon = IconRegistry.icon_door_french_glass_bottom;
} else {
icon = IconRegistry.icon_door_french_glass_top;
}
VertexHelper.setOffset(-(1 - path_offset));
Tessellator.instance.setBrightness(Block.glass.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y, z));
if (path_on_x) {
Tessellator.instance.setColorOpaque_F(0.6F, 0.6F, 0.6F);
renderBlocks.setRenderBounds(0.0F, isBottom ? 0.1875F : 0.0F, 0.1875F, 1.0F, isBottom ? 1.0F : 0.8125F, 0.8125F);
RenderHelper.renderFaceXNeg(renderBlocks, x, y, z, icon);
VertexHelper.setOffset(-path_offset);
RenderHelper.renderFaceXPos(renderBlocks, x, y, z, icon);
} else {
Tessellator.instance.setColorOpaque_F(0.8F, 0.8F, 0.8F);
renderBlocks.setRenderBounds(0.1875F, isBottom ? 0.1875F : 0.0F, 0.0F, 0.8125F, isBottom ? 1.0F : 0.8125F, 1.0F);
RenderHelper.renderFaceZNeg(renderBlocks, x, y, z, icon);
VertexHelper.setOffset(-path_offset);
RenderHelper.renderFaceZPos(renderBlocks, x, y, z, icon);
}
VertexHelper.clearOffset();
renderHandle(Block.blockIron, x, y, z, true, true);
}
}
/**
* Renders a glass top door at the given coordinates
*/
private void renderGlassTopDoor(Block block, int x, int y, int z)
{
int hinge = Door.getHinge(TE);
boolean isOpen = Door.getState(TE) == Door.STATE_OPEN;
boolean isBottom = Door.getPiece(TE) == Door.PIECE_BOTTOM;
boolean path_on_x = false;
float path_offset = 0.0F;
float x_low = 0.0F;
float y_low = 0.0F;
float z_low = 0.0F;
float x_high = 1.0F;
float y_high = 1.0F;
float z_high = 1.0F;
float x_low_offset = 0.0F;
float z_low_offset = 0.0F;
float x_high_offset = 1.0F;
float z_high_offset = 1.0F;
switch (Door.getFacing(TE))
{
case Door.FACING_XN:
if (!isOpen) {
x_low = 0.8125F;
x_low_offset = x_low;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.09375F;
path_on_x = true;
} else if (hinge == Door.HINGE_RIGHT) {
z_high = 0.1875F;
z_high_offset = z_high;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.90625F;
} else {
z_low = 0.8125F;
z_low_offset = z_low;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.09375F;
}
break;
case Door.FACING_XP:
if (!isOpen) {
x_high = 0.1875F;
x_high_offset = x_high;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.90625F;
path_on_x = true;
} else if (hinge == Door.HINGE_RIGHT) {
z_low = 0.8125F;
z_low_offset = z_low;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.09375F;
} else {
z_high = 0.1875F;
z_high_offset = z_high;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.90625F;
}
break;
case Door.FACING_ZN:
if (!isOpen) {
z_low = 0.8125F;
z_low_offset = z_low;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.09375F;
} else if (hinge == Door.HINGE_RIGHT) {
x_low = 0.8125F;
x_low_offset = x_low;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.09375F;
path_on_x = true;
} else {
x_high = 0.1875F;
x_high_offset = x_high;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.90625F;
path_on_x = true;
}
break;
case Door.FACING_ZP:
if (!isOpen) {
z_high = 0.1875F;
z_high_offset = z_high;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.90625F;
} else if (hinge == Door.HINGE_RIGHT) {
x_high = 0.1875F;
x_high_offset = x_high;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.90625F;
path_on_x = true;
} else {
x_low = 0.8125F;
x_low_offset = x_low;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.09375F;
path_on_x = true;
}
break;
}
if (shouldRenderBlock(block))
{
renderBlocks.setRenderBounds(x_low, y_low, z_low, x_high_offset, y_high, z_high_offset);
renderBlock(block, x, y, z);
renderBlocks.setRenderBounds(x_low_offset, y_low, z_low_offset, x_high, y_high, z_high);
renderBlock(block, x, y, z);
float temp_x_low = x_low;
float temp_x_high = x_high;
float temp_z_low = z_low;
float temp_z_high = z_high;
/*
* Render interior sheet on bottom
*/
if (isBottom)
{
if (path_on_x) {
temp_x_low += 0.0625F;
temp_x_high -= 0.0625F;
temp_z_low = 0.1875F;
temp_z_high = 0.8125F;
} else {
temp_z_low += 0.0625F;
temp_z_high -= 0.0625F;
temp_x_low = 0.1875F;
temp_x_high = 0.8125F;
}
lightingHelper.setLightnessOffset(REDUCED_OFFSET);
renderBlocks.setRenderBounds(temp_x_low, 0.1875F, temp_z_low, temp_x_high, 1.0F, temp_z_high);
renderBlock(block, x, y, z);
lightingHelper.clearLightnessOffset();
temp_x_low = x_low;
temp_x_high = x_high;
temp_z_low = z_low;
temp_z_high = z_high;
}
/*
* Render horizontal pieces
*/
if (path_on_x) {
temp_z_low = 0.1875F;
temp_z_high = 0.8125F;
} else {
temp_x_low = 0.1875F;
temp_x_high = 0.8125F;
}
if (isBottom) {
renderBlocks.setRenderBounds(temp_x_low, 0.0F, temp_z_low, temp_x_high, 0.1875F, temp_z_high);
renderBlock(block, x, y, z);
} else {
renderBlocks.setRenderBounds(temp_x_low, 0.8125F, temp_z_low, temp_x_high, 1.0F, temp_z_high);
renderBlock(block, x, y, z);
renderBlocks.setRenderBounds(temp_x_low, 0.0F, temp_z_low, temp_x_high, 0.1875F, temp_z_high);
renderBlock(block, x, y, z);
}
temp_x_low = x_low;
temp_x_high = x_high;
temp_z_low = z_low;
temp_z_high = z_high;
/*
* Render interior panel on bottom
*/
if (isBottom)
{
if (path_on_x) {
temp_z_low = 0.3125F;
temp_z_high = 0.6875F;
} else {
temp_x_low = 0.3125F;
temp_x_high = 0.6875F;
}
renderBlocks.setRenderBounds(temp_x_low, 0.3125F, temp_z_low, temp_x_high, 0.875F, temp_z_high);
renderBlock(block, x, y, z);
}
}
if (shouldRenderOpaque())
{
if (!isBottom)
{
VertexHelper.setOffset(-(1 - path_offset));
Tessellator.instance.setBrightness(Block.glass.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y, z));
if (path_on_x) {
Tessellator.instance.setColorOpaque_F(0.6F, 0.6F, 0.6F);
renderBlocks.setRenderBounds(0.0F, 0.1875F, 0.1875F, 1.0F, 0.8125F, 0.8125F);
RenderHelper.renderFaceXNeg(renderBlocks, x, y, z, IconRegistry.icon_door_glass_top);
VertexHelper.setOffset(-path_offset);
RenderHelper.renderFaceXPos(renderBlocks, x, y, z, IconRegistry.icon_door_glass_top);
} else {
Tessellator.instance.setColorOpaque_F(0.8F, 0.8F, 0.8F);
renderBlocks.setRenderBounds(0.1875F, 0.1875F, 0.0F, 0.8125F, 0.8125F, 1.0F);
RenderHelper.renderFaceZNeg(renderBlocks, x, y, z, IconRegistry.icon_door_glass_top);
VertexHelper.setOffset(-path_offset);
RenderHelper.renderFaceZPos(renderBlocks, x, y, z, IconRegistry.icon_door_glass_top);
}
VertexHelper.clearOffset();
}
renderHandle(Block.blockIron, x, y, z, true, true);
}
}
/**
* Renders a panels door at the given coordinates
*/
private void renderPanelsDoor(Block block, int x, int y, int z)
{
int hinge = Door.getHinge(TE);
boolean isOpen = Door.getState(TE) == Door.STATE_OPEN;
boolean isBottom = Door.getPiece(TE) == Door.PIECE_BOTTOM;
boolean path_on_x = false;
float x_low = 0.0F;
float y_low = 0.0F;
float z_low = 0.0F;
float x_high = 1.0F;
float y_high = 1.0F;
float z_high = 1.0F;
float x_low_offset = 0.0F;
float z_low_offset = 0.0F;
float x_high_offset = 1.0F;
float z_high_offset = 1.0F;
switch (Door.getFacing(TE))
{
case Door.FACING_XN:
if (!isOpen) {
x_low = 0.8125F;
x_low_offset = x_low;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_on_x = true;
} else if (hinge == Door.HINGE_RIGHT) {
z_high = 0.1875F;
z_high_offset = z_high;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
} else {
z_low = 0.8125F;
z_low_offset = z_low;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
}
break;
case Door.FACING_XP:
if (!isOpen) {
x_high = 0.1875F;
x_high_offset = x_high;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_on_x = true;
} else if (hinge == Door.HINGE_RIGHT) {
z_low = 0.8125F;
z_low_offset = z_low;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
} else {
z_high = 0.1875F;
z_high_offset = z_high;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
}
break;
case Door.FACING_ZN:
if (!isOpen) {
z_low = 0.8125F;
z_low_offset = z_low;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
} else if (hinge == Door.HINGE_RIGHT) {
x_low = 0.8125F;
x_low_offset = x_low;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_on_x = true;
} else {
x_high = 0.1875F;
x_high_offset = x_high;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_on_x = true;
}
break;
case Door.FACING_ZP:
if (!isOpen) {
z_high = 0.1875F;
z_high_offset = z_high;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
} else if (hinge == Door.HINGE_RIGHT) {
x_high = 0.1875F;
x_high_offset = x_high;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_on_x = true;
} else {
x_low = 0.8125F;
x_low_offset = x_low;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_on_x = true;
}
break;
}
if (shouldRenderBlock(block))
{
renderBlocks.setRenderBounds(x_low, y_low, z_low, x_high_offset, y_high, z_high_offset);
renderBlock(block, x, y, z);
renderBlocks.setRenderBounds(x_low_offset, y_low, z_low_offset, x_high, y_high, z_high);
renderBlock(block, x, y, z);
float temp_x_low = x_low;
float temp_x_high = x_high;
float temp_z_low = z_low;
float temp_z_high = z_high;
/*
* Render interior sheet
*/
if (path_on_x) {
temp_x_low += 0.0625F;
temp_x_high -= 0.0625F;
temp_z_low = 0.1875F;
temp_z_high = 0.8125F;
} else {
temp_z_low += 0.0625F;
temp_z_high -= 0.0625F;
temp_x_low = 0.1875F;
temp_x_high = 0.8125F;
}
lightingHelper.setLightnessOffset(REDUCED_OFFSET);
if (isBottom) {
renderBlocks.setRenderBounds(temp_x_low, 0.1875F, temp_z_low, temp_x_high, 1.0F, temp_z_high);
renderBlock(block, x, y, z);
} else {
renderBlocks.setRenderBounds(temp_x_low, 0.0F, temp_z_low, temp_x_high, 0.8125F, temp_z_high);
renderBlock(block, x, y, z);
}
lightingHelper.clearLightnessOffset();
temp_x_low = x_low;
temp_x_high = x_high;
temp_z_low = z_low;
temp_z_high = z_high;
/*
* Render horizontal pieces
*/
if (path_on_x) {
temp_z_low = 0.1875F;
temp_z_high = 0.8125F;
} else {
temp_x_low = 0.1875F;
temp_x_high = 0.8125F;
}
if (isBottom) {
renderBlocks.setRenderBounds(temp_x_low, y_low, temp_z_low, temp_x_high, 0.1875F, temp_z_high);
renderBlock(block, x, y, z);
} else {
renderBlocks.setRenderBounds(temp_x_low, 0.8125F, temp_z_low, temp_x_high, y_high, temp_z_high);
renderBlock(block, x, y, z);
renderBlocks.setRenderBounds(temp_x_low, 0.0625F, temp_z_low, temp_x_high, 0.25F, temp_z_high);
renderBlock(block, x, y, z);
}
temp_x_low = x_low;
temp_x_high = x_high;
temp_z_low = z_low;
temp_z_high = z_high;
/*
* Render interior panel
*/
if (path_on_x) {
temp_z_low = 0.3125F;
temp_z_high = 0.6875F;
} else {
temp_x_low = 0.3125F;
temp_x_high = 0.6875F;
}
if (isBottom) {
renderBlocks.setRenderBounds(temp_x_low, 0.3125F, temp_z_low, temp_x_high, 0.9375F, temp_z_high);
renderBlock(block, x, y, z);
} else {
renderBlocks.setRenderBounds(temp_x_low, 0.375F, temp_z_low, temp_x_high, 0.6875F, temp_z_high);
renderBlock(block, x, y, z);
}
}
if (shouldRenderOpaque()) {
renderHandle(Block.blockIron, x, y, z, true, true);
}
}
/**
* Renders a tall glass or screen door at the given coordinates
*/
private void renderTallDoor(Block block, int x, int y, int z)
{
int hinge = Door.getHinge(TE);
boolean isOpen = Door.getState(TE) == Door.STATE_OPEN;
boolean isBottom = Door.getPiece(TE) == Door.PIECE_BOTTOM;
boolean path_on_x = false;
float path_offset = 0.0F;
float x_low = 0.0F;
float y_low = 0.0F;
float z_low = 0.0F;
float x_high = 1.0F;
float y_high = 1.0F;
float z_high = 1.0F;
float x_low_offset = 0.0F;
float z_low_offset = 0.0F;
float x_high_offset = 1.0F;
float z_high_offset = 1.0F;
switch (Door.getFacing(TE))
{
case Door.FACING_XN:
if (!isOpen) {
x_low = 0.8125F;
x_low_offset = x_low;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.09375F;
path_on_x = true;
} else if (hinge == Door.HINGE_RIGHT) {
z_high = 0.1875F;
z_high_offset = z_high;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.90625F;
} else {
z_low = 0.8125F;
z_low_offset = z_low;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.09375F;
}
break;
case Door.FACING_XP:
if (!isOpen) {
x_high = 0.1875F;
x_high_offset = x_high;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.90625F;
path_on_x = true;
} else if (hinge == Door.HINGE_RIGHT) {
z_low = 0.8125F;
z_low_offset = z_low;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.09375F;
} else {
z_high = 0.1875F;
z_high_offset = z_high;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.90625F;
}
break;
case Door.FACING_ZN:
if (!isOpen) {
z_low = 0.8125F;
z_low_offset = z_low;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.09375F;
} else if (hinge == Door.HINGE_RIGHT) {
x_low = 0.8125F;
x_low_offset = x_low;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.09375F;
path_on_x = true;
} else {
x_high = 0.1875F;
x_high_offset = x_high;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.90625F;
path_on_x = true;
}
break;
case Door.FACING_ZP:
if (!isOpen) {
z_high = 0.1875F;
z_high_offset = z_high;
x_high_offset = 0.1875F;
x_low_offset = 0.8125F;
path_offset = 0.90625F;
} else if (hinge == Door.HINGE_RIGHT) {
x_high = 0.1875F;
x_high_offset = x_high;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.90625F;
path_on_x = true;
} else {
x_low = 0.8125F;
x_low_offset = x_low;
z_high_offset = 0.1875F;
z_low_offset = 0.8125F;
path_offset = 0.09375F;
path_on_x = true;
}
break;
}
if (shouldRenderBlock(block))
{
renderBlocks.setRenderBounds(x_low, y_low, z_low, x_high_offset, y_high, z_high_offset);
renderBlock(block, x, y, z);
renderBlocks.setRenderBounds(x_low_offset, y_low, z_low_offset, x_high, y_high, z_high);
renderBlock(block, x, y, z);
if (path_on_x) {
z_low = 0.1875F;
z_high = 0.8125F;
} else {
x_low = 0.1875F;
x_high = 0.8125F;
}
if (isBottom) {
renderBlocks.setRenderBounds(x_low, y_low, z_low, x_high, 0.1875F, z_high);
renderBlock(block, x, y, z);
} else {
renderBlocks.setRenderBounds(x_low, 0.8125F, z_low, x_high, y_high, z_high);
renderBlock(block, x, y, z);
}
}
if (shouldRenderOpaque())
{
int type = Door.getType(TE);
Icon icon;
if (isBottom) {
icon = type == Door.TYPE_SCREEN_TALL ? IconRegistry.icon_door_screen_tall : IconRegistry.icon_door_glass_tall_bottom;
} else {
icon = type == Door.TYPE_SCREEN_TALL ? IconRegistry.icon_door_screen_tall : IconRegistry.icon_door_glass_tall_top;
}
VertexHelper.setOffset(-(1 - path_offset));
Tessellator.instance.setBrightness(Block.glass.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y, z));
if (path_on_x) {
Tessellator.instance.setColorOpaque_F(0.6F, 0.6F, 0.6F);
renderBlocks.setRenderBounds(0.0F, isBottom ? 0.1875F : 0.0F, 0.1875F, 1.0F, isBottom ? 1.0F : 0.8125F, 0.8125F);
RenderHelper.renderFaceXNeg(renderBlocks, x, y, z, icon);
VertexHelper.setOffset(-path_offset);
RenderHelper.renderFaceXPos(renderBlocks, x, y, z, icon);
} else {
Tessellator.instance.setColorOpaque_F(0.8F, 0.8F, 0.8F);
renderBlocks.setRenderBounds(0.1875F, isBottom ? 0.1875F : 0.0F, 0.0F, 0.8125F, isBottom ? 1.0F : 0.8125F, 1.0F);
RenderHelper.renderFaceZNeg(renderBlocks, x, y, z, icon);
VertexHelper.setOffset(-path_offset);
RenderHelper.renderFaceZPos(renderBlocks, x, y, z, icon);
}
VertexHelper.clearOffset();
renderHandle(Block.blockIron, x, y, z, true, true);
}
}
/**
* Renders a hidden door at the given coordinates
*/
private void renderHiddenDoor(Block block, int x, int y, int z)
{
if (shouldRenderBlock(block))
{
BlockCarpentersDoor blockRef = (BlockCarpentersDoor) BlockRegistry.blockCarpentersDoor;
blockRef.setBlockBoundsBasedOnState(renderBlocks.blockAccess, x, y, z);
renderBlock(block, x, y, z);
}
if (shouldRenderOpaque()) {
renderHandle(Block.blockIron, x, y, z, true, false);
}
}
/**
* Renders a door handle for the given coordinates
*/
private void renderHandle(Block handleBlock, int x, int y, int z, boolean render_inside_handle, boolean render_outside_handle)
{
if (!render_inside_handle && !render_outside_handle) {
return;
}
int hinge = Door.getHinge(TE);
boolean isOpen = Door.getState(TE) == Door.STATE_OPEN;
boolean isBottom = Door.getPiece(TE) == Door.PIECE_BOTTOM;
float x_low = 0.0F;
float y_low = isBottom ? 0.875F : 0.0625F;
float z_low = 0.0F;
float y_high = isBottom ? 0.9375F : 0.125F;
float y_low_offset = isBottom ? 0.875F : 0.0F;
float y_high_offset = isBottom ? 1.0F : 0.125F;
switch (Door.getFacing(TE))
{
case Door.FACING_XN:
if (!isOpen) {
z_low = hinge == Door.HINGE_RIGHT ? 0.875F : 0.0625F;
if (render_inside_handle)
{
renderBlocks.setRenderBounds(0.75F, y_low, z_low, 0.8125F, y_high, z_low + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
renderBlocks.setRenderBounds(0.6875F, y_low_offset, z_low, 0.75F, y_high_offset, z_low + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
}
if (render_outside_handle)
{
renderBlocks.setRenderBounds(0.0F, y_low, z_low, 0.0625F, y_high, z_low + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x + 1, y, z);
renderBlocks.setRenderBounds(0.0625F, y_low_offset, z_low, 0.125F, y_high_offset, z_low + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x + 1, y, z);
}
} else if (hinge == Door.HINGE_RIGHT) {
if (render_outside_handle)
{
renderBlocks.setRenderBounds(0.0625F, y_low, 0.1875F, 0.0625F + 0.0625F, y_high, 0.25F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
renderBlocks.setRenderBounds(0.0625F, y_low_offset, 0.25F, 0.0625F + 0.0625F, y_high_offset, 0.3125F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
}
if (render_inside_handle)
{
renderBlocks.setRenderBounds(0.0625F, y_low, 0.9375F, 0.0625F + 0.0625F, y_high, 1.0F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z - 1);
renderBlocks.setRenderBounds(0.0625F, y_low_offset, 0.875F, 0.0625F + 0.0625F, y_high_offset, 0.9375F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z - 1);
}
} else {
if (render_outside_handle)
{
renderBlocks.setRenderBounds(0.0625F, y_low, 0.75F, 0.0625F + 0.0625F, y_high, 0.8125F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
renderBlocks.setRenderBounds(0.0625F, y_low_offset, 0.6875F, 0.0625F + 0.0625F, y_high_offset, 0.75F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
}
if (render_inside_handle)
{
renderBlocks.setRenderBounds(0.0625F, y_low, 0.0F, 0.0625F + 0.0625F, y_high, 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z + 1);
renderBlocks.setRenderBounds(0.0625F, y_low_offset, 0.0625F, 0.0625F + 0.0625F, y_high_offset, 0.125F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z + 1);
}
}
break;
case Door.FACING_XP:
if (!isOpen) {
z_low = hinge == Door.HINGE_RIGHT ? 0.0625F : 0.875F;
if (render_inside_handle)
{
renderBlocks.setRenderBounds(0.1875F, y_low, z_low, 0.25F, y_high, z_low + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
renderBlocks.setRenderBounds(0.25F, y_low_offset, z_low, 0.3125F, y_high_offset, z_low + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
}
if (render_outside_handle)
{
renderBlocks.setRenderBounds(0.9375F, y_low, z_low, 1.0F, y_high, z_low + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x - 1, y, z);
renderBlocks.setRenderBounds(0.875F, y_low_offset, z_low, 0.9375F, y_high_offset, z_low + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x - 1, y, z);
}
} else if (hinge == Door.HINGE_RIGHT) {
if (render_outside_handle)
{
renderBlocks.setRenderBounds(0.875F, y_low, 0.75F, 0.875F + 0.0625F, y_high, 0.8125F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
renderBlocks.setRenderBounds(0.875F, y_low_offset, 0.6875F, 0.875F + 0.0625F, y_high_offset, 0.75F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
}
if (render_inside_handle)
{
renderBlocks.setRenderBounds(0.875F, y_low, 0.0F, 0.875F + 0.0625F, y_high, 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z + 1);
renderBlocks.setRenderBounds(0.875F, y_low_offset, 0.0625F, 0.875F + 0.0625F, y_high_offset, 0.125F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z + 1);
}
} else {
if (render_outside_handle)
{
renderBlocks.setRenderBounds(0.875F, y_low, 0.1875F, 0.875F + 0.0625F, y_high, 0.25F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
renderBlocks.setRenderBounds(0.875F, y_low_offset, 0.25F, 0.875F + 0.0625F, y_high_offset, 0.3125F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
}
if (render_inside_handle)
{
renderBlocks.setRenderBounds(0.875F, y_low, 0.9375F, 0.875F + 0.0625F, y_high, 1.0F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z - 1);
renderBlocks.setRenderBounds(0.875F, y_low_offset, 0.875F, 0.875F + 0.0625F, y_high_offset, 0.9375F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z - 1);
}
}
break;
case Door.FACING_ZN:
if (!isOpen) {
x_low = hinge == Door.HINGE_RIGHT ? 0.0625F : 0.875F;
if (render_inside_handle)
{
renderBlocks.setRenderBounds(x_low, y_low, 0.75F, x_low + 0.0625F, y_high, 0.8125F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
renderBlocks.setRenderBounds(x_low, y_low_offset, 0.6875F, x_low + 0.0625F, y_high_offset, 0.75F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
}
if (render_outside_handle)
{
renderBlocks.setRenderBounds(x_low, y_low, 0.0F, x_low + 0.0625F, y_high, 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z + 1);
renderBlocks.setRenderBounds(x_low, y_low_offset, 0.0625F, x_low + 0.0625F, y_high_offset, 0.125F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z + 1);
}
} else if (hinge == Door.HINGE_RIGHT) {
if (render_outside_handle)
{
renderBlocks.setRenderBounds(0.75F, y_low, 0.0625F, 0.8125F, y_high, 0.0625F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
renderBlocks.setRenderBounds(0.6875F, y_low_offset, 0.0625F, 0.75F, y_high_offset, 0.0625F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
}
if (render_inside_handle)
{
renderBlocks.setRenderBounds(0.0F, y_low, 0.0625F, 0.0625F, y_high, 0.0625F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x + 1, y, z);
renderBlocks.setRenderBounds(0.0625F, y_low_offset, 0.0625F, 0.125F, y_high_offset, 0.0625F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x + 1, y, z);
}
} else {
if (render_outside_handle)
{
renderBlocks.setRenderBounds(0.1875F, y_low, 0.0625F, 0.25F, y_high, 0.0625F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
renderBlocks.setRenderBounds(0.25F, y_low_offset, 0.0625F, 0.3125F, y_high_offset, 0.0625F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
}
if (render_inside_handle)
{
renderBlocks.setRenderBounds(0.9375F, y_low, 0.0625F, 1.0F, y_high, 0.0625F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x - 1, y, z);
renderBlocks.setRenderBounds(0.875F, y_low_offset, 0.0625F, 0.9375F, y_high_offset, 0.0625F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x - 1, y, z);
}
}
break;
case Door.FACING_ZP:
if (!isOpen) {
x_low = hinge == Door.HINGE_RIGHT ? 0.875F : 0.0625F;
if (render_inside_handle)
{
renderBlocks.setRenderBounds(x_low, y_low, 0.1875F, x_low + 0.0625F, y_high, 0.25F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
renderBlocks.setRenderBounds(x_low, y_low_offset, 0.25F, x_low + 0.0625F, y_high_offset, 0.3125F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
}
if (render_outside_handle)
{
renderBlocks.setRenderBounds(x_low, y_low, 0.9375F, x_low + 0.0625F, y_high, 1.0F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z - 1);
renderBlocks.setRenderBounds(x_low, y_low_offset, 0.875F, x_low + 0.0625F, y_high_offset, 0.9375F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z - 1);
}
} else if (hinge == Door.HINGE_RIGHT) {
if (render_outside_handle)
{
renderBlocks.setRenderBounds(0.1875F, y_low, 0.875F, 0.25F, y_high, 0.875F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
renderBlocks.setRenderBounds(0.25F, y_low_offset, 0.875F, 0.3125F, y_high_offset, 0.875F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
}
if (render_inside_handle)
{
renderBlocks.setRenderBounds(0.9375F, y_low, 0.875F, 1.0F, y_high, 0.875F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x - 1, y, z);
renderBlocks.setRenderBounds(0.875F, y_low_offset, 0.875F, 0.9375F, y_high_offset, 0.875F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x - 1, y, z);
}
} else {
if (render_outside_handle)
{
renderBlocks.setRenderBounds(0.75F, y_low, 0.875F, 0.8125F, y_high, 0.875F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
renderBlocks.setRenderBounds(0.6875F, y_low_offset, 0.875F, 0.75F, y_high_offset, 0.875F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x, y, z);
}
if (render_inside_handle)
{
renderBlocks.setRenderBounds(0.0F, y_low, 0.875F, 0.0625F, y_high, 0.875F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x + 1, y, z);
renderBlocks.setRenderBounds(0.0625F, y_low_offset, 0.875F, 0.125F, y_high_offset, 0.875F + 0.0625F);
renderBlocks.renderStandardBlock(handleBlock, x + 1, y, z);
}
}
break;
}
}
} | [
"[email protected]"
] | |
b0eaf7e07ee1862eeac030b923828e27ff01871e | 1348204aaaab2ad91494f15670071a5b775b0f0e | /ver8/FileUtil.java | 0733df615a063f94465feca323273a221fde7029 | [] | no_license | GreenLiuWhy/HUAWEISoftware2017 | 807eb266a5c8a9bbe1c92a534ac63d7d483ac35e | 5a41b216a3775e2a46b91642d2a5fe58ec80be78 | refs/heads/master | 2020-04-05T13:08:31.661330 | 2017-07-13T11:49:43 | 2017-07-13T11:49:43 | 95,115,362 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,522 | java | package realcode.ver8;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
public final class FileUtil
{
public static String[] read(final String filePath, final Integer spec)
{
File file = new File(filePath);
// 褰撴枃浠朵笉瀛樺湪鎴栬€呬笉鍙鏃?
if ((!isFileExists(file)) || (!file.canRead()))
{
System.out.println("file [" + filePath + "] is not exist or cannot read!!!");
return null;
}
List<String> lines = new LinkedList<String>();
BufferedReader br = null;
FileReader fb = null;
try
{
fb = new FileReader(file);
br = new BufferedReader(fb);
String str = null;
int index = 0;//
//spec是传入的一个值(本来应该是一个int),在main里面传的是null
while (((spec == null) || index++ < spec) && (str = br.readLine()) != null)
{
lines.add(str);
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
closeQuietly(br);
closeQuietly(fb);
}
return lines.toArray(new String[lines.size()]);
}
/**
* 鍐欐枃浠?
* @param filePath 杈撳嚭鏂囦欢璺緞
* @param content 瑕佸啓鍏ョ殑鍐呭
* @param append 鏄惁杩藉姞
* @return
* @author s00274007
* @since 2016-3-1
*/
public static int write(final String filePath, final String[] contents, final boolean append)
{
File file = new File(filePath);
if (contents == null)
{
System.out.println("file [" + filePath + "] invalid!!!");
return 0;
}
// 褰撴枃浠跺瓨鍦ㄤ絾涓嶅彲鍐欐椂
if (isFileExists(file) && (!file.canRead()))
{
return 0;
}
FileWriter fw = null;
BufferedWriter bw = null;
try
{
if (!isFileExists(file))
{
file.createNewFile();
}
fw = new FileWriter(file, append);
bw = new BufferedWriter(fw);
//也就是说明 需要传入的contents[0]=第一行,contents[1]=空,contents[2]=行
for (String content : contents)//for(int i=0;i<contents.length;i++){String content=contents[i]}
{
if (content == null)//这个是干嘛的?
{
continue;
}
bw.write(content);//写一行
bw.newLine();
}
}
catch (IOException e)
{
e.printStackTrace();
return 0;
}
finally
{
closeQuietly(bw);
closeQuietly(fw);
}
return 1;
}
private static void closeQuietly(Closeable closeable)
{
try
{
if (closeable != null)
{
closeable.close();
}
}
catch (IOException e)
{
}
}
private static boolean isFileExists(final File file)
{
if (file.exists() && file.isFile())
{
return true;
}
return false;
}
}
| [
"[email protected]"
] | |
f2e33d120ffa7064be43b640fa5e188b4fee5823 | 47d87f04707689d9c1b3b4506ccb3bb1c614b4db | /StudentDriver/app/src/main/java/com/example/StudentDriver/data/model/LoggedInUser.java | a839ca2dd136636e09ff637f8fa7bb9ad6d3a79c | [] | no_license | Karan9991/Student-Ride-and-Driver | 169b476b7662dcd371d2fee48dec8dc7746939d3 | 17dcfbe21a27601ca0e51ff9e6ef1e5f1bd2f429 | refs/heads/master | 2020-09-22T15:37:04.036054 | 2020-01-23T02:31:26 | 2020-01-23T02:31:26 | 203,691,162 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 513 | java | package com.example.StudentDriver.data.model;
/**
* Data class that captures user information for logged in users retrieved from LoginRepository
*/
public class LoggedInUser {
private String userId;
private String displayName;
public LoggedInUser(String userId, String displayName) {
this.userId = userId;
this.displayName = displayName;
}
public String getUserId() {
return userId;
}
public String getDisplayName() {
return displayName;
}
}
| [
"[email protected]"
] | |
f75ddb1542b1cd5dc04eb7cb74bb5e6daf884bdb | 5ab0a51445bccbe6afd50ab42557fdf6b4a39ee9 | /cloud-provider-payment8002/src/main/java/com/atguigu/springcloud/dao/PaymentDao.java | f2d77c8e67df14613c95e1ecb86acc7f934850ab | [] | no_license | Ottack/cloud2020 | 33458b7ab120e038cf3937585d9f9d053f92c5c3 | eab5e308cf856865e62a660d156b0a73f09c6f5c | refs/heads/master | 2022-07-18T16:51:52.052023 | 2020-04-26T14:49:02 | 2020-04-26T14:49:02 | 254,128,943 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 310 | java | package com.atguigu.springcloud.dao;
import com.atguigu.springcloud.entities.Payment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface PaymentDao {
public int create(Payment payment);
public Payment getPaymentById(@Param("id") Long id);
}
| [
"[email protected]"
] | |
4f660dfa17ab92dd0a38f9f2f2a0dd820e500797 | 9018e7fd6417c1ee54e1d0289b37ba42aef29ba4 | /src/main/java/org/mcsg/double0negative/supercraftbros/Game.java | e2e7f884f25546c8a3f403d955db2998fa7be7bf | [] | no_license | AwesomePowered/SuperCraftBros | 56d62ebd74946716de99f58181ba527798454f7d | 48a6c8d6ac8c992c5fa13197e9e92a8a22fb13f0 | refs/heads/master | 2021-01-15T20:14:17.147009 | 2013-07-09T16:02:14 | 2013-07-09T16:02:14 | 10,972,714 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,302 | java | package org.mcsg.double0negative.supercraftbros;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.potion.PotionEffectType;
import org.mcsg.double0negative.supercraftbros.classes.PlayerClass;
import org.mcsg.double0negative.tabapi.TabAPI;
public class Game {
public enum State{
INGAME, LOBBY, DISABLED, WAITING
}
private int gameID;
private int spawnCount;
private Arena arena;
private State state;
private HashMap<Player, Integer>players = new HashMap<Player, Integer>();
private HashMap<Player, PlayerClass>pClasses = new HashMap<Player, PlayerClass>();
private ArrayList<Player>inactive = new ArrayList<Player>();
private ArrayList<Player>queue = new ArrayList<Player>();
public Game(int a) {
this.gameID = a;
init();
}
public void init(){
FileConfiguration s = SettingsManager.getInstance().getSystemConfig();
int x = s.getInt("system.arenas." + gameID + ".x1");
int y = s.getInt("system.arenas." + gameID + ".y1");
int z = s.getInt("system.arenas." + gameID + ".z1");
System.out.println(x + " " + y + " " + z);
int x1 = s.getInt("system.arenas." + gameID + ".x2");
int y1 = s.getInt("system.arenas." + gameID + ".y2");
int z1 = s.getInt("system.arenas." + gameID + ".z2");
System.out.println(x1 + " " + y1 + " " + z1);
Location max = new Location(SettingsManager.getGameWorld(gameID), Math.max(x, x1), Math.max(y, y1), Math.max(z, z1));
System.out.println(max.toString());
Location min = new Location(SettingsManager.getGameWorld(gameID), Math.min(x, x1), Math.min(y, y1), Math.min(z, z1));
System.out.println(min.toString());
arena = new Arena(min, max);
state = State.LOBBY;
spawnCount = SettingsManager.getInstance().getSpawnCount(gameID);
}
public void addPlayer(Player p){
if(state == State.LOBBY && players.size() < 10){
p.teleport(SettingsManager.getInstance().getGameLobbySpawn(gameID));
players.put(p ,3 );
p.setGameMode(GameMode.ADVENTURE);
p.setHealth(p.getMaxHealth()); p.setFoodLevel(20);
TabAPI.setPriority(GameManager.getInstance().getPlugin(), p, 2);
p.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "Joined arena " + gameID + ". Select a class! \nHit tab for HUD!");
msgAll(ChatColor.GREEN + p.getName()+ " joined the game!");
updateTabAll();
}
else if(state == State.INGAME){
p.sendMessage(ChatColor.RED + "Game already started!");
}
else if(players.size() >= 10){
p.sendMessage(ChatColor.RED + "Game Full!");
}
else{
p.sendMessage(ChatColor.RED + "Cannot join game!");
}
}
public void startGame(){
if(players.size() < 2){
msgAll("Not enough players");
return;
}
inactive.clear();
state = State.INGAME;
for(Player p: players.keySet().toArray(new Player[0])){
if(pClasses.containsKey(p)){
spawnPlayer(p);
}
else{
removePlayer(p, false);
p.sendMessage(ChatColor.RED + "You didn't pick a class!");
}
}
}
int count = 20;
int tid = 0;
public void countdown(int time) {
count = time;
Bukkit.getScheduler().cancelTask(tid);
if (state == State.LOBBY) {
tid = Bukkit.getScheduler().scheduleSyncRepeatingTask((Plugin) GameManager.getInstance().getPlugin(), new Runnable() {
public void run() {
if (count > 0) {
if (count % 10 == 0) {
msgAll(ChatColor.BLUE + "Game starting in " + count);
}
if (count < 6) {
msgAll(ChatColor.BLUE + "Game starting in " + count);
}
count--;
} else {
startGame();
Bukkit.getScheduler().cancelTask(tid);
}
}
}, 0, 20);
}
}
boolean started = false;
public void setPlayerClass(Player player, PlayerClass playerClass){
if(player.hasPermission("scb.class."+playerClass.getName())){
clearPotions(player);
player.sendMessage(ChatColor.GREEN + "You choose " + playerClass.getName() + "!");
//int prev = pClasses.keySet().size();
pClasses.put(player, playerClass);
updateTabAll();
if(!started && pClasses.keySet().size()>= 3 && players.size() >= 3 ){
countdown(30);
started = true;
}
}
else{
player.sendMessage(ChatColor.RED + "You do not have permission for this class!");
}
}
public void killPlayer(Player p, String msg){
clearPotions(p);
msgAll(ChatColor.GOLD + msg);
int lives = players.get(p)-1;
if(lives <= 0){
playerEliminate(p);
}
else{
players.put(p, lives);
msgAll(p.getName() + " has " + lives + " lives left");
}
updateTabAll();
}
@SuppressWarnings("deprecation")
public void playerEliminate(Player p){
started = false;
msgAll(ChatColor.DARK_RED + p.getName() + " has been eliminated!");
players.remove(p);
//pClasses.remove(p);
inactive.add(p);
p.getInventory().clear();
p.getInventory().setArmorContents(new ItemStack[4]);
p.updateInventory();
p.setAllowFlight(false);
p.setFlying(false);
clearPotions(p);
p.teleport(SettingsManager.getInstance().getLobbySpawn());
if(players.keySet().size() <= 1 && state == State.INGAME){
Player pl = null;
for(Player pl2 : players.keySet()){
pl = pl2;
}
Bukkit.broadcastMessage(ChatColor.BLUE + pl.getName() + " won Super Craft Bros on arena " + gameID);
gameEnd();
}
TabAPI.setPriority(GameManager.getInstance().getPlugin(), p, -1);
TabAPI.updatePlayer(p);
updateTabAll();
}
public void clearPotions(Player p){
for(PotionEffectType e: PotionEffectType.values()){
if(e != null && p.hasPotionEffect(e))
p.removePotionEffect(e);
}
}
@SuppressWarnings("deprecation")
public void gameEnd(){
/*for(Entity e:SettingsManager.getGameWorld(gameID).getEntities()){
if(arena.containsBlock(e.getLocation())){
e.remove();
}
}*/
for(Player p:players.keySet()){
p.getInventory().clear();
p.getInventory().setArmorContents(new ItemStack[4]);
p.updateInventory();
p.teleport(SettingsManager.getInstance().getLobbySpawn());
clearPotions(p);
TabAPI.setPriority(GameManager.getInstance().getPlugin(), p, -2);
TabAPI.updatePlayer(p);
p.setFlying(false);
p.setAllowFlight(false);
}
players.clear();
pClasses.clear();
inactive.clear();
state = State.LOBBY;
}
public void updateTabAll(){
for(Player p: players.keySet()){
updateTab(p);
}
}
public void updateTab(Player p){
Plugin plugin = GameManager.getInstance().getPlugin();
TabAPI.setTabString(plugin, p, 0, 0, " \u00a7lSuper");
TabAPI.setTabString(plugin, p, 0, 1, " \u00a7lCraft");
TabAPI.setTabString(plugin, p, 0, 2, " \u00a7lBros");
TabAPI.setTabString(plugin, p, 1, 1, " \u00a7lBrawl");
TabAPI.setTabString(plugin, p, 2, 0, " \u00a76\u00a7l----------");
TabAPI.setTabString(plugin, p, 2, 1, "\u00a7e\u00a7l----------");
TabAPI.setTabString(plugin, p, 2, 2, "\u00a76\u00a7l---------- ");
TabAPI.setTabString(plugin, p, 4, 0, "\u00a7lArena");
TabAPI.setTabString(plugin, p, 4, 1, gameID+TabAPI.nextNull());
TabAPI.setTabString(plugin, p, 5, 0, "\u00a7lClass");
TabAPI.setTabString(plugin, p, 5, 1, (getPlayerClass(p) != null)? getPlayerClass(p).getName()+TabAPI.nextNull():"None "+TabAPI.nextNull());
TabAPI.setTabString(plugin, p, 7, 0, "\u00a7e\u00a7lPlayer");
TabAPI.setTabString(plugin, p, 7, 1, "\u00a7e\u00a7lLives");
TabAPI.setTabString(plugin, p, 7, 2, "\u00a7e\u00a7lClass");
int a = 8;
for(Player pl:players.keySet()){
int h = convertHealth(20);
TabAPI.setTabString(plugin, p, a, 0, pl.getName(), h);
TabAPI.setTabString(plugin, p, a, 1, "\u00a7a"+players.get(pl)+TabAPI.nextNull(), h);
TabAPI.setTabString(plugin, p, a, 2, (getPlayerClass(pl) != null)? getPlayerClass(pl).getName()+TabAPI.nextNull():"None "+TabAPI.nextNull(),h );
a++;
}
if(state == State.INGAME){
for(Player pl:inactive){
TabAPI.setTabString(plugin, p, a, 0, pl.getName(), -1);
TabAPI.setTabString(plugin, p, a, 1, "\u00a7c0"+TabAPI.nextNull(), -1);
TabAPI.setTabString(plugin, p, a, 2, (getPlayerClass(pl) != null)? getPlayerClass(pl).getName()+TabAPI.nextNull():"None "+TabAPI.nextNull(), -1);
a++;
}
}
TabAPI.updatePlayer(p);
}
private int convertHealth(double h){
if(h > 17){
return 1;
}else if(h >14){
return 151;
}else if(h > 10){
return 301;
}else if(h > 5){
return 601;
}else if(h > 2){
return 1001;
}
else{
return -1;
}
}
public void spawnPlayer(Player p){
if(players.containsKey(p)){
p.setAllowFlight(true);
Random r = new Random();
final Location l = SettingsManager.getInstance().getSpawnPoint(gameID, r.nextInt(spawnCount)+1);
p.teleport(l);
getPlayerClass(p).PlayerSpawn();
}
}
public int getID() {
return gameID;
}
public boolean isBlockInArena(Location v) {
return arena.containsBlock(v);
}
public void addSpawn() {
spawnCount++;
}
public boolean isPlayerActive(Player p) {
return players.keySet().contains(p);
}
public boolean isInQueue(Player p) {
return queue.contains(p);
}
public void removeFromQueue(Player p) {
queue.remove(p);
}
@SuppressWarnings("deprecation")
public void removePlayer(Player p, boolean b) {
players.remove(p);
p.getInventory().clear();
p.updateInventory();
clearPotions(p);
playerEliminate(p);
inactive.remove(p);
p.teleport(SettingsManager.getInstance().getLobbySpawn());
msgAll(ChatColor.RED + p.getName() + " left the game!");
}
public void msgAll(String msg){
for(Player p: players.keySet()){
p.sendMessage(msg);
}
}
public void enable(){
if(state != State.DISABLED){
disable();
}
state = State.LOBBY;
}
public void disable() {
for(Player p: players.keySet().toArray(new Player[0])){
playerEliminate(p);
p.sendMessage(ChatColor.RED + "Game Disabled");
}
gameEnd();
state = State.DISABLED;
}
public State getState() {
return state;
}
public PlayerClass getPlayerClass(Player p) {
return pClasses.get(p);
}
public Set<Player> getActivePlayers(){
return players.keySet();
}
}
| [
"[email protected]"
] | |
6f1538e28c9e38f7f5118d98d2277e44c9174b73 | 1e8a255c5b2a46002c3f2075715762eabac5e43c | /spring-security-form-thym/src/main/java/pl/javastart/security/SecurityConfig.java | 4a1f11258052f8c5da250b37aa580ea4d599d3fa | [] | no_license | dev-com2020/spring | 01928cf729906d04e8f28ebd5e96684fe12782fa | 5144297c4d4e087d77b9c1eca85e8079680879dc | refs/heads/master | 2023-04-30T05:28:10.350373 | 2021-02-17T07:47:44 | 2021-02-17T07:47:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,048 | java | package pl.javastart.security;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/loginform")
.permitAll()
.loginProcessingUrl("/processlogin")
.permitAll()
.usernameParameter("user")
.passwordParameter("pass")
.and()
.logout()
.logoutUrl("/logmeout")
.logoutSuccessUrl("/")
.permitAll();
}
}
| [
"[email protected]"
] | |
eed71b82d1959a0d0d287a25cab2e43fd5e2466e | 8b087fc7691fee383718d1d7e004f37abbba263f | /MoraLitumaSRIJEE/src/main/java/ec/edu/ups/MoraLitumaSRIJEE/modelo/Factura.java | 00b324823d078918a20266acf2e1f9d41254294d | [] | no_license | bryamOzl/ExamenFinal | 0e279c19984ee35ae10d17811c80d2ac7eb27169 | 1c025b5efa84876635e44efd889a2f540f12e75e | refs/heads/master | 2023-02-27T11:56:47.400998 | 2021-02-05T17:05:07 | 2021-02-05T17:05:07 | 336,282,584 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,079 | java | package ec.edu.ups.MoraLitumaSRIJEE.modelo;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Entity
public class Factura implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@Column(name = "factura_id")
private int facturaId;
private double valor;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "cuenta_id")
private Cuenta cuenta;
public int getFacturaId() {
return facturaId;
}
public void setFacturaId(int facturaId) {
this.facturaId = facturaId;
}
public double getValor() {
return valor;
}
public void setValor(double valor) {
this.valor = valor;
}
public Cuenta getCuenta() {
return cuenta;
}
public void setCuenta(Cuenta cuenta) {
this.cuenta = cuenta;
}
@Override
public String toString() {
return "Factura [facturaId=" + facturaId + ", valor=" + valor + ", cuenta=" + cuenta + "]";
}
}
| [
"[email protected]"
] | |
b491bd6ced1ac0155fc1db89c25854d3b021ea90 | cd75ffa9c7fcbb470aaa931266c1bb05c9e7185f | /client/src/Authentication.java | b172668a3e99e33598eecd007d50cfd81d3b6758 | [] | no_license | thecuriousbig/java-simple-message-system | 72689f498232554bc6b3b4354e6fbfefd4cc927b | fb5b888c472223e31f0c7bd356226e052dfc1760 | refs/heads/master | 2020-05-17T00:09:56.547913 | 2019-05-23T05:53:22 | 2019-05-23T05:53:22 | 183,389,105 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,697 | java | /**
* Authentication
*
* The Authentication class help the client do the operation <br>
* about verify or validate the identity of client such as login <br>
* or register or logout.
* <p>
* Created by Tanatorn Nateesanprasert (Big) 59070501035 <br>
* Manchuporn Pungtippimanchai (Mai) 59070501060 <br>
* On 20-May-2019
*/
public class Authentication
{
/**
* This method perform the login operation by get the credential of user
* such as username and password as the parameter.
* Then this method will send login request to the server to verify the user.
*
* @param username username of the user that want to login.
* @param password password of the user.
* @return the flag that represent the overall status of this operation.
*/
public static boolean login(String username, String password)
{
/* Create the packet that will send to the server */
Packet authPacket = new Packet().setCommand("login").setUsername(username).setPassword(password);
/* Get the ConnectionManager instance */
ConnectionManager connectionManager = ConnectionManager.getInstance();
/* Call the auth operation in connectionManager */
return connectionManager.authOperation(authPacket, "Login");
}
/**
* This method perform the register operation by get the credential of user
* such username password as the parameter.
* <br>
* With the help of ConnectionManager, Allows this method to connect to
* the server to perform the register operation properly.
*
* @param username username of the user
* @param password password of the user
* @return The flag that represents the overall status of this operation.
*/
public static boolean register(String username, String password)
{
/* Create the authPacket that will send to the server */
Packet authPacket = new Packet().setCommand("register").setUsername(username).setPassword(password);
/* Calling connectionManager getInstance() to get the instance */
ConnectionManager connectionManager = ConnectionManager.getInstance();
/* Calling the authOperation to perform the register request */
return connectionManager.authOperation(authPacket, "register");
}
/**
* Logout from the system by set the client to null
*
* @param client Client that are currently login to the system.
* @return the boolean that represent the successful of loggin out operation.
*/
public static boolean logout(Client client)
{
/* Make the client = null */
client = null;
return true;
}
}
| [
"[email protected]"
] | |
1aecf1afdf6038aa1689472632fe6a0581e5bf84 | 32fb93164e04c17a1af0c00a6fa262025f029c02 | /app/src/main/java/br/com/prova/interfaces/AgendaMedicaAPI.java | 616971355e28e5d95ce40f8fddfe9bb5c1f7dcfc | [] | no_license | isgreen/MarcaConsultas | c0ac8bf65b68c990153663a6acf9ad6e89366244 | 2f9e8ec7c0a372a7751c94dc4d7334a745e55a2a | refs/heads/master | 2021-05-30T04:48:02.510155 | 2015-12-15T02:18:16 | 2015-12-15T02:18:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 433 | java | package br.com.prova.interfaces;
import java.util.List;
import br.com.prova.model.bean.AgendaMedica;
import retrofit.Call;
import retrofit.Callback;
import retrofit.http.GET;
/**
* Created by Wolfstein on 30/11/2015.
*/
public interface AgendaMedicaAPI {
@GET("agendaMedica/listarAgendaMedica")
Call<List<AgendaMedica>> listarAgendaMedica();
// void listarAgendaMedica(Callback<List<AgendaMedica>> agendaMedica);
}
| [
"[email protected]"
] | |
24bea9da164df82b48bfbf15ff964edf727a38a1 | c456d59ffaa706d7243bb88a64e0be104e327e35 | /src/test/java/com/docker/com/dockerContainer/DockerTest1.java | cf8671e3517e9f8c45cae7b96ea5121fc6d361d2 | [] | no_license | swapanqa/docker_grid_test | 2dc258fea929286ae2d8a7fcccb5dfcfa2fb3ad2 | 4044be3187b1804c3e538a74263f01a7fc021c1f | refs/heads/master | 2020-06-30T15:40:44.433243 | 2019-08-07T01:55:30 | 2019-08-07T01:55:30 | 200,874,323 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 798 | java | package com.docker.com.dockerContainer;
import org.testng.annotations.Test;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
public class DockerTest1 {
@Test
public void test2() throws MalformedURLException {
//DesiredCapabilities ds = DesiredCapabilities.chrome();
DesiredCapabilities ds = DesiredCapabilities.chrome();
URL url = new URL("http://localhost:4444/wd/hub");
RemoteWebDriver driver = new RemoteWebDriver(url,ds);
driver.get("https://www.google.com");
String title = driver.getTitle();
System.out.println("Title name is : " + title);
driver.quit();
}
}
| [
"[[email protected]]"
] | |
abe074742c51cf2657c22b6b99f4492a5d870500 | 58c0529be1ee5ad274292184cc0fc19c7d0e0fd2 | /HHTask/src/com/task/Server/BonusServer.java | 43afddd0422ff89b9ce248ad2f1a1ec06973d40d | [] | no_license | hbliyafei/nianfojishu | 6dc348fdca415d2e7aa328c76f0cbfb9b3aba9c3 | 0a8a125e661f0d582245a4c2586d57f85e496399 | refs/heads/master | 2023-03-17T15:03:03.247703 | 2019-05-14T07:56:20 | 2019-05-14T07:56:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,706 | java | package com.task.Server;
import java.util.List;
import com.task.entity.Bonus;
import com.task.entity.Bonusmoney;
import com.task.entity.Teammembers;
public interface BonusServer {
// 根据登录人的部门查询出所对应的班组成员
public List finDept(String dept);
// 根据登录人的id查询出所对应的班组成员
public List finDept(Integer addUserId);
// 根据奖金分配的时间查询出提奖的总金额
public List finddate(String date);
// 添加奖金分配明细表
public boolean saveBonus(Bonus bonus);
// 添加奖金总金额表
public boolean saveBonusmoney(Bonusmoney bonusmoney);
// 根据时间查询出所对应的奖金总额表的总金额
public List findbonusmoney(String date);
// 根据时间查询出奖金总额表中是否存在
public List finddatabonusmoney(String date, String dept);
// 根据ID查询出 所对的成员信息
public Teammembers findByID(int id);
// 根据月份和登入人的职位查询出奖金分配详细信息
public List findzhiwei(String yuefen, String dept);
// 根据月份显示 和班组显示相应的奖金分配信息
public List findDateDept(String date, String dept);
// 根据工号 月份查询出奖金明细
public List fidnghdate(String chengyuangonghao, String yuefen, String dept);
// 修改 奖金明细表
public boolean updateBonus(Bonus bonus);
// 根据月份和班组查询出奖金明细表部留
public List findDpetbuliuMoney(String date, String banzu);
// 根据月份和班组查询出奖金总额表信息
public List findBonusmoney(String date, String banzu);
// 修改 奖金分配总额表
public boolean updateBonusmoney(Bonusmoney bonusmoney);
// 根据月份查询出奖金分配的汇总
public List findSummary(String date, int pageNo, int pageSize);
// 根据月份查询出奖金分配的汇总 总数
public int summaryCount(String date);
// 跟据月份查询出奖金分配汇总信息 用于导出EXCEL
public List findexcelsummary(String date);
// 根据月份和班组 状态为审核中的
public List findStatus(String date, String dept);
// 根据月份查询出奖金总额表状态为 总经理同意或者财务同意
public List findzongjiaji(String date);
// 根据月份查询奖金总额表
public List findDate(String date);
// 根据登录人的部门查询出其所属成员并且该成员未添加过工资
public List finDept(int addUserId, String status);
public Object[] findExamList(int parseInt, int pageSize);
public boolean updateExamBonus(Integer[] detailSelect, String tag);
public Bonusmoney findbonusmoney1(String dateyuefen, String duty);
public void updateBus(Integer bonusId);
}
| [
"horsexming.sina.com"
] | horsexming.sina.com |
13b465893838e2d500d868b00b96c54c6f2eef5b | e9f953286b8471db2a624739540b2594b66ef0a5 | /parkingos_cloud_web/src/com/zld/struts/anlysis/PlotProdAnlysisAction.java | 896fc70c313c083a8eaf63359dc18766b2899864 | [] | no_license | dlzdy/ParkingOS_cloud | a7eb402d307d55809ee3d49f54a917c685bdb31d | f4481a4a7fcb99308c2248c10d2ca649a0e32ca5 | refs/heads/master | 2021-08-07T04:33:30.166835 | 2018-11-21T05:36:17 | 2018-11-21T05:36:17 | 143,713,423 | 0 | 0 | null | 2018-08-06T10:32:26 | 2018-08-06T10:32:26 | null | UTF-8 | Java | false | false | 19,375 | java | package com.zld.struts.anlysis;
import com.zld.AjaxUtil;
import com.zld.dao.PgOnlyReadDao;
import com.zld.service.DataBaseService;
import com.zld.utils.*;
import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.VerticalAlignment;
import jxl.write.*;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PlotProdAnlysisAction extends Action{
@Autowired
private DataBaseService daService;
@Autowired
private PgOnlyReadDao pgOnlyReadDao;
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String action = RequestUtil.processParams(request, "action");
Long comid = (Long)request.getSession().getAttribute("comid");
Integer role = RequestUtil.getInteger(request, "role",-1);
if(ZLDType.ZLD_ACCOUNTANT_ROLE==role||ZLDType.ZLD_CARDOPERATOR==role)
request.setAttribute("role", role);
if(comid==null){
response.sendRedirect("login.do");
return null;
}
if(action.equals("")){
String monday = StringUtils.getFistdayOfMonth();
request.setAttribute("btime", monday);
SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
request.setAttribute("etime", df2.format(System.currentTimeMillis()));
return mapping.findForward("list");
}else if(action.equals("query")){
String fieldsstr = RequestUtil.processParams(request, "fieldsstr");
List<Map<String, Object>> list = plotprodquery(request, comid);
int count = list!=null?list.size():0;
String json = JsonUtil.Map2Json(list,1,count, fieldsstr,"p_lot");
AjaxUtil.ajaxOutput(response, json);
}else if(action.equals("detail")){
request.setAttribute("p_lot", RequestUtil.processParams(request, "p_lot"));
request.setAttribute("btime", RequestUtil.processParams(request, "btime"));
request.setAttribute("etime", RequestUtil.processParams(request, "etime"));
return mapping.findForward("plotproddetail");
}else if(action.equals("ppdetail")){
String p_lot = RequestUtil.processParams(request, "p_lot");
String fieldsstr = RequestUtil.processParams(request, "fieldsstr");
String year = RequestUtil.processParams(request, "time");
if(year.equals("")){
year = "curyear";
}
String firday = StringUtils.getFistdayOfYear();//今年开始时间
Integer curyear = Integer.valueOf(firday.split("-")[0]);
String nextfirday = (curyear + 1) + "-01-01";//明年的开始时间
Long b = TimeTools.getLongMilliSecondFrom_HHMMDD(firday)/1000;
Long e = TimeTools.getLongMilliSecondFrom_HHMMDD(nextfirday)/1000;
if(year.equals("lastyear")){
String lastfirday = (curyear - 1) + "-01-01";//去年的开始时间
b = TimeTools.getLongMilliSecondFrom_HHMMDD(lastfirday)/1000;
e = TimeTools.getLongMilliSecondFrom_HHMMDD(firday)/1000;
}
String sql = "select cp.*,p.p_name,p.price from carower_product cp,product_package_tb p where " +
"cp.pid=p.id and cp.create_time between ? and ? and p.comid=? and cp.p_lot=? order by cp.create_time desc ";
List<Object> params = new ArrayList<Object>();
params.add(b);
params.add(e);
params.add(comid);
params.add(p_lot);
List<Map<String, Object>> list = daService.getAllMap(sql, params);
int count = list!=null?list.size():0;
getcarinfo(list);
String json = JsonUtil.Map2Json(list,1,count, fieldsstr,"id");
AjaxUtil.ajaxOutput(response, json);
}else if(action.equals("expexcel")){
try {
String fname = "停车位月卡收费台账" + com.zld.utils.TimeTools.getDate_YY_MM_DD();
fname = StringUtils.encodingFileName(fname);
java.io.OutputStream os;
os = response.getOutputStream();
response.reset();
response.setHeader("Content-disposition", "attachment; filename="
+ fname + ".xls");
//首先要使用Workbook类的工厂方法创建一个可写入的工作薄(Workbook)对象
WritableWorkbook wwb = Workbook.createWorkbook(os);
//创建一个可写入的工作表
//Workbook的createSheet方法有两个参数,第一个是工作表的名称,第二个是工作表在工作薄中的位置
WritableSheet sheetOne = wwb.createSheet("sheet1", 0);
WritableFont wf = new WritableFont(WritableFont.TIMES, 10, WritableFont.BOLD, false);
WritableCellFormat wff = new WritableCellFormat(wf);
wff.setWrap(true);
wff.setAlignment(Alignment.CENTRE);
wff.setVerticalAlignment(VerticalAlignment.CENTRE);
//label第一个参数代表列,第二个参数代表行,第三个是数据,第四个是格式
//第一行
sheetOne.addCell(new Label(0,0,"停车位月卡收费台账",wff));
sheetOne.addCell(new Label(0,1,"车位号",wff));
sheetOne.addCell(new Label(1,1,"房号",wff));
sheetOne.addCell(new Label(2,1,"会员姓名",wff));
sheetOne.addCell(new Label(3,1,"会员手机号",wff));
sheetOne.addCell(new Label(4,1,"收费标准(元/月)",wff));
sheetOne.addCell(new Label(5,1,"月卡开通情况",wff));
sheetOne.addCell(new Label(7,1,"收取时间/收取周期/收取金额",wff));
sheetOne.addCell(new Label(8,1,"收取合计",wff));
sheetOne.addCell(new Label(9,1,"分配到各期",wff));
sheetOne.addCell(new Label(12,1,"优惠金额合计",wff));
//第二行
sheetOne.addCell(new Label(5,2,"开通日期",wff));
sheetOne.addCell(new Label(6,2,"车牌号",wff));
sheetOne.addCell(new Label(9,2,"上一年",wff));
sheetOne.addCell(new Label(10,2,"本年",wff));
sheetOne.addCell(new Label(11,2,"下一年",wff));
sheetOne.mergeCells(0, 0, 12, 0);//第一行所有列合并
sheetOne.mergeCells(0, 1, 0, 2);//第一列的第二行和第三行合并
sheetOne.mergeCells(1, 1, 1, 2);//第二列的第二行和第三行合并
sheetOne.mergeCells(2, 1, 2, 2);//第三列的第二行和第三行合并
sheetOne.mergeCells(3, 1, 3, 2);//第四列的第二行和第三行合并
sheetOne.mergeCells(4, 1, 4, 2);//第五列的第二行和第三行合并
sheetOne.mergeCells(5, 1, 6, 1);//第六列和第七列的第二行合并
sheetOne.mergeCells(7, 1, 7, 2);//第八列的第二行和第三行合并
sheetOne.mergeCells(8, 1, 8, 2);//第九列的第二行和第三行合并
sheetOne.mergeCells(9, 1, 11, 1);//第十列和第十二列的第二行合并
sheetOne.mergeCells(12, 1, 12, 2);//第十三列的第二行和第三行合并
List<Map<String, Object>> list = plotprodquery(request, comid);
if(list != null && !list.isEmpty()){
String [] f = new String[]{"p_lot","address","names","mobiles","unitprice","opentime","carnumbers","record","atotal","lasttotal","curtotal","nexttotal","dtotal"};
for(int i=0; i<list.size();i++){
Map<String, Object> map = list.get(i);
for(int j=0;j<f.length;j++){
Label data=new Label(j,i+3,map.get(f[j])+"");//数据从第三行开始添加
sheetOne.addCell(data);
}
}
}
//从内存中读出
wwb.write();
//关闭资源,释放内存
wwb.close();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
return null;
}
@SuppressWarnings("unchecked")
private List<Map<String, Object>> plotprodquery(HttpServletRequest request, Long comid){
String year = RequestUtil.processParams(request, "time");
if(year.equals("")){
year = "curyear";
}
String firday = StringUtils.getFistdayOfYear();//今年开始时间
Integer curyear = Integer.valueOf(firday.split("-")[0]);
String nextfirday = (curyear + 1) + "-01-01";//明年的开始时间
Long b = TimeTools.getLongMilliSecondFrom_HHMMDD(firday)/1000;
Long e = TimeTools.getLongMilliSecondFrom_HHMMDD(nextfirday)/1000;
if(year.equals("lastyear")){
String lastfirday = (curyear - 1) + "-01-01";//去年的开始时间
b = TimeTools.getLongMilliSecondFrom_HHMMDD(lastfirday)/1000;
e = TimeTools.getLongMilliSecondFrom_HHMMDD(firday)/1000;
}
String sql = "select cp.*,p.p_name,p.price from carower_product cp,product_package_tb p where " +
"cp.pid=p.id and cp.p_lot!=? and cp.create_time between ? and ? and p.comid=? order by cp.create_time ";
List<Object> params = new ArrayList<Object>();
params.add("");
params.add(b);
params.add(e);
params.add(comid);
List<Map<String, Object>> list = daService.getAllMap(sql, params);
List<Map<String, Object>> rList = new ArrayList<Map<String,Object>>();
List<String> plots = new ArrayList<String>();
List<Long> uinList = new ArrayList<Long>();
if(list != null && !list.isEmpty()){
for(Map<String, Object> map : list){
String p_lot = (String)map.get("p_lot");
Long create_time = (Long)map.get("create_time");
Long b_time = (Long)map.get("b_time");
Long e_time = (Long)map.get("e_time");
Double total = Double.valueOf(map.get("total") + "");
Double act_total = Double.valueOf(map.get("act_total") + "");
Double d_total = total > act_total ? total - act_total : 0d;
String name = (map.get("name") == null) ? "" : (String)map.get("name");
String p_name = (String)map.get("p_name");
Double price = Double.valueOf(map.get("price") + "");
Long uin = (Long)map.get("uin");
String address = "";
if(map.get("address") != null){
address = (String)map.get("address");
}
String onerec = TimeTools.getTimeStr_yyyy_MM_dd(create_time*1000)+
"/"+TimeTools.getTimeStr_yyyy_MM_dd(b_time*1000)+
"至"+TimeTools.getTimeStr_yyyy_MM_dd(e_time*1000)+
"/"+act_total;
Map<String, Object> stgMap = getAcctByYear(map);
Double lasttotal = Double.valueOf(stgMap.get("lasttotal") + "");//分配到去年的金额
Double curtotal = Double.valueOf(stgMap.get("curtotal") + "");//分配到今年的金额
Double nexttotal = Double.valueOf(stgMap.get("nexttotal") + "");//分配到明年的金额
if(plots.contains(p_lot)){
for(Map<String, Object> map2 : rList){
String plot = (String)map2.get("p_lot");
if(p_lot.equals(plot)){
String record = (String)map2.get("record");//收取记录
String names = (String)map2.get("names");//会员姓名
String uins = (String)map2.get("uins");//会员编号
Double ototal = Double.valueOf(map2.get("ototal") + "");//应收总金额
Double atotal = Double.valueOf(map2.get("atotal") + "");//实收总金额
Double dtotal = Double.valueOf(map2.get("dtotal") + "");//优惠金额
Double lsttal = Double.valueOf(map2.get("lasttotal") + "");
Double curtal = Double.valueOf(map2.get("curtotal") + "");
Double nxttal = Double.valueOf(map2.get("nexttotal") + "");
Integer count = (Integer)map2.get("count");
String addresses = (String)map2.get("address");
record += "\n"+onerec;
map2.put("record", record);
if(!name.equals("") && !names.contains(name)){
if(names.equals("")){
names = name;
}else{
names += ","+name;
}
}
map2.put("names", names);
if(!uins.contains(uin+"")){
uins += ","+uin;
}
map2.put("uins", uins);
map2.put("ototal", StringUtils.formatDouble(ototal + total));
map2.put("atotal", StringUtils.formatDouble(atotal + act_total));
map2.put("dtotal", StringUtils.formatDouble(dtotal + d_total));
map2.put("lasttotal", StringUtils.formatDouble(lsttal + lasttotal));
map2.put("curtotal", StringUtils.formatDouble(curtal + curtotal));
map2.put("nexttotal", StringUtils.formatDouble(nxttal + nexttotal));
map2.put("count", count + 1);
if(!address.equals("") && !addresses.contains(address)){
if(addresses.equals("")){
addresses = address;
}else{
addresses += ","+address;
}
}
map2.put("address", addresses);
break;
}
}
}else{
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("p_lot", p_lot);
map2.put("opentime", TimeTools.getTimeStr_yyyy_MM_dd(create_time*1000));
map2.put("unitprice", price);
map2.put("names", name);
map2.put("uins", uin+"");
map2.put("record", onerec);
map2.put("ototal", total);
map2.put("atotal", act_total);
map2.put("lasttotal", lasttotal);
map2.put("curtotal", curtotal);
map2.put("nexttotal", nexttotal);
map2.put("carnumbers", "");
map2.put("mobiles", "");
map2.put("dtotal", d_total);
map2.put("count", 1);
map2.put("address", address);
plots.add(p_lot);
rList.add(map2);
}
if(!uinList.contains(uin)){
uinList.add(uin);
}
}
List<Map<String, Object>> resultlList = getUserInfo(uinList);
if(resultlList != null && !resultlList.isEmpty()){
for(Map<String, Object> map : rList){
String uins = (String)map.get("uins");
String[] uinArr = uins.split(",");
String carnumbers = "";
String mobiles = "";
for(int i=0; i<uinArr.length; i++){
for(Map<String, Object> map2 : resultlList){
String id = map2.get("id") + "";
String mobile = (String)map2.get("mobile");
if(uinArr[i].equals(id)){
if(mobiles.equals("")){
mobiles = mobile;
}else{
mobiles += "," + mobile;
}
if(map2.get("car_number") != null){
String car_number = (String)map2.get("car_number");
if(car_number.equals("")){
carnumbers = car_number;
}else{
carnumbers += "\n" + car_number;
}
}
break;
}
}
}
map.put("mobiles", mobiles);
map.put("carnumbers", carnumbers);
}
}
// getPlotinfo(rList,comid);
}
return rList;
}
private Map<String, Object> getAcctByYear(Map<String, Object> plotMap){
Map<String, Object> rmap = new HashMap<String, Object>();
String firday = StringUtils.getFistdayOfYear();//今年开始时间
Integer year = Integer.valueOf(firday.split("-")[0]);
String nextfirday = (year + 1) + "-01-01";//明年的开始时间
Long fir = TimeTools.getLongMilliSecondFrom_HHMMDD(firday)/1000;
Long nextfir = TimeTools.getLongMilliSecondFrom_HHMMDD(nextfirday)/1000;
Long btime = (Long)plotMap.get("b_time");
Long etime = (Long)plotMap.get("e_time");
Double act_total = Double.valueOf(plotMap.get("act_total") + "");
Long lsttime = 0L;//分配到去年的时间
Long curtime = 0L;//分配到今年的时间
Long nexttime = 0L;//分配到明年的时间
//计算去年分配的时间
if(etime <= fir){
lsttime = etime - btime;
}else if(btime < fir){
lsttime = fir - btime;
}
//计算今年分配的时间
if(etime > fir && btime < nextfir){
if(btime < fir){
if(etime <= nextfir){
curtime = etime - fir;
}else{
curtime = nextfir - fir;
}
}else{
if(etime > nextfir){
curtime = nextfir - btime;
}else{
curtime = etime - btime;
}
}
}
//计算明年分配的时间
if(etime > nextfir){
if(btime <= nextfir){
nexttime = etime - nextfir;
}else{
nexttime = etime - btime;
}
}
Double lasttotal = StringUtils.formatDouble((((double)lsttime)/(etime - btime))*act_total);//分配到今年之前的金额
Double curtotal = StringUtils.formatDouble((((double)curtime)/(etime - btime))*act_total);//分配到今年的金额
Double nexttotal = StringUtils.formatDouble(act_total-lasttotal - curtotal);//分配到明年的金额
rmap.put("lasttotal", lasttotal);
rmap.put("curtotal", curtotal);
rmap.put("nexttotal", nexttotal);
return rmap;
}
private void getPlotinfo(List<Map<String, Object>> list, Long comid){
if(list != null && !list.isEmpty()){
List<Object> plots = new ArrayList<Object>();
String preParams ="";
for(Map<String, Object> map : list){
String p_lot = (String)map.get("p_lot");
plots.add(p_lot);
if(preParams.equals("")){
preParams ="?";
}else{
preParams += ",?";
}
}
plots.add(comid);
String sql = "select cid,address from com_park_tb where cid in ("+preParams+") and comid=? ";
List<Map<String, Object>> list2 = daService.getAllMap(sql, plots);
if(list2 != null && !list2.isEmpty()){
for(Map<String, Object> map : list2){
String cid = "";
if(map.get("cid") != null){
cid = (String)map.get("cid");
}
String address = "";
if(map.get("address") != null){
address = (String)map.get("address");
}
for(Map<String, Object> map2 : list){
String p_lot = (String)map2.get("p_lot");
if(cid.equals(p_lot)){
map2.put("address", address);
break;
}
}
}
}
}
}
private void getcarinfo(List<Map<String, Object>> list){
if(list != null && !list.isEmpty()){
List<Long> uins = new ArrayList<Long>();
for(Map<String, Object> map : list){
Long uin = (Long)map.get("uin");
Double total = Double.valueOf(map.get("total") + "");
Double act_total = Double.valueOf(map.get("act_total") + "");
Double favtotal = 0d;
if(total > act_total){
favtotal = StringUtils.formatDouble(total - act_total);
}
map.put("favtotal", favtotal);
if(!uins.contains(uin)){
uins.add(uin);
}
}
List<Map<String, Object>> resultlList = getUserInfo(uins);
for(Map<String, Object> map : list){
Long uin = (Long)map.get("uin");
for(Map<String, Object> map2 : resultlList){
Long id = (Long)map2.get("id");
if(uin.intValue() == id.intValue()){
if(map2.get("nickname") != null){
map.put("nickname", map2.get("nickname"));
}
if(map2.get("mobile") != null){
map.put("mobile", map2.get("mobile"));
}
if(map2.get("car_number") != null){
map.put("car_number", map2.get("car_number"));
}
}
}
}
}
}
private List<Map<String, Object>> getUserInfo(List<Long> uins){
List<Map<String, Object>> resultlList = new ArrayList<Map<String,Object>>();
if(uins != null && !uins.isEmpty()){
String preParams ="";
for(Long uin : uins){
if(preParams.equals("")){
preParams ="?";
}else{
preParams += ",?";
}
}
List<Object> params = new ArrayList<Object>();
params.addAll(uins);
String sql = "select c.car_number,u.id,u.nickname,u.mobile from user_info_tb u left join car_info_tb c on u.id=c.uin where " +
"u.id in ("+preParams+") ";
List<Map<String, Object>> list2 = daService.getAllMap(sql, params);
List<Long> rsltuins = new ArrayList<Long>();
for(Map<String, Object> map : list2){
Long uin = (Long)map.get("id");
if(rsltuins.contains(uin)){
String carnumber = (String)map.get("car_number");
for(Map<String, Object> map2 : resultlList){
Long id = (Long)map2.get("id");
if(uin.intValue() == id.intValue()){
String cnum = (String)map2.get("car_number");
cnum += "," + carnumber;
map2.put("car_number", cnum);
break;
}
}
}else{
rsltuins.add(uin);
resultlList.add(map);
}
}
}
return resultlList;
}
}
| [
"[email protected]"
] | |
ef6cbb33f2a7d5e713e31853abf62f511e528676 | 3592d3b212aef1167933234813329bc81a314cbf | /app/src/androidTest/java/id/ac/tari/sqlitedemo02/ExampleInstrumentedTest.java | 27298ea7d7519dd71c6e77a0d54802ec895490db | [] | no_license | dwilestarilestari/SQLiteDemo02 | fae9c71dfe48c3b61257a8f6f80852fcc034a6c6 | 7cdc7b0d7f22d2ac586c8ba30cee849c3fc63866 | refs/heads/master | 2020-08-28T07:34:52.068416 | 2019-10-26T01:09:13 | 2019-10-26T01:09:13 | 217,637,883 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 717 | java | package id.ac.tari.sqlitedemo02;
import android.content.Context;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("id.ac.tari.sqlitedemo02", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
952844b9856f6004b98d2bd7894b2b377bc68d0e | a30292faa777e690112f1ea85ed5ae1ecd762bfe | /src/test/java/com/github/hermod/ser/descriptor/FootballPlayer.java | d01553c523b11e73e1612a3f9d7f5866c5ed63c4 | [] | no_license | hermod/hermod-java-ser-descriptor-api | 293548001602a96f14673e904eb1a6407da20ed1 | 9fb87dec143a1233850d29da46acf4bde4c0a55b | refs/heads/master | 2021-01-21T11:23:55.638750 | 2014-01-06T23:13:29 | 2014-01-06T23:13:29 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 617 | java | package com.github.hermod.ser.descriptor;
/**
* <p>FootballPlayer. </p>
*
* @author anavarro - Apr 14, 2013
*
*/
public enum FootballPlayer implements IEnumIntConverter{
GOALKEEPER(1), LIBERO(5), STRIKER(9);
private int jerseyNumber;
/**
* Constructor.
*
* @param aNumber
*/
private FootballPlayer(final int aNumber) {
this.jerseyNumber = aNumber;
}
/**
* (non-Javadoc)
*
* @see com.github.hermod.ser.descriptor.IEnumIntConverter#convert()
*/
@Override
public Integer convert() {
return jerseyNumber;
}
}
| [
"[email protected]"
] |
Subsets and Splits