blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
listlengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e7e8d33af50cc54ad5723a0356c1c5e931404dda | ea61a4f82e2582ce8a7fe9cbd4fad6d78c8fbbe0 | /src/com/rfour/LinkedListApp.java | c47ec3b457b1d3c8a88f9e9aabb0028288bef0ef | [
"MIT"
]
| permissive | rramatchandran/DataStructures | 429664ec1f75c999d8f0e613866a2c35cbfa67fc | ed318fc872a355aa3e95b1265d94def6fedf0fbb | refs/heads/master | 2020-04-14T07:18:37.224738 | 2019-01-01T02:36:01 | 2019-01-01T02:36:01 | 163,708,981 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,620 | java | package com.rfour;
import com.rfour.ds.BasicLinkedList;
public class LinkedListApp {
BasicLinkedList<TrainCar> train = new BasicLinkedList<TrainCar>();
public static void main(String[] args) {
LinkedListApp app = new LinkedListApp();
app.buildInitialTrain();
//print out the train size
System.out.println(app.trainSize());
//first stop, we remove a car and add a couple more
app.firstStop();
//print out the train size
System.out.println("After First Stop train size: " + app.trainSize());
//second stop, we need to remove all the tankers
app.secondStop();
//print out the train size
System.out.println("After Second Stop train size: " + app.trainSize());
//at the last stop we remove all of the train cars and we're done
app.lastStop();
//print out the train size
System.out.println("After Last Stop train size: " + app.trainSize());
}
private int trainSize() {
return train.size();
}
private void buildInitialTrain() {
//build the train for it's initial trip
TrainCar car1 = new TrainCar(CarType.BOXCAR, "Amazon Packages");
TrainCar car2 = new TrainCar(CarType.FLATBED, "Farm Machinery");
TrainCar car3 = new TrainCar(CarType.BOXCAR, "Paper");
TrainCar car4 = new TrainCar(CarType.BOXCAR, "Grease");
TrainCar car5 = new TrainCar(CarType.TANKER, "Crude Oil #1");
TrainCar car6 = new TrainCar(CarType.TANKER, "Crude Oil #2");
TrainCar car7 = new TrainCar(CarType.TANKER, "Crude Oil #3");
TrainCar car8 = new TrainCar(CarType.FLATBED, "Empty Shipping Container");
TrainCar car9 = new TrainCar(CarType.HOPPER, "Wheat Grain");
TrainCar car10 = new TrainCar(CarType.HOPPER, "Coal");
//connect the cars
train.add(car1);
train.add(car2);
train.add(car3);
train.add(car4);
train.add(car5);
train.add(car6);
train.add(car7);
train.add(car8);
train.add(car9);
train.add(car10);
//test out the find and get
//see if we can find the position of the paper box car and then get it
int position = train.find(car3);
TrainCar paperCar = train.get(position);
System.out.println("Train is built correctly. found and retrieved the paper car at position: " + paperCar + " - " + position);
//print out the train cars
System.out.println(train);
}
private void firstStop() {
//at this stop we need to pull off the first box car and insert a new BoxCar after the farm machinery
TrainCar boxcar = train.remove();
System.out.println("First Stop: Removed - " + boxcar);
TrainCar newBoxcar = new TrainCar(CarType.BOXCAR, "Farm Fence Posts and Barbwire");
train.insert(newBoxcar, 1);
//print out the train cars
System.out.println(train);
}
private void secondStop() {
//at this stop we need to pull off all of the tanker cars. They should start at position 5 and there's 3 of them
TrainCar car = train.removeAt(5);
System.out.println("Second Stop: Removed - " + car);
car = train.removeAt(5);
System.out.println("Second Stop: Removed - " + car);
car = train.removeAt(5);
System.out.println("Second Stop: Removed - " + car);
//print out the train cars
System.out.println(train);
}
private void lastStop() {
//at this stop we simply pull the remaining cars off of the train until we have no more train.
try{
while(true) {
TrainCar car = train.remove();
System.out.println("Last Stop: Removed - " + car);
}
} catch (IllegalStateException ise) {
//when we get an ise that means we don't have any more cars to remove and the train is now empty
}
//print out the train cars
System.out.println(train);
}
class TrainCar {
private CarType type;
private String contents;
public TrainCar(CarType carType, String carContents) {
this.type = carType;
this.contents = carContents;
}
public String toString() {
return type.toString() + " - " + contents;
}
}
enum CarType {
BOXCAR, TANKER, FLATBED, HOPPER
}
}
| [
"[email protected]"
]
| |
6c8a3ff1d2243b03c4139c52566db89e1d8610bc | d44c75d5b901973b4fe6a72e882dd3ab34c21cea | /BillingManagementBackend/src/test/java/com/getBatch3/BillingManagementBackend/BillingManagementBackend/AppTest.java | deeaf78a340bfda165762fc066a9848a3412641c | []
| no_license | Tushar8Sharma/Billing-Management- | e22410e3e54bd4db57664e267ff1efa695b6294d | cda1d72677c20758b869021d061470ff517b2c65 | refs/heads/master | 2022-12-22T19:58:11.424572 | 2019-08-23T15:12:56 | 2019-08-23T15:12:56 | 204,021,929 | 0 | 0 | null | 2022-12-16T00:40:36 | 2019-08-23T15:10:50 | Java | UTF-8 | Java | false | false | 1,740 | java | package com.getBatch3.BillingManagementBackend.BillingManagementBackend;
import static org.junit.Assert.*;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import com.getBatch3.BillingManagementBackend.DBConfig.DBConfig;
import com.getBatch3.BillingManagementBackend.Daos.DeveloperDao;
import com.getBatch3.BillingManagementBackend.Daos.ProjectDao;
import com.getBatch3.BillingManagementBackend.Daos.RoleDao;
import com.getBatch3.BillingManagementBackend.models.Developer;
import com.getBatch3.BillingManagementBackend.models.Project;
import com.getBatch3.BillingManagementBackend.models.Role;
/**
* Unit test for simple App.
*/
public class AppTest
{
private static ProjectDao projectDao;
private static RoleDao roleDao;
private static DeveloperDao developerDao;
@BeforeClass
public static void init() {
AnnotationConfigApplicationContext context=new AnnotationConfigApplicationContext();
context.register(DBConfig.class);
context.refresh();
projectDao=context.getBean("projectDao",ProjectDao.class);
roleDao=context.getBean("roleDao",RoleDao.class);
developerDao=context.getBean("developerDao",DeveloperDao.class);
}
@Test
@Ignore
public void getProjectByIdTest() {
List<Project> obj=projectDao.getAllProject();
assertNotNull("Project not available",obj);
}
@Test
@Ignore
public void getAllRole() {
List<Role> obj=roleDao.getAllRole();
assertNotNull("Project not available",obj);
}
@Test
@Ignore
public void getAllDeveloper() {
List<Developer> obj=developerDao.getAllDeveloper();
assertNotNull("Developer not available",obj);
}
}
| [
"[email protected]"
]
| |
4cdf85d738f57d13dcffbb9e9402746323c3259e | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/5/5_fddcc20015f925af328afb208c754ec06543748c/ApplicationConnection/5_fddcc20015f925af328afb208c754ec06543748c_ApplicationConnection_s.java | 1cf6f4b42808ddd4f375318e8109297f729b0461 | []
| no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 84,134 | java | /*
@ITMillApache2LicenseForJavaFiles@
*/
package com.vaadin.terminal.gwt.client;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize;
import com.vaadin.terminal.gwt.client.RenderInformation.Size;
import com.vaadin.terminal.gwt.client.ui.Field;
import com.vaadin.terminal.gwt.client.ui.VContextMenu;
import com.vaadin.terminal.gwt.client.ui.VNotification;
import com.vaadin.terminal.gwt.client.ui.VView;
import com.vaadin.terminal.gwt.client.ui.VNotification.HideEvent;
import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager;
import com.vaadin.terminal.gwt.server.AbstractCommunicationManager;
/**
* This is the client side communication "engine", managing client-server
* communication with its server side counterpart
* {@link AbstractCommunicationManager}.
*
* Client-side widgets receive updates from the corresponding server-side
* components as calls to
* {@link Paintable#updateFromUIDL(UIDL, ApplicationConnection)} (not to be
* confused with the server side interface {@link com.vaadin.terminal.Paintable}
* ). Any client-side changes (typically resulting from user actions) are sent
* back to the server as variable changes (see {@link #updateVariable()}).
*
* TODO document better
*
* Entry point classes (widgetsets) define <code>onModuleLoad()</code>.
*/
public class ApplicationConnection {
// This indicates the whole page is generated by us (not embedded)
public static final String GENERATED_BODY_CLASSNAME = "v-generated-body";
private static final String MODIFIED_CLASSNAME = "v-modified";
private static final String REQUIRED_CLASSNAME_EXT = "-required";
private static final String ERROR_CLASSNAME_EXT = "-error";
public static final String VAR_RECORD_SEPARATOR = "\u001e";
public static final String VAR_FIELD_SEPARATOR = "\u001f";
public static final String VAR_BURST_SEPARATOR = "\u001d";
public static final String VAR_ARRAYITEM_SEPARATOR = "\u001c";
public static final String UIDL_SECURITY_TOKEN_ID = "Vaadin-Security-Key";
/**
* @deprecated use UIDL_SECURITY_TOKEN_ID instead
*/
@Deprecated
public static final String UIDL_SECURITY_HEADER = UIDL_SECURITY_TOKEN_ID;
public static final String PARAM_UNLOADBURST = "onunloadburst";
public static final String ATTRIBUTE_DESCRIPTION = "description";
public static final String ATTRIBUTE_ERROR = "error";
// will hold the UIDL security key (for XSS protection) once received
private String uidl_security_key = "init";
private final HashMap<String, String> resourcesMap = new HashMap<String, String>();
private static Console console;
private final ArrayList<String> pendingVariables = new ArrayList<String>();
private final ComponentDetailMap idToPaintableDetail = ComponentDetailMap
.create();
private final WidgetSet widgetSet;
private VContextMenu contextMenu = null;
private Timer loadTimer;
private Timer loadTimer2;
private Timer loadTimer3;
private Element loadElement;
private final VView view;
private boolean applicationRunning = false;
private int activeRequests = 0;
/** Parameters for this application connection loaded from the web-page */
private final ApplicationConfiguration configuration;
/** List of pending variable change bursts that must be submitted in order */
private final ArrayList<ArrayList<String>> pendingVariableBursts = new ArrayList<ArrayList<String>>();
/** Timer for automatic refirect to SessionExpiredURL */
private Timer redirectTimer;
/** redirectTimer scheduling interval in seconds */
private int sessionExpirationInterval;
private ArrayList<Paintable> relativeSizeChanges = new ArrayList<Paintable>();;
private ArrayList<Paintable> componentCaptionSizeChanges = new ArrayList<Paintable>();;
private Date requestStartTime;
private boolean validatingLayouts = false;
private Set<Paintable> zeroWidthComponents = null;
private Set<Paintable> zeroHeightComponents = null;
public ApplicationConnection(WidgetSet widgetSet,
ApplicationConfiguration cnf) {
this.widgetSet = widgetSet;
configuration = cnf;
windowName = configuration.getInitialWindowName();
if (isDebugMode()) {
console = new VDebugConsole(this, cnf, !isQuietDebugMode());
} else {
console = new NullConsole();
}
ComponentLocator componentLocator = new ComponentLocator(this);
String appRootPanelName = cnf.getRootPanelId();
// remove the end (window name) of autogenerated rootpanel id
appRootPanelName = appRootPanelName.replaceFirst("-\\d+$", "");
initializeTestbenchHooks(componentLocator, appRootPanelName);
initializeClientHooks();
view = new VView(cnf.getRootPanelId());
showLoadingIndicator();
}
/**
* Starts this application. Don't call this method directly - it's called by
* {@link ApplicationConfiguration#startNextApplication()}, which should be
* called once this application has started (first response received) or
* failed to start. This ensures that the applications are started in order,
* to avoid session-id problems.
*/
void start() {
makeUidlRequest("", true, false, false);
}
private native void initializeTestbenchHooks(
ComponentLocator componentLocator, String TTAppId)
/*-{
var ap = this;
var client = {};
client.isActive = function() {
return [email protected]::hasActiveRequest()() || [email protected]::isLoadingIndicatorVisible()();
}
var vi = [email protected]::getVersionInfo()();
if (vi) {
client.getVersionInfo = function() {
return vi;
}
}
client.getElementByPath = function(id) {
return componentLocator.@com.vaadin.terminal.gwt.client.ComponentLocator::getElementByPath(Ljava/lang/String;)(id);
}
client.getPathForElement = function(element) {
return componentLocator.@com.vaadin.terminal.gwt.client.ComponentLocator::getPathForElement(Lcom/google/gwt/user/client/Element;)(element);
}
if(!$wnd.vaadin.clients) {
$wnd.vaadin.clients = {};
}
$wnd.vaadin.clients[TTAppId] = client;
}-*/;
/**
* Helper for tt initialization
*/
@SuppressWarnings("unused")
private JavaScriptObject getVersionInfo() {
return configuration.getVersionInfoJSObject();
}
/**
* Publishes a JavaScript API for mash-up applications.
* <ul>
* <li><code>vaadin.forceSync()</code> sends pending variable changes, in
* effect synchronizing the server and client state. This is done for all
* applications on host page.</li>
* <li><code>vaadin.postRequestHooks</code> is a map of functions which gets
* called after each XHR made by vaadin application. Note, that it is
* attaching js functions responsibility to create the variable like this:
*
* <code><pre>
* if(!vaadin.postRequestHooks) {vaadin.postRequestHooks = new Object();}
* postRequestHooks.myHook = function(appId) {
* if(appId == "MyAppOfInterest") {
* // do the staff you need on xhr activity
* }
* }
* </pre></code> First parameter passed to these functions is the identifier
* of Vaadin application that made the request.
* </ul>
*
* TODO make this multi-app aware
*/
private native void initializeClientHooks()
/*-{
var app = this;
var oldSync;
if($wnd.vaadin.forceSync) {
oldSync = $wnd.vaadin.forceSync;
}
$wnd.vaadin.forceSync = function() {
if(oldSync) {
oldSync();
}
[email protected]::sendPendingVariableChanges()();
}
var oldForceLayout;
if($wnd.vaadin.forceLayout) {
oldForceLayout = $wnd.vaadin.forceLayout;
}
$wnd.vaadin.forceLayout = function() {
if(oldForceLayout) {
oldForceLayout();
}
[email protected]::forceLayout()();
}
}-*/;
/**
* Runs possibly registered client side post request hooks. This is expected
* to be run after each uidl request made by Vaadin application.
*
* @param appId
*/
private static native void runPostRequestHooks(String appId)
/*-{
if($wnd.vaadin.postRequestHooks) {
for(var hook in $wnd.vaadin.postRequestHooks) {
if(typeof($wnd.vaadin.postRequestHooks[hook]) == "function") {
try {
$wnd.vaadin.postRequestHooks[hook](appId);
} catch(e) {}
}
}
}
}-*/;
/**
* Get the active Console for writing debug messages. May return an actual
* logging console, or the NullConsole if debugging is not turned on.
*
* @return the active Console
*/
public static Console getConsole() {
return console;
}
/**
* Checks if client side is in debug mode. Practically this is invoked by
* adding ?debug parameter to URI.
*
* @return true if client side is currently been debugged
*/
public native static boolean isDebugMode()
/*-{
if($wnd.vaadin.debug) {
var parameters = $wnd.location.search;
var re = /debug[^\/]*$/;
return re.test(parameters);
} else {
return false;
}
}-*/;
private native static boolean isQuietDebugMode()
/*-{
var uri = $wnd.location;
var re = /debug=q[^\/]*$/;
return re.test(uri);
}-*/;
/**
* Gets the application base URI. Using this other than as the download
* action URI can cause problems in Portlet 2.0 deployments.
*
* @return application base URI
*/
public String getAppUri() {
return configuration.getApplicationUri();
};
/**
* Indicates whether or not there are currently active UIDL requests. Used
* internally to squence requests properly, seldom needed in Widgets.
*
* @return true if there are active requests
*/
public boolean hasActiveRequest() {
return (activeRequests > 0);
}
private void makeUidlRequest(final String requestData,
final boolean repaintAll, final boolean forceSync,
final boolean analyzeLayouts) {
startRequest();
// Security: double cookie submission pattern
final String rd = uidl_security_key + VAR_BURST_SEPARATOR + requestData;
console.log("Making UIDL Request with params: " + rd);
String uri;
if (configuration.usePortletURLs()) {
uri = configuration.getPortletUidlURLBase();
} else {
uri = getAppUri() + "UIDL" + configuration.getPathInfo();
}
if (repaintAll) {
// collect some client side data that will be sent to server on
// initial uidl request
int clientHeight = Window.getClientHeight();
int clientWidth = Window.getClientWidth();
com.google.gwt.dom.client.Element pe = view.getElement()
.getParentElement();
int offsetHeight = pe.getOffsetHeight();
int offsetWidth = pe.getOffsetWidth();
int screenWidth = BrowserInfo.get().getScreenWidth();
int screenHeight = BrowserInfo.get().getScreenHeight();
String token = History.getToken();
// TODO figure out how client and view size could be used better on
// server. screen size can be accessed via Browser object, but other
// values currently only via transaction listener.
if (configuration.usePortletURLs()) {
uri += "&";
} else {
uri += "?";
}
uri += "repaintAll=1&" + "sh=" + screenHeight + "&sw="
+ screenWidth + "&cw=" + clientWidth + "&ch="
+ clientHeight + "&vw=" + offsetWidth + "&vh="
+ offsetHeight + "&fr=" + token;
if (analyzeLayouts) {
uri += "&analyzeLayouts=1";
}
}
if (windowName != null && windowName.length() > 0) {
uri += (repaintAll || configuration.usePortletURLs() ? "&" : "?")
+ "windowName=" + windowName;
}
if (!forceSync) {
final RequestBuilder rb = new RequestBuilder(RequestBuilder.POST,
uri);
// TODO enable timeout
// rb.setTimeoutMillis(timeoutMillis);
rb.setHeader("Content-Type", "text/plain;charset=utf-8");
try {
rb.sendRequest(rd, new RequestCallback() {
public void onError(Request request, Throwable exception) {
showCommunicationError(exception.getMessage());
endRequest();
if (!applicationRunning) {
// start failed, let's try to start the next app
ApplicationConfiguration.startNextApplication();
}
}
public void onResponseReceived(Request request,
Response response) {
console.log("Server visit took "
+ String.valueOf((new Date()).getTime()
- requestStartTime.getTime()) + "ms");
int statusCode = response.getStatusCode();
if ((statusCode / 100) == 4) {
// Handle all 4xx errors the same way as (they are
// all permanent errors)
showCommunicationError("UIDL could not be read from server. Check servlets mappings. Error code: "
+ statusCode);
endRequest();
return;
}
switch (statusCode) {
case 0:
showCommunicationError("Invalid status code 0 (server down?)");
endRequest();
return;
case 503:
// We'll assume msec instead of the usual seconds
int delay = Integer.parseInt(response
.getHeader("Retry-After"));
console.log("503, retrying in " + delay + "msec");
(new Timer() {
@Override
public void run() {
activeRequests--;
makeUidlRequest(requestData, repaintAll,
forceSync, analyzeLayouts);
}
}).schedule(delay);
return;
}
if (applicationRunning) {
handleReceivedJSONMessage(response);
} else {
applicationRunning = true;
handleWhenCSSLoaded(response);
ApplicationConfiguration.startNextApplication();
}
}
int cssWaits = 0;
static final int MAX_CSS_WAITS = 20;
private void handleWhenCSSLoaded(final Response response) {
int heightOfLoadElement = DOM.getElementPropertyInt(
loadElement, "offsetHeight");
if (heightOfLoadElement == 0
&& cssWaits < MAX_CSS_WAITS) {
(new Timer() {
@Override
public void run() {
handleWhenCSSLoaded(response);
}
}).schedule(50);
console
.log("Assuming CSS loading is not complete, "
+ "postponing render phase. "
+ "(.v-loading-indicator height == 0)");
cssWaits++;
} else {
handleReceivedJSONMessage(response);
if (cssWaits >= MAX_CSS_WAITS) {
console
.error("CSS files may have not loaded properly.");
}
}
}
});
} catch (final RequestException e) {
ClientExceptionHandler.displayError(e);
endRequest();
}
} else {
// Synchronized call, discarded response (leaving the page)
SynchronousXHR syncXHR = (SynchronousXHR) SynchronousXHR.create();
syncXHR.synchronousPost(uri + "&" + PARAM_UNLOADBURST + "=1", rd);
}
}
/**
* Shows the communication error notification. The 'details' only go to the
* console for now.
*
* @param details
* Optional details for debugging.
*/
private void showCommunicationError(String details) {
console.error("Communication error: " + details);
String html = "";
if (configuration.getCommunicationErrorCaption() != null) {
html += "<h1>" + configuration.getCommunicationErrorCaption()
+ "</h1>";
}
if (configuration.getCommunicationErrorMessage() != null) {
html += "<p>" + configuration.getCommunicationErrorMessage()
+ "</p>";
}
if (html.length() > 0) {
VNotification n = new VNotification(1000 * 60 * 45);
n.addEventListener(new NotificationRedirect(configuration
.getCommunicationErrorUrl()));
n
.show(html, VNotification.CENTERED_TOP,
VNotification.STYLE_SYSTEM);
} else {
redirect(configuration.getCommunicationErrorUrl());
}
}
private void startRequest() {
activeRequests++;
requestStartTime = new Date();
// show initial throbber
if (loadTimer == null) {
loadTimer = new Timer() {
@Override
public void run() {
/*
* IE7 does not properly cancel the event with
* loadTimer.cancel() so we have to check that we really
* should make it visible
*/
if (loadTimer != null) {
showLoadingIndicator();
}
}
};
// First one kicks in at 300ms
}
loadTimer.schedule(300);
}
private void endRequest() {
if (applicationRunning) {
checkForPendingVariableBursts();
runPostRequestHooks(configuration.getRootPanelId());
}
activeRequests--;
// deferring to avoid flickering
DeferredCommand.addCommand(new Command() {
public void execute() {
if (activeRequests == 0) {
hideLoadingIndicator();
}
}
});
}
/**
* This method is called after applying uidl change set to application.
*
* It will clean current and queued variable change sets. And send next
* change set if it exists.
*/
private void checkForPendingVariableBursts() {
cleanVariableBurst(pendingVariables);
if (pendingVariableBursts.size() > 0) {
for (Iterator<ArrayList<String>> iterator = pendingVariableBursts
.iterator(); iterator.hasNext();) {
cleanVariableBurst(iterator.next());
}
ArrayList<String> nextBurst = pendingVariableBursts.get(0);
pendingVariableBursts.remove(0);
buildAndSendVariableBurst(nextBurst, false);
}
}
/**
* Cleans given queue of variable changes of such changes that came from
* components that do not exist anymore.
*
* @param variableBurst
*/
private void cleanVariableBurst(ArrayList<String> variableBurst) {
for (int i = 1; i < variableBurst.size(); i += 2) {
String id = variableBurst.get(i);
id = id.substring(0, id.indexOf(VAR_FIELD_SEPARATOR));
if (!idToPaintableDetail.containsKey(id) && !id.startsWith("DD")) {
// variable owner does not exist anymore
variableBurst.remove(i - 1);
variableBurst.remove(i - 1);
i -= 2;
ApplicationConnection.getConsole().log(
"Removed variable from removed component: " + id);
}
}
}
private void showLoadingIndicator() {
// show initial throbber
if (loadElement == null) {
loadElement = DOM.createDiv();
DOM.setStyleAttribute(loadElement, "position", "absolute");
DOM.appendChild(view.getElement(), loadElement);
ApplicationConnection.getConsole().log("inserting load indicator");
}
DOM.setElementProperty(loadElement, "className", "v-loading-indicator");
DOM.setStyleAttribute(loadElement, "display", "block");
// Initialize other timers
loadTimer2 = new Timer() {
@Override
public void run() {
DOM.setElementProperty(loadElement, "className",
"v-loading-indicator-delay");
}
};
// Second one kicks in at 1500ms from request start
loadTimer2.schedule(1200);
loadTimer3 = new Timer() {
@Override
public void run() {
DOM.setElementProperty(loadElement, "className",
"v-loading-indicator-wait");
}
};
// Third one kicks in at 5000ms from request start
loadTimer3.schedule(4700);
}
private void hideLoadingIndicator() {
if (loadTimer != null) {
loadTimer.cancel();
if (loadTimer2 != null) {
loadTimer2.cancel();
loadTimer3.cancel();
}
loadTimer = null;
}
if (loadElement != null) {
DOM.setStyleAttribute(loadElement, "display", "none");
}
}
/**
* Determines whether or not the loading indicator is showing.
*
* @return true if the loading indicator is visible
*/
public boolean isLoadingIndicatorVisible() {
if (loadElement == null) {
return false;
}
if (loadElement.getStyle().getProperty("display").equals("none")) {
return false;
}
return true;
}
private static native ValueMap parseJSONResponse(String jsonText)
/*-{
try {
return JSON.parse(jsonText);
} catch(ignored) {
return eval('(' + jsonText + ')');
}
}-*/;
private void handleReceivedJSONMessage(Response response) {
final Date start = new Date();
// for(;;);[realjson]
final String jsonText = response.getText().substring(9,
response.getText().length() - 1);
final ValueMap json;
try {
json = parseJSONResponse(jsonText);
} catch (final Exception e) {
endRequest();
showCommunicationError(e.getMessage() + " - Original JSON-text:");
console.log(jsonText);
return;
}
ApplicationConnection.getConsole().log(
"JSON parsing took " + (new Date().getTime() - start.getTime())
+ "ms");
// Handle redirect
if (json.containsKey("redirect")) {
String url = json.getValueMap("redirect").getString("url");
console.log("redirecting to " + url);
redirect(url);
return;
}
// Get security key
if (json.containsKey(UIDL_SECURITY_TOKEN_ID)) {
uidl_security_key = json.getString(UIDL_SECURITY_TOKEN_ID);
}
if (json.containsKey("resources")) {
ValueMap resources = json.getValueMap("resources");
JsArrayString keyArray = resources.getKeyArray();
int l = keyArray.length();
for (int i = 0; i < l; i++) {
String key = keyArray.get(i);
resourcesMap.put(key, resources.getAsString(key));
}
}
if (json.containsKey("typeMappings")) {
configuration.addComponentMappings(
json.getValueMap("typeMappings"), widgetSet);
}
Command c = new Command() {
public void execute() {
if (json.containsKey("locales")) {
// Store locale data
JsArray<ValueMap> valueMapArray = json
.getJSValueMapArray("locales");
LocaleService.addLocales(valueMapArray);
}
ValueMap meta = null;
if (json.containsKey("meta")) {
meta = json.getValueMap("meta");
if (meta.containsKey("repaintAll")) {
view.clear();
idToPaintableDetail.clear();
if (meta.containsKey("invalidLayouts")) {
validatingLayouts = true;
zeroWidthComponents = new HashSet<Paintable>();
zeroHeightComponents = new HashSet<Paintable>();
}
}
if (meta.containsKey("timedRedirect")) {
final ValueMap timedRedirect = meta
.getValueMap("timedRedirect");
redirectTimer = new Timer() {
@Override
public void run() {
redirect(timedRedirect.getString("url"));
}
};
sessionExpirationInterval = timedRedirect
.getInt("interval");
}
}
if (redirectTimer != null) {
redirectTimer.schedule(1000 * sessionExpirationInterval);
}
// Process changes
JsArray<ValueMap> changes = json.getJSValueMapArray("changes");
ArrayList<Paintable> updatedWidgets = new ArrayList<Paintable>();
relativeSizeChanges.clear();
componentCaptionSizeChanges.clear();
int length = changes.length();
for (int i = 0; i < length; i++) {
try {
final UIDL change = changes.get(i).cast();
try {
console.dirUIDL(change);
} catch (final Exception e) {
ClientExceptionHandler.displayError(e);
// TODO: dir doesn't work in any browser although it
// should
// work (works in hosted mode)
// it partially did at some part but now broken.
}
final UIDL uidl = change.getChildUIDL(0);
// TODO optimize
final Paintable paintable = getPaintable(uidl.getId());
if (paintable != null) {
paintable.updateFromUIDL(uidl,
ApplicationConnection.this);
// paintable may have changed during render to
// another
// implementation, use the new one for updated
// widgets map
updatedWidgets.add(idToPaintableDetail.get(
uidl.getId()).getComponent());
} else {
if (!uidl.getTag().equals(
configuration.getEncodedWindowTag())) {
ClientExceptionHandler
.displayError("Received update for "
+ uidl.getTag()
+ ", but there is no such paintable ("
+ uidl.getId() + ") rendered.");
} else {
view.updateFromUIDL(uidl,
ApplicationConnection.this);
}
}
} catch (final Throwable e) {
ClientExceptionHandler.displayError(e);
}
}
if (json.containsKey("dd")) {
// response contains data for drag and drop service
VDragAndDropManager.get().handleServerResponse(
json.getValueMap("dd"));
}
// Check which widgets' size has been updated
Set<Paintable> sizeUpdatedWidgets = new HashSet<Paintable>();
updatedWidgets.addAll(relativeSizeChanges);
sizeUpdatedWidgets.addAll(componentCaptionSizeChanges);
for (Paintable paintable : updatedWidgets) {
ComponentDetail detail = idToPaintableDetail
.get(getPid(paintable));
Widget widget = (Widget) paintable;
Size oldSize = detail.getOffsetSize();
Size newSize = new Size(widget.getOffsetWidth(), widget
.getOffsetHeight());
if (oldSize == null || !oldSize.equals(newSize)) {
sizeUpdatedWidgets.add(paintable);
detail.setOffsetSize(newSize);
}
}
Util.componentSizeUpdated(sizeUpdatedWidgets);
if (meta != null) {
if (meta.containsKey("appError")) {
ValueMap error = meta.getValueMap("appError");
String html = "";
if (error.containsKey("caption")
&& error.getString("caption") != null) {
html += "<h1>" + error.getAsString("caption")
+ "</h1>";
}
if (error.containsKey("message")
&& error.getString("message") != null) {
html += "<p>" + error.getAsString("message")
+ "</p>";
}
String url = null;
if (error.containsKey("url")) {
url = error.getString("url");
}
if (html.length() != 0) {
/* 45 min */
VNotification n = new VNotification(1000 * 60 * 45);
n.addEventListener(new NotificationRedirect(url));
n.show(html, VNotification.CENTERED_TOP,
VNotification.STYLE_SYSTEM);
} else {
redirect(url);
}
applicationRunning = false;
}
if (validatingLayouts) {
getConsole().printLayoutProblems(meta,
ApplicationConnection.this,
zeroHeightComponents, zeroWidthComponents);
zeroHeightComponents = null;
zeroWidthComponents = null;
validatingLayouts = false;
}
}
// TODO build profiling for widget impl loading time
final long prosessingTime = (new Date().getTime())
- start.getTime();
console.log(" Processing time was "
+ String.valueOf(prosessingTime) + "ms for "
+ jsonText.length() + " characters of JSON");
console.log("Referenced paintables: "
+ idToPaintableDetail.size());
endRequest();
}
};
configuration.runWhenWidgetsLoaded(c);
}
/**
* This method assures that all pending variable changes are sent to server.
* Method uses synchronized xmlhttprequest and does not return before the
* changes are sent. No UIDL updates are processed and thus UI is left in
* inconsistent state. This method should be called only when closing
* windows - normally sendPendingVariableChanges() should be used.
*/
public void sendPendingVariableChangesSync() {
if (applicationRunning) {
pendingVariableBursts.add(pendingVariables);
ArrayList<String> nextBurst = pendingVariableBursts.get(0);
pendingVariableBursts.remove(0);
buildAndSendVariableBurst(nextBurst, true);
}
}
// Redirect browser, null reloads current page
private static native void redirect(String url)
/*-{
if (url) {
$wnd.location = url;
} else {
$wnd.location.reload(false);
}
}-*/;
public void registerPaintable(String pid, Paintable paintable) {
ComponentDetail componentDetail = new ComponentDetail(this, pid,
paintable);
idToPaintableDetail.put(pid, componentDetail);
setPid(((Widget) paintable).getElement(), pid);
}
private native void setPid(Element el, String pid)
/*-{
el.tkPid = pid;
}-*/;
/**
* Gets the paintableId for a specific paintable (a.k.a Vaadin Widget).
* <p>
* The paintableId is used in the UIDL to identify a specific widget
* instance, effectively linking the widget with it's server side Component.
* </p>
*
* @param paintable
* the paintable who's id is needed
* @return the id for the given paintable
*/
public String getPid(Paintable paintable) {
return getPid(((Widget) paintable).getElement());
}
/**
* Gets the paintableId using a DOM element - the element should be the main
* element for a paintable otherwise no id will be found. Use
* {@link #getPid(Paintable)} instead whenever possible.
*
* @see #getPid(Paintable)
* @param el
* element of the paintable whose pid is desired
* @return the pid of the element's paintable, if it's a paintable
*/
public native String getPid(Element el)
/*-{
return el.tkPid;
}-*/;
/**
* Gets the main element for the paintable with the given id. The revers of
* {@link #getPid(Element)}.
*
* @param pid
* the pid of the widget whose element is desired
* @return the element for the paintable corresponding to the pid
*/
public Element getElementByPid(String pid) {
return ((Widget) getPaintable(pid)).getElement();
}
/**
* Unregisters the given paintable; always use after removing a paintable.
* Does not actually remove the paintable from the DOM.
*
* @param p
* the paintable to remove
*/
public void unregisterPaintable(Paintable p) {
if (p == null) {
ApplicationConnection.getConsole().error(
"WARN: Trying to unregister null paintable");
return;
}
String id = getPid(p);
idToPaintableDetail.remove(id);
if (p instanceof HasWidgets) {
unregisterChildPaintables((HasWidgets) p);
}
}
/**
* Unregisters a paintable and all it's child paintables recursively. Use
* when after removing a paintable that contains other paintables. Does not
* unregister the given container itself. Does not actually remove the
* paintable from the DOM.
*
* @see #unregisterPaintable(Paintable)
* @param container
*/
public void unregisterChildPaintables(HasWidgets container) {
final Iterator<Widget> it = container.iterator();
while (it.hasNext()) {
final Widget w = it.next();
if (w instanceof Paintable) {
unregisterPaintable((Paintable) w);
} else if (w instanceof HasWidgets) {
unregisterChildPaintables((HasWidgets) w);
}
}
}
/**
* Returns Paintable element by its id
*
* @param id
* Paintable ID
*/
public Paintable getPaintable(String id) {
ComponentDetail componentDetail = idToPaintableDetail.get(id);
if (componentDetail == null) {
return null;
} else {
return componentDetail.getComponent();
}
}
private void addVariableToQueue(String paintableId, String variableName,
String encodedValue, boolean immediate, char type) {
final String id = paintableId + VAR_FIELD_SEPARATOR + variableName
+ VAR_FIELD_SEPARATOR + type;
for (int i = 1; i < pendingVariables.size(); i += 2) {
if ((pendingVariables.get(i)).equals(id)) {
pendingVariables.remove(i - 1);
pendingVariables.remove(i - 1);
break;
}
}
pendingVariables.add(encodedValue);
pendingVariables.add(id);
if (immediate) {
sendPendingVariableChanges();
}
}
/**
* This method sends currently queued variable changes to server. It is
* called when immediate variable update must happen.
*
* To ensure correct order for variable changes (due servers multithreading
* or network), we always wait for active request to be handler before
* sending a new one. If there is an active request, we will put varible
* "burst" to queue that will be purged after current request is handled.
*
*/
@SuppressWarnings("unchecked")
public void sendPendingVariableChanges() {
if (applicationRunning) {
if (hasActiveRequest()) {
// skip empty queues if there are pending bursts to be sent
if (pendingVariables.size() > 0
|| pendingVariableBursts.size() == 0) {
ArrayList<String> burst = (ArrayList<String>) pendingVariables
.clone();
pendingVariableBursts.add(burst);
pendingVariables.clear();
}
} else {
buildAndSendVariableBurst(pendingVariables, false);
}
}
}
/**
* Build the variable burst and send it to server.
*
* When sync is forced, we also force sending of all pending variable-bursts
* at the same time. This is ok as we can assume that DOM will never be
* updated after this.
*
* @param pendingVariables
* Vector of variable changes to send
* @param forceSync
* Should we use synchronous request?
*/
private void buildAndSendVariableBurst(ArrayList<String> pendingVariables,
boolean forceSync) {
final StringBuffer req = new StringBuffer();
while (!pendingVariables.isEmpty()) {
for (int i = 0; i < pendingVariables.size(); i++) {
if (i > 0) {
if (i % 2 == 0) {
req.append(VAR_RECORD_SEPARATOR);
} else {
req.append(VAR_FIELD_SEPARATOR);
}
}
req.append(pendingVariables.get(i));
}
pendingVariables.clear();
// Append all the busts to this synchronous request
if (forceSync && !pendingVariableBursts.isEmpty()) {
pendingVariables = pendingVariableBursts.get(0);
pendingVariableBursts.remove(0);
req.append(VAR_BURST_SEPARATOR);
}
}
makeUidlRequest(req.toString(), false, forceSync, false);
}
/**
* Sends a new value for the given paintables given variable to the server.
* <p>
* The update is actually queued to be sent at a suitable time. If immediate
* is true, the update is sent as soon as possible. If immediate is false,
* the update will be sent along with the next immediate update.
* </p>
*
* @param paintableId
* the id of the paintable that owns the variable
* @param variableName
* the name of the variable
* @param newValue
* the new value to be sent
* @param immediate
* true if the update is to be sent as soon as possible
*/
public void updateVariable(String paintableId, String variableName,
Paintable newValue, boolean immediate) {
String pid = (newValue != null) ? getPid(newValue) : null;
addVariableToQueue(paintableId, variableName, pid, immediate, 'p');
}
/**
* Sends a new value for the given paintables given variable to the server.
* <p>
* The update is actually queued to be sent at a suitable time. If immediate
* is true, the update is sent as soon as possible. If immediate is false,
* the update will be sent along with the next immediate update.
* </p>
*
* @param paintableId
* the id of the paintable that owns the variable
* @param variableName
* the name of the variable
* @param newValue
* the new value to be sent
* @param immediate
* true if the update is to be sent as soon as possible
*/
public void updateVariable(String paintableId, String variableName,
String newValue, boolean immediate) {
addVariableToQueue(paintableId, variableName, newValue, immediate, 's');
}
/**
* Sends a new value for the given paintables given variable to the server.
* <p>
* The update is actually queued to be sent at a suitable time. If immediate
* is true, the update is sent as soon as possible. If immediate is false,
* the update will be sent along with the next immediate update.
* </p>
*
* @param paintableId
* the id of the paintable that owns the variable
* @param variableName
* the name of the variable
* @param newValue
* the new value to be sent
* @param immediate
* true if the update is to be sent as soon as possible
*/
public void updateVariable(String paintableId, String variableName,
int newValue, boolean immediate) {
addVariableToQueue(paintableId, variableName, "" + newValue, immediate,
'i');
}
/**
* Sends a new value for the given paintables given variable to the server.
* <p>
* The update is actually queued to be sent at a suitable time. If immediate
* is true, the update is sent as soon as possible. If immediate is false,
* the update will be sent along with the next immediate update.
* </p>
*
* @param paintableId
* the id of the paintable that owns the variable
* @param variableName
* the name of the variable
* @param newValue
* the new value to be sent
* @param immediate
* true if the update is to be sent as soon as possible
*/
public void updateVariable(String paintableId, String variableName,
long newValue, boolean immediate) {
addVariableToQueue(paintableId, variableName, "" + newValue, immediate,
'l');
}
/**
* Sends a new value for the given paintables given variable to the server.
* <p>
* The update is actually queued to be sent at a suitable time. If immediate
* is true, the update is sent as soon as possible. If immediate is false,
* the update will be sent along with the next immediate update.
* </p>
*
* @param paintableId
* the id of the paintable that owns the variable
* @param variableName
* the name of the variable
* @param newValue
* the new value to be sent
* @param immediate
* true if the update is to be sent as soon as possible
*/
public void updateVariable(String paintableId, String variableName,
float newValue, boolean immediate) {
addVariableToQueue(paintableId, variableName, "" + newValue, immediate,
'f');
}
/**
* Sends a new value for the given paintables given variable to the server.
* <p>
* The update is actually queued to be sent at a suitable time. If immediate
* is true, the update is sent as soon as possible. If immediate is false,
* the update will be sent along with the next immediate update.
* </p>
*
* @param paintableId
* the id of the paintable that owns the variable
* @param variableName
* the name of the variable
* @param newValue
* the new value to be sent
* @param immediate
* true if the update is to be sent as soon as possible
*/
public void updateVariable(String paintableId, String variableName,
double newValue, boolean immediate) {
addVariableToQueue(paintableId, variableName, "" + newValue, immediate,
'd');
}
/**
* Sends a new value for the given paintables given variable to the server.
* <p>
* The update is actually queued to be sent at a suitable time. If immediate
* is true, the update is sent as soon as possible. If immediate is false,
* the update will be sent along with the next immediate update.
* </p>
*
* @param paintableId
* the id of the paintable that owns the variable
* @param variableName
* the name of the variable
* @param newValue
* the new value to be sent
* @param immediate
* true if the update is to be sent as soon as possible
*/
public void updateVariable(String paintableId, String variableName,
boolean newValue, boolean immediate) {
addVariableToQueue(paintableId, variableName, newValue ? "true"
: "false", immediate, 'b');
}
/**
* Sends a new value for the given paintables given variable to the server.
* <p>
* The update is actually queued to be sent at a suitable time. If immediate
* is true, the update is sent as soon as possible. If immediate is false,
* the update will be sent along with the next immediate update.
* </p>
*
* @param paintableId
* the id of the paintable that owns the variable
* @param variableName
* the name of the variable
* @param newValue
* the new value to be sent
* @param immediate
* true if the update is to be sent as soon as possible
*/
public void updateVariable(String paintableId, String variableName,
Map<String, Object> map, boolean immediate) {
final StringBuffer buf = new StringBuffer();
Iterator<String> iterator = map.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
Object value = map.get(key);
char transportType = getTransportType(value);
buf.append(transportType);
buf.append(key);
buf.append(VAR_ARRAYITEM_SEPARATOR);
if (transportType == 'p') {
buf.append(getPid((Paintable) value));
} else {
buf.append(value);
}
if (iterator.hasNext()) {
buf.append(VAR_ARRAYITEM_SEPARATOR);
}
}
addVariableToQueue(paintableId, variableName, buf.toString(),
immediate, 'm');
}
private char getTransportType(Object value) {
if (value instanceof String) {
return 's';
} else if (value instanceof Paintable) {
return 'p';
} else if (value instanceof Boolean) {
return 'b';
} else if (value instanceof Integer) {
return 'i';
} else if (value instanceof Float) {
return 'f';
} else if (value instanceof Double) {
return 'd';
} else if (value instanceof Long) {
return 'l';
} else if (value instanceof Enum) {
return 's'; // transported as string representation
}
return 'u';
}
/**
* Sends a new value for the given paintables given variable to the server.
*
* The update is actually queued to be sent at a suitable time. If immediate
* is true, the update is sent as soon as possible. If immediate is false,
* the update will be sent along with the next immediate update.
*
* A null array is sent as an empty array.
*
* @param paintableId
* the id of the paintable that owns the variable
* @param variableName
* the name of the variable
* @param newValue
* the new value to be sent
* @param immediate
* true if the update is to be sent as soon as possible
*/
public void updateVariable(String paintableId, String variableName,
String[] values, boolean immediate) {
final StringBuffer buf = new StringBuffer();
if (values != null) {
for (int i = 0; i < values.length; i++) {
buf.append(values[i]);
// there will be an extra separator at the end to differentiate
// between an empty array and one containing an empty string
// only
buf.append(VAR_ARRAYITEM_SEPARATOR);
}
}
addVariableToQueue(paintableId, variableName, buf.toString(),
immediate, 'c');
}
/**
* Sends a new value for the given paintables given variable to the server.
*
* The update is actually queued to be sent at a suitable time. If immediate
* is true, the update is sent as soon as possible. If immediate is false,
* the update will be sent along with the next immediate update. </p>
*
* A null array is sent as an empty array.
*
*
* @param paintableId
* the id of the paintable that owns the variable
* @param variableName
* the name of the variable
* @param newValue
* the new value to be sent
* @param immediate
* true if the update is to be sent as soon as possible
*/
public void updateVariable(String paintableId, String variableName,
Object[] values, boolean immediate) {
final StringBuffer buf = new StringBuffer();
if (values != null) {
for (int i = 0; i < values.length; i++) {
if (i > 0) {
buf.append(VAR_ARRAYITEM_SEPARATOR);
}
Object value = values[i];
char transportType = getTransportType(value);
// first char tells the type in array
buf.append(transportType);
if (transportType == 'p') {
buf.append(getPid((Paintable) value));
} else {
buf.append(value);
}
}
}
addVariableToQueue(paintableId, variableName, buf.toString(),
immediate, 'a');
}
/**
* Update generic component features.
*
* <h2>Selecting correct implementation</h2>
*
* <p>
* The implementation of a component depends on many properties, including
* styles, component features, etc. Sometimes the user changes those
* properties after the component has been created. Calling this method in
* the beginning of your updateFromUIDL -method automatically replaces your
* component with more appropriate if the requested implementation changes.
* </p>
*
* <h2>Caption, icon, error messages and description</h2>
*
* <p>
* Component can delegate management of caption, icon, error messages and
* description to parent layout. This is optional an should be decided by
* component author
* </p>
*
* <h2>Component visibility and disabling</h2>
*
* This method will manage component visibility automatically and if
* component is an instanceof FocusWidget, also handle component disabling
* when needed.
*
* @param component
* Widget to be updated, expected to implement an instance of
* Paintable
* @param uidl
* UIDL to be painted
* @param manageCaption
* True if you want to delegate caption, icon, description and
* error message management to parent.
*
* @return Returns true iff no further painting is needed by caller
*/
public boolean updateComponent(Widget component, UIDL uidl,
boolean manageCaption) {
String pid = getPid(component.getElement());
if (pid == null) {
getConsole().error(
"Trying to update an unregistered component: "
+ Util.getSimpleName(component));
return true;
}
ComponentDetail componentDetail = idToPaintableDetail.get(pid);
if (componentDetail == null) {
getConsole().error(
"ComponentDetail not found for "
+ Util.getSimpleName(component) + " with PID "
+ pid + ". This should not happen.");
return true;
}
// If the server request that a cached instance should be used, do
// nothing
if (uidl.getBooleanAttribute("cached")) {
return true;
}
// register the listened events by the server-side to the event-handler
// of the component
componentDetail.registerEventListenersFromUIDL(uidl);
// Visibility
boolean visible = !uidl.getBooleanAttribute("invisible");
boolean wasVisible = component.isVisible();
component.setVisible(visible);
if (wasVisible != visible) {
// Changed invisibile <-> visible
if (wasVisible && manageCaption) {
// Must hide caption when component is hidden
final Container parent = Util.getLayout(component);
if (parent != null) {
parent.updateCaption((Paintable) component, uidl);
}
}
}
if (configuration.useDebugIdInDOM() && uidl.getId().startsWith("PID_S")) {
DOM.setElementProperty(component.getElement(), "id", uidl.getId()
.substring(5));
}
if (!visible) {
// component is invisible, delete old size to notify parent, if
// later make visible
componentDetail.setOffsetSize(null);
return true;
}
// Switch to correct implementation if needed
if (!widgetSet.isCorrectImplementation(component, uidl, configuration)) {
final Container parent = Util.getLayout(component);
if (parent != null) {
final Widget w = (Widget) widgetSet.createWidget(uidl,
configuration);
parent.replaceChildComponent(component, w);
unregisterPaintable((Paintable) component);
registerPaintable(uidl.getId(), (Paintable) w);
((Paintable) w).updateFromUIDL(uidl, this);
return true;
}
}
boolean enabled = !uidl.getBooleanAttribute("disabled");
if (component instanceof FocusWidget) {
FocusWidget fw = (FocusWidget) component;
if (uidl.hasAttribute("tabindex")) {
fw.setTabIndex(uidl.getIntAttribute("tabindex"));
}
// Disabled state may affect tabindex
fw.setEnabled(enabled);
}
StringBuffer styleBuf = new StringBuffer();
final String primaryName = component.getStylePrimaryName();
styleBuf.append(primaryName);
// first disabling and read-only status
if (!enabled) {
styleBuf.append(" ");
styleBuf.append("v-disabled");
}
if (uidl.getBooleanAttribute("readonly")) {
styleBuf.append(" ");
styleBuf.append("v-readonly");
}
// add additional styles as css classes, prefixed with component default
// stylename
if (uidl.hasAttribute("style")) {
final String[] styles = uidl.getStringAttribute("style").split(" ");
for (int i = 0; i < styles.length; i++) {
styleBuf.append(" ");
styleBuf.append(primaryName);
styleBuf.append("-");
styleBuf.append(styles[i]);
styleBuf.append(" ");
styleBuf.append(styles[i]);
}
}
// add modified classname to Fields
if (uidl.hasAttribute("modified") && component instanceof Field) {
styleBuf.append(" ");
styleBuf.append(MODIFIED_CLASSNAME);
}
TooltipInfo tooltipInfo = componentDetail.getTooltipInfo(null);
// Update tooltip
if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)) {
tooltipInfo
.setTitle(uidl.getStringAttribute(ATTRIBUTE_DESCRIPTION));
} else {
tooltipInfo.setTitle(null);
}
// add error classname to components w/ error
if (uidl.hasAttribute(ATTRIBUTE_ERROR)) {
tooltipInfo.setErrorUidl(uidl.getErrors());
styleBuf.append(" ");
styleBuf.append(primaryName);
styleBuf.append(ERROR_CLASSNAME_EXT);
} else {
tooltipInfo.setErrorUidl(null);
}
// add required style to required components
if (uidl.hasAttribute("required")) {
styleBuf.append(" ");
styleBuf.append(primaryName);
styleBuf.append(REQUIRED_CLASSNAME_EXT);
}
// Styles + disabled & readonly
component.setStyleName(styleBuf.toString());
// Set captions
if (manageCaption) {
final Container parent = Util.getLayout(component);
if (parent != null) {
parent.updateCaption((Paintable) component, uidl);
}
}
/*
* updateComponentSize need to be after caption update so caption can be
* taken into account
*/
updateComponentSize(componentDetail, uidl);
return false;
}
private void updateComponentSize(ComponentDetail cd, UIDL uidl) {
String w = uidl.hasAttribute("width") ? uidl
.getStringAttribute("width") : "";
String h = uidl.hasAttribute("height") ? uidl
.getStringAttribute("height") : "";
float relativeWidth = Util.parseRelativeSize(w);
float relativeHeight = Util.parseRelativeSize(h);
// First update maps so they are correct in the setHeight/setWidth calls
if (relativeHeight >= 0.0 || relativeWidth >= 0.0) {
// One or both is relative
FloatSize relativeSize = new FloatSize(relativeWidth,
relativeHeight);
if (cd.getRelativeSize() == null && cd.getOffsetSize() != null) {
// The component has changed from absolute size to relative size
relativeSizeChanges.add(cd.getComponent());
}
cd.setRelativeSize(relativeSize);
} else if (relativeHeight < 0.0 && relativeWidth < 0.0) {
if (cd.getRelativeSize() != null) {
// The component has changed from relative size to absolute size
relativeSizeChanges.add(cd.getComponent());
}
cd.setRelativeSize(null);
}
Widget component = (Widget) cd.getComponent();
// Set absolute sizes
if (relativeHeight < 0.0) {
component.setHeight(h);
}
if (relativeWidth < 0.0) {
component.setWidth(w);
}
// Set relative sizes
if (relativeHeight >= 0.0 || relativeWidth >= 0.0) {
// One or both is relative
handleComponentRelativeSize(cd);
}
}
/**
* Traverses recursively child widgets until ContainerResizedListener child
* widget is found. They will delegate it further if needed.
*
* @param container
*/
private boolean runningLayout = false;
/**
* Causes a re-calculation/re-layout of all paintables in a container.
*
* @param container
*/
public void runDescendentsLayout(HasWidgets container) {
if (runningLayout) {
return;
}
runningLayout = true;
internalRunDescendentsLayout(container);
runningLayout = false;
}
/**
* This will cause re-layouting of all components. Mainly used for
* development. Published to JavaScript.
*/
public void forceLayout() {
Set<Paintable> set = new HashSet<Paintable>();
for (ComponentDetail cd : idToPaintableDetail.values()) {
set.add(cd.getComponent());
}
Util.componentSizeUpdated(set);
}
private void internalRunDescendentsLayout(HasWidgets container) {
// getConsole().log(
// "runDescendentsLayout(" + Util.getSimpleName(container) + ")");
final Iterator<Widget> childWidgets = container.iterator();
while (childWidgets.hasNext()) {
final Widget child = childWidgets.next();
if (child instanceof Paintable) {
if (handleComponentRelativeSize(child)) {
/*
* Only need to propagate event if "child" has a relative
* size
*/
if (child instanceof ContainerResizedListener) {
((ContainerResizedListener) child).iLayout();
}
if (child instanceof HasWidgets) {
final HasWidgets childContainer = (HasWidgets) child;
internalRunDescendentsLayout(childContainer);
}
}
} else if (child instanceof HasWidgets) {
// propagate over non Paintable HasWidgets
internalRunDescendentsLayout((HasWidgets) child);
}
}
}
/**
* Converts relative sizes into pixel sizes.
*
* @param child
* @return true if the child has a relative size
*/
private boolean handleComponentRelativeSize(ComponentDetail cd) {
if (cd == null) {
return false;
}
boolean debugSizes = false;
FloatSize relativeSize = cd.getRelativeSize();
if (relativeSize == null) {
return false;
}
Widget widget = (Widget) cd.getComponent();
boolean horizontalScrollBar = false;
boolean verticalScrollBar = false;
Container parent = Util.getLayout(widget);
RenderSpace renderSpace;
// Parent-less components (like sub-windows) are relative to browser
// window.
if (parent == null) {
renderSpace = new RenderSpace(Window.getClientWidth(), Window
.getClientHeight());
} else {
renderSpace = parent.getAllocatedSpace(widget);
}
if (relativeSize.getHeight() >= 0) {
if (renderSpace != null) {
if (renderSpace.getScrollbarSize() > 0) {
if (relativeSize.getWidth() > 100) {
horizontalScrollBar = true;
} else if (relativeSize.getWidth() < 0
&& renderSpace.getWidth() > 0) {
int offsetWidth = widget.getOffsetWidth();
int width = renderSpace.getWidth();
if (offsetWidth > width) {
horizontalScrollBar = true;
}
}
}
int height = renderSpace.getHeight();
if (horizontalScrollBar) {
height -= renderSpace.getScrollbarSize();
}
if (validatingLayouts && height <= 0) {
zeroHeightComponents.add(cd.getComponent());
}
height = (int) (height * relativeSize.getHeight() / 100.0);
if (height < 0) {
height = 0;
}
if (debugSizes) {
getConsole()
.log(
"Widget "
+ Util.getSimpleName(widget)
+ "/"
+ getPid(widget.getElement())
+ " relative height "
+ relativeSize.getHeight()
+ "% of "
+ renderSpace.getHeight()
+ "px (reported by "
+ Util.getSimpleName(parent)
+ "/"
+ (parent == null ? "?" : parent
.hashCode()) + ") : "
+ height + "px");
}
widget.setHeight(height + "px");
} else {
widget.setHeight(relativeSize.getHeight() + "%");
ApplicationConnection.getConsole().error(
Util.getLayout(widget).getClass().getName()
+ " did not produce allocatedSpace for "
+ widget.getClass().getName());
}
}
if (relativeSize.getWidth() >= 0) {
if (renderSpace != null) {
int width = renderSpace.getWidth();
if (renderSpace.getScrollbarSize() > 0) {
if (relativeSize.getHeight() > 100) {
verticalScrollBar = true;
} else if (relativeSize.getHeight() < 0
&& renderSpace.getHeight() > 0
&& widget.getOffsetHeight() > renderSpace
.getHeight()) {
verticalScrollBar = true;
}
}
if (verticalScrollBar) {
width -= renderSpace.getScrollbarSize();
}
if (validatingLayouts && width <= 0) {
zeroWidthComponents.add(cd.getComponent());
}
width = (int) (width * relativeSize.getWidth() / 100.0);
if (width < 0) {
width = 0;
}
if (debugSizes) {
getConsole().log(
"Widget " + Util.getSimpleName(widget) + "/"
+ getPid(widget.getElement())
+ " relative width "
+ relativeSize.getWidth() + "% of "
+ renderSpace.getWidth()
+ "px (reported by "
+ Util.getSimpleName(parent) + "/"
+ (parent == null ? "?" : getPid(parent))
+ ") : " + width + "px");
}
widget.setWidth(width + "px");
} else {
widget.setWidth(relativeSize.getWidth() + "%");
ApplicationConnection.getConsole().error(
Util.getLayout(widget).getClass().getName()
+ " did not produce allocatedSpace for "
+ widget.getClass().getName());
}
}
return true;
}
/**
* Converts relative sizes into pixel sizes.
*
* @param child
* @return true if the child has a relative size
*/
public boolean handleComponentRelativeSize(Widget child) {
return handleComponentRelativeSize(idToPaintableDetail.get(getPid(child
.getElement())));
}
/**
* Gets the specified Paintables relative size (percent).
*
* @param widget
* the paintable whose size is needed
* @return the the size if the paintable is relatively sized, -1 otherwise
*/
public FloatSize getRelativeSize(Widget widget) {
return idToPaintableDetail.get(getPid(widget.getElement()))
.getRelativeSize();
}
/**
* Get either existing or new Paintable for given UIDL.
*
* If corresponding Paintable has been previously painted, return it.
* Otherwise create and register a new Paintable from UIDL. Caller must
* update the returned Paintable from UIDL after it has been connected to
* parent.
*
* @param uidl
* UIDL to create Paintable from.
* @return Either existing or new Paintable corresponding to UIDL.
*/
public Paintable getPaintable(UIDL uidl) {
final String id = uidl.getId();
Paintable w = getPaintable(id);
if (w != null) {
return w;
} else {
w = widgetSet.createWidget(uidl, configuration);
registerPaintable(id, w);
return w;
}
}
/**
* Returns a Paintable element by its root element
*
* @param element
* Root element of the paintable
*/
public Paintable getPaintable(Element element) {
return getPaintable(getPid(element));
}
/**
* Gets a recource that has been pre-loaded via UIDL, such as custom
* layouts.
*
* @param name
* identifier of the resource to get
* @return the resource
*/
public String getResource(String name) {
return resourcesMap.get(name);
}
/**
* Singleton method to get instance of app's context menu.
*
* @return VContextMenu object
*/
public VContextMenu getContextMenu() {
if (contextMenu == null) {
contextMenu = new VContextMenu();
DOM.setElementProperty(contextMenu.getElement(), "id",
"PID_VAADIN_CM");
}
return contextMenu;
}
/**
* Translates custom protocols in UIDL URI's to be recognizable by browser.
* All uri's from UIDL should be routed via this method before giving them
* to browser due URI's in UIDL may contain custom protocols like theme://.
*
* @param uidlUri
* Vaadin URI from uidl
* @return translated URI ready for browser
*/
public String translateVaadinUri(String uidlUri) {
if (uidlUri == null) {
return null;
}
if (uidlUri.startsWith("theme://")) {
final String themeUri = configuration.getThemeUri();
if (themeUri == null) {
console
.error("Theme not set: ThemeResource will not be found. ("
+ uidlUri + ")");
}
uidlUri = themeUri + uidlUri.substring(7);
}
return uidlUri;
}
/**
* Gets the URI for the current theme. Can be used to reference theme
* resources.
*
* @return URI to the current theme
*/
public String getThemeUri() {
return configuration.getThemeUri();
}
/**
* Listens for Notification hide event, and redirects. Used for system
* messages, such as session expired.
*
*/
private class NotificationRedirect implements VNotification.EventListener {
String url;
NotificationRedirect(String url) {
this.url = url;
}
public void notificationHidden(HideEvent event) {
redirect(url);
}
}
/* Extended title handling */
/**
* Data showed in tooltips are stored centrilized as it may be needed in
* varios place: caption, layouts, and in owner components themselves.
*
* Updating TooltipInfo is done in updateComponent method.
*
*/
public TooltipInfo getTooltipTitleInfo(Paintable titleOwner, Object key) {
if (null == titleOwner) {
return null;
}
ComponentDetail cd = idToPaintableDetail.get(getPid(titleOwner));
if (null != cd) {
return cd.getTooltipInfo(key);
} else {
return null;
}
}
private final VTooltip tooltip = new VTooltip(this);
/**
* Component may want to delegate Tooltip handling to client. Layouts add
* Tooltip (description, errors) to caption, but some components may want
* them to appear one other elements too.
*
* Events wanted by this handler are same as in Tooltip.TOOLTIP_EVENTS
*
* @param event
* @param owner
*/
public void handleTooltipEvent(Event event, Paintable owner) {
tooltip.handleTooltipEvent(event, owner, null);
}
/**
* Component may want to delegate Tooltip handling to client. Layouts add
* Tooltip (description, errors) to caption, but some components may want
* them to appear one other elements too.
*
* Events wanted by this handler are same as in Tooltip.TOOLTIP_EVENTS
*
* @param event
* @param owner
* @param key
* the key for tooltip if this is "additional" tooltip, null for
* components "main tooltip"
*/
public void handleTooltipEvent(Event event, Paintable owner, Object key) {
tooltip.handleTooltipEvent(event, owner, key);
}
/**
* Adds PNG-fix conditionally (only for IE6) to the specified IMG -element.
*
* @param el
* the IMG element to fix
*/
public void addPngFix(Element el) {
BrowserInfo b = BrowserInfo.get();
if (b.isIE6()) {
Util.addPngFix(el, getThemeUri() + "/../runo/common/img/blank.gif");
}
}
/*
* Helper to run layout functions triggered by child components with a
* decent interval.
*/
private final Timer layoutTimer = new Timer() {
private boolean isPending = false;
@Override
public void schedule(int delayMillis) {
if (!isPending) {
super.schedule(delayMillis);
isPending = true;
}
}
@Override
public void run() {
getConsole().log(
"Running re-layout of " + view.getClass().getName());
runDescendentsLayout(view);
isPending = false;
}
};
/**
* Components can call this function to run all layout functions. This is
* usually done, when component knows that its size has changed.
*/
public void requestLayoutPhase() {
layoutTimer.schedule(500);
}
private String windowName = null;
/**
* Reset the name of the current browser-window. This should reflect the
* window-name used in the server, but might be different from the
* window-object target-name on client.
*
* @param stringAttribute
* New name for the window.
*/
public void setWindowName(String newName) {
windowName = newName;
}
/**
* Use to notify that the given component's caption has changed; layouts may
* have to be recalculated.
*
* @param component
* the Paintable whose caption has changed
*/
public void captionSizeUpdated(Paintable component) {
componentCaptionSizeChanges.add(component);
}
/**
* Requests an analyze of layouts, to find inconsistensies. Exclusively used
* for debugging during develpoment.
*/
public void analyzeLayouts() {
makeUidlRequest("", true, false, true);
}
/**
* Gets the main view, a.k.a top-level window.
*
* @return the main view
*/
public VView getView() {
return view;
}
/**
* If component has several tooltips in addition to the one provided by
* {@link com.vaadin.ui.AbstractComponent}, component can register them with
* this method.
* <p>
* Component must also pipe events to
* {@link #handleTooltipEvent(Event, Paintable, Object)} method.
* <p>
* This method can also be used to deregister tooltips by using null as
* tooltip
*
* @param paintable
* Paintable "owning" this tooltip
* @param key
* key assosiated with given tooltip. Can be any object. For
* example a related dom element. Same key must be given for
* {@link #handleTooltipEvent(Event, Paintable, Object)} method.
*
* @param tooltip
* the TooltipInfo object containing details shown in tooltip,
* null if deregistering tooltip
*/
public void registerTooltip(Paintable paintable, Object key,
TooltipInfo tooltip) {
ComponentDetail componentDetail = idToPaintableDetail
.get(getPid(paintable));
componentDetail.putAdditionalTooltip(key, tooltip);
}
/**
* Gets the {@link ApplicationConfiguration} for the current application.
*
* @see ApplicationConfiguration
* @return the configuration for this application
*/
public ApplicationConfiguration getConfiguration() {
return configuration;
}
/**
* Checks if there is a registered server side listener for the event. The
* list of events which has server side listeners is updated automatically
* before the component is updated so the value is correct if called from
* updatedFromUIDL.
*
* @param eventIdentifier
* The identifier for the event
* @return true if at least one listener has been registered on server side
* for the event identified by eventIdentifier.
*/
public boolean hasEventListeners(Paintable paintable, String eventIdentifier) {
return idToPaintableDetail.get(getPid(paintable)).hasEventListeners(
eventIdentifier);
}
}
| [
"[email protected]"
]
| |
0c6bd4304515c6adf5d24341cdf6211539691671 | e115443bd241b513ded37b166ca2f8d17eb79882 | /src/test/java/com/rbmhtechnology/example/japi/dbreplica/repository/AssetRepository.java | 4fd39b7c486284382126aabfb5ea2abeea302ad9 | [
"Apache-2.0"
]
| permissive | jrudolph/eventuate | bc48c0f1efd34c879fd4ba00ea103354c330a5df | c95ed9c3aee8f924e28b253c16bc2cef8fe653e7 | refs/heads/master | 2021-01-15T08:58:38.622940 | 2016-03-08T10:39:12 | 2016-03-08T10:39:12 | 53,586,240 | 0 | 0 | null | 2016-03-10T13:25:05 | 2016-03-10T13:25:04 | Scala | UTF-8 | Java | false | false | 2,178 | java | /*
* Copyright (C) 2015 - 2016 Red Bull Media House GmbH <http://www.redbullmediahouse.com> - 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.
* 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.rbmhtechnology.example.japi.dbreplica.repository;
import com.rbmhtechnology.example.japi.dbreplica.domain.Asset;
import javaslang.control.Option;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import static com.rbmhtechnology.example.japi.dbreplica.util.CollectionUtil.headOption;
@Repository
public class AssetRepository {
@Autowired
private JdbcTemplate template;
private final RowMapper<Asset> assetMapper = (rs, rowNum) ->
new Asset(
rs.getString("id"),
rs.getString("subject"),
rs.getString("content")
);
public Collection<Asset> findAll() {
return template.query("SELECT * FROM Asset ORDER BY id ASC", assetMapper);
}
public Option<Asset> find(final String assetId) {
return headOption(template.query("SELECT * FROM Asset WHERE id = ?", assetMapper, assetId));
}
public int insert(final Asset asset) {
return template.update("INSERT INTO Asset(id, subject, content) VALUES (?,?,?)", asset.getId(), asset.getSubject(), asset.getContent());
}
public int update(final Asset asset) {
return template.update("UPDATE Asset SET subject = ?, content = ? WHERE id = ?", asset.getSubject(), asset.getContent(), asset.getId());
}
}
| [
"[email protected]"
]
| |
9d248fed5e429e877d82acab83901b97e4bcf3e4 | bad06c5495a7ccb812e0592184efb3e35e417fda | /Features/dockerform-yocordapp/workflows/src/main/java/net/corda/samples/dockerform/flows/YoFlowResponder.java | 11c02a54aa9a5b133200b99a0d7d8e8140554669 | [
"Apache-2.0"
]
| permissive | Vs-karma/AmexHack | 66c5d0fe814f0cba71080c1df201bacf6c5f225d | 67919c82e4ae4cd56b366a90f9b9791e75171bc6 | refs/heads/master | 2023-08-15T18:04:55.819721 | 2021-10-14T08:50:43 | 2021-10-14T08:50:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 623 | java | package net.corda.samples.dockerform.flows;
import co.paralleluniverse.fibers.Suspendable;
import net.corda.core.flows.*;
import net.corda.core.transactions.SignedTransaction;
@InitiatedBy(YoFlow.class)
public class YoFlowResponder extends FlowLogic<SignedTransaction> {
private final FlowSession counterpartySession;
public YoFlowResponder(FlowSession counterpartySession) {
this.counterpartySession = counterpartySession;
}
@Suspendable
@Override
public SignedTransaction call() throws FlowException {
return subFlow(new ReceiveFinalityFlow(this.counterpartySession));
}
}
| [
"[email protected]"
]
| |
8b17eafd3f0f20205d3dec153da22b7b09249690 | 004c81fd777abe1f7a0447cf8f618cc1a7ad7d17 | /src/main/java/com/stefanini/YuGiOh/YuGiOhAPI/Services/UserTypeServices.java | b1fc8c2d04186b7d58762c3f603d2a1c060c1b0f | []
| no_license | RMRodrigues-Stefanini/Api_YuGiOh_V2 | 9e0e43a125e0255336112c1179a49b08e56bf2cb | 2075917cbe9cfe8038840d469a02d29e8172405b | refs/heads/master | 2023-07-11T00:38:20.289295 | 2021-08-03T19:22:32 | 2021-08-03T19:22:32 | 392,335,150 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,259 | java | package com.stefanini.YuGiOh.YuGiOhAPI.Services;
import com.stefanini.YuGiOh.YuGiOhAPI.Entities.UserType;
import com.stefanini.YuGiOh.YuGiOhAPI.Repository.UserTypeRepository;
import com.sun.istack.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class UserTypeServices {
@Autowired
UserTypeRepository userTypeRepository;
public List<UserType> findAll() {return userTypeRepository.findAll();}
public Optional<UserType> findById(Long id){ return userTypeRepository.findById (id);}
public UserType save(UserType userType) { return (UserType) userTypeRepository.save(userType);}
public UserType update (@NotNull UserType userType){
checkId((long) userType.getIdUT());
return (UserType) userTypeRepository.save(userType);
}
public void deleteById(Long id){ userTypeRepository.deleteById(id);}
public void delete (UserType userType){
userTypeRepository.delete(userType);
}
private UserType checkId(Long id){
return (UserType) userTypeRepository.findById(id).
orElseThrow(()->new RuntimeException("Id not found"));
}
}
| [
"[email protected]"
]
| |
dd488287134d489b0f9d2366b7da469e589885d3 | 980addaf3645ea61529c60a7a3e2da20e30ab0d8 | /oauth2-server/src/main/java/com/suimi/security/oauth2server/web/WebController.java | 9cac7ab86b906686f52e42d1ee244bb6b7221677 | []
| no_license | suimi/security-demo | e9c7db825cf137f0830551a7b4d2705c38c64fa2 | 5869e2952807516c155ef0b5f6e50a915a1634de | refs/heads/master | 2021-08-22T03:57:15.257101 | 2017-11-29T06:59:30 | 2017-11-29T06:59:30 | 109,667,577 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 448 | java | /*
* Copyright (c) 2013-2015, suimi
*/
package com.suimi.security.oauth2server.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
/**
* @author suimi
* @date 2017-10-23
* @deprecated see {@link com.suimi.security.oauth2server.mvc.WebPageConfig}
*/
@Deprecated
public class WebController {
@GetMapping("/login")
public String login() {
return "login";
}
}
| [
"[email protected]"
]
| |
f5edae7a978a9ff7a618853497f9cdfbe01c5469 | 1a1b20c66454522c5367693aaec32ef95124b750 | /Gnss/Release/GNSS/src/com/file/Move.java | aa1c5a7dc34015140696d8d027c41c4c26a75da4 | []
| no_license | HuO50/GNSS | 54c0660c39e2607939781a3eb4b28d14dca3d7c1 | b58e4107fae4e1f1ff0e7ec3ec4a4b6cef87cdee | refs/heads/master | 2020-05-26T00:39:44.965553 | 2018-03-18T13:49:56 | 2018-03-18T13:49:56 | 62,221,094 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 949 | java | package com.file;
/**
* Created by Harry on 2016/4/25.
* 用于移动文件
*/
import org.apache.commons.io.*;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
public class Move {
public static void moveFile(String from,String to){
//将文件夹下的所有文件,移动到另一个文件夹中
File from_file = new File(from);
String[] str_array = {"txt"};
Iterator it = FileUtils.iterateFiles(from_file,str_array,true);
while (it.hasNext()){
try {
FileUtils.moveFileToDirectory((File) it.next(),new File(to),true);
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void copyFile(String from,String to) throws IOException {
//拷贝一个文件夹下的所有文件到指定文件夹下
FileUtils.copyDirectory(new File(from),new File(to));
}
}
| [
"[email protected]"
]
| |
1568d978d7ae2ce999ac74a8d61b87ac5bbbff81 | d4a1bb3694be020cdaa9776427ca8bb2a9afec8e | /app/src/main/java/com/example/WeatherReport/Entity/CurrentConditions/Direction.java | bcc78a4198ef5624e12a17aae72f35d0f863579d | []
| no_license | just-a-tractor/WeatherReport | 126039de9fca87ae7b249cc188a4ea8fce03ac61 | eb318236e6fa507af1c958c372265675b522e103 | refs/heads/master | 2022-12-10T05:57:58.227346 | 2020-08-31T10:09:45 | 2020-08-31T10:09:45 | 288,445,867 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 175 | java |
package com.example.WeatherReport.Entity.CurrentConditions;
public class Direction {
public Integer Degrees;
public String Localized;
public String English;
}
| [
"[email protected]"
]
| |
6ec81f2dacc0fc5163639446f8b6847df50b2c2c | 9ec7afbaf4c909efdf9acdef630f05e8b92d9722 | /src/main/java/ku/message/dto/SignupDto.java | 027c59e3a30c1bc155bfb2b0e060b064a80addd2 | []
| no_license | th-bunratta/secure-message-product-error-log | 3fb2495ffb0c9576da516c5f61b9b553d338cd78 | 4df8290a2a405a320f4e838ba60f2b7602fd5bf1 | refs/heads/main | 2023-04-27T10:27:20.837302 | 2021-05-07T17:02:12 | 2021-05-07T17:02:12 | 365,301,488 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,553 | java | package ku.message.dto;
import ku.message.validation.ValidPassword;
import lombok.Data;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
@Data
public class SignupDto {
@NotBlank
@Size(min=4, message = "Username must have at least 4 characters")
private String username;
@NotBlank
@Size(min=12, max=128)
@ValidPassword
private String password;
@NotBlank(message = "First name is required")
@Pattern(regexp = "^[a-zA-Z]+$",
message = "First name can only contain letters")
private String firstName;
@NotBlank
private String lastName;
@Email
@NotBlank
private String email;
private String role;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
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 getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
}
| [
"[email protected]"
]
| |
259c3f623f7cc4e646b736756d3f139e6c69198a | 2f5dd9ee294b7a7d5884f0a0dd6f2d88c6ff7ebd | /EasyMission-ejb/src/main/java/tn/easymission/entities/Feedback.java | 51ba05814ee0a2001ec06c637e1f160e766221c6 | []
| no_license | bettaiebahmed/EasyMission | ea686dcd3717127fda0784794868f7754ce350cc | 8dd9d51d47ad9c4a18700416a6c57477dfdb9157 | refs/heads/master | 2021-01-18T12:47:58.359744 | 2017-03-29T19:02:26 | 2017-03-29T19:02:26 | 84,332,099 | 0 | 1 | null | 2017-03-29T19:02:27 | 2017-03-08T14:55:25 | JavaScript | UTF-8 | Java | false | false | 1,339 | java | package tn.easymission.entities;
import java.io.Serializable;
import java.lang.String;
import javax.persistence.*;
/**
* Entity implementation class for Entity: Commentaire
*
*/
@Entity
public class Feedback implements Serializable {
private FeedBackPk idFeedBack;
private int rate;
private String description;
private User userLeft,userRight;
private static final long serialVersionUID = 1L;
public Feedback() {
super();
}
@EmbeddedId
public FeedBackPk getIdFeedBack() {
return idFeedBack;
}
public void setIdFeedBack(FeedBackPk idFeedBack) {
this.idFeedBack = idFeedBack;
}
public int getRate() {
return rate;
}
public void setRate(int rate) {
this.rate = rate;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@ManyToOne
@JoinColumn(name="idUserleft",referencedColumnName="idUser",insertable=false,updatable=false)
public User getUserLeft() {
return userLeft;
}
public void setUserLeft(User userLeft) {
this.userLeft = userLeft;
}
@ManyToOne
@JoinColumn(name="idUserRight",referencedColumnName="idUser",insertable=false,updatable=false)
public User getUserRight() {
return userRight;
}
public void setUserRight(User userRight) {
this.userRight = userRight;
}
}
| [
"[email protected]"
]
| |
b34425c01cf43ab9ac35601ff12ec722c67dea4d | 434eeace9a2d4d19d8946499ad92331bca2e7c5f | /descent.ui.metrics/src/descent/ui/metrics/calculators/LinesOfCodeCalculator.java | d794249e7a3404285f3f07fef97583844fedafd4 | []
| no_license | jacob-carlborg/descent | bc9632d774c5d4b6b36ace5b63ab213e5040c6b6 | 4a78f1e441aa89632c4a7329fe894f9ed506b4ad | refs/heads/master | 2021-03-12T23:27:42.290232 | 2011-08-26T17:42:07 | 2011-08-26T17:42:07 | 2,454,693 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,207 | java | package descent.ui.metrics.calculators;
import descent.core.dom.ConstructorDeclaration;
import descent.core.dom.FunctionDeclaration;
public final class LinesOfCodeCalculator extends AbstractASTVisitorCalculator {
public static final String METHOD_METRIC_ID = CalculatorUtils.createMethodMetricId(LinesOfCodeCalculator.class);
private static final String[] METRIC_IDS = new String[]{METHOD_METRIC_ID};
public String[] getMetricIds() {
return LinesOfCodeCalculator.METRIC_IDS;
}
public boolean visit(FunctionDeclaration arg0) {
super.visit(arg0);
if ((arg0.getModifiers()) == 0) {
noteMethodValue(LinesOfCodeCalculator.METHOD_METRIC_ID, getEndLineNumber(arg0) - getStartLineNumber(arg0) + 1);
return super.visit(arg0);
} else {
return false;
}
}
public boolean visit(ConstructorDeclaration arg0) {
super.visit(arg0);
if ((arg0.getModifiers()) == 0) {
noteMethodValue(LinesOfCodeCalculator.METHOD_METRIC_ID, getEndLineNumber(arg0) - getStartLineNumber(arg0) + 1);
return super.visit(arg0);
} else {
return false;
}
}
}
| [
"asterite@6538119e-2221-0410-ba12-9a5a7e5062c7"
]
| asterite@6538119e-2221-0410-ba12-9a5a7e5062c7 |
628450d4becf11c02e1f4ebdb46869c7b6f18c13 | 3f9ed110b81b2cbf4bdfac5a9b445192726d038f | /designpatterns/src/main/java/designpatterns/chainofresponsibility/BancoA.java | d3b158c8167d92c99da8af65f75808ce3bc77baf | []
| no_license | MarcianoAnunciacao/gofdesignpatterns | d814e8f9cc24d1af4940c1bc3fbcc14e5a12c132 | c97127d73067a6f48910ea5708f92097fef99914 | refs/heads/master | 2020-03-19T12:46:13.280185 | 2018-06-13T01:33:06 | 2018-06-13T01:33:06 | 136,539,223 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 251 | java | package designpatterns.chainofresponsibility;
public class BancoA extends BancoChain {
public BancoA() {
super(IdBanco.BANCOA);
}
@Override
protected void efetuaPagamento() {
System.out.println("Banco A efetuando pagamento: \n");
}
}
| [
"[email protected]"
]
| |
312d987fe731bf2c1bf29906c38148dc419b0cca | 92573a343c441ff5552b8a8ee2751f83a8f8fc73 | /PAFR/src/domain/WagonBuilderFactory.java | 3f15dcef605e65c66ac92f3daab42f9676fb2f58 | []
| no_license | almar456/PAFR | 00f3c945a208cf7b0c06594ab2fc5ac5d1c72839 | eb4da32fc75fafbee442d9aa3c8c7a4825bb7a2c | refs/heads/master | 2020-09-20T07:09:22.183298 | 2020-04-07T12:49:33 | 2020-04-07T12:49:33 | 224,407,715 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 307 | java | package domain;
public class WagonBuilderFactory {
public String type;
public WagonBuilderFactoryInterface build(String type) {
if (type == "Passenger") {
return new PassengerWagonBuilder(type);
}else if(type == "Freight") {
return new FreightWagonBuilder(type);
} else { return null;}
}
}
| [
"[email protected]"
]
| |
5d258bf17e299da42205435d65424a4a0698354f | 41a34205ee8fe009bb1b6ecf068ee5b1afb42523 | /cardinal-components-item/src/main/java/dev/onyxstudios/cca/internal/item/ItemCaller.java | c5da88019dfd678e9fa2a88d6a85213571204080 | [
"MIT"
]
| permissive | xanderstuff/Cardinal-Components-API | d67502963fd35e110059ed4ac3c3d6af0099761c | 2d23311a59bef0fc0f33d8aa6b7915a2e4463bf1 | refs/heads/master | 2023-08-17T04:04:02.873434 | 2021-09-14T22:02:15 | 2021-09-14T22:02:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,393 | java | /*
* Cardinal-Components-API
* Copyright (C) 2019-2021 OnyxStudios
*
* 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 dev.onyxstudios.cca.internal.item;
import dev.onyxstudios.cca.api.v3.component.ComponentContainer;
import net.minecraft.item.ItemStack;
public interface ItemCaller {
ComponentContainer cardinal_createComponents(ItemStack stack);
}
| [
"[email protected]"
]
| |
fc847a9f38534136f0d9045a2fd7ea2c7938a9c4 | 62ba6c10e0110512e3ec918e871c499b482655c3 | /leetCode690.java | 4ccc6610a3aacbb40e795a8153a2d1463c12244e | []
| no_license | Midalas/leetCode | a31dff284adf9bbb8085fe354626001f4041b5a6 | 1724b2fedc150db5b49f6adb49af22aef24a66fb | refs/heads/master | 2021-08-16T05:26:15.586454 | 2018-12-28T07:48:34 | 2018-12-28T07:48:34 | 135,102,667 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,473 | java |
package leetCode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class leetCode690 {
public static void main(String[] args) throws Exception {
List<Integer> temp1 = new ArrayList<Integer>();
temp1.add(2);
temp1.add(3);
Employee e1 = new Employee();
e1.id = 1;
e1.importance = 5;
e1.subordinates = temp1;
Employee e2 = new Employee();
e2.id = 2;
e2.importance = 3;
e2.subordinates = new ArrayList<Integer>();
Employee e3 = new Employee();
e3.id = 3;
e3.importance = 3;
e3.subordinates = new ArrayList<Integer>();
List<Employee> employees = new ArrayList<Employee>();
employees.add(e1);
employees.add(e2);
employees.add(e3);
int id = 1;
int x = getImportance(employees, id);
System.out.println();
}
// runtime 39ms
public static int getImportance(List<Employee> employees, int id) {
int res = 0;
for (Employee e : employees) {
if (e.id == id) {
res += e.importance;
for (Integer t : e.subordinates)
res += getImportance(employees, t);
}
}
return res;
}
// fastest solution runtime 9ms
HashMap<Integer, Employee> map;
public int getImportance1(List<Employee> employees, int id) {
map = new HashMap<>();
for (Employee e : employees)
map.put(e.id, e);
return helper(map.get(id));
}
public int helper(Employee em) {
int res = em.importance;
for (int sub : em.subordinates) {
res += helper(map.get(sub));
}
return res;
}
}
| [
"[email protected]"
]
| |
99c51dd539856e3638fe940c93ae5afa7a3b344c | e3bc1788a0e5e2d7b2462fbb2119d43e6993d5af | /org.kevoree.modeling.test.ghcnd/src/main/java/org/kevoree/modeling/test/ghcn/GhcnReader.java | a896d29d1be2edf1d9adf1652476e3b4425ab7da | []
| no_license | kevoree/kmf-ghcn | 2d19d2cd3f5eec557ced52e704d36357fdfc57c7 | 296990411767831d28e622360c6df52677d70eb9 | refs/heads/master | 2021-01-20T06:57:10.986469 | 2016-02-22T16:25:03 | 2016-02-22T16:25:03 | 22,251,171 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,654 | java | package org.kevoree.modeling.test.ghcn;
/**
* Created by gregory.nain on 22/07/2014.
*/
public class GhcnReader {
/*
private String dbLocation = "GhcnLevelDB";
private GhcnTransactionManager tm;
private SimpleDateFormat simpleDateFormat;
private GhcnTransaction transaction;
public GhcnReader() {
initFactory();
}
public GhcnReader(String dbLocation) {
this.dbLocation=dbLocation;
initFactory();
}
private void initFactory() {
try {
tm = new GhcnTransactionManager(new LevelDbDataStore(dbLocation));
simpleDateFormat = new SimpleDateFormat("yyyyMMd");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
transaction = tm.createTransaction();
GhcnTimeView rootTimeView = transaction.time(simpleDateFormat.parse("18000101").getTime());
DataSet root = (DataSet)rootTimeView.lookup("/");
if(root == null) {
System.err.println("Root not found !");
System.exit(-1);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
public void printCountries() {
try {
GhcnTimeView rootTimeView = transaction.time(simpleDateFormat.parse("18000101").getTime());
DataSet root = (DataSet)rootTimeView.lookup("/");
int i = 0;
for(Country c : root.getCountries()) {
i++;
if(i % 100 == 0){
System.out.println(c.getName());
} else {
System.out.print(c.getName() + ", ");
}
}
System.out.println();
} catch (ParseException e) {
e.printStackTrace();
}
}
public void printStates() {
try {
GhcnTimeView rootTimeView = transaction.time(simpleDateFormat.parse("18000101").getTime());
DataSet root = (DataSet)rootTimeView.lookup("/");
int i = 0;
for(USState state : root.getUsStates()) {
i++;
if(i % 100 == 0){
System.out.println(state.getName());
} else {
System.out.print(state.getName() + ", ");
}
}
System.out.println();
} catch (ParseException e) {
e.printStackTrace();
}
}
public void printStations() {
try {
GhcnTransaction transaction = tm.createTransaction();
GhcnTimeView rootTimeView = null;
rootTimeView = transaction.time(simpleDateFormat.parse("18000101").getTime());
DataSet root = (DataSet)rootTimeView.lookup("/");
int i = 0;
for(Station station : root.getStations()) {
i++;
if(i % 100 == 0){
System.out.println(station.getName());
} else {
System.out.print(station.getName() + ", ");
}
}
System.out.println();
} catch (ParseException e) {
e.printStackTrace();
}
}
public void printDailyRecords() {
try {
final int[] records = new int[1];
final GhcnTimeView rootTimeView = transaction.time(simpleDateFormat.parse("18000101").getTime());
for(final Station station : ((DataSet)rootTimeView.lookup("/")).getStations()) {
//System.out.println("Station:" + station.getName());
if(station.next() != null) {
GhcnTransaction stationTransaction = tm.createTransaction();
GhcnTimeView tv = stationTransaction.time(station.next().getNow());
Station temporizedStation = (Station) tv.lookup(station.path());
for (final Record rc : temporizedStation.getLastRecords()) {
final GhcnTransaction recordTransaction = tm.createTransaction();
GhcnTimeView recordView = recordTransaction.time(rc.getNow());
Record timedRecord = (Record) recordView.lookup(rc.path());
do {
//timedRecord = (Record) recordView.lookup(timedRecord.path());
StringBuilder sb = new StringBuilder();
sb.append("Recorded on ");
sb.append(simpleDateFormat.format(timedRecord.getNow()));
sb.append(" on Station ");
sb.append(station.getName() + "("+station.getId()+")");
sb.append("[");
sb.append("Type:");
sb.append(Element.parse(timedRecord.getType()).name);
sb.append(", Quality:");
sb.append(Quality.parse(timedRecord.getQuality()).name);
sb.append(", Measurement:");
sb.append(Measurement.parse(timedRecord.getMeasurement()).name);
sb.append(", Source:");
sb.append(Source.parse(timedRecord.getSource()).name);
sb.append(", Value:");
sb.append(timedRecord.getValue());
sb.append("]");
System.out.println(sb.toString());
records[0]++;
timedRecord = timedRecord.next();
} while (timedRecord != null);
recordTransaction.close();
}
stationTransaction.close();
}
}
System.out.println("Records:" + records[0]);
} catch (ParseException e) {
e.printStackTrace();
}
}
public void printDates() {
try {
final GhcnTimeView rootTimeView = transaction.time(simpleDateFormat.parse("18000101").getTime());
final TimeMeta timeMetaRoot = ((TimeAwareKMFFactory)rootTimeView).getTimeTree("#global");
timeMetaRoot.walkAsc(new TimeWalker() {
long previous;
@Override
public void walk(@JetValueParameter(name = "timePoint") @NotNull long timePoint) {
System.out.println("" + SimpleDateFormat.getDateInstance().format(new Date(timePoint)));
}
});
} catch (ParseException e) {
e.printStackTrace();
}
}
*/
}
| [
"[email protected]"
]
| |
36c733c90a1895d1a53667cd347e46325eff5e39 | 0b3b870e20f8dfe45a73977e3ca2024459924740 | /cloudlike_common/src/main/java/com/lzb/cloudlike/common/dto/MqMessageDto.java | ac1ebb894f9d3c46ab0d67a646f95753f93428af | []
| no_license | lzb-ovo/teacher-management | 0c84db8f2d27523b141819733272347d6cdef653 | f8362a3c0e4f349576db3c330333dbe4750915ba | refs/heads/master | 2023-01-06T15:37:13.142920 | 2020-11-04T12:27:00 | 2020-11-04T12:27:00 | 309,993,838 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 370 | java | package com.lzb.cloudlike.common.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* projectName: cloudlike
*
* @author: 罗智博
* time: 2020/11/3 14:27
* description:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MqMessageDto {
private long id;
private int type;
private Object data;
}
| [
"[email protected]"
]
| |
7a3e49f3c8972c21b3ba6241649791bf839285e8 | c3e7093443229213035b807f6d502a0af48162a6 | /src/_23_overload/Point.java | e9d57f1156d02aac5f1c46496b463550af9c7960 | []
| no_license | mithun3/JavaLanguageBasics | 1ee28a22ba799b0132b8ba8ae9fa98580b986336 | 91baf0216f164edbf788a2de57cc6c45cf50e9c9 | refs/heads/master | 2016-09-06T08:54:36.272569 | 2014-10-31T07:06:12 | 2014-10-31T07:06:12 | 24,887,905 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 381 | java | package _23_overload;
public class Point {
int x, y;
Point(int x, int y) // Overloaded constructor
{
this.x = x;
this.y = y;
}
Point(Point p) // Overloaded constructor
{
this(p.x, p.y);
} // Calls the first constructor
void move(int dx, int dy) {
x += dx;
y += dy;
}
public String toString() {
return "(" + x + ", " + y + ")";
}
} | [
"[email protected]"
]
| |
2936e5de7f622a2b32f2961a01e5d71a3da11236 | b6ea417b48402d85b6fe90299c51411b778c07cc | /spring-web/src/test/java/org/springframework/http/codec/json/JacksonViewBean.java | b5f8a197c3298f3b847814eed10adb1a43ec9335 | [
"Apache-2.0"
]
| permissive | DevHui/spring-framework | 065f24e96eaaed38495b9d87bc322db82b6a046c | 4a2f291e26c6f78c3875dea13432be21bb1c0ed6 | refs/heads/master | 2020-12-04T21:08:18.445815 | 2020-01-15T03:54:42 | 2020-01-15T03:54:42 | 231,526,595 | 1 | 0 | Apache-2.0 | 2020-01-03T06:28:30 | 2020-01-03T06:28:29 | null | UTF-8 | Java | false | false | 1,497 | java | /*
* Copyright 2002-2017 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
*
* https://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.http.codec.json;
import com.fasterxml.jackson.annotation.JsonView;
/**
* @author Sebastien Deleuze
*/
@JsonView(JacksonViewBean.MyJacksonView3.class)
class JacksonViewBean {
@JsonView(MyJacksonView1.class)
private String withView1;
@JsonView(MyJacksonView2.class)
private String withView2;
private String withoutView;
public String getWithView1() {
return withView1;
}
public void setWithView1(String withView1) {
this.withView1 = withView1;
}
public String getWithView2() {
return withView2;
}
public void setWithView2(String withView2) {
this.withView2 = withView2;
}
public String getWithoutView() {
return withoutView;
}
public void setWithoutView(String withoutView) {
this.withoutView = withoutView;
}
interface MyJacksonView1 {
}
interface MyJacksonView2 {
}
interface MyJacksonView3 {
}
}
| [
"[email protected]"
]
| |
79c48935f8c61ead8a458e7762b7a5bd3dcb5257 | bf5cd2ad1edeb2daf92475d95a380ddc66899789 | /netty/src/main/java/com/microwu/cxd/network/netty/demo/NettyMessage.java | 046ac0a49c00df7fcf054b7184ba9b4440cc1aa7 | []
| no_license | MarsGravitation/demo | 4ca7cb8d8021bdc3924902946cc9bb533445a31e | 53708b78dcf13367d20fd5c290cf446b02a73093 | refs/heads/master | 2022-11-27T10:17:18.130657 | 2022-04-26T08:02:59 | 2022-04-26T08:02:59 | 250,443,561 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 422 | java | package com.microwu.cxd.network.netty.demo;
public class NettyMessage {
private Header header;
private Object body;
public Header getHeader() {
return header;
}
public void setHeader(Header header) {
this.header = header;
}
public Object getBody() {
return body;
}
public void setBody(Object body) {
this.body = body;
}
public String toString(){
return "NettyMessage [header=" + header + "]";
}
}
| [
"[email protected]"
]
| |
ad797182331198e12b74ac0015d9d77bef492c81 | 08bfc6ad269cdef5dc9252e587412d9e83be710e | /src/main/java/oop/g8/model/entity/Person.java | 01be170a6b67a02a19f82c052f0275f44077fb30 | []
| no_license | dinhhoangnam998/20181-OOP-Neo4j | c9eaae40ee8693ef9b6b6b1cf4864f29dbc77986 | 5b25658c8f7fcaae1841894cc318ba7a35c7ed69 | refs/heads/master | 2021-10-09T15:47:10.688923 | 2018-12-31T09:41:00 | 2018-12-31T09:41:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 399 | java | package oop.g8.model.entity;
import org.neo4j.ogm.annotation.NodeEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
@NodeEntity
@Data
@ToString(callSuper=true, includeFieldNames=true)
@NoArgsConstructor
@AllArgsConstructor
public class Person extends Entity {
private int age;
private boolean gender;
private String job;
}
| [
"[email protected]"
]
| |
63af4b808733fbf3bed6b9baeda93bd3071f4dd2 | 09a7fa80d420634848b5e6af7b59353afd8c726b | /src/main/java/org/myrobotlab/kinematics/Point.java | 28cda26799af0bd697890dbb0744f497296ecd62 | [
"Apache-2.0"
]
| permissive | MyRobotLab/myrobotlab | cf789956d9f97a98eead44faf7a8b61f70348dc3 | 0ecdc681b4928ab65649404779c095d352dd96b1 | refs/heads/develop | 2023-09-04T10:57:19.041683 | 2023-08-30T14:04:44 | 2023-08-30T14:04:44 | 18,051,302 | 213 | 114 | Apache-2.0 | 2023-09-07T14:14:58 | 2014-03-24T03:59:27 | Java | UTF-8 | Java | false | false | 5,914 | java | package org.myrobotlab.kinematics;
import java.io.Serializable;
import java.text.DecimalFormat;
import java.text.NumberFormat;
/**
* Represents a 3d point in space. TODO: add rotation (roll/pitch/yaw -
* rz,rx,ry)
*
* @author kwatters
*
*/
public class Point implements Serializable {
private static final long serialVersionUID = 1L;
private double x;
private double y;
private double z;
private double roll;
private double pitch;
private double yaw;
/**
* A 6 dimensional vector representing the 6 degrees of freedom in space.
*
* @param x
* - left / right axis
* @param y
* - up / down axis
* @param z
* - forward / backward axis
* @param roll
* - rotation about the z axis
* @param pitch
* - rotation about the x axis
* @param yaw
* - rotation about the y axis
*
*/
public Point(double x, double y, double z, double roll, double pitch, double yaw) {
super();
// linear information
this.x = x;
this.y = y;
this.z = z;
// angular information
this.roll = roll;
this.pitch = pitch;
this.yaw = yaw;
}
public Point(Point copy) {
this.x = copy.x;
this.y = copy.y;
this.z = copy.z;
this.roll = copy.roll;
this.pitch = copy.pitch;
this.yaw = copy.yaw;
}
public Point(double x, double y, double z) {
this(x, y, z, 0.0, 0.0, 0.0);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Point other = (Point) obj;
if (Double.doubleToLongBits(x) != Double.doubleToLongBits(other.x))
return false;
if (Double.doubleToLongBits(y) != Double.doubleToLongBits(other.y))
return false;
if (Double.doubleToLongBits(z) != Double.doubleToLongBits(other.z))
return false;
if (Double.doubleToLongBits(roll) != Double.doubleToLongBits(other.roll))
return false;
if (Double.doubleToLongBits(pitch) != Double.doubleToLongBits(other.pitch))
return false;
if (Double.doubleToLongBits(yaw) != Double.doubleToLongBits(other.yaw))
return false;
return true;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public double getZ() {
return z;
}
public double getRoll() {
return roll;
}
public double getPitch() {
return pitch;
}
public double getYaw() {
return yaw;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(x);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(y);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(z);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(roll);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(pitch);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(yaw);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
public double magnitude() {
// TODO Auto-generated method stub
return Math.sqrt(x * x + y * y + z * z);
}
public Point subtract(Point p) {
// TODO Auto-generated method stub
Point newPoint = new Point(x - p.getX(), y - p.getY(), z - p.getZ(), roll - p.getRoll(), pitch - p.getPitch(), yaw - p.getYaw());
return newPoint;
}
@Override
public String toString() {
// TODO: round this out
NumberFormat formatter = new DecimalFormat("#0.000");
return "(x=" + formatter.format(x) + ", y=" + formatter.format(y) + ", z=" + formatter.format(z) + ", roll=" + formatter.format(roll) + ", pitch=" + formatter.format(pitch)
+ ", yaw=" + formatter.format(yaw) + ")";
}
public void setX(double x) {
this.x = x;
}
public void setY(double y) {
this.y = y;
}
public void setZ(double z) {
this.z = z;
}
public void setRoll(double roll) {
this.roll = roll;
}
public void setPitch(double pitch) {
this.pitch = pitch;
}
public void setYaw(double yaw) {
this.yaw = yaw;
}
/**
* add the x,y,z,roll,pitch,yaw of the point passed in, to the current point.
* return a new point with the individual components summed.
*
* @param p
* the point to be added
* @return the new point
*/
public Point add(Point p) {
// add the linear and angular parts and return the resulting sum.
// TODO: move this to a utils class and keep this a POJO.
Point p2 = new Point(p.x + x, p.y + y, p.z + z, p.roll + roll, p.pitch + pitch, p.yaw + yaw);
return p2;
}
/**
* return a new point with the x,y,z values multipled by the xyzScale
*
* @param xyzScale
* the scaling (maintain aspect ratios)
* @return the point as scaled
*/
public Point multiplyXYZ(double xyzScale) {
// add the linear and angular parts and return the resulting sum.
// TODO: move this to a utils class and keep this a POJO.
Point p2 = new Point(xyzScale * x, xyzScale * y, xyzScale * z, roll, pitch, yaw);
return p2;
}
public Double distanceTo(Point point) {
Point calcPoint = subtract(point);
return Math.sqrt(Math.pow(calcPoint.getX(), 2) + Math.pow(calcPoint.getY(), 2) + Math.pow(calcPoint.getZ(), 2));
}
public Point unitVector(double unitSize) {
if (magnitude() == 0) {
return this;
}
Point retval = multiplyXYZ(unitSize / magnitude());
return retval;
}
}
| [
"[email protected]"
]
| |
922bd978e41a800c084eeb24570582e596d5a885 | 39513a5989d98ad1473256a713949619cafffa8c | /SistemaSolar/src/com/master/planetas/saturno/PlanetasSaturnoTexto.java | f052a8abca1bacd2521a09c749fa8dbd962baddc | []
| no_license | 1reset9/sistema-solar | f48b25396465197c3b8080a154c4a7241ef9e79c | 4467bdd528c4c49ed50cf0fafaebb8d61d76f82d | refs/heads/master | 2019-01-02T09:39:58.878472 | 2013-01-05T08:34:59 | 2013-01-05T08:34:59 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 14,581 | java | package com.master.planetas.saturno;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TableLayout;
import android.widget.TextView;
import com.master.Planetas;
import com.master.R;
public class PlanetasSaturnoTexto extends Activity {
private Button bVerSaturnoTextoEstructura;
private Button bOcultarSaturnoTextoEstructura;
private TextView SaturnoTextoEstructura1T;
private TextView SaturnoTextoEstructura2T;
private TextView SaturnoTextoEstructura3T;
private Button bVerSaturnoTextoAtmosfera;
private Button bOcultarSaturnoTextoAtmosfera;
private TextView SaturnoTextoAtmosfera1T;
private TextView SaturnoTextoAtmosfera2T;
private TextView SaturnoTextoAtmosfera3T;
private ImageView SaturnoTextoAtmosfera4I;
private TextView SaturnoTextoAtmosfera5C;
private Button bVerSaturnoTextoOrbitaRotacion;
private Button bOcultarSaturnoTextoOrbitaRotacion;
private TextView OrbitaRotacion1T;
private TextView OrbitaRotacion2T;
private Button bVerSaturnoTextoSatelites;
private Button bOcultarSaturnoTextoSatelites;
private TextView SaturnoTextoSatelites1T;
private ImageView SaturnoTextoSatelites2I;
private TextView SaturnoTextoSatelites3C;
private TextView SaturnoTextoSatelites4T;
private TextView SaturnoTextoSatelites5T;
private TableLayout SaturnoTextoSatelites6Tabla;
private Button bVerSaturnoTextoObservacionEstudio;
private Button bOcultarSaturnoTextoObservacionEstudio;
private TextView ObservacionEstudio1T;
private TextView ObservacionEstudio2T;
private TextView ObservacionEstudio3T;
private TextView ObservacionEstudio4T;
private ImageView ObservacionEstudio5I;
private TextView ObservacionEstudio6T;
private TextView ObservacionEstudio7T;
private TextView ObservacionEstudio8T;
private TextView ObservacionEstudio9T;
private TextView ObservacionEstudio10T;
private ImageView ObservacionEstudio11I;
private TextView ObservacionEstudio12C;
private TextView ObservacionEstudio13T;
private ImageView ObservacionEstudio14I;
private TextView ObservacionEstudio15C;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.planetas_saturno_texto);
// ESTRUCTURA
bVerSaturnoTextoEstructura = (Button) findViewById(R.id.VerSaturnoTextoEstructura);
SaturnoTextoEstructura1T = (TextView) findViewById(R.id.SaturnoTextoEstructura1T);
SaturnoTextoEstructura2T = (TextView) findViewById(R.id.SaturnoTextoEstructura2T);
SaturnoTextoEstructura3T = (TextView) findViewById(R.id.SaturnoTextoEstructura3T);
bOcultarSaturnoTextoEstructura = (Button) findViewById(R.id.OcultarSaturnoTextoEstructura);
SaturnoTextoEstructura1T.setVisibility(View.GONE);
SaturnoTextoEstructura2T.setVisibility(View.GONE);
SaturnoTextoEstructura3T.setVisibility(View.GONE);
bOcultarSaturnoTextoEstructura.setVisibility(View.GONE);
bVerSaturnoTextoEstructura.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
SaturnoTextoEstructura1T.setVisibility(View.VISIBLE);
SaturnoTextoEstructura2T.setVisibility(View.VISIBLE);
SaturnoTextoEstructura3T.setVisibility(View.VISIBLE);
bOcultarSaturnoTextoEstructura.setVisibility(View.VISIBLE);
}
});
bOcultarSaturnoTextoEstructura
.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
SaturnoTextoEstructura1T.setVisibility(View.GONE);
SaturnoTextoEstructura2T.setVisibility(View.GONE);
SaturnoTextoEstructura3T.setVisibility(View.GONE);
bOcultarSaturnoTextoEstructura.setVisibility(View.GONE);
}
});
Animation a = AnimationUtils.loadAnimation(this, R.anim.rotate1);
a.reset();
bVerSaturnoTextoEstructura.clearAnimation();
bVerSaturnoTextoEstructura.startAnimation(a);
// ATMÓSFERA
bVerSaturnoTextoAtmosfera = (Button) findViewById(R.id.VerSaturnoTextoAtmosfera);
SaturnoTextoAtmosfera1T = (TextView) findViewById(R.id.SaturnoTextoAtmosfera1T);
SaturnoTextoAtmosfera2T = (TextView) findViewById(R.id.SaturnoTextoAtmosfera2T);
SaturnoTextoAtmosfera3T = (TextView) findViewById(R.id.SaturnoTextoAtmosfera3T);
SaturnoTextoAtmosfera4I = (ImageView) findViewById(R.id.SaturnoTextoAtmosfera4I);
SaturnoTextoAtmosfera5C = (TextView) findViewById(R.id.SaturnoTextoAtmosfera5C);
bOcultarSaturnoTextoAtmosfera = (Button) findViewById(R.id.OcultarSaturnoTextoAtmosfera);
SaturnoTextoAtmosfera1T.setVisibility(View.GONE);
SaturnoTextoAtmosfera2T.setVisibility(View.GONE);
SaturnoTextoAtmosfera3T.setVisibility(View.GONE);
SaturnoTextoAtmosfera4I.setVisibility(View.GONE);
SaturnoTextoAtmosfera5C.setVisibility(View.GONE);
bOcultarSaturnoTextoAtmosfera.setVisibility(View.GONE);
bVerSaturnoTextoAtmosfera.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
SaturnoTextoAtmosfera1T.setVisibility(View.VISIBLE);
SaturnoTextoAtmosfera2T.setVisibility(View.VISIBLE);
SaturnoTextoAtmosfera3T.setVisibility(View.VISIBLE);
SaturnoTextoAtmosfera4I.setVisibility(View.VISIBLE);
SaturnoTextoAtmosfera5C.setVisibility(View.VISIBLE);
bOcultarSaturnoTextoAtmosfera.setVisibility(View.VISIBLE);
}
});
bOcultarSaturnoTextoAtmosfera.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
SaturnoTextoAtmosfera1T.setVisibility(View.GONE);
SaturnoTextoAtmosfera2T.setVisibility(View.GONE);
SaturnoTextoAtmosfera3T.setVisibility(View.GONE);
SaturnoTextoAtmosfera4I.setVisibility(View.GONE);
SaturnoTextoAtmosfera5C.setVisibility(View.GONE);
bOcultarSaturnoTextoAtmosfera.setVisibility(View.GONE);
}
});
a = AnimationUtils.loadAnimation(this, R.anim.rotate2);
a.reset();
bVerSaturnoTextoAtmosfera.clearAnimation();
bVerSaturnoTextoAtmosfera.startAnimation(a);
// ÓRBITA Y ROTACIÓN
bVerSaturnoTextoOrbitaRotacion = (Button) findViewById(R.id.VerSaturnoTextoOrbitaRotacion);
bOcultarSaturnoTextoOrbitaRotacion = (Button) findViewById(R.id.OcultarSaturnoTextoOrbitaRotacion);
OrbitaRotacion1T = (TextView) findViewById(R.id.OrbitaRotacion1T);
OrbitaRotacion2T = (TextView) findViewById(R.id.OrbitaRotacion2T);
bOcultarSaturnoTextoOrbitaRotacion.setVisibility(View.GONE);
OrbitaRotacion1T.setVisibility(View.GONE);
OrbitaRotacion2T.setVisibility(View.GONE);
bVerSaturnoTextoOrbitaRotacion
.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
bOcultarSaturnoTextoOrbitaRotacion
.setVisibility(View.VISIBLE);
OrbitaRotacion1T.setVisibility(View.VISIBLE);
OrbitaRotacion2T.setVisibility(View.VISIBLE);
}
});
bOcultarSaturnoTextoOrbitaRotacion
.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
bOcultarSaturnoTextoOrbitaRotacion
.setVisibility(View.GONE);
OrbitaRotacion1T.setVisibility(View.GONE);
OrbitaRotacion2T.setVisibility(View.GONE);
}
});
a = AnimationUtils.loadAnimation(this, R.anim.rotate3);
a.reset();
bVerSaturnoTextoOrbitaRotacion.clearAnimation();
bVerSaturnoTextoOrbitaRotacion.startAnimation(a);
// SATÉLITES
bVerSaturnoTextoSatelites = (Button) findViewById(R.id.VerSaturnoTextoSatelites);
bOcultarSaturnoTextoSatelites = (Button) findViewById(R.id.OcultarSaturnoTextoSatelites);
SaturnoTextoSatelites1T = (TextView) findViewById(R.id.SaturnoTextoSatelites1T);
SaturnoTextoSatelites2I = (ImageView) findViewById(R.id.SaturnoTextoSatelites2I);
SaturnoTextoSatelites3C = (TextView) findViewById(R.id.SaturnoTextoSatelites3C);
SaturnoTextoSatelites4T = (TextView) findViewById(R.id.SaturnoTextoSatelites4T);
SaturnoTextoSatelites5T = (TextView) findViewById(R.id.SaturnoTextoSatelites5T);
SaturnoTextoSatelites6Tabla = (TableLayout) findViewById(R.id.SaturnoTextoSatelites6Tabla);
SaturnoTextoSatelites1T.setVisibility(View.GONE);
SaturnoTextoSatelites2I.setVisibility(View.GONE);
SaturnoTextoSatelites3C.setVisibility(View.GONE);
SaturnoTextoSatelites4T.setVisibility(View.GONE);
SaturnoTextoSatelites5T.setVisibility(View.GONE);
SaturnoTextoSatelites6Tabla.setVisibility(View.GONE);
bOcultarSaturnoTextoSatelites.setVisibility(View.GONE);
bVerSaturnoTextoSatelites.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
SaturnoTextoSatelites1T.setVisibility(View.VISIBLE);
SaturnoTextoSatelites2I.setVisibility(View.VISIBLE);
SaturnoTextoSatelites3C.setVisibility(View.VISIBLE);
SaturnoTextoSatelites4T.setVisibility(View.VISIBLE);
SaturnoTextoSatelites5T.setVisibility(View.VISIBLE);
SaturnoTextoSatelites6Tabla.setVisibility(View.VISIBLE);
bOcultarSaturnoTextoSatelites.setVisibility(View.VISIBLE);
}
});
bOcultarSaturnoTextoSatelites.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
SaturnoTextoSatelites1T.setVisibility(View.GONE);
SaturnoTextoSatelites2I.setVisibility(View.GONE);
SaturnoTextoSatelites3C.setVisibility(View.GONE);
SaturnoTextoSatelites4T.setVisibility(View.GONE);
SaturnoTextoSatelites5T.setVisibility(View.GONE);
SaturnoTextoSatelites6Tabla.setVisibility(View.GONE);
bOcultarSaturnoTextoSatelites.setVisibility(View.GONE);
}
});
a = AnimationUtils.loadAnimation(this, R.anim.rotate4);
a.reset();
bVerSaturnoTextoSatelites.clearAnimation();
bVerSaturnoTextoSatelites.startAnimation(a);
// OBSERVACIÓN Y ESTUDIO
bVerSaturnoTextoObservacionEstudio = (Button) findViewById(R.id.VerSaturnoTextoObservacionEstudio);
bOcultarSaturnoTextoObservacionEstudio = (Button) findViewById(R.id.OcultarSaturnoTextoObservacionEstudio);
ObservacionEstudio1T = (TextView) findViewById(R.id.ObservacionEstudio1T);
ObservacionEstudio2T = (TextView) findViewById(R.id.ObservacionEstudio2T);
ObservacionEstudio3T = (TextView) findViewById(R.id.ObservacionEstudio3T);
ObservacionEstudio4T = (TextView) findViewById(R.id.ObservacionEstudio4T);
ObservacionEstudio5I = (ImageView) findViewById(R.id.ObservacionEstudio5I);
ObservacionEstudio6T = (TextView) findViewById(R.id.ObservacionEstudio6T);
ObservacionEstudio7T = (TextView) findViewById(R.id.ObservacionEstudio7T);
ObservacionEstudio8T = (TextView) findViewById(R.id.ObservacionEstudio8T);
ObservacionEstudio9T = (TextView) findViewById(R.id.ObservacionEstudio9T);
ObservacionEstudio10T = (TextView) findViewById(R.id.ObservacionEstudio10T);
ObservacionEstudio11I = (ImageView) findViewById(R.id.ObservacionEstudio11I);
ObservacionEstudio12C = (TextView) findViewById(R.id.ObservacionEstudio12C);
ObservacionEstudio13T = (TextView) findViewById(R.id.ObservacionEstudio13T);
ObservacionEstudio14I = (ImageView) findViewById(R.id.ObservacionEstudio14I);
ObservacionEstudio15C = (TextView) findViewById(R.id.ObservacionEstudio15C);
ObservacionEstudio1T.setVisibility(View.GONE);
ObservacionEstudio2T.setVisibility(View.GONE);
ObservacionEstudio3T.setVisibility(View.GONE);
ObservacionEstudio4T.setVisibility(View.GONE);
ObservacionEstudio5I.setVisibility(View.GONE);
ObservacionEstudio6T.setVisibility(View.GONE);
ObservacionEstudio7T.setVisibility(View.GONE);
ObservacionEstudio8T.setVisibility(View.GONE);
ObservacionEstudio9T.setVisibility(View.GONE);
ObservacionEstudio10T.setVisibility(View.GONE);
ObservacionEstudio11I.setVisibility(View.GONE);
ObservacionEstudio12C.setVisibility(View.GONE);
ObservacionEstudio13T.setVisibility(View.GONE);
ObservacionEstudio14I.setVisibility(View.GONE);
ObservacionEstudio15C.setVisibility(View.GONE);
bOcultarSaturnoTextoObservacionEstudio.setVisibility(View.GONE);
bVerSaturnoTextoObservacionEstudio
.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
ObservacionEstudio1T.setVisibility(View.VISIBLE);
ObservacionEstudio2T.setVisibility(View.VISIBLE);
ObservacionEstudio3T.setVisibility(View.VISIBLE);
ObservacionEstudio4T.setVisibility(View.VISIBLE);
ObservacionEstudio5I.setVisibility(View.VISIBLE);
ObservacionEstudio6T.setVisibility(View.VISIBLE);
ObservacionEstudio7T.setVisibility(View.VISIBLE);
ObservacionEstudio8T.setVisibility(View.VISIBLE);
ObservacionEstudio9T.setVisibility(View.VISIBLE);
ObservacionEstudio10T.setVisibility(View.VISIBLE);
ObservacionEstudio11I.setVisibility(View.VISIBLE);
ObservacionEstudio12C.setVisibility(View.VISIBLE);
ObservacionEstudio13T.setVisibility(View.VISIBLE);
ObservacionEstudio14I.setVisibility(View.VISIBLE);
ObservacionEstudio15C.setVisibility(View.VISIBLE);
bOcultarSaturnoTextoObservacionEstudio
.setVisibility(View.VISIBLE);
}
});
bOcultarSaturnoTextoObservacionEstudio
.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
ObservacionEstudio1T.setVisibility(View.GONE);
ObservacionEstudio2T.setVisibility(View.GONE);
ObservacionEstudio3T.setVisibility(View.GONE);
ObservacionEstudio4T.setVisibility(View.GONE);
ObservacionEstudio5I.setVisibility(View.GONE);
ObservacionEstudio6T.setVisibility(View.GONE);
ObservacionEstudio7T.setVisibility(View.GONE);
ObservacionEstudio8T.setVisibility(View.GONE);
ObservacionEstudio9T.setVisibility(View.GONE);
ObservacionEstudio10T.setVisibility(View.GONE);
ObservacionEstudio11I.setVisibility(View.GONE);
ObservacionEstudio12C.setVisibility(View.GONE);
ObservacionEstudio13T.setVisibility(View.GONE);
ObservacionEstudio14I.setVisibility(View.GONE);
ObservacionEstudio15C.setVisibility(View.GONE);
bOcultarSaturnoTextoObservacionEstudio
.setVisibility(View.GONE);
}
});
a = AnimationUtils.loadAnimation(this, R.anim.rotate5);
a.reset();
bVerSaturnoTextoObservacionEstudio.clearAnimation();
bVerSaturnoTextoObservacionEstudio.startAnimation(a);
}
@Override
public void onBackPressed() {
Intent intent = new Intent(this, Planetas.class);
startActivity(intent);
}
} | [
"[email protected]"
]
| |
99c1915a9f1dbc2460bccbb3aff8c0eeba326f72 | c4dbc2e254d37e7556223446263d49d9094a6066 | /app/src/main/java/com/travel/cotravel/fragment/account/profile/adapter/MyAdapter.java | 380f485387dbe28e4b3d1d38d4ff856e7e846dc9 | []
| no_license | dipmalatelang/Deep-Sarita-master | 194292f05f4ba09fb659f4fcdd7dc88d630a6b9f | b912d9716e60f9d974d0c1b0fc08146142c339ef | refs/heads/master | 2020-11-27T21:31:22.460032 | 2019-12-22T19:19:03 | 2019-12-22T19:19:03 | 229,608,372 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,501 | java | package com.travel.cotravel.fragment.account.profile.adapter;
import android.content.Context;
import android.graphics.Bitmap;
import android.media.MediaPlayer;
import android.net.Uri;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.VideoView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.request.transition.Transition;
import com.travel.cotravel.R;
import com.travel.cotravel.fragment.account.profile.module.Upload;
import com.travel.cotravel.fragment.account.profile.ui.EditPhotoActivity;
import com.wajahatkarim3.easyflipview.EasyFlipView;
import java.util.List;
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ImageViewHolder> {
private Context mcontext;
private List<Upload> mUploads;
String TAG = "AdapterClass";
String uid;
String previousValue="";
String gender;
public MyAdapter(Context context, String uid, String gender, List<Upload> uploads, PhotoInterface listener) {
this.uid=uid;
mcontext =context;
mUploads =uploads;
this.gender=gender;
this.listener=listener;
}
@NonNull
@Override
public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
View v = LayoutInflater.from(mcontext).inflate(R.layout.layout_images, parent,false);
return new ImageViewHolder(v);
}
@Override
public void onBindViewHolder(@NonNull ImageViewHolder holder, int position) {
Upload uploadCurrent = mUploads.get(position);
if(mUploads.get(position).getName().equalsIgnoreCase("Video"))
{
holder.set_main.setText("View");
holder.delete.setText("Remove video");
holder.imageView.setVisibility(View.GONE);
holder.videoView.setVideoURI(Uri.parse(mUploads.get(position).getUrl()));
holder.videoView.seekTo(1000);
holder.progressBar.setVisibility(View.GONE);
holder.videoView.setVisibility(View.VISIBLE);
holder.videoView.setOnPreparedListener(mp -> {
mp.setVolume(0,0);
mp.start();
});
}
else {
if(gender.equalsIgnoreCase("Female"))
{
holder.imageView.setImageResource(R.drawable.no_photo_female);
}
else {
holder.imageView.setImageResource(R.drawable.no_photo_male);
}
holder.progressBar.setVisibility(View.GONE);
if(!uploadCurrent.getUrl().equalsIgnoreCase(""))
{
Glide.with(mcontext).asBitmap().load(uploadCurrent.getUrl())
.centerCrop()
.override(450, 600)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
holder.imageView.setImageBitmap(resource);
}
});
holder.imageView.setAdjustViewBounds(true);
holder.imageView.setScaleType(ImageView.ScaleType.FIT_XY);
}
}
if(uploadCurrent.getType()==3)
{
holder.pp_eye.setText("Make Public");
}
else if(uploadCurrent.getType()==2)
{
holder.pp_eye.setText("Make Private");
}
else if(uploadCurrent.getType()==1){
holder.ivTitle.setVisibility(View.VISIBLE);
holder.pp_eye.setText("Make Private");
((EditPhotoActivity)mcontext).appDetails("CurProfilePhoto",uploadCurrent.getId());
}
holder.flipView.setOnFlipListener((flipView, newCurrentSide) -> {
holder.set_main.setOnClickListener(view -> {
if(mUploads.get(position).getName().equalsIgnoreCase("Video"))
{
listener.playVideo(mUploads.get(position).getUrl());
}
else {
listener.setProfilePhoto(mUploads.get(position).getId(), ((EditPhotoActivity) mcontext).getAppDetails("CurProfilePhoto"), position);
holder.ivTitle.setVisibility(View.VISIBLE);
}
});
holder.pp_eye.setOnClickListener(view -> listener.setPhotoAsPrivate(mUploads.get(position).getId()));
holder.delete.setOnClickListener(view -> listener.removePhoto(mUploads.get(position).getId()));
});
}
@Override
public int getItemCount() {
return mUploads.size();
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public int getItemViewType(int position) {
return position;
}
public class ImageViewHolder extends RecyclerView.ViewHolder{
public ImageView imageView,ivTitle;
TextView set_main, pp_eye, delete;
EasyFlipView flipView;
ProgressBar progressBar;
VideoView videoView;
public ImageViewHolder(@NonNull View itemView) {
super(itemView);
imageView = itemView.findViewById(R.id.imageView);
videoView=itemView.findViewById(R.id.videoView);
ivTitle=itemView.findViewById(R.id.ivTitle);
flipView=itemView.findViewById(R.id.flipView);
set_main=itemView.findViewById(R.id.set_main);
pp_eye=itemView.findViewById(R.id.pp_eye);
delete=itemView.findViewById(R.id.delete);
progressBar=itemView.findViewById(R.id.progressBar);
}
}
PhotoInterface listener;
public interface PhotoInterface{
void playVideo(String url);
void setProfilePhoto(String id, String previousValue, int position);
void removePhoto(String id);
void setPhotoAsPrivate(String id);
}
} | [
"[email protected]"
]
| |
592c8c0c7dd85b096d637b878c6525387e2d6d54 | 82dfacb015f36958b5c17e2e4e861ad224307d84 | /lab2/src/main/java/omaftiyak/javacourse/lab2/validator/EmployeeValidator.java | 12b70a7f2db4786443d7a1c2d919ca5371ec1f90 | []
| no_license | omaftiyak/javacourse | 1ff6d63ae5ebdc68097a2ec358484e21839ad918 | f54bff0c4f4b7193a25b40c8338d0ceeb287d008 | refs/heads/master | 2020-09-11T10:05:07.054879 | 2016-12-04T21:39:03 | 2016-12-04T21:39:03 | 67,364,079 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 2,499 | java | package omaftiyak.javacourse.lab2.validator;
import omaftiyak.javacourse.lab2.model.Employee;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
public class EmployeeValidator implements Validator<Employee>{
@Override
public boolean validate(String[] parts) throws ValidatorException {
List<String> errors = new ArrayList<>();
if (parts.length != 5) {
throw new ValidatorException("Invalid line format");
}
int index = 0;
int firstNameIndex = index++;
int lastNameIndex = index++;
int positionIndex = index++;
int dateIndex = index++;
int salaryIndex = index++;
validateString(parts[firstNameIndex], 32, "first name", errors);
validateString(parts[lastNameIndex], 32, "last name", errors);
validateString(parts[positionIndex], 32, "position", errors);
try {
int birthYear = Integer.parseInt(parts[dateIndex]);
if (birthYear < 1900 || birthYear > Calendar.getInstance().get(Calendar.YEAR) - 18) {
errors.add("Year of publication should be between 1000 and this year");
}
} catch (NumberFormatException e) {
e.printStackTrace();
errors.add("Invalid characters in year of birth");
}
try {
int salary = Integer.parseInt(parts[salaryIndex]);
if (salary > 1000000 || salary < 1000) {
errors.add("Salary is less then 100 and greater then 1000000");
}
} catch (NumberFormatException e) {
e.printStackTrace();
errors.add("Invalid salary");
}
if (parts[firstNameIndex] == null || !parts[firstNameIndex].matches("[A-Z][a-z]+-?([A-Z]?[a-z]*)")) {
errors.add("Employee first name should begin with upper case character");
}
if (parts[lastNameIndex] == null || !parts[lastNameIndex].matches("[A-Z][a-z]+-?([A-Z]?[a-z]*)")) {
errors.add("Employee last name should begin with upper case character");
}
if (!errors.isEmpty()) {
throw new ValidatorException(errors);
}else return true;
}
private void validateString(String string, int maxLength, String fieldName,List<String> errors) {
if (string == null || string.length() >= maxLength) {
errors.add(String.format("%s should be provided and length less than %s", fieldName, maxLength));
}
}
}
| [
"[email protected]"
]
| |
14a572c0969d5aaea0e45ab98520bc492a73556f | 52cb6cb99166fb0adbe71217556267ddd188a93c | /app/src/main/java/com/example/admin/myapplication/ToolUtils/LogUtils.java | 11292d9b20c5247fcb776a548d8c5aef01b8114d | []
| no_license | xujixiong2017/MyApplication | 08b9f2aa41913bb231d69671a7a620edf9af6169 | e3c69faf712664376fea76543d83cc74561fcbb9 | refs/heads/master | 2021-01-19T04:10:34.930234 | 2016-08-01T12:16:09 | 2016-08-01T12:16:09 | 64,664,200 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,345 | java | package com.example.admin.myapplication.ToolUtils;
import android.util.Log;
/**
* Log统一管理类
*/
public class LogUtils {
private LogUtils() {
/* cannot be instantiated */
throw new UnsupportedOperationException("cannot be instantiated");
}
public static boolean isDebug = true;// 是否需要打印bug,可以在application的onCreate函数里面初始化
private static final String TAG = "way";
// 下面四个是默认tag的函数
public static void i(String msg) {
if (isDebug)
Log.i(TAG, msg);
}
public static void d(String msg) {
if (isDebug)
Log.d(TAG, msg);
}
public static void e(String msg) {
if (isDebug)
Log.e(TAG, msg);
}
public static void v(String msg) {
if (isDebug)
Log.v(TAG, msg);
}
// 下面是传入自定义tag的函数
public static void i(String tag, String msg) {
if (isDebug)
Log.i(tag, msg);
}
public static void d(String tag, String msg) {
if (isDebug)
Log.i(tag, msg);
}
public static void e(String tag, String msg) {
if (isDebug)
Log.i(tag, msg);
}
public static void v(String tag, String msg) {
if (isDebug)
Log.i(tag, msg);
}
} | [
"[email protected]"
]
| |
889cdb25558f0d092e5cc94feca8b50f3eed30b8 | 7d1ff41f588ea7e1a8654d7fd0c51b7e3b42df5b | /Online-Ayurveda-Medical-Store/src/main/java/com/g7/oam/entities/User.java | 8b1d7a62fbffa5c6082a33c022c1a15737201ed2 | []
| no_license | Vses200/ayurvedaAPp | d0a55e996020c75e6a3dedc194c01f27b7f1f046 | acc712093228c5a36668796585d1f6fce170d0cb | refs/heads/master | 2023-05-05T21:39:09.422633 | 2021-05-25T08:31:57 | 2021-05-25T08:31:57 | 370,617,132 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,038 | java | package com.g7.oam.entities;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
@Entity
@Table(name = "OAM_User")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "user_mode", discriminatorType = DiscriminatorType.INTEGER)
@DiscriminatorValue(value = "1")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int userId;
@Column
private String password;
@Column
private String userType;
public User(int userId, String password, String userType) {
super();
this.userId = userId;
this.password = password;
this.userType = userType;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUserType() {
return userType;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((password == null) ? 0 : password.hashCode());
result = prime * result + userId;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
User other = (User) obj;
if (password == null) {
if (other.password != null)
return false;
} else if (!password.equals(other.password))
return false;
if (userId != other.userId)
return false;
return true;
}
@Override
public String toString() {
return "User [userId=" + userId + ", password=" + password + ", userType=" + userType + "]";
}
}
| [
"[email protected]"
]
| |
46e65a1157332578a337451bdc19fd18f1ac87c9 | f2d4984cd1e115200e84fabd71d7c37cc7dbf7c6 | /guli_java/service/service_order/src/main/java/com/lixuan/order/controller/PayLogController.java | 7f0df6e1d1bd6b4684acfc57dacbd7762863296d | []
| no_license | lixuan789/guli_admin | 78acd1b8c66a9af1a41313e0728728df90b517bf | ce24885061f2aa9dcf21806f701551c8ee06fb80 | refs/heads/master | 2023-01-03T07:09:04.951486 | 2020-10-20T00:04:20 | 2020-10-20T00:04:20 | 297,599,184 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,460 | java | package com.lixuan.order.controller;
import com.lixuan.common.base.result.Result;
import com.lixuan.order.service.PayLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* <p>
* 支付日志表 前端控制器
* </p>
*
* @author lixuan
* @since 2020-10-13
*/
@RestController
@RequestMapping("/order/payLog")
@CrossOrigin
public class PayLogController {
@Autowired
private PayLogService payService;
/**
* 生成二维码
*
* @return
*/
@GetMapping("/createNative/{orderNo}")
public Result createNative(@PathVariable String orderNo) {
Map map = payService.createNative(orderNo);
return Result.ok().data(map);
}
/**
* 获取支付状态
* @param orderNo
* @return
*/
@GetMapping("/queryPayStatus/{orderNo}")
public Result queryPayStatus(@PathVariable String orderNo) {
//调用查询接口
Map<String, String> map = payService.queryPayStatus(orderNo);
if (map == null) {//出错
return Result.error().message("支付出错");
}
if (map.get("trade_state").equals("SUCCESS")) {//如果成功
//更改订单状态
payService.updateOrderStatus(map);
return Result.ok().message("支付成功");
}
return Result.ok().code(25000).message("支付中");
}
}
| [
"[email protected]"
]
| |
2324deed01851e7366193392df800c41f0e0e3da | 3df2ed77c82778639f1ef03102969b817931e3d0 | /ejb-web/src/main/java/com/stobinski/bottlecaps/ejb/servlets/LoadSaltFilter.java | cd706009e343e2b27b4adc295b6758cc64011c78 | []
| no_license | diamen/BotteCaps | f51c4d04aeacd1a4ad669c011f9797aeb0fe6953 | ff54037c5038a20abb9a6b5b2ed70849f0d21c79 | refs/heads/master | 2021-03-27T13:05:37.695517 | 2016-10-07T13:34:18 | 2016-10-07T13:34:18 | 54,710,457 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,626 | java | package com.stobinski.bottlecaps.ejb.servlets;
import java.io.IOException;
import java.security.SecureRandom;
import javax.inject.Inject;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.RandomStringUtils;
import com.stobinski.bottlecaps.ejb.security.SessionCache;
import com.stobinski.bottlecaps.ejb.security.CsrfSessionCacheBean;
import com.stobinski.bottlecaps.ejb.security.ISessionCache;
@WebFilter(filterName = "loadSaltFilter", urlPatterns = { "/admin/login" } )
public class LoadSaltFilter implements Filter {
@Inject
@SessionCache(SessionCache.Type.CSRF)
private ISessionCache sessionCache;
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpReq = (HttpServletRequest) request;
if(!(httpReq.getSession().getAttribute(CsrfSessionCacheBean.SALT_CACHE) != null)) {
sessionCache.attachCacheToSession(httpReq.getSession());
}
String salt = RandomStringUtils.random(20, 0, 0, true, true, null, new SecureRandom());
sessionCache.updateCachedValue(httpReq, salt);
chain.doFilter(httpReq, response);
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {}
@Override
public void destroy() {}
}
| [
"[email protected]"
]
| |
eb1df3114e7bc6682898f3da24bca3b2b7b9e2ee | 49a5ca02311785f0ef2b1e4bed37fd29e5fac8da | /src/main/java/sn/delivery/neldam/repository/package-info.java | 5b0a6308d5b50980573423ea7c126b4fefb86975 | []
| no_license | anscamou/neldam | 400138896827d70e11d31f2c0c7e14fc13c921f9 | d5f646f28587cf87b337797e99b57bba80146055 | refs/heads/main | 2023-03-24T06:11:33.663237 | 2021-03-17T19:03:48 | 2021-03-17T19:03:48 | 345,460,574 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 80 | java | /**
* Spring Data JPA repositories.
*/
package sn.delivery.neldam.repository;
| [
"[email protected]"
]
| |
aca5ece78f3fdd088d703b11670970ae0fe8b14e | 6c8fe6c479ea370e23a51072cbe92027f7b21ac5 | /Jet/src/main/java/org/jnbis/imageio/WSQImageWriterSpi.java | e68fe275adb9c4b637ae3c63f9040958e132e1be | [
"Apache-2.0"
]
| permissive | brunohdossantos/jet | 423ee724df8b33b21c952688381f0ec6f10bfbf4 | 91ea96dc7d230d6d3106021eea75220e286cd2e5 | refs/heads/master | 2023-07-04T19:07:04.425622 | 2019-09-12T17:55:34 | 2019-09-12T17:55:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,928 | java | package org.jnbis.imageio;
import org.kohsuke.MetaInfServices;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.ImageWriter;
import javax.imageio.spi.ImageWriterSpi;
import javax.imageio.stream.ImageOutputStream;
import java.io.IOException;
import java.util.Locale;
public class WSQImageWriterSpi extends ImageWriterSpi {
static final String vendorName = "JMRTD";
static final String version = "0.0.2";
static final String writerClassName = "org.jnbis.imageio.WSQImageWriter";
static final String[] names = { "WSQ", "wsq", "WSQ FBI" };
static final String[] suffixes = { "wsq" };
static final String[] MIMETypes = { "image/x-wsq" };
static final String[] readerSpiNames = { "org.jnbis.imageio.WSQImageReaderSpi" };
static final boolean supportsStandardStreamMetadataFormat = false;
static final String nativeStreamMetadataFormatName = null;
static final String nativeStreamMetadataFormatClassName = null;
static final String[] extraStreamMetadataFormatNames = null;
static final String[] extraStreamMetadataFormatClassNames = null;
static final boolean supportsStandardImageMetadataFormat = true;
static final String nativeImageMetadataFormatName = "org.jnbis.imageio.WSQMetadata_1.0";
static final String nativeImageMetadataFormatClassName = "org.jnbis.imageio.WSQMetadataFormat";
static final String[] extraImageMetadataFormatNames = null;
static final String[] extraImageMetadataFormatClassNames = null;
public WSQImageWriterSpi() {
super(
vendorName,
version,
names,
suffixes,
MIMETypes,
writerClassName,
new Class[] { ImageOutputStream.class }, // Write to ImageOutputStreams
readerSpiNames,
supportsStandardStreamMetadataFormat,
nativeStreamMetadataFormatName,
nativeStreamMetadataFormatClassName,
extraStreamMetadataFormatNames,
extraStreamMetadataFormatClassNames,
supportsStandardImageMetadataFormat,
nativeImageMetadataFormatName,
nativeImageMetadataFormatClassName,
extraImageMetadataFormatNames,
extraImageMetadataFormatClassNames);
}
public boolean canEncodeImage(final ImageTypeSpecifier imageType) {
//Can encode any image, but it will be converted to grayscale.
return true;
//return imageType.getBufferedImageType() == BufferedImage.TYPE_BYTE_GRAY;
}
public ImageWriter createWriterInstance(final Object extension) throws IOException {
return new WSQImageWriter(this);
}
public String getDescription(final Locale locale) {
return "Wavelet Scalar Quantization (WSQ)";
}
}
| [
"[email protected]"
]
| |
78624e31792be599f2762ebcd67de0cde9193577 | f22209bfdc4a9c40f8e34686f8c0771e0cea2b94 | /src/main/java/com/rfb/repository/RfbUserRepositoryInternalImpl.java | f569c5f994b7d6b9f48dc28fc419725e64a82c3f | []
| no_license | yuchilai/rfb-loyalty | 87acabab88e860d43d7003cf62ffb22b254b7d2e | 72f2854d11e1f4794b9d68467d79ffd2fb131da6 | refs/heads/main | 2023-04-09T23:02:59.826246 | 2021-04-02T23:28:49 | 2021-04-02T23:28:49 | 352,770,770 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,796 | java | package com.rfb.repository;
import static org.springframework.data.relational.core.query.Criteria.where;
import static org.springframework.data.relational.core.query.Query.query;
import com.rfb.domain.RfbUser;
import com.rfb.repository.rowmapper.RfbLocationRowMapper;
import com.rfb.repository.rowmapper.RfbUserRowMapper;
import com.rfb.service.EntityManager;
import io.r2dbc.spi.Row;
import io.r2dbc.spi.RowMetadata;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.function.BiFunction;
import org.springframework.data.domain.Pageable;
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
import org.springframework.data.relational.core.query.Criteria;
import org.springframework.data.relational.core.sql.Column;
import org.springframework.data.relational.core.sql.Expression;
import org.springframework.data.relational.core.sql.Select;
import org.springframework.data.relational.core.sql.SelectBuilder.SelectFromAndJoinCondition;
import org.springframework.data.relational.core.sql.Table;
import org.springframework.r2dbc.core.DatabaseClient;
import org.springframework.r2dbc.core.RowsFetchSpec;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
* Spring Data SQL reactive custom repository implementation for the RfbUser entity.
*/
@SuppressWarnings("unused")
class RfbUserRepositoryInternalImpl implements RfbUserRepositoryInternal {
private final DatabaseClient db;
private final R2dbcEntityTemplate r2dbcEntityTemplate;
private final EntityManager entityManager;
private final RfbLocationRowMapper rfblocationMapper;
private final RfbUserRowMapper rfbuserMapper;
private static final Table entityTable = Table.aliased("rfb_user", EntityManager.ENTITY_ALIAS);
private static final Table homeLocationTable = Table.aliased("rfb_location", "homeLocation");
public RfbUserRepositoryInternalImpl(
R2dbcEntityTemplate template,
EntityManager entityManager,
RfbLocationRowMapper rfblocationMapper,
RfbUserRowMapper rfbuserMapper
) {
this.db = template.getDatabaseClient();
this.r2dbcEntityTemplate = template;
this.entityManager = entityManager;
this.rfblocationMapper = rfblocationMapper;
this.rfbuserMapper = rfbuserMapper;
}
@Override
public Flux<RfbUser> findAllBy(Pageable pageable) {
return findAllBy(pageable, null);
}
@Override
public Flux<RfbUser> findAllBy(Pageable pageable, Criteria criteria) {
return createQuery(pageable, criteria).all();
}
RowsFetchSpec<RfbUser> createQuery(Pageable pageable, Criteria criteria) {
List<Expression> columns = RfbUserSqlHelper.getColumns(entityTable, EntityManager.ENTITY_ALIAS);
columns.addAll(RfbLocationSqlHelper.getColumns(homeLocationTable, "homeLocation"));
SelectFromAndJoinCondition selectFrom = Select
.builder()
.select(columns)
.from(entityTable)
.leftOuterJoin(homeLocationTable)
.on(Column.create("home_location_id", entityTable))
.equals(Column.create("id", homeLocationTable));
String select = entityManager.createSelect(selectFrom, RfbUser.class, pageable, criteria);
String alias = entityTable.getReferenceName().getReference();
String selectWhere = Optional
.ofNullable(criteria)
.map(
crit ->
new StringBuilder(select)
.append(" ")
.append("WHERE")
.append(" ")
.append(alias)
.append(".")
.append(crit.toString())
.toString()
)
.orElse(select); // TODO remove once https://github.com/spring-projects/spring-data-jdbc/issues/907 will be fixed
return db.sql(selectWhere).map(this::process);
}
@Override
public Flux<RfbUser> findAll() {
return findAllBy(null, null);
}
@Override
public Mono<RfbUser> findById(Long id) {
return createQuery(null, where("id").is(id)).one();
}
private RfbUser process(Row row, RowMetadata metadata) {
RfbUser entity = rfbuserMapper.apply(row, "e");
entity.setHomeLocation(rfblocationMapper.apply(row, "homeLocation"));
return entity;
}
@Override
public <S extends RfbUser> Mono<S> insert(S entity) {
return entityManager.insert(entity);
}
@Override
public <S extends RfbUser> Mono<S> save(S entity) {
if (entity.getId() == null) {
return insert(entity);
} else {
return update(entity)
.map(
numberOfUpdates -> {
if (numberOfUpdates.intValue() <= 0) {
throw new IllegalStateException("Unable to update RfbUser with id = " + entity.getId());
}
return entity;
}
);
}
}
@Override
public Mono<Integer> update(RfbUser entity) {
//fixme is this the proper way?
return r2dbcEntityTemplate.update(entity).thenReturn(1);
}
}
class RfbUserSqlHelper {
static List<Expression> getColumns(Table table, String columnPrefix) {
List<Expression> columns = new ArrayList<>();
columns.add(Column.aliased("id", table, columnPrefix + "_id"));
columns.add(Column.aliased("username", table, columnPrefix + "_username"));
columns.add(Column.aliased("home_location_id", table, columnPrefix + "_home_location_id"));
return columns;
}
}
| [
"[email protected]"
]
| |
1cc74cf4521d0a13c90afbcb585ff4fe1c78e532 | 516568177d0c108ebd1787a8b4f373259c1a6f5a | /OnlineEyeClinic/src/main/java/com/g6/onlineeyecare/patient/controller/PatientController.java | 49ad30c19b2be1a6a6cac0da5479c671540cd71d | []
| no_license | samyuktha1599/Project | 479b15cb603ff88b41209bc4709907d97a42e355 | f2ebecf84a045ebe4d63fd6da71a50703f5ecec8 | refs/heads/main | 2023-05-09T02:25:24.917719 | 2021-05-31T16:49:59 | 2021-05-31T16:49:59 | 372,251,831 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,540 | java | package com.g6.onlineeyecare.patient.controller;
import java.util.List;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.g6.onlineeyecare.appointment.dto.Appointment;
import com.g6.onlineeyecare.exceptions.AppointmentIdNotFoundException;
import com.g6.onlineeyecare.exceptions.PatientIdFoundNotException;
import com.g6.onlineeyecare.patient.dto.Patient;
import com.g6.onlineeyecare.patient.service.IPatientService;
import com.g6.onlineeyecare.report.dto.Report;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@Validated
@Api(value = "Patient Rest Controller", description = "REST APIs related to Patient Entity!!!!")
@RestController
@RequestMapping("/patient")
public class PatientController {
@Autowired
IPatientService patientService;
@ApiOperation(value = "create a new Patient profile",response = Patient.class)
@PostMapping("/add")
public Patient addPatient(@RequestBody @Valid Patient patient) {
return this.patientService.addPatient(patient);
}
@ApiOperation(value = "Update your profile ",response = Patient.class)
@PutMapping("/update")
public Patient updatePatient(@RequestBody Patient patient) throws PatientIdFoundNotException {
return this.patientService.updatePatient(patient);
}
@ApiOperation(value = "Delete your profile ",response = Patient.class)
@DeleteMapping("/delete/{patientId}")
public Patient deletePatient(@PathVariable("patientId") int patientId) throws PatientIdFoundNotException
{
return this.patientService.deletePatient(patientId);
}
@ApiOperation(value = "view Patient profile by Id",response = Patient.class)
@GetMapping("/view/{patientId}")
public Patient viewPatient(@PathVariable("patientId") int patientId ) throws PatientIdFoundNotException {
return this.patientService.viewPatient(patientId);
}
@ApiOperation(value = "view list of Patients ",response = Patient.class)
@GetMapping("/viewPatientList")
public List<Patient> viewPatientList(){
return this.patientService.viewPatientList();
}
@ApiOperation(value = "Book appointment to consult the doctor",response = Appointment.class)
@PostMapping("/book")
public Appointment bookAppointment(@RequestBody Appointment appointment) {
return this.patientService.bookAppointment(appointment);
}
@ApiOperation(value = "Get the required appointment by Id ",response = Appointment.class)
@GetMapping("/viewAppointmentDetails/{appointmentId}")
public Appointment viewAppointmentDetails(@PathVariable("appointmentId") int appointmentid) throws AppointmentIdNotFoundException {
return this.patientService.viewAppointmentDetails(appointmentid);
}
@ApiOperation(value = "Get the required Report by patientId ",response = Report.class)
@GetMapping("/report/{patientId}")
public List<Report> viewReport(@PathVariable("patientId") int patientId) throws PatientIdFoundNotException {
return this.patientService.viewReport(patientId);
}
}
| [
"[email protected]"
]
| |
4e2fa47ec3c9b6f882a6ad263a6e3a6e9b37b8e9 | 63da595a4e74145e86269e74e46c98ad1c1bcad3 | /java/com/genscript/gsscm/epicorwebservice/stub/customer/Update.java | cd641b1d102a478355acca78743ee97fa14493bb | []
| no_license | qcamei/scm | 4f2cec86fedc3b8dc0f1cc1649e9ef3be687f726 | 0199673fbc21396e3077fbc79eeec1d2f9bd65f5 | refs/heads/master | 2020-04-27T19:38:19.460288 | 2012-09-18T07:06:04 | 2012-09-18T07:06:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,819 | java |
package com.genscript.gsscm.epicorwebservice.stub.customer;
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="CompanyID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="CustomerData" type="{http://epicor.com/schemas}CustomerDataSetType" minOccurs="0"/>
* <element name="continueProcessingOnError" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="callContextIn" type="{http://epicor.com/schemas}CallContextDataSetType" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"companyID",
"customerData",
"continueProcessingOnError",
"callContextIn"
})
@XmlRootElement(name = "Update")
public class Update {
@XmlElement(name = "CompanyID", namespace = "http://epicor.com/webservices/")
protected String companyID;
@XmlElement(name = "CustomerData", namespace = "http://epicor.com/webservices/")
protected CustomerDataSetType customerData;
@XmlElement(namespace = "http://epicor.com/webservices/")
protected boolean continueProcessingOnError;
@XmlElement(namespace = "http://epicor.com/webservices/")
protected CallContextDataSetType callContextIn;
/**
* Gets the value of the companyID property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCompanyID() {
return companyID;
}
/**
* Sets the value of the companyID property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCompanyID(String value) {
this.companyID = value;
}
/**
* Gets the value of the customerData property.
*
* @return
* possible object is
* {@link CustomerDataSetType }
*
*/
public CustomerDataSetType getCustomerData() {
return customerData;
}
/**
* Sets the value of the customerData property.
*
* @param value
* allowed object is
* {@link CustomerDataSetType }
*
*/
public void setCustomerData(CustomerDataSetType value) {
this.customerData = value;
}
/**
* Gets the value of the continueProcessingOnError property.
*
*/
public boolean isContinueProcessingOnError() {
return continueProcessingOnError;
}
/**
* Sets the value of the continueProcessingOnError property.
*
*/
public void setContinueProcessingOnError(boolean value) {
this.continueProcessingOnError = value;
}
/**
* Gets the value of the callContextIn property.
*
* @return
* possible object is
* {@link CallContextDataSetType }
*
*/
public CallContextDataSetType getCallContextIn() {
return callContextIn;
}
/**
* Sets the value of the callContextIn property.
*
* @param value
* allowed object is
* {@link CallContextDataSetType }
*
*/
public void setCallContextIn(CallContextDataSetType value) {
this.callContextIn = value;
}
}
| [
"[email protected]"
]
| |
3317480962fd6dbdc770e5b565107ea643dcd102 | c7b23b790d0bd8b340050d5b08e39f336f225ba9 | /Junit/src/main/java/com/tyss/junit/StringOperation.java | 668c2a1aeec1490232caa8a16d95b942b45adafd | []
| no_license | smalghate7867/ELF-06June19-TestYantra-ShubhamM | 6dc44a853d4f13144e2236de19d033df53214f2b | 0163386e6bbd604ca2046bc5b8450c4e6b9f4ea9 | refs/heads/master | 2023-01-10T06:42:06.307115 | 2019-07-31T13:29:35 | 2019-07-31T13:29:35 | 192,526,360 | 0 | 0 | null | 2023-01-07T07:54:26 | 2019-06-18T11:26:06 | Rich Text Format | UTF-8 | Java | false | false | 185 | java | package com.tyss.junit;
public class StringOperation {
public int count(String str) {
return str.length();
}
public String toUpcase(String str) {
return str.toUpperCase();
}
}
| [
"[email protected]"
]
| |
665c9bcb45fceb0bb9f2328c58b998e1349a075b | 5e7e00fd86114a1c87f5d37f25682204884ee53c | /proyecto/proyecto-EJB/src/main/java/co/edu/avanzada/negocio/excepciones/ExcepcionNegocio.java | 57551597da1a73ea6bd8bd4d2cc3f8435308d3a5 | []
| no_license | cristianh/proyectofinalbdavan | 724429ab65b13f27b41a0f48065181e3b03b2527 | 3db3d020f58bf3fc979dd949e7519938fb9b8427 | refs/heads/master | 2021-05-16T04:52:25.730112 | 2017-11-21T02:42:09 | 2017-11-21T02:42:09 | 106,214,500 | 0 | 0 | null | 2017-11-02T00:05:51 | 2017-10-08T22:30:56 | Java | UTF-8 | Java | false | false | 294 | java | package co.edu.avanzada.negocio.excepciones;
import javax.ejb.ApplicationException;
@ApplicationException(rollback=true)
public class ExcepcionNegocio extends RuntimeException {
/**
* COnstructor
* @param message
*/
public ExcepcionNegocio(String message) {
super(message);
}
}
| [
"[email protected]"
]
| |
1b9b6be0c4a05175e6b9e1b1b583c4c2ba3eb428 | cd3ccc969d6e31dce1a0cdc21de71899ab670a46 | /agp-7.1.0-alpha01/tools/base/build-system/integration-test/test-projects/parentLibsTest/lib1/src/androidTest/java/com/android/tests/libstest/lib1/MainActivityTest.java | 4d9cdeefd8910505f9b66727686f3ccbe067fb6a | [
"Apache-2.0"
]
| permissive | jomof/CppBuildCacheWorkInProgress | 75e76e1bd1d8451e3ee31631e74f22e5bb15dd3c | 9e3475f6d94cb3239f27ed8f8ee81b0abde4ef51 | refs/heads/main | 2023-05-28T19:03:16.798422 | 2021-06-10T20:59:25 | 2021-06-10T20:59:25 | 374,736,765 | 0 | 1 | Apache-2.0 | 2021-06-07T21:06:53 | 2021-06-07T16:44:55 | Java | UTF-8 | Java | false | false | 2,362 | java | /*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.tests.libstest.lib1;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import android.support.test.filters.MediumTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.widget.TextView;
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> rule = new ActivityTestRule<>(MainActivity.class);
private TextView mLib1TextView1;
private TextView mLib1TextView2;
@Before
public void setUp() {
final MainActivity a = rule.getActivity();
// ensure a valid handle to the activity has been returned
assertNotNull(a);
mLib1TextView1 = (TextView) a.findViewById(R.id.lib1_text1);
mLib1TextView2 = (TextView) a.findViewById(R.id.lib1_text2);
}
/**
* The name 'test preconditions' is a convention to signal that if this test doesn't pass, the
* test case was not set up properly and it might explain any and all failures in other tests.
* This is not guaranteed to run before other tests, as junit uses reflection to find the tests.
*/
@Test
@MediumTest
public void testPreconditions() {
assertNotNull(mLib1TextView1);
assertNotNull(mLib1TextView2);
}
@Test
@MediumTest
public void testAndroidStrings() {
assertEquals("SUCCESS-LIB1", mLib1TextView1.getText().toString());
}
@Test
@MediumTest
public void testJavaStrings() {
assertEquals("SUCCESS-LIB1", mLib1TextView2.getText().toString());
}
}
| [
"[email protected]"
]
| |
7d82f42b29803bbae51a5405b808ff5b33d8a344 | 0fe869ffd67841071ed397e9cf774c4e68e0a94a | /questions/src/main/java/com/google/interview/questions/parkinglot/ParkingLot.java | 01577d63357eadc04c3cde9252d53d3775c34a81 | []
| no_license | VijaySidhu/MasterRepository | e98b0694c1c0d4e6cd314991a8f2d2993ddb706e | 6a1c37530cedc15255d5682c9914eb88c439ef1a | refs/heads/master | 2021-01-13T02:23:24.711119 | 2018-05-10T04:46:40 | 2018-05-10T04:46:40 | 40,020,767 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,563 | java | package com.google.interview.questions.parkinglot;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class ParkingLot {
private static final int NUMBER_OF_SMALL_SLOTS = 10;
private static final int NUMBER_OF_COMPACT_SLOTS = 10;
private static final int NUMBER_OF_LARGE_SLOTS = 10;
public Map<Long, Slot> occupiedSlots;
private List<Slot> smallSlots;
private List<Slot> compactSlots;
private List<Slot> largeSlots;
public ParkingLot() {
smallSlots = new ArrayList(NUMBER_OF_SMALL_SLOTS);
compactSlots = new ArrayList(NUMBER_OF_COMPACT_SLOTS);
largeSlots = new ArrayList(NUMBER_OF_LARGE_SLOTS);
createSlots();
occupiedSlots = new HashMap();
}
private void createSlots() {
for (int i = 1; i <= NUMBER_OF_SMALL_SLOTS; i++) {
smallSlots.add(new SmallSlot(i));
}
for (int i = 1; i <= NUMBER_OF_COMPACT_SLOTS; i++) {
compactSlots.add(new CompactSlot(i));
}
for (int i = 1; i <= NUMBER_OF_LARGE_SLOTS; i++) {
largeSlots.add(new LargeSlot(i));
}
}
public long park(Vehicle vehicle) {
Slot slot;
long uniqueToken = -1;
if (vehicle instanceof Motorcycle) {
if ((slot = getFirstEmptySlot(smallSlots)) != null) {
uniqueToken = parkHelper(slot, vehicle);
} else if ((slot = getFirstEmptySlot(compactSlots)) != null) {
uniqueToken = parkHelper(slot, vehicle);
} else if ((slot = getFirstEmptySlot(largeSlots)) != null) {
uniqueToken = parkHelper(slot, vehicle);
}
} else if (vehicle instanceof Car) {
if ((slot = getFirstEmptySlot(compactSlots)) != null) {
uniqueToken = parkHelper(slot, vehicle);
} else if ((slot = getFirstEmptySlot(largeSlots)) != null) {
uniqueToken = parkHelper(slot, vehicle);
}
} else {
if ((slot = getFirstEmptySlot(largeSlots)) != null) {
uniqueToken = parkHelper(slot, vehicle);
}
}
return uniqueToken;
}
public void unPark(long uniqueToken) {
occupiedSlots.get(uniqueToken).unPark();
occupiedSlots.remove(uniqueToken);
}
private Slot getFirstEmptySlot(List<Slot> slots) {
Iterator<Slot> slotIterator = slots.iterator();
boolean isSlotFound = false;
Slot emptySlot = null;
while (slotIterator.hasNext() && !isSlotFound) {
emptySlot = slotIterator.next();
if (!emptySlot.isOccupied()) {
isSlotFound = true;
}
}
return emptySlot;
}
private long parkHelper(Slot slot, Vehicle vehicle) {
slot.park();
long uniqueToken = vehicle.hashCode() * 43;
occupiedSlots.put(uniqueToken, slot);
return uniqueToken;
}
}
| [
"[email protected]"
]
| |
e420c3b6edd11a4491ddc1d7d1ef2953fdc188ce | 1fa429510589c77dd920910a38c5f8ece2a936b9 | /fullsample/src/main/java/com/yashoid/mmv/fullsample/Basics.java | fa689684b923834d7855420a5d80afee0e2caab8 | []
| no_license | yasharpm/MMV | 55f952f991c4edfcd5754b28a3cb785c195b6d61 | 4bc8991574ab468870493a5803a8062d2a7e1a9b | refs/heads/master | 2020-06-01T05:35:29.919328 | 2020-04-27T12:40:29 | 2020-04-27T12:40:29 | 190,657,871 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 93 | java | package com.yashoid.mmv.fullsample;
public interface Basics {
String TYPE = "type";
}
| [
"[email protected]"
]
| |
6dcd2178647e0c151dfff6bf987d0b6c13ea50a7 | e7e046284f7de71d514e8f19afa1ce0efa0d90e1 | /src/main/java/com/wangtao/dbhelper/datasource/PoolDataSource.java | 68c601f3867856003994131a296d7f0d901f6158 | []
| no_license | wangtaoj/DbHelper | cae1ffcbe6d08387b0ad1837859d8ab61a53d370 | 83d1b02ccfa4e17cbf16dbca91208c0de11a3aaf | refs/heads/master | 2020-04-12T14:14:33.149097 | 2019-02-28T07:18:25 | 2019-02-28T07:18:25 | 162,546,378 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 6,807 | java | package com.wangtao.dbhelper.datasource;
import com.wangtao.dbhelper.logging.Log;
import com.wangtao.dbhelper.logging.LogFactory;
import javax.sql.DataSource;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.Properties;
/**
* Created by wangtao at 2018/12/24 16:45
*/
public class PoolDataSource implements DataSource {
private static Log logger = LogFactory.getLogger(PoolDataSource.class);
private SimpleDataSource dataSource;
/**
* 最大连接数量
*/
private int maxSize = 20;
/**
* 是否已初始化
**/
private boolean flag;
/**
* 初始数量
*/
private int initSize = 5;
/**
* 最大空闲数量
*/
private int maxIdleSize = 10;
/**
* 从池中获取连接的最大等待时间, 默认10秒
*/
private int maxWaitTime = 10000;
/**
* 保存空闲连接
*/
private LinkedList<PoolConnection> idleConnections = new LinkedList<>();
/**
* 活动连接数量
**/
private int activeSize;
public PoolDataSource() {
}
public PoolDataSource(String driver, String url, String username, String password) {
this.dataSource = new SimpleDataSource(driver, url, username, password);
}
public PoolDataSource(Properties properties) {
this.dataSource = new SimpleDataSource(properties);
}
/**
* 返回一个PoolConnection对象
* @param username 用户名
* @param password 密码
* @return connection
*/
private PoolConnection wrapConnection(String username, String password) throws SQLException {
Connection connection = dataSource.getConnection(username, password);
if (logger.isDebugEnabled()) {
logger.debug("Opening connection[" + connection.hashCode() + "].");
}
return new PoolConnection(connection, this);
}
public synchronized void initConnection() {
if (initSize > maxIdleSize) {
throw new DataSourceException(String.format("初始连接数量(%d)大于最大空闲数量(%d)", initSize, maxIdleSize));
}
try {
for (int i = 0; i < initSize; i++) {
idleConnections.addFirst(wrapConnection(dataSource.getUsername(), dataSource.getPassword()));
}
} catch (SQLException e) {
throw new DataSourceException("初始化连接失败. 原因:" + e);
}
if (logger.isDebugEnabled()) {
logger.debug("The connection pool have already initialize " + initSize + " connections.");
}
}
public synchronized Connection popConnection(String username, String password) throws SQLException {
PoolConnection connection = null;
// 初始连接数量
if (!flag) {
initConnection();
flag = true;
}
// 有空闲连接, 直接返回
if (idleConnections.size() > 0) {
activeSize++;
connection = idleConnections.removeLast();
} else if (activeSize + idleConnections.size() < maxSize) {
// 没有达到最大连接, 创建新连接
connection = wrapConnection(username, password);
activeSize++;
} else {
long beforeTime = System.currentTimeMillis();
while (System.currentTimeMillis() - beforeTime < maxWaitTime) {
if (idleConnections.size() > 0) {
activeSize++;
connection = idleConnections.removeLast();
break;
}
}
}
if (connection != null) {
return connection.getProxyConnection();
}
throw new DataSourceException("获取连接失败, 已经达到最大等待时间, 没有空闲连接可用");
}
/**
* 将连接放到连接池中
* @param connection PoolConnection
*/
public synchronized void pushConnection(PoolConnection connection) throws SQLException {
if (idleConnections.size() < maxIdleSize) {
idleConnections.addLast(connection);
activeSize--;
if (logger.isDebugEnabled()) {
logger.debug("Connection[" + connection.getRealConnection().hashCode() +
"] is returned the connection pool.");
}
} else {
Connection realConection = connection.getRealConnection();
realConection.close();
if (logger.isDebugEnabled()) {
logger.debug("Connection[" + realConection.hashCode() + "] is closed.");
}
}
}
/**
* 关闭所有连接
*/
public synchronized void forceClose() throws SQLException{
for(PoolConnection connection : idleConnections) {
connection.getRealConnection().close();
}
idleConnections.clear();
activeSize = 0;
}
@Override
public Connection getConnection() throws SQLException {
return getConnection(dataSource.getUsername(), dataSource.getPassword());
}
@Override
public Connection getConnection(String username, String password) throws SQLException {
return popConnection(username, password);
}
public SimpleDataSource getDataSource() {
return dataSource;
}
public void setDataSource(SimpleDataSource dataSource) {
this.dataSource = dataSource;
}
public int getMaxSize() {
return maxSize;
}
public void setMaxSize(int maxSize) {
this.maxSize = maxSize;
}
public int getInitSize() {
return initSize;
}
public void setInitSize(int initSize) {
this.initSize = initSize;
}
public int getMaxIdleSize() {
return maxIdleSize;
}
public void setMaxIdleSize(int maxIdleSize) {
this.maxIdleSize = maxIdleSize;
}
public int getMaxWaitTime() {
return maxWaitTime;
}
public void setMaxWaitTime(int maxWaitTime) {
this.maxWaitTime = maxWaitTime;
}
@Override
public <T> T unwrap(Class<T> iface) {
return null;
}
@Override
public boolean isWrapperFor(Class<?> iface) {
return false;
}
@Override
public PrintWriter getLogWriter() {
return null;
}
@Override
public void setLogWriter(PrintWriter out) {
}
@Override
public void setLoginTimeout(int seconds) {
DriverManager.setLoginTimeout(seconds);
}
@Override
public int getLoginTimeout() {
return DriverManager.getLoginTimeout();
}
@Override
public java.util.logging.Logger getParentLogger() {
return null;
}
}
| [
"[email protected]"
]
| |
ec1a3c86cb7812abd9a0b7829bd662fc8daff6bc | 3ac20f01b64d23bda2a0069925a528d85da39d4c | /homework21/src/by/gerasimchik/Main.java | ca0b09940a3eb4437279366bb12b28762968d11c | []
| no_license | pavelgerasimchik20/homework-first-repository | b95f7828e6f439811d814b76732ea3f8ea58bdd8 | c6bb514cc2ab98428ad05378fab2e0da655518a0 | refs/heads/master | 2022-04-12T17:43:34.199473 | 2020-04-07T17:43:24 | 2020-04-07T17:43:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 909 | java | package by.gerasimchik;
public class Main {
static double t, t1 = 0, t2 = 0;
static String str = "1 java forever ";
static int n = 2;
public static void main(String[] args) {
StringBuilder stringBuilder = new StringBuilder(str);
for (int i = 0; i < 99; i++) {
t = System.currentTimeMillis();
str += n + " java forever ";
n++;
t1 += System.currentTimeMillis() - t;
}
int n = 2;
for (int i = 0; i < 99; i++) {
t = System.currentTimeMillis();
stringBuilder.append(n + " java forever ");
n++;
t2 += System.currentTimeMillis() - t;
}
System.out.println(str);
System.out.println("String execution speed: " + t1);
System.out.println(stringBuilder);
System.out.println("StringBuilder execution speed: " + t2);
}
}
| [
"[email protected]"
]
| |
76d808033f27f47b7e2a6c4c47f9c028a1740332 | 747092f51d699265ec9fc002b59cc87c8f7514be | /MicroService_V008/auth-server/src/main/java/com/wathsala/microService/authserver/conf/AuthServerConfiguration.java | 5ddce47b7db9d8cf51a227d3d0c6b9b51b3aa299 | []
| no_license | Rasanjalee/Micro-Service-Full-Project | 573d205e27266550bdcf67d06437297e17022757 | e3aea78e72b12cf3e313a147edb524151b99d40f | refs/heads/master | 2023-03-10T14:20:51.132783 | 2021-02-16T04:07:01 | 2021-02-16T04:07:01 | 338,785,974 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,103 | java | package com.wathsala.microService.authserver.conf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
/**
* @author acer on 2/10/2021
*/
@Configuration
public class AuthServerConfiguration extends WebSecurityConfigurerAdapter implements AuthorizationServerConfigurer {
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Autowired
AuthenticationManager authenticationManager;
PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
security.checkTokenAccess("permitAll()");
}
@Override
public void configure(ClientDetailsServiceConfigurer client) throws Exception {
client.inMemory().withClient("web").secret(passwordEncoder.encode("webpass")).scopes("READ","WRITE").authorizedGrantTypes("password","authorization_code");
}
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoint) throws Exception {
endpoint.authenticationManager(authenticationManager);
}
}
| [
"[email protected]"
]
| |
533e4cf2a6777b6c2088715b932c647b9826f493 | 7b70e1a68e1c7302800c33d05e527eb262ec07ca | /facebook/src/main/java/net/bbridge/crawler/facebook/entities/User.java | 178115f961eed60f2d614c6716327b5d6a4510f6 | []
| no_license | kburaya/multi-source-crawler | 645877e1fc735329392d611886502691859eb169 | ab0aacfa2e1e7b8795a0ca2d64f7cf2103679ee3 | refs/heads/master | 2021-05-15T23:24:11.616669 | 2017-10-20T11:44:28 | 2017-10-20T11:44:28 | 106,796,928 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 424 | java | package net.bbridge.crawler.facebook.entities;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class User {
private Long id;
private String username;
private String email;
private List<Post> posts;
public User(long id) {
this.id = id;
}
public User(long id, String username) {
this.id = id;
this.username = username;
}
}
| [
"[email protected]"
]
| |
26df20cef729c6529b08c1e392c8072fd1353da1 | 9a79cfaf757b40bda426d9c53bc660c031e05403 | /src/objConverter/Vertex.java | 1b45f9694df7c50a304120ff0f0f013ea5272ab3 | []
| no_license | swd3e2/gameEngine | 63c923f0e10cb4ca21d17bd04baabd309b7afa33 | 758ebde88b6da69a3335581d94153cd6e039bd3a | refs/heads/master | 2020-03-19T19:16:36.872965 | 2018-07-19T18:27:43 | 2018-07-19T18:27:43 | 136,847,950 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,474 | java | package objConverter;
import org.joml.Vector3f;
public class Vertex {
private static final int NO_INDEX = -1;
private Vector3f position;
private int textureIndex = NO_INDEX;
private int normalIndex = NO_INDEX;
private Vertex duplicateVertex = null;
private int index;
private float length;
public Vertex(int index,Vector3f position){
this.index = index;
this.position = position;
this.length = position.length();
}
public int getIndex(){
return index;
}
public float getLength(){
return length;
}
public boolean isSet(){
return textureIndex!=NO_INDEX && normalIndex!=NO_INDEX;
}
public boolean hasSameTextureAndNormal(int textureIndexOther,int normalIndexOther){
return textureIndexOther==textureIndex && normalIndexOther==normalIndex;
}
public void setTextureIndex(int textureIndex){
this.textureIndex = textureIndex;
}
public void setNormalIndex(int normalIndex){
this.normalIndex = normalIndex;
}
public Vector3f getPosition() {
return position;
}
public int getTextureIndex() {
return textureIndex;
}
public int getNormalIndex() {
return normalIndex;
}
public Vertex getDuplicateVertex() {
return duplicateVertex;
}
public void setDuplicateVertex(Vertex duplicateVertex) {
this.duplicateVertex = duplicateVertex;
}
} | [
"[email protected]"
]
| |
1807d5fe2272dfb04f3e26692e97deb951cdfe8b | 20eb62855cb3962c2d36fda4377dfd47d82eb777 | /newEvaluatedBugs/Jsoup_38_buggy/mutated/188/CharacterReader.java | 1f70e3dc7b49e3f5841233fc7a2ac0396d97969d | []
| no_license | ozzydong/CapGen | 356746618848065cce4e253e5d3c381baa85044a | 0ba0321b6b1191443276021f1997833342f02515 | refs/heads/master | 2023-03-18T20:12:02.923428 | 2020-08-21T03:08:28 | 2020-08-21T03:08:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,350 | java | package org.jsoup.parser;
import org.jsoup.helper.Validate;
import java.util.Locale;
/**
CharacterReader consumes tokens off a string. To replace the old TokenQueue.
*/
class CharacterReader {
static final char EOF = (char) -1;
private final char[] input;
private final int length;
private int pos = 0;
private int mark = 0;
CharacterReader(String input) {
Validate.notNull(input);
this.input = input.toCharArray();
this.length = this.input.length;
}
int pos() {
return pos;
}
boolean isEmpty() {
return pos >= length;
}
char current() {
return isEmpty() ? EOF : input[pos];
}
char consume() {
char val = isEmpty() ? EOF : input[pos];
pos++;
return val;
}
void unconsume() {
pos--;
}
void advance() {
pos++;
}
void mark() {
mark = pos;
}
void rewindToMark() {
pos = mark;
}
String consumeAsString() {
return new String(input, pos++, 1);
}
/**
* Returns the number of characters between the current position and the next instance of the input char
* @param c scan target
* @return offset between current position and next instance of target. -1 if not found.
*/
int nextIndexOf(char c) {
// doesn't handle scanning for surrogates
for (int i = pos; i < length; i++) {
if (c == input[i])
return i - pos;
}
return -1;
}
/**
* Returns the number of characters between the current position and the next instance of the input sequence
*
* @param seq scan target
* @return offset between current position and next instance of target. -1 if not found.
*/
int nextIndexOf(CharSequence seq) {
// doesn't handle scanning for surrogates
char startChar = seq.charAt(0);
for (int offset = pos; offset < length; offset++) {
// scan to first instance of startchar:
if (startChar != input[offset])
while(++offset < length && startChar != input[offset]);
if (offset < length) {
int i = offset + 1;
int last = i + seq.length()-1;
for (int j = 1; i < last && seq.charAt(j) == input[i]; i++, j++);
if (i == last) // found full sequence
return offset - pos;
}
}
return -1;
}
String consumeTo(char c) {
int offset = nextIndexOf(c);
if (offset != -1) {
String consumed = new String(input, pos, offset);
pos += offset;
return consumed;
} else {
return consumeToEnd();
}
}
String consumeTo(String seq) {
int offset = nextIndexOf(seq);
if (offset != -1) {
String consumed = new String(input, pos, offset);
pos += offset;
return consumed;
} else {
return consumeToEnd();
}
}
String consumeToAny(final char... chars) {
int start = pos;
OUTER: while (pos < length) {
for (int i = 0; i < chars.length; i++) {
if (input[pos] == chars[i])
break OUTER;
}
pos++;
}
return pos > start ? new String(input, start, pos-start) : "";
}
String consumeToEnd() {
String data = new String(input, pos, length-pos);
pos = length;
return data;
}
String consumeLetterSequence() {
int start = pos;
while (pos < length) {
char c = input[pos];
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
pos++;
else
break;
}
return new String(input, start, pos - start);
}
String consumeLetterThenDigitSequence() {
int start = pos;
while (pos < length) {
char c = input[pos];
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
pos++;
else
break;
}
while (!isEmpty()) {
char c = input[pos];
if ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z') && c <= '9')
pos++;
else
break;
}
return new String(input, start, pos - start);
}
String consumeHexSequence() {
int start = pos;
while (pos < length) {
char c = input[pos];
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'))
pos++;
else
break;
}
return new String(input, start, pos - start);
}
String consumeDigitSequence() {
int start = pos;
while (pos < length) {
char c = input[pos];
if (c >= '0' && c <= '9')
pos++;
else
break;
}
return new String(input, start, pos - start);
}
boolean matches(char c) {
return !isEmpty() && input[pos] == c;
}
boolean matches(String seq) {
int scanLength = seq.length();
if (scanLength > length - pos)
return false;
for (int offset = 0; offset < scanLength; offset++)
if (seq.charAt(offset) != input[pos+offset])
return false;
return true;
}
boolean matchesIgnoreCase(String seq) {
int scanLength = seq.length();
if (scanLength > length - pos)
return false;
for (int offset = 0; offset < scanLength; offset++) {
char upScan = Character.toUpperCase(seq.charAt(offset));
char upTarget = Character.toUpperCase(input[pos + offset]);
if (upScan != upTarget)
return false;
}
return true;
}
boolean matchesAny(char... seq) {
if (isEmpty())
return false;
char c = input[pos];
for (char seek : seq) {
if (seek == c)
return true;
}
return false;
}
boolean matchesLetter() {
if (isEmpty())
return false;
char c = input[pos];
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
}
boolean matchesDigit() {
if (isEmpty())
return false;
char c = input[pos];
return (c >= '0' && c <= '9');
}
boolean matchConsume(String seq) {
if (matches(seq)) {
pos += seq.length();
return true;
} else {
return false;
}
}
boolean matchConsumeIgnoreCase(String seq) {
if (matchesIgnoreCase(seq)) {
pos += seq.length();
return true;
} else {
return false;
}
}
boolean containsIgnoreCase(String seq) {
// used to check presence of </title>, </style>. only finds consistent case.
String loScan = seq.toLowerCase(Locale.ENGLISH);
String hiScan = seq.toUpperCase(Locale.ENGLISH);
return (nextIndexOf(loScan) > -1) || (nextIndexOf(hiScan) > -1);
}
@Override
public String toString() {
return new String(input, pos, length - pos);
}
}
| [
"[email protected]"
]
| |
9b56c898082832afa974a09783d3c69550f27cad | e052fe3b587528510c01f5700fd9517ce80b7610 | /src/test/java/io/zipcoder/interfaces/TestStudent.java | 648f797f2665fb1c636db024e3deb8ca74a45cd8 | []
| no_license | ZCW-Java6dot2/learner-lab-NikkiaOwens | 786b219bceeb5fb789ee722dcf4bbef38b9fbcfc | c08002be7c3a0b1be0a0e0a3373301f118500cb6 | refs/heads/feat/TC-Mesolab-Interfaces-1 | 2023-01-19T09:08:56.044902 | 2020-11-30T23:06:31 | 2020-11-30T23:06:31 | 314,952,981 | 0 | 0 | null | 2020-11-22T03:41:22 | 2020-11-22T03:40:56 | Java | UTF-8 | Java | false | false | 880 | java | package io.zipcoder.interfaces;
import org.junit.Assert;
import org.junit.Test;
public class TestStudent {
@Test
public void instanceLearnerTest(){
//Given
Student student = new Student();
//When
//Then
Assert.assertTrue(student instanceof Learner);
}
@Test
public void inheritanceTest(){
//Given
Student student = new Student();
Person person = new Person();
//When
//Then
Assert.assertTrue(student instanceof Person);
}
@Test
public void learnTest(){
//Given
Student student = new Student();
//Person person = new Person();
Double expected = 10.0;
//When
student.learn(expected);
Double actual = student.getTotalStudyTime();
//Then
Assert.assertEquals(expected, actual);
}
}
| [
"[email protected]"
]
| |
1691aceb5bb1c145911e9e9301d2326f05ff239a | 8c45f02145b1b834f98f9371eac5caff82021b99 | /src/rene/gui/CheckboxMenu.java | 860af8aed66dae0749e374dd07cba41e8d6752af | []
| no_license | nadihighlander/GeometryUI | ccddad9d5317039a9765b7e266e8ff4eff120f10 | 122f20b027d1656f177e390eb5fc7d510e2b13ad | refs/heads/master | 2023-07-17T11:07:49.040377 | 2017-08-22T17:07:02 | 2017-08-22T17:07:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,426 | java | /*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
C.a.R. is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.gui;
import java.awt.CheckboxMenuItem;
import java.util.Vector;
class CheckboxMenuElement {
public String Tag;
public CheckboxMenuItem Item;
public CheckboxMenuElement(final CheckboxMenuItem i, final String tag) {
Item = i;
Tag = tag;
}
}
public class CheckboxMenu {
Vector V;
public CheckboxMenu() {
V = new Vector();
}
public void add(final CheckboxMenuItem i, final String tag) {
V.addElement(new CheckboxMenuElement(i, tag));
}
public void set(final String tag) {
int i;
for (i = 0; i < V.size(); i++) {
final CheckboxMenuElement e = (CheckboxMenuElement) V.elementAt(i);
if (tag.equals(e.Tag))
e.Item.setState(true);
else
e.Item.setState(false);
}
}
}
| [
"[email protected]"
]
| |
8e7f473e5440b3a868522bb388ebf445bde4d209 | 6d27d20e6b0c95a073d85cba609fe1ecc95835c8 | /src/main/java/com/gautam/service/EmployeeManagementServiceImpl.java | 4475a0268d85a841d15e28d4b49b799653d64f97 | []
| no_license | gtmb007/Spring-Hibernate | d49111ae4e33f04bd195ddd652b1c9658aa86ce7 | 037689b887d86122fa10ece890004c84af4abe3c | refs/heads/master | 2022-12-15T08:55:34.290499 | 2020-08-12T11:16:06 | 2020-08-12T11:16:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,261 | java | package com.gautam.service;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gautam.dao.EmployeeManagementDAO;
import com.gautam.model.Employee;
@Service("employeeService")
public class EmployeeManagementServiceImpl implements EmployeeManagementService {
@Autowired
EmployeeManagementDAO employeeDao;
public Integer addEmployee(Employee emp) throws Exception {
Integer empId=employeeDao.addEmployee(emp);
if(empId==null) throw new Exception("Employee Not Added");
return empId;
}
public Integer deleteEmployee(Integer empId) throws Exception {
Integer id=employeeDao.deleteEmployee(empId);
if(id==null) throw new Exception("Employee Not Deleted");
return id;
}
public Integer updateEmployee(Integer empId, Employee newEmp) throws Exception {
Integer id=employeeDao.updateEmployee(empId, newEmp);
if(id==null) throw new Exception("Employee Not Update");
return empId;
}
public Optional<Employee> getEmployee(Integer empId) throws Exception {
return employeeDao.getEmployee(empId);
}
public Optional<List<Employee>> getEmployees() throws Exception {
return employeeDao.getEmployees();
}
}
| [
"[email protected]"
]
| |
efa845b013fbd8930abe60e6087932e3dfc5a39d | 9b0585719161977e5c220b9da6352bb8f485d919 | /Trunk/Tablet/src/com/example/tablet/Splash.java | 79f786c1a96aad84c934420064458a318ab002b9 | []
| no_license | Henri1992/AndroidRepo | b1c64a789c297bcd0bac03891d9254c5e97ab93f | 006400bf5dea4f683a3e6f27cfb053f515197c4b | refs/heads/master | 2020-04-06T03:43:23.702789 | 2013-06-21T19:02:20 | 2013-06-21T19:02:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 891 | java | package com.example.tablet;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
public class Splash extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Handler x = new Handler();
x.postDelayed(new SplashHandler(), 4000);
}
class SplashHandler implements Runnable {
public void run() {
startActivity(new Intent(getApplication(), Main.class));
Splash.this.finish();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
| [
"[email protected]"
]
| |
98321d3b76242141a44eaf63b7e07126fd9d205f | 960c99902ce313a6198033564c9ae000c5e151bc | /src/main/java/com/hxgis/model/geojson/geometry/GeoGeometryMultiLineString.java | ede94ad2e4e88a3e0c7a23c095e751c005ce8874 | []
| no_license | GitHubLiHong/ReadGrb2FileToDb | d8195e925dfc559cf749d2f086ee69f211b72d30 | ca22efdac0a0739a5121a4cd65981129252ca5e2 | refs/heads/master | 2020-03-18T18:49:10.988122 | 2018-05-30T11:42:44 | 2018-05-30T11:42:44 | 135,116,787 | 1 | 5 | null | null | null | null | UTF-8 | Java | false | false | 520 | java | package com.hxgis.model.geojson.geometry;
import com.hxgis.model.geojson.GeoType;
import java.util.List;
public class GeoGeometryMultiLineString extends GeoGeometry {
public GeoGeometryMultiLineString() {
this.type = GeoType.GEO_MULTILINESTRING;
}
private List<List<double[]>> coordinates;
public List<List<double[]>> getCoordinates() {
return coordinates;
}
public void setCoordinates(List<List<double[]>> coordinates) {
this.coordinates = coordinates;
}
}
| [
"[email protected]"
]
| |
98d7fb7487e2756b6b79d38635ea571273c255a3 | bae054872928da61aa524b7d72704611ffa5551b | /src/main/java/mashibing/algorithm/class23/Code03_NQueens.java | 489f70666f7c83116acc6c51460457440ae6dd4c | []
| no_license | gitHubAction/learn | 9e5125d78e0c9010973558cb6c747cb6aad51231 | 51f934d1a98a85f0c804264fba0fd3d05cf23920 | refs/heads/master | 2023-04-07T21:21:34.073441 | 2023-03-16T09:17:05 | 2023-03-16T09:17:05 | 243,207,432 | 5 | 1 | null | 2022-12-16T05:15:44 | 2020-02-26T08:19:07 | Java | UTF-8 | Java | false | false | 2,418 | java | package mashibing.algorithm.class23;
public class Code03_NQueens {
public static int num1(int n) {
if (n < 1) {
return 0;
}
int[] record = new int[n];
return process1(0, record, n);
}
// 当前来到i行,一共是0~N-1行
// 在i行上放皇后,所有列都尝试
// 必须要保证跟之前所有的皇后不打架
// int[] record record[x] = y 之前的第x行的皇后,放在了y列上
// 返回:不关心i以上发生了什么,i.... 后续有多少合法的方法数
public static int process1(int i, int[] record, int n) {
if (i == n) {
return 1;
}
int res = 0;
// i行的皇后,放哪一列呢?j列,
for (int j = 0; j < n; j++) {
if (isValid(record, i, j)) {
record[i] = j;
res += process1(i + 1, record, n);
}
}
return res;
}
public static boolean isValid(int[] record, int i, int j) {
// 0..i-1
for (int k = 0; k < i; k++) {
if (j == record[k] || Math.abs(record[k] - j) == Math.abs(i - k)) {
return false;
}
}
return true;
}
// 请不要超过32皇后问题
public static int num2(int n) {
if (n < 1 || n > 32) {
return 0;
}
// 如果你是13皇后问题,limit 最右13个1,其他都是0
int limit = n == 32 ? -1 : (1 << n) - 1;
return process2(limit, 0, 0, 0);
}
// 7皇后问题
// limit : 0....0 1 1 1 1 1 1 1
// 之前皇后的列影响:colLim
// 之前皇后的左下对角线影响:leftDiaLim
// 之前皇后的右下对角线影响:rightDiaLim
public static int process2(int limit, int colLim, int leftDiaLim, int rightDiaLim) {
if (colLim == limit) {
return 1;
}
// pos中所有是1的位置,是你可以去尝试皇后的位置
int pos = limit & (~(colLim | leftDiaLim | rightDiaLim));
int mostRightOne = 0;
int res = 0;
while (pos != 0) {
mostRightOne = pos & (~pos + 1);
pos = pos - mostRightOne;
res += process2(limit, colLim | mostRightOne, (leftDiaLim | mostRightOne) << 1,
(rightDiaLim | mostRightOne) >>> 1);
}
return res;
}
public static void main(String[] args) {
int n = 15;
long start = System.currentTimeMillis();
System.out.println(num2(n));
long end = System.currentTimeMillis();
System.out.println("cost time: " + (end - start) + "ms");
start = System.currentTimeMillis();
System.out.println(num1(n));
end = System.currentTimeMillis();
System.out.println("cost time: " + (end - start) + "ms");
}
}
| [
"[email protected]"
]
| |
3991ed73e3c342ab25a780f355557c4c52c79d15 | 9e58b039296146681346f6c6b6a2cf1810c2a916 | /server/blog-sso/src/main/java/org/sangaizhi/blog/sso/controller/LoginController.java | ddfeb6caa63a53ad5d26cb84b5e9a90ea79c0d6f | []
| no_license | sangaizhi/sazlog | bd7eeebaf0141cfb766c79f2ee06e0536e7bcc78 | eab5288351cefd2f70cc282c3b69c464529e16a1 | refs/heads/master | 2021-09-01T18:56:13.417395 | 2017-12-28T10:16:28 | 2017-12-28T10:16:28 | 115,571,165 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,684 | java | package org.sangaizhi.blog.sso.controller;
import org.apache.commons.lang3.StringUtils;
import org.sangaizhi.blog.sso.service.LoginService;
import org.sangaizhi.common.constant.ResponseResult;
import org.sangaizhi.common.constant.SystemConstant;
import org.sangaizhi.common.util.CookieUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author sangaizhi
* @date 2017/8/26
*/
@Controller
public class LoginController {
@Autowired
private LoginService loginService;
@RequestMapping(value = "/login", method = RequestMethod.POST, produces = {"application/json;charset=utf8"})
@ResponseBody
public ResponseResult login(String account, String password, String redirectUrl, HttpServletRequest request, HttpServletResponse response){
if(StringUtils.isBlank(account) || StringUtils.isBlank(password)) {
return ResponseResult.fail("账号或密码不能为空");
}
ResponseResult responseResult = loginService.login(account, password);
if(!responseResult.getStatus()){
return responseResult;
}
String token = (String) responseResult.getData();
CookieUtils.setCookie(request, response, SystemConstant.USER_TOKEN_COOKIE_KEY, token);
return responseResult;
}
}
| [
"[email protected]"
]
| |
e7ea480aa3fa31048384c0e6298a39b886e942ef | 1cd287d115c521440fec10581c101181d5e9028e | /src/main/java/com/demoshop/demoshop/config/StaticResourceConfiguration.java | 3d0f26bbec16debb9d9a011c5a8ff2c651784be2 | []
| no_license | GhostOfCode/SurfShop | 24e9dcbfc5189ff600e9cd8cb63a5d77b8a5f2b5 | 6c0d4b1ef5e5497a8bf1951b16994fac7eec8d16 | refs/heads/main | 2023-08-12T19:31:57.172231 | 2021-10-13T18:52:29 | 2021-10-13T18:52:29 | 416,728,628 | 0 | 0 | null | 2021-10-13T18:52:30 | 2021-10-13T12:14:31 | JavaScript | UTF-8 | Java | false | false | 791 | java | //package com.demoshop.demoshop.config;
//
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//
//@Configuration
//public class StaticResourceConfiguration implements WebMvcConfigurer {
//
// @Override
// public void addResourceHandlers(ResourceHandlerRegistry registry) {
// registry
// .addResourceHandler("/styles/**")
// .addResourceLocations("/styles/")
// .setCachePeriod(3600)
// .resourceChain(true);
//// .addResolver(new GzipResourceResolver())
//// .addResolver(new PathResourceResolver());
// }
//}
| [
"[email protected]"
]
| |
88b8e1e55f7983b7890bbcbc11acfb09f27d5591 | 309c3db61303320ad1b794fa9217a914a5add827 | /target/news/WEB-INF/classes/service/NewsService.java | 69138c4384869a3eb142100978f7ecaa01d79c9b | []
| no_license | exercise1/exercise1 | 832185d1f673077bcc3fc5d520d17a7c9eb3e43b | c15a24e17d58f625480a116d00d1c55641d79461 | refs/heads/master | 2020-03-28T13:59:45.195158 | 2018-09-14T10:04:59 | 2018-09-14T10:04:59 | 148,449,170 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,687 | java | package service;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import tools.PageInformation;
import tools.Tool;
import tools.WebProperties;
import dao.DatabaseDao;
import dao.NewsDao;
import dao.NewsDao;
import bean.News;
import bean.News;
public class NewsService {
public Integer add(News news){
try {
DatabaseDao databaseDao=new DatabaseDao();
NewsDao newsDao=new NewsDao();
return newsDao.add( news, databaseDao);
} catch (SQLException e) {
e.printStackTrace();
return -1;
} catch (Exception e) {
e.printStackTrace();
return -2;
}
}
public List<News> getOnePage(PageInformation pageInformation) {
List<News> newses=new ArrayList<News>();
try {
DatabaseDao databaseDao=new DatabaseDao();
NewsDao newsDao=new NewsDao();
newses=newsDao.getOnePage(pageInformation,databaseDao);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return newses;
}
public News getNewsById(Integer newsId){
NewsDao newsDao=new NewsDao();
try {
return newsDao.getById(newsId);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
//删除多条记录
public List<News> deletes(PageInformation pageInformation) {
List<News> newses=null;
try {
DatabaseDao databaseDao=new DatabaseDao();
NewsDao newsDao=new NewsDao();
newsDao.deletes(pageInformation.getTableName(),pageInformation.getIds(),databaseDao);
pageInformation.setIds(null);
newses=newsDao.getOnePage(pageInformation,databaseDao);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return newses;
}
public List<List<News>> getByTypesTopN(String[] newsTypes, Integer n){
List<List<News>> newsesList=new ArrayList<List<News>>();
try {
DatabaseDao databaseDao=new DatabaseDao();
NewsDao newsDao=new NewsDao();
for(String type: newsTypes){
List<News> newses=newsDao.getByTypesTopN(type, n, databaseDao);
newsesList.add(newses);
}
} catch (SQLException e) {
e.printStackTrace();
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
return newsesList;
}
public List<List<News>> getByTypesTopN1(String[] newsTypes, Integer n,List<List<String>> newsCaptionsList){
List<List<News>> newsesList=new ArrayList<List<News>>();
try {
DatabaseDao databaseDao=new DatabaseDao();
NewsDao newsDao=new NewsDao();
for(String type: newsTypes){
List<News> newses=newsDao.getByTypesTopN(type, n, databaseDao);
List<String> newsCaptions=new ArrayList<String>();
for(News news:newses){
String newsCaption=Tool.getStringByMaxLength(news.getCaption(),
Integer.parseInt(WebProperties.config.getString("homePageNewsCaptionMaxLength")));
newsCaptions.add(newsCaption);
}
newsesList.add(newses);
newsCaptionsList.add(newsCaptions);
}
} catch (SQLException e) {
e.printStackTrace();
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
return newsesList;
}
public Integer update(News news){
try {
DatabaseDao databaseDao=new DatabaseDao();
NewsDao newsDao=new NewsDao();
return newsDao.update( news, databaseDao);
} catch (SQLException e) {
e.printStackTrace();
return -1;
} catch (Exception e) {
e.printStackTrace();
return -2;
}
}
}
| [
"[email protected]"
]
| |
9db336630986afa2e8df1eb4223a61d24c9c5a21 | 6086c5b03091b6e7ce64c8fc8355d8d86f94696b | /video-cache/src/main/java/com/gxh/video_cache/file/FileCache.java | b9c3f089383f4ef11493e0497a839fafa483ab05 | [
"MIT"
]
| permissive | abc1225/MediaRender-1 | e2a76bff6514f70128e7585e76e144e5cd34450d | 7cbc9e7ace03b4df2904173bb95784b24c0a74a0 | refs/heads/main | 2022-12-27T09:41:05.638370 | 2020-10-15T12:52:20 | 2020-10-15T12:52:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,261 | java | package com.gxh.video_cache.file;
import com.gxh.video_cache.Cache;
import com.gxh.video_cache.ProxyCacheException;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
/**
* {@link Cache} that uses file for storing data.
*
* @author Alexey Danilov ([email protected]).
*/
public class FileCache implements Cache {
private static final String TEMP_POSTFIX = ".download";
private final DiskUsage diskUsage;
public File file;
private RandomAccessFile dataFile;
public FileCache(File file) throws ProxyCacheException {
this(file, new UnlimitedDiskUsage());
}
public FileCache(File file, DiskUsage diskUsage) throws ProxyCacheException {
try {
if (diskUsage == null) {
throw new NullPointerException();
}
this.diskUsage = diskUsage;
File directory = file.getParentFile();
Files.makeDir(directory);
boolean completed = file.exists();
this.file = completed ? file : new File(file.getParentFile(), file.getName() + TEMP_POSTFIX);
this.dataFile = new RandomAccessFile(this.file, completed ? "r" : "rw");
} catch (IOException e) {
throw new ProxyCacheException("Error using file " + file + " as disc cache", e);
}
}
@Override
public synchronized long available() throws ProxyCacheException {
try {
return (int) dataFile.length();
} catch (IOException e) {
throw new ProxyCacheException("Error reading length of file " + file, e);
}
}
@Override
public synchronized int read(byte[] buffer, long offset, int length) throws ProxyCacheException {
try {
dataFile.seek(offset);
return dataFile.read(buffer, 0, length);
} catch (IOException e) {
String format = "Error reading %d bytes with offset %d from file[%d bytes] to buffer[%d bytes]";
throw new ProxyCacheException(String.format(format, length, offset, available(), buffer.length), e);
}
}
@Override
public synchronized void append(byte[] data, int length) throws ProxyCacheException {
try {
if (isCompleted()) {
throw new ProxyCacheException("Error append cache: cache file " + file + " is completed!");
}
dataFile.seek(available());
dataFile.write(data, 0, length);
} catch (IOException e) {
String format = "Error writing %d bytes to %s from buffer with size %d";
throw new ProxyCacheException(String.format(format, length, dataFile, data.length), e);
}
}
@Override
public synchronized void close() throws ProxyCacheException {
try {
dataFile.close();
diskUsage.touch(file);
} catch (IOException e) {
throw new ProxyCacheException("Error closing file " + file, e);
}
}
@Override
public synchronized void complete() throws ProxyCacheException {
if (isCompleted()) {
return;
}
close();
String fileName = file.getName().substring(0, file.getName().length() - TEMP_POSTFIX.length());
File completedFile = new File(file.getParentFile(), fileName);
boolean renamed = file.renameTo(completedFile);
if (!renamed) {
throw new ProxyCacheException("Error renaming file " + file + " to " + completedFile + " for completion!");
}
file = completedFile;
try {
dataFile = new RandomAccessFile(file, "r");
diskUsage.touch(file);
} catch (IOException e) {
throw new ProxyCacheException("Error opening " + file + " as disc cache", e);
}
}
@Override
public synchronized boolean isCompleted() {
return !isTempFile(file);
}
/**
* Returns file to be used fo caching. It may as original file passed in constructor as some temp file for not completed cache.
*
* @return file for caching.
*/
public File getFile() {
return file;
}
private boolean isTempFile(File file) {
return file.getName().endsWith(TEMP_POSTFIX);
}
}
| [
"[email protected]"
]
| |
74fa18d48e688b2aecba7645f472b18d3965d33f | 636a6ab80948fb3d9e8403db61e6efdd737a053c | /Time_em/app/src/main/java/com/time_em/utils/ValueSetUtils.java | 3e4a5e69e70a4e09aa4a2f28458d1b740af13326 | []
| no_license | minakshibh/Time-em-Android | 4807fdbc6d0c1b436e3c0467ea80ba36383c1a6d | 0eb2a39a661c24feb9222a1a0b2927729113a5da | refs/heads/master | 2021-01-19T02:07:37.970121 | 2019-05-30T06:23:31 | 2019-05-30T06:23:31 | 59,177,385 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 795 | java | package com.time_em.utils;
import android.widget.EditText;
import android.widget.TextView;
public class ValueSetUtils {
public static void setValueTextView(TextView tv, String value)
{
if(value!=null && !value.equalsIgnoreCase("null")) {
tv.setText(value);
}else{
tv.setText("");
}
}
public static void setValueEditText(EditText ed, String value)
{
if(value!=null && !value.equalsIgnoreCase("null")) {
ed.setText(value);
}else{
ed.setText("");
}
}
public static void setEnableEditText(EditText ed)
{
ed.setEnabled(true);
}
public static void setDisableEditText(EditText ed)
{
ed.setEnabled(false);
}
}
| [
"[email protected]"
]
| |
18ecb340656b26030dc54500da36d2c57ac3361c | 8d4e1ec876a7e659d8570e19f7161e7585f30a1a | /appgradotitulo/src/main/java/pe/edu/lamolina/gradotitulo/dao/FacultadDAOHibernate.java | 628a74dabaaa5a27c34915b533d52af75d360be0 | []
| no_license | Trigger00/Secretary | bc5169cfff1e42f63a465810cba1e4d5da54da44 | 3950f94e49c55f4583f770c744cc187075d3a04d | refs/heads/master | 2023-01-02T13:43:20.198796 | 2020-10-31T18:38:19 | 2020-10-31T18:38:19 | 308,935,772 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,575 | java | package pe.edu.lamolina.gradotitulo.dao;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.hibernate.sql.JoinType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Repository;
import pe.edu.lamolina.constant.ApplicationConstant;
import pe.edu.lamolina.gradotitulo.entity.SCGEspecialidadEntity;
import pe.edu.lamolina.gradotitulo.entity.SCGFacultadEntity;
import pe.edu.lamolina.gradotitulo.entity.SCGTipoEspecialidadEntity;
import pe.edu.lamolina.logging.UNALMLogger;
import pe.edu.lamolina.util.TypesUtil;
@Repository
public class FacultadDAOHibernate extends HibernateTemplate implements FacultadDAO {
private final static Logger log = Logger.getLogger(FacultadDAOHibernate.class);
@Autowired
public FacultadDAOHibernate(SessionFactory sessionFactory) {
super(sessionFactory);
}
@Override
public List<SCGFacultadEntity> getListFacultadDAO(SCGFacultadEntity entity) {
final String method = "getListFacultadDAO";
final String params = "SCGFacultadEntity entity";
UNALMLogger.entry(log, method,params,new Object[]{entity});
Criteria criteria = this.getSessionFactory().getCurrentSession().createCriteria(SCGFacultadEntity.class, "f");
criteria.add(Restrictions.eq("flagEliminado", ApplicationConstant.FLAG_ELIMINADO));
if(entity!= null){
if(entity.getCodigo() != null){
UNALMLogger.trace(log, method, "codigo "+entity.getCodigo());
criteria.add(Restrictions.ilike("codigo", entity.getTextoNombreEspanol(), MatchMode.ANYWHERE ));
}
if(entity.getTextoNombreEspanol() != null){
UNALMLogger.trace(log, method, "textoNombreEspanol "+entity.getTextoNombreEspanol());
criteria.add(Restrictions.ilike("textoNombreEspanol", entity.getTextoNombreEspanol(), MatchMode.ANYWHERE ));
}
if(entity.getCodigoExterno() !=null && entity.getCodigoExterno()!=""){
UNALMLogger.trace(log, method, "getCodigoExterno "+entity.getCodigoExterno());
criteria.add(Restrictions.eq("codigoExterno", entity.getCodigoExterno() ));
}
if(entity.getFlagEstado()!=null && entity.getFlagEstado()!=""){
UNALMLogger.trace(log, method, "getFlagEstado "+entity.getFlagEstado());
criteria.add(Restrictions.eq("flagEstado", entity.getFlagEstado() ));
}
}
criteria.addOrder(Order.asc("textoNombreEspanol"));
List<SCGFacultadEntity> result = criteria.list();
UNALMLogger.exit(log, method, result.size());
return result;
}
@Override
public List<SCGEspecialidadEntity> getListEspecialidadDAO(SCGEspecialidadEntity entity) {
final String method = "getListEspecialidadDAO";
final String params = "SCGEspecialidadEntity entity";
UNALMLogger.entry(log, method,params,new Object[]{entity});
Criteria criteria = this.getSessionFactory().getCurrentSession().createCriteria(SCGEspecialidadEntity.class,"e");
criteria.createCriteria("facultad","f", JoinType.LEFT_OUTER_JOIN);
criteria.createCriteria("tipoEspecialidad","te", JoinType.LEFT_OUTER_JOIN);
criteria.add(Restrictions.eq("flagEliminado", ApplicationConstant.FLAG_ELIMINADO));
if(entity!= null){
if(entity.getCodigo() != null){
UNALMLogger.trace(log, method, "codigo "+entity.getCodigo());
criteria.add(Restrictions.ilike("codigo", entity.getTextoNombreEspanol(), MatchMode.ANYWHERE ));
}
if(entity.getTextoNombreEspanol() != null&&entity.getTextoNombreEspanol()!=""){
UNALMLogger.trace(log, method, "textoNombreEspanol "+entity.getTextoNombreEspanol());
criteria.add(Restrictions.ilike("textoNombreEspanol", entity.getTextoNombreEspanol(), MatchMode.ANYWHERE ));
}
if(entity.getCodigoExterno() !=null && entity.getCodigoExterno()!=""){
UNALMLogger.trace(log, method, "getCodigoExterno "+entity.getCodigoExterno());
criteria.add(Restrictions.eq("codigoExterno", entity.getCodigoExterno() ));
}
if(entity.getFacultad() !=null ){
if(entity.getFacultad().getTextoNombreEspanol() !=null && entity.getFacultad().getTextoNombreEspanol()!="" ){
UNALMLogger.trace(log, method, "getFacultad().getTextoNombreEspanol "+entity.getFacultad().getTextoNombreEspanol());
criteria.add(Restrictions.ilike("f.textoNombreEspanol", entity.getFacultad().getTextoNombreEspanol() , MatchMode.ANYWHERE ));
}
if(entity.getFacultad().getCodigo() !=null ){
UNALMLogger.trace(log, method, "getFacultad().getCodigo() "+entity.getFacultad().getCodigo());
criteria.add(Restrictions.eq("f.codigo", entity.getFacultad().getCodigo() ));
}
}
if(entity.getTipoEspecialidad() !=null ){
if(entity.getTipoEspecialidad().getTextoNombreEspanol() !=null && entity.getTipoEspecialidad().getTextoNombreEspanol()!="" ){
UNALMLogger.trace(log, method, "getTipoEspecialidad().getTextoNombreEspanol "+entity.getTipoEspecialidad().getTextoNombreEspanol());
criteria.add(Restrictions.ilike("te.textoNombreEspanol", entity.getTipoEspecialidad().getTextoNombreEspanol() , MatchMode.ANYWHERE ));
}
if(entity.getTipoEspecialidad().getCodigo() !=null ){
UNALMLogger.trace(log, method, "getTipoEspecialidad().getCodigo() "+entity.getTipoEspecialidad().getCodigo());
criteria.add(Restrictions.eq("te.codigo", entity.getTipoEspecialidad().getCodigo() ));
}
if(!TypesUtil.isEmptyString(entity.getTipoEspecialidad().getCodigoExterno())){
UNALMLogger.trace(log, method, "entity.getTipoEspecialidad().getCodigoExterno() "+entity.getTipoEspecialidad().getCodigoExterno());
criteria.add(Restrictions.ilike("te.codigoExterno", entity.getTipoEspecialidad().getCodigoExterno() , MatchMode.ANYWHERE ));
}
}
if(!TypesUtil.isEmptyString(entity.getFlagEstado())){
UNALMLogger.trace(log, method, "getFlagEstado "+entity.getFlagEstado());
criteria.add(Restrictions.eq("flagEstado", entity.getFlagEstado() ));
}
}
criteria.addOrder(Order.asc("f.textoNombreEspanol"));
criteria.addOrder(Order.asc("textoNombreEspanol"));
List<SCGEspecialidadEntity> result = criteria.list();
UNALMLogger.exit(log, method, result.size());
return result;
}
@Override
public List<SCGTipoEspecialidadEntity> getListTipoEspecialidadDAO(SCGTipoEspecialidadEntity entity) {
final String method = "getListTipoEspecialidadDAO";
final String params = "SCGTipoEspecialidadEntity entity";
UNALMLogger.entry(log, method,params,new Object[]{entity});
Criteria criteria = this.getSessionFactory().getCurrentSession().createCriteria(SCGTipoEspecialidadEntity.class, "tp");
criteria.add(Restrictions.eq("flagEliminado", ApplicationConstant.FLAG_ELIMINADO));
List<SCGTipoEspecialidadEntity> result = criteria.list();
UNALMLogger.exit(log, method, result.size());
return result;
}
@Override
public SCGFacultadEntity getForUpdateDAO(SCGFacultadEntity entity) {
final String method = "getForUpdateDAO";
final String params = "SCGFacultadEntity entity";
UNALMLogger.entry(log, method,params,new Object[]{entity});
Criteria criteria = this.getSessionFactory().getCurrentSession().createCriteria(SCGFacultadEntity.class, "f");
criteria.add(Restrictions.eq("flagEliminado", ApplicationConstant.FLAG_ELIMINADO));
UNALMLogger.trace(log, method, "SCGFacultadEntity: "+entity.getCodigo());
criteria.add(Restrictions.eq("codigo", entity.getCodigo()));
SCGFacultadEntity result = (SCGFacultadEntity)criteria.uniqueResult();
UNALMLogger.exit(log, method, result);
return result;
}
@Override
public SCGEspecialidadEntity getForUpdateEspecialidadDAO(SCGEspecialidadEntity entity) {
final String method = "getForUpdateEspecialidadDAO";
final String params = "SCGEspecialidadEntity entity";
UNALMLogger.entry(log, method,params,new Object[]{entity});
Criteria criteria = this.getSessionFactory().getCurrentSession().createCriteria(SCGEspecialidadEntity.class,"e");
criteria.createCriteria("facultad","f", JoinType.LEFT_OUTER_JOIN);
criteria.createCriteria("tipoEspecialidad","te", JoinType.LEFT_OUTER_JOIN);
criteria.add(Restrictions.eq("flagEliminado", ApplicationConstant.FLAG_ELIMINADO));
criteria.add(Restrictions.eq("codigo", entity.getCodigo()));
SCGEspecialidadEntity result = (SCGEspecialidadEntity)criteria.uniqueResult();
UNALMLogger.exit(log, method, result);
return result;
}
@Override
public SCGFacultadEntity saveDAO(SCGFacultadEntity entity) {
final String method="saveDAO";
final String params="SCGFacultadEntity entity";
UNALMLogger.entry(log, method,params,new Object[]{entity});
SCGFacultadEntity result=(SCGFacultadEntity)this.merge(entity);
UNALMLogger.exit(log, method, result);
return result;
}
@Override
public SCGEspecialidadEntity saveEspecialidadDAO(SCGEspecialidadEntity entity) {
final String method="saveEspecialidadDAO";
final String params="SCGEspecialidadEntity entity";
UNALMLogger.entry(log, method,params,new Object[]{entity});
SCGEspecialidadEntity result=(SCGEspecialidadEntity)this.getSessionFactory().getCurrentSession().merge(entity);
UNALMLogger.exit(log, method, result);
return result;
}
@Override
public void deleteDAO(SCGFacultadEntity entity) {
this.getSessionFactory().getCurrentSession().delete(entity);
}
}
| [
"[email protected]"
]
| |
ca3869992b9789378c1a76bd5da95d01168ae4a6 | 0af8b92686a58eb0b64e319b22411432aca7a8f3 | /large-multiproject/project92/src/test/java/org/gradle/test/performance92_5/Test92_483.java | 885e73e573dce0a68a313fcd812c382232bdaa32 | []
| 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 | 292 | java | package org.gradle.test.performance92_5;
import static org.junit.Assert.*;
public class Test92_483 {
private final Production92_483 production = new Production92_483("value");
@org.junit.Test
public void test() {
assertEquals(production.getProperty(), "value");
}
} | [
"[email protected]"
]
| |
89778e950692f7f212c3275163c448aa32992eed | 92e79f38a66d0875d2b611a6b518ecfcc167dc94 | /app/src/main/java/eu/uk/ncl/pet5o/esper/core/thread/InboundUnitSendObjectArray.java | 325fbead5116684c07d0e31ce6be89e1cac61e80 | []
| no_license | PetoMichalak/EsperOn | f8f23d24db21269070e302c0a6c329312491388b | 688012d2a92217f4b24bf072dac04ed8902a313d | refs/heads/master | 2020-03-24T01:06:17.446804 | 2018-07-25T15:53:50 | 2018-07-25T15:53:50 | 142,322,329 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,193 | java | /*
***************************************************************************************
* Copyright (C) 2006 EsperTech, Inc. All rights reserved. *
* http://www.espertech.com/esper *
* http://www.espertech.com *
* ---------------------------------------------------------------------------------- *
* The software in this package is published under the terms of the GPL license *
* a copy of which has been included with this distribution in the license.txt file. *
***************************************************************************************
*/
package eu.uk.ncl.pet5o.esper.core.thread;
import eu.uk.ncl.pet5o.esper.core.service.EPRuntimeImpl;
import eu.uk.ncl.pet5o.esper.core.service.EPServicesContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Inbound work unit processing a map event.
*/
public class InboundUnitSendObjectArray implements InboundUnitRunnable {
private static final Logger log = LoggerFactory.getLogger(InboundUnitSendObjectArray.class);
private final Object[] properties;
private final String eventTypeName;
private final EPServicesContext services;
private final EPRuntimeImpl runtime;
/**
* Ctor.
*
* @param properties to send
* @param eventTypeName type name
* @param services to wrap
* @param runtime to process
*/
public InboundUnitSendObjectArray(Object[] properties, String eventTypeName, EPServicesContext services, EPRuntimeImpl runtime) {
this.eventTypeName = eventTypeName;
this.properties = properties;
this.services = services;
this.runtime = runtime;
}
public void run() {
try {
eu.uk.ncl.pet5o.esper.client.EventBean eventBean = services.getEventAdapterService().adapterForObjectArray(properties, eventTypeName);
runtime.processWrappedEvent(eventBean);
} catch (RuntimeException e) {
log.error("Unexpected error processing Object-array event: " + e.getMessage(), e);
}
}
}
| [
"[email protected]"
]
| |
d827f898cd5a5ec566fa98fd13509caa3046f306 | 296617626c75fde4047500d4d3853ad89b4426c3 | /Lab1/src/com/jlcindia/hibernate/Lab1B.java | 5b88fb7fa65e36180ac4e0632176fee58ea21e45 | []
| no_license | satish4792/MyTestProjects | f959df3dd5b5d4328c9ea65f262f9137137e061d | edc764caa833ea87616ab2052d2a99deab0084bd | refs/heads/master | 2022-02-17T10:44:50.875491 | 2019-06-06T16:36:36 | 2019-06-06T16:36:36 | 190,614,190 | 0 | 0 | null | 2022-02-09T23:54:41 | 2019-06-06T16:28:02 | JavaScript | UTF-8 | Java | false | false | 679 | java | package com.jlcindia.hibernate;
import org.hibernate.*;
public class Lab1B {
public static void main(String[] args) {
Transaction tx = null;
try {
SessionFactory sf = CHibernateUtil.getSessionFactory();
Session session = sf.openSession();
tx = session.beginTransaction();
Customer cust = (Customer) session.load(Customer.class, 1);
System.out.println(cust.getCid() + "\t" + cust.getCname() + "\t"
+ cust.getEmail() + "\t" + cust.getPhone() + "\t"
+ cust.getCity() + "\t" + cust.getBal());
tx.commit();
session.close();
} catch (Exception e) {
e.printStackTrace();
if(tx!=null)
tx.rollback();
}
}
}
| [
"[email protected]"
]
| |
f2c5c60611971597489ca8d581c4db76475c85d8 | 7654d261ec867b19381ef415e4d9c205b18b482e | /my-rbac/src/com/hooverz/exception/ErrorOperationException.java | 321726ede40af19d4e4cd2856ab59bbcecae8e7e | []
| no_license | paifeng/my-rbac | 8e3861b1514fc5fd4ef7008bc2ab0464c9aa5d4c | 988fe174bfd22c8222e22f3ae08db9f836cfc5eb | refs/heads/master | 2021-01-22T05:57:16.172594 | 2017-04-28T09:07:41 | 2017-04-28T09:07:41 | 81,722,376 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 225 | java | package com.hooverz.exception;
public class ErrorOperationException extends Exception {
private static final long serialVersionUID = 2937357436686553318L;
public ErrorOperationException(String msg) {
super(msg);
}
}
| [
"[email protected]"
]
| |
4cd2dd6cae955d0c5be2f6ad8185fc3be961f3b9 | 2c97e13704f64dd8ce21d5c878ee062ccd57f017 | /XMSClientLibrary/src/com/dialogic/XMSClientLibrary/XMSConfMixingMode.java | 3b5b4f40d00947370a8fec328b2c75a277a5d00b | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive"
]
| permissive | amynkvirani/dialogic-XMSClientLibrary | 39d76262f46c8e1df9b201e6159876f06a820838 | c82baae43d7d9b7e009ec9a68ae6f58e5fd82e0c | refs/heads/master | 2020-12-20T12:00:19.821736 | 2018-02-16T01:12:11 | 2018-02-16T01:12:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 222 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.dialogic.XMSClientLibrary;
/**
*
* @author ssatyana
*/
public enum XMSConfMixingMode {
MCU,
SFU
}
| [
"[email protected]"
]
| |
1a6415c543eaf99b14ac42602d4f82eb4a04c71a | 58f1d48cac92538c5136bb26ac21d9c9cc48855b | /src/main/java/com/example/rest/webservices/restfulwebservices/book/BooksController.java | 3361d8094126870bd99b1aaaba81d251cd4c7a7b | []
| no_license | 9306350/spring | 94fd5759093612e3f7c1244ef7778cbf7d7b669a | 0007d16238283aeefaa5804e0195bd8cebdbdfac | refs/heads/master | 2022-11-16T04:57:23.954818 | 2020-07-13T10:54:22 | 2020-07-13T10:54:22 | 279,276,404 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,692 | java | package com.example.rest.webservices.restfulwebservices.book;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@CrossOrigin(origins = "http://localhost:4200")
@RestController
public class BooksController {
@Autowired
private BookService bookService;
@Autowired
private BookRepository bookRepo;
@GetMapping(path = "/books")
public List<Book> getAllBooks() {
return bookRepo.findAll();
}
@GetMapping(path = "/books/{id}")
public Book getBook(@PathVariable long id) {
return bookRepo.findById(id).get();
}
@PostMapping(path="/books")
public ResponseEntity<Book> addBook(@RequestBody Book book) {
return new ResponseEntity<Book>(bookRepo.save(book), HttpStatus.OK);
}
@PutMapping(path="/books/{id}")
public ResponseEntity<Book> upateBook(@PathVariable long id, @RequestBody Book book) {
book.setId(id);
return new ResponseEntity<Book>(bookRepo.save(book), HttpStatus.OK);
}
@DeleteMapping(path = "/books/{id}")
public ResponseEntity<Void> deleteBook(@PathVariable long id) {
bookRepo.deleteById(id);
return ResponseEntity.ok(null);
}
}
| [
"[email protected]"
]
| |
11333d2ea3139000abcec23075193f3aa4ac199a | 862e10a8769d8046a17b2eb7f37b286443f7a94b | /The Triangle Class/src/Triangle.java | 6313c2fbf11d21ba14dbc5f536afd21172ffc560 | []
| no_license | Tinytimmmy/TheTriangleClass | 33514204d188d7a55485ac0f10d089cf23519f78 | 3142eceb73a1957aff2151808ca8179aeb176490 | refs/heads/master | 2021-01-10T15:18:10.021183 | 2015-09-30T04:19:24 | 2015-09-30T04:19:24 | 43,411,309 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 922 | java |
public class Triangle extends GeometricObject {
private double side1 = 1.0;
private double side2 = 1.0;
private double side3 = 1.0;
public Triangle() {}
// this method sets up the triangle's sides
public Triangle (double side1, double side2, double side3)
{this.side1=side1; this.side2=side2; this.side3=side3;}
public double setside1() {return side1;}
public double setside2() {return side2;}
public double setside3() {return side3;}
public void setside1(double side1) {this.side1 = side1;}
public void setside2(double side2) {this.side2 = side2;}
// these methods calculate area and perimeter
public double getArea() {return (side1+side2+side3)/2;}
public double getPerimeter() {return (side1+side2+side3);}
// this method returns a literal discription of the triangle
public String toString() {return "Side 1 = " + side1 + "Side 2 = " + side2 + "Side 3 = " + side3; }
}
| [
"[email protected]"
]
| |
bbcf565fef64e2921edda0fbd442300a4be3db8d | 489dea13d3c0c74688c74c7a36a50390eccd0175 | /Mail/WEB-INF/classes/outbox_deleteall.java | d4f3cf5ee8412f340b6fbf4b3837f117b8c82c3a | []
| no_license | Rishabh05apr/Mail-server | 23a2478d3fddcdd9e03a163d4ba4fcd6ecff7136 | 8f73f752372c573105d017bbf7a6d9a5dd04586e | refs/heads/master | 2021-05-05T22:31:37.200174 | 2018-01-03T19:09:30 | 2018-01-03T19:09:30 | 116,171,506 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,859 | java | import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class outbox_deleteall extends HttpServlet implements SingleThreadModel
{
String url;
Connection con;
Statement stmt,stmt1;
ResultSet rs,rs1;
PrintWriter out;
String check,user;
String to,subject,message,date,username;
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
{
doPost(request,response);
}
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException
{
try
{
HttpSession session=request.getSession(true);
check=(String)session.getAttribute("check");
if(check==null)
{
System.out.println("Error");
response.sendRedirect("http://localhost:8080/Mail");
}
user=(String)session.getAttribute("user");
System.out.println("Session id="+session.getId());
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
url="jdbc:mysql://localhost:3306/onlinemail?user=root&password=root";
con=DriverManager.getConnection(url);
stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=stmt.executeQuery("Select * from outbox");
stmt1=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs1=stmt1.executeQuery("Select * from deleted");
while(rs.next())
{
if(user.equals(rs.getString("Username")))
{
to=rs.getString("To");
subject=rs.getString("Subject");
message=rs.getString("Message");
date=rs.getString("Date");
username=rs.getString("Username");
rs1.moveToInsertRow();
rs1.updateString("To",to);
rs1.updateString("Subject",subject);
rs1.updateString("Message",message);
rs1.updateString("Date",date);
rs1.updateString("Username",username);
rs1.updateString("Folder","o");
rs1.insertRow();
}
}
rs.afterLast();
while(rs.previous())
{
if(user.equals(rs.getString("Username")))
{
rs.deleteRow();
}
}
response.setContentType("text/html");
out = response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<br/>");
out.println("<br/>");
out.println("<table align='right'>");
out.println("<tr>");
out.println("<th>");
out.println("<form method='post' action='logout'>");
out.println("<input type='submit' name='logout' value='Logout'/>");
out.println("</form>");
out.println("</th>");
out.println("</tr>");
out.println("</table>");
out.println("<h1 align='center'><font size='5'>Welcome </font>");
out.println("<font size='5' color='green'>"+user+"</font><h1>");
out.println("<table align='left' cellpadding='3'>");
out.println("<tr>");
out.println("<td>");
out.println("<pre> </pre>");
out.println("</td>");
out.println("</tr>");
out.println("</table>");
out.println("<table align='center' border='1' cellpadding='3' bordercolor='green'>");
out.println("<tr>");
out.println("<th>");
out.println("<form method='post' action='compose'>");
out.println("<input type='submit' name='compose' value='Compose'/>");
out.println("</form>");
out.println("</th>");
out.println("<th>");
out.println("<form method='post' action='inbox'>");
out.println("<input type='submit' name='inbox' value='Inbox'/>");
out.println("</form>");
out.println("</th>");
out.println("<th>");
out.println("<form method='post' action='outbox'>");
out.println("<input type='submit' name='outbox' value='Outbox'/>");
out.println("</form>");
out.println("</th>");
out.println("<th>");
out.println("<form method='post' action='sent'>");
out.println("<input type='submit' name='sent' value='Sent items'/>");
out.println("</form>");
out.println("</th>");
out.println("<th>");
out.println("<form method='post' action='drafts'>");
out.println("<input type='submit' name='drafts' value='Drafts'/>");
out.println("</form>");
out.println("</th>");
out.println("<th>");
out.println("<form method='post' action='deleted'>");
out.println("<input type='submit' name='deleted' value='Deleted'/>");
out.println("</form>");
out.println("</th>");
out.println("</tr>");
out.println("</table>");
out.println("<table align='left' border='2' cellpadding='3' bordercolor='blue'>");
out.println("<tr>");
out.println("<td>");
out.println("<form method='post' action='outbox1'>");
out.println("<input type='submit' name='send' value='Send'/>");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>");
out.println("<input type='submit' name='sendall' value='Send All'/>");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>");
out.println("<input type='submit' name='delete' value='Delete'/>");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>");
out.println("<input type='submit' name='deleteall' value='Delete All'/>");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>");
out.println("<input type='submit' name='content' value='Content'/>");
out.println("</td>");
out.println("</tr>");
out.println("</table>");
out.println("<table align='center' border='2' cellpadding='3' bordercolor='blue'>");
out.println("<tr>");
out.println("<th>");
out.println("<font size='4'>To</font>");
out.println("</th>");
out.println("<th>");
out.println("<font size='4'>Subject</font>");
out.println("</th>");
out.println("<th>");
out.println("<font size='4'>Date</font>");
out.println("</th>");
out.println("</tr>");
while(rs.next())
{int sno=rs.getInt("Sno");
if(user.equals(rs.getString("Username")))
{
out.println("<tr>");
out.println("<td>");
out.println("<input type=radio name=rb value="+sno+"></input>"+rs.getString("To"));
out.println("</td>");
out.println("<td>");
out.println(""+rs.getString("Subject")+"");
out.println("</td>");
out.println("<td>");
out.println(""+rs.getString("Date")+"");
out.println("</td>");
out.println("</tr>");
}
}
out.println("</form>");
out.println("</table>");
out.println("<h1 align='center'><font size='5'>All mails deleted</font></h1>");
out.println("</body>");
out.println("</html>");
}
catch(Exception e)
{
System.out.print("delete all outbox"+e.getMessage());
}
}
} | [
"[email protected]"
]
| |
72f0671e0588388041382877f21f47ab174634ee | 7961133bd042d73e83871877378ef55579b63058 | /src/main/java/com/siwuxie095/spring/chapter10th/example1st/Main.java | 905b84c697fbef407fd43becc0d3b5472d18751e | []
| no_license | siwuxie095/spring-practice | f234c14f33e468538fb620b4dd8648526fc2d28c | 7fa5aeaa5c81efd30a5c3d9e0d1396d0f866b056 | refs/heads/master | 2023-04-08T03:33:46.620416 | 2021-04-03T06:57:19 | 2021-04-03T06:57:19 | 319,481,337 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,972 | java | package com.siwuxie095.spring.chapter10th.example1st;
/**
* @author Jiajing Li
* @date 2021-02-21 16:21:32
*/
public class Main {
/**
* 通过 Spring 和 JDBC 征服数据库
*
* 在掌握了 Spring 容器的核心知识之后,是时候将它在实际应用中进行使用了。数据持久化是一个非常不错的起点,
* 因为几乎所有的企业级应用程序中都存在这样的需求。你可能处理过数据库访问功能,在实际的工作中可能会发现数
* 据访问有一些不足之处。必须初始化数据访问框架、打开连接、处理各种异常和关闭连接。如果上述操作出现任何问
* 题,都有可能损坏或删除珍贵的企业数据。如果你还未曾经历过因未妥善处理数据访问而带来的严重后果,那这里要
* 提醒你这绝对不是什么好事情。
*
* 做事要追求尽善尽美,所以这里选择了 Spring。Spring 自带了一组数据访问框架,集成了多种数据访问技术。不
* 管你是直接通过 JDBC 还是像 Hibernate 这样的对象关系映射(object-relational mapping,ORM)框架实
* 现数据持久化,Spring 都能够帮你消除持久化代码中那些单调枯燥的数据访问逻辑。可以依赖 Spring 来处理底
* 层的数据访问,这样就可以专注于应用程序中数据的管理了。
*
* 当开发 Spittr 应用的持久层的时候,会面临多种选择,可以使用 JDBC、Hibernate、Java 持久化 API(Java
* Persistence API,JPA)或者其他任意的持久化框架。你可能还会考虑使用最近很流行的 NoSQL 数据库。
*
* PS:NoSQL 数据库,也被称为无模式数据库。
*
* 幸好,不管你选择哪种持久化方式,Spring 都能够提供支持。在这里,主要关注于 Spring 对 JDBC 的支持。
*/
public static void main(String[] args) {
}
}
| [
"[email protected]"
]
| |
32316da937bd2a77af4b3211b0fadf2021b602cb | 08ed5b29f58f9310b213a96b0f2187de7cfa914e | /app/src/androidTest/java/com/zl/baiduspeechsynthesis/ExampleInstrumentedTest.java | cb84749c1867a810deed64df54ead068d6956a6c | []
| no_license | WLIN534/BaiDuSpeechSynthesis | 07c5bc11f62815cfe80f91b491f4ff659625a4e8 | f2196acca28027ac541137deaf54088b2ef7e00f | refs/heads/master | 2021-01-19T11:58:33.782700 | 2017-02-17T08:40:10 | 2017-02-17T08:40:10 | 82,275,106 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 758 | java | package com.zl.baiduspeechsynthesis;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.zl.baiduspeechsynthesis", appContext.getPackageName());
}
}
| [
"[email protected]"
]
| |
9644e01440f8a2dc3caedb18d94b1f336b2e9f0c | 5ad234676e58cb3058600736c98040c0865ce6aa | /src/ba/unsa/etf/rpr/tut1/Main.java | b68172aa5e6e652e97e45fbe0df377f994c10b20 | []
| no_license | MiralemMemic/new | 94da021c6b60a116293882b05c855acfbaeb8da7 | ddd60dd847bb85a387c8b4ee15d469c849359fb1 | refs/heads/master | 2020-08-13T20:25:52.132238 | 2020-04-29T10:28:03 | 2020-04-29T10:28:03 | 215,033,053 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 564 | java | package ba.unsa.etf.rpr.tut1;
import java.util.Scanner;
public class Main {
public static int sumaCifara(int broj) {
int suma=0;
while(broj!=0) {
suma+=broj%10;
broj/=10;
}
return suma;
}
public static void main(String[] args) {
System.out.println("Unesite n: ");
Scanner ulaz = new Scanner(System.in);
int n=ulaz.nextInt();
for(int i=1; i<=n; i++) {
if(i%(sumaCifara(i))==0) {
System.out.println(i);
}
}
}
}
| [
"[email protected]"
]
| |
eaefe8f19593b270b140894ed9af3cdbc98beb6d | 35bb978a5e9b0638e51157a94698c3dc22243f22 | /guinmp2009/src/dk/aau/imi/med4/guinmp2009/networks/DomainName2IPAddress.java | a18750678374084885c4db27db6aad50824ffef2 | []
| no_license | Sillycatface/guinmp2009 | a0e83218c0101d6226d9806c7e82170855fd693f | 56f5f0eaf56f28bc4e6121525113432a622e2201 | refs/heads/master | 2021-01-01T03:58:12.471691 | 2012-12-10T13:32:13 | 2012-12-10T13:32:13 | 56,390,653 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 621 | java | package dk.aau.imi.med4.guinmp2009.networks;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class DomainName2IPAddress {
public static void main(String[] args) {
String domainName = "www.imi.aau.dk";
InetAddress[] ipAddresses;
try {
ipAddresses = InetAddress.getAllByName(domainName);
for(InetAddress inetAddress : ipAddresses) {
System.out.print(inetAddress.getHostAddress());
System.out.println("; Canonical host name: "+inetAddress.getCanonicalHostName());
}
} catch (UnknownHostException e) {
System.out.println("Unknown host!");
}
}
}
| [
"chromamorph@1f5a8d96-2cf6-11de-9401-6341fb89ae7c"
]
| chromamorph@1f5a8d96-2cf6-11de-9401-6341fb89ae7c |
957b172a881083bef262cc49c41bf61650ec45ca | ef06a7327dea2264f5e4a0732a767361ff93b4a4 | /app/src/main/java/jp/techacademy/yasufumi/hagiwara/qa_app/Question.java | 3f533119afb8a0559839dd439dc832859d611e84 | []
| no_license | yhagi299/QA_App | fe7071dd24d5ba10f9ba62712070d834fc82ab7f | c2e7fbdf33a6547e5a7664d93fd5bbf4d5ba3ca3 | refs/heads/master | 2021-04-09T16:02:50.245835 | 2018-03-19T10:48:20 | 2018-03-19T10:48:20 | 125,843,003 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,336 | java | package jp.techacademy.yasufumi.hagiwara.qa_app;
import java.io.Serializable;
import java.util.ArrayList;
/**
* Created by hagiwara on 2018/03/09.
*/
public class Question implements Serializable {
private String mTitle;
private String mBody;
private String mName;
private String mUid;
private String mQuestionUid;
private int mGenre;
private byte[] mBitmapArray;
private ArrayList<Answer> mAnswerArrayList;
public String getTitle(){
return mTitle;
}
public String getBody(){
return mBody;
}
public String getName(){
return mName;
}
public String getUid(){
return mUid;
}
public String getQuestionUid(){
return mQuestionUid;
}
public int getGenre(){
return mGenre;
}
public byte[] getImageBytes(){
return mBitmapArray;
}
public ArrayList<Answer> getAnswers(){
return mAnswerArrayList;
}
public Question(String title, String body, String name, String uid, String questionUid, int genre, byte[] bytes, ArrayList<Answer> answers){
mTitle = title;
mBody = body;
mName = name;
mUid = uid;
mQuestionUid = questionUid;
mGenre = genre;
mBitmapArray = bytes.clone();
mAnswerArrayList = answers;
}
}
| [
"[email protected]"
]
| |
fa0b242efc6a9fd7ede58b5789389343bdefe294 | c0730b91f8cf82436e2d0b42e35c87935c49be56 | /workflow-web/src/main/java/com/sxdx/workflow/web/controller/RoleMenuController.java | 456e04e119cad8f2a8574e34b7e3b0a4b9420f3c | []
| no_license | when2016/workflow-activiti6 | bdf19705214c667420eceea416d970f0ae725350 | fd81d5b679ffda39f731d75ae2567b6cc7289abf | refs/heads/master | 2023-04-11T09:35:17.094644 | 2021-03-23T09:50:53 | 2021-03-23T09:50:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 362 | java | package com.sxdx.workflow.web.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 角色菜单关联表 前端控制器
* </p>
*
* @author Garnett
* @since 2020-10-16
*/
@RestController
@RequestMapping("//roleMenu")
public class RoleMenuController {
}
| [
"[email protected]"
]
| |
46f3f347109318661d8eab208fb0eee9c4913b2a | a9f885bd7f6d60dc72f7274425c419c839708361 | /src/main/java/com/nelioalves/cursomc/domain/PagamentoComCartao.java | b2b3b70c36390b6c837fcb63ddf83b8a59534c82 | []
| no_license | g3l2e1/cursomc | 9531779a897d97c7c27411fb0f3db41853978b95 | dde1db57d223e46514ec0d0ca6f166b698d851a8 | refs/heads/master | 2020-04-09T10:11:02.210743 | 2018-12-11T15:10:19 | 2018-12-11T15:10:19 | 160,261,403 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 786 | java | package com.nelioalves.cursomc.domain;
import javax.persistence.Entity;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.nelioalves.cursomc.domain.enums.SituacaoPagamento;
@Entity
@JsonTypeName("pagamentoComCartao")
public class PagamentoComCartao extends Pagamento{
private static final long serialVersionUID = 1L;
private Integer numeroDeParcelas;
public PagamentoComCartao() {
}
public PagamentoComCartao(Integer id, SituacaoPagamento situacao, Pedido pedido, Integer numeroDeParcelas) {
super(id, situacao, pedido);
this.numeroDeParcelas = numeroDeParcelas;
}
public Integer getNumeroDeParcelas() {
return numeroDeParcelas;
}
public void setNumeroDeParcelas(Integer numeroDeParcelas) {
this.numeroDeParcelas = numeroDeParcelas;
}
}
| [
"[email protected]"
]
| |
ed4fe3749cdb3870f95b8a794cd347fc6ca15a9c | 633559e1183cc2868fe9b095e362d1bef8aa8d9b | /app/src/main/java/com/example/fizhu/tele_health/SBArt2Activity.java | befc066bc3bc3dba481d67c269ae969bf1795d80 | []
| no_license | Fizhu/Tele-Health | 8360e313b787b6b5b2d118031fb79ba984cc3b73 | ab3a76e96c3abad2622579427e5b5c5ae2757a72 | refs/heads/master | 2020-07-13T15:58:59.139959 | 2019-08-29T08:37:00 | 2019-08-29T08:37:00 | 205,110,624 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,406 | java | package com.example.fizhu.tele_health;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class SBArt2Activity extends AppCompatActivity implements View.OnClickListener{
private View tblbackart2;
private WebView sbart2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sbart2);
sbart2 = (WebView) findViewById(R.id.webarts2);
sbart2.getSettings().setJavaScriptEnabled(true);
sbart2.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return super.shouldOverrideUrlLoading(view, request);
}
});
sbart2.loadUrl("https://www.alodokter.com/demam-naik-turun-bisa-jadi-tanda-3-penyakit-ini");
tblbackart2 = (View) findViewById(R.id.bhsbart2);
tblbackart2.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == tblbackart2){
startActivity(new Intent(SBArt2Activity.this,SuhuDTActivity.class));
}
}
}
| [
"[email protected]"
]
| |
9e60d9a1dc7e82fa3477e85fb72d435aed0859b9 | e97a764de34afd58a087a095ce2d7916d782431b | /groups/org/ghcc/toft/toft-0/toft-0.1/products/ware/core/design/design-1/projects/surpass/surpass-1/org.ghcc.toft-ware.core.design-surpass-0.1-1-1/java-code/org/ghcc/toft/ware/core/design/interfaces/mop/caas/output/exception/OutputDriveException.java | e0a45637ea46cd0f2e5c50c27612e4aed8af94c0 | []
| no_license | yanchangyou/ghcc | dccda7d5da6ada660c6e0661e63ee33bbf57a3bb | 27b2139b81850a18b7de77fdef84bf7f1b724fc6 | refs/heads/master | 2020-04-26T10:56:57.132233 | 2010-11-22T15:37:48 | 2010-11-22T15:37:48 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 632 | java | /*
* CopyCenter 2010 GHCC.ORG, all rights freed.
*/
package org.ghcc.toft.ware.core.design.interfaces.mop.caas.output.exception;
import org.ghcc.toft.ware.core.design.interfaces.concept.caas.Output;
import org.ghcc.toft.ware.core.design.interfaces.cop.exception.DriveException;
/**
* OutputDriveException
*
* @author code machine
* @author yanchangyou
* @date 2010-10-23 21:10:15
* @version 0.1-1-1
*
*/
public class OutputDriveException extends DriveException implements Output, OutputCOPException {
/**
*
*/
private static final long serialVersionUID = 4688292442176788439L;
}
| [
"[email protected]@1b3c01a9-0980-7ae1-184d-a1ecbe3d4eca"
]
| [email protected]@1b3c01a9-0980-7ae1-184d-a1ecbe3d4eca |
957a8430344f7b4c9f8be3f02d3ee61c2270394f | fcbe9fddf30700703a501ae58649af9a4195870f | /src/myPackage/LoginStep.java | 4db2caceb869deaaa84075a1f28c2433453e1366 | []
| no_license | paritoshkumar1/BDD_CUCUMBER | 9994a56b35ea0af5df9e6097e0cd9452e04024ab | 53a721f7db19a50438672d8c2375750604b0a582 | refs/heads/master | 2020-03-10T06:27:25.937191 | 2018-04-16T17:05:35 | 2018-04-16T17:05:35 | 129,240,259 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,368 | java | package myPackage;
import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
public class LoginStep {
/* @Before("@Signup")
public void beforeScenario(){
System.out.println("This is before hook");
}
@After("@Signup")
public void afterScenario(){
System.out.println("This is after hook");
}*/
@Before
public void beforeScenarionoTag(){
System.out.println("========This is before Scenario =========");
}
@After
public void afterScenarionoTag(){
System.out.println("============This is afterScenario ========");
}
@Given("^Launch the Firefox browser$")
public void Launch_the_Firefox_browser(){
System.out.println("Launch the Firefox browser");
}
@Given("^I launch the application$")
public void I_launch_the_application(){
System.out.println("I launch the application");
}
@Then("^I enter correct username and password$")
public void I_enter_correct_username_and_password(){
System.out.println("I enter correct username and password");
}
@And("^Clicked on Login Button$")
public void Clicked_on_Login_Button(){
System.out.println("Clicked on Login Button");
}
@And("^I am login into application$")
public void I_am_login_into_application(){
System.out.println("I am login into application");
}
}
| [
"[email protected]"
]
| |
93d0cbd2b4ff8245500bf15bb597ddb615eab93b | 54a263dbbdb5bd8e90824baf9487f44fd003bbaa | /omics/src/main/java/org/kobic/omics/archive/web/ArchiveController.java | 020c47d4a3abcecec4fe1586e2e9e37e361806aa | []
| no_license | termopyle/prometheus | b681b27055449ef0ada4d849c1677439bc0b50b5 | dd9b67275317e52f6ded405566257da3575b19b8 | refs/heads/master | 2020-04-25T02:13:27.410702 | 2019-02-25T05:07:26 | 2019-02-25T05:07:26 | 172,432,037 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,948 | java | package org.kobic.omics.archive.web;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
import org.kobic.omics.archive.service.TaxonomyService;
import org.kobic.omics.archive.vo.TaxonomyVo;
import org.kobic.omics.common.OmicsConstants;
import org.kobic.omics.common.vo.EasyUiJsonTreeVO;
import org.kobic.omics.common.vo.EasyUiRootJsonTreeVO;
import org.kobic.omics.common.vo.EasyUiStaticJsonTreeVO;
import org.kobic.omics.report.service.ReportService;
import org.kobic.omics.report.vo.AseemblyFilePathVo;
import org.kobic.omics.report.vo.AssemblyReportVo;
import org.kobic.omics.archive.vo.LineageVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.gson.Gson;
@Controller
public class ArchiveController {
private static final Logger LOGGER = LoggerFactory.getLogger(ArchiveController.class);
@Resource(name = "taxonomyService")
private TaxonomyService taxonomyService;
@Resource(name = "reportService")
private ReportService reportService;
@RequestMapping(value = "/taxonomy", method = RequestMethod.GET)
public ModelAndView viewer(ModelMap model,
HttpServletRequest request, HttpServletResponse response,
@RequestParam(value="taxon_id", required=false) String taxId){
ModelAndView result = new ModelAndView();
result.setViewName("archive/genome_archive");
result.addObject("taxon_id",taxId);
return result;
}
@RequestMapping(value = "/getTaxnomyData.do", method = RequestMethod.POST)
public void getTaxnomyData(HttpServletRequest request, HttpServletResponse response,
@RequestParam(value="taxon_id", required=false) String taxId,
@RequestParam(value="species_name", required=false) String speciesName) {
LOGGER.info("getTaxonomyData.do");
if(taxId == null || taxId == ""){
LOGGER.info("검색에의한 데이터 호출");
taxId = taxonomyService.getAssemblyId(speciesName).getTax_id();
}
List<AseemblyFilePathVo> assemblyResult = reportService.getAssemblyResult(taxId);
List<AseemblyFilePathVo> existDB = reportService.getAssemblyReportExist(taxId);
JSONObject jso=new JSONObject();
jso.put("data", assemblyResult);
jso.put("existDB", existDB);
response.setContentType("application/json");
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = null;
try {
out = new PrintWriter(response.getWriter());
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(jso.toString());
out.print(jso.toString());
out.flush();
out.close();
}
@RequestMapping(value = "/initData.do", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
public void initData(HttpServletRequest request,
HttpServletResponse response,
@RequestParam(value = "keyword", required = false) String keyword ) {
LOGGER.info("init : keyword : " + keyword);
String type = "1";
String getData = null;
if (keyword.length() == 0) {
List<TaxonomyVo> voList = null;
List<EasyUiJsonTreeVO> collection = new ArrayList<EasyUiJsonTreeVO>();
try {
voList = this.taxonomyService.getTaxonNodes(type);
for (TaxonomyVo vo : voList) {
EasyUiJsonTreeVO jsonVo = new EasyUiJsonTreeVO();
jsonVo.setId(String.valueOf(vo.getTax_id()));
jsonVo.setText(vo.getName_txt());
jsonVo.setEnd_yn(vo.getEnd_yn());
jsonVo.setLeaf_node(vo.getLeaf_node());
collection.add(jsonVo);
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
EasyUiRootJsonTreeVO root = new EasyUiRootJsonTreeVO();
root.setId(String.valueOf(OmicsConstants.ROOT_ID));
root.setText("Classification System");
root.setChildren(collection);
Gson gson = new Gson();
getData = gson.toJson(root);
} else {
Multimap<String, String> kingdomMap = ArrayListMultimap.create();
Multimap<String, String> phylumMap = ArrayListMultimap.create();
Multimap<String, String> classMap = ArrayListMultimap.create();
Multimap<String, String> orderMap = ArrayListMultimap.create();
Multimap<String, String> familyMap = ArrayListMultimap.create();
Multimap<String, String> genusMap = ArrayListMultimap.create();
Multimap<String, String> speciesMap = ArrayListMultimap.create();
Map<String, String> kingdomIdMap = new HashMap<String, String>();
Map<String, String> phylumIdMap = new HashMap<String, String>();
Map<String, String> classIdMap = new HashMap<String, String>();
Map<String, String> orderIdMap = new HashMap<String, String>();
Map<String, String> familyIdMap = new HashMap<String, String>();
Map<String, String> genusIdMap = new HashMap<String, String>();
Map<String, String> speciesIdMap = new HashMap<String, String>();
LOGGER.info("Taxon Tree 데이터 전달 키워드: " + keyword);
String[] temp1 = null;
String[] temp2 = null;
List<LineageVo> voKobisfList;
List<String> taxonText = new ArrayList<String>();
voKobisfList = null;
try {
voKobisfList = this.taxonomyService.getQueryResultAsTaxonNode(keyword);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for (LineageVo vo : voKobisfList) {
taxonText.add(vo.getLineage());
System.out.println(vo.getLineage());
}
String kingdomTemp = "";
String kingdomTempId= "";
String phylumTemp = "";
String phylumTempId = "";
String classTemp = "";
String classTempId = "";
String orderTemp = "";
String orderTempId = "";
String familyTemp = "";
String familyTempId = "";
String genusTemp = "";
String genusTempId = "";
String speciesTemp = "";
String speciesTempId = "";
for(String text : taxonText){
temp1 = null;
temp2 = null;
temp1 = text.split("&");
if(temp1.length < 7){
continue;
}else{
temp2 = temp1[6].split("[|]");
kingdomTemp = temp2[temp2.length - 1];
kingdomTempId = temp2[0];
temp2 = temp1[5].split("[|]");
phylumTemp = temp2[temp2.length - 1];
phylumTempId = temp2[0];
temp2 = temp1[4].split("[|]");
classTemp = temp2[temp2.length - 1];
classTempId = temp2[0];
temp2 = temp1[3].split("[|]");
orderTemp = temp2[temp2.length - 1];
orderTempId = temp2[0];
temp2 = temp1[2].split("[|]");
familyTemp = temp2[temp2.length - 1];
familyTempId = temp2[0];
temp2 = temp1[1].split("[|]");
genusTemp = temp2[temp2.length - 1];
genusTempId = temp2[0];
temp2 = temp1[0].split("[|]");
speciesTemp = temp2[temp2.length - 1];
speciesTempId = temp2[0];
if(!kingdomMap.get(String.valueOf(OmicsConstants.ROOT_ID)).contains(kingdomTemp)){
kingdomMap.put(String.valueOf(OmicsConstants.ROOT_ID), kingdomTemp);
kingdomIdMap.put(kingdomTemp, kingdomTempId);
};
if(!phylumMap.get(kingdomTemp).contains(phylumTemp)){
phylumMap.put(kingdomTemp, phylumTemp);
phylumIdMap.put(phylumTemp, phylumTempId);
};
if(!classMap.get(phylumTemp).contains(classTemp)){
classMap.put(phylumTemp, classTemp);
classIdMap.put(classTemp, classTempId);
};
if(!orderMap.get(classTemp).contains(orderTemp)){
orderMap.put(classTemp, orderTemp);
orderIdMap.put(orderTemp, orderTempId);
};
if(!familyMap.get(orderTemp).contains(familyTemp)){
familyMap.put(orderTemp, familyTemp);
familyIdMap.put(familyTemp, familyTempId);
};
if(!genusMap.get(familyTemp).contains(genusTemp)){
genusMap.put(familyTemp, genusTemp);
genusIdMap.put(genusTemp, genusTempId);
};
if(!speciesMap.get(genusTemp).contains(speciesTemp)){
speciesMap.put(genusTemp, speciesTemp);
speciesIdMap.put(speciesTemp, speciesTempId);
};
}
}
List<EasyUiStaticJsonTreeVO> rootChild = new ArrayList<EasyUiStaticJsonTreeVO>();
if(kingdomMap.get(String.valueOf(OmicsConstants.ROOT_ID)).size() != 0){
for(String kingdom : kingdomMap.get(String.valueOf(OmicsConstants.ROOT_ID))){
EasyUiStaticJsonTreeVO vo1 = new EasyUiStaticJsonTreeVO();
vo1.setId(kingdomIdMap.get(kingdom));
vo1.setState(OmicsConstants.DEFAULT_STATUS);
vo1.setText(kingdom);
List<EasyUiStaticJsonTreeVO> kingdomChild = new ArrayList<EasyUiStaticJsonTreeVO>();
if(phylumMap.get(kingdom).size() != 0){
for(String phylum : phylumMap.get(kingdom)){
EasyUiStaticJsonTreeVO vo2 = new EasyUiStaticJsonTreeVO();
vo2.setId(phylumIdMap.get(phylum));
vo2.setState(OmicsConstants.DEFAULT_STATUS);
vo2.setText(phylum);
List<EasyUiStaticJsonTreeVO> phylumChild = new ArrayList<EasyUiStaticJsonTreeVO>();
if(classMap.get(phylum).size() != 0){
for(String classs : classMap.get(phylum)){
EasyUiStaticJsonTreeVO vo3 = new EasyUiStaticJsonTreeVO();
vo3.setId(classIdMap.get(classs));
vo3.setState(OmicsConstants.DEFAULT_STATUS);
vo3.setText(classs);
List<EasyUiStaticJsonTreeVO> classChild = new ArrayList<EasyUiStaticJsonTreeVO>();
if(orderMap.get(classs).size() != 0){
for(String order : orderMap.get(classs)){
EasyUiStaticJsonTreeVO vo4 = new EasyUiStaticJsonTreeVO();
vo4.setId(orderIdMap.get(order));
vo4.setState(OmicsConstants.DEFAULT_STATUS);
vo4.setText(order);
List<EasyUiStaticJsonTreeVO> orderChild = new ArrayList<EasyUiStaticJsonTreeVO>();
if(familyMap.get(order).size() != 0){
for(String family : familyMap.get(order)){
EasyUiStaticJsonTreeVO vo5 = new EasyUiStaticJsonTreeVO();
vo5.setId(familyIdMap.get(family));
vo5.setState(OmicsConstants.DEFAULT_STATUS);
vo5.setText(family);
List<EasyUiStaticJsonTreeVO> familyChild = new ArrayList<EasyUiStaticJsonTreeVO>();
if(genusMap.get(family).size() != 0){
for(String genus : genusMap.get(family)){
EasyUiStaticJsonTreeVO vo6 = new EasyUiStaticJsonTreeVO();
vo6.setId(genusIdMap.get(genus));
vo6.setState(OmicsConstants.DEFAULT_STATUS);
vo6.setText(genus);
List<EasyUiStaticJsonTreeVO> genusChild = new ArrayList<EasyUiStaticJsonTreeVO>();
if(speciesMap.get(genus).size() != 0){
for(String species : speciesMap.get(genus)){
List<EasyUiStaticJsonTreeVO> speciesChild = new ArrayList<EasyUiStaticJsonTreeVO>();
EasyUiStaticJsonTreeVO vo7 = new EasyUiStaticJsonTreeVO();
vo7.setId(speciesIdMap.get(species));
vo7.setState(OmicsConstants.DEFAULT_STATUS);
vo7.setText(species);
vo7.setChildren(speciesChild);
genusChild.add(vo7);
}
}
vo6.setChildren(genusChild);
familyChild.add(vo6);
}
}
vo5.setChildren(familyChild);
orderChild.add(vo5);
}
}
vo4.setChildren(orderChild);
classChild.add(vo4);
}
}
vo3.setChildren(classChild);
phylumChild.add(vo3);
}
}
vo2.setChildren(phylumChild);
kingdomChild.add(vo2);
}
}
vo1.setChildren(kingdomChild);
rootChild.add(vo1);
}
}
EasyUiStaticJsonTreeVO root = new EasyUiStaticJsonTreeVO();
root.setId(String.valueOf(OmicsConstants.ROOT_ID));
root.setText("Classification System");
root.setState(OmicsConstants.DEFAULT_STATUS);
root.setChildren(rootChild);
Gson gson = new Gson();
getData = gson.toJson(root);
}
LOGGER.info(type + " tree getData: "+getData);
PrintWriter pw = null;
response.setContentType("application/json");
response.setContentType("text/xml;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
try {
pw = new PrintWriter(response.getWriter());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
pw.println(String.format(OmicsConstants.JSON_FORMAT, getData));
pw.flush();
pw.close();
}
@RequestMapping(value = "/taxonomy_update.do", method = RequestMethod.POST, produces = "text/plain;charset=UTF-8")
public void taxonomy_update(HttpServletRequest request,
HttpServletResponse response,
@RequestParam(value = "id") String id,
@RequestParam(value = "rank") String rank,
@RequestParam(value = "keyword") String keyword) {
int type = 1;
LOGGER.info("분류체계 트리 클릭 이벤트 발생 시 get parameger values: id: [" + id +"], type: [" + type + "]");
List<TaxonomyVo> voList = null;
List<EasyUiJsonTreeVO> collection = new ArrayList<EasyUiJsonTreeVO>();
try {
voList = this.taxonomyService.getTaxonNodes(id);
for (TaxonomyVo vo : voList) {
EasyUiJsonTreeVO jsonVo = new EasyUiJsonTreeVO();
jsonVo.setId(String.valueOf(vo.getTax_id()));
jsonVo.setText(vo.getName_txt().replace(" ", "_"));
jsonVo.setRank(vo.getRank());
jsonVo.setEnd_yn(vo.getEnd_yn());
jsonVo.setLeaf_node(vo.getLeaf_node());
collection.add(jsonVo);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Gson gson = new Gson();
if (Integer.parseInt(id) == OmicsConstants.ROOT_ID) {
collection.clear();
}
String json = gson.toJson(collection);
List<AseemblyFilePathVo> assemblyResult = reportService.getAssemblyReportExist(id);
JSONObject jso=new JSONObject();
PrintWriter pw = null;
response.setContentType("application/json");
response.setContentType("text/xml;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
try {
pw = new PrintWriter(response.getWriter());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//키워드로 검색했을 경우와 Archive로 접근했을 때 필요한 데이터를 구분
if(keyword==null || keyword == ""){
LOGGER.info("json(collection) : " + json);
pw.println(json);
}else{
jso.put("data", assemblyResult);
pw.print(jso.toString());
}
pw.flush();
pw.close();
}
}
| [
"kogun82@DESKTOP-CCPE3C8"
]
| kogun82@DESKTOP-CCPE3C8 |
f91bf00fa6f55659310cf43a766574ba5fdc1c73 | 53a91de02e55ef21f98e0ae4f5b34a65078ac68e | /app/src/main/java/it/units/ceschia/help/entity/Application.java | a45e303e7ad83e39a09a6bdc91d47e318b149ffe | []
| no_license | cecia234/Help | 75034a838703c1ff99285091894b59ab6cf679ed | d0253297bc6d4ab24cbb91bc277e709575e173c0 | refs/heads/master | 2023-07-28T04:02:29.900799 | 2021-09-09T08:15:19 | 2021-09-09T08:15:19 | 400,423,600 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 115 | java | package it.units.ceschia.help.entity;
public enum Application {
WHATSAPP,
TELEGRAM,
SMS,
CALL,
}
| [
"[email protected]"
]
| |
5c30f0a0bbb6e7ae801757402b84826a43323a51 | ecf9f1c89e4a3be6a1a11c106461db7afa24240a | /udemy/curso-java/exercicios/src/controle/Switch.java | 2d1fddc0d7a15f9c8278d328570d58971373b821 | [
"MIT"
]
| permissive | pedrolpsouza/curso-java-udemy | cb53955c9575594fba2134b2eeaf23e7b11b7056 | 587982f4550289766a0e5e415eef9454aee93ff7 | refs/heads/master | 2022-11-26T20:42:21.994519 | 2020-08-03T19:09:08 | 2020-08-03T19:09:08 | 284,785,211 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 607 | java | package controle;
public class Switch {
public static void main(String[] args) {
String faixa = "VERDE";
switch (faixa.toLowerCase()) {
case"preta":
System.out.println("fodao");
break;
case"marrom":
System.out.println("medio foda");
break;
case"verde":
System.out.println("menos medio foda");
break;
case"laranja":
System.out.println("pouco noob");
break;
case"vermelha":
System.out.println("noobao");
break;
case"amarela":
System.out.println("eu era nob");
break;
case"branca":
System.out.println("burro");
break;
}
}
}
| [
"[email protected]"
]
| |
05cf91ecc810e56a65c9b4b12cdd403b161937ff | 6aa5c1c9269b96d17c66bedf16a56a6ec1c4dc2a | /android/app/src/main/java/com/rnlearn/MainApplication.java | 8759cf95c861f47a3c984165cb25fa413d281160 | []
| no_license | zhanMr/rnlearn | 4868c5c1577494d318c1d2cb1dd8f90eb472ba1c | 477db1348f35603a1b73a45fe247b1745dd46bcd | refs/heads/master | 2021-01-19T16:01:39.651158 | 2017-04-19T11:20:04 | 2017-04-19T11:20:04 | 88,237,764 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 955 | java | package com.rnlearn;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
| [
"[email protected]"
]
| |
e9540cbea1d56288b3486139fbf08e01620e310f | bdf31a1f4d8f6f2bd3a0e1609bf037b027996269 | /src/main/java/com/works/admin/ProductListController.java | 43938dc4b6456fe5c9a4ff68297b222548cc7628 | []
| no_license | serdarsanu/SpringOrderProject | da8e15f2d7df6cbd0a1298998cfe4e4e15b7be36 | 5d41dab6a58364b4257c30ba63a2d7f224ce0b27 | refs/heads/master | 2022-12-22T10:44:06.664224 | 2019-10-06T15:04:53 | 2019-10-06T15:04:53 | 213,182,530 | 0 | 0 | null | 2022-12-16T00:59:25 | 2019-10-06T14:24:32 | JavaScript | UTF-8 | Java | false | false | 1,958 | java | package com.works.admin;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import model.Contact;
import model.Neworder;
import model.Product;
import model.User;
import util.HibernateUtil;
import util.Util;
@Controller
@RequestMapping("/admin")
public class ProductListController {
SessionFactory sf = HibernateUtil.getSessionFactory();
@RequestMapping(value = "/productlist", method = RequestMethod.GET)
public String productList(HttpServletRequest req, Model model) {
Session sesi = sf.openSession();
List<Product> productcount = sesi.createQuery("from Product").list();
List<User> usercount = sesi.createQuery("from User").list();
List<Neworder> ordercount = sesi.createQuery("from Neworder").list();
List<Contact> contactcount = sesi.createQuery("from Contact").list();
model.addAttribute("productcount", productcount.size());
model.addAttribute("usercount", usercount.size());
model.addAttribute("ordercount", ordercount.size());
model.addAttribute("contactcount", contactcount.size());
List<Product> productlist = sesi.createQuery("from Product").list();
model.addAttribute("productlist", productlist);
return Util.control(req, "productlist");
}
@RequestMapping(value = "/deleteproduct/{productid}")
public String deleteProduct(@PathVariable int productid, HttpServletRequest req) {
Session sesi = sf.openSession();
Transaction tr = sesi.beginTransaction();
Product adm = sesi.load(Product.class, productid);
sesi.delete(adm);
tr.commit();
return Util.control(req, "redirect:/admin/productlist");
}
}
| [
"[email protected]"
]
| |
cfae1e911ceffa4c735522245ae891789f2767da | 2045cbef684d17148c59b362a41ab2f72e37d077 | /browser-app/src/main/java/com/xyz/browser/app/modular/api/TxnController.java | 1d818621884b468fe39f1ffdac06d48d6479286f | []
| no_license | baka233/explorer-server | 15d79d20c65addd92b2e1be942ab5305bc98ad1e | 87883200a3d213fd8713f762ed310d7d60535b46 | refs/heads/master | 2020-05-24T11:46:51.970617 | 2019-04-12T02:35:03 | 2019-04-12T02:35:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,989 | java | /**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.xyz.browser.app.modular.api;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.stylefeng.roses.core.base.controller.BaseController;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xyz.browser.app.core.util.JsonResult;
import com.xyz.browser.app.modular.api.dto.PageDto;
import com.xyz.browser.app.modular.api.dto.TxnPageDto;
import com.xyz.browser.app.modular.api.vo.BlockPageVo;
import com.xyz.browser.app.modular.api.vo.LogVo;
import com.xyz.browser.app.modular.api.vo.TransactionVo;
import com.xyz.browser.app.modular.api.vo.TxnPageVo;
import com.xyz.browser.app.modular.hbase.model.Block;
import com.xyz.browser.app.modular.hbase.model.Btransaction;
import com.xyz.browser.app.modular.hbase.model.Transaction;
import com.xyz.browser.app.modular.hbase.service.BlockService;
import com.xyz.browser.app.modular.hbase.service.BtransactionService;
import com.xyz.browser.app.modular.hbase.service.TransactionService;
import com.xyz.browser.app.modular.system.model.RtBlock;
import com.xyz.browser.app.modular.system.model.RtTxn;
import com.xyz.browser.app.modular.system.service.IRtBlockService;
import com.xyz.browser.app.modular.system.service.IRtTxnService;
import com.xyz.browser.common.model.RtBlockDto;
import com.xyz.browser.common.model.RtTxnDto;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.FastDateFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api/vns/txn")
@Slf4j
public class TxnController extends BaseController {
private static FastDateFormat sdf = FastDateFormat.getInstance("yyyy-MM-dd");
@Autowired
private TransactionService transactionService;
@Autowired
private BtransactionService btransactionService;
@Autowired
private BlockService blockService;
@Autowired
private IRtBlockService rtBlockService;
@Autowired
private IRtTxnService rtTxnService;
private static CopyOptions co1;
private static CopyOptions co2;
static{
co1 = new CopyOptions();
//RtTxn to TxnPageVo
Map<String,String> fm = Maps.newHashMap();
fm.put("t","timestamp");
co1.setFieldMapping(fm);
co2 = new CopyOptions();
Map<String,String> fm2 = Maps.newHashMap();
fm2.put("transactionHash","hash");
fm2.put("transactionIndex","position");
String[] ignorePro = new String[]{"logs"};
co2.setFieldMapping(fm2).setIgnoreProperties(ignorePro);
}
public static void main(String[] args) {
BigInteger a = new BigInteger("9");
BigInteger b = new BigInteger("4");
System.out.println(a.divide(b).toString());
// Transaction txn = new Transaction();
// txn.setLogs("223");
// TransactionVo transactionVo = new TransactionVo();
// BeanUtil.copyProperties(txn,transactionVo,new CopyOptions().setIgnoreProperties(new String[]{"logs"}));
// System.out.println(transactionVo);
}
@RequestMapping(value = "/info", method = RequestMethod.GET)
public JsonResult info(String hash) {
TransactionVo transactionVo = new TransactionVo();
Transaction transaction = transactionService.selectByHash(hash);
if(transaction!=null){
BeanUtil.copyProperties(transaction,transactionVo,co2);
// System.out.println("t p:"+transaction.getTransactionIndex());
// System.out.println("tv p:"+transactionVo.getPosition());
BigInteger blockNumber = new BigInteger(transactionVo.getBlockNumber().substring(2),16);
transactionVo.setBlockNumber(blockNumber.toString());
RtBlock rtBlock = rtBlockService.selectOne(new EntityWrapper<RtBlock>().orderBy("number",false).last("limit 1"));
if(rtBlock!=null && rtBlock.getNumber() - blockNumber.longValue()>=0L)
transactionVo.setConfirms(String.valueOf(rtBlock.getNumber() - blockNumber.longValue()));
else
transactionVo.setConfirms("0");
transactionVo.setPosition(new BigInteger(transactionVo.getPosition().substring(2),16).toString());
transactionVo.setStatus(new BigInteger(transactionVo.getStatus().substring(2),16).toString());
transactionVo.setGasUsed(new BigInteger(transactionVo.getGasUsed().substring(2),16).toString());
List<LogVo> logs = JSON.parseArray(transaction.getLogs(), LogVo.class);
if(logs!=null){
for(LogVo logVo: logs){
logVo.setLogIndex(new BigInteger(logVo.getLogIndex().substring(2),16).toString());
}
}
Btransaction btransaction = btransactionService.selectByHash(hash);
if(btransaction!=null){
transactionVo.setTimestamp(new BigInteger(btransaction.getTimestamp().substring(2),16).toString());
transactionVo.setValue(new java.math.BigDecimal(new java.math.BigInteger(btransaction.getValue().substring(2),16).toString())
.divide(new java.math.BigDecimal("1000000000000000000")).toString());
BigInteger gas = new BigInteger(btransaction.getGas().substring(2),16);
BigInteger gasPrice = new BigInteger(btransaction.getGasPrice().substring(2),16);
transactionVo.setGasPrice(gasPrice.toString());
transactionVo.setTxnFee(gas.multiply(gasPrice).toString());
transactionVo.setNonce(new BigInteger(btransaction.getNonce().substring(2),16).toString());
transactionVo.setInputData(btransaction.getInput());
}
Block block = blockService.selectByHash(transaction.getBlockHash());
if(block!=null) {
transactionVo.setGasLimit(new BigInteger(block.getGasLimit().substring(2), 16).toString());
}
transactionVo.setLogs(logs);
}
return new JsonResult().addData("txn",transactionVo);
}
@RequestMapping(value = "/rt", method = RequestMethod.GET)
public JsonResult rt() {
Page<RtTxn> s;
List<RtTxn> list = rtTxnService.selectList(new EntityWrapper<RtTxn>().orderBy("t",false).last("limit 10"));
return new JsonResult().addData("txns",list);
}
@RequestMapping(value = "/list", method = RequestMethod.POST)
public JsonResult list(@RequestBody TxnPageDto txnPageDto) {
BigInteger page = new BigInteger(txnPageDto.getPage()).subtract(BigInteger.ONE);
BigInteger limit = new BigInteger(txnPageDto.getLimit());
BigInteger offset = page.multiply(limit);
Map<String,Object> params = Maps.newHashMap();
EntityWrapper ew = new EntityWrapper<RtTxn>();
if(StringUtils.isNotBlank(txnPageDto.getBh()))
params.put("block_hash",txnPageDto.getBh());
// ew.and("block_hash={0}",txnPageDto.getBh());
if(StringUtils.isNotBlank(txnPageDto.getStatus()))
params.put("status",txnPageDto.getStatus());
// ew.and("status = {0}",txnPageDto.getStatus());
if(StringUtils.isNotBlank(txnPageDto.getAddress())){
if("in".equals(txnPageDto.getIo()))
params.put("to",txnPageDto.getAddress());
// ew.and("to={0}",txnPageDto.getAddress());
else if("out".equals(txnPageDto.getIo()))
params.put("from",txnPageDto.getAddress());
// ew.and("from={0}",txnPageDto.getAddress());
else
params.put("address",txnPageDto.getAddress());
// ew.and().andNew("from={0} or to = {1}",txnPageDto.getAddress(),txnPageDto.getAddress());
}
long total = rtTxnService.pageCount(params);
params.put("offset",offset.longValue());
params.put("limit",limit.intValue());
List<RtTxn> rtTxns = rtTxnService.pageList(params);
long size ;
if(total % limit.intValue() == 0){
size = total/limit.intValue();
}else{
size = total/limit.intValue()+1;
}
// ew.orderBy("t",false).last("limit "+offset.toString()+","+limit.toString());
List<TxnPageVo> list = Lists.newArrayList();
// List<RtTxn> rtTxns = rtTxnService.selectList(ew);
for(RtTxn rtTxn :rtTxns){
TxnPageVo txnPageVo = new TxnPageVo();
BeanUtil.copyProperties(rtTxn,txnPageVo,co1);
if(StringUtils.isNotBlank(txnPageDto.getAddress())){
if(txnPageDto.getAddress().equals(txnPageVo.getFrom())){
txnPageVo.setIo("out");
}else if(txnPageDto.getAddress().equals(txnPageVo.getTo())){
txnPageVo.setIo("in");
}
}
list.add(txnPageVo);
}
return new JsonResult().addData("txns",list).addData("total",String.valueOf(total)).addData("size",String.valueOf(size));
}
//
// @RequestMapping(value = "/list", method = RequestMethod.POST)
// public JsonResult list(@RequestBody TxnPageDto txnPageDto) {
// BigInteger page = new BigInteger(txnPageDto.getPage());
// BigInteger limit = new BigInteger(txnPageDto.getLimit());
//
// EntityWrapper ew = new EntityWrapper<RtTxn>();
// if(StringUtils.isNotBlank(txnPageDto.getBh()))
// ew.and("block_hash={0}",txnPageDto.getBh());
// if(StringUtils.isNotBlank(txnPageDto.getStatus()))
// ew.and("status = {0}",txnPageDto.getStatus());
// if(StringUtils.isNotBlank(txnPageDto.getAddress())){
// if("in".equals(txnPageDto.getIo()))
// ew.and("to={0}",txnPageDto.getAddress());
// else if("out".equals(txnPageDto.getIo()))
// ew.and("from={0}",txnPageDto.getAddress());
// else
// ew.and().andNew("from={0} or to = {1}",txnPageDto.getAddress(),txnPageDto.getAddress());
// }
// ew.orderBy("t",false);//.last("limit "+offset.toString()+","+limit.toString());
//
// Page<RtTxn> pages = new Page<>(page.intValue(),limit.intValue());
// rtTxnService.selectPage(pages,ew);
// //待优化
//// BigInteger total = new BigInteger(String.valueOf(rtTxnService.selectCount(ew)));
// long size ;
// if(pages.getTotal() % limit.intValue() == 0){
// size = pages.getTotal()/limit.intValue();
// }else{
// size = pages.getTotal()/limit.intValue()+1;
// }
// List<TxnPageVo> list = Lists.newArrayList();
//// List<RtTxn> rtTxns = rtTxnService.selectList(ew);
// for(RtTxn rtTxn :pages.getRecords()){
// TxnPageVo txnPageVo = new TxnPageVo();
// BeanUtil.copyProperties(rtTxn,txnPageVo,co1);
// list.add(txnPageVo);
// }
//
//
//
// return new JsonResult().addData("txns",list).addData("total",String.valueOf(pages.getTotal())).addData("size",String.valueOf(size));
// }
@RequestMapping(value = "/commit", method = RequestMethod.POST)
public JsonResult commit(@RequestBody List<RtTxnDto> rtTxnDtos) {
List<String> failedhashs = Lists.newArrayList();
if(rtTxnDtos!=null){
for(RtTxnDto rtTxnDto: rtTxnDtos){
String hash=rtTxnDto.getHash();
try{
RtTxn rtTxn = new RtTxn();
BeanUtil.copyProperties(rtTxnDto,rtTxn);
rtTxnService.updateStatus(rtTxn);
}catch(Exception e){
log.error("txnStatus commit failed:"+hash);
e.printStackTrace();
failedhashs.add(hash);
}
}
}
return new JsonResult().addData("failed",failedhashs);
}
}
| [
"[email protected]"
]
| |
5334cf564054c5f062c46e65af0db66ce42d37f9 | 3c0ef4f53add0b49f35d13a81450d0d201fdbf2e | /src/main/java/core/time_series/spatial_utilities/snn_bf/data/twitter/TwitterOutput.java | b42e20ad52e516ba67a0c078f750397198183e3e | []
| no_license | RFASilva/Changes-Prototype | 1e060f208b8747e15e7d92bb10932a96ee75ddea | 42b6b0bd2cdda0d13463c1f306271de76d30e840 | refs/heads/master | 2021-01-21T05:06:01.559736 | 2015-02-04T15:14:59 | 2015-02-04T15:14:59 | 30,183,734 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,476 | java | package core.time_series.spatial_utilities.snn_bf.data.twitter;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import snn.SNNObject;
import weka.WekaPlot;
import weka.WekaPlotException;
import file.Output;
public class TwitterOutput implements Output<TwitterPoint>{
private String content;
private Iterator<TwitterPoint> it;
private Map<Long,SNNObject> clusters;
private Set<Long> clustersIds;
public TwitterOutput(){
this.content = new String();
}
public void setIterator(Iterator<TwitterPoint> it) {
this.it = it;
}
public void setClusters(Map<Long, SNNObject> clusters) {
this.clusters = clusters;
}
public void setClustersIds(Set<Long> clustersIds){
this.clustersIds = clustersIds;
}
public void output(String outputName, boolean resToPlot)
throws IOException, WekaPlotException{
content = new String();
if(!outputName.equals("") || resToPlot){
headerArff();
contentArff();
}
if(!outputName.equals(""))
outputArff(outputName);
if(resToPlot)
plot();
}
private void headerArff(){
content += "@relation 'twitter'\n";
content += "@attribute LAT real\n";
content += "@attribute LONG real\n";
content += "@attribute cluster {-1, " + parseClustersIds() + "}\n";
content += "@data\n";
}
private String parseClustersIds(){
String result = clustersIds.toString();
result = result.substring(1, result.length()-1);
return result;
}
private void contentArff(){
while(it.hasNext()){
TwitterPoint current = it.next();
content += outputPoint(current);
}
}
private String outputPoint(TwitterPoint point){
String result = "";
for(int i = 0; i < 3; i++){
result += point.getCoord(i);
result += ",";
}
result += clusters.get(point.getId()).getCluster();
result += "\n";
return result;
}
private void outputArff(String outputName) throws IOException{
FileWriter fileOut = new FileWriter(outputName);
BufferedWriter out = new BufferedWriter(fileOut);
out.write(content);
out.close();
}
private void plot() throws WekaPlotException {
InputStream is = new ByteArrayInputStream(content.getBytes());
WekaPlot wp = new WekaPlot(is);
wp.plot();
}
}
| [
"[email protected]"
]
| |
c7628be92452f39afb0af25af60a978f88505e9c | 8dea0c3f985414133d248c6314bfa89a48b5e597 | /photon-office/src/main/java/org/lpw/photon/office/OfficeHelperImpl.java | 56c96578a4662e480f0a4853b3167dd38935426f | [
"MIT"
]
| permissive | heisedebaise/photon | 1afe182ddf305588cc41e72d0168f80bc8a1dcf3 | 1991ddd464c33a820e410525d495a0764b19b8f1 | refs/heads/master | 2023-09-05T00:24:51.808431 | 2023-08-18T03:04:20 | 2023-08-18T03:04:20 | 247,466,804 | 0 | 1 | MIT | 2022-12-12T06:31:37 | 2020-03-15T12:59:06 | Java | UTF-8 | Java | false | false | 4,170 | java | package org.lpw.photon.office;
import com.alibaba.fastjson.JSONObject;
import org.lpw.photon.util.Context;
import org.lpw.photon.util.Generator;
import org.lpw.photon.util.Numeric;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.awt.Color;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@Component("photon.office.helper")
public class OfficeHelperImpl implements OfficeHelper {
@Inject
private Generator generator;
@Inject
private Context context;
@Inject
private Numeric numeric;
@Value("${photon.office.temp-path:}")
private String temp;
private final Set<String> excelContentTypes = new HashSet<>(Arrays.asList("application/vnd.ms-excel",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
private final Set<String> excelSuffixes = new HashSet<>(Arrays.asList(".xls", ".xlsx"));
private final Set<String> pptContentTypes = new HashSet<>(Arrays.asList("application/octet-stream",
"application/vnd.openxmlformats-officedocument.presentationml.presentation"));
private final Set<String> pptSuffixes = new HashSet<>(Arrays.asList(".ppt", ".pptx"));
private final Set<String> wordContentTypes = new HashSet<>(Arrays.asList("application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"));
private final Set<String> wordSuffixes = new HashSet<>(Arrays.asList(".doc", ".docx"));
@Override
public boolean isExcel(String contentType, String fileName) {
if (!excelContentTypes.contains(contentType) || fileName == null)
return false;
int indexOf = fileName.lastIndexOf('.');
if (indexOf == -1)
return false;
return excelSuffixes.contains(fileName.substring(indexOf).toLowerCase());
}
@Override
public boolean isPpt(String contentType, String fileName) {
if (!pptContentTypes.contains(contentType) || fileName == null)
return false;
int indexOf = fileName.lastIndexOf('.');
if (indexOf == -1)
return false;
return pptSuffixes.contains(fileName.substring(indexOf).toLowerCase());
}
@Override
public boolean isWord(String contentType, String fileName) {
if (!wordContentTypes.contains(contentType) || fileName == null)
return false;
int indexOf = fileName.lastIndexOf('.');
if (indexOf == -1)
return false;
return wordSuffixes.contains(fileName.substring(indexOf).toLowerCase());
}
@Override
public String getTempPath(String name) {
return context.getAbsolutePath(temp + "/" + name + "/" + generator.random(32));
}
@Override
public long pixelToEmu(int pixel) {
return pixel * 9525L;
}
@Override
public int emuToPixel(long emu) {
return numeric.toInt(emu / 9525);
}
@Override
public double emuToPoint(long emu) {
return emu / 9525.0D * 72 / 96;
}
@Override
public int pointToPixel(double point) {
return numeric.toInt(point * 96 / 72);
}
@Override
public double pixelToPoint(int pixel) {
return pixel * 72 / 96.0D;
}
@Override
public double fromPercent(int percent) {
return percent / 100000.0D;
}
@Override
public int toPercent(double value) {
return numeric.toInt(value * 100000);
}
@Override
public JSONObject colorToJson(Color color) {
JSONObject object = new JSONObject();
if (color == null)
return object;
object.put("red", color.getRed());
object.put("green", color.getGreen());
object.put("blue", color.getBlue());
object.put("alpha", color.getAlpha());
return object;
}
@Override
public Color jsonToColor(JSONObject object) {
return new Color(object.getIntValue("red"), object.getIntValue("green"), object.getIntValue("blue"),
object.containsKey("alpha") ? object.getIntValue("alpha") : 255);
}
}
| [
"[email protected]"
]
| |
825faab72b5c4f57e622e8d9c2aa6b6b37320654 | bfa485e2ecd7464cf4d4e38979e816cfcdced16a | /kiloboltgame/src/com/kilobolt/robotgame/SampleGame.java | c282638446b595b254f938be0b8bbfcf9079881e | []
| no_license | usmanr149/Java_Applications | 855161a017b472073dc5f33f136734216dc173d0 | 429e1b90952a6f3784ef894e5d48e8efaadbcb6d | refs/heads/master | 2021-01-14T14:01:52.673906 | 2016-09-15T21:33:39 | 2016-09-15T21:33:39 | 68,332,943 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,478 | java | package com.kilobolt.robotgame;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import android.util.Log;
import com.kilobolt.framework.Screen;
import com.kilobolt.framework.implementation.AndroidGame;
public class SampleGame extends AndroidGame {
public static String map;
boolean firstTimeCreate = true;
@Override
public Screen getInitScreen() {
if (firstTimeCreate) {
Assets.load(this);
firstTimeCreate = false;
}
InputStream is = getResources().openRawResource(R.raw.map1);
map = convertStreamToString(is);
return new SplashLoadingScreen(this);
}
@Override
public void onBackPressed() {
getCurrentScreen().backButton();
}
private static String convertStreamToString(InputStream is) {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append((line + "\n"));
}
} catch (IOException e) {
Log.w("LOG", e.getMessage());
} finally {
try {
is.close();
} catch (IOException e) {
Log.w("LOG", e.getMessage());
}
}
return sb.toString();
}
@Override
public void onResume() {
super.onResume();
Assets.theme.play();
}
@Override
public void onPause() {
super.onPause();
Assets.theme.pause();
}
} | [
"[email protected]"
]
| |
edf721109d550c8e2f58349f5c8272bfa7d6da42 | 0a6e54c08ecd0dab0e5c4a14d4c674f4a2828fbd | /app/src/main/java/com/example/giftapp/ServerMessage.java | 46dd9964743357cdc71d5c21314362d0422abdb2 | []
| no_license | NathanielScottBailey/GiftApp | 423fbfe7438ff445436c5e62d914cbd99a3f94ab | 454a8f3f4dd6692b170c9056d4c1e4127672a23b | refs/heads/main | 2023-01-30T12:42:37.298750 | 2020-12-11T22:26:06 | 2020-12-11T22:26:06 | 304,970,096 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 372 | java | package com.example.giftapp;
public class ServerMessage {
private String text;
public String getText() {
return text;
}
/**
* a toString method written for debugging.
* @return
*/
@Override
public String toString() {
return "ServerMessage{" +
"text='" + text + '\'' +
'}';
}
}
| [
"[email protected]"
]
| |
035a4684e73aa15c66a9737d4409fc1e0f509ba0 | bac5e384627575f8dc96fa49d8858e23442d0753 | /project/src/state/InService.java | 0284f0a2af869d3f767ed323bf22860f904b147c | []
| no_license | alohakya/Carnival-Amusement-Park | 7279690c66ae389182351ac012bd25773c92d513 | 19ef0ed3611ac778110a905c681792a72b6fb198 | refs/heads/main | 2023-08-21T07:06:52.415237 | 2021-10-20T12:29:37 | 2021-10-20T12:29:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 371 | java | package state;
import constant.Const;
/**
* 游乐设施状态类
*
* @function 将游乐设施正常运行状态抽象为状态类
* @pattern 状态模式 State
* @author Yejingxin
*/
public class InService extends EquipmentState{
/**
* 构造函数
*/
public InService()
{
stateName = Const.IN_SERVICE;
}
}
| [
"[email protected]"
]
| |
d85ad3caf50833093bfa0d00978ebfcc0e30b179 | a0a0c7c8e52fb7fb58af4f095a973b6377fb6a8d | /mod_developement_1.7.10/src/main/java/monjin/immersive_mod/inventory/AbstractInventory.java | 6504d6e826021392bbe425a17031023d57d682a7 | []
| no_license | Monjinn/monjin-s_immersive_mod | 7ab49172067b02b39dd02272a489a884786ddd3f | 61b58b5bfcf573427107442906574564b18fca8d | refs/heads/master | 2022-12-07T12:45:56.349404 | 2020-08-11T08:53:27 | 2020-08-11T08:53:27 | 286,525,986 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,436 | java | package monjin.immersive_mod.inventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.IChatComponent;
public abstract class AbstractInventory implements IInventory {
/** The inventory slots need to be initialized during construction */
protected ItemStack[] inventory;
@Override
public int getSizeInventory() {
return inventory.length;
}
@Override
public ItemStack getStackInSlot(int slot) {
return inventory[slot];
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
ItemStack stack = getStackInSlot(slot);
if (stack != null) {
if (stack.stackSize > amount) {
stack = stack.splitStack(amount);
markDirty();
} else {
setInventorySlotContents(slot, null);
}
}
return stack;
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
ItemStack stack = getStackInSlot(slot);
setInventorySlotContents(slot, null);
return stack;
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack) {
inventory[slot] = itemstack;
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) {
itemstack.stackSize = getInventoryStackLimit();
}
markDirty();
}
@Override
public void markDirty() {
} // usually only TileEntities implement this method
public int getField(int id) {
return 0;
}
public void setField(int id, int value) {
}
public int getFieldCount() {
return 0;
}
public void clear() {
for (int i = 0; i < inventory.length; ++i) {
inventory[i] = null;
}
}
/**
* Return unlocalized name here, or pre-translated and return true for
* hasCustomName()
*/
public String getName() {
return "";
}
public boolean hasCustomName() {
return false;
}
public IChatComponent getDisplayName() {
return (IChatComponent) (hasCustomName() ? new ChatComponentText(
getName()) : new ChatComponentTranslation(getName()));
}
/**
* NBT key used to set and retrieve the NBTTagCompound containing this
* inventory
*/
protected abstract String getNbtKey();
/**
* Writes this inventory to NBT; must be called manually Fails silently if
* {@link #getNbtKey} returns null or an empty string
*/
public void writeToNBT(NBTTagCompound compound) {
String key = getNbtKey();
if (key == null || key.equals("")) {
return;
}
NBTTagList items = new NBTTagList();
for (int i = 0; i < getSizeInventory(); ++i) {
if (getStackInSlot(i) != null) {
NBTTagCompound item = new NBTTagCompound();
item.setByte("Slot", (byte) i);
getStackInSlot(i).writeToNBT(item);
items.appendTag(item);
}
}
compound.setTag(key, items);
}
/**
* Loads this inventory from NBT; must be called manually Fails silently if
* {@link #getNbtKey} returns null or an empty string
*/
public void readFromNBT(NBTTagCompound compound) {
String key = getNbtKey();
if (key == null || key.equals("")) {
return;
}
NBTTagList items = compound.getTagList(key, compound.getId());
for (int i = 0; i < items.tagCount(); ++i) {
NBTTagCompound item = items.getCompoundTagAt(i);
byte slot = item.getByte("Slot");
if (slot >= 0 && slot < getSizeInventory()) {
inventory[slot] = ItemStack.loadItemStackFromNBT(item);
}
}
}
@Override
public String getInventoryName() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean hasCustomInventoryName() {
// TODO Auto-generated method stub
return false;
}
@Override
public int getInventoryStackLimit() {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
// TODO Auto-generated method stub
return false;
}
@Override
public void openInventory() {
// TODO Auto-generated method stub
}
@Override
public void closeInventory() {
// TODO Auto-generated method stub
}
@Override
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
// TODO Auto-generated method stub
return false;
}
} | [
"Petri@DESKTOP-QB5AQLI"
]
| Petri@DESKTOP-QB5AQLI |
2885e619871fd3ac5d08eeb4075db5cb5eabe0b8 | d673f02088ae846d89e5f9d301785d38bccc88c8 | /library/src/main/java/com/domain/library/recycleview/creator/DefaultLoadMoreCreator.java | 5694db5660e5efc6497b2dc1be8a20e86a4648a8 | []
| no_license | Zhangyinbi/self_wan | c06e242d901973bc26fd2f751aeceee47221f793 | 90eb27e1a57ecbc2014026085574e30d6607e68e | refs/heads/master | 2020-04-01T03:43:38.820524 | 2019-01-22T02:02:25 | 2019-01-22T02:02:25 | 152,834,067 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,780 | java | package com.domain.library.recycleview.creator;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.TextView;
import com.domain.library.R;
import java.text.SimpleDateFormat;
import static com.domain.library.recycleview.RefreshRecyclerView.REFRESH_STATUS_LOOSEN_REFRESHING;
import static com.domain.library.recycleview.RefreshRecyclerView.REFRESH_STATUS_PULL_DOWN_REFRESH;
/**
* Project Name : UIKit
* description:null
*
* @author : yinbi.zhang.o
* Create at : 2018/12/3 13:43
*/
public class DefaultLoadMoreCreator implements LoadViewCreator {
private static final String FIRST_TIME_TEXT = "更新时间:";
private static final String NOT_FIRST_TIME_TEXT = "上次更新:";
private static final String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
// 加载数据的ImageView
private ImageView mRefreshIv;
private Context mContext;
private TextView mTvRefreshText;
private TextView mTvRefreshTime;
private String mLastTime;
private boolean isFirst;
/**
* 日期格式化
*
* @param time 时间格式化
* @return 返回格式化的时间
*/
public static String formatTimeMillis(long time) {
SimpleDateFormat sdf = new SimpleDateFormat(TIME_FORMAT);
return sdf.format(time);
}
/**
* 获取上啦加载更多的view
*
* @param context 上下文
* @param parent 父布局
* @return 返回上拉加载更多的view
*/
@Override
public View getLoadView(Context context, ViewGroup parent) {
View refreshView = LayoutInflater.from(context).inflate(R.layout.layout_refresh_header_view, parent, false);
mRefreshIv = refreshView.findViewById(R.id.iv_refresh_icon);
mTvRefreshText = refreshView.findViewById(R.id.tv_refresh_text);
mTvRefreshTime = refreshView.findViewById(R.id.tv_refresh_time);
mLastTime = formatTimeMillis(System.currentTimeMillis());
mTvRefreshTime.setText(FIRST_TIME_TEXT + mLastTime);
isFirst = true;
mContext = context;
return refreshView;
}
/**
* 正在下拉pull
*
* @param currentDragHeight 当前拖动的高度
* @param refreshViewHeight 总的刷新高度 即刷新view 的高度
* @param currentLoadStatus 当前状态
*/
@Override
public void onPull(int currentDragHeight, int refreshViewHeight, int currentLoadStatus) {
float rotate = ((float) currentDragHeight) / refreshViewHeight;
if (currentLoadStatus == REFRESH_STATUS_LOOSEN_REFRESHING) {
if (isFirst) {
mTvRefreshTime.setText(FIRST_TIME_TEXT + mLastTime);
} else {
mTvRefreshTime.setText(NOT_FIRST_TIME_TEXT + mLastTime);
}
}
if (currentLoadStatus == REFRESH_STATUS_PULL_DOWN_REFRESH) {
mTvRefreshText.setText(R.string.uikit_com_refresh_status_pull_load_hint_text);
}
if (rotate >= 0.0002) {
mRefreshIv.setRotation(0);
mRefreshIv.clearAnimation();
mTvRefreshText.setText(R.string.uikit_com_refresh_status_loosen_load_hint_text);
return;
}
// 不断下拉的过程中不断的旋转图片
mRefreshIv.setRotation(rotate * 180);
}
/**
* 加载更多
*/
@Override
public void onLoading() {
mTvRefreshText.setText(R.string.uikit_com_refresh_status_load_hint_text);
mRefreshIv.setImageResource(R.drawable.uikit_com_refreshing_icon);
Animation operatingAnim = AnimationUtils.loadAnimation(mContext, R.anim.uikit_com_rotate_anim);
LinearInterpolator lin = new LinearInterpolator();
operatingAnim.setInterpolator(lin);
mRefreshIv.startAnimation(operatingAnim);
}
/**
* 完成加载
*/
@Override
public void onComplete() {
isFirst = false;
mRefreshIv.postDelayed(new Runnable() {
@Override
public void run() {
reset();
}
}, 500);
}
/**
* 初始化刷新view设置
*/
private void reset() {
mLastTime = formatTimeMillis(System.currentTimeMillis());
mTvRefreshTime.setText(NOT_FIRST_TIME_TEXT + mLastTime);
mTvRefreshText.setText(R.string.uikit_com_refresh_status_loosen_refreshing_hint_text);
mRefreshIv.setImageResource(R.drawable.uikit_com_pre_refresh_icon);
// 停止加载的时候清除动画
mRefreshIv.clearAnimation();
}
}
| [
"[email protected]"
]
| |
3534fb20a027773b25fd12319a0eb5bdab5bf7d2 | 192b38ebd7d274b4c09e1add8027f5ec48f8a322 | /src/test/java/com/ems/controller/test/DepartmentsControllerTest.java | 4d065d7c853adb9f76c9ec740ce9997034d57fb7 | []
| no_license | gaurav07b/empMgmtSystem | 41a6e61e03ee87cfac1c6e9a4379ce4906ff7c75 | 15b1cae24ef8a08b80ce566160087186645af88c | refs/heads/master | 2020-03-24T20:38:52.606556 | 2018-07-31T09:04:03 | 2018-07-31T09:04:03 | 142,989,628 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 4,997 | java | package com.ems.controller.test;
import static org.junit.Assert.*;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import com.ems.controller.DepartmentsController;
import com.ems.dto.DepartmentsDto;
import com.ems.response.ResponseData;
import com.ems.service.DeptServiceImpl;
import com.ems.service.IDepartmentService;
import com.google.gson.Gson;
@RunWith(SpringRunner.class)
//@ContextConfiguration
@WebMvcTest(DepartmentsController.class)
//@WebAppConfiguration
public class DepartmentsControllerTest {
@Autowired
private MockMvc mvc;
@Autowired
private WebApplicationContext ctx;
// @MockBean
// private DeptServiceImpl deptService;
@MockBean
private IDepartmentService ideptService;
@Before
public void setUp() {
this.mvc = MockMvcBuilders.webAppContextSetup(ctx).build();
}
//**************************************Basic Test Case***************8**********************
@Test
public void test() {
assert(true);
}
//*******************************************************************************************
@Test
public void testGetDept() throws Exception {
List<DepartmentsDto> lst = new ArrayList<>();
lst.add(new DepartmentsDto(20,"TestDepartment","TestLocation",null));
lst.add(new DepartmentsDto(21,"TestDepartment2","TestLocation2",null));
when(ideptService.getAllDept()).thenReturn(lst);
RequestBuilder requestBuilder = MockMvcRequestBuilders.get("/department").accept(MediaType.APPLICATION_JSON);
MvcResult result = mvc.perform(requestBuilder).andReturn();
verify(ideptService).getAllDept();
Gson gson = new Gson();
ResponseData responseData = gson.fromJson(result.getResponse().getContentAsString(), ResponseData.class);
assertEquals("200", responseData.getCode().toString());
assertEquals(result.getResponse().getContentType(), MediaType.APPLICATION_JSON_UTF8.toString());
}
// @Test
// public void testFindOne() throws Exception {
// DepartmentsDto dDto = new DepartmentsDto(20,"TestDepartment","TestLocation",null);
// when(iDeptServ.findOneDept(Mockito.anyInt())).thenReturn(dDto);
// RequestBuilder requestBuilder = MockMvcRequestBuilders.get("/department/3").accept(MediaType.APPLICATION_JSON);
// MvcResult result = mvc.perform(requestBuilder).andReturn();
// verify(iDeptServ).findOneDept(Mockito.anyInt());//to verify that service is called once
// Gson gson = new Gson();
// ResponseData responseData = gson.fromJson(result.getResponse().getContentAsString(), ResponseData.class);
// assertEquals(responseData.getCode().toString(), "200");
// assertEquals(result.getResponse().getContentType(), MediaType.APPLICATION_JSON_UTF8.toString());
// }
//
// @Test
// public void testAddNew() throws Exception {
// DepartmentsDto dDto = new DepartmentsDto(20,"TestDepartment","TestLocation",null);
// when(iDeptServ.addNewDept(Mockito.any(DepartmentsDto.class))).thenReturn(dDto);
// Gson gson = new Gson();
// RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/department").
// contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON).content(gson.toJson(dDto));
// MvcResult result = mvc.perform(requestBuilder).andReturn();//*******************************is this correct as it throws exception???
// verify(iDeptServ).addNewDept(Mockito.any(DepartmentsDto.class));
// ResponseData responseData = gson.fromJson(result.getResponse().getContentAsString(), ResponseData.class);
// assertEquals(responseData.getCode().toString(), "200");
// }
//
// @Test
// public void testDeleteDept() throws Exception {
// when(iDeptServ.deleteOneDept(Mockito.anyInt())).thenReturn("Deletion Successful");
// RequestBuilder requestBuilder = MockMvcRequestBuilders.delete("/department/"+"{id}", new Integer(1));
// MvcResult result = mvc.perform(requestBuilder).andReturn();
// verify(iDeptServ.deleteOneDept(Mockito.anyInt()));
// assertEquals(result,"Deletion Successful");
// }
}
| [
"[email protected]"
]
| |
f47eac863c63eb213b041011ac93461f00b170d9 | ed5782558e6452b29fb59a5640fc59a696e8c673 | /src/rockmails/Rockmails.java | ecf86a72b740fef21fa3d4c404f3f78bd877a8c1 | []
| no_license | grieche1705/Rockmails | 4f780caa8eee586741fd47e8d29466de93ce05b1 | 50e069791cf2e2805ec66ee2d416eaf7d8ef5253 | refs/heads/master | 2016-09-10T14:58:32.162711 | 2013-12-22T18:29:15 | 2013-12-22T18:29:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 470 | 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 rockmails;
/**
*
* @author pyrock
*/
public class Rockmails {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Graphic gui = new Graphic();
gui.start();
}
}
| [
"[email protected]"
]
| |
4f3de8f2689a5c3b0eb4a87e4a8a7468a5c5643b | 7010b9ed0cb7a5ea9363c7e0655bfd88c811afe7 | /src/main/java/org/createyourevent/app/service/impl/GiftServiceImpl.java | eeb571d2f6eee959f46000383ae8f6d9d60f4a21 | []
| no_license | createyourevent/createyourevent | a855c46054754acd0c1c432fe138b60692391b7f | f106fbddd2766d4fcb46921c13ad5a7861995bd3 | refs/heads/main | 2023-07-11T18:26:45.087832 | 2023-06-04T14:40:19 | 2023-06-04T14:40:19 | 332,435,618 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,843 | java | package org.createyourevent.app.service.impl;
import java.util.Optional;
import org.createyourevent.app.domain.Gift;
import org.createyourevent.app.repository.GiftRepository;
import org.createyourevent.app.service.GiftService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Service Implementation for managing {@link Gift}.
*/
@Service
@Transactional
public class GiftServiceImpl implements GiftService {
private final Logger log = LoggerFactory.getLogger(GiftServiceImpl.class);
private final GiftRepository giftRepository;
public GiftServiceImpl(GiftRepository giftRepository) {
this.giftRepository = giftRepository;
}
@Override
public Gift save(Gift gift) {
log.debug("Request to save Gift : {}", gift);
return giftRepository.save(gift);
}
@Override
public Optional<Gift> partialUpdate(Gift gift) {
log.debug("Request to partially update Gift : {}", gift);
return giftRepository
.findById(gift.getId())
.map(existingGift -> {
if (gift.getTitle() != null) {
existingGift.setTitle(gift.getTitle());
}
if (gift.getDescription() != null) {
existingGift.setDescription(gift.getDescription());
}
if (gift.getPhoto() != null) {
existingGift.setPhoto(gift.getPhoto());
}
if (gift.getPhotoContentType() != null) {
existingGift.setPhotoContentType(gift.getPhotoContentType());
}
if (gift.getPoints() != null) {
existingGift.setPoints(gift.getPoints());
}
if (gift.getActive() != null) {
existingGift.setActive(gift.getActive());
}
if (gift.getStock() != null) {
existingGift.setStock(gift.getStock());
}
return existingGift;
})
.map(giftRepository::save);
}
@Override
@Transactional(readOnly = true)
public Page<Gift> findAll(Pageable pageable) {
log.debug("Request to get all Gifts");
return giftRepository.findAll(pageable);
}
@Override
@Transactional(readOnly = true)
public Optional<Gift> findOne(Long id) {
log.debug("Request to get Gift : {}", id);
return giftRepository.findById(id);
}
@Override
public void delete(Long id) {
log.debug("Request to delete Gift : {}", id);
giftRepository.deleteById(id);
}
}
| [
"[email protected]"
]
| |
5236b6f01ff1c889e575fd09426898a688c1874f | 1091e03dcaa2ef550b4659fce39001b887a8abb7 | /Sorts/src/com/sorts/Search.java | 6af1c40a8c3267cebabd70da5fa8d4c6180dfd06 | []
| no_license | marcoantoniodiazdiaz/ideaProyects | 6b0446f7c268a20c21139b1e5b3c3825bf2196f0 | bfaed26cfbdfe5c27db1c0c0abe9d3f819c7f863 | refs/heads/master | 2020-09-27T01:14:39.771024 | 2019-12-06T18:30:11 | 2019-12-06T18:30:11 | 226,387,241 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,488 | java | package com.sorts;/*
██████╗ ██╗ █████╗ ███████╗
██╔══██╗██║██╔══██╗╚══███╔╝
██║ ██║██║███████║ ███╔╝
██║ ██║██║██╔══██║ ███╔╝
██████╔╝██║██║ ██║███████╗
╚═════╝ ╚═╝╚═╝ ╚═╝╚══════╝
*/
public class Search {
public void busquedaSecuencial(int arr[], int find) {
int ciclos = 0;
for (int n : arr) {
ciclos ++;
if (n == find) {
System.out.println("Encontrado");
System.out.println("Ciclos: " + ciclos);
return;
}
}
System.out.println("No encotrado");
}
public void busquedaBinaria(int arr[], int find){
int ciclos = 0;
int n = arr.length;
int centro, inf=0 ,sup=n-1;
while(inf <= sup) {
ciclos ++;
centro = (sup + inf) / 2;
if (arr[centro] == find) {
System.out.println("Encontrado");
System.out.println("Ciclos: " + ciclos);
return;
}
else if(find < arr [centro] ){
sup = centro - 1;
}
else {
inf = centro + 1;
}
}
}
}
| [
"[email protected]"
]
| |
b5def20081226fbb0ef383bb227b97fa05206c78 | dc60f269b5749bbd56cae58bf3c3adce6acdcfc2 | /OnLineSpringLastProject/src/main/java/com/sist/web/CharController.java | 1e5f166e9520e7748b87a51067acdfdf62bfb35f | []
| no_license | chaijewon/20200914-OnlineStudy | 37ddae6b8095af0ea127d1193f69778bc8348af7 | fcbe9431fce83f2bbebd32157bb9e333d675b35a | refs/heads/master | 2023-02-01T22:13:14.729742 | 2020-12-04T07:07:26 | 2020-12-04T07:07:26 | 295,305,611 | 2 | 9 | null | null | null | null | UTF-8 | Java | false | false | 522 | java | package com.sist.web;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@CrossOrigin("http://localhost:3000")
public class CharController {
@RequestMapping("chat/chat.do")
public String chat_chat(HttpSession session)
{
String name=(String)session.getAttribute("id");
return name;
}
}
| [
"채제분@LAPTOP-G5H90GCB"
]
| 채제분@LAPTOP-G5H90GCB |
33b00a3f3b64aeb99bd98124afcc93970fedb199 | 32d31bd725fabb5beae08c24d83a351cbe2931df | /Homework15/src/TextProvider.java | 884e0293637ffb8b9b273ccea13810ce3b732c9b | []
| no_license | echpochmc/11-807_Sultanov | 4fd2ee5fa45c3699bf6d84dfb003c6711bafe40b | 5868d4e6f68aa96c1333c3ac52777ab174ffac46 | refs/heads/master | 2020-04-13T17:14:29.187205 | 2018-12-27T23:00:06 | 2018-12-27T23:00:06 | 163,342,403 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 124 | java | import java.io.IOException;
/**
* Entity, representing a text
*/
public interface TextProvider {
String getText();
}
| [
"[email protected]"
]
| |
8ea93d2c5078456a7ff7bf628e0c9c78fdef9e73 | 2d79470f65487a7884d2b93d668b3252b333b33d | /src/BeautifulArrangement.java | 882b7077776fe8088aad80fcd06537cd0803ae4f | []
| no_license | bravados/leetcode | 46c8228ec0931845b3509db32a935eed084b27bd | b6b1b395a68dd307fbc87ea2cd4541addf37d999 | refs/heads/main | 2023-03-07T11:07:25.975887 | 2021-02-18T17:49:45 | 2021-02-18T17:49:45 | 340,130,021 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 851 | java | import java.util.*;
public class BeautifulArrangement {
private int backtrack(int index, int n, boolean [] visited){
if(index > n) return 1;
int count = 0;
for(int i = 1; i <= n; i++)
if(!visited[i - 1] && (i % index == 0 || index % i == 0)){
visited[i - 1] = true;
count += backtrack(index + 1, n, visited);
visited[i - 1] = false;
}
return count;
}
public int countArrangement(int n){
return backtrack(1, n, new boolean[n]);
}
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
BeautifulArrangement beautifulArrangement = new BeautifulArrangement();
System.out.println(beautifulArrangement.countArrangement(n));
}
}
| [
"[email protected]"
]
| |
5fd6cde199819ebf0bf06ee0b2c326e44bdffb0c | fc453f552b9ca55f605a8dec99fcba631fe60a45 | /Java/Basicos/Prueba1/src/prueba1/Prueba1.java | acc10e3963548216cc04274384bc1dc0cbe2d957 | []
| no_license | jpguitron/TC2004-AgoDic17 | 23f572d1f321d8a17b36822889dea5b8a4f1db72 | e04ea05952b7b7ecec42150ad08b179715c3d44f | refs/heads/master | 2021-01-15T19:06:34.961001 | 2017-10-27T17:44:51 | 2017-10-27T17:44:51 | 99,808,163 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 841 | java | package prueba1;
import java.util.Scanner;
public class Prueba1
{
protected int edad;
protected String nombre;
public Prueba1(int edad, String nombre)
{
this.edad = edad;
this.nombre = nombre;
}
public int getEdad()
{
return edad;
}
protected void printName()
{
System.out.println("Mi nombre es: "+ nombre);
}
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.println("Ingresa tu nombre");
String nombre = s.nextLine();
System.out.println("Ingresa tu edad");
int edad= s.nextInt();
Prueba1 ejemplo = new Prueba1(edad, nombre);
ejemplo.printName();
System.out.println("Mi edad es " + ejemplo.getEdad());
}
}
| [
"[email protected]"
]
| |
fb31fc326c3e9ace2cb9d7b82564f87b5cc1bdcc | 6f48cd3a88ba99370689d800e30d39645900f37d | /mysite2/src/main/java/com/cafe24/security/AuthLoginInterceptor.java | 23b8f70908f0fc3b8414d88c1d388c6d28c7b643 | []
| no_license | MaximSungmo/mysite | dfdbf916e7244a91823635492bcb6f89366afac6 | a9e90bb0a6088e5c117bbfb6591a5b98af63446a | refs/heads/master | 2020-06-11T03:07:38.564322 | 2019-06-11T07:32:18 | 2019-06-11T07:32:18 | 193,834,797 | 1 | 0 | null | 2019-06-26T05:22:34 | 2019-06-26T05:22:32 | null | UTF-8 | Java | false | false | 1,428 | java | package com.cafe24.security;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.cafe24.mysite.service.UserService;
import com.cafe24.mysite.vo.UserVo;
public class AuthLoginInterceptor extends HandlerInterceptorAdapter {
@Autowired
private UserService userService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
String email = request.getParameter("email");
String password = request.getParameter("password");
// ApplicationContext ac =
// WebApplicationContextUtils.
// getWebApplicationContext(request.getServletContext());
// UserService userService = ac.getBean(UserService.class);
UserVo userVo = new UserVo();
userVo.setEmail(email);
userVo.setPassword(password);
UserVo authUser = userService.getUser(userVo);
if(authUser == null) {
response.sendRedirect(request.getContextPath() + "/user/login");
return false;
}
// session 처리
HttpSession session = request.getSession(true);
session.setAttribute("authUser", authUser);
response.sendRedirect( request.getContextPath() );
return false;
}
}
| [
"[email protected]"
]
| |
d1e52b31d756a3d31aaa41c1076edc808f881dd0 | 109cf714e0ac5bae02c98ef181e9b66504b3f563 | /app/src/androidTest/java/com/example/kif/lesson2_fragment/ExampleInstrumentedTest.java | 09c5261d1c3f582f197a374c99df0a510dbf12bd | []
| no_license | kafurmin/Lesson2_fragment | 0a72ad4e541c821c206b4f6e3d451081283247fa | d32e59cce11d7295a4c010bb6daa80fb076e69f8 | refs/heads/master | 2021-01-21T14:28:32.195048 | 2017-06-24T09:03:38 | 2017-06-24T09:03:38 | 95,287,021 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 768 | java | package com.example.kif.lesson2_fragment;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.kif.lesson2_fragment", appContext.getPackageName());
}
}
| [
"[email protected]"
]
| |
3dab98075d903f26c3b23e2e44e56c71b4139547 | 11d64a550927e5e5b42b9f8563ca52c8e9adeb1e | /20211109/src/Ex_11test.java | 897e27b72b5a244e1e8fb5a1f071188440578bfb | []
| no_license | kim0yeeun/java | 1198575c7985db89607570111c758bd9a3cfb663 | 9e6d305e58a4780d73fa9541724afb69d3da4a9d | refs/heads/main | 2023-08-30T14:52:42.897247 | 2021-11-12T01:14:48 | 2021-11-12T01:14:48 | 424,508,296 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 302 | java |
public class Ex_11test {
public static void main(String[] args) {
Ex_11 ex11 = new Ex_11();
ex11.setFirst(20);
ex11.setSecond(10);
int result = ex11.add();
System.out.println(result);
System.out.println();
int result1 = ex11.sub();
System.out.println(result1);
}
}
| [
"user@DESKTOP-4NMVE1B"
]
| user@DESKTOP-4NMVE1B |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.