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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5e8e22c2b735179e3a8097b4467a7b6a6fdf9b36 | d7b7eedfa1c24e53b4665b44bb0814abeec72c09 | /11/11.9/SimpleClipboard.java | 0e721ae3d5739ef0d6de0df131d18b2243762383 | []
| no_license | lefeudelavie/CreazyJavaLearn | a2e01e47952405c42f7d2826c2fb09367e8022e2 | 507ef0066b101f3bc0a02379df6763ce68b03c45 | refs/heads/master | 2021-06-07T18:17:10.730984 | 2021-05-11T15:52:17 | 2021-05-11T15:52:17 | 159,046,456 | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 1,588 | java | import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.datatransfer.*;
public class SimpleClipboard
{
private Frame f = new Frame("¼òµ¥¼ôÌù°å");
private Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
private TextArea jtaCopyTo = new TextArea(5, 20);
private TextArea jtaPaste = new TextArea(5, 20);
private Button btCopy = new Button("¸´ÖÆ");
private Button btPaste = new Button("Õ³Ìù");
public void init()
{
Panel p = new Panel();
p.add(btCopy);
p.add(btPaste);
btCopy.addActionListener(event ->
{
StringSelection contents = new StringSelection(jtaCopyTo.getText());
clipboard.setContents(contents, null);
});
btPaste.addActionListener(event ->
{
if (clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor))
{
try
{
String content = (String)clipboard.getData(DataFlavor.stringFlavor);
jtaPaste.append(content);
}
catch (Exception e)
{
e.printStackTrace();
}
}
});
Box box = new Box(BoxLayout.X_AXIS);
box.add(jtaCopyTo);
box.add(jtaPaste);
f.add(p, BorderLayout.SOUTH);
f.add(box, BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
public static void main(String[] args)
{
new SimpleClipboard().init();
}
}
| [
"[email protected]"
]
| |
53a95f0f33b0352f0a775d9fbe57ed40d7ea40f8 | 0d14680ed62ec8c3fba74222ed0015bc7c972915 | /src/test/java/net/seocoo/ggys/module/coupon/service/impl/CouponTemplateServiceImplTest.java | 9c772ac30d0ce3954f9942f5d5cd1508b22d35df | []
| no_license | love52saber/ggys | 3667567ece5431a547bb9b1bda1feaaea51cb4e2 | fce00e4cd81add9e586c88aef513eb2c65aeec95 | refs/heads/master | 2022-06-30T09:12:21.227535 | 2019-08-27T13:07:20 | 2019-08-27T13:07:20 | 204,705,232 | 0 | 0 | null | 2022-06-29T15:58:47 | 2019-08-27T13:06:23 | Java | UTF-8 | Java | false | false | 622 | java | package net.seocoo.ggys.module.coupon.service.impl;
import net.seocoo.ggys.module.coupon.service.CouponTemplateService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @author ZengXiaoLiang
* @date 2018/5/29 21:28
**/
@RunWith(SpringRunner.class)
@SpringBootTest
public class CouponTemplateServiceImplTest {
@Autowired
private CouponTemplateService couponTemplateServiceImpl;
@Test
public void test(){
}
} | [
"[email protected]"
]
| |
1948b71f23277f3ae7387a0257a66bdc395f827a | 0ec0175900d862a67c586eee6ecc849de16e102d | /sources/TestClass.java | 91e5ea5b0182fa0bd72e339562eb4781a99006e2 | []
| no_license | arshedg/history | b7f567becbe3a2ebf874c13978fa39d5049322eb | 4dd58b9d9cc6058e3437c7cc841f927b616998dc | refs/heads/master | 2016-09-10T09:31:54.523036 | 2016-02-13T21:39:53 | 2016-02-13T21:39:53 | 28,503,803 | 1 | 2 | null | null | null | null | UTF-8 | Java | false | false | 2,661 | java |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author arshed
*/
public class TestClass {
public static void main(String[] args) {
ConsoleReader reader = new ConsoleReader();
String string = reader.getLine();
int t = reader.getInt();
Map<String,String> map = createMap(string);
for (int i = 0; i < t; i++) {
solve(map,reader);
}
}
private static Map<String,String> createMap(String string){
Map<String,String> map = new HashMap<>();
for(int i=0;i<string.length();i++){
for(int j=i;j<string.length();j++){
map.put(i+":"+j, string.substring(i, j+1));
}
}
return map;
}
private static void solve(Map<String,String> map, ConsoleReader reader) {
int l1=reader.getInt()-1;
int r1=reader.getInt()-1;
int l2=reader.getInt()-1;
int r2=reader.getInt()-1;
if(l1-r1!=l2-r2){
System.out.println("No");
return;
}
if(map.get(l1+":"+r1).equals(map.get(l2+":"+r2))){
System.out.println("Yes");
}else{
System.out.println("No");
}
}
static class ConsoleReader{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
LinkedList<String> tokens = new LinkedList<>();
public int getInt(){
String token = getToken();
return Integer.parseInt(token);
}
public long getLong(){
return Long.parseLong(getToken());
}
public float getFloat(){
return Float.parseFloat(getToken());
}
public String getLine(){
try {
tokens.clear();
return reader.readLine();
} catch (IOException ex) {
throw new RuntimeException("reading failed");
}
}
private String getToken() {
if(tokens.isEmpty()){
try {
String line = reader.readLine();
String parts[] = line.split(" ");
for(String part:parts){
tokens.add(part);
}
} catch (IOException ex) {
throw new RuntimeException("not able to read");
}
}
return tokens.poll();
}
}
}
| [
"[email protected]"
]
| |
ad8e23c116291d9cdb8022fe4014cde4933aa7c3 | 5d6ad5c43c14057daee3a33f8a3bc5c4ea13adc1 | /src/test/java/com/qa/MapTests/AccountServiceTest.java | 641696b9bedd4caefcb70a57bd31380a761d6242 | []
| no_license | Matt25969/Account-SE-Base | 8bb516c4c56e50ad26b413255371089ec587aa42 | 56cd5eec1327e10c5ea1b8926f70a7b6d7d09b67 | refs/heads/master | 2020-04-17T00:09:45.978057 | 2019-02-11T09:37:03 | 2019-02-11T09:37:03 | 166,039,290 | 1 | 6 | null | null | null | null | UTF-8 | Java | false | false | 1,064 | java | package com.qa.MapTests;
import static org.junit.Assert.*;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.qa.persistence.domain.Account;
import com.qa.persistence.repository.AccountMapRepository;
public class AccountServiceTest {
@Before
public void setup() {
}
@Test
public void addAccountTest() {
fail("TODO");
}
@Test
public void add2AccountsTest() {
fail("TODO");
}
@Test
public void removeAccountTest() {
fail("TODO");
}
@Test
public void remove2AccountsTest() {
fail("TODO");
}
@Test
public void remove2AccountTestAnd1ThatDoesntExist() {
fail("TODO");
}
@Test
public void jsonStringToAccountConversionTest() {
fail("TODO");
}
@Test
public void accountConversionToJSONTest() {
fail("TODO");
}
@Test
public void getCountForFirstNamesInAccountWhenZeroOccurances() {
fail("TODO");
}
@Test
public void getCountForFirstNamesInAccountWhenOne() {
fail("TODO");
}
@Test
public void getCountForFirstNamesInAccountWhenTwo() {
fail("TODO");
}
}
| [
"[email protected]"
]
| |
650055d985e904ce3f31dd573c838842e7e8e114 | ee84f9b93fc4038fed7448578df0ce60f71c61e3 | /Java Recursion/DesignPatterns/src/com/balleyne/designpatterns/converter/ConverterRunner.java | 983d19e4743331329f24aa8df4bf53464480e987 | []
| no_license | BAlleyneDev/Java-Algorithm-Practice | 825eb46e32b3099968d8d9c273097cfccf68eb4f | f83bdfd05120a970945a76ceb65d8ae02b5b7c36 | refs/heads/master | 2022-11-16T20:18:28.915426 | 2020-07-10T06:52:30 | 2020-07-10T06:52:30 | 278,560,794 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 470 | java | package com.balleyne.designpatterns.converter;
public class ConverterRunner {
public static void main(String[] args) {
ConverterFactory converter = new WeightConverterFactory();
double result = converter.calculate(5.87, "tonnes", "ounces");
System.out.println("Weight: "+result);
ConverterFactory converter2 = new LengthFactory();
double result2 = converter2.calculate(5.87, "m", "cm");
System.out.println("Length: "+result2);
}
}
| [
"[email protected]"
]
| |
93018b5586ffed179f0bc1bef70e3f44f0dbacea | ca9208cc7fb8a8c85f3a975b0de280dbaa5e77d1 | /src/Main.java | 3c337faefbbf4491e9214f87e99e63463160bc6f | []
| no_license | prashant-chaudhary-code/Test | 3dca14e63ab0baf1f6ecb7f3999bd3789bba299d | e164b252ff2d876e7b78dfe879dccb65fe2b0dce | refs/heads/master | 2021-11-09T12:52:44.439751 | 2021-11-02T18:27:05 | 2021-11-02T18:27:05 | 95,423,143 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 140 | java | public class Main {
public static void main(String args[]) {
System.out.println("My first Test program for GIT push");
}
}
| [
"[email protected]"
]
| |
575600ea51926fa0e931a30ed5980e9c5c8f2a34 | 8db9f0d6b2b8e9c3be652f7bbc827f3e94c742eb | /src/S1401TO1600/S1590.java | 801fcbd8b5eea62d06999318cbb4486825682e0c | []
| no_license | proliuxz/Lintcode | de7e4bb369abb5b59c7f3c128f75a0e3ba396398 | 3b9e5dbb14fe257d77adc82325cc8cf8f3aae8fe | refs/heads/master | 2021-07-18T21:12:37.752690 | 2020-06-22T12:04:38 | 2020-06-22T12:04:38 | 183,857,014 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 733 | java | package S1401TO1600;
public class S1590 {
public int surfaceAreaof3DShapes(int[][] grid) {
// Write your code here.
int length = grid.length;
int surface1 = 0;
int surface2 = 0;
for (int i = 0; i < length; i++) {
for (int j = 0; j < length; j++) {
if (grid[i][j] != 0) {
surface1 += grid[i][j] * 4 + 2;
}
if (i != length - 1) {
surface2 += (grid[i][j] > grid[i + 1][j] ? grid[i + 1][j] : grid[i][j]) * 2;
surface2 += (grid[j][i] > grid[j][i + 1] ? grid[j][i + 1] : grid[j][i]) * 2;
}
}
}
return surface1 - surface2;
}
}
| [
"[email protected]"
]
| |
a6cad66fd9bb825ef9649cb85e74582f5aa3ff85 | 1f47217ad740b03b5ca7c965a01788dee3c0fbf7 | /JLibrary06/lib/XML/JAXB/jaxb/samples/xml-channel/src/Test.java | 3a49bee77c4b22545ce67dfe1fdd092299c77171 | []
| no_license | amitabha66/JLibrary06 | bee7fddca01188991af968a5678fe1d89dce7ee3 | f19056cee7a88318315f9c25f8618aface8f0683 | refs/heads/master | 2021-01-19T07:03:19.133486 | 2016-06-23T16:41:59 | 2016-06-23T16:41:59 | 61,802,950 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,870 | java | /*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* https://jwsdp.dev.java.net/CDDLv1.0.html
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* https://jwsdp.dev.java.net/CDDLv1.0.html If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.Reader;
/**
*
*
* @author
* Kohsuke Kawaguchi ([email protected])
*/
public class Test {
public static Object lock = new Object();
public static boolean ready = false;
public static void main(String[] args) throws Exception {
// launch the server
new Thread(new TestServer()).start();
// wait for the server to become ready
while( !ready ) {
synchronized( lock ) {
lock.wait(1000);
}
}
// reset the flag
ready = false;
// run the client
new TestClient().run();
// wait for the server to finish processing data
// from the client
while( !ready ) {
synchronized( lock ) {
lock.wait(1000);
}
}
System.exit(0);
}
}
| [
"[email protected]"
]
| |
248e06271378fb574471de5726d225e160f54041 | 15d173d594038eafdbc36f971a3737a4551db681 | /repository/ProtoDummyStarsign/src/main/java/domain/Spellspecies.java | 0a28ef78fc09b71aecf4b8e7c210a7bef06c2e00 | []
| no_license | hydrolythe/Starsignbackend | 662dd082ca05cbcf37a7e83b65cf31ed493b7c3c | e3ff93939d408ed5bfc3ef1c8f9ea257f93b2b76 | refs/heads/master | 2023-01-31T12:44:46.886976 | 2020-12-17T13:28:24 | 2020-12-17T13:28:24 | 322,299,435 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 79 | java | package domain;
public enum Spellspecies {
EQUIPMENT,
FIELD,
EVENT
}
| [
"[email protected]"
]
| |
a301ce86c370b7cf97a265e8b4af838d9cd601fa | 2af5e62c67b1294d2f44970e3fd478bdca7bce7d | /src/Traversal.java | 0fdfc9c96b7d3dfa1a2ed305508063227a51feaf | [
"MIT"
]
| permissive | MichaelMBradley/Detailing | 6f6380d705a753140cc089e17e6b3d667d44bf05 | 0783c13157e8b3cfd0b067cc9fbcd6271e2b5b62 | refs/heads/main | 2023-06-20T17:27:38.321828 | 2021-08-07T05:23:38 | 2021-08-07T05:23:38 | 363,982,326 | 0 | 0 | MIT | 2021-08-02T19:49:45 | 2021-05-03T15:52:13 | Java | UTF-8 | Java | false | false | 3,584 | java | import processing.core.PVector;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashSet;
public class Traversal {
public static Node closestNode(HashSet<Node> nodes, PVector vertex) {
Node close = new Node();
float tempDist;
float distance = Float.MAX_VALUE;
for(Node n : nodes) {
tempDist = PVector.dist(vertex, n.getPV());
if(tempDist < distance) {
distance = tempDist;
close = n;
}
}
return close;
}
public static PVector closestPoint(PVector p1, PVector p2, PVector p0) {
/*
Uses basic point-slope formulas to find the intersection of (p1, p2)
and the line perpendicular to (p1, p2) passing through the node.
Slightly slower.
*/
if(p1.x == p2.x) {
return new PVector(p1.x, p0.y);
}
if(p1.y == p2.y) {
return new PVector(p0.x, p1.y);
}
float m = (p2.y - p1.y) / (p2.x - p1.x);
float mi = -1 / m;
float x = (p1.x * m - p0.x * mi + p0.y - p1.y) / (m - mi);
float y = m * (x - p1.x) + p1.y;
return new PVector(x, y);
}
public static PVector closestPoint2(PVector p1, PVector p2, PVector p0) {
/*
Projects the node onto the vector between (p1, p2) to find the closest point.
Slightly faster.
*/
PVector y = PVector.sub(p0, p1);
PVector u = PVector.sub(p2, p1);
return u.mult(y.dot(u) / u.magSq()).add(p1);
}
public static HashSet<Node> containing(ArrayList<PVector> vertices, HashSet<Node> nodes, boolean inside) {
/*
Accepts a set of nodes, returns the subset
that is either inside or outside the shape.
*/
HashSet<Node> side = new HashSet<>();
Polygon shape = ShapeFunctions.toPolygon(vertices);
for(Node n : nodes) {
if(shape.contains(n.getX(), n.getY()) == inside) {
side.add(n);
}
}
return side;
}
public static PVector crossover(PVector p1, PVector p2, PVector p3, PVector p4) {
float m1 = (p2.x == p1.x) ? Float.NaN : (p2.y - p1.y) / (p2.x - p1.x);
float m2 = (p4.x == p3.x) ? Float.NaN : (p4.y - p3.y) / (p4.x - p3.x);
if(Float.isNaN(m1)) {
if(Float.isNaN(m2)) {
return new PVector(Float.NaN, Float.NaN);
} else {
return new PVector(p1.x, m2 * (p1.x - p3.x) + p3.y);
}
} else if(Float.isNaN(m2)) {
return new PVector(p3.x, m1 * (p3.x - p1.x) + p1.y);
} else {
float x = (m1 * p1.x - m2 * p3.x - p1.y + p3.y) / (m1 - m2);
return new PVector(x, m1 * (x - p1.x) + p1.y);
}
}
public static PVector newRelative(PVector base, float offset, float angle) {
return PVector.add(base, new PVector(1, 0).setMag(offset).rotate(angle));
}
public static boolean inLine(PVector p1, PVector p2, PVector test) {
/*
Tests if PVector test is in the line described by p1, p2
by determining of it's distance to the closest point on that
line is approximately 0 (for rounding errors).
*/
return PVector.dist(test, closestPoint2(p1, p2, test)) < 1;
}
public static ArrayList<Arc> delaunayTraversalToArcs(ArrayList<Node> traversal) {
ArrayList<Arc> arcs = new ArrayList<>();
System.out.println(traversal.size());
for(int i = 0; i < traversal.size() - 1; i++) {
if(traversal.get(i).getKruskalAdjacent().contains(traversal.get(i + 1))) {
arcs.add(Geometry.getArcKruskal(traversal.get(i), traversal.get(i + 1))[0]);//All(Arrays.asList(ShapeFunctions.getArcKruskal(traversal.get(i), traversal.get(i + 1))));//
System.out.println(arcs.get(arcs.size() - 1));
} else {
arcs.add(Geometry.arcLine(traversal.get(i).getPV(), traversal.get(i + 1).getPV()));
}
}
arcs.add(Geometry.arcLine(traversal.get(traversal.size() - 1).getPV(), traversal.get(0).getPV()));
return arcs;
}
}
| [
"[email protected]"
]
| |
edccb49e67f3905e4e053be91ffc0ed4110efe52 | 228b755cc1d2495a32e0052038285726d4db2c65 | /src/test/java/helpers/PageHelper.java | 210fc1f4dc516ffbdde15bcef0f0e04133c6e5b2 | []
| no_license | dsibagat/messaging_lk | bf2a835624014af5569fb8cbf3066add499c3250 | 25824dfd95959bad80d81553fe5f2b01e84ab0c8 | refs/heads/main | 2023-03-22T23:37:39.870542 | 2021-03-14T08:13:52 | 2021-03-14T08:13:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 796 | java | package helpers;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.$x;
public class PageHelper {
public static void openPersonalData() {
$x("//span[contains(text(),'Профиль')]").click();
$x("//a[contains(text(),'Личные данные')]").click();
}
public static void clickSave() {
$x("//button[contains(text(),'Сохранить')]").click();
}
public static void clickChange() {
$x("//button[contains(text(),'Изменить')]").click();
}
public static void setProfileData(String s, String userData) {
$(s).setValue(userData);
}
public static void setProfileTimeZone(Integer timeZone) {
$("#profile_timeZone").selectOption(timeZone);
}
}
| [
"[email protected]"
]
| |
85bfa65ebc5e2032764bb248e3c273212e528894 | 8172d6c45c0c9516fd2e89822c56aa99a33bc859 | /app/src/main/java/com/andrey/englishcard/utils/Pair.java | 0cbcdf636f5a1c3ce423ff47ea2648eb13eeadf3 | []
| no_license | karlson136/EnglishCard | 05170d0bd047aea13d34ac1fcf1f708b0dc52a2a | 1a5078343abd603f68929eafe14743476e656eb9 | refs/heads/master | 2021-01-22T17:33:19.472661 | 2016-07-25T18:32:53 | 2016-07-25T18:32:53 | 63,883,283 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 608 | java | package com.andrey.englishcard.utils;
/**
* Created by andrey on 22.07.16.
*/
public class Pair<T, U> {
private final T english;
private final U russian;
// serialization purpose
public Pair() {
english = null;
russian = null;
}
public Pair(T key, U value) {
this.english = key;
this.russian = value;
}
public static <T, U> Pair<T, U> pair(T english, U russian) {
return new Pair<T, U>(english, russian);
}
public T getEnglish() {
return english;
}
public U getRussian() {
return russian;
}
} | [
"[email protected]"
]
| |
b15b4b2026427913f4d5510de4cff1565814cf47 | 7070dfe4f01634bc4489247e1db5d1483b6a5e5f | /app/src/main/java/com/baoyz/swipemenulistview/SwipeMenuItem.java | a37181492ce5b14cb78584223c8a22c3f53e5c02 | []
| no_license | chutianfan/SNSApp | 342123b25810b5adeffff429a3b57ebc0006f25b | 4df34a714cc478ee227ec3e45daca66d41a72798 | refs/heads/master | 2021-01-23T20:13:21.454972 | 2016-03-11T18:05:48 | 2016-03-11T18:05:48 | 67,822,941 | 1 | 0 | null | 2016-09-09T18:32:24 | 2016-09-09T18:32:24 | null | UTF-8 | Java | false | false | 1,807 | java | package com.baoyz.swipemenulistview;
import android.content.Context;
import android.graphics.drawable.Drawable;
public class SwipeMenuItem {
private Drawable background;
private Drawable icon;
private int id;
private Context mContext;
private String title;
private int titleColor;
private int titleSize;
private int width;
public SwipeMenuItem(Context context) {
this.mContext = context;
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public int getTitleColor() {
return this.titleColor;
}
public int getTitleSize() {
return this.titleSize;
}
public void setTitleSize(int titleSize) {
this.titleSize = titleSize;
}
public void setTitleColor(int titleColor) {
this.titleColor = titleColor;
}
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
this.title = title;
}
public void setTitle(int resId) {
setTitle(this.mContext.getString(resId));
}
public Drawable getIcon() {
return this.icon;
}
public void setIcon(Drawable icon) {
this.icon = icon;
}
public void setIcon(int resId) {
this.icon = this.mContext.getResources().getDrawable(resId);
}
public Drawable getBackground() {
return this.background;
}
public void setBackground(Drawable background) {
this.background = background;
}
public void setBackground(int resId) {
this.background = this.mContext.getResources().getDrawable(resId);
}
public int getWidth() {
return this.width;
}
public void setWidth(int width) {
this.width = width;
}
}
| [
"[email protected]"
]
| |
f4f7743dd28292e6d816b57d7c8461f7e7a2f76f | 065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be | /drjava_cluster/15520/src_1.java | 6b961a62ec455fcc14049a0d1d435502e02a36d2 | []
| no_license | martinezmatias/GenPat-data-C3 | 63cfe27efee2946831139747e6c20cf952f1d6f6 | b360265a6aa3bb21bd1d64f1fc43c3b37d0da2a4 | refs/heads/master | 2022-04-25T17:59:03.905613 | 2020-04-15T14:41:34 | 2020-04-15T14:41:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 26,220 | java | /*BEGIN_COPYRIGHT_BLOCK
*
* Copyright (c) 2001-2008, JavaPLT group at Rice University ([email protected])
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software is Open Source Initiative approved Open Source Software.
* Open Source Initative Approved is a trademark of the Open Source Initiative.
*
* This file is part of DrJava. Download the current version of this project
* from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
*
* END_COPYRIGHT_BLOCK*/
package edu.rice.cs.drjava.model.definitions.reducedmodel;
import java.util.Stack;
/** Keeps track of the true braces (i.e., "() {}[]"). This reduced sub-model is used to balance braces for both
* indenting and highlighting purposes. For example, when the user's caret is immediately after a closing brace,
* this allows the DefinitionsPane to produced a highlight extending from the closing brace to its match.
* @version $Id$
* @author JavaPLT
*/
public class ReducedModelBrace extends AbstractReducedModel {
private ReducedModelControl _parent; // contains the walker which is moved by moveWalkerGetState
public ReducedModelBrace(ReducedModelControl parent) {
super();
_parent = parent;
}
public void insertChar(char ch) {
switch(ch) {
case '{':
case '}':
case '[':
case ']':
case '(':
case ')':
_insertBrace(String.valueOf(ch));
break;
default:
_insertGap(1);
break;
}
}
/** Helper function for top level brace insert functions.
*
* <OL>
* <li> at Head: not special case
* <li> at Tail: not special case
* <li> between two things (offset is 0):
* <ol>
* <li> insert brace
* <li> move next
* <li> offset = 0
* </ol>
* <li> inside gap:
* <ol>
* <li> shrink gap to size of gap - offset.
* <li> insert brace
* <li> insert gap the size of offset.
* <li> move next twice
* <li> offset = 0
* </ol>
* <li> inside multiple char brace:
* <ol>
* <li> break
* <li> insert brace
* </ol>
* </OL>
* @param text the String type of the brace to insert
*/
private void _insertBrace(String text) {
if (_cursor.atStart() || _cursor.atEnd()) _cursor.insertNewBrace(text); // inserts brace and goes to next
else if (_cursor.current().isGap()) _cursor.insertBraceToGap(text);
else _cursor.insertNewBrace(text);
}
/** Inserts a gap between the characters in a multiple character brace. However, since ReducedModelBrace doesn't keep
* track of comment braces and escape sequences, we just throw an exception since the condition in insertGap
* that spawns this method doesn't arise.
*/
protected void insertGapBetweenMultiCharBrace(int length) {
throw new RuntimeException("ReducedModelBrace does not keep track of multi-character braces.");
}
/** Updates ReducedModelBrace to reflect cursor movement. Negative values move left from the cursor, positive
* values move right. All functionality has been refactored into TokenList.
* @param count indicates the direction and magnitude of cursor movement
*/
public void move(int count) { _cursor.move(count); }
/** Updates ReducedModelBrace to reflect text deletion. Negative values mean text left of the cursor, positive
* values mean text to the right. All functionality has been refactored into TokenList.
*/
public void delete( int count ) {
if (count == 0) return;
_cursor.delete(count);
return;
}
/** If the current brace is a /, a *, a // or a \n, it's not matchable. This means it is ignored on balancing and
* on next/prev brace finding. All other braces are matchable.
*/
private boolean _isCurrentBraceMatchable() { return _cursor.current().isMatchable(); }
/** Returns distance from current location of cursor to the location of the previous significant brace. For example,
* given "(...|)" where | signifies the cursor, previousBrace returns 4 because it goes to the position preceding the (.
* Given "* /|*", it returns 1 (the distance to the position of this brace) since you're in the middle of it and going
* backward finds it.
*/
public int previousBrace() {
int relDistance;
int dist = 0;
resetWalkerLocationToCursor(); //reset the interface to the comment model
TokenList.Iterator copyCursor = _cursor._copy();
if (!copyCursor.atStart()) copyCursor.prev();
if (copyCursor.atStart()) {
copyCursor.dispose();
return -1;
}
//initialize the size.
dist += _cursor.getBlockOffset();
relDistance = dist;
// if we're in the middle of the first brace element, we're not going to find any previous braces
while (!copyCursor.atStart()) {
if (!copyCursor.current().isGap()) {
if (moveWalkerGetState(-relDistance) == FREE) {
copyCursor.dispose();
return dist + copyCursor.current().getSize();
}
relDistance = 0;
}
dist += copyCursor.current().getSize();
relDistance += copyCursor.current().getSize();
copyCursor.prev();
}
copyCursor.dispose();
return -1;
}
/** Determines the distance to the location before the next open brace. For example, |...( where | is the cursor,
* returns 3 since it is 3 moves to the position preceding the (. NOTE: /|* returns the next brace. It does not
* return this brace because you are past it.
*/
public int nextBrace() {
int relDistance = 0;
int dist = 0;
TokenList.Iterator copyCursor = _cursor._copy();
resetWalkerLocationToCursor();
if ( copyCursor.atStart())
copyCursor.next();
if (_cursor.getBlockOffset() > 0) {
dist = copyCursor.current().getSize() - _cursor.getBlockOffset();
relDistance = dist;
copyCursor.next();
}
// there are no braces on the last brace element - it's empty
while (!copyCursor.atEnd() ) {
if (!copyCursor.current().isGap()) {
if (moveWalkerGetState(relDistance) ==
FREE) {
copyCursor.dispose();
return dist;
}
relDistance = 0;
}
relDistance += copyCursor.current().getSize();
dist += copyCursor.current().getSize();
copyCursor.next();
}
copyCursor.dispose();
return -1;
}
/** If the current ReducedToken is an open significant brace and the offset is 0 (i.e., if we're immediately left of
* said brace), push the current Brace onto a Stack and iterate forwards, keeping track of the distance covered.
* - For every closed significant Brace, if it matches the top of the Stack, pop the Stack. Increase the distance
* by the size of the Brace. If the Stack is Empty, we have a balance. Return distance. If the closed Brace does
* not match the top of the Stack, return -1; We have an unmatched open Brace at the top of the Stack.
* - For every open significant Brace, push onto the Stack. Increase distance by size of the Brace, continue.
* - Anything else, increase distance by size of the ReducedToken, continue.
*/
public int balanceForward() {
//System.out.println("-------------------------------------------");
Stack<Brace> braceStack = new Stack<Brace>();
TokenList.Iterator iter = _cursor._copy();
resetWalkerLocationToCursor();
if (iter.atStart() || iter.atFirstItem() || ! openBraceImmediatelyLeft()) {
// System.out.println("openBraceImmediatelyLeft(): "+openBraceImmediatelyLeft());
iter.dispose();
// System.out.println("! atStart, atFirstItem, or no closed brace");
return -1;
}
iter.prev();
ReducedToken curToken = iter.current();
assert curToken instanceof Brace; // In fact, it is a significant matchable open brace.
int openBraceDistance = - curToken.getSize();
moveWalkerGetState(openBraceDistance);
braceStack.push((Brace) curToken);
iter.next();
moveWalkerGetState(-openBraceDistance);
int relDistance = 0; // distance to closest preceding Brace (non-gap)
int distance = 0; // distance to end of original open Brace (immediately left of cursor on entry)
/* Loop until either:
* (i) we get a match and the stack is empty (success);
* (ii) we reach the end of a file and haven't found a match and abort; or
* (iii) we reach a close brace that doesn't have a match and abort.
*/
while (! iter.atEnd() && ! braceStack.isEmpty()) {
curToken = iter.current(); // a ReducedToken is either a Gap or a Brace
if (! curToken.isGap()) { // curToken is a Brace
Brace curBrace = (Brace) curToken;
if (moveWalkerGetState(relDistance) == FREE) {
// check for closed brace
if (curBrace.isClosedBrace()) {
Brace popped = braceStack.pop();
if (! curBrace.isMatch(popped)) {
iter.dispose();
// System.out.println("! encountered closed brace that didn't match");
return -1;
}
}
// otherwise, this must be an open brace
else braceStack.push(curBrace);
}
relDistance = 0; // we moved the walker back to the right edge of the curBrace
}
// increment distances of size of current token
int size = curToken.getSize();
distance += size;
relDistance += size;
iter.next();
}
// check if we exited because of failure
if (! braceStack.isEmpty()) {
iter.dispose();
// System.out.println("! ran to end of file. distance: " + distance);
return -1;
}
// success
else {
iter.dispose();
return distance;
}
}
// /**
// * This is no longer used internally -- highlight is always started on left.
// */
// public boolean openBraceImmediatelyRight() {
// if (_cursor.atEnd()) {
// return false;
// }
// else {
// return ((_cursor.getBlockOffset() == 0) && _cursor.current().isOpen() &&
// _isCurrentBraceMatchable());
// }
// }
public boolean openBraceImmediatelyLeft() {
if (_cursor.atStart() || _cursor.atFirstItem()) return false;
else {
_cursor.prev();
/*
System.out.println("+ closedBraceImmediatelyLeft() {");
System.out.println(" _cursor.getBlockOffset(): "+_cursor.getBlockOffset());
System.out.println(" _cursor.current().isClosed(): "+_cursor.current().isClosed());
System.out.println(" _isCurrentBraceMatchable(): "+_isCurrentBraceMatchable());
System.out.println(" }");
*/
boolean isLeft = ((_cursor.getBlockOffset() == 0) && _cursor.current().isOpen() &&
_isCurrentBraceMatchable());
//System.out.println("= token to left: " + _cursor);
_cursor.next();
//String output = (_cursor.atEnd()) ? "<end>": _cursor.toString();
//System.out.println("= current token: " + output);
return isLeft;
}
}
public boolean closedBraceImmediatelyLeft() {
if (_cursor.atStart() || _cursor.atFirstItem()) {
return false;
}
else {
_cursor.prev();
/*
System.out.println("+ closedBraceImmediatelyLeft() {");
System.out.println(" _cursor.getBlockOffset(): "+_cursor.getBlockOffset());
System.out.println(" _cursor.current().isClosed(): "+_cursor.current().isClosed());
System.out.println(" _isCurrentBraceMatchable(): "+_isCurrentBraceMatchable());
System.out.println(" }");
*/
boolean isLeft = ((_cursor.getBlockOffset() == 0) && _cursor.current().isClosed() &&
_isCurrentBraceMatchable());
//System.out.println("= token to left: " + _cursor);
_cursor.next();
//String output = (_cursor.atEnd()) ? "<end>": _cursor.toString();
//System.out.println("= current token: " + output);
return isLeft;
}
}
/* If the previous ReducedToken is a closed significant brace, offset is 0 (i.e., if we're immediately right of said
* brace), push the previous Brace onto a Stack and iterate backwards, keeping track of the distance covered.
* - For every open significant Brace, if it matches the top of the Stack, pop the Stack. Increase the distance by
* the size of the Brace. If the Stack is Empty, we have a balance. Return distance. If the open Brace does not
* match the top of the Stack, return -1; We have an unmatched closed Brace at the top of the Stack.
* - For every closed significant Brace, push onto the Stack. Increase distance by size of the Brace, continue.
* - Anything else, increase distance by size of the ReducedToken, continue.
*/
public int balanceBackward() {
//System.out.println("-------------------------------------------");
Stack<Brace> braceStack = new Stack<Brace>();
TokenList.Iterator iter = _cursor._copy();
resetWalkerLocationToCursor();
if (iter.atStart() || iter.atFirstItem() || ! closedBraceImmediatelyLeft()) {
//System.out.println("closedBraceImmediatelyLeft(): "+closedBraceImmediatelyLeft());
iter.dispose();
//System.out.println("! atStart, atFirstItem, or no closed brace");
return -1;
}
iter.prev();
assert iter.current() instanceof Brace; // In fact, it is a significant closed brace.
int relDistance = 0; // distance to right edge of nearest brace
int distance = 0; // distance to original cursor
/* We loop until:
* (i) we get a match and the stack is empty and report success
* (ii) we reach the start of a file and haven't found a match and aborrt
* (iii) we reach an open brace that doesn't have a match and abort
*/
do {
ReducedToken curToken = iter.current();
int size = curToken.getSize();
distance += size;
relDistance += size;
if (! curToken.isGap()) { // curToken is a Brace
Brace curBrace = (Brace) curToken;
if (moveWalkerGetState(- relDistance) == FREE) {
if (curBrace.isOpenBrace()) {
Brace popped = braceStack.pop();
if (! curBrace.isMatch(popped)) {
iter.dispose();
//System.out.println("! encountered open brace that didn't match");
return -1;
}
}
// closed
else braceStack.push(curBrace);
}
relDistance = 0;
}
iter.prev();
}
while (! iter.atStart() && ! braceStack.isEmpty());
// test to see if we exited without a match
if (! braceStack.isEmpty()) {
iter.dispose();
//System.out.println("! ran to end of brace stack");
return -1;
}
// success
else {
iter.dispose();
return distance;
}
}
protected ReducedModelState moveWalkerGetState(int relDistance) {
return _parent.moveWalkerGetState(relDistance);
}
protected void resetWalkerLocationToCursor() {
_parent.resetLocation();
}
/** Determines the brace (type and distance) enclosing the beginning of the current line (except the first line). The
* matching brace obviously must appear on the preceding line or before. To find the enclosing brace one must first
* move past this newline. The distance to the newline does not include the newline char.
*/
public BraceInfo getEnclosingBrace() {
Stack<Brace> braceStack = new Stack<Brace>();
TokenList.Iterator iter = _cursor._copy();
resetWalkerLocationToCursor();
// this is the distance to in front of the previous newline.
final int distToStart = _parent.getDistToStart();
if (distToStart == -1) {
iter.dispose();
return BraceInfo.NULL;
}
int relDistance = distToStart + 1;
int distance = relDistance;
// move to the proper location, then add the rest of the block and go to the previous.
iter.move(-relDistance);
final int offset = iter.getBlockOffset();
relDistance += offset;
distance += offset;
if (iter.atStart() || iter.atFirstItem()) { // no preceding brace exists
iter.dispose();
return BraceInfo.NULL;
}
iter.prev(); // move to reduced token preceding the newline.
String braceType;
// either we get a match and the stack is empty
// or we reach the start of a file and haven't found a match
// or we have a open brace that doesn't have a match,
// so we abort
while (! iter.atStart()) {
ReducedToken curToken = iter.current();
int size = curToken.getSize();
distance += size;
relDistance += size;
if (! curToken.isGap()) {
Brace curBrace = (Brace) curToken;
if (moveWalkerGetState(-relDistance) == FREE) {
// open
if (curBrace.isOpenBrace()) {
if (braceStack.isEmpty()) {
braceType = curBrace.getType();
// distance to brace == distance;
iter.dispose();
return new BraceInfo(braceType, distance);
}
Brace popped = braceStack.pop();
if (! curBrace.isMatch(popped)) {
iter.dispose();
return BraceInfo.NULL;
}
}
// closed
else braceStack.push(curBrace);
}
relDistance = 0;
}
// no matter what, we always want to increase the distance
// by the size of the token we have just gone over
iter.prev();
}
// Enclosing brace not found
iter.dispose();
return BraceInfo.NULL;
}
/** Finds distance to brace enclosing the start of this line. Assumes that the field info.distToStart already
* holds the distance to the previous newline. To find the enclosing brace one must first move past this newline.
* The distance held in this variable is only to the space in front of the newline hence you must move back that
* distance + 1.
* This is legacy code that will eventually be completely replaced.
*/
protected void getDistToLineEnclosingBrace(IndentInfo info) {
if (info.distToStart() == -1) { // There is no preceding newline char.
// info.setDistToLineEnclosingBrace(-1); // should be unnecessary
return;
}
Stack<Brace> braceStack = new Stack<Brace>();
TokenList.Iterator iter = _cursor._copy();
resetWalkerLocationToCursor();
// this is the distance to in front of the previous newline.
int relDistance = info.distToStart() + 1;
int distance = relDistance;
/* Invariant: distance == relDistance == distance to start of line preceded by newline. */
// move to the proper location, then add the rest of the block and go to the previous.
iter.move(-info.distToStart() - 1);
relDistance += iter.getBlockOffset();
distance += iter.getBlockOffset();
//reset the value of info signiling the necessary newline has not been found.
// info.setDistToLineEnclosingBraceStart(-1); // should be unnecessary
if (iter.atStart() || iter.atFirstItem()) {
iter.dispose();
return;
}
iter.prev();
// either we get a match and the stack is empty
// or we reach the start of a file and haven't found a match
// or we have a open brace that doesn't have a match,
// so we abort
while (! iter.atStart()) {
ReducedToken curToken = iter.current();
int size = curToken.getSize();
distance += size;
relDistance += size;
if (! curToken.isGap()) {
Brace curBrace = (Brace) curToken;
if (moveWalkerGetState(-relDistance) == FREE) {
// open
if (curBrace.isOpenBrace()) {
if (braceStack.isEmpty()) {
info.setLineEnclosingBraceType(curBrace.getType());
info.setDistToLineEnclosingBrace(distance);
iter.dispose();
return;
}
Brace popped = braceStack.pop();
if (! curBrace.isMatch(popped)) {
iter.dispose();
return;
}
}
// closed
else braceStack.push(curBrace);
}
relDistance = 0;
}
// no matter what, we always want to increase the distance
// by the size of the token we have just gone over
iter.prev();
}
iter.dispose();
return;
}
/** Determines the type of and distance to the brace enclosing the current location and stores this information
* in info.enclosingBraceType and info.distToEnclosingBrace. */
protected void getDistToEnclosingBrace(IndentInfo info) {
Stack<Brace> braceStack = new Stack<Brace>();
TokenList.Iterator iter = _cursor._copy();
resetWalkerLocationToCursor();
int relDistance = 0;
int distance = relDistance;
// Move to the proper location, then add the rest of the block and go to the previous.
relDistance += iter.getBlockOffset();
distance += iter.getBlockOffset();
// initialize info to signal that no preceding newline exists.
// info.setDistToEnclosingBraceStart(-1); // should be unnecessary
if (iter.atStart() || iter.atFirstItem()) {
iter.dispose();
return;
}
iter.prev();
// either we get a match and the stack is empty or we reach the start of a file and haven't found a match
// or we have a open brace that doesn't have a match, so we abort
while (!iter.atStart()) {
ReducedToken curToken = iter.current();
int size = curToken.getSize();
distance += size;
relDistance += size;
if (! curToken.isGap()) {
Brace curBrace = (Brace) curToken;
if (moveWalkerGetState(-relDistance) == FREE) {
// open
if (curBrace.isOpenBrace()) {
if (braceStack.isEmpty()) {
info.setEnclosingBraceType(curBrace.getType());
info.setDistToEnclosingBrace(distance);
iter.dispose();
return;
}
Brace popped = braceStack.pop();
if (! curBrace.isMatch(popped)) {
iter.dispose();
return;
}
}
// closed
else braceStack.push(curBrace);
}
relDistance = 0;
}
// no matter what, we always want to increase the distance
// by the size of the token we have just gone over
iter.prev();
}
iter.dispose();
return;
}
/** Determines the brace enclosing the current location. */
protected BraceInfo getEnclosingBraceCurrent() {
Stack<Brace> braceStack = new Stack<Brace>();
TokenList.Iterator iter = _cursor._copy();
resetWalkerLocationToCursor();
int relDistance = 0;
int distance = relDistance;
// Move to the proper location, then add the rest of the block and go to the previous.
int offset = iter.getBlockOffset();
relDistance += offset;
distance += offset;
if (iter.atStart() || iter.atFirstItem()) {
iter.dispose();
return BraceInfo.NULL;
}
iter.prev();
String braceType;
// either we get a match and the stack is empty or we reach the start of a file and haven't found a match
// or we have a open brace that doesn't have a match, so we abort
while (! iter.atStart()) {
ReducedToken curToken = iter.current();
int size = curToken.getSize();
distance += size;
relDistance += size;
if (! curToken.isGap()) {
Brace curBrace = (Brace) curToken;
if (moveWalkerGetState(-relDistance) == FREE) {
// open
if (curBrace.isOpenBrace()) {
if (braceStack.isEmpty()) {
braceType = curBrace.getType();
iter.dispose();
return new BraceInfo(braceType, distance);
}
Brace popped = braceStack.pop();
if (! curBrace.isMatch(popped)) {
iter.dispose();
return BraceInfo.NULL;
}
}
// closed
else braceStack.push(curBrace);
}
relDistance = 0;
}
// no matter what, we always want to increase the distance
// by the size of the token we have just gone over
iter.prev();
}
iter.dispose();
return BraceInfo.NULL;
}
}
| [
"[email protected]"
]
| |
b7f1b968ae0b0d5f25de4c6948442b4e36dc8b8d | 7545119988bc288492a256d63325c036f092e9db | /project/reversing/upos/upos_jadx/sources/android/support/v7/view/ContextThemeWrapper.java | 3690c43d77011a4f999c53b81d59290ab28fbb9f | []
| no_license | KhoaDD2/homework | edfc7ba5361028b0a508e6148b50e0dc199c061d | fb55d7591ed86f1f3391c42ecc60b5aca33e0bf7 | refs/heads/master | 2022-12-18T10:30:01.646990 | 2020-09-19T05:44:33 | 2020-09-19T05:44:33 | 295,287,598 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,699 | java | package android.support.v7.view;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.support.annotation.StyleRes;
import android.support.v7.appcompat.R;
import android.view.LayoutInflater;
public class ContextThemeWrapper extends ContextWrapper {
private LayoutInflater mInflater;
private Configuration mOverrideConfiguration;
private Resources mResources;
private Resources.Theme mTheme;
private int mThemeResource;
public ContextThemeWrapper() {
super((Context) null);
}
public ContextThemeWrapper(Context base, @StyleRes int themeResId) {
super(base);
this.mThemeResource = themeResId;
}
public ContextThemeWrapper(Context base, Resources.Theme theme) {
super(base);
this.mTheme = theme;
}
/* access modifiers changed from: protected */
public void attachBaseContext(Context newBase) {
super.attachBaseContext(newBase);
}
public void applyOverrideConfiguration(Configuration overrideConfiguration) {
if (this.mResources != null) {
throw new IllegalStateException("getResources() or getAssets() has already been called");
} else if (this.mOverrideConfiguration == null) {
this.mOverrideConfiguration = new Configuration(overrideConfiguration);
} else {
throw new IllegalStateException("Override configuration has already been set");
}
}
public Resources getResources() {
return getResourcesInternal();
}
private Resources getResourcesInternal() {
if (this.mResources == null) {
if (this.mOverrideConfiguration == null) {
this.mResources = super.getResources();
} else if (Build.VERSION.SDK_INT >= 17) {
this.mResources = createConfigurationContext(this.mOverrideConfiguration).getResources();
}
}
return this.mResources;
}
public void setTheme(int resid) {
if (this.mThemeResource != resid) {
this.mThemeResource = resid;
initializeTheme();
}
}
public int getThemeResId() {
return this.mThemeResource;
}
public Resources.Theme getTheme() {
Resources.Theme theme = this.mTheme;
if (theme != null) {
return theme;
}
if (this.mThemeResource == 0) {
this.mThemeResource = R.style.Theme_AppCompat_Light;
}
initializeTheme();
return this.mTheme;
}
public Object getSystemService(String name) {
if (!"layout_inflater".equals(name)) {
return getBaseContext().getSystemService(name);
}
if (this.mInflater == null) {
this.mInflater = LayoutInflater.from(getBaseContext()).cloneInContext(this);
}
return this.mInflater;
}
/* access modifiers changed from: protected */
public void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
theme.applyStyle(resid, true);
}
private void initializeTheme() {
boolean first = this.mTheme == null;
if (first) {
this.mTheme = getResources().newTheme();
Resources.Theme theme = getBaseContext().getTheme();
if (theme != null) {
this.mTheme.setTo(theme);
}
}
onApplyThemeResource(this.mTheme, this.mThemeResource, first);
}
public AssetManager getAssets() {
return getResources().getAssets();
}
}
| [
"[email protected]"
]
| |
1a780ec1e62e7348260f172905e51e6920b28a45 | 3144eaac0e5d800282232af00d80337c6dfb0098 | /zebone/dip/src/main/java/com/zebone/dip/ws/resource/check/component/UserCheck.java | b66924ee6f02fe2b7d27f776d78cd00f1caa50a2 | []
| no_license | HeeroLL/store | a2bf17a9edc1594fb2d8c71bf30cc8298d322b91 | 02177879d1bad1d919cc14498122fe3f98bc3453 | refs/heads/master | 2022-12-11T12:23:11.029000 | 2022-12-02T09:13:59 | 2022-12-02T09:13:59 | 25,424,633 | 8 | 3 | null | null | null | null | UTF-8 | Java | false | false | 1,644 | java | package com.zebone.dip.ws.resource.check.component;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.zebone.check.CheckResult;
import com.zebone.log.ErrorType;
import com.zebone.log.RangeError;
public class UserCheck {
private static final Log log = LogFactory.getLog(UserCheck.class);
private static final String message = "人员数据不存在";
public CheckResult checkUserData(Connection con,String org,String checkValue){
int resultCount = 0;
CheckResult checkResult = new CheckResult(true);
String querySql = "select count(*) as count from p_resource_user_info t " +
" where t.code='"+checkValue+"' and t.MEDICAL_ORGAN_CODE='"+org+"'";
try {
PreparedStatement ps = con.prepareStatement(querySql);
ResultSet rs = ps.executeQuery();
if(rs.next()){
resultCount = rs.getInt("count");
}
} catch (SQLException e) {
checkResult.setSuccess(false);
checkResult.setErrorCode(ErrorType.SYSTEM.getErrorCode());
checkResult.setErrorMessage(ErrorType.SYSTEM.getErrorDesc());
log.error(e.getMessage(),e);
return checkResult;
}finally{
if(resultCount == 0){
checkResult.setSuccess(false);
checkResult.setErrorCode(ErrorType.VALUE_CHECK.getErrorCode()+"-"+RangeError.VALUE_NO.getErrorCode());
checkResult.setErrorMessage(ErrorType.VALUE_CHECK.getErrorDesc()+"--"+RangeError.VALUE_NO.getErrorDesc()+"--"+message);
}
}
return checkResult;
}
}
| [
"[email protected]"
]
| |
b31b421c01bf562fb4bc1f9d145042895d992552 | 6079a95946f746c2c68f9e1b21d87799d139f857 | /src/boletin6/pkg14/Boletin614.java | f7c62d368ee9f7ac48f32a1f835bdf5caaa104d4 | []
| no_license | AaronADRC88/boletin6.14 | eb45a8181017c2f7257d6060443ee884893d6de5 | f6e306e1cbd0111c3b53be26140c41f5f328678b | refs/heads/master | 2020-03-30T05:19:18.707712 | 2014-10-23T10:19:28 | 2014-10-23T10:19:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 931 | java | /*(código: C1, precio: 24 euros), (código: H23, precio: 234 euros) y (código: M30,
precio: 109 euros). A continuación debe cambiarse o segundo producto da factura
polo seguinte (código: K123, precio:247 euros) e volve a imprimir a factura */
package boletin6.pkg14;
public class Boletin614 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Tenda tenda1 = new Tenda("C1", 24f);
Tenda tenda2 = new Tenda("H23", 234f);
Tenda tenda3 = new Tenda("M30", 109f);
System.out.println("prezos do C1, H23 e M30" + "\n" + tenda1.toString() + "\t" + "\n" + tenda2.toString() + "\n" + tenda3.toString());
tenda2.setCodigo("K123");
tenda2.setPrezo(247);
System.out.println("prezos do C1, K123 e M30" + "\n" + tenda1.toString() + "\t" + "\n" + tenda2.toString() + "\n" + tenda3.toString());
}
}
| [
"[email protected]"
]
| |
7e098621c54912783edc4af7528644ca97555850 | bf2966abae57885c29e70852243a22abc8ba8eb0 | /aws-java-sdk-iam/src/main/java/com/amazonaws/services/identitymanagement/model/transform/PutUserPermissionsBoundaryResultStaxUnmarshaller.java | 6c758a033dbb10fca81a894d673455fc795eb47b | [
"Apache-2.0"
]
| permissive | kmbotts/aws-sdk-java | ae20b3244131d52b9687eb026b9c620da8b49935 | 388f6427e00fb1c2f211abda5bad3a75d29eef62 | refs/heads/master | 2021-12-23T14:39:26.369661 | 2021-07-26T20:09:07 | 2021-07-26T20:09:07 | 246,296,939 | 0 | 0 | Apache-2.0 | 2020-03-10T12:37:34 | 2020-03-10T12:37:33 | null | UTF-8 | Java | false | false | 2,389 | java | /*
* Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.identitymanagement.model.transform;
import javax.xml.stream.events.XMLEvent;
import javax.annotation.Generated;
import com.amazonaws.services.identitymanagement.model.*;
import com.amazonaws.transform.Unmarshaller;
import com.amazonaws.transform.StaxUnmarshallerContext;
import com.amazonaws.transform.SimpleTypeStaxUnmarshallers.*;
/**
* PutUserPermissionsBoundaryResult StAX Unmarshaller
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class PutUserPermissionsBoundaryResultStaxUnmarshaller implements Unmarshaller<PutUserPermissionsBoundaryResult, StaxUnmarshallerContext> {
public PutUserPermissionsBoundaryResult unmarshall(StaxUnmarshallerContext context) throws Exception {
PutUserPermissionsBoundaryResult putUserPermissionsBoundaryResult = new PutUserPermissionsBoundaryResult();
int originalDepth = context.getCurrentDepth();
int targetDepth = originalDepth + 1;
if (context.isStartOfDocument())
targetDepth += 1;
while (true) {
XMLEvent xmlEvent = context.nextEvent();
if (xmlEvent.isEndDocument())
return putUserPermissionsBoundaryResult;
if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {
} else if (xmlEvent.isEndElement()) {
if (context.getCurrentDepth() < originalDepth) {
return putUserPermissionsBoundaryResult;
}
}
}
}
private static PutUserPermissionsBoundaryResultStaxUnmarshaller instance;
public static PutUserPermissionsBoundaryResultStaxUnmarshaller getInstance() {
if (instance == null)
instance = new PutUserPermissionsBoundaryResultStaxUnmarshaller();
return instance;
}
}
| [
""
]
| |
c6e4295f7430281f55ffceeab7b3d53b41a51550 | aaa50c2cc725f3f1a86d694e7ee0e8192f607a0e | /ext/daimlerspm/daimlerspmcore/src/com/daimler/spm/core/actions/quote/QuoteBuyerSubmitAction.java | 48176a568679933c8e5ca24958bb2075f71322ed | []
| no_license | hilbertlu/daimlerspm_poc | 5c4e0760bfd68753ced8013ca6875890df3e709f | 0f66b9a992d84df57f8e356d734e22231b14c851 | refs/heads/master | 2021-01-23T02:59:14.901408 | 2017-07-07T12:49:38 | 2017-07-07T12:49:38 | 86,037,802 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,651 | java | /*
* [y] hybris Platform
*
* Copyright (c) 2017 SAP SE or an SAP affiliate company. All rights reserved.
*
* This software is the confidential and proprietary information of SAP
* ("Confidential Information"). You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the
* license agreement you entered into with SAP.
*/
package com.daimler.spm.core.actions.quote;
import static com.daimler.spm.core.constants.DaimlerspmCoreConstants.QUOTE_USER_TYPE;
import de.hybris.platform.commerceservices.enums.QuoteUserType;
import de.hybris.platform.commerceservices.model.process.QuoteProcessModel;
import de.hybris.platform.commerceservices.order.CommerceQuoteService;
import de.hybris.platform.core.enums.QuoteState;
import de.hybris.platform.core.model.order.QuoteModel;
import de.hybris.platform.order.QuoteService;
import de.hybris.platform.processengine.action.AbstractSimpleDecisionAction;
import de.hybris.platform.task.RetryLaterException;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Required;
/**
* This action class creates a sales representative snapshot.
*/
public class QuoteBuyerSubmitAction extends AbstractSimpleDecisionAction<QuoteProcessModel>
{
private static final Logger LOG = Logger.getLogger(QuoteBuyerSubmitAction.class);
private CommerceQuoteService commerceQuoteService;
private QuoteService quoteService;
@Override
public Transition executeAction(final QuoteProcessModel process) throws RetryLaterException, Exception
{
Transition result;
if (LOG.isDebugEnabled())
{
LOG.debug(String.format("In QuoteBuyerSubmitAction for process code : [%s]", process.getCode()));
}
final QuoteUserType quoteUserType = (QuoteUserType) processParameterHelper
.getProcessParameterByName(process, QUOTE_USER_TYPE).getValue();
final QuoteModel quoteModel = getQuoteService().getCurrentQuoteForCode(process.getQuoteCode());
if (QuoteUserType.BUYER.equals(quoteUserType))
{
getCommerceQuoteService().createQuoteSnapshotWithState(quoteModel, QuoteState.SELLER_REQUEST);
result = Transition.OK;
}
else
{
result = Transition.NOK;
}
return result;
}
protected QuoteService getQuoteService()
{
return quoteService;
}
@Required
public void setQuoteService(final QuoteService quoteService)
{
this.quoteService = quoteService;
}
protected CommerceQuoteService getCommerceQuoteService()
{
return commerceQuoteService;
}
@Required
public void setCommerceQuoteService(final CommerceQuoteService commerceQuoteService)
{
this.commerceQuoteService = commerceQuoteService;
}
}
| [
"[email protected]"
]
| |
ea3e5e64de961d77921cb110f52ef9a6d78a9804 | cfd1b6ca1f2fa5209a9d8d593dc5326a4f216fdc | /zhizhi/.svn/pristine/67/67d87b98d34958729399c0b5b3c2ee91f55e78de.svn-base | e47b55e07ba5e979f8c07d2440dae3b3ebd6bd98 | []
| no_license | BuseeLi/zhizhi1.0 | a6c68a4be6d058039b31e6881944a04326efa8f9 | f10ee7ac5672106b31a39dd3bbd51c59aaeb0586 | refs/heads/master | 2021-05-02T10:52:36.257717 | 2018-02-08T13:57:00 | 2018-02-08T13:57:00 | 120,764,505 | 0 | 0 | null | 2018-02-08T13:25:18 | 2018-02-08T13:25:18 | null | UTF-8 | Java | false | false | 7,045 |
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2017 摩码创想, [email protected]
*
* This file is part of Jiaowu_v1.0.
* Jiaowu_v1.0 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Jiaowu_v1.0 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Jiaowu_v1.0. If not, see <http://www.gnu.org/licenses/>.
*
* 这个文件是Jiaowu_v1.0的一部分。
* 您可以单独使用或分发这个文件,但请不要移除这个头部声明信息.
* Jiaowu_v1.0是一个自由软件,您可以自由分发、修改其中的源代码或者重新发布它,
* 新的任何修改后的重新发布版必须同样在遵守LGPL3或更后续的版本协议下发布.
* 关于LGPL协议的细则请参考COPYING文件,
* 您可以在Jiaowu_v1.0的相关目录中获得LGPL协议的副本,
* 如果没有找到,请连接到 http://www.gnu.org/licenses/ 查看。
*
* - Author:摩码创想
* - Contact: [email protected]
* - License: GNU Lesser General Public License (GPL)
*/
package com.zhizhi.common.constants;
/**
* @ClassName com.common.Constants
* @description
* @author : jsq
* @Create Date : 2017-11-1 下午4:06:53
*/
public class Constants {
public static String account_session = "account_session";// 存储当前用户信息session
public static String schoolDomain = ".paike.268xue.com";// 使用268教育网站时二级域名后缀
public static String EhcacheName = "ehcache";// ehcache默认名字
public static String domoaincache = "ehcache:domoaincache";// 存域名的信息
public static String session_school = "session_school";// 存域名的信息
public static final String OPERATE_SUCCESS_CODE = "0";
public static final String OPERATE_FAILE_CODE = "1";
public static final String OPERATE_SUCCESS = "操作成功";
public static final String OPERATE_FAILE = "操作失败";
public static final String MOBILE_IS_EXIST = "手机号已存在";
public static final String EMAIL_IS_EXIST = "电子邮箱已存在";
public static final String QQ_IS_EXIST = "QQ号码已存在";
public static final String ENTITY_IS_NULL = "操作对象不存在";
public static final String COUNSELOR_NOT_EXIST = "顾问不存在";
public static final String COUNSELOR_NAME_IS_NULL = "姓名不能为空";
public static final String COUNSELOR_MOBILE_IS_NULL = "手机号不能为空";
public static final String COUNSELOR_EMAIL_IS_NULL = "电子邮箱不能为空";
public static final String COUNSELOR_PARENT_MOBLIE_IS_NULL = "推荐人手机号不能为空";
public static final String COUNSELOR_PARENT_NOT_EXIST = "推荐人不存在";
public static final String COUNSELOR_IS_EXIST = "顾问已存在";
public static final String CONTACTER_IS_EXIST = "联系人已存在";
public static final String CONTACTER_NOT_EXIST = "联系人不存在";
public static final String STUDENT_NOT_EXIST = "学生不存在";
public static final String SUBJECT_IS_NULL = "咨询科目不能为空";
public static final String SUBJECT_NOT_EXIST = "咨询科目不存在";
public static final String PAIKE_ACCOUNT_IS_EXIST = "排课账号已存在";
public static final String PHONE_IS_ERROR = "请填写正确的电话格式";
public static final String LENGTH_IS_ERROR = "输入内容超出规定的长度";
public static final String NAME_CANNOT_EMPTY = "姓名不能为空";
public static final String TUIJIAN_SUCCESS = "推荐成功";
public static final String TUIJIAN_FAILE = "推荐失败";
public static final String WEI_GUAN_ZHU_WEIXIN = "请先搜索微信号【ldzhushou】,关注后再进行注册。";
public static final String ACCOUNT_PAYING = "1";// 用户付款
public static final String ACCOUNT_REWARD = "2";// 赠送、优惠
public static final String ACCOUNT_REFUND = "3";// 退费
public static final String ACCOUNT_CONSUME_COURSE = "4";// 课程消耗
public static final String ACCOUNT_CANCEL_COURSE = "5";// 课程取消
public static final String ACCOUNT_FRONT_MONEY = "6";// 定金
public static final String ACCOUNT_ZHUANCUN = "7";//转存
public static final String ACCOUNT_ZHUANRU = "8";//转入主账户
public static final String STUDENT_COURSE_NOTICE = "student_course_notice";//学生课表通知
public static final String PARENTS_COURSE_NOTICE = "parents_course_notice";//家长课表通知
public static final String STUDENT_TEST_NOTICE = "student_test_notice";//学生模考通知
public static final String PARENTS_TEST_NOTICE = "parents_test_notice";//家长模考通知
public static final String TEACHER_COURSE_NOTICE = "teacher_course_notice";//老师课表通知
public static final String TEACHER_BAN_COURSE_NOTICE = "teacher_ban_course_notice";//老师课表通知
public static final String STUDENT_CANCEL_COURSE_NOTICE = "student_cancel_course_notice";//学生取消课表通知
public static final String PARENTS_CANCEL_COURSE_NOTICE = "parents_cancel_course_notice";//家长取消课表通知
public static final String TEACHER_CANCEL_COURSE_NOTICE = "teacher_cancel_course_notice";//老师取消课表通知
public static final String TEACHER_BAN_CANCEL_COURSE_NOTICE = "teacher_ban_cancel_course_notice";//老师取消课表通知
public static final String LANGUAGE_CH = "ch";
public static final String LANGUAGE_EN = "en";
public static final String OPERATOR_CODE = "code";
public static final String SUCCESS = "0";
public static final String ERROR = "1";
//接收人:1.学生本人 2.家长 3.老师 4.员工 5.留学顾问
public static final Integer RECEIVE_SMS_STUDENT=1;
public static final Integer RECEIVE_SMS_PARENTS=2;
public static final Integer RECEIVE_SMS_TEACHER=3;
public static final Integer RECEIVE_SMS_STAFF=4;
public static final Integer RECEIVE_SMS_COURSE_CONSULTANT=5;
// 短信平台相关
public static final String SERVERURL = "https://api.netease.im/sms/sendcode.action";
public static final String VERIFYURL = "https://api.netease.im/sms/verifycode.action";
// app key
public static final String APPKEY="8bed57cf58d868d7485ea22471f558f3";
// app security
public static final String APPSECURITY="857ba667fb6c";
// 模板id
public static final String TEMPLATEID="3128046";
// 验证码长度,范围4-10,默认为4
public static final String CODELEN="6";
}
| [
"[email protected]"
]
| ||
2e8abff8691e7fd2abbbd8a889cf3dcc4ec783a7 | 6df5e4ca8a831000696f5155a921460d9e121293 | /app/src/test/java/com/example/jeetmeena/findplace/ExampleUnitTest.java | 4313e833215c718f830e9943c7de1fef91a4d8bd | []
| no_license | jeetmeena/FindPlace | 1110dd791678f23db913739eff60cd179e4f0283 | 0a16fcf4946107cb15820d42a73a1f5a662a940e | refs/heads/master | 2020-03-30T20:34:33.422977 | 2018-10-04T17:02:08 | 2018-10-04T17:02:08 | 151,593,977 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 392 | java | package com.example.jeetmeena.findplace;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
]
| |
1e59e85e57db9fe9e59fdcaf9989eb93febefd57 | f417dbb7856d987373c1588014b9aed059235015 | /spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java | a7010857b6e6be4c27b2a129e19e65bf00ac7b72 | [
"Apache-2.0"
]
| permissive | MonsterCodingJ/spring-framework | 975c0bc44247cfbd367bdb35da67146c0d7e3971 | 5f152cb1530ea88485efef115e0ff05687301792 | refs/heads/master | 2022-12-05T04:43:08.831380 | 2020-08-28T00:47:56 | 2020-08-28T00:47:56 | 290,420,347 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,070 | java | /*
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.beans.factory.support;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.BeanIsNotAFactoryException;
import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.SmartFactoryBean;
import org.springframework.core.ResolvableType;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
* Static {@link org.springframework.beans.factory.BeanFactory} implementation
* which allows to register existing singleton instances programmatically.
* Does not have support for prototype beans or aliases.
*
* <p>Serves as example for a simple implementation of the
* {@link org.springframework.beans.factory.ListableBeanFactory} interface,
* managing existing bean instances rather than creating new ones based on bean
* definitions, and not implementing any extended SPI interfaces (such as
* {@link org.springframework.beans.factory.config.ConfigurableBeanFactory}).
*
* <p>For a full-fledged factory based on bean definitions, have a look
* at {@link DefaultListableBeanFactory}.
*
* @author Rod Johnson
* @author Juergen Hoeller
* @since 06.01.2003
* @see DefaultListableBeanFactory
*/
public class StaticListableBeanFactory implements ListableBeanFactory {
/** Map from bean name to bean instance. */
private final Map<String, Object> beans;
/**
* Create a regular {@code StaticListableBeanFactory}, to be populated
* with singleton bean instances through {@link #addBean} calls.
*/
public StaticListableBeanFactory() {
this.beans = new LinkedHashMap<>();
}
/**
* Create a {@code StaticListableBeanFactory} wrapping the given {@code Map}.
* <p>Note that the given {@code Map} may be pre-populated with beans;
* or new, still allowing for beans to be registered via {@link #addBean};
* or {@link java.util.Collections#emptyMap()} for a dummy factory which
* enforces operating against an empty set of beans.
* @param beans a {@code Map} for holding this factory's beans, with the
* bean name String as key and the corresponding singleton object as value
* @since 4.3
*/
public StaticListableBeanFactory(Map<String, Object> beans) {
Assert.notNull(beans, "Beans Map must not be null");
this.beans = beans;
}
/**
* Add a new singleton bean.
* Will overwrite any existing instance for the given name.
* @param name the name of the bean
* @param bean the bean instance
*/
public void addBean(String name, Object bean) {
this.beans.put(name, bean);
}
//---------------------------------------------------------------------
// Implementation of BeanFactory interface
//---------------------------------------------------------------------
@Override
public Object getBean(String name) throws BeansException {
String beanName = BeanFactoryUtils.transformedBeanName(name);
Object bean = this.beans.get(beanName);
if (bean == null) {
throw new NoSuchBeanDefinitionException(beanName,
"Defined beans are [" + StringUtils.collectionToCommaDelimitedString(this.beans.keySet()) + "]");
}
// Don't let calling code try to dereference the
// bean factory if the bean isn't a factory
if (BeanFactoryUtils.isFactoryDereference(name) && !(bean instanceof FactoryBean)) {
throw new BeanIsNotAFactoryException(beanName, bean.getClass());
}
if (bean instanceof FactoryBean && !BeanFactoryUtils.isFactoryDereference(name)) {
try {
Object exposedObject = ((FactoryBean<?>) bean).getObject();
if (exposedObject == null) {
throw new BeanCreationException(beanName, "FactoryBean exposed null object");
}
return exposedObject;
}
catch (Exception ex) {
throw new BeanCreationException(beanName, "FactoryBean threw exception on object creation", ex);
}
}
else {
return bean;
}
}
@Override
@SuppressWarnings("unchecked")
public <T> T getBean(String name, @Nullable Class<T> requiredType) throws BeansException {
Object bean = getBean(name);
if (requiredType != null && !requiredType.isInstance(bean)) {
throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
}
return (T) bean;
}
@Override
public Object getBean(String name, Object... args) throws BeansException {
if (!ObjectUtils.isEmpty(args)) {
throw new UnsupportedOperationException(
"StaticListableBeanFactory does not support explicit bean creation arguments");
}
return getBean(name);
}
@Override
public <T> T getBean(Class<T> requiredType) throws BeansException {
String[] beanNames = getBeanNamesForType(requiredType);
if (beanNames.length == 1) {
return getBean(beanNames[0], requiredType);
}
else if (beanNames.length > 1) {
throw new NoUniqueBeanDefinitionException(requiredType, beanNames);
}
else {
throw new NoSuchBeanDefinitionException(requiredType);
}
}
@Override
public <T> T getBean(Class<T> requiredType, Object... args) throws BeansException {
if (!ObjectUtils.isEmpty(args)) {
throw new UnsupportedOperationException(
"StaticListableBeanFactory does not support explicit bean creation arguments");
}
return getBean(requiredType);
}
@Override
public <T> ObjectProvider<T> getBeanProvider(Class<T> requiredType) throws BeansException {
return getBeanProvider(ResolvableType.forRawClass(requiredType));
}
@SuppressWarnings("unchecked")
@Override
public <T> ObjectProvider<T> getBeanProvider(ResolvableType requiredType) {
return new ObjectProvider<T>() {
@Override
public T getObject() throws BeansException {
String[] beanNames = getBeanNamesForType(requiredType);
if (beanNames.length == 1) {
return (T) getBean(beanNames[0], requiredType);
}
else if (beanNames.length > 1) {
throw new NoUniqueBeanDefinitionException(requiredType, beanNames);
}
else {
throw new NoSuchBeanDefinitionException(requiredType);
}
}
@Override
public T getObject(Object... args) throws BeansException {
String[] beanNames = getBeanNamesForType(requiredType);
if (beanNames.length == 1) {
return (T) getBean(beanNames[0], args);
}
else if (beanNames.length > 1) {
throw new NoUniqueBeanDefinitionException(requiredType, beanNames);
}
else {
throw new NoSuchBeanDefinitionException(requiredType);
}
}
@Override
@Nullable
public T getIfAvailable() throws BeansException {
String[] beanNames = getBeanNamesForType(requiredType);
if (beanNames.length == 1) {
return (T) getBean(beanNames[0]);
}
else if (beanNames.length > 1) {
throw new NoUniqueBeanDefinitionException(requiredType, beanNames);
}
else {
return null;
}
}
@Override
@Nullable
public T getIfUnique() throws BeansException {
String[] beanNames = getBeanNamesForType(requiredType);
if (beanNames.length == 1) {
return (T) getBean(beanNames[0]);
}
else {
return null;
}
}
@Override
public Stream<T> stream() {
return Arrays.stream(getBeanNamesForType(requiredType)).map(name -> (T) getBean(name));
}
};
}
@Override
public boolean containsBean(String name) {
return this.beans.containsKey(name);
}
@Override
public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
Object bean = getBean(name);
// In case of FactoryBean, return singleton status of created object.
return (bean instanceof FactoryBean && ((FactoryBean<?>) bean).isSingleton());
}
@Override
public boolean isPrototype(String name) throws NoSuchBeanDefinitionException {
Object bean = getBean(name);
// In case of FactoryBean, return prototype status of created object.
return ((bean instanceof SmartFactoryBean && ((SmartFactoryBean<?>) bean).isPrototype()) ||
(bean instanceof FactoryBean && !((FactoryBean<?>) bean).isSingleton()));
}
@Override
public boolean isTypeMatch(String name, ResolvableType typeToMatch) throws NoSuchBeanDefinitionException {
Class<?> type = getType(name);
return (type != null && typeToMatch.isAssignableFrom(type));
}
@Override
public boolean isTypeMatch(String name, @Nullable Class<?> typeToMatch) throws NoSuchBeanDefinitionException {
Class<?> type = getType(name);
return (typeToMatch == null || (type != null && typeToMatch.isAssignableFrom(type)));
}
@Override
public Class<?> getType(String name) throws NoSuchBeanDefinitionException {
String beanName = BeanFactoryUtils.transformedBeanName(name);
Object bean = this.beans.get(beanName);
if (bean == null) {
throw new NoSuchBeanDefinitionException(beanName,
"Defined beans are [" + StringUtils.collectionToCommaDelimitedString(this.beans.keySet()) + "]");
}
if (bean instanceof FactoryBean && !BeanFactoryUtils.isFactoryDereference(name)) {
// If it's a FactoryBean, we want to look at what it creates, not the factory class.
return ((FactoryBean<?>) bean).getObjectType();
}
return bean.getClass();
}
@Override
public String[] getAliases(String name) {
return new String[0];
}
//---------------------------------------------------------------------
// Implementation of ListableBeanFactory interface
//---------------------------------------------------------------------
@Override
public boolean containsBeanDefinition(String name) {
return this.beans.containsKey(name);
}
@Override
public int getBeanDefinitionCount() {
return this.beans.size();
}
@Override
public String[] getBeanDefinitionNames() {
return StringUtils.toStringArray(this.beans.keySet());
}
@Override
public String[] getBeanNamesForType(@Nullable ResolvableType type) {
boolean isFactoryType = false;
if (type != null) {
Class<?> resolved = type.resolve();
if (resolved != null && FactoryBean.class.isAssignableFrom(resolved)) {
isFactoryType = true;
}
}
List<String> matches = new ArrayList<>();
for (Map.Entry<String, Object> entry : this.beans.entrySet()) {
String name = entry.getKey();
Object beanInstance = entry.getValue();
if (beanInstance instanceof FactoryBean && !isFactoryType) {
Class<?> objectType = ((FactoryBean<?>) beanInstance).getObjectType();
if (objectType != null && (type == null || type.isAssignableFrom(objectType))) {
matches.add(name);
}
}
else {
if (type == null || type.isInstance(beanInstance)) {
matches.add(name);
}
}
}
return StringUtils.toStringArray(matches);
}
@Override
public String[] getBeanNamesForType(@Nullable Class<?> type) {
return getBeanNamesForType(ResolvableType.forClass(type));
}
@Override
public String[] getBeanNamesForType(@Nullable Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) {
return getBeanNamesForType(ResolvableType.forClass(type));
}
@Override
public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type) throws BeansException {
return getBeansOfType(type, true, true);
}
@Override
@SuppressWarnings("unchecked")
public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
throws BeansException {
boolean isFactoryType = (type != null && FactoryBean.class.isAssignableFrom(type));
Map<String, T> matches = new LinkedHashMap<>();
for (Map.Entry<String, Object> entry : this.beans.entrySet()) {
String beanName = entry.getKey();
Object beanInstance = entry.getValue();
// Is bean a FactoryBean?
if (beanInstance instanceof FactoryBean && !isFactoryType) {
// Match object created by FactoryBean.
FactoryBean<?> factory = (FactoryBean<?>) beanInstance;
Class<?> objectType = factory.getObjectType();
if ((includeNonSingletons || factory.isSingleton()) &&
objectType != null && (type == null || type.isAssignableFrom(objectType))) {
matches.put(beanName, getBean(beanName, type));
}
}
else {
if (type == null || type.isInstance(beanInstance)) {
// If type to match is FactoryBean, return FactoryBean itself.
// Else, return bean instance.
if (isFactoryType) {
beanName = FACTORY_BEAN_PREFIX + beanName;
}
matches.put(beanName, (T) beanInstance);
}
}
}
return matches;
}
@Override
public String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType) {
List<String> results = new ArrayList<>();
for (String beanName : this.beans.keySet()) {
if (findAnnotationOnBean(beanName, annotationType) != null) {
results.add(beanName);
}
}
return StringUtils.toStringArray(results);
}
@Override
public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType)
throws BeansException {
Map<String, Object> results = new LinkedHashMap<>();
for (String beanName : this.beans.keySet()) {
if (findAnnotationOnBean(beanName, annotationType) != null) {
results.put(beanName, getBean(beanName));
}
}
return results;
}
@Override
@Nullable
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
throws NoSuchBeanDefinitionException{
Class<?> beanType = getType(beanName);
return (beanType != null ? AnnotationUtils.findAnnotation(beanType, annotationType) : null);
}
}
| [
"[email protected]"
]
| |
32387ac93217c87440fcb5f8df61964bec0a762a | dc25b23f8132469fd95cee14189672cebc06aa56 | /frameworks/base/core/java/android/net/NetworkInfo.java | 9196dd7921299dee2b147420d716873e4847d7b4 | [
"LicenseRef-scancode-unicode",
"Apache-2.0"
]
| permissive | nofearnohappy/alps_mm | b407d3ab2ea9fa0a36d09333a2af480b42cfe65c | 9907611f8c2298fe4a45767df91276ec3118dd27 | refs/heads/master | 2020-04-23T08:46:58.421689 | 2019-03-28T21:19:33 | 2019-03-28T21:19:33 | 171,048,255 | 1 | 5 | null | 2020-03-08T03:49:37 | 2019-02-16T20:25:00 | Java | UTF-8 | Java | false | false | 16,673 | java | /*
* Copyright (C) 2014 MediaTek Inc.
* Modification based on code covered by the mentioned copyright
* and/or permission notice(s).
*/
/*
* 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 android.net;
import android.os.Parcelable;
import android.os.Parcel;
import com.android.internal.annotations.VisibleForTesting;
import java.util.EnumMap;
/**
* Describes the status of a network interface.
* <p>Use {@link ConnectivityManager#getActiveNetworkInfo()} to get an instance that represents
* the current network connection.
*/
public class NetworkInfo implements Parcelable {
/**
* Coarse-grained network state. This is probably what most applications should
* use, rather than {@link android.net.NetworkInfo.DetailedState DetailedState}.
* The mapping between the two is as follows:
* <br/><br/>
* <table>
* <tr><td><b>Detailed state</b></td><td><b>Coarse-grained state</b></td></tr>
* <tr><td><code>IDLE</code></td><td><code>DISCONNECTED</code></td></tr>
* <tr><td><code>SCANNING</code></td><td><code>CONNECTING</code></td></tr>
* <tr><td><code>CONNECTING</code></td><td><code>CONNECTING</code></td></tr>
* <tr><td><code>AUTHENTICATING</code></td><td><code>CONNECTING</code></td></tr>
* <tr><td><code>CONNECTED</code></td><td><code>CONNECTED</code></td></tr>
* <tr><td><code>DISCONNECTING</code></td><td><code>DISCONNECTING</code></td></tr>
* <tr><td><code>DISCONNECTED</code></td><td><code>DISCONNECTED</code></td></tr>
* <tr><td><code>UNAVAILABLE</code></td><td><code>DISCONNECTED</code></td></tr>
* <tr><td><code>FAILED</code></td><td><code>DISCONNECTED</code></td></tr>
* </table>
*/
public enum State {
CONNECTING, CONNECTED, SUSPENDED, DISCONNECTING, DISCONNECTED, UNKNOWN
}
/**
* The fine-grained state of a network connection. This level of detail
* is probably of interest to few applications. Most should use
* {@link android.net.NetworkInfo.State State} instead.
*/
public enum DetailedState {
/** Ready to start data connection setup. */
IDLE,
/** Searching for an available access point. */
SCANNING,
/** Currently setting up data connection. */
CONNECTING,
/** Network link established, performing authentication. */
AUTHENTICATING,
/** Awaiting response from DHCP server in order to assign IP address information. */
OBTAINING_IPADDR,
/** IP traffic should be available. */
CONNECTED,
/** IP traffic is suspended */
SUSPENDED,
/** Currently tearing down data connection. */
DISCONNECTING,
/** IP traffic not available. */
DISCONNECTED,
/** Attempt to connect failed. */
FAILED,
/** Access to this network is blocked. */
BLOCKED,
/** Link has poor connectivity. */
VERIFYING_POOR_LINK,
/** Checking if network is a captive portal */
CAPTIVE_PORTAL_CHECK
}
/**
* This is the map described in the Javadoc comment above. The positions
* of the elements of the array must correspond to the ordinal values
* of <code>DetailedState</code>.
*/
private static final EnumMap<DetailedState, State> stateMap =
new EnumMap<DetailedState, State>(DetailedState.class);
static {
stateMap.put(DetailedState.IDLE, State.DISCONNECTED);
stateMap.put(DetailedState.SCANNING, State.DISCONNECTED);
stateMap.put(DetailedState.CONNECTING, State.CONNECTING);
stateMap.put(DetailedState.AUTHENTICATING, State.CONNECTING);
stateMap.put(DetailedState.OBTAINING_IPADDR, State.CONNECTING);
stateMap.put(DetailedState.VERIFYING_POOR_LINK, State.CONNECTING);
stateMap.put(DetailedState.CAPTIVE_PORTAL_CHECK, State.CONNECTING);
stateMap.put(DetailedState.CONNECTED, State.CONNECTED);
stateMap.put(DetailedState.SUSPENDED, State.SUSPENDED);
stateMap.put(DetailedState.DISCONNECTING, State.DISCONNECTING);
stateMap.put(DetailedState.DISCONNECTED, State.DISCONNECTED);
stateMap.put(DetailedState.FAILED, State.DISCONNECTED);
stateMap.put(DetailedState.BLOCKED, State.DISCONNECTED);
}
private int mNetworkType;
private int mSubtype;
private String mTypeName;
private String mSubtypeName;
private State mState;
private DetailedState mDetailedState;
private String mReason;
private String mExtraInfo;
private boolean mIsFailover;
private boolean mIsRoaming;
/**
* Indicates whether network connectivity is possible:
*/
private boolean mIsAvailable;
/**
* @hide
*/
public NetworkInfo(int type, int subtype, String typeName, String subtypeName) {
if (!ConnectivityManager.isNetworkTypeValid(type)) {
throw new IllegalArgumentException("Invalid network type: " + type);
}
mNetworkType = type;
mSubtype = subtype;
mTypeName = typeName;
mSubtypeName = subtypeName;
setDetailedState(DetailedState.IDLE, null, null);
mState = State.UNKNOWN;
mIsAvailable = false; // until we're told otherwise, assume unavailable
mIsRoaming = false;
}
/** {@hide} */
public NetworkInfo(NetworkInfo source) {
if (source != null) {
synchronized (source) {
mNetworkType = source.mNetworkType;
mSubtype = source.mSubtype;
mTypeName = source.mTypeName;
mSubtypeName = source.mSubtypeName;
mState = source.mState;
mDetailedState = source.mDetailedState;
mReason = source.mReason;
mExtraInfo = source.mExtraInfo;
mIsFailover = source.mIsFailover;
mIsRoaming = source.mIsRoaming;
mIsAvailable = source.mIsAvailable;
}
}
}
/**
* Reports the type of network to which the
* info in this {@code NetworkInfo} pertains.
* @return one of {@link ConnectivityManager#TYPE_MOBILE}, {@link
* ConnectivityManager#TYPE_WIFI}, {@link ConnectivityManager#TYPE_WIMAX}, {@link
* ConnectivityManager#TYPE_ETHERNET}, {@link ConnectivityManager#TYPE_BLUETOOTH}, or other
* types defined by {@link ConnectivityManager}
*/
public int getType() {
synchronized (this) {
return mNetworkType;
}
}
/**
* @hide
*/
public void setType(int type) {
synchronized (this) {
mNetworkType = type;
}
}
/**
* M: add for IMS feature
* @hide
* @param typeName typeName set for network info
*/
public void setTypeName(String typeName) {
synchronized (this) {
mTypeName = typeName;
}
}
/**
* Return a network-type-specific integer describing the subtype
* of the network.
* @return the network subtype
*/
public int getSubtype() {
synchronized (this) {
return mSubtype;
}
}
/**
* @hide
*/
public void setSubtype(int subtype, String subtypeName) {
synchronized (this) {
mSubtype = subtype;
mSubtypeName = subtypeName;
}
}
/**
* Return a human-readable name describe the type of the network,
* for example "WIFI" or "MOBILE".
* @return the name of the network type
*/
public String getTypeName() {
synchronized (this) {
return mTypeName;
}
}
/**
* Return a human-readable name describing the subtype of the network.
* @return the name of the network subtype
*/
public String getSubtypeName() {
synchronized (this) {
return mSubtypeName;
}
}
/**
* Indicates whether network connectivity exists or is in the process
* of being established. This is good for applications that need to
* do anything related to the network other than read or write data.
* For the latter, call {@link #isConnected()} instead, which guarantees
* that the network is fully usable.
* @return {@code true} if network connectivity exists or is in the process
* of being established, {@code false} otherwise.
*/
public boolean isConnectedOrConnecting() {
synchronized (this) {
return mState == State.CONNECTED || mState == State.CONNECTING;
}
}
/**
* Indicates whether network connectivity exists and it is possible to establish
* connections and pass data.
* <p>Always call this before attempting to perform data transactions.
* @return {@code true} if network connectivity exists, {@code false} otherwise.
*/
public boolean isConnected() {
synchronized (this) {
return mState == State.CONNECTED;
}
}
/**
* Indicates whether network connectivity is possible. A network is unavailable
* when a persistent or semi-persistent condition prevents the possibility
* of connecting to that network. Examples include
* <ul>
* <li>The device is out of the coverage area for any network of this type.</li>
* <li>The device is on a network other than the home network (i.e., roaming), and
* data roaming has been disabled.</li>
* <li>The device's radio is turned off, e.g., because airplane mode is enabled.</li>
* </ul>
* @return {@code true} if the network is available, {@code false} otherwise
*/
public boolean isAvailable() {
synchronized (this) {
return mIsAvailable;
}
}
/**
* Sets if the network is available, ie, if the connectivity is possible.
* @param isAvailable the new availability value.
*
* @hide
*/
public void setIsAvailable(boolean isAvailable) {
synchronized (this) {
mIsAvailable = isAvailable;
}
}
/**
* Indicates whether the current attempt to connect to the network
* resulted from the ConnectivityManager trying to fail over to this
* network following a disconnect from another network.
* @return {@code true} if this is a failover attempt, {@code false}
* otherwise.
*/
public boolean isFailover() {
synchronized (this) {
return mIsFailover;
}
}
/**
* Set the failover boolean.
* @param isFailover {@code true} to mark the current connection attempt
* as a failover.
* @hide
*/
public void setFailover(boolean isFailover) {
synchronized (this) {
mIsFailover = isFailover;
}
}
/**
* Indicates whether the device is currently roaming on this network.
* When {@code true}, it suggests that use of data on this network
* may incur extra costs.
* @return {@code true} if roaming is in effect, {@code false} otherwise.
*/
public boolean isRoaming() {
synchronized (this) {
return mIsRoaming;
}
}
/** {@hide} */
@VisibleForTesting
public void setRoaming(boolean isRoaming) {
synchronized (this) {
mIsRoaming = isRoaming;
}
}
/**
* Reports the current coarse-grained state of the network.
* @return the coarse-grained state
*/
public State getState() {
synchronized (this) {
return mState;
}
}
/**
* Reports the current fine-grained state of the network.
* @return the fine-grained state
*/
public DetailedState getDetailedState() {
synchronized (this) {
return mDetailedState;
}
}
/**
* Sets the fine-grained state of the network.
* @param detailedState the {@link DetailedState}.
* @param reason a {@code String} indicating the reason for the state change,
* if one was supplied. May be {@code null}.
* @param extraInfo an optional {@code String} providing addditional network state
* information passed up from the lower networking layers.
* @hide
*/
public void setDetailedState(DetailedState detailedState, String reason, String extraInfo) {
synchronized (this) {
this.mDetailedState = detailedState;
this.mState = stateMap.get(detailedState);
this.mReason = reason;
this.mExtraInfo = extraInfo;
}
}
/**
* Set the extraInfo field.
* @param extraInfo an optional {@code String} providing addditional network state
* information passed up from the lower networking layers.
* @hide
*/
public void setExtraInfo(String extraInfo) {
synchronized (this) {
this.mExtraInfo = extraInfo;
}
}
/**
* Report the reason an attempt to establish connectivity failed,
* if one is available.
* @return the reason for failure, or null if not available
*/
public String getReason() {
synchronized (this) {
return mReason;
}
}
/**
* Report the extra information about the network state, if any was
* provided by the lower networking layers.
* @return the extra information, or null if not available
*/
public String getExtraInfo() {
synchronized (this) {
return mExtraInfo;
}
}
@Override
public String toString() {
synchronized (this) {
StringBuilder builder = new StringBuilder("[");
builder.append("type: ").append(getTypeName()).append("[").append(getSubtypeName()).
append("], state: ").append(mState).append("/").append(mDetailedState).
append(", reason: ").append(mReason == null ? "(unspecified)" : mReason).
append(", extra: ").append(mExtraInfo == null ? "(none)" : mExtraInfo).
append(", roaming: ").append(mIsRoaming).
append(", failover: ").append(mIsFailover).
append(", isAvailable: ").append(mIsAvailable).
append("]");
return builder.toString();
}
}
/**
* Implement the Parcelable interface
* @hide
*/
public int describeContents() {
return 0;
}
/**
* Implement the Parcelable interface.
* @hide
*/
public void writeToParcel(Parcel dest, int flags) {
synchronized (this) {
dest.writeInt(mNetworkType);
dest.writeInt(mSubtype);
dest.writeString(mTypeName);
dest.writeString(mSubtypeName);
dest.writeString(mState.name());
dest.writeString(mDetailedState.name());
dest.writeInt(mIsFailover ? 1 : 0);
dest.writeInt(mIsAvailable ? 1 : 0);
dest.writeInt(mIsRoaming ? 1 : 0);
dest.writeString(mReason);
dest.writeString(mExtraInfo);
}
}
/**
* Implement the Parcelable interface.
* @hide
*/
public static final Creator<NetworkInfo> CREATOR =
new Creator<NetworkInfo>() {
public NetworkInfo createFromParcel(Parcel in) {
int netType = in.readInt();
int subtype = in.readInt();
String typeName = in.readString();
String subtypeName = in.readString();
NetworkInfo netInfo = new NetworkInfo(netType, subtype, typeName, subtypeName);
netInfo.mState = State.valueOf(in.readString());
netInfo.mDetailedState = DetailedState.valueOf(in.readString());
netInfo.mIsFailover = in.readInt() != 0;
netInfo.mIsAvailable = in.readInt() != 0;
netInfo.mIsRoaming = in.readInt() != 0;
netInfo.mReason = in.readString();
netInfo.mExtraInfo = in.readString();
return netInfo;
}
public NetworkInfo[] newArray(int size) {
return new NetworkInfo[size];
}
};
}
| [
"[email protected]"
]
| |
8b02860225dd9ff82023aa12c545c78cf36f05c0 | 699258f4346b9a4db5ef98ad3b7b5fd3621e50ee | /src/main/java/io/quarkus/arc/benchmarks/appbeans/AppBean156.java | c7bf5698ae0f5d740329f38d7cbfb4dabb995a69 | [
"Apache-2.0"
]
| permissive | mkouba/arc-benchmarks | 3828fc33a1394023136335dc9b9cededce85f5a3 | 0b3536f490217ee9621d8a082c6cfb8286e96e10 | refs/heads/master | 2023-02-16T20:33:51.835507 | 2023-02-02T14:17:21 | 2023-02-02T14:17:21 | 215,313,316 | 0 | 2 | Apache-2.0 | 2021-03-25T12:40:11 | 2019-10-15T14:01:23 | Java | UTF-8 | Java | false | false | 211 | java | package io.quarkus.arc.benchmarks.appbeans;
import javax.enterprise.context.ApplicationScoped;
import io.quarkus.runtime.Startup;
@ApplicationScoped
@Startup
public class AppBean156 {
void ping() {
}
} | [
"[email protected]"
]
| |
1b4e02703b7d8a9ee595f1957cb7c64675f66515 | ac8ea764f9e55984f416541085d966ae4a04f866 | /DailyFlash/Assignemnt/Solution/p16.java | a906c1f9097fece7b565e2b6e95575213bccac4d | []
| no_license | kajalbabar/Java | 9be6944606d8b5ecab2c7b43529fd221376131ac | 941b5941e31176ca8163ced1267fba4775e776ef | refs/heads/master | 2023-01-20T03:41:49.351508 | 2020-11-23T20:58:09 | 2020-11-23T20:58:09 | 315,439,229 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 679 | java | /*Program 17: Write a program to check whether the number is prime number or not
(Take hardcoded Value)
Input: 13
Output: It is a prime number
*/
class Program {
static boolean isPrime(int num) {
if(num == 1)
return false;
for(int i=2; i<=num/2; i++) {
if(num%i == 0)
return false;
}
return true;
}
public static void main(String[] args) {
System.out.println("is 5 prime? "+ isPrime(5));
System.out.println("is 7 prime? "+ isPrime(7));
System.out.println("is 8 prime? "+ isPrime(8));
System.out.println("is 13 prime? "+ isPrime(13));
}
}
| [
"“[email protected]”"
]
| |
0473a11d516662cd4ce7f1f98d8ca39b1d93ab45 | 0af8b92686a58eb0b64e319b22411432aca7a8f3 | /large-multiproject/project48/src/main/java/org/gradle/test/performance48_4/Production48_348.java | 27dd9abdb9e5c6c503c1ce51e0cb2a5f89a3f113 | []
| 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 | 305 | java | package org.gradle.test.performance48_4;
public class Production48_348 extends org.gradle.test.performance14_4.Production14_348 {
private final String property;
public Production48_348() {
this.property = "foo";
}
public String getProperty() {
return property;
}
}
| [
"[email protected]"
]
| |
6390c78892ac336a0da116d6c0f5c88e5d093636 | e4b466225eba658619f858ad5ef93b525ddb1823 | /app/src/main/java/com/sengmei/RetrofitHttps/Beans/ZhuanHuanBean.java | 1376a504f8706c2a4ff39bf73b0416c0c4e87291 | []
| no_license | kingTec-org/Coinbks | dae4410928aa117e77ca68bc28d2c717e81e9f4c | 634693b6a84ac1e36aac9de1323a270a3af0e45f | refs/heads/master | 2020-12-02T09:40:44.329877 | 2019-08-07T09:22:00 | 2019-08-07T09:22:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,391 | java | package com.sengmei.RetrofitHttps.Beans;
import java.util.List;
public class ZhuanHuanBean {
private String type;
private ObjectBean message;
public ObjectBean getMessage() {
return message;
}
public void setMessage(ObjectBean message) {
this.message = message;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public static class ObjectBean {
private List<walletBean> legal_wallet;
public List<walletBean> getLegal_wallet() {
return legal_wallet;
}
public void setLegal_wallet(List<walletBean> legal_wallet) {
this.legal_wallet = legal_wallet;
}
}
public static class walletBean {
private int id;
private String name;
private String legal_balance;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLegal_balance() {
return legal_balance;
}
public void setLegal_balance(String legal_balance) {
this.legal_balance = legal_balance;
}
}
}
| [
"[email protected]"
]
| |
7bf80ed74226e2732b10aebd357cbf2358d2f9cc | 7c3b2e1bee374976cd6641c0e6e15fe4877a1db8 | /src/main/java/br/com/devdojo/endpoint/StudentEndpoint.java | dd6ffe46e69a189bfa6c9fa7072112005c64ec57 | []
| no_license | vanvibig/springboot-essentials | 4862a3d1fa542fe14316c749810249880bc4d9a0 | 7c406a8edf1800cdcb21a530b161520ea0dcd707 | refs/heads/master | 2020-03-17T17:41:27.179329 | 2018-05-19T11:16:29 | 2018-05-19T11:16:29 | 133,798,336 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,769 | java | package br.com.devdojo.endpoint;
import br.com.devdojo.error.ResourceNotFoundException;
import br.com.devdojo.model.Student;
import br.com.devdojo.repository.StudentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@RestController
@RequestMapping("v1")
public class StudentEndpoint {
private final StudentRepository studentDAO;
@Autowired
public StudentEndpoint(StudentRepository studentDAO) {
this.studentDAO = studentDAO;
}
@GetMapping(path = "protected/students")
public ResponseEntity<?> listAll(Pageable pageable) {
return new ResponseEntity<>(studentDAO.findAll(pageable), HttpStatus.OK);
}
@GetMapping(path = "protected/students/{id}")
public ResponseEntity<?> getStudentById(
@PathVariable("id") Long id,
@AuthenticationPrincipal UserDetails userDetails) {
System.out.println(userDetails);
verifyIfStudentExist(id);
Student student = studentDAO.findOne(id);
return new ResponseEntity<>(student, HttpStatus.OK);
}
@GetMapping(path = "protected/students/findByName/{name}")
public ResponseEntity<?> findStudentByName(@PathVariable String name) {
return new ResponseEntity<>(studentDAO.findByNameIgnoreCaseContaining(name), HttpStatus.OK);
}
@PostMapping(path = "admin/students")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<?> save(@Valid @RequestBody Student student) {
return new ResponseEntity<>(studentDAO.save(student), HttpStatus.CREATED);
}
@DeleteMapping(path = "admin/students/{id}")
// @PreAuthorize("hasRole('ADMIN')")
public ResponseEntity<?> delete(@PathVariable Long id) {
verifyIfStudentExist(id);
studentDAO.delete(id);
return new ResponseEntity<>(HttpStatus.OK);
}
@PutMapping(path = "admin/students")
public ResponseEntity<?> update(@RequestBody Student student) {
verifyIfStudentExist(student.getId());
studentDAO.save(student);
return new ResponseEntity<>(HttpStatus.OK);
}
public void verifyIfStudentExist(Long id){
if (studentDAO.findOne(id) == null)
throw new ResourceNotFoundException("Student not found by id: " + id);
}
}
| [
"[email protected]"
]
| |
b3c189cb60b123ea9e2124d4d0fd40d269ccd972 | 0e66389d4374e7ae3955cd2712c75616ee4b6444 | /vendor/samsung/hardware/wifi/hostapd/V2_0/ISehHostapdCallback.java | 270803114d84c04c23a7021000d844656f2fbab6 | []
| no_license | hk-ng/SM-N9750-TGY | 07d2fd67e140145a56bfa6475e90758328f56750 | 2495bf5b0d3298d07b5fd47d7a0db006c9b316ed | refs/heads/main | 2022-12-25T08:09:46.183119 | 2020-10-11T13:56:50 | 2020-10-11T13:56:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 21,802 | java | package vendor.samsung.hardware.wifi.hostapd.V2_0;
import android.hardware.wifi.hostapd.V1_1.IHostapdCallback;
import android.hidl.base.V1_0.DebugInfo;
import android.hidl.base.V1_0.IBase;
import android.os.HidlSupport;
import android.os.HwBinder;
import android.os.HwBlob;
import android.os.HwParcel;
import android.os.IHwBinder;
import android.os.IHwInterface;
import android.os.NativeHandle;
import android.os.RemoteException;
import com.samsung.android.server.wifi.softap.smarttethering.SemWifiApSmartUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Objects;
public interface ISehHostapdCallback extends IHostapdCallback {
public static final String kInterfaceName = "[email protected]::ISehHostapdCallback";
IHwBinder asBinder();
void debug(NativeHandle nativeHandle, ArrayList<String> arrayList) throws RemoteException;
DebugInfo getDebugInfo() throws RemoteException;
ArrayList<byte[]> getHashChain() throws RemoteException;
ArrayList<String> interfaceChain() throws RemoteException;
String interfaceDescriptor() throws RemoteException;
boolean linkToDeath(IHwBinder.DeathRecipient deathRecipient, long j) throws RemoteException;
void notifySyspropsChanged() throws RemoteException;
void ping() throws RemoteException;
void sehHostapdCallbackEvent(String str) throws RemoteException;
void setHALInstrumentation() throws RemoteException;
boolean unlinkToDeath(IHwBinder.DeathRecipient deathRecipient) throws RemoteException;
static ISehHostapdCallback asInterface(IHwBinder binder) {
if (binder == null) {
return null;
}
IHwInterface iface = binder.queryLocalInterface(kInterfaceName);
if (iface != null && (iface instanceof ISehHostapdCallback)) {
return (ISehHostapdCallback) iface;
}
ISehHostapdCallback proxy = new Proxy(binder);
try {
Iterator<String> it = proxy.interfaceChain().iterator();
while (it.hasNext()) {
if (it.next().equals(kInterfaceName)) {
return proxy;
}
}
} catch (RemoteException e) {
}
return null;
}
static ISehHostapdCallback castFrom(IHwInterface iface) {
if (iface == null) {
return null;
}
return asInterface(iface.asBinder());
}
static ISehHostapdCallback getService(String serviceName, boolean retry) throws RemoteException {
return asInterface(HwBinder.getService(kInterfaceName, serviceName, retry));
}
static ISehHostapdCallback getService(boolean retry) throws RemoteException {
return getService("default", retry);
}
static ISehHostapdCallback getService(String serviceName) throws RemoteException {
return asInterface(HwBinder.getService(kInterfaceName, serviceName));
}
static ISehHostapdCallback getService() throws RemoteException {
return getService("default");
}
public static final class Proxy implements ISehHostapdCallback {
private IHwBinder mRemote;
public Proxy(IHwBinder remote) {
this.mRemote = (IHwBinder) Objects.requireNonNull(remote);
}
public IHwBinder asBinder() {
return this.mRemote;
}
public String toString() {
try {
return interfaceDescriptor() + "@Proxy";
} catch (RemoteException e) {
return "[class or subclass of [email protected]::ISehHostapdCallback]@Proxy";
}
}
public final boolean equals(Object other) {
return HidlSupport.interfacesEqual(this, other);
}
public final int hashCode() {
return asBinder().hashCode();
}
public void onFailure(String ifaceName) throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IHostapdCallback.kInterfaceName);
_hidl_request.writeString(ifaceName);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(1, _hidl_request, _hidl_reply, 1);
_hidl_request.releaseTemporaryStorage();
} finally {
_hidl_reply.release();
}
}
public void sehHostapdCallbackEvent(String message) throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(ISehHostapdCallback.kInterfaceName);
_hidl_request.writeString(message);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(2, _hidl_request, _hidl_reply, 1);
_hidl_request.releaseTemporaryStorage();
} finally {
_hidl_reply.release();
}
}
public ArrayList<String> interfaceChain() throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IBase.kInterfaceName);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(256067662, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
return _hidl_reply.readStringVector();
} finally {
_hidl_reply.release();
}
}
public void debug(NativeHandle fd, ArrayList<String> options) throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IBase.kInterfaceName);
_hidl_request.writeNativeHandle(fd);
_hidl_request.writeStringVector(options);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(256131655, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
} finally {
_hidl_reply.release();
}
}
public String interfaceDescriptor() throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IBase.kInterfaceName);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(256136003, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
return _hidl_reply.readString();
} finally {
_hidl_reply.release();
}
}
public ArrayList<byte[]> getHashChain() throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IBase.kInterfaceName);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(256398152, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
ArrayList<byte[]> _hidl_out_hashchain = new ArrayList<>();
HwBlob _hidl_blob = _hidl_reply.readBuffer(16);
int _hidl_vec_size = _hidl_blob.getInt32(8);
HwBlob childBlob = _hidl_reply.readEmbeddedBuffer((long) (_hidl_vec_size * 32), _hidl_blob.handle(), 0, true);
_hidl_out_hashchain.clear();
for (int _hidl_index_0 = 0; _hidl_index_0 < _hidl_vec_size; _hidl_index_0++) {
byte[] _hidl_vec_element = new byte[32];
childBlob.copyToInt8Array((long) (_hidl_index_0 * 32), _hidl_vec_element, 32);
_hidl_out_hashchain.add(_hidl_vec_element);
}
return _hidl_out_hashchain;
} finally {
_hidl_reply.release();
}
}
public void setHALInstrumentation() throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IBase.kInterfaceName);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(256462420, _hidl_request, _hidl_reply, 1);
_hidl_request.releaseTemporaryStorage();
} finally {
_hidl_reply.release();
}
}
public boolean linkToDeath(IHwBinder.DeathRecipient recipient, long cookie) throws RemoteException {
return this.mRemote.linkToDeath(recipient, cookie);
}
public void ping() throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IBase.kInterfaceName);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(256921159, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
} finally {
_hidl_reply.release();
}
}
public DebugInfo getDebugInfo() throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IBase.kInterfaceName);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(257049926, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
DebugInfo _hidl_out_info = new DebugInfo();
_hidl_out_info.readFromParcel(_hidl_reply);
return _hidl_out_info;
} finally {
_hidl_reply.release();
}
}
public void notifySyspropsChanged() throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IBase.kInterfaceName);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(257120595, _hidl_request, _hidl_reply, 1);
_hidl_request.releaseTemporaryStorage();
} finally {
_hidl_reply.release();
}
}
public boolean unlinkToDeath(IHwBinder.DeathRecipient recipient) throws RemoteException {
return this.mRemote.unlinkToDeath(recipient);
}
}
public static abstract class Stub extends HwBinder implements ISehHostapdCallback {
public IHwBinder asBinder() {
return this;
}
public final ArrayList<String> interfaceChain() {
return new ArrayList<>(Arrays.asList(new String[]{ISehHostapdCallback.kInterfaceName, IHostapdCallback.kInterfaceName, IBase.kInterfaceName}));
}
public void debug(NativeHandle fd, ArrayList<String> arrayList) {
}
public final String interfaceDescriptor() {
return ISehHostapdCallback.kInterfaceName;
}
public final ArrayList<byte[]> getHashChain() {
return new ArrayList<>(Arrays.asList(new byte[][]{new byte[]{-25, 75, 34, -67, 36, 55, -97, 86, 68, 26, SemWifiApSmartUtil.BLE_BATT_6, 78, 98, 99, -85, 97, 108, -86, -71, -37, 29, 27, -94, 10, -13, -51, -81, Byte.MAX_VALUE, 86, 62, -124, 15}, new byte[]{-111, 62, 102, -40, 121, 12, 78, 73, 73, 80, -15, -53, -62, 89, 23, 59, 69, -39, -25, -65, -97, 30, -113, -64, -58, -93, 98, 49, SemWifiApSmartUtil.BLE_BATT_5, 41, 15, 77}, new byte[]{-20, Byte.MAX_VALUE, -41, -98, -48, 45, -6, -123, -68, 73, -108, 38, -83, -82, 62, -66, 35, -17, 5, 36, -13, -51, 105, 87, 19, -109, 36, -72, 59, SemWifiApSmartUtil.BLE_BATT_3, -54, 76}}));
}
public final void setHALInstrumentation() {
}
public final boolean linkToDeath(IHwBinder.DeathRecipient recipient, long cookie) {
return true;
}
public final void ping() {
}
public final DebugInfo getDebugInfo() {
DebugInfo info = new DebugInfo();
info.pid = HidlSupport.getPidIfSharable();
info.ptr = 0;
info.arch = 0;
return info;
}
public final void notifySyspropsChanged() {
HwBinder.enableInstrumentation();
}
public final boolean unlinkToDeath(IHwBinder.DeathRecipient recipient) {
return true;
}
public IHwInterface queryLocalInterface(String descriptor) {
if (ISehHostapdCallback.kInterfaceName.equals(descriptor)) {
return this;
}
return null;
}
public void registerAsService(String serviceName) throws RemoteException {
registerService(serviceName);
}
public String toString() {
return interfaceDescriptor() + "@Stub";
}
public void onTransact(int _hidl_code, HwParcel _hidl_request, HwParcel _hidl_reply, int _hidl_flags) throws RemoteException {
boolean _hidl_is_oneway = false;
boolean _hidl_is_oneway2 = true;
if (_hidl_code == 1) {
if ((_hidl_flags & 1) != 0) {
_hidl_is_oneway = true;
}
if (!_hidl_is_oneway) {
_hidl_reply.writeStatus(Integer.MIN_VALUE);
_hidl_reply.send();
return;
}
_hidl_request.enforceInterface(IHostapdCallback.kInterfaceName);
onFailure(_hidl_request.readString());
} else if (_hidl_code != 2) {
switch (_hidl_code) {
case 256067662:
if ((_hidl_flags & 1) == 0) {
_hidl_is_oneway2 = false;
}
if (_hidl_is_oneway2) {
_hidl_reply.writeStatus(Integer.MIN_VALUE);
_hidl_reply.send();
return;
}
_hidl_request.enforceInterface(IBase.kInterfaceName);
ArrayList<String> _hidl_out_descriptors = interfaceChain();
_hidl_reply.writeStatus(0);
_hidl_reply.writeStringVector(_hidl_out_descriptors);
_hidl_reply.send();
return;
case 256131655:
if ((_hidl_flags & 1) == 0) {
_hidl_is_oneway2 = false;
}
if (_hidl_is_oneway2) {
_hidl_reply.writeStatus(Integer.MIN_VALUE);
_hidl_reply.send();
return;
}
_hidl_request.enforceInterface(IBase.kInterfaceName);
debug(_hidl_request.readNativeHandle(), _hidl_request.readStringVector());
_hidl_reply.writeStatus(0);
_hidl_reply.send();
return;
case 256136003:
if ((_hidl_flags & 1) == 0) {
_hidl_is_oneway2 = false;
}
if (_hidl_is_oneway2) {
_hidl_reply.writeStatus(Integer.MIN_VALUE);
_hidl_reply.send();
return;
}
_hidl_request.enforceInterface(IBase.kInterfaceName);
String _hidl_out_descriptor = interfaceDescriptor();
_hidl_reply.writeStatus(0);
_hidl_reply.writeString(_hidl_out_descriptor);
_hidl_reply.send();
return;
case 256398152:
if ((_hidl_flags & 1) == 0) {
_hidl_is_oneway2 = false;
}
if (_hidl_is_oneway2) {
_hidl_reply.writeStatus(Integer.MIN_VALUE);
_hidl_reply.send();
return;
}
_hidl_request.enforceInterface(IBase.kInterfaceName);
ArrayList<byte[]> _hidl_out_hashchain = getHashChain();
_hidl_reply.writeStatus(0);
HwBlob _hidl_blob = new HwBlob(16);
int _hidl_vec_size = _hidl_out_hashchain.size();
_hidl_blob.putInt32(8, _hidl_vec_size);
_hidl_blob.putBool(12, false);
HwBlob childBlob = new HwBlob(_hidl_vec_size * 32);
for (int _hidl_index_0 = 0; _hidl_index_0 < _hidl_vec_size; _hidl_index_0++) {
long _hidl_array_offset_1 = (long) (_hidl_index_0 * 32);
byte[] _hidl_array_item_1 = _hidl_out_hashchain.get(_hidl_index_0);
if (_hidl_array_item_1 == null || _hidl_array_item_1.length != 32) {
throw new IllegalArgumentException("Array element is not of the expected length");
}
childBlob.putInt8Array(_hidl_array_offset_1, _hidl_array_item_1);
}
_hidl_blob.putBlob(0, childBlob);
_hidl_reply.writeBuffer(_hidl_blob);
_hidl_reply.send();
return;
case 256462420:
if ((_hidl_flags & 1) != 0) {
_hidl_is_oneway = true;
}
if (!_hidl_is_oneway) {
_hidl_reply.writeStatus(Integer.MIN_VALUE);
_hidl_reply.send();
return;
}
_hidl_request.enforceInterface(IBase.kInterfaceName);
setHALInstrumentation();
return;
case 256660548:
if ((_hidl_flags & 1) != 0) {
_hidl_is_oneway = true;
}
if (_hidl_is_oneway) {
_hidl_reply.writeStatus(Integer.MIN_VALUE);
_hidl_reply.send();
return;
}
return;
case 256921159:
if ((_hidl_flags & 1) == 0) {
_hidl_is_oneway2 = false;
}
if (_hidl_is_oneway2) {
_hidl_reply.writeStatus(Integer.MIN_VALUE);
_hidl_reply.send();
return;
}
_hidl_request.enforceInterface(IBase.kInterfaceName);
ping();
_hidl_reply.writeStatus(0);
_hidl_reply.send();
return;
case 257049926:
if ((_hidl_flags & 1) == 0) {
_hidl_is_oneway2 = false;
}
if (_hidl_is_oneway2) {
_hidl_reply.writeStatus(Integer.MIN_VALUE);
_hidl_reply.send();
return;
}
_hidl_request.enforceInterface(IBase.kInterfaceName);
DebugInfo _hidl_out_info = getDebugInfo();
_hidl_reply.writeStatus(0);
_hidl_out_info.writeToParcel(_hidl_reply);
_hidl_reply.send();
return;
case 257120595:
if ((_hidl_flags & 1) != 0) {
_hidl_is_oneway = true;
}
if (!_hidl_is_oneway) {
_hidl_reply.writeStatus(Integer.MIN_VALUE);
_hidl_reply.send();
return;
}
_hidl_request.enforceInterface(IBase.kInterfaceName);
notifySyspropsChanged();
return;
case 257250372:
if ((_hidl_flags & 1) != 0) {
_hidl_is_oneway = true;
}
if (_hidl_is_oneway) {
_hidl_reply.writeStatus(Integer.MIN_VALUE);
_hidl_reply.send();
return;
}
return;
default:
return;
}
} else {
if ((_hidl_flags & 1) != 0) {
_hidl_is_oneway = true;
}
if (!_hidl_is_oneway) {
_hidl_reply.writeStatus(Integer.MIN_VALUE);
_hidl_reply.send();
return;
}
_hidl_request.enforceInterface(ISehHostapdCallback.kInterfaceName);
sehHostapdCallbackEvent(_hidl_request.readString());
}
}
}
}
| [
"[email protected]"
]
| |
8445e25e90fc4fb59e60364b33f8e9c830accc91 | 9faf0ff086f1873606518b7e43eb1d088b7cc955 | /txlcn-tm/src/main/java/com/codingapi/txlcn/tm/core/DefaultDTXContext.java | f36456385ac1cabb26b470c0373ccb72af45e64f | []
| no_license | zsx950110/master | f1d745b367ec89475b008abe4577e6ebb77b935d | 95c3434be8afc1aaf925fae87c53f06bd1abdb0d | refs/heads/master | 2022-12-23T15:44:18.525077 | 2020-06-30T09:45:54 | 2020-06-30T09:45:54 | 202,537,448 | 1 | 0 | null | 2022-12-16T09:44:36 | 2019-08-15T12:30:58 | JavaScript | UTF-8 | Java | false | false | 2,757 | java | /*
* Copyright 2017-2019 CodingApi .
*
* 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.codingapi.txlcn.tm.core;
import com.codingapi.txlcn.common.exception.TransactionException;
import com.codingapi.txlcn.tm.core.storage.FastStorage;
import com.codingapi.txlcn.common.exception.FastStorageException;
import com.codingapi.txlcn.tm.core.storage.GroupProps;
import com.codingapi.txlcn.tm.core.storage.TransactionUnit;
import java.util.List;
/**
* Description:
* Date: 19-1-21 下午2:53
*
* @author ujued
*/
public class DefaultDTXContext implements DTXContext {
private final FastStorage fastStorage;
private final String groupId;
DefaultDTXContext(String groupId, FastStorage fastStorage) {
this.fastStorage = fastStorage;
this.groupId = groupId;
}
@Override
public void join(TransactionUnit transactionUnit) throws TransactionException {
try {
fastStorage.saveTransactionUnitToGroup(groupId, transactionUnit);
} catch (FastStorageException e) {
throw new TransactionException("attempts to join the non-existent transaction group. ["
+ transactionUnit.getUnitId() + '@' + transactionUnit.getModId() + ']');
}
}
@Override
public void resetTransactionState(int state) throws TransactionException {
try {
fastStorage.saveTransactionState(groupId, state);
} catch (FastStorageException e) {
throw new TransactionException(e);
}
}
@Override
public List<TransactionUnit> transactionUnits() throws TransactionException {
try {
return fastStorage.findTransactionUnitsFromGroup(groupId);
} catch (FastStorageException e) {
throw new TransactionException(e);
}
}
@Override
public String getGroupId() {
return this.groupId;
}
@Override
public int transactionState() {
try {
return fastStorage.getTransactionState(groupId);
} catch (FastStorageException e) {
return -1;
}
}
}
| [
"[email protected]"
]
| |
87edc7857e630ccfd9b8572df02a16e19916496c | 54682b2d75932cbfd6de6c32ce58dc250b5046cc | /src/beans/CircleFurniture.java | 2a125a1617411f9f078a6d02a199d2e58d675dc6 | []
| no_license | Alexander-Gaidukevich/FiguresProject | 4cc7f9119ecd8790fe37d30bca815fc1fe3ee58f | 68f35750e7f738edc2ae92aa02c5f979e4e40b93 | refs/heads/master | 2021-01-20T06:39:04.480527 | 2017-03-04T08:11:58 | 2017-03-04T08:11:58 | 83,878,028 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 367 | java | package beans;
public class CircleFurniture extends Figuare implements IPerimeter {
public CircleFurniture(int a) {
super(a);
}
@Override
public double getSquareFiguare() {
return getA()*getA()*Math.PI; //S = Pi * R * R
}
@Override
public double getPerimeter() {
return 2*Math.PI*getA(); //P = 2 * Pi * R
}
}
| [
"[email protected]"
]
| |
ed7fb3003447071024eb850966a9dbdf33c089c1 | 2c65c53ef5390bd70fd2ddb9bbc2b19027f2479f | /kangaroo-web-admin/src/main/java/io/github/pactstart/admin/system/form/ConfigLogQueryForm.java | 35819db5f077b04daa98c703958e8295f99dcd97 | []
| no_license | zt6220493/kangaroo | f37cdaa815708fb56e33d8f4ed7d83885551011a | 16c8a9f7589ec33f01559d3308f8dd8e49493afe | refs/heads/master | 2022-12-28T04:50:48.186699 | 2019-09-25T10:40:27 | 2019-09-25T10:40:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 307 | java | package io.github.pactstart.admin.system.form;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class ConfigLogQueryForm {
/**
* 命名空间
*/
private String namespace;
/**
* 配置名称
*/
private String name;
}
| [
"[email protected]"
]
| |
6a6dfd8c0dd10250c488ae353a5d7b5ca8f73950 | cd2dcaf6b9d041edb6599b184ba61c6825c3e0c8 | /kadima-commons/src/main/java/com/bei2love/kadima/modules/sys/security/FormAuthenticationFilter.java | 85f32c45954d235ea85c497fa011d50b830fd436 | [
"Apache-2.0"
]
| permissive | bei2love/kadima | cd4886121402b684daeda0e0d73ce88f8bbaa1b7 | fa608c5ddf92041edb949017c40524254c0aa68b | refs/heads/master | 2021-01-10T13:22:28.359544 | 2015-10-30T03:19:06 | 2015-10-30T03:19:06 | 45,022,939 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,430 | java |
package com.bei2love.kadima.modules.sys.security;
import com.bei2love.kadima.commons.utils.StringUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.web.util.WebUtils;
import org.springframework.stereotype.Service;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
/**
* 表单验证(包含验证码)过滤类
* @author ThinkGem
* @version 2014-5-19
*/
@Service
public class FormAuthenticationFilter extends org.apache.shiro.web.filter.authc.FormAuthenticationFilter {
public static final String DEFAULT_CAPTCHA_PARAM = "validateCode";
public static final String DEFAULT_MOBILE_PARAM = "mobileLogin";
public static final String DEFAULT_MESSAGE_PARAM = "message";
private String captchaParam = DEFAULT_CAPTCHA_PARAM;
private String mobileLoginParam = DEFAULT_MOBILE_PARAM;
private String messageParam = DEFAULT_MESSAGE_PARAM;
protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) {
String username = getUsername(request);
String password = getPassword(request);
if (password==null){
password = "";
}
boolean rememberMe = isRememberMe(request);
String host = StringUtils.getRemoteAddr((HttpServletRequest)request);
String captcha = getCaptcha(request);
boolean mobile = isMobileLogin(request);
return new UsernamePasswordToken(username, password.toCharArray(), rememberMe, host, captcha, mobile);
}
public String getCaptchaParam() {
return captchaParam;
}
protected String getCaptcha(ServletRequest request) {
return WebUtils.getCleanParam(request, getCaptchaParam());
}
public String getMobileLoginParam() {
return mobileLoginParam;
}
protected boolean isMobileLogin(ServletRequest request) {
return WebUtils.isTrue(request, getMobileLoginParam());
}
public String getMessageParam() {
return messageParam;
}
/**
* 登录成功之后跳转URL
*/
public String getSuccessUrl() {
return super.getSuccessUrl();
}
@Override
protected void issueSuccessRedirect(ServletRequest request,
ServletResponse response) throws Exception {
// Principal p = UserUtils.getPrincipal();
// if (p != null && !p.isMobileLogin()){
WebUtils.issueRedirect(request, response, getSuccessUrl(), null, true);
// }else{
// super.issueSuccessRedirect(request, response);
// }
}
/**
* 登录失败调用事件
*/
@Override
protected boolean onLoginFailure(AuthenticationToken token,
AuthenticationException e, ServletRequest request, ServletResponse response) {
String className = e.getClass().getName(), message = "";
if (IncorrectCredentialsException.class.getName().equals(className)
|| UnknownAccountException.class.getName().equals(className)){
message = "用户或密码错误, 请重试.";
}
else if (e.getMessage() != null && StringUtils.startsWith(e.getMessage(), "msg:")){
message = StringUtils.replace(e.getMessage(), "msg:", "");
}
else{
message = "系统出现点问题,请稍后再试!";
e.printStackTrace(); // 输出到控制台
}
request.setAttribute(getFailureKeyAttribute(), className);
request.setAttribute(getMessageParam(), message);
return true;
}
} | [
"[email protected]"
]
| |
2c11ce25730f70ccdb27a19aa38423c9d5e34393 | ba08938dba94f1ac09539c6394f9aeeefbafe792 | /JavaDemoPrograms/src/com/sgtesting/assgn13/Cuberet.java | 756658a60a6d52618d6cbae8e88b3498e44e724e | []
| no_license | monisha321/TestAutomation | d36331a7f197c2286ae22f930a7c578723142ea1 | 86e945c784d6bf7b542708f5d3e5467dab4bd01c | refs/heads/master | 2023-06-02T20:30:17.016426 | 2021-06-14T13:01:27 | 2021-06-14T13:01:27 | 374,366,938 | 0 | 0 | null | 2021-06-11T07:23:32 | 2021-06-06T13:26:09 | Java | UTF-8 | Java | false | false | 549 | java | package com.sgtesting.assgn13;
class Cube
{
static int display()
{
int x=10;
System.out.println("size of array is "+x);
return x;
}
static int[] arr()
{
int k=0;
int a[]=new int [Cube.display()];//if it was normal method then ,just display()
for(int p=1;p<=10;p++)
{
a[k]=(p*p*p);
System.out.println(a[k]);
k=k+1;
}
return a;
}
}
public class Cuberet {
public static void main(String[] args) {
int b[]=Cube.arr();//no object creation
for(int i=0;i<b.length;i++)
{
System.out.println(b[i]);
}
}
}
| [
"[email protected]"
]
| |
56a4362b23e964e4180cc9bdc3b84da46d8b93c6 | 0959377429523e7ffa6f9cbf6d489912d45400f6 | /app/src/main/java/com/example/alex/fragments/groups/FacultyGroupsFragment.java | f15666bf990c9811dbf163496a546451f75d5a23 | []
| no_license | AlexKiss6/Corkboard | d18c663ec8c2fe731f7da5a04d78de4c84fc98b0 | ac9af00ea87c216f08e740e68945e2e2917a242e | refs/heads/master | 2021-01-21T21:43:23.469523 | 2016-03-08T17:01:02 | 2016-03-08T17:01:02 | 52,010,970 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,797 | java | package com.example.alex.fragments.groups;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.example.alex.corkboard.R;
import com.example.alex.fragments.events.FacultyEventsFragment;
/**
* Created by Alex on 3/5/2016.
*/
public class FacultyGroupsFragment extends Fragment implements View.OnClickListener {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_faculty_groups, container, false);
Button group1Button = (Button) rootView.findViewById(R.id.group1Button);
Button group2Button = (Button) rootView.findViewById(R.id.group2Button);
Button group3Button = (Button) rootView.findViewById(R.id.group3Button);
Button group4Button = (Button) rootView.findViewById(R.id.group4Button);
Button group5Button = (Button) rootView.findViewById(R.id.group5Button);
Button group6Button = (Button) rootView.findViewById(R.id.group6Button);
Button group7Button = (Button) rootView.findViewById(R.id.group7Button);
Button group8Button = (Button) rootView.findViewById(R.id.group8Button);
Button group9Button = (Button) rootView.findViewById(R.id.group9Button);
group1Button.setOnClickListener(this);
group2Button.setOnClickListener(this);
group3Button.setOnClickListener(this);
group4Button.setOnClickListener(this);
group5Button.setOnClickListener(this);
group6Button.setOnClickListener(this);
group7Button.setOnClickListener(this);
group8Button.setOnClickListener(this);
group9Button.setOnClickListener(this);
return rootView;
}
@Override
public void onClick(View view) {
Fragment fragment = null;
switch (view.getId()) {
case R.id.group1Button:
fragment = new FacultyEventsFragment();
replaceFragment(fragment);
break;
case R.id.group2Button:
fragment = new FacultyEventsFragment();
replaceFragment(fragment);
break;
case R.id.group3Button:
fragment = new FacultyEventsFragment();
replaceFragment(fragment);
break;
case R.id.group4Button:
fragment = new FacultyEventsFragment();
replaceFragment(fragment);
break;
case R.id.group5Button:
fragment = new FacultyEventsFragment();
replaceFragment(fragment);
break;
case R.id.group6Button:
fragment = new FacultyEventsFragment();
replaceFragment(fragment);
break;
case R.id.group7Button:
fragment = new FacultyEventsFragment();
replaceFragment(fragment);
break;
case R.id.group8Button:
fragment = new FacultyEventsFragment();
replaceFragment(fragment);
break;
case R.id.group9Button:
fragment = new FacultyEventsFragment();
replaceFragment(fragment);
break;
}
}
public void replaceFragment(Fragment someFragment) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.content_frame, someFragment);
transaction.addToBackStack(null);
transaction.commit();
}
}
| [
"[email protected]"
]
| |
fc89baa79d9121292ce9dcee8f26685e613e6faf | 2a1433d5ea686dcf47ef299cbd2d1f42be29b942 | /Laboratoriniai/Lab7/app/src/main/java/com/example/lab7/MainActivity.java | 49cef3f181e064f4969f349b32a55d3573490a3d | []
| no_license | Paranite/Android_uni | 978457f1c03693f3f5ba494b4e38d2b736f7b984 | 84aa1323012471e4d0c1a85011db0577defb0316 | refs/heads/main | 2023-02-18T01:36:19.521752 | 2021-01-21T19:06:53 | 2021-01-21T19:06:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,059 | java | package com.example.lab7;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import android.app.AlarmManager;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Switch;
public class MainActivity extends AppCompatActivity {
EditText battery_percentage;
EditText time;
String channelName = "Channel1";
int notificationId = 1;
Switch alarm;
AlarmManager alarmManager;
PendingIntent pendingIntent;
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// battery_percentage = findViewById(R.id.editTextProcentai);
time = findViewById(R.id.editTextLaikas);
alarm = findViewById(R.id.switchPranesti);
createChannel();
Intent intent = new Intent(this, Notification.class);
pendingIntent = PendingIntent.getBroadcast(this, 2, intent, 0);
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void createChannel(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
CharSequence name = channelName;
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(channelName, name, importance);
NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
}
public void notify(View v){
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelName);
builder.setSmallIcon(R.drawable.arrow);
builder.setContentTitle("Senka baterija!");
builder.setContentText("Telefone liko maziau nei " + battery_percentage.getText() + "% baterijos");
builder.setPriority(NotificationCompat.PRIORITY_DEFAULT);
NotificationManagerCompat manager = NotificationManagerCompat.from(this);
manager.notify(notificationId, builder.build());
}
public void alarmSet(View v){
if (alarm.isChecked()) {
alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
long period = Long.parseLong(String.valueOf(time.getText()));
alarmManager.setRepeating(
AlarmManager.RTC,
System.currentTimeMillis() + period,
period,
pendingIntent
);
}else{
if(pendingIntent != null && alarmManager != null){
alarmManager.cancel(pendingIntent);
}
}
}
} | [
"[email protected]"
]
| |
7efc75ec27cd34c0691143e56eeb16e56ebecfd5 | 9205eb3b00c75cd7fbecbd5669667feb3cf1d3cc | /src/main/java/com/rest/webservices/user/User.java | fcd057973f3db5f07710c4ce70839d84e76c8898 | []
| no_license | sarracent/Master-Microservices-with-Spring-Boot-and-Spring-Cloud | c0b2ef9f4d621e21c47541b971e4309fa29e821d | 708d776b5acb8d174f869cfdfe3d576dc291d435 | refs/heads/master | 2022-11-22T18:03:32.253401 | 2020-07-29T17:12:53 | 2020-07-29T17:12:53 | 283,410,596 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 789 | java | package com.rest.webservices.user;
import java.util.Date;
public class User {
private Integer id;
private String name;
private Date birthDate;
public User() {
super();
}
public User(Integer id, String name, Date birthDate) {
super();
this.id = id;
this.name = name;
this.birthDate = birthDate;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
@Override
public String toString() {
return "User [id=" + id + ", name=" + name + ", birthDate=" + birthDate + "]";
}
}
| [
"[email protected]"
]
| |
5a60a1a2e2e3226f0f488a807cb1d680044a8ced | 79ebd9b90aa032317187d9a2ff6383479be47181 | /SMASHCSS/src/no/ntnu/item/smash/css/comm/ULCResponse.java | dd0be2f8fa03658ae3d73cb9a20766d72a499396 | []
| no_license | shiec/MasterThesis | c663a075c93e254164c7aecb4770ac7b5c467c65 | d316ea46c00ed70d6a7e89ee11bf22fd6a2a363c | refs/heads/master | 2021-01-01T17:16:09.045380 | 2015-05-05T18:55:32 | 2015-05-05T18:55:32 | 35,118,134 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 691 | java | package no.ntnu.item.smash.css.comm;
import java.util.HashMap;
public class ULCResponse {
public static final int OK = 1;
public static final int REJECT = 0;
public static final int PARTIAL = 2;
private String id;
private int code;
private HashMap<String,Object> data = new HashMap<String,Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public HashMap<String, Object> getData() {
return data;
}
public void setData(HashMap<String, Object> data) {
this.data = data;
}
}
| [
"[email protected]"
]
| |
105792ba0b5e25ff5c27b4f51a9800ffdd231c68 | 4b0bf4787e89bcae7e4759bde6d7f3ab2c81f849 | /aliyun-java-sdk-cr/src/main/java/com/aliyuncs/cr/model/v20160607/GetImageLayerRequest.java | 266f6f1677a77311ed3d307ccfa9740192f4fbc9 | [
"Apache-2.0"
]
| permissive | aliyun/aliyun-openapi-java-sdk | a263fa08e261f12d45586d1b3ad8a6609bba0e91 | e19239808ad2298d32dda77db29a6d809e4f7add | refs/heads/master | 2023-09-03T12:28:09.765286 | 2023-09-01T09:03:00 | 2023-09-01T09:03:00 | 39,555,898 | 1,542 | 1,317 | NOASSERTION | 2023-09-14T07:27:05 | 2015-07-23T08:41:13 | Java | UTF-8 | Java | false | false | 2,135 | java | /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.cr.model.v20160607;
import com.aliyuncs.RoaAcsRequest;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.cr.Endpoint;
/**
* @author auto create
* @version
*/
public class GetImageLayerRequest extends RoaAcsRequest<GetImageLayerResponse> {
private String repoNamespace;
private String repoName;
private String tag;
public GetImageLayerRequest() {
super("cr", "2016-06-07", "GetImageLayer", "acr");
setUriPattern("/repos/[RepoNamespace]/[RepoName]/tags/[Tag]/layers");
setMethod(MethodType.GET);
try {
com.aliyuncs.AcsRequest.class.getDeclaredField("productEndpointMap").set(this, Endpoint.endpointMap);
com.aliyuncs.AcsRequest.class.getDeclaredField("productEndpointRegional").set(this, Endpoint.endpointRegionalType);
} catch (Exception e) {}
}
public String getRepoNamespace() {
return this.repoNamespace;
}
public void setRepoNamespace(String repoNamespace) {
this.repoNamespace = repoNamespace;
if(repoNamespace != null){
putPathParameter("RepoNamespace", repoNamespace);
}
}
public String getRepoName() {
return this.repoName;
}
public void setRepoName(String repoName) {
this.repoName = repoName;
if(repoName != null){
putPathParameter("RepoName", repoName);
}
}
public String getTag() {
return this.tag;
}
public void setTag(String tag) {
this.tag = tag;
if(tag != null){
putPathParameter("Tag", tag);
}
}
@Override
public Class<GetImageLayerResponse> getResponseClass() {
return GetImageLayerResponse.class;
}
}
| [
"[email protected]"
]
| |
652b3ccc60a4c91556a873d76e5db512affc0658 | 69e09b8930a8affee58f9bb3be8a95a591196576 | /tab/src/main/java/com/toocms/tab/widget/banner/transform/FlowTransformer.java | 408562bf164990148fb539b406e9f3081d8d1237 | []
| no_license | toocms-library/tab6 | 16b84e0f52121a01b7999467f2dd5a6f33904a6a | 1a2f9613ee407c8a31f4a3d682ab389cd1a788e4 | refs/heads/master | 2023-07-05T21:45:05.770527 | 2021-08-06T06:06:44 | 2021-08-06T06:06:44 | 312,519,794 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 438 | java | package com.toocms.tab.widget.banner.transform;
import androidx.annotation.NonNull;
import androidx.viewpager.widget.ViewPager;
import android.view.View;
/**
* 翻转切换
*
* @author xuexiang
* @since 2019/1/14 下午10:12
*/
public class FlowTransformer implements ViewPager.PageTransformer {
@Override
public void transformPage(@NonNull View page, float position) {
page.setRotationY(position * -30f);
}
}
| [
"[email protected]"
]
| |
515622d4fbd59ffd13b56fffeaff65b3e2dd07aa | e32aec58128008cc9b66e7f417ea3a0f5a90ffe4 | /server/ifx-server/ifx-web/src/main/java/com/isoft/ifx/web/filter/CrossOriginFilter.java | 240d117cda89110af698ab4d9b83788fe3dccdd2 | []
| no_license | com-isoft/ifx | 446e4a24380bd1e14cf1d20171ed48c13ff49f02 | e69211c528979326f1ca1b646ad02a57e5c65028 | refs/heads/master | 2021-01-20T12:21:15.988150 | 2017-08-29T09:22:21 | 2017-08-29T09:22:23 | 101,713,107 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 831 | java | package com.isoft.ifx.web.filter;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
/**
* 跨域filter
*/
public class CrossOriginFilter extends CorsFilter {
public CrossOriginFilter() {
super(configurationSource());
}
private static UrlBasedCorsConfigurationSource configurationSource() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("*");
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return source;
}
}
| [
"[email protected]"
]
| |
d15dc8ff11a92c2e3e8af4cafa3f67073485bbab | 66624f731af15be78b5f4651472956ee0aacea19 | /MyJavaFXProject/src/application/bo/myCarre.java | 89318cb3c33676b92d28edd1047070f9ab029e80 | []
| no_license | inatsauolee/shape-drawing | b91ce7d0d450bce90f647322c7295d2bb9efe8c9 | c372575a4abd85e33f2b54839f0a8780d0ff29a5 | refs/heads/master | 2020-04-09T21:51:26.222715 | 2018-12-06T03:34:42 | 2018-12-06T03:34:42 | 160,614,076 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,011 | java | package application.bo;
import application.Panneau;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
public class myCarre extends myRectangle {
public myCarre(double x, double y, double lar, Color color, double width) {
super(x, y, lar, lar, color, width);
}
public myCarre(myCarre forme, double width) {
super(forme, width);
}
public myCarre(int coordX, int coordY, int largeur) {
super(coordX, coordY, largeur, largeur);
}
@Override
public void affiche() {
r= new Rectangle(x-lar/2, y-lng/2, lar, lar);
r.setStrokeWidth(myWidth);
r.setStroke(myColor);
r.setFill(null);
r.setOnMouseClicked(
evtClick -> {
System.out.println("Clicked!");
System.out.println("this is a Rectangle [("+(x-lar/2)+", "+(y-lng/2)+"), "+lar+"]");
Panneau.goma(calque, r);
});
calque.getChildren().add(r);
Panneau.shapes.add(r);
Panneau.formes.add(this);
}
}
| [
"[email protected]"
]
| |
12682a78dbadc7ff26828f2a678ee1fea960fabf | b8a0b865c8e28247fcbac2882349223c90494933 | /gr2_lhj/안드로이드코드/자바코드/WantPage.java | cb8ffc65b01e097331067d79bdac7b26706ad681 | []
| no_license | ezenteam2/ZENTAL | 048f6506c1979dd11181d9ffe2dcb7303fb7f05c | 72186846fe517f1fca4686fdff0e084cfa50381e | refs/heads/master | 2021-02-04T21:29:56.510754 | 2020-03-30T04:27:23 | 2020-03-30T04:27:23 | 243,711,142 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,153 | java | package com.cookandroid.zental;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;
public class WantPage extends AppCompatActivity {
ListView mListView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.want1);
mListView = (ListView)findViewById(R.id.list1);
dataSetting();
}
private void dataSetting(){
WantAdapter mMyAdapter = new WantAdapter();
mMyAdapter.addItem(ContextCompat.getDrawable(getApplicationContext(),R.drawable.hj_prod1),"4,000원", "마스크 빌립니다 깨끗한 걸로 부탁드려요");
mMyAdapter.addItem(ContextCompat.getDrawable(getApplicationContext(),R.drawable.hj_prod2),"5,000원", "검정색 신발 빌려요 하루 5000원");
mMyAdapter.addItem(ContextCompat.getDrawable(getApplicationContext(),R.drawable.hj_prod3),"4,500원", "가방 빌려봅니당 4가지 중에 하나로 ");
mMyAdapter.addItem(ContextCompat.getDrawable(getApplicationContext(),R.drawable.hj_prod4),"5,500원", "운동화 하루만 빌려주실분 흰색으로");
mMyAdapter.addItem(ContextCompat.getDrawable(getApplicationContext(),R.drawable.hj_prod5),"6,000원", "노트북 빌려주세요");
mMyAdapter.addItem(ContextCompat.getDrawable(getApplicationContext(),R.drawable.hj_prod6),"7,000원", "검정 신발 빌려주세요");
mMyAdapter.addItem(ContextCompat.getDrawable(getApplicationContext(),R.drawable.hj_prod7),"12,000원", "옷 빌려주세요");
mMyAdapter.addItem(ContextCompat.getDrawable(getApplicationContext(),R.drawable.hj_prod8),"8,000원", "가방 빌려주세요");
mMyAdapter.addItem(ContextCompat.getDrawable(getApplicationContext(),R.drawable.hj_prod9),"7,000원", "휴지 빌려봅니다");
mMyAdapter.addItem(ContextCompat.getDrawable(getApplicationContext(),R.drawable.hj_prod10),"6,000원", "백팩 빌려요");
mListView.setAdapter(mMyAdapter);
}
}
| [
"[email protected]"
]
| |
dbb6bb79ecc891253ed0b89451fa1ef992201ea2 | a1385d076aba4a103e5973233c3425203c056a58 | /MyProject/BFUBChannels/src/com/trapedza/bankfusion/features/UB_IBI_InternetBankingFeature.java | bdc448ef631aba88e61920f8cc9b701a613bdff0 | []
| no_license | Singhmnish1947/java1.8 | 8ff0a83392b051e5614e49de06556c684ff4283e | 6b2d4dcf06c5fcbb13c2c2578706a825aaa4dc03 | refs/heads/master | 2021-07-10T17:38:55.581240 | 2021-04-08T12:36:02 | 2021-04-08T12:36:02 | 235,827,640 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,028 | java | /* ********************************************************************************
* Copyright (c) 2002,2004 Trapedza Financial Systems Ltd. All Rights Reserved.
*
* This software is the proprietary information of Trapedza Financial Systems Ltd.
* Use is subject to license terms.
*
* ********************************************************************************
*
* $Id: UB_IBI_InternetBankingFeature.java,v 1.31 2009/05/06 10:11:01 akhileshp Exp $
*
* $Log: BankStatementFeature.java,v $
*
*
*/
package com.trapedza.bankfusion.features;
import java.math.BigDecimal;
import java.util.HashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.misys.bankfusion.subsystem.persistence.runtime.impl.BankFusionThreadLocal;
import com.misys.ub.channels.events.ChannelsEventCodes;
import com.misys.ub.interfaces.IfmConstants;
import com.misys.ub.systeminformation.BusinessInformationService;
import com.misys.ub.systeminformation.IBusinessInformation;
import com.misys.ub.systeminformation.IBusinessInformationService;
import com.trapedza.bankfusion.bo.refimpl.IBOAttributeCollectionFeature;
import com.trapedza.bankfusion.bo.refimpl.IBOFinancialPostingMessage;
import com.trapedza.bankfusion.bo.refimpl.IBOInterestApplicationMessage;
import com.trapedza.bankfusion.bo.refimpl.IBOUB_IBI_INFTB_IBIAccount;
import com.trapedza.bankfusion.core.CommonConstants;
import com.trapedza.bankfusion.core.CurrencyValue;
import com.trapedza.bankfusion.core.EventsHelper;
import com.trapedza.bankfusion.core.ExtensionPointHelper;
import com.trapedza.bankfusion.core.PostingHelper;
import com.trapedza.bankfusion.features.refimpl.AbstractUB_IBI_InternetBankingFeature;
import com.trapedza.bankfusion.features.refimpl.IUB_IBI_InternetBankingFeature;
import com.trapedza.bankfusion.postingengine.gateway.interfaces.IPostingMessage;
import com.trapedza.bankfusion.servercommon.commands.BankFusionEnvironment;
import com.trapedza.bankfusion.servercommon.microflow.MFExecuter;
import com.trapedza.bankfusion.servercommon.services.ServiceManagerFactory;
import com.trapedza.bankfusion.systeminformation.PostingMessageConstants;
public class UB_IBI_InternetBankingFeature extends AbstractUB_IBI_InternetBankingFeature implements IUB_IBI_InternetBankingFeature {
/**
* The logger instance for this feature
*/
private transient final static Log logger = LogFactory.getLog(UB_IBI_InternetBankingFeature.class.getName());
public UB_IBI_InternetBankingFeature(BankFusionEnvironment env) {
super(env);
}
static {
com.trapedza.bankfusion.utils.Tracer.register(cvsRevision);
}
/**
* Returns an ExtensionPoint associated with the name
*/
public ExtensionPointHelper getExtensionPoint(String name) {
return null;
}
/**
* Accepts a posting message and checks if the amount is a non zero amount. If amount is a non
* zero amount then it checks whether Account is eligible to send details to Internet Banking
* Then it checks whether EOD is running or Not. If EOD is running it updates the table
* INFTB_InternetBankingAccount column INEODBALANCECHANGE as true and come out of the method IF
* EOD is not running then raise business Events 1.BALANCE AFFECTED 2.TRANSACTION OCCURRED
*
* @param message
*/
public void postingEngineUpdate(IPostingMessage message) {
char messageType = message.getMessageType();
/*
* Checks if the MessageType is a financial Posting Message or Interest Posting Message or
* Base Code Rate Change Message or Account Rate Change Message or Tiered Rate Change
* Message
*/
if (messageType == PostingMessageConstants.FINANCIAL_POSTING_MESSAGE) {
financialPosting(message);
}
else if (messageType == PostingMessageConstants.INTEREST_APPLICATION_MESSAGE) {
interestPosting(message);
}
else if (PostingHelper.isAccountRateChangeMessage(message)) { // artf789199:Issue Fix done
// to send either account or
// base code or Tiered rate
// changes details.
baseCodeRateChange(message);
}
else {
return;
}
}
/**
* process
*/
public void process(BankFusionEnvironment env) {
super.process(env);
}
/**
* returns the feature implementation type.
*/
public String toString() {
return "com.trapedza.bankfusion.features.UB_IBI_InternetBankingFeature";
}
public static BigDecimal RoundBasedOnCurrency(BigDecimal unRoundedAmount, String currencyCode) {
CurrencyValue curr = new CurrencyValue(currencyCode, unRoundedAmount);
return (new CurrencyValue(curr.getCurrencyCode(), curr.roundCurrency()));
}
public void baseCodeRateChange(IPostingMessage message) {
IBOUB_IBI_INFTB_IBIAccount accDetails = (IBOUB_IBI_INFTB_IBIAccount) BankFusionThreadLocal.getPersistanceFactory()
.findByPrimaryKey(IBOUB_IBI_INFTB_IBIAccount.BONAME, message.getPrimaryID(), true);
if (null != accDetails) {
IBusinessInformationService ubInformationService = (IBusinessInformationService) ServiceManagerFactory.getInstance()
.getServiceManager().getServiceForName(IBusinessInformationService.BUSINESS_INFORMATION_SERVICE);
IBusinessInformation bizzInfo = ((IBusinessInformation) ubInformationService.getBizInfo());
Boolean isEODRunning = bizzInfo.isEODInProgress();
if (isEODRunning.equals(true)) {
accDetails.setF_ISACCOUNTAMENDED(true);
}
else {
/*
* This will raise an Account Amendment event and sends the to the IFM
*/
IBOAttributeCollectionFeature accountBO = null;
String productId = message.getProductID();
accountBO = PostingHelper.getAccountBO(message);
HashMap paramsToRaiseEvent = new HashMap();
paramsToRaiseEvent.put("ACCOUNTNAME", accountBO.getF_ACCOUNTNAME().toString());
paramsToRaiseEvent.put("ACCOUNTNO", (String) message.getPrimaryID());
paramsToRaiseEvent.put("PRODUCTID", productId);
paramsToRaiseEvent.put("CURRENCYCODE", message.getAcctCurrencyCode());
EventsHelper.handleEvent(ChannelsEventCodes.I_ACCOUNT_AMEND_BUSINESS_EVENT, new Object[] {}, paramsToRaiseEvent,
env);
if (logger.isInfoEnabled()) {
logger.info("raising event block");
}
}
}
else {
logger.info("Internet Banking not enabled");
}
}
public void interestPosting(IPostingMessage message) {
IBOAttributeCollectionFeature accountBO = null;
String productId = message.getProductID();
boolean forwardValued = false;
boolean forwardValuedIntoValue = false;
String currencyCode = null;
BigDecimal txnAmount = CommonConstants.BIGDECIMAL_ZERO;
IBOInterestApplicationMessage intPostMessage = (IBOInterestApplicationMessage) message;
forwardValued = intPostMessage.isForwardValued();
forwardValuedIntoValue = intPostMessage.isForwardValuedIntoValue();
accountBO = PostingHelper.retrieveAccount(intPostMessage.getPrimaryID(), intPostMessage.getBranchID(),
intPostMessage.getAcctCurrencyCode(), env);
currencyCode = accountBO.getF_ISOCURRENCYCODE();
txnAmount = RoundBasedOnCurrency(intPostMessage.getF_AMOUNTAsCurrency(), currencyCode);
txnAmountExists(txnAmount, message, accountBO, productId, forwardValued, forwardValuedIntoValue);
}
public void financialPosting(IPostingMessage message) {
IBOAttributeCollectionFeature accountBO = null;
String productId = message.getProductID();
boolean forwardValued = false;
boolean forwardValuedIntoValue = false;
String currencyCode = null;
BigDecimal txnAmount = CommonConstants.BIGDECIMAL_ZERO;
IBOFinancialPostingMessage finPostMessage = (IBOFinancialPostingMessage) message;
forwardValued = finPostMessage.isForwardValued();
forwardValuedIntoValue = finPostMessage.isForwardValuedIntoValue();
accountBO = PostingHelper.retrieveAccount(finPostMessage.getPrimaryID(), finPostMessage.getBranchID(),
finPostMessage.getAcctCurrencyCode(), env);
currencyCode = accountBO.getF_ISOCURRENCYCODE();
txnAmount = RoundBasedOnCurrency(finPostMessage.getF_AMOUNTAsCurrency(), currencyCode);
txnAmountExists(txnAmount, message, accountBO, productId, forwardValued, forwardValuedIntoValue);
}
public void txnAmountExists(BigDecimal txnAmount, IPostingMessage message, IBOAttributeCollectionFeature accountBO,
String productId, boolean forwardValued, boolean forwardValuedIntoValue) {
String accountID = message.getPrimaryID();
Long txnCounter = (long) message.getTransactionCounter();
if (txnAmount.compareTo(BigDecimal.valueOf(0)) > 0) {
IBOUB_IBI_INFTB_IBIAccount accDetails = (IBOUB_IBI_INFTB_IBIAccount) BankFusionThreadLocal.getPersistanceFactory()
.findByPrimaryKey(IBOUB_IBI_INFTB_IBIAccount.BONAME, message.getPrimaryID(), true);
if (accDetails != null) {
IBusinessInformation bizInfo = ((IBusinessInformationService) ServiceManagerFactory.getInstance()
.getServiceManager().getServiceForName(BusinessInformationService.BUSINESS_INFORMATION_SERVICE))
.getBizInfo();
if (bizInfo.isEODInProgress()) {
accDetails.setF_ISBALANCECHANGED(true);
}
else {
// Raise Events for a.BALANCE AFFECTED
// b.TRANSACTION OCCURRED
if (logger.isInfoEnabled()) {
logger.info("Raising the Business Events by Calling the Microflow ");
}
HashMap paramsForWhatProDef = new HashMap();
paramsForWhatProDef.put("productid", productId);
HashMap featuresAttToProduct = MFExecuter.executeMF(IfmConstants.WHAT_PRODUCT_DEFAULTS, env,
paramsForWhatProDef);
HashMap paramsForTransactionOccured = new HashMap();
HashMap paramsForAcctAmendEvent = new HashMap();
// Raise Event for TRANSACTION OCCURRED
paramsForTransactionOccured.put("ACCID", (String) message.getPrimaryID());
paramsForTransactionOccured.put("UBACCTRANSCOUNTER", (String) txnCounter.toString());
if (forwardValued && !forwardValuedIntoValue) {
paramsForTransactionOccured.put(IfmConstants.IS_FWD_VALUE_TXN, Boolean.TRUE.toString());
}
else {
paramsForTransactionOccured.put(IfmConstants.IS_FWD_VALUE_TXN, Boolean.FALSE.toString());
}
if (forwardValuedIntoValue) {
paramsForTransactionOccured.put(IfmConstants.FWD_DATED_INTO_VALUE, Boolean.TRUE.toString());
}
else {
paramsForTransactionOccured.put(IfmConstants.FWD_DATED_INTO_VALUE, Boolean.FALSE.toString());
}
EventsHelper.handleEvent(ChannelsEventCodes.EVT_TRANSACTION_DETAILS, new Object[] { accountID },
paramsForTransactionOccured, env);
/*
* This condition checks whether the product has Lending Feature and if it has
* then it will raise an Account Amendment to Send the Next Repayment Date and
* other details to the IFM
*/
if ((Boolean) featuresAttToProduct.get(IfmConstants.HAS_LEN_FEATURE)) {
paramsForAcctAmendEvent.put("ACCOUNTNAME", accountBO.getF_ACCOUNTNAME());
paramsForAcctAmendEvent.put("ACCOUNTNO", (String) message.getPrimaryID());
paramsForAcctAmendEvent.put("CURRENCYCODE", message.getAcctCurrencyCode());
paramsForAcctAmendEvent.put("PRODUCTID", productId);
EventsHelper.handleEvent(ChannelsEventCodes.I_ACCOUNT_AMEND_BUSINESS_EVENT, new Object[] { accountID },
paramsForAcctAmendEvent, env);
}
}
}
}
}
}
| [
"[email protected]"
]
| |
7fec5f19208874c396deda2bdbb808bf0c8d8c38 | 1b6ae88353600578c1167bf854887aa1cd70963e | /kg-dqp/src/main/java/fr/inria/edelweiss/kgdqp/core/Messages.java | eeccfbce23d3c01478ebbda00ae778473806d498 | []
| no_license | Ahmedko/corese | 8a2fddde7b51d4e4830b7b51528732d828c3f588 | 6c746bdc3b3ae45ad5e90ef2be959e31ae84913d | refs/heads/master | 2021-05-10T21:48:39.771470 | 2018-01-24T09:41:24 | 2018-01-24T09:41:24 | 118,238,712 | 0 | 1 | null | 2018-01-20T11:57:10 | 2018-01-20T11:57:10 | null | UTF-8 | Java | false | false | 581 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fr.inria.edelweiss.kgdqp.core;
/**
* Basic messages to be displayed in the UI.
* @author Alban Gaignard <[email protected]>
*/
public class Messages {
public static String countQueries = "Remote queries";
public static String countTransferredResults = "Transferred results per query";
public static String countDS = "Remote queries per data source";
public static String countTransferredResultsPerSource = "Transferred results per source";
}
| [
"[email protected]"
]
| |
0ddc5674c87f5b7c55f6861083c3069f5911e2be | 7131395821937aa611de99335115a043e4fbfd21 | /src/main/java/ru/itsjava/oop/inheritance/Mother.java | 03d7e0a567a92c8a3a52030e12336b75c51956f9 | []
| no_license | ekasandr21/java-foundations-online | 13b72bcc18fa7d8b62d87c5023997ebf4517a985 | 1ad866c56d395c3ea4d4f8af00775719f4e11da9 | refs/heads/master | 2023-01-07T12:52:19.064475 | 2020-10-30T21:13:18 | 2020-10-30T21:13:18 | 305,372,652 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 150 | java | package ru.itsjava.oop.inheritance;
public interface Mother {
default void giveLove() {
System.out.println("Mother loves you");
}
}
| [
"[email protected]"
]
| |
f21c600db89a1db2bb7550248f009a348ead1bc0 | 6c1f184d0da46d21711a237a1c606b9d49077f3d | /library/src/main/java/com/laiyifen/library/net/server/task/PriorityBlockingQueue.java | 4a241ff9b0da7c1bf5c5bbb1a681b64bded1fcf7 | []
| no_license | BIGMONK/QuickStart | 1580ba692c29304c13606754a36d11b5a9052121 | 5d7f99751a62ad23d9c31a2ade91d859eb98d15a | refs/heads/master | 2020-04-11T15:09:55.754346 | 2018-05-08T05:34:20 | 2018-05-08T05:34:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,773 | java | package com.laiyifen.library.net.server.task;
import com.laiyifen.library.net.model.Priority;
import java.util.AbstractQueue;
import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
/**
* Created by Wisn on 2018/5/3 下午1:58.
*/
public class PriorityBlockingQueue<E> extends AbstractQueue<E> implements BlockingQueue<E>, java.io.Serializable {
private static final long serialVersionUID = -6903933977591709194L;
/**
* The capacity bound, or Integer.MAX_VALUE if none
*/
private final int capacity;
/**
* Current number of elements
*/
private final AtomicInteger count = new AtomicInteger();
/**
* Head of linked list.
* Invariant: head.item == null
*/
transient Node<E> head;
/**
* Tail of linked list.
* Invariant: last.next == null
*/
private transient Node<E> last;
/**
* Lock held by take, poll, etc
*/
private final ReentrantLock takeLock = new ReentrantLock();
/**
* Wait queue for waiting takes
*/
private final Condition notEmpty = takeLock.newCondition();
/**
* Lock held by put, offer, etc
*/
private final ReentrantLock putLock = new ReentrantLock();
/**
* Wait queue for waiting puts
*/
private final Condition notFull = putLock.newCondition();
/**
* Signals a waiting take. Called only from put/offer (which do not
* otherwise ordinarily lock takeLock.)
*/
private void signalNotEmpty() {
final ReentrantLock takeLock = this.takeLock;
takeLock.lock();
try {
notEmpty.signal();
} finally {
takeLock.unlock();
}
}
/**
* Signals a waiting put. Called only from take/poll.
*/
private void signalNotFull() {
final ReentrantLock putLock = this.putLock;
putLock.lock();
try {
notFull.signal();
} finally {
putLock.unlock();
}
}
private synchronized E opQueue(Node<E> node) {
if (node == null) {
return _dequeue();
} else {
_enqueue(node);
return null;
}
}
// only invoke in opQueue
private void _enqueue(Node<E> node) {
boolean added = false;
Node<E> curr = head;
Node<E> temp = null;
while (curr.next != null) {
temp = curr.next;
if (temp.getPriority() < node.getPriority()) {
curr.next = node;
node.next = temp;
added = true;
break;
}
curr = curr.next;
}
if (!added) {
last = last.next = node;
}
}
// only invoke in opQueue
private E _dequeue() {
// assert takeLock.isHeldByCurrentThread();
// assert head.item == null;
Node<E> h = head;
Node<E> first = h.next;
h.next = h; // help GC
head = first;
E x = first.getValue();
first.setValue(null);
return x;
}
/**
* Locks to prevent both puts and takes.
*/
void fullyLock() {
putLock.lock();
takeLock.lock();
}
/**
* Unlocks to allow both puts and takes.
*/
void fullyUnlock() {
takeLock.unlock();
putLock.unlock();
}
public PriorityBlockingQueue() {
this(Integer.MAX_VALUE);
}
public PriorityBlockingQueue(int capacity) {
if (capacity <= 0) throw new IllegalArgumentException();
this.capacity = capacity;
last = head = new Node<E>(null);
}
public PriorityBlockingQueue(Collection<? extends E> c) {
this(Integer.MAX_VALUE);
final ReentrantLock putLock = this.putLock;
putLock.lock(); // Never contended, but necessary for visibility
try {
int n = 0;
for (E e : c) {
if (e == null) throw new NullPointerException();
if (n == capacity) throw new IllegalStateException("Queue full");
opQueue(new Node<E>(e));
++n;
}
count.set(n);
} finally {
putLock.unlock();
}
}
public int size() {
return count.get();
}
public int remainingCapacity() {
return capacity - count.get();
}
public void put(E e) throws InterruptedException {
if (e == null) throw new NullPointerException();
// Note: convention in all put/take/etc is to preset local var
// holding count negative to indicate failure unless set.
int c = -1;
Node<E> node = new Node<E>(e);
final ReentrantLock putLock = this.putLock;
final AtomicInteger count = this.count;
putLock.lockInterruptibly();
try {
while (count.get() == capacity) {
notFull.await();
}
opQueue(node);
c = count.getAndIncrement();
if (c + 1 < capacity) notFull.signal();
} finally {
putLock.unlock();
}
if (c == 0) signalNotEmpty();
}
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
if (e == null) throw new NullPointerException();
long nanos = unit.toNanos(timeout);
int c = -1;
final ReentrantLock putLock = this.putLock;
final AtomicInteger count = this.count;
putLock.lockInterruptibly();
try {
while (count.get() == capacity) {
if (nanos <= 0) return false;
nanos = notFull.awaitNanos(nanos);
}
opQueue(new Node<E>(e));
c = count.getAndIncrement();
if (c + 1 < capacity) notFull.signal();
} finally {
putLock.unlock();
}
if (c == 0) signalNotEmpty();
return true;
}
public boolean offer(E e) {
if (e == null) throw new NullPointerException();
final AtomicInteger count = this.count;
if (count.get() == capacity) return false;
int c = -1;
Node<E> node = new Node<E>(e);
final ReentrantLock putLock = this.putLock;
putLock.lock();
try {
if (count.get() < capacity) {
opQueue(node);
c = count.getAndIncrement();
if (c + 1 < capacity) notFull.signal();
}
} finally {
putLock.unlock();
}
if (c == 0) signalNotEmpty();
return c >= 0;
}
public E take() throws InterruptedException {
E x;
int c = -1;
final AtomicInteger count = this.count;
final ReentrantLock takeLock = this.takeLock;
takeLock.lockInterruptibly();
try {
while (count.get() == 0) {
notEmpty.await();
}
x = opQueue(null);
c = count.getAndDecrement();
if (c > 1) notEmpty.signal();
} finally {
takeLock.unlock();
}
if (c == capacity) signalNotFull();
return x;
}
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
E x = null;
int c = -1;
long nanos = unit.toNanos(timeout);
final AtomicInteger count = this.count;
final ReentrantLock takeLock = this.takeLock;
takeLock.lockInterruptibly();
try {
while (count.get() == 0) {
if (nanos <= 0) return null;
nanos = notEmpty.awaitNanos(nanos);
}
x = opQueue(null);
c = count.getAndDecrement();
if (c > 1) notEmpty.signal();
} finally {
takeLock.unlock();
}
if (c == capacity) signalNotFull();
return x;
}
public E poll() {
final AtomicInteger count = this.count;
if (count.get() == 0) return null;
E x = null;
int c = -1;
final ReentrantLock takeLock = this.takeLock;
takeLock.lock();
try {
if (count.get() > 0) {
x = opQueue(null);
c = count.getAndDecrement();
if (c > 1) notEmpty.signal();
}
} finally {
takeLock.unlock();
}
if (c == capacity) signalNotFull();
return x;
}
public E peek() {
if (count.get() == 0) return null;
final ReentrantLock takeLock = this.takeLock;
takeLock.lock();
try {
Node<E> first = head.next;
if (first == null) return null;
else return first.getValue();
} finally {
takeLock.unlock();
}
}
/**
* Unlinks interior Node p with predecessor trail.
*/
void unlink(Node<E> p, Node<E> trail) {
// assert isFullyLocked();
// p.next is not changed, to allow iterators that are
// traversing p to maintain their weak-consistency guarantee.
p.setValue(null);
trail.next = p.next;
if (last == p) last = trail;
if (count.getAndDecrement() == capacity) notFull.signal();
}
public boolean remove(Object o) {
if (o == null) return false;
fullyLock();
try {
for (Node<E> trail = head, p = trail.next; p != null; trail = p, p = p.next) {
if (o.equals(p.getValue())) {
unlink(p, trail);
return true;
}
}
return false;
} finally {
fullyUnlock();
}
}
public boolean contains(Object o) {
if (o == null) return false;
fullyLock();
try {
for (Node<E> p = head.next; p != null; p = p.next)
if (o.equals(p.getValue())) return true;
return false;
} finally {
fullyUnlock();
}
}
public Object[] toArray() {
fullyLock();
try {
int size = count.get();
Object[] a = new Object[size];
int k = 0;
for (Node<E> p = head.next; p != null; p = p.next)
a[k++] = p.getValue();
return a;
} finally {
fullyUnlock();
}
}
@SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
fullyLock();
try {
int size = count.get();
if (a.length < size) a = (T[]) java.lang.reflect.Array.newInstance(a.getClass().getComponentType(), size);
int k = 0;
for (Node<T> p = (Node<T>) head.next; p != null; p = p.next)
a[k++] = (T) p.getValue();
if (a.length > k) a[k] = null;
return a;
} finally {
fullyUnlock();
}
}
public void clear() {
fullyLock();
try {
for (Node<E> p, h = head; (p = h.next) != null; h = p) {
h.next = h;
p.setValue(null);
}
head = last;
// assert head.item == null && head.next == null;
if (count.getAndSet(0) == capacity) notFull.signal();
} finally {
fullyUnlock();
}
}
public int drainTo(Collection<? super E> c) {
return drainTo(c, Integer.MAX_VALUE);
}
public int drainTo(Collection<? super E> c, int maxElements) {
if (c == null) throw new NullPointerException();
if (c == this) throw new IllegalArgumentException();
if (maxElements <= 0) return 0;
boolean signalNotFull = false;
final ReentrantLock takeLock = this.takeLock;
takeLock.lock();
try {
int n = Math.min(maxElements, count.get());
// count.query provides visibility to first n Nodes
Node<E> h = head;
int i = 0;
try {
while (i < n) {
Node<E> p = h.next;
c.add(p.getValue());
p.setValue(null);
h.next = h;
h = p;
++i;
}
return n;
} finally {
// Restore invariants even if c.add() threw
if (i > 0) {
// assert h.item == null;
head = h;
signalNotFull = (count.getAndAdd(-i) == capacity);
}
}
} finally {
takeLock.unlock();
if (signalNotFull) signalNotFull();
}
}
public Iterator<E> iterator() {
return new Itr();
}
private class Itr implements Iterator<E> {
private Node<E> current;
private Node<E> lastRet;
private E currentElement;
Itr() {
fullyLock();
try {
current = head.next;
if (current != null) currentElement = current.getValue();
} finally {
fullyUnlock();
}
}
public boolean hasNext() {
return current != null;
}
private Node<E> nextNode(Node<E> p) {
for (; ; ) {
Node<E> s = p.next;
if (s == p) return head.next;
if (s == null || s.getValue() != null) return s;
p = s;
}
}
public E next() {
fullyLock();
try {
if (current == null) throw new NoSuchElementException();
E x = currentElement;
lastRet = current;
current = nextNode(current);
currentElement = (current == null) ? null : current.getValue();
return x;
} finally {
fullyUnlock();
}
}
public void remove() {
if (lastRet == null) throw new IllegalStateException();
fullyLock();
try {
Node<E> node = lastRet;
lastRet = null;
for (Node<E> trail = head, p = trail.next; p != null; trail = p, p = p.next) {
if (p == node) {
unlink(p, trail);
break;
}
}
} finally {
fullyUnlock();
}
}
}
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
fullyLock();
try {
// Write out any hidden stuff, plus capacity
s.defaultWriteObject();
// Write out all elements in the proper order.
for (Node<E> p = head.next; p != null; p = p.next)
s.writeObject(p.getValue());
// Use trailing null as sentinel
s.writeObject(null);
} finally {
fullyUnlock();
}
}
/**
* Reconstitutes this queue from a stream (that is, deserializes it).
*/
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
// Read in capacity, and any hidden stuff
s.defaultReadObject();
count.set(0);
last = head = new Node<E>(null);
// Read in all elements and place in queue
for (; ; ) {
@SuppressWarnings("unchecked") E item = (E) s.readObject();
if (item == null) break;
add(item);
}
}
/**
* Linked list node class
*/
class Node<T> {
private boolean valueAsT = false;
private PriorityObject<?> value;
Node<T> next;
Node(T value) {
setValue(value);
}
public int getPriority() {
return value.priority;
}
@SuppressWarnings("unchecked")
public T getValue() {
if (value == null) {
return null;
} else if (valueAsT) {
return (T) value;
} else {
return (T) value.obj;
}
}
public void setValue(T value) {
if (value == null) {
this.value = null;
} else if (value instanceof PriorityObject) {
this.value = (PriorityObject<?>) value;
this.valueAsT = true;
} else {
this.value = new PriorityObject<T>(Priority.DEFAULT, value);
}
}
}
}
| [
"[email protected]"
]
| |
9e2b31f60917e2c38a3e925e87b30948ee7ccec8 | c36d318208e403abf0ff3ab758a508f348d092ed | /pac4j-oauth/src/main/java/org/pac4j/oauth/config/OAuthConfiguration.java | 0acc8845442d5dfbfa44dfb13b753cfd463a936c | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
]
| permissive | JadeLuo/pac4j | 581bf83c4b524f0694457beb9e86565ac97281bd | b40efa32be5ac8b0cb76a22e4f4c62e75d39e0a6 | refs/heads/master | 2021-01-22T20:08:29.245565 | 2017-03-16T08:22:29 | 2017-03-16T08:22:29 | 85,285,854 | 1 | 0 | null | 2017-03-17T08:00:10 | 2017-03-17T08:00:10 | null | UTF-8 | Java | false | false | 5,556 | java | package org.pac4j.oauth.config;
import com.github.scribejava.core.builder.api.BaseApi;
import com.github.scribejava.core.model.OAuthConfig;
import com.github.scribejava.core.model.SignatureType;
import com.github.scribejava.core.model.Token;
import com.github.scribejava.core.oauth.OAuthService;
import org.pac4j.core.client.IndirectClient;
import org.pac4j.core.context.HttpConstants;
import org.pac4j.core.context.WebContext;
import org.pac4j.core.util.CommonHelper;
import org.pac4j.core.util.InitializableWebObject;
import org.pac4j.oauth.profile.definition.OAuthProfileDefinition;
import java.util.function.Function;
/**
* The base OAuth configuration.
*
* @author Jerome Leleu
* @since 2.0.0
*/
public class OAuthConfiguration<C extends IndirectClient, S extends OAuthService<?>, T extends Token> extends InitializableWebObject {
public static final String OAUTH_TOKEN = "oauth_token";
public static final String RESPONSE_TYPE_CODE = "code";
private C client;
private String key;
private String secret;
private boolean tokenAsHeader;
private int connectTimeout = HttpConstants.DEFAULT_CONNECT_TIMEOUT;
private int readTimeout = HttpConstants.DEFAULT_READ_TIMEOUT;
private String responseType = RESPONSE_TYPE_CODE;
private String scope;
private BaseApi<S> api;
private boolean hasGrantType;
private Function<WebContext, Boolean> hasBeenCancelledFactory = ctx -> false;
private OAuthProfileDefinition profileDefinition;
protected S service;
@Override
protected void internalInit(final WebContext context) {
CommonHelper.assertNotNull("client", this.client);
CommonHelper.assertNotBlank("key", this.key);
CommonHelper.assertNotBlank("secret", this.secret);
CommonHelper.assertNotNull("api", api);
CommonHelper.assertNotNull("hasBeenCancelledFactory", hasBeenCancelledFactory);
CommonHelper.assertNotNull("profileDefinition", profileDefinition);
this.service = buildService(context, null);
}
/**
* Build an OAuth service from the web context and with a state.
*
* @param context the web context
* @param state a given state
* @return the OAuth service
*/
public S buildService(final WebContext context, final String state) {
return getApi().createService(buildOAuthConfig(context, state));
}
protected OAuthConfig buildOAuthConfig(final WebContext context, final String state) {
final String finalCallbackUrl = this.client.getCallbackUrlResolver().compute(this.client.getCallbackUrl(), context);
return new OAuthConfig(this.key, this.secret, finalCallbackUrl, SignatureType.Header, this.scope,
null, state, this.responseType, null, this.connectTimeout, this.readTimeout,
null, null);
}
public S getService() {
return this.service;
}
public C getClient() {
return client;
}
public void setClient(final C client) {
this.client = client;
}
public String getKey() {
return key;
}
public void setKey(final String key) {
this.key = key;
}
public String getSecret() {
return secret;
}
public void setSecret(final String secret) {
this.secret = secret;
}
public boolean isTokenAsHeader() {
return tokenAsHeader;
}
public void setTokenAsHeader(final boolean tokenAsHeader) {
this.tokenAsHeader = tokenAsHeader;
}
public int getConnectTimeout() {
return connectTimeout;
}
public void setConnectTimeout(final int connectTimeout) {
this.connectTimeout = connectTimeout;
}
public int getReadTimeout() {
return readTimeout;
}
public void setReadTimeout(final int readTimeout) {
this.readTimeout = readTimeout;
}
public String getResponseType() {
return responseType;
}
public void setResponseType(final String responseType) {
this.responseType = responseType;
}
public String getScope() {
return scope;
}
public void setScope(final String scope) {
this.scope = scope;
}
public BaseApi<S> getApi() {
return api;
}
public void setApi(final BaseApi<S> api) {
this.api = api;
}
public boolean isHasGrantType() {
return hasGrantType;
}
public void setHasGrantType(final boolean hasGrantType) {
this.hasGrantType = hasGrantType;
}
public Function<WebContext, Boolean> getHasBeenCancelledFactory() {
return hasBeenCancelledFactory;
}
public void setHasBeenCancelledFactory(final Function<WebContext, Boolean> hasBeenCancelledFactory) {
this.hasBeenCancelledFactory = hasBeenCancelledFactory;
}
public OAuthProfileDefinition getProfileDefinition() {
return profileDefinition;
}
public void setProfileDefinition(final OAuthProfileDefinition profileDefinition) {
this.profileDefinition = profileDefinition;
}
@Override
public String toString() {
return CommonHelper.toString(this.getClass(), "key", key, "secret", secret, "tokenAsHeader", tokenAsHeader,
"connectTimeout", connectTimeout, "readTimeout", readTimeout, "responseType", responseType,
"scope", scope, "api", api, "hasGrantType", hasGrantType, "service", service,
"hasBeenCancelledFactory", hasBeenCancelledFactory, "profileDefinition", profileDefinition);
}
}
| [
"[email protected]"
]
| |
c4f01f312d57f7bb281019d45985ac6ccff4d674 | 410333d15b6c7a952bbf55dc8be99eb5c9edf863 | /src/main/java/au/com/dius/agileboard/Iteration.java | 29571ab3cd57c267a7871986b3eed5c5bc617f6a | [
"MIT"
]
| permissive | rashiagarwal/agileBoard | 27eef369e3b71accbde6a869af533d439fc2a699 | 21ec44e2db4fdca47b039ce9787a4a5bdbd40cbb | refs/heads/master | 2021-01-22T06:14:40.354959 | 2017-05-27T07:01:38 | 2017-05-27T07:01:38 | 92,534,783 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,786 | java | package au.com.dius.agileboard;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.function.Supplier;
public class Iteration {
private Set<Column> columns = new HashSet<>();
private State state = new State();
Iteration(Set<String> columnNames) {
createColumns(columnNames);
}
public void add(Card card) {
Column startingColumn = getColumn("Starting");
startingColumn.addCard(card);
}
public int velocity() {
Column doneColumn = getColumn("Done");
return doneColumn.getColumnSize();
}
public void moveCard(Card card, String destinationColumnName) {
Column destinationColumn = getColumn(destinationColumnName);
state.save(card, destinationColumn);
Column sourceColumn = card.getColumn();
sourceColumn.removeCard(card);
destinationColumn.addCard(card);
}
public void undoLastMove() {
state.restore();
}
public Column getColumn(String columnName) {
return this.columns.stream().filter(column -> Objects.equals(column.getName(), columnName))
.findFirst().orElseThrow((Supplier<RuntimeException>) () ->
new IllegalArgumentException(columnName + " Not found"));
}
public Set<Column> getColumns() {
return columns;
}
private void createColumns(Set<String> columnNames) {
columnNames.forEach(name -> columns.add(new Column(name)));
}
class State {
private Card card;
private Column sourceColumn;
private Column destinationColumn;
void save(Card card, Column destinationColumn) {
this.card = card;
this.sourceColumn = card.getColumn();
this.destinationColumn = destinationColumn;
}
void restore() {
sourceColumn.addCard(card);
destinationColumn.removeCard(card);
}
}
} | [
"[email protected]"
]
| |
d4dd5421f6ac02378adf41030592422dd9e7ecb4 | dac2d8bfe86d927cce0471b3025dbba9aab85d04 | /nLayeredDemo/src/nLayeredDemo/entities/abstarcts/Entity.java | 0aa4b8c59c83c66663f2da2312dd1bee9115671a | []
| no_license | emirhancibir/JavaCourse | 77ed3ed51a68471ae63dcbede4136e6ba06d9dc9 | f9595bceb38992d85fe8b6d5ff8f4518a7a67f6a | refs/heads/main | 2023-07-25T12:08:00.742105 | 2021-09-08T13:43:24 | 2021-09-08T13:43:24 | 398,538,157 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 71 | java | package nLayeredDemo.entities.abstarcts;
public interface Entity {
}
| [
"[email protected]"
]
| |
cf49b0b9accf78010b45146876d46ae2dffce9c1 | 9adfeb0e52a40cea6cafe56fce5c1abb04e074a9 | /src/main/java/com/springbootdemo/Test.java | 420e216a1b57e8f6bc2bf92e2d02cc99240b757c | []
| no_license | yangdp1983/springbootdemo | 3d4716ac3294a29d026f022fa35228a6b635b2cb | 1443e394a818e41af56a73e1005f3a2e31deac55 | refs/heads/master | 2022-12-13T08:06:33.996461 | 2020-09-06T12:41:44 | 2020-09-06T12:41:44 | 293,224,665 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 52 | java | package com.springbootdemo;
public class Test {
}
| [
"[email protected]"
]
| |
890e981b2c12c74e1258441c9dc4e884db3c4966 | 5278a8a94ad85ecff00dd92b74c37bab7f07a562 | /credit-common/src/main/java/com/honeywen/credit/model/card/Card.java | e1fd2e89cff719352d6910147332ef9d19f5f237 | []
| no_license | yuanfangren/credit-center | 2a9a88e4a36cfa3a44927c6d1390def72ace81f5 | ec737758d1939f7bf816954b52d736b6144ebba4 | refs/heads/master | 2021-05-15T14:28:35.121932 | 2017-09-10T14:07:31 | 2017-09-10T14:07:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 757 | java | package com.honeywen.credit.model.card;
import com.honeywen.credit.model.base.BaseModel;
import lombok.Data;
import java.math.BigDecimal;
/**
* Created by wangwei on 2017/9/10.
*/
public @Data class Card extends BaseModel {
private String cardNo; // 卡号
private String alias; // 别名
private Integer bankId; //所属银行代码
private String cardType; // 卡片类型 1. 贷记卡 2. 准贷记卡 3.借记卡
private BigDecimal creditLimit; // 信用卡额度
private Integer billDay; // 账单日, 每月X号
private Integer fixedRepayDay; // 固定还款日, 为每月固定x号
private Integer delayRepayDay; // 还款日, 账单日后 X 天
private Integer status; // 状态 1. 启用 2.未开卡
}
| [
"[email protected]"
]
| |
cf205905f4b2884ccaf1bd8d3523884bf5533d44 | 680f671218deb51b449081f2442a062510cecc81 | /Proyecto1/src/com/elorrieta/videojuego/Mago.java | 62c894949708f244684e124ea75f6d7298bb755a | []
| no_license | IbonJG/Programacion-JAVA | 0fa76032faac44c1edf01a0ff7b5b96d2c76fcae | c1f445bf8745b2f713fe67c6f9e42ee842b81f35 | refs/heads/master | 2023-04-29T17:25:39.680860 | 2021-05-09T19:18:32 | 2021-05-09T19:18:32 | 358,505,398 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 799 | java | package com.elorrieta.videojuego;
public class Mago extends Personaje {
public static final int ENERGIA_INICIAL = 100;
private String poder;
public Mago(String nombre, String poder) {
super(nombre, ENERGIA_INICIAL);
this.poder = poder;
}
public String getPoder() {
return poder;
}
public void setPoder(String poder) {
this.poder = poder;
}
/**
* disminuye en 2 unidades el nivel propio de energía y que retorna el poder del
* mago.
*
* @return
*/
public String encantar() {
setNivelEnergia(getNivelEnergia() - 2);
return poder + " " + getNivelEnergia();
}
@Override
public String toString() {
return "Mago [nombre= " + getNombre() + ", poder= " + getPoder() + ", nivelEnergia= " + getNivelEnergia() + "]";
}
}
| [
"[email protected]"
]
| |
953215d2589f5cfd236762a052bf379dd126731e | a7530bbe995cc052198ff3d025db179e47043627 | /src/main/java/guru/springframework/services/RecipeServiceImpl.java | 988860f58f692748462802c0d5b0489a308dfe84 | []
| no_license | jleoirab/spring5-recipe-app | 2faf9e5ff5b388e1429d39a7ec5a5d7ca0391dc1 | 086cc5ee6a00a850bc0298ebad40e496868b5abc | refs/heads/master | 2020-06-01T22:30:01.951657 | 2019-06-10T03:20:57 | 2019-06-10T03:20:57 | 190,951,975 | 0 | 0 | null | 2019-06-09T01:35:39 | 2019-06-09T01:35:39 | null | UTF-8 | Java | false | false | 769 | java | package guru.springframework.services;
import guru.springframework.models.Recipe;
import guru.springframework.repositories.RecipeRepository;
import java.util.HashSet;
import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Created by jleoirab on 2019-06-09
*/
public class RecipeServiceImpl implements RecipeService {
private final RecipeRepository recipeRepository;
public RecipeServiceImpl(RecipeRepository recipeRepository) {
this.recipeRepository = checkNotNull(recipeRepository);
}
@Override
public Set<Recipe> getAllRecipes() {
HashSet<Recipe> recipes = new HashSet<>();
recipeRepository.findAll().iterator().forEachRemaining(recipes::add);
return recipes;
}
}
| [
"[email protected]"
]
| |
ff6460e6c94f3507bcb2e80fe2a3d78e1efb9ccd | c06febc200d561786e9ac9ff1ec555cc0039f9e7 | /ppjoke/app/src/main/java/com/test/ppjoke/utils/AppConfig.java | a820e3372ebd6292cd89e2a54d6672cf7a42193d | []
| no_license | LiuBo2019/base_component_learn | f9f014d78678f05cef1cdfe5c7f59a35ed4266db | a2ea104c32b97b82c0b39374484efbab0cb67bf1 | refs/heads/master | 2023-03-27T21:49:11.667474 | 2021-03-29T07:12:07 | 2021-03-29T07:12:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,020 | java | package com.test.ppjoke.utils;
import android.content.res.AssetManager;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.test.libcommon.global.AppGlobals;
import com.test.ppjoke.model.BottomBar;
import com.test.ppjoke.model.Destination;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
public class AppConfig {
private static HashMap<String, Destination> sDestConfig;
private static BottomBar sBottomBar;
public static HashMap<String, Destination> getDestConfig() {
if (sDestConfig == null) {
String content = parseFile("destination.json");
sDestConfig = JSON.parseObject(content, new TypeReference<HashMap<String, Destination>>() {
});
}
return sDestConfig;
}
public static BottomBar getBottomBarConfig() {
if (sBottomBar == null) {
String content = parseFile("main_tabs_config.json");
sBottomBar = JSON.parseObject(content, BottomBar.class);
}
return sBottomBar;
}
private static String parseFile(String fileName) {
AssetManager assets = AppGlobals.getApplication().getAssets();
InputStream is = null;
BufferedReader br = null;
StringBuilder builder = new StringBuilder();
try {
is = assets.open(fileName);
br = new BufferedReader(new InputStreamReader(is));
String line = null;
while ((line = br.readLine()) != null) {
builder.append(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (is != null) {
is.close();
}
if (br != null) {
br.close();
}
} catch (Exception e) {
}
}
return builder.toString();
}
}
| [
"[email protected]"
]
| |
e512ecf21a4ca6a41e7fd0b556629252a8f89ce9 | 7255d4ec0f9b063319f7e4b68ae0f05a0fd993ec | /model_ui_common/src/main/java/com/wukj/uilibrary/model/tagcloud/sample/TextTagsAdapter.java | bcb05fd1079787792646e9eec9b68f5cfaccf27c | [
"Apache-2.0"
]
| permissive | Jonyker/AndroidGeneralLibrary | b22a711b8eb2fba6b230986bee34fe77fcd3e60d | 5e6b3171e6a6c980d952f2306ca8128c24a8789e | refs/heads/master | 2020-04-03T16:42:03.470608 | 2020-02-07T16:49:05 | 2020-02-07T16:49:05 | 155,415,064 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,749 | java | package com.wukj.uilibrary.model.tagcloud.sample;
import android.content.Context;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.wukj.uilibrary.model.tagcloud.TagsAdapter;
import java.util.ArrayList;
import java.util.List;
/**
* 项目名称:UILibrary
* 创建时间:2018/10/30 0030 下午 7:05
* 作者:Jonyker
* 博客:https://www.jianshu.com/u/07642698e7f4
* github:https://github.com/Jonyker
* 修改人:Jonyker
* 联系方式:QQ/534098845
* 修改时间:2018/10/30 0030 下午 7:05
* 备注:
* 版本:V.1.0
* 描述:
* 1.
* 2.
* 3.
*/
public class TextTagsAdapter extends TagsAdapter {
private List<TagEntity> dataSet = new ArrayList<>();
public TextTagsAdapter(@NonNull List<TagEntity> dataset) {
dataSet.clear();
dataSet.addAll(dataset);
}
@Override
public int getCount() {
return dataSet.size();
}
@Override
public View getView(final Context context, final int position, ViewGroup parent) {
final TagEntity tagEntity = dataSet.get(position);
TextView tv = new TextView(context);
tv.setText(tagEntity.getTitle());
tv.setGravity(Gravity.CENTER);
tv.setTextColor(Color.BLUE);
return tv;
}
@Override
public Object getItem(int position) {
return dataSet.get(position);
}
@Override
public int getPopularity(int position) {
return position % 3;
}
@Override
public void onThemeColorChanged(View view, int themeColor, float alpha) {
view.setBackgroundColor(themeColor);
}
}
| [
"[email protected]"
]
| |
91663ce114fcee286aedfa95388ec836d9e79efb | e05214a911748ed6dd296e50eb53e949c29a956a | /android/app/src/main/java/com/rnworkshop/WebviewActivity.java | dae2b3ada7c8aa6aaf5f635f7a7560e7bb55f3d1 | []
| no_license | ahdrew/RNWorkshop | c6ab0433e66d9e1b3cb05741a748be938e397fed | 2a65b36b3217b91b4e9e9dd581da8ff22c41e480 | refs/heads/master | 2023-01-19T03:49:51.076720 | 2019-10-09T10:33:09 | 2019-10-09T10:33:09 | 203,767,524 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,653 | java | package com.rnworkshop;
import android.annotation.SuppressLint;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
/**
* An example full-screen activity that shows and hides the system UI (i.e.
* status bar and navigation/system bar) with user interaction.
*/
public class WebviewActivity extends AppCompatActivity implements WebviewFragment.OnFragmentInteractionListener {
/**
* Whether or not the system UI should be auto-hidden after
* {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
*/
private static final boolean AUTO_HIDE = true;
/**
* If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
* user interaction before hiding the system UI.
*/
private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
/**
* Some older devices needs a small delay between UI widget updates
* and a change of the status and navigation bar.
*/
private static final int UI_ANIMATION_DELAY = 300;
private final Handler mHideHandler = new Handler();
private View mContentView;
private final Runnable mHidePart2Runnable = new Runnable() {
@SuppressLint("InlinedApi")
@Override
public void run() {
// Delayed removal of status and navigation bar
// Note that some of these constants are new as of API 16 (Jelly Bean)
// and API 19 (KitKat). It is safe to use them, as they are inlined
// at compile-time and do nothing on earlier devices.
}
};
private final Runnable mShowPart2Runnable = new Runnable() {
@Override
public void run() {
// Delayed display of UI elements
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.show();
}
}
};
private boolean mVisible;
private final Runnable mHideRunnable = new Runnable() {
@Override
public void run() {
hide();
}
};
/**
* Touch listener to use for in-layout UI controls to delay hiding the
* system UI. This is to prevent the jarring behavior of controls going away
* while interacting with activity UI.
*/
private final View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (AUTO_HIDE) {
delayedHide(AUTO_HIDE_DELAY_MILLIS);
}
return false;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
mVisible = true;
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Trigger the initial hide() shortly after the activity has been
// created, to briefly hint to the user that UI controls
// are available.
delayedHide(100);
}
private void toggle() {
if (mVisible) {
hide();
} else {
show();
}
}
private void hide() {
// Hide UI first
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.hide();
}
mVisible = false;
// Schedule a runnable to remove the status and navigation bar after a delay
mHideHandler.removeCallbacks(mShowPart2Runnable);
mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY);
}
@SuppressLint("InlinedApi")
private void show() {
// Show the system bar
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
mVisible = true;
// Schedule a runnable to display UI elements after a delay
mHideHandler.removeCallbacks(mHidePart2Runnable);
mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);
}
/**
* Schedules a call to hide() in delay milliseconds, canceling any
* previously scheduled calls.
*/
private void delayedHide(int delayMillis) {
mHideHandler.removeCallbacks(mHideRunnable);
mHideHandler.postDelayed(mHideRunnable, delayMillis);
}
@Override
public void onFragmentInteraction(Uri uri) {
System.out.println("LOL");
}
}
| [
"[email protected]"
]
| |
b92f9a76abc24c10406b423721235243081b96c1 | 4d37505edab103fd2271623b85041033d225ebcc | /spring-web/src/main/java/org/springframework/web/HttpMediaTypeException.java | 0975940c81a026cbebc74d35101b9e655605c283 | [
"Apache-2.0"
]
| permissive | huifer/spring-framework-read | 1799f1f073b65fed78f06993e58879571cc4548f | 73528bd85adc306a620eedd82c218094daebe0ee | refs/heads/master | 2020-12-08T08:03:17.458500 | 2020-03-02T05:51:55 | 2020-03-02T05:51:55 | 232,931,630 | 6 | 2 | Apache-2.0 | 2020-03-02T05:51:57 | 2020-01-10T00:18:15 | Java | UTF-8 | Java | false | false | 1,921 | java | /*
* Copyright 2002-2013 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.web;
import org.springframework.http.MediaType;
import javax.servlet.ServletException;
import java.util.Collections;
import java.util.List;
/**
* Abstract base for exceptions related to media types. Adds a list of supported {@link MediaType MediaTypes}.
*
* @author Arjen Poutsma
* @since 3.0
*/
@SuppressWarnings("serial")
public abstract class HttpMediaTypeException extends ServletException {
private final List<MediaType> supportedMediaTypes;
/**
* Create a new HttpMediaTypeException.
*
* @param message the exception message
*/
protected HttpMediaTypeException(String message) {
super(message);
this.supportedMediaTypes = Collections.emptyList();
}
/**
* Create a new HttpMediaTypeException with a list of supported media types.
*
* @param supportedMediaTypes the list of supported media types
*/
protected HttpMediaTypeException(String message, List<MediaType> supportedMediaTypes) {
super(message);
this.supportedMediaTypes = Collections.unmodifiableList(supportedMediaTypes);
}
/**
* Return the list of supported media types.
*/
public List<MediaType> getSupportedMediaTypes() {
return this.supportedMediaTypes;
}
}
| [
"[email protected]"
]
| |
51639686171e849327637c6b2d628bdddfc8f38d | 54bdf9200e3e2a4ab8a2e6fbe9b4ed791d47e612 | /src/main/java/cn/ux/jxxt/config/WebLogAspect.java | 3b8c13a1dd991e80e70c61877b1ab3fe86a6142a | []
| no_license | ygg404/jxxt | cb00aadf99799572e633883ab1bef1139935a0e5 | 7bb1ba25899112bd1f43a8ddf47ee6da1f169b01 | refs/heads/master | 2022-07-21T05:28:04.162276 | 2019-10-28T09:41:05 | 2019-10-28T09:41:05 | 208,528,886 | 0 | 0 | null | 2022-06-29T17:38:45 | 2019-09-15T02:02:25 | Java | UTF-8 | Java | false | false | 2,149 | java | package cn.ux.jxxt.config;
import cn.ux.jxxt.util.IPUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Arrays;
@Component
@Aspect
public class WebLogAspect {
private Logger looger = LoggerFactory.getLogger(this.getClass());
ThreadLocal<Long> startTime = new ThreadLocal<>();
@Pointcut("execution(public * cn.ux.jxxt.web.*.*(..))")//.*.*代表所有子目录下的所有方法,最后括号里(..)的两个..代表所有参数
public void webLog(){}
@Before("webLog()")
public void doBefore(JoinPoint joinPoint) throws Throwable{
startTime.set(System.currentTimeMillis());
//接收到请求,记录请求内容
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
//记录下请求内容
looger.info("请求地址 : " + request.getRequestURL().toString());
looger.info("HTTP_METHOD : " + request.getMethod());
looger.info("IP : " + IPUtils.getIpAddr(request));
looger.info("CLASS_METHOD" + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
looger.info("参数 : " + Arrays.toString(joinPoint.getArgs()));
}
@AfterReturning(returning = "ret" ,pointcut = "webLog()")
public void doAfterReturning(Object ret) throws Throwable{
//处理完请求,返回内容
looger.info("返回值 : " + ret);
looger.info("耗时 : " + (System.currentTimeMillis() - startTime.get()));
}
}
| [
"[email protected]"
]
| |
7bce181a8231e2edf2f255cf799c39bd3deefecb | 49ecfbfed2fbf0009005b6b2b9528b72e001c5b6 | /src/InverseFactorial.java | 3057011dba8b22b839fd1c23279c40fa22376949 | []
| no_license | Joachimmorken/Kattis-solutions | 0958d3cf098cc3e0653667d2ed67fe87bec69b27 | 9bfc1c2561dd98e3edbe2c0bab593897c3a1f703 | refs/heads/master | 2023-01-24T11:12:21.373566 | 2020-12-05T14:51:47 | 2020-12-05T14:51:47 | 168,152,842 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,635 | java | import java.io.*;
import java.util.StringTokenizer;
public class InverseFactorial {
public static void main(String[] args) {
Kattio in = new Kattio(System.in, System.out);
String n = in.getWord();
int ln = String.valueOf(n).length();
if (ln < 4) {
int small
= (n.equals("0") || n.equals("1")) ? 1
: (n.equals("2")) ? 2
: (n.equals("6")) ? 3
: (n.equals("24")) ? 4
: (n.equals("120")) ? 5 : 6;
System.out.println(small);
}
else {
double sum = Math.log10(720) + 1; //first factorial is always length 4 or bigger (i.e first possible number is 5040)
int factorial = 6;
while (true) {
factorial++;
sum += Math.log10(factorial);
if (Math.floor(sum) == ln) break;
}
in.write(String.valueOf(factorial));
}
in.flush();
in.close();
}
public static class Kattio extends PrintWriter {
public Kattio(InputStream i) {
super(new BufferedOutputStream(System.out));
r = new BufferedReader(new InputStreamReader(i));
}
public Kattio(InputStream i, OutputStream o) {
super(new BufferedOutputStream(o));
r = new BufferedReader(new InputStreamReader(i));
}
public boolean hasMoreTokens() {
return peekToken() != null;
}
public int getInt() {
return Integer.parseInt(nextToken());
}
public double getDouble() {
return Double.parseDouble(nextToken());
}
public long getLong() {
return Long.parseLong(nextToken());
}
public String getWord() {
return nextToken();
}
private BufferedReader r;
private String line;
private StringTokenizer st;
private String token;
private String peekToken() {
if (token == null)
try {
while (st == null || !st.hasMoreTokens()) {
line = r.readLine();
if (line == null) return null;
st = new StringTokenizer(line);
}
token = st.nextToken();
} catch (IOException e) {
}
return token;
}
private String nextToken() {
String ans = peekToken();
token = null;
return ans;
}
}
}
| [
"[email protected]"
]
| |
1760dd21a25842ec95ae9d7cceead6f6459db680 | 8f804724bac6b1832c6af63584f23b4b178ec603 | /src/main/java/jp/sample/api/controller/sampleController.java | 9153ba30dedf2998773429a1ce4832ca89cfc995 | []
| no_license | oblily/springBootSample | e8fecf9cf33c30b8ecd197681c8766b1cb54f27d | 654258305eb19f0a0d753e183b0b8b701c1388fa | refs/heads/master | 2020-04-17T03:02:54.578253 | 2019-01-17T05:19:51 | 2019-01-17T05:19:51 | 166,164,095 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 400 | java | package jp.sample.api.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class sampleController {
// http://localhost:1234/getFirstMethod
@GetMapping("/getFirstMethod")
public String getTest() {
return "Hello!, This is a sample for SpringBoot API. ";
}
}
| [
"[email protected]"
]
| |
ce1a1a511c0f4add9d52cf150b6e12a68f837c7a | 42dd95fbf89b2de1ee2fea69438f6eccd5649516 | /app/src/test/java/com/example/edwin/sistema_hotel/ExampleUnitTest.java | d53437eb57ba06d2b4b3c3034b8acc3e20016d98 | []
| no_license | edwinchaina/hostalapp | ab569f1efa3953d2515c7463615f981cba7629e0 | e3cb27e2040b52856c014b91bf66b5b7fe262607 | refs/heads/master | 2021-01-20T03:34:53.840648 | 2017-04-28T03:50:35 | 2017-04-28T03:50:35 | 89,558,708 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 409 | java | package com.example.edwin.sistema_hotel;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
]
| |
bffb2420949d135134fc8bedea9fc245c074a63e | b40d4c5264d17bc01783163dbb12746afdadc9c7 | /src/main/java/org/statnlp/commons/types/DAG.java | 14c22a43537b0a180cb85382ae1879ed88a8d290 | []
| no_license | allanj/dep-hybrid-tree | 93ce1c3da27a91d8a36cca899a6f8b4706566a8b | bc1b607cabe7e28271dfa0b7179a63bbd5d380a8 | refs/heads/master | 2020-03-26T19:36:00.987465 | 2019-03-07T12:56:33 | 2019-03-07T12:56:33 | 145,274,165 | 7 | 4 | null | null | null | null | UTF-8 | Java | false | false | 1,004 | java | /** Statistical Natural Language Processing System
Copyright (C) 2014-2016 Lu, Wei
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 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 org.statnlp.commons.types;
import java.io.Serializable;
/**
* @author wei_lu
*
*/
public interface DAG extends Serializable{
//get the node by id, the nodes in the DAG are sorted in topological order.
public Token get(int id);
} | [
"[email protected]"
]
| |
f2740f93ed10c11573bf155e51e9a0270de7e087 | 6e2b4479addd0965239ba77bb2f704bad9ab40a2 | /mediaplayertest/src/androidTest/java/cn/erayton/mediaplayertest/ExampleInstrumentedTest.java | 5c1574273bf04138fb195e775f42801eaabf0f90 | [
"Apache-2.0"
]
| permissive | 0xFF1E071F/tp808 | 30ea3c380625ef474c8a9803e949a5006bd218b2 | 1440010fdb77be01d5a7a9bbf4cfe49bceb3c8f3 | refs/heads/master | 2023-03-15T06:04:02.115603 | 2020-06-22T01:53:32 | 2020-06-22T01:53:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 723 | java | package cn.erayton.mediaplayertest;
import android.content.Context;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("cn.erayton.mediaplayertest", appContext.getPackageName());
}
}
| [
"[email protected]"
]
| |
b1b801bd7a8c03580dd923d5d2a52db7f5372282 | d53032277cc5ccf77d7e05fe52cb8c5d132e4fc6 | /src/com/github/gumtreediff/gen/srcml/AbstractSrcmlTreeGenerator.java | 8a0d9f25b01e6f3d9dd4b8b181c614c8eddff1e7 | []
| no_license | bitsecurerlab/ROS_migration | 7f902c3077b1fa7eb50853e29e025a0cd917e724 | 3f29798dec21701d66d85de40d7b228afeb4cbc9 | refs/heads/master | 2020-04-29T00:57:48.190018 | 2019-03-14T23:09:34 | 2019-03-14T23:09:34 | 175,713,981 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,007 | java | /*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2016 Jean-Rémy Falleri <[email protected]>
*/
package com.github.gumtreediff.gen.srcml;
import com.github.gumtreediff.gen.TreeGenerator;
import com.github.gumtreediff.io.LineReader;
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.TreeContext;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.events.*;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
public abstract class AbstractSrcmlTreeGenerator extends TreeGenerator {
private static final String SRCML_CMD = System.getProperty("gt.srcml.path", "srcml");
private static final QName LINE = new QName("http://www.srcML.org/srcML/position", "line", "pos");
private static final QName COLUMN = new QName("http://www.srcML.org/srcML/position", "column", "pos");
private LineReader lr;
private Set<String> labeled = new HashSet<String>(
Arrays.asList("specifier", "name", "comment", "literal", "operator"));
private StringBuilder currentLabel;
private TreeContext context;
@Override
public TreeContext generate(Reader r) throws IOException {
lr = new LineReader(r);
String xml = getXml(lr);
return getTreeContext(xml);
}
public TreeContext getTreeContext(String xml) {
XMLInputFactory fact = XMLInputFactory.newInstance();
context = new TreeContext();
currentLabel = new StringBuilder();
try {
ArrayDeque<ITree> trees = new ArrayDeque<>();
XMLEventReader r = fact.createXMLEventReader(new StringReader(xml));
while (r.hasNext()) {
XMLEvent ev = r.nextEvent();
if (ev.isStartElement()) {
StartElement s = ev.asStartElement();
String typeLabel = s.getName().getLocalPart();
if (typeLabel.equals("position"))
setLength(trees.peekFirst(), s);
else {
int type = typeLabel.hashCode();
ITree t = context.createTree(type, "", typeLabel);
if (trees.isEmpty()) {
context.setRoot(t);
t.setPos(0);
} else {
t.setParentAndUpdateChildren(trees.peekFirst());
setPos(t, s);
}
trees.addFirst(t);
}
} else if (ev.isEndElement()) {
EndElement end = ev.asEndElement();
if (!end.getName().getLocalPart().equals("position")) {
if (isLabeled(trees))
trees.peekFirst().setLabel(currentLabel.toString());
trees.removeFirst();
currentLabel = new StringBuilder();
}
} else if (ev.isCharacters()) {
Characters chars = ev.asCharacters();
if (!chars.isWhiteSpace() && isLabeled(trees))
currentLabel.append(chars.getData().trim());
}
}
fixPos(context);
context.validate();
return context;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private boolean isLabeled(ArrayDeque<ITree> trees) {
return labeled.contains(context.getTypeLabel(trees.peekFirst().getType()));
}
private void fixPos(TreeContext ctx) {
for (ITree t : ctx.getRoot().postOrder()) {
if (!t.isLeaf()) {
if (t.getPos() == ITree.NO_VALUE || t.getLength() == ITree.NO_VALUE) {
ITree firstChild = t.getChild(0);
t.setPos(firstChild.getPos());
if (t.getChildren().size() == 1)
t.setLength(firstChild.getLength());
else {
ITree lastChild = t.getChild(t.getChildren().size() - 1);
t.setLength(lastChild.getEndPos() - firstChild.getPos());
}
}
}
}
}
private void setPos(ITree t, StartElement e) {
if (e.getAttributeByName(LINE) != null) {
int line = Integer.parseInt(e.getAttributeByName(LINE).getValue());
int column = Integer.parseInt(e.getAttributeByName(COLUMN).getValue());
t.setPos(lr.positionFor(line, column));
}
}
private void setLength(ITree t, StartElement e) {
if (t.getPos() == -1)
return;
if (e.getAttributeByName(LINE) != null) {
int line = Integer.parseInt(e.getAttributeByName(LINE).getValue());
int column = Integer.parseInt(e.getAttributeByName(COLUMN).getValue());
t.setLength(lr.positionFor(line, column) - t.getPos() + 1);
}
}
public String getXml(Reader r) throws IOException {
// String path = "exception.txt";
// BufferedWriter wr = new BufferedWriter(new FileWriter(new File(path)));
//FIXME this is not efficient but I am not sure how to speed up things here.
File f = File.createTempFile("gumtree", "");
try (
Writer w = Files.newBufferedWriter(f.toPath(), Charset.forName("UTF-8"));
BufferedReader br = new BufferedReader(r);
) {
String line = br.readLine();
while (line != null) {
w.append(line + System.lineSeparator());
line = br.readLine();
}
}
ProcessBuilder pb = new ProcessBuilder(getArguments(f.getAbsolutePath()));
pb.redirectErrorStream(true);
pb.directory(f.getParentFile());
try {
Process p = pb.start();
Scanner scanner = new Scanner(p.getInputStream(), "UTF-8");
StringBuilder buf = new StringBuilder();
// TODO Why do we need to read and bufferize everything, when we could/should only use generateFromStream
while (scanner.hasNextLine()) {
buf.append(scanner.nextLine() + System.lineSeparator());
}
scanner.close();
p.waitFor();
// if (exit != 0) {
// throw new RuntimeException();
// }
p.destroy();
// Thread.sleep(1000);
String xml = buf.toString();
return xml;
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
f.delete();
}
}
private static void splitMessage(final InputStream input) {
// try {
// Process p = b.start();
// final InputStream is1 = p.getInputStream();
// final InputStream is2 = p.getErrorStream();
// new Thread() {
// public void run(){
// try {
// BufferedReader br = new BufferedReader(new InputStreamReader(is1, "UTF-8"));
// StringBuilder buf = new StringBuilder();
// String line = null ;
// while((line = br.readLine())!=null){
// buf.append(line + System.lineSeparator());
// }
// r.close();
// xml = buf.toString();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }.start();
//
// new Thread() {
// public void run(){
// try {
// BufferedReader br2 = new BufferedReader(new InputStreamReader(is2, "UTF-8"));
// String lineC = null ;
// while((lineC = br2.readLine())!= null){
// if(lineC!=null)
// System.out.println(lineC);
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }.start();
// p.waitFor();
// } catch (Exception e) {
// System.err.println(e);
// }
new Thread(new Runnable(){
public void run() {
try {
Reader r = new InputStreamReader(input, "UTF-8");
BufferedReader br = new BufferedReader(r);
StringBuilder buf = new StringBuilder();
String line = null;
while((line=br.readLine())!=null) {
buf.append(line + System.lineSeparator());
// System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
public abstract String getLanguage();
public String[] getArguments(String file) {
return new String[]{SRCML_CMD, "-l", getLanguage(), "--position", file, "--tabs=1"};
}
}
| [
"[email protected]"
]
| |
ddf8fbd68a87c69dc66a2a26916ebf3f424cbf5f | 694cee19962538ea68969a7588f9ca448bf67075 | /src/javafxapplication6/GegevensOpvragen_SceneController.java | e17732ce53b81e5dc042a52101af9efabe8b7ac9 | [
"MIT"
]
| permissive | hwpvanholsteijn/voedselbank_information_manager | c808dede1c2ffa6ee8febed0871707bff4333af7 | 985ed3922f2f5f5f7ffd58cb8b64cf7e88a37284 | refs/heads/master | 2020-03-07T10:26:31.123767 | 2018-03-30T14:36:22 | 2018-03-30T14:36:22 | 127,431,514 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,644 | java | package javafxapplication6;
import Lijsten.Lijst;
import Filters.UitgiftenpuntFilter;
import dataModels.Uitgiftepunt;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
public class GegevensOpvragen_SceneController implements Initializable {
@Override
public void initialize(URL url, ResourceBundle rb) {
tableView.getColumns().clear();
addColumns();
tableView.setItems(Lijst.uitgiftpuntenObservableList);
postcode.setCellValueFactory(
new PropertyValueFactory<>("postcode"));
uitgiftepunt.setCellValueFactory(
new PropertyValueFactory<>("naam"));
adres.setCellValueFactory(
new PropertyValueFactory<>("adres"));
maximumCapaciteit.setCellValueFactory(
new PropertyValueFactory<>("maximumCapaciteit"));
teLeverenPakketen.setCellValueFactory(
new PropertyValueFactory<>("teLeverenPakketen"));
aantalClienten.setCellValueFactory(
new PropertyValueFactory<>("aantalCliënten"));
teLeverenPakketen.setCellFactory(column -> {
return new TableCell<Uitgiftepunt, Integer>() {
@Override
protected void updateItem(Integer item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setText(null);
setStyle("");
} else {
setText(item.toString());
int plekOver = maximumCapaciteit.getCellData(getIndex()) - item;
if (plekOver <= 0) {
setStyle("-fx-background-color: red");
} else if (plekOver < 10) {
setStyle("-fx-background-color: orange");
}else{
setStyle("-fx-background-color: none");
}
}
}
};
});
maximumCapaciteit.setCellFactory(column -> {
return new TableCell<Uitgiftepunt, Integer>() {
@Override
protected void updateItem(Integer item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setText(null);
setStyle("");
} else {
setText(item.toString());
int plekOver = item - teLeverenPakketen.getCellData(getIndex());
if (plekOver <= 0) {
setStyle("-fx-background-color: red");
} else if (plekOver < 10) {
setStyle("-fx-background-color: orange");
} else{
setStyle("-fx-background-color: none");
}
}
}
};
});
}
@FXML
private Pane OpPane;
@FXML
private TableColumn<Uitgiftepunt, Integer> teLeverenPakketen;
@FXML
private TableColumn<Uitgiftepunt, Integer> aantalClienten;
@FXML
private TableColumn<Uitgiftepunt, String> postcode;
@FXML
private TableColumn<Uitgiftepunt, String> uitgiftepunt;
@FXML
private TableColumn<Uitgiftepunt, String> adres;
@FXML
private TableColumn<Uitgiftepunt, Integer> maximumCapaciteit;
@FXML
private TableView<Uitgiftepunt> tableView;
@FXML
private void backButton(MouseEvent event) throws IOException {
HomePageController.sceneControl.setScene(1);
}
private void addColumns() {
tableView.getColumns().add(uitgiftepunt);
if (UitgiftenpuntFilter.aantalClienten) {
tableView.getColumns().add(aantalClienten);
}
if (UitgiftenpuntFilter.capaciteit) {
tableView.getColumns().add(maximumCapaciteit);
tableView.getColumns().add(teLeverenPakketen);
}
if (UitgiftenpuntFilter.toonAdres) {
tableView.getColumns().add(adres);
}
if (UitgiftenpuntFilter.toonPostcode) {
tableView.getColumns().add(postcode);
}
}
}
| [
"[email protected]"
]
| |
63396e0d04fbd52631c17e12cd144c716ec4b645 | 38f7837c79d1a65e7a16497c9ce2965b88db6969 | /home-work-spring-10/src/main/java/ru/otus/homework/service/BookServiceImpl.java | e09e9d74a944155333ee53c63c4c4b3e6def61cf | []
| no_license | z0oba/2020-11-otus-spring-zubkov | c314e8b0cfe545faf2dca75a9a7e35be8853841e | 3b73111f5e86c7276fb364ecb60ef99c3f3c522b | refs/heads/main | 2023-04-19T20:17:54.005525 | 2021-05-10T06:45:17 | 2021-05-10T06:45:17 | 317,168,648 | 0 | 0 | null | 2021-05-10T06:45:18 | 2020-11-30T09:12:22 | Java | UTF-8 | Java | false | false | 2,693 | java | package ru.otus.homework.service;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ru.otus.homework.domain.Author;
import ru.otus.homework.domain.Book;
import ru.otus.homework.domain.Genre;
import ru.otus.homework.exceptions.BookServiceException;
import ru.otus.homework.repo.AuthorRepository;
import ru.otus.homework.repo.BookRepository;
import ru.otus.homework.repo.GenreRepository;
import java.util.List;
@AllArgsConstructor
@Service
public class BookServiceImpl implements BookService {
private final BookRepository bookRepository;
private final AuthorRepository authorRepository;
private final GenreRepository genreRepository;
@Override
@Transactional(readOnly = true)
public List<Book> getAll() {
return bookRepository.findAll();
}
@Override
@Transactional(readOnly = true)
public Book getById(long id) {
return bookRepository.findById(id).orElseThrow(() -> {
throw new BookServiceException("Can`t find book by id");
});
}
@Override
@Transactional(readOnly = true)
public long count() {
return bookRepository.count();
}
@Override
@Transactional
public Book add(String name, String authorName, String genreName) {
Author author = authorRepository.findByName(authorName);
if (author == null)
author = authorRepository.save(new Author(authorName));
Genre genre = genreRepository.findByName(genreName);
if (genre == null)
genre = genreRepository.save(new Genre(genreName));
return bookRepository.save(new Book(name, author, genre));
}
@Override
@Transactional
public long updateById(long id, String name, String authorName, String genreName) {
if (bookRepository.findById(id).isEmpty())
throw new BookServiceException("Can`t find book by id for update");
else {
Book book = bookRepository.findById(id).get();
Author author = authorRepository.findByName(authorName);
if (author == null)
author = authorRepository.save(new Author(authorName));
Genre genre = genreRepository.findByName(genreName);
if (genre == null)
genre = genreRepository.save(new Genre(genreName));
book.setName(name);
book.setAuthor(author);
book.setGenre(genre);
return bookRepository.save(book).getId();
}
}
@Override
@Transactional
public void deleteById(long id) {
bookRepository.deleteById(id);
}
} | [
"[email protected]"
]
| |
4f54a64e7d76fe782b6731666440bcc372b44757 | 67e2a16d5b1f45cdc5afe3b88d68784aceed6afb | /src/com/cjl/nio/NioServer.java | b5ce602c5b5a62787db654c12a175bd6374a7269 | []
| no_license | codingCJL/mianshi | ca441ff2df667c26632d338e1879b3e218e30886 | 754c229e601599f600e7c31e889b34a09235647f | refs/heads/master | 2021-02-09T23:17:22.788334 | 2020-03-09T09:54:52 | 2020-03-09T09:54:52 | 244,333,167 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,724 | java | package com.cjl.nio;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* NIO提供了与传统BIO模型中的 Socket 和 ServerSocket
* 相对应的 SocketChannel 和 ServerSocketChannel
* 多人聊天
*/
public class NioServer {
private int port;
// 用于字符集编解码
private Charset charset=Charset.forName("UTF-8");
// 用于接收数据的缓冲区
private ByteBuffer rBuffer=ByteBuffer.allocate(1024);
// 用于发送数据的缓冲区
private ByteBuffer sBuffer=ByteBuffer.allocate(1024);
// 用于存放客户端SocketChannel集合
private Map<String, SocketChannel> clientMap=new HashMap<>();
// 用于监听通道事件
private static Selector selector;
public NioServer(int port) {
this.port = port;
try {
init();
} catch (Exception e) {
e.printStackTrace();
}
}
// 初始化服务器
public void init() throws IOException {
ServerSocketChannel serverSocketChannel=ServerSocketChannel.open();
serverSocketChannel.configureBlocking(false);
ServerSocket serverSocket=serverSocketChannel.socket();
serverSocket.bind(new InetSocketAddress(port));
//开启监听通道事件
selector=Selector.open();
serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT);
System.out.println("服务器启动,端口为:"+port);
}
/**
* 服务器端轮询监听,select 方法会一直阻塞直到有相关事件发生或超时
*/
public void listen(){
while (true){
try {
selector.select(); // 返回值为本次触发的事件数
Set<SelectionKey> selectionKeys=selector.selectedKeys();
selectionKeys.forEach(selectionKey -> handle(selectionKey));
selectionKeys.clear(); // 清除处理过的事件
} catch (IOException e) {
System.out.println("客户端退出了连接");
break;
}
}
}
/**
* 处理事件
*/
private void handle(SelectionKey selectionKey) {
try {
// 有客户端要连接
if(selectionKey.isAcceptable()){
ServerSocketChannel server=(ServerSocketChannel)selectionKey.channel();
SocketChannel client=server.accept();
System.out.println("客户端["+client.getRemoteAddress()+"]连接成功");
client.configureBlocking(false);
client.register(selector,SelectionKey.OP_READ);
clientMap.put(getClientName(client),client);
}
// 客户端发送了消息
else if(selectionKey.isReadable()){
SocketChannel client=(SocketChannel)selectionKey.channel();
rBuffer.clear();
int bytes=client.read(rBuffer);
if(bytes>0){
rBuffer.flip();
String receiveText=String.valueOf(charset.decode(rBuffer));
System.out.println("客户端["+client.getRemoteAddress()+"]发出消息:"+receiveText);
//转发消息给各个客户端
dispatch(client, receiveText);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 转发消息给各个客户端
*/
private void dispatch(SocketChannel client, String info) throws IOException{
if(!clientMap.isEmpty()){
for(Map.Entry<String,SocketChannel> entry:clientMap.entrySet()){
SocketChannel temp=entry.getValue();
if(!client.equals(temp)){
sBuffer.clear();
sBuffer.put(charset.encode(getClientName(client)+":"+info));
sBuffer.flip();
temp.write(sBuffer);
}
}
}
}
/**
* 生成客户端名字
*/
private String getClientName(SocketChannel client) {
Socket socket=client.socket();
return "["+socket.getInetAddress().toString().substring(1)+":"+Integer.toHexString(client.hashCode())+"]";
}
public static void main(String[] args) {
NioServer server=new NioServer(8888);
server.listen();
}
}
| [
"[email protected]"
]
| |
5866f1f430ec4d26dc273a3b98f7a785254c8ed9 | 918f35cdc61d0024fc916c0293e1f71f8db509cf | /core/src/wg/games/warp/systems/spawning/EntityManager.java | 22bd17b78151dc97923e3850a082f7125da5f77b | []
| no_license | WaffeFIN/WarpGame5 | d2ccd8147fad5e40437e77639b0703db2b6507cc | 55cceab7dd8435fe856418378fdec74c1aca9a90 | refs/heads/master | 2021-01-20T19:53:05.484572 | 2017-04-22T19:49:52 | 2017-04-22T19:49:52 | 63,018,561 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,452 | 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 wg.games.warp.systems.spawning;
import com.artemis.Aspect;
import com.artemis.BaseSystem;
import com.artemis.Component;
import com.artemis.ComponentMapper;
import com.artemis.utils.IntBag;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.physics.box2d.World;
import wg.games.warp.components.*;
import wg.games.warp.systems.GameState;
/**
Responsible for all initial entity creation. This includes level
initialization. This class contains hard-coded entity setups as the
{@link DefaultDataMapper} holds all data.
@author Walter
*/
public class EntityManager extends BaseSystem {
private final AssetManager assetManager;
private final World engine;
private DefaultDataMapper defaultDataMapper;
public EntityManager(AssetManager assetManager, World engine) {
super();
this.assetManager = assetManager;
this.engine = engine;
}
@Override
protected void initialize() {
defaultDataMapper = new DefaultDataMapper(new Archetypes(world));
}
public void signalStateSwitch(GameState newState) {
if (newState != GameState.INTRO)
clear();
spawn(EntityGroup.get(newState));
}
public void spawn(EntityGroup group) {
if (group == null)
return;
EntityType[] types = EntityType.getAllFromGroup(group);
for (EntityType type : types) {
spawn(type);
}
}
//type -> data package; data -> archetype; data -> default components
public int spawn(EntityType type, Component... values) {
if (type == null)
return -1;
EntityData data = defaultDataMapper.getDefaultEntityData(type);
if (data == null)
return -1;
int e = world.create(data.archetype);
setComponentValues(e, data.defaultComponentValues);
setComponentValues(e, values);
return e;
}
private void setComponentValues(int e, Iterable<Component> components) {
for (Component value : components) {
Class componentClass = value.getClass();
if (CopyableComponent.class.isAssignableFrom(componentClass)) {
ComponentMapper<CopyableComponent> mapper = world.getMapper(componentClass);
CopyableComponent component = mapper.get(e);
component.copyFrom(value);
}
}
}
private void setComponentValues(int e, Component[] components) {
for (Component value : components) {
Class componentClass = value.getClass();
if (CopyableComponent.class.isAssignableFrom(componentClass)) {
ComponentMapper<CopyableComponent> mapper = world.getMapper(componentClass);
CopyableComponent component = mapper.get(e);
component.copyFrom(value);
}
}
}
public void clear() {
IntBag ents = world.getAspectSubscriptionManager().get(Aspect.all()).getEntities();
int[] ids = ents.getData();
for (int i = 0; i < ids.length; i++) {
world.delete(ids[i]);
}
}
@Override
protected boolean checkProcessing() {
return false;
}
@Override
protected void processSystem() {
}
}
| [
"[email protected]"
]
| |
b90347766976f5071fb29c2fd78e1b9a3cf058e0 | 3cfaf80c17169daf106f1bf69924dd5d4f235bbb | /src/main/java/site/zeng/wukongaq/entity/answer/Answer.java | 4b48166c18f7705057d1d21b2b86ab9a3ee03b99 | []
| no_license | mike-zeng/wukongaq | cf8cbf243121e16b7683af8eedb3daa7ee3753e6 | ca99e01f7a39759f6b2b404658437e496cff69f6 | refs/heads/master | 2020-06-05T04:22:02.711265 | 2019-07-17T10:36:05 | 2019-07-17T10:36:05 | 192,311,839 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,187 | java | package site.zeng.wukongaq.entity.answer;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Cascade;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
/**
* @author zeng
*/
@Entity
@Table(name = "tb_answer")
@Getter
@Setter
public class Answer {
/**
* 回答id
*/
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
/**
* 问题id
*/
@Column
private Integer pid;
@OneToMany
@JoinColumn(name = "aid")
@Cascade(org.hibernate.annotations.CascadeType.DELETE)
private List<Comment> comments;
/**
* 用户id
*/
@Column
private Integer uid;
/**
* 回答内容
*/
@Column
private String content;
/**
* 阅读数
*/
@Column
private Integer readNum=0;
/**
* 评论数
*/
@Column
private Integer commentNum=0;
/**
* 赞同数
*/
@Column
private Integer approvalNum=0;
/**
* 反对数
*/
@Column
private Integer oppositionNum=0;
/**
* 更新时间
*/
@Column
private Date updateTime=new Date();
}
| [
"[email protected]"
]
| |
5f2256d10a9a9fb4b6d6c658aa3dd4970fc0850c | bb6d63a698abc5ed8776c67f5c360b9c2f2b0cfc | /EPRUI/EPRUI/src/ClientUI/clientController.java | 9ef80b8cbb714b537828f4b003236054265b20e5 | []
| no_license | zhping5678/ERP | 484ac6689cdb998a60fe42de8bfd7b5e9555b430 | 23f4d4f7e1af537be02e07f1552c27733bf4f00e | refs/heads/master | 2022-01-05T13:11:47.837946 | 2019-01-15T06:19:59 | 2019-01-15T06:19:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,998 | java | package ClientUI;
import Login.CurrentState;
import MockObject.Clientbl;
import Start.Client;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Paint;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import vo.clientvo.ClientIdentity;
import vo.clientvo.ClientVO;
import vo.utilityvo.ResultMessage;
import java.util.Currency;
public class clientController {
@FXML public TextField ID;
@FXML public TextField NAME;
@FXML public TextField text1;
@FXML public TextField text2;
@FXML public TextField text3;
@FXML public TextField text4;
@FXML public TextField text5;
@FXML public TextField text6;
@FXML public TextField text7;
@FXML public TextField text8;
@FXML public TextField text9;
@FXML public TextField text10;
@FXML public TextField text11;
@FXML public TextField text12;
@FXML public TextField text13;
@FXML public TextField text14;
@FXML public VBox VBoxL;
@FXML public Label saveOrModify;
@FXML public Label banOrRecover;
@FXML public Label attention1;
@FXML public Label attention2;
public void ClickedT(MouseEvent mouseEvent) {
redo();
TextField t= (TextField) mouseEvent.getSource();
t.setStyle("-fx-background-color:rgb(242,242,242); -fx-background-radius:50; -fx-text-fill:rgb(102,0,153); -fx-font-size:18;");
}
public void ClickedP(MouseEvent mouseEvent) {
VBoxL.requestFocus();
redo();
}
public void redo(){
text1.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
text2.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
text3.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
text4.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
text5.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
text6.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
text7.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
text8.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
text9.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
text10.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
text11.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
text12.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
text13.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
text14.setStyle("-fx-background-color:rgb(255,255,255); -fx-background-radius:50; -fx-text-fill:rgb(0,0,0); -fx-font-size:18;");
attention1.setTextFill(Paint.valueOf("ffffff"));
attention2.setTextFill(Paint.valueOf("ffffff"));
}
String oldID;
public void ClickedSave(MouseEvent mouseEvent) {
if(mouseEvent.getPickResult().toString().contains("修改")){
//点击修改
saveOrModify.setText("保存");
oldID=ID.getText();
Editable();
}
else{
//点击保存
Clientbl bl=new Clientbl();
if(ID.getText().equals("")){
attention1.setText("客户ID/客户编号 为必填项");
attention1.setTextFill(Paint.valueOf("red"));
}
else{
//判断进货/销售
ClientIdentity client=null;
if(text2.getText().equals("进货商")){
client=ClientIdentity.Supplier;
}
else if(text2.getText().equals("销售商")){
client=ClientIdentity.Seller;
}
//判断是否被禁用
Boolean isban=false;
if(banOrRecover.getText().equals("禁用该客户")){
isban=false;
}
else if(banOrRecover.getText().equals("启用该客户")){
isban=true;
}
double quota=0;
if(text11.getText().equals("")){
quota=0;
}
else {
quota=Double.parseDouble(text11.getText());
}
//进行修改更新
ClientVO vo=new ClientVO(text1.getText(),text3.getText(),client,Integer.parseInt(text7.getText()),text5.getText(),text4.getText(),text12.getText(),text6.getText(),text14.getText(),text10.getText(),quota,Double.parseDouble(text9.getText()),Double.parseDouble(text8.getText()),Double.parseDouble(text13.getText()),isban);
ResultMessage message=bl.modifyClient(CurrentState.getLoginID(),oldID,vo);
if(message== ResultMessage.exist){
redo();
attention1.setText("该客户ID已存在");
attention1.setTextFill(Paint.valueOf("red"));
}
else if(message==ResultMessage.Fail){
redo();
attention1.setText("修改客户失败");
attention1.setTextFill(Paint.valueOf("red"));
}
else if(message==ResultMessage.modiSuccess){
redo();
attention1.setText("您已成功修改客户");
attention1.setTextFill(Paint.valueOf("#660099"));
UnEditable();
saveOrModify.setText("修改");
}
}
}
}
public void UnEditable(){
ID.setEditable(false);
NAME.setEditable(false);
text1.setEditable(false);
text2.setEditable(false);
text3.setEditable(false);
text4.setEditable(false);
text5.setEditable(false);
text6.setEditable(false);
text7.setEditable(false);
text8.setEditable(false);
text9.setEditable(false);
text10.setEditable(false);
text11.setEditable(false);
text12.setEditable(false);
text13.setEditable(false);
text14.setEditable(false);
}
public void Editable(){
ID.setEditable(true);
NAME.setEditable(true);
text1.setEditable(true);
//text2.setEditable(false);
text3.setEditable(true);
text4.setEditable(true);
text5.setEditable(true);
text6.setEditable(true);
text7.setEditable(true);
//text8.setEditable(false);
//text9.setEditable(false);
if(CurrentState.getRight()){
text10.setEditable(true);
}
else{
text10.setEditable(false);
}
//text10.setEditable(false);
text11.setEditable(true);
text12.setEditable(true);
text13.setEditable(true);
text14.setEditable(true);
}
public void EnteredSave(MouseEvent mouseEvent) {
saveOrModify.setFont(Font.font("system 18", FontWeight.BOLD,18));
}
public void ExitedSave(MouseEvent mouseEvent) {
saveOrModify.setFont(Font.font("system 18",FontWeight.NORMAL,18));
}
public void keepSameWithTitle(KeyEvent keyEvent) {
ID.setText(text1.getText());
}
public void keepSameWithItem(KeyEvent keyEvent) {
text1.setText(ID.getText());
}
public void ClickedBan(MouseEvent mouseEvent) {
if(saveOrModify.getText().equals("修改")){
;
}
else{
if(banOrRecover.getText().equals("禁用该客户")){
banOrRecover.setText("启用该客户");
}
else{
banOrRecover.setText("禁用该客户");
}
}
}
public void EnteredBan(MouseEvent mouseEvent) {
banOrRecover.setFont(Font.font("system 18",FontWeight.BOLD,18));
}
public void ExitedBan(MouseEvent mouseEvent) {
banOrRecover.setFont(Font.font("system 18",FontWeight.NORMAL,18));
}
}
| [
"[email protected]"
]
| |
fc06562cf0c5f9af019444b4a199f5fffd9248d8 | 1cd56efcec2ad1d4ce4df9cab21062fedb86d1ad | /IST412_alpacare/src/m03/a04/AbstractFactory.java | cc34daa32cf41bfdb8044859749156fabe706cb9 | []
| no_license | wacadushi/IST4123 | 595ca271cd72ec6a6385f4020ccdfe43645b1da7 | e1b41fda8c504330022a5d836a71edcfe3b57dc4 | refs/heads/master | 2020-04-30T19:30:47.740349 | 2019-04-21T21:58:30 | 2019-04-21T21:58:30 | 177,041,551 | 0 | 0 | null | 2019-04-14T22:49:38 | 2019-03-21T23:57:37 | Java | UTF-8 | Java | false | false | 318 | 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 m03.a04;
/**
*
* @author myphs
*/
public interface AbstractFactory<T> {
T create(String animalType);
}
| [
"[email protected]"
]
| |
df82394991511fdb7eaa79d1e09ca5821b3b3683 | bc1fd1f4b44d81f08d48266994256ec1eba90971 | /src/main/java/com/nelioalves/cursomc/domain/Categoria.java | d30b04ee229ab7dcfe658133e10d064992b8efbb | []
| no_license | scademir/cursomc | c11520d4d0a644a10f491e63e18f4caf22aa18f5 | 8356ad5771edd799c41a6880d45e20477559e33e | refs/heads/master | 2020-03-08T17:57:32.240220 | 2018-04-21T18:18:12 | 2018-04-21T18:18:12 | 128,282,610 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,335 | java | package com.nelioalves.cursomc.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
<<<<<<< HEAD
@Entity
public class Categoria implements Serializable {
private static final long serialVersionUID = 1L;
=======
@Entity
public class Categoria implements Serializable{
private static final long serialVersionUID = 1L;
>>>>>>> 04fcbc0d3e8104fcd90e14d5cb19da145a7b8c3e
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
private String nome;
@ManyToMany(mappedBy="categorias")
private List<Produto> produtos = new ArrayList<>();
public Categoria() {
}
<<<<<<< HEAD
=======
>>>>>>> 04fcbc0d3e8104fcd90e14d5cb19da145a7b8c3e
public Categoria(Integer id, String nome) {
super();
this.id = id;
this.nome = nome;
}
<<<<<<< HEAD
=======
>>>>>>> 04fcbc0d3e8104fcd90e14d5cb19da145a7b8c3e
public Integer getId() {
return id;
}
<<<<<<< HEAD
=======
>>>>>>> 04fcbc0d3e8104fcd90e14d5cb19da145a7b8c3e
public void setId(Integer id) {
this.id = id;
}
<<<<<<< HEAD
=======
>>>>>>> 04fcbc0d3e8104fcd90e14d5cb19da145a7b8c3e
public String getNome() {
return nome;
}
<<<<<<< HEAD
=======
>>>>>>> 04fcbc0d3e8104fcd90e14d5cb19da145a7b8c3e
public void setNome(String nome) {
this.nome = nome;
}
public List<Produto> getProdutos() {
return produtos;
}
<<<<<<< HEAD
=======
>>>>>>> 04fcbc0d3e8104fcd90e14d5cb19da145a7b8c3e
public void setProdutos(List<Produto> produtos) {
this.produtos = produtos;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
<<<<<<< HEAD
=======
>>>>>>> 04fcbc0d3e8104fcd90e14d5cb19da145a7b8c3e
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Categoria other = (Categoria) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
<<<<<<< HEAD
=======
>>>>>>> 04fcbc0d3e8104fcd90e14d5cb19da145a7b8c3e
}
| [
"[email protected]"
]
| |
cec2e04b8b16e351727aa7eb322c7e38fc46a525 | dad78fa3f55eac67cffd004e7613e64a579be41d | /src/com/bvan/oop/hw/lesson5/airlineticket/Meal.java | 7983f7e90639bd687fbd6a52533d72a36328fa3e | []
| no_license | bohdanvan/javaoop-homework | 414afa5812fd236c2c4338766ae68cab1a335e7b | 1fd858cc56defc896d52bfca2a2abf54d3f4828b | refs/heads/master | 2020-03-12T01:15:52.805041 | 2018-10-30T17:14:47 | 2018-10-30T17:14:47 | 130,371,628 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 763 | java | package com.bvan.oop.hw.lesson5.airlineticket;
/**
* @author bvanchuhov
*/
public class Meal {
private final String type;
private final boolean withDrink;
private final long price;
public Meal(String type, boolean withDrink, long price) {
this.type = type;
this.withDrink = withDrink;
this.price = price;
}
public String getType() {
return type;
}
public boolean isWithDrink() {
return withDrink;
}
public long getPrice() {
return price;
}
@Override
public String toString() {
return "Meal{" +
"type='" + type + '\'' +
", withDrink=" + withDrink +
", price=" + price +
'}';
}
}
| [
"[email protected]"
]
| |
a60298f44be9a736416f296c73c890ba8cdf37f5 | 609ae5e3a99649c8c8c45ad8eff04251e8403e25 | /PadCalc/src/data/skill/EnemyDamageReduction.java | 6eb843edd135567608bf4aee30dcf9f6d7477dbe | []
| no_license | candyninja001/PadCalc | 4b4b99726dc1fc322d23f9d3d1bad956f08e5229 | 4c575e5c0e758b8d02039edea3f27740ec84c962 | refs/heads/master | 2021-06-21T02:15:52.706936 | 2017-08-11T23:32:28 | 2017-08-11T23:32:28 | 100,076,709 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 74 | java | package data.skill;
public class EnemyDamageReduction extends Skill {
}
| [
"[email protected]"
]
| |
708f7afdb3a4ca57004cdbfbaa059e5328cd95b9 | fb110fead2ecfffb4b78d3920da1a3d162bd1932 | /de.gematik.ti.cardreader.provider.api/src/main/java/de/gematik/ti/cardreader/provider/spi/ICardReaderControllerProvider.java | caea54a738158fecf711654c2dbb76bade555c4f | [
"Apache-2.0"
]
| permissive | gematik/ref-CardReaderProvider-Api | ca8495bbb81b6f018f09c7f9856db5b56f827b4e | 80d863c5b03a776534d7fa8a26916273dc7e39b9 | refs/heads/master | 2022-02-10T18:06:21.446280 | 2022-01-07T07:36:00 | 2022-01-07T07:36:00 | 227,793,349 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 827 | java | /*
* ${GEMATIK_LICENSE}
*/
package de.gematik.ti.cardreader.provider.spi;
import de.gematik.ti.cardreader.provider.api.ICardReaderController;
import de.gematik.ti.cardreader.provider.api.entities.IProviderDescriptor;
/**
* include::{userguide}/CRPAPI_Overview.adoc[tag=ServiceProvider]
*
*/
public interface ICardReaderControllerProvider {
/**
* Return the Controller for specific ICardReaderController implementation
*
* @return - return CardReaderController for a specific card reader interface
*/
ICardReaderController getCardReaderController();
/**
* Descriptor class for information about the card reader provider and functionality
* @return - Descriptor object for this card reader provider
*/
IProviderDescriptor getDescriptor();
}
| [
"[email protected]"
]
| |
92dfc8c5860f00ff5b5381f93b2c8360ac90020d | a3c75d0490c1e7d0f4a2e44dd723b519072cdb5b | /src/Parsing/Main.java | 997d516a6a15978fca45d47e5102a76a882fae23 | []
| no_license | nvmnghia/TestingJS | 93cdd5f1177cbddf930b98ad69f5e83d510a17e8 | 0dbd59e5ca9dbc51b01e09c649a1283527f2d2c0 | refs/heads/master | 2021-07-25T01:19:26.682256 | 2017-11-05T10:23:35 | 2017-11-05T10:23:35 | 109,569,364 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,488 | java | package Parsing;
import com.google.gson.Gson;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Node;
import org.mozilla.javascript.ast.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) throws IOException {
AstRoot root = Parser.parse(new File("javascript.js"));
System.out.println(root.toSource());
System.out.println("__________________________________________________________________________");
// String[] paramAndVar = root.getParamAndVarNames();
// for (String str : paramAndVar) {
// System.out.print(str + " ");
// }
List<Symbol> listSymbols = root.getSymbols();
System.out.println(listSymbols.size());
for (Symbol symbol : listSymbols) {
System.out.println(symbol.getDeclTypeName() + " " + symbol.getName());
}
List<FunctionNode> listFunctions = root.getFunctions();
System.out.println(listFunctions.size());
for (FunctionNode func : listFunctions) {
System.out.println(func.getName() + " " + func.toString());
}
// Node firstNodeBody = ((FunctionNode) root.getFirstChild()).getBody();
// traverse(firstNodeBody);
simpleTraverse(root.getFirstChild());
// root.visitAll(new NodeVisitor() {
// @Override
// public boolean visit(AstNode node) {
// System.out.println(String.format("%1$3d", node.getLineno()) + " " + node.getClass());
// return true;
// }
// });
// root.visit(new NodeVisitor() {
// @Override
// public boolean visit(AstNode node) {
// System.out.println(String.format("%1$3d", node.getLineno()) + " " + node.getClass());
//
// return true;
// }
// });
}
public static void traverse(Node node) {
while (node != null) {
System.out.println(node.getType() + " " + node.getLineno());
if (node instanceof FunctionNode) {
FunctionNode thisNode = (FunctionNode) node;
System.out.println("FunctionNode: " + thisNode.getFunctionName() + " " + thisNode.getFunctionType());
AstNode body = thisNode.getBody();
System.out.println("Traversing into body of " + thisNode.getFunctionName());
traverse(body);
} else if (node instanceof VariableDeclaration) {
System.out.println("VariableDeclaration: " + ((VariableDeclaration) node).getVariables());
} else {
System.out.println("WHAT THE FUCK IS " + node.getClass());
}
System.out.println("");
System.out.println("Start traverse child");
Node childNode = node.getFirstChild();
traverse(childNode);
System.out.println("Stop traverse child");
System.out.println("Move to next");
node = node.getNext();
}
System.out.println("End traverse");
}
private static int depth = 0; // For pretty printing
public static void simpleTraverse(Node node) {
StringBuilder builder = new StringBuilder("");
for (int i = 0; i < depth; ++i) {
builder.append('\t');
}
String tabs = builder.toString();
while (node != null) {
System.out.println(node.getClass() + " " + node.getLineno());
// Node childNode = node.getFirstChild();
for (Node childNode : node) {
if (childNode != null) {
++depth;
System.out.println(tabs + "Start traversing child");
simpleTraverse(childNode);
--depth;
System.out.println(tabs + "Stop traversing child");
}
}
System.out.println("Move to next");
node = node.getNext();
}
System.out.println(tabs + "End traversing");
// if (node != null) {
// AstNode thisNode = (AstNode) node;
// for (Node sib : thisNode) {
// System.out.println(sib.getClass().getName().substring(33) + " " + sib.getLineno());
// simpleTraverse(sib);
// }
//
// simpleTraverse(thisNode.getNext());
// }
}
}
| [
"[email protected]"
]
| |
48610b397e7535992d233e124fbb55ee6f645889 | 56f7d200384baa10fd4283a77b6e977441efe02b | /CentralUFG/app/src/main/java/muralufg/fabrica/inf/ufg/br/centralufg/ouvidoria/fragments/OuvidoriaFragment.java | 8f7e09a29a443a7c49d8666a2070a73601961eb1 | []
| no_license | AlexMota/muralCliente | 38632a0a864497ba0bdc44b25e9237dd326b2cd3 | b0f45cad13c3d47901ef209101bfde1ce5213dab | refs/heads/master | 2021-01-17T06:33:15.672921 | 2014-12-04T18:26:50 | 2014-12-04T18:26:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,627 | java | package muralufg.fabrica.inf.ufg.br.centralufg.ouvidoria.fragments;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.Toast;
import org.apache.log4j.Logger;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import de.keyboardsurfer.android.widget.crouton.Crouton;
import de.keyboardsurfer.android.widget.crouton.Style;
import muralufg.fabrica.inf.ufg.br.centralufg.R;
import muralufg.fabrica.inf.ufg.br.centralufg.ouvidoria.adapters.AnexoAdapter;
import muralufg.fabrica.inf.ufg.br.centralufg.ouvidoria.adapters.AnexoImagensAdapter;
import muralufg.fabrica.inf.ufg.br.centralufg.ouvidoria.models.ItemException;
import muralufg.fabrica.inf.ufg.br.centralufg.ouvidoria.models.Ouvidoria;
import muralufg.fabrica.inf.ufg.br.centralufg.ouvidoria.models.OuvidoriaItemAnexo;
import muralufg.fabrica.inf.ufg.br.centralufg.ouvidoria.services.OuvidoriaService;
import muralufg.fabrica.inf.ufg.br.centralufg.ouvidoria.utils.FormOuvidoriaValidator;
import muralufg.fabrica.inf.ufg.br.centralufg.ouvidoria.utils.OuvidoriaUtil;
import muralufg.fabrica.inf.ufg.br.centralufg.util.ServiceCompliant;
public class OuvidoriaFragment extends Fragment implements ServiceCompliant {
private static final Logger LOGGER = Logger.getLogger(OuvidoriaFragment.class.getName());
static final int REQUEST_IMAGE_CAPTURE = 1;
static final int REQUEST_IMAGE_GALERIA = 2;
static final int REQUEST_ARQUIVO = 3;
public static final String IMAGEM_TYPE = "image/*";
public static final String AUDIO_TYPE = "audio/*";
public static final String VIDEO_TYPE = "video/*";
/**
* Tamanho máximo de 20 MB
*/
private static final long TAMANNHO_MAXIMO_ARQUIVO = 20971520;
private EditText mOuvidoriaTitulo;
private EditText mOuvidoriaData;
private EditText mOuvidoriaDescricao;
private ListView mOuvidoriaListaArquivos;
private GridView mOuvidoriaGridImagens;
private AnexoAdapter mArquviosAdapter;
private AnexoImagensAdapter mImagensAdapter;
private String mFotoDiretorioAtual;
public OuvidoriaFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ArrayList<OuvidoriaItemAnexo> arquivos = new ArrayList<OuvidoriaItemAnexo>();
mArquviosAdapter = new AnexoAdapter(getActivity(), arquivos);
final ArrayList<OuvidoriaItemAnexo> imagens = new ArrayList<OuvidoriaItemAnexo>();
mImagensAdapter = new AnexoImagensAdapter(getActivity(), imagens);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
setHasOptionsMenu(true);
View rootView = inflater.inflate(R.layout.fragment_ouvidoria, container, false);
mOuvidoriaTitulo = (EditText) rootView.findViewById(R.id.ouvidoriaTitulo);
mOuvidoriaData = (EditText) rootView.findViewById(R.id.ouvidoriaData);
mOuvidoriaDescricao = (EditText) rootView.findViewById(R.id.ouvidoriaDescricao);
mOuvidoriaListaArquivos = (ListView) rootView.findViewById(R.id.ouvidoriaListaAnexos);
mOuvidoriaListaArquivos.setAdapter(mArquviosAdapter);
mOuvidoriaGridImagens = (GridView) rootView.findViewById(R.id.ouvidoriaGridImagens);
mOuvidoriaGridImagens.setAdapter(mImagensAdapter);
return rootView;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.ouvidoria, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch (id) {
case R.id.action_enviar:
enviarMensagem();
break;
case R.id.action_camera:
chooserCamera();
break;
case R.id.action_anexar_imagem:
chooserImagem();
break;
case R.id.action_anexar_arquivo:
chooserArquivo();
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
/**
* Enviar mensagem
*/
private void enviarMensagem() {
// Definir os parametros para validar o formulário
FormOuvidoriaValidator form = new FormOuvidoriaValidator.Builder()
.data(mOuvidoriaData)
.minimo(mOuvidoriaTitulo, 5)
.minimo(mOuvidoriaDescricao, 10)
.build();
// Enviar mensagem, se o formulário for preenchido corretamente
if (form.isValid()) {
String titulo = mOuvidoriaTitulo.getText().toString();
String data = mOuvidoriaData.getText().toString();
String descricao = mOuvidoriaDescricao.getText().toString();
Ouvidoria ouvidoria = new Ouvidoria(titulo, data, descricao);
// Adicionar todos os itens em anexo
ouvidoria.addAllItensAnexo(mArquviosAdapter.getAll());
ouvidoria.addAllItensAnexo(mImagensAdapter.getAll());
// Enviar a mensagem para a ouvidoria
OuvidoriaService ouvidoriaService = new OuvidoriaService(this, ouvidoria);
ouvidoriaService.execute();
}
}
/**
* Abrir seletor de arquivos de Audio ou Vídeo
*/
private void chooserArquivo() {
Intent chooseIntent = new Intent(Intent.ACTION_PICK);
chooseIntent.setType(AUDIO_TYPE);
chooseIntent.setType(VIDEO_TYPE);
chooseIntent.setAction(Intent.ACTION_GET_CONTENT);
if (chooseIntent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivityForResult(chooseIntent, REQUEST_ARQUIVO);
}
}
/**
* Abrir seletor de imagem
*/
private void chooserImagem() {
Intent chooseIntent = new Intent(Intent.ACTION_PICK);
chooseIntent.setType(IMAGEM_TYPE);
chooseIntent.setAction(Intent.ACTION_GET_CONTENT);
if (chooseIntent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivityForResult(chooseIntent, REQUEST_IMAGE_GALERIA);
}
}
/**
* Abrir camera para foto
*/
private void chooserCamera() {
Intent chooseIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// Certifique-se de que há uma atividade câmera para lidar com a intenção
if (chooseIntent.resolveActivity(getActivity().getPackageManager()) != null) {
// Criar o arquivo onde a foto deve ser salva
File photoFile = null;
try {
photoFile = criarArquivoImagem();
} catch (IOException ex) {
LOGGER.error(ex.getMessage());
showMenssage(ex.getMessage());
}
// Continuar apenas se o arquivo estiver criado
if (photoFile != null) {
chooseIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photoFile));
startActivityForResult(chooseIntent, REQUEST_IMAGE_CAPTURE);
}
}
}
/**
* Criar um arquivo para a imagem que sera salva apos a foto
*
* @return
* @throws java.io.IOException
*/
private File criarArquivoImagem() throws IOException {
// Criar o nome do arquivo
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imagemNome = "JPEG_" + timeStamp + "_";
File armazenamentoDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(
imagemNome, /* prefixo */
".jpg", /* sufixo */
armazenamentoDir /* diretorio */
);
mFotoDiretorioAtual = image.getAbsolutePath();
return image;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
switch (requestCode) {
case REQUEST_IMAGE_CAPTURE:
anexarImagem(mFotoDiretorioAtual);
break;
case REQUEST_IMAGE_GALERIA:
anexarImagem(getDiretorio(data.getData()));
break;
case REQUEST_ARQUIVO:
anexarArquivo(getDiretorio(data.getData()));
break;
default:
break;
}
}
}
/**
* @param arquivo
*/
private void anexarArquivo(String arquivo) {
try {
final OuvidoriaItemAnexo itemAnexo = getItemAnexo(arquivo);
addArquivo(itemAnexo);
} catch (ItemException e) {
LOGGER.error(e.getMessage(), e);
showMenssage(e.getMessage());
}
}
/**
* @param imagem
*/
private void anexarImagem(String imagem) {
try {
final OuvidoriaItemAnexo itemAnexo = getItemAnexo(imagem);
addImagem(itemAnexo);
} catch (ItemException e) {
LOGGER.error(e.getMessage(), e);
showMenssage(e.getMessage());
}
}
/**
* @param diretorio
* @return
* @throws Exception
*/
private OuvidoriaItemAnexo getItemAnexo(String diretorio) throws ItemException {
OuvidoriaItemAnexo itemAnexo;
// localização do item
File file = new File(diretorio);
if (file.exists()) {
// Verifica o tamanho máximo do arquivo para envio
if (file.length() > TAMANNHO_MAXIMO_ARQUIVO) {
throw new ItemException(String.format(
getResources().getString(R.string.erro_tamanho_maximo_arquivo),
getTamanhoMaximo()
));
}
// Item Anexo
final String nome = file.getName();
final Long tamanho = file.length();
itemAnexo = new OuvidoriaItemAnexo(diretorio, nome, tamanho);
return itemAnexo;
} else {
throw new ItemException(String.format(
getResources().getString(R.string.erro_arquivo_nao_existe)
));
}
}
/**
* Capturar o diretorio de um arquivo selecionado
*
* @param uri
* @return
*/
public String getDiretorio(Uri uri) {
String[] projection = {MediaStore.MediaColumns.DATA};
Cursor cursor = getActivity().getContentResolver().query(uri, projection, null, null, null);
int columnIndex = cursor
.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
cursor.moveToFirst();
return cursor.getString(columnIndex);
}
/**
* Adicionar uma imagem na lista de anexos
*
* @param itemAnexo
*/
private void addImagem(OuvidoriaItemAnexo itemAnexo) {
mImagensAdapter.add(itemAnexo);
mImagensAdapter.notifyDataSetChanged();
}
/**
* Adicionar um arquivo na lista de anexos
*
* @param itemAnexo
*/
private void addArquivo(OuvidoriaItemAnexo itemAnexo) {
mArquviosAdapter.add(itemAnexo);
mArquviosAdapter.notifyDataSetChanged();
}
/**
* Obter o tamanho máximo e formatado para o usuário
*
* @return
*/
private String getTamanhoMaximo() {
return OuvidoriaUtil.bytesParaFormatoLegivel(TAMANNHO_MAXIMO_ARQUIVO, true);
}
/**
* Mostrar o Toast para o usuário
*
* @param mensagem
*/
private void showMenssage(String mensagem) {
Toast.makeText(getActivity(), mensagem, Toast.LENGTH_SHORT).show();
}
/**
* Resposta de erro após enviar mensagem à ouvidoria
*
* @param error
*/
@Override
public void handleError(String error) {
Crouton.makeText(this.getActivity(), error, Style.ALERT).show();
}
/**
* Resposta contendo a mensagem de retorno à mensagem enviada
*
* @param object
*/
@Override
public void readObject(Object object) {
if (object instanceof String) {
final String mensagem = (String) object;
Crouton.makeText(this.getActivity(), mensagem, Style.CONFIRM).show();
limparCamposForm();
} else {
Log.e(this.getClass().getName(), "A mensagem de reposta deve ser uma String");
}
}
/**
* Limpar todos os dados inseridos nos campos do formulário
*/
private void limparCamposForm() {
mOuvidoriaTitulo.setText("");
mOuvidoriaTitulo.requestFocus();
mOuvidoriaData.setText("");
mOuvidoriaDescricao.setText("");
}
/**
* Informar a activity do fragment
*
* @return
*/
@Override
public Activity getContextActivity() {
return this.getActivity();
}
} | [
"[email protected]"
]
| |
a58a1cd5f2b6f2bd5be46858d26e4bce912daddb | 678da12789dddc32d09ae2a553c44261759c1ab0 | /src/view/studentManagement/StudentDetailController.java | 28183f7c564fcca37f5bf5dcb787f0d87dab33c0 | []
| no_license | MrLeanage/HMS | 65b9dec42feaab544b59ef55130e7dc11db9c55e | 6c23512ba9a8fffe4a8d3cc44d0a7699328a3302 | refs/heads/main | 2023-04-28T06:55:38.651979 | 2021-05-20T15:06:41 | 2021-05-20T15:06:41 | 369,248,483 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,646 | java | package view.studentManagement;
import bean.Student;
import com.jfoenix.controls.JFXButton;
import javafx.collections.ObservableList;
import javafx.collections.transformation.SortedList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.stage.FileChooser;
import service.StudentService;
import utility.dataHandler.DataValidation;
import utility.dataHandler.UtilityMethod;
import utility.popUp.AlertPopUp;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.Optional;
import java.util.ResourceBundle;
public class StudentDetailController implements Initializable {
@FXML
private TableView<Student> studentTable;
@FXML
private TableColumn<Student, ImageView> imageColumn;
@FXML
private TableColumn<Student, String> nicColumn;
@FXML
private TableColumn<Student, String> nameColumn;
@FXML
private TableColumn<Student, String> addressColumn;
@FXML
private TableColumn<Student, Integer> phoneColumn;
@FXML
private TextField searchTextField;
@FXML
private TextField nicTextField;
@FXML
private TextField nameTextField;
@FXML
private Label nicLabel;
@FXML
private Label nameLabel;
@FXML
private JFXButton updateButton;
@FXML
private JFXButton addButton;
@FXML
private TextField phoneTextField;
@FXML
private TextArea addressTextField;
@FXML
private Label phoneLabel;
@FXML
private Label addressLabel;
@FXML
private ImageView photoImageView;
@FXML
private Label photoLabel;
private static Student selectedStudent;
private static File staticFile;
@Override
public void initialize(URL location, ResourceBundle resources) {
loadData();
}
private void loadData() {
StudentService studentService = new StudentService();
ObservableList<Student> studentObservableList = studentService.loadAllStudentData();
imageColumn.setCellValueFactory(new PropertyValueFactory<>("sImage"));
nicColumn.setCellValueFactory(new PropertyValueFactory<>("sNIC"));
nameColumn.setCellValueFactory(new PropertyValueFactory<>("sName"));
addressColumn.setCellValueFactory(new PropertyValueFactory<>("sAddress"));
phoneColumn.setCellValueFactory(new PropertyValueFactory<>("sPhone"));
imageColumn.setCellFactory(param -> {
//Set up the ImageView
final ImageView imageview = new ImageView();
imageview.setFitHeight(80);
imageview.setFitWidth(80);
//Set up the Table
TableCell<Student, ImageView> cell = new TableCell<Student, ImageView>() {
public void updateItem(ImageView item, boolean empty) {
if(item != null){
if(!empty){
imageview.setImage(item.getImage());
}
}
}
};
// Attach the imageview to the cell
cell.setGraphic(null);
cell.setGraphic(imageview);
return cell;
});
studentTable.setItems(null);
studentTable.setItems(studentObservableList);
searchTable();
}
public void searchTable() {
StudentService studentService = new StudentService();
SortedList<Student> sortedData = studentService.searchTable(searchTextField);
//binding the SortedList to TableView
sortedData.comparatorProperty().bind(studentTable.comparatorProperty());
//adding sorted and filtered data to the table
studentTable.setItems(sortedData);
}
@FXML
void addStudent(ActionEvent event) {
ObservableList<Student> modelList = studentTable.getItems();
ArrayList<String> studentList = new ArrayList<>();
for (Student student : modelList) {
studentList.add(student.getsNIC().toLowerCase());
}
clearLabels();
if (studentValidation() && !UtilityMethod.checkDataAvailability(studentList, nicTextField.getText().toLowerCase())) {
Student student = new Student();
StudentService studentService = new StudentService();
student.setsNIC(nicTextField.getText());
student.setsName(nameTextField.getText());
student.setsAddress(addressTextField.getText());
student.setsPhone(Integer.valueOf(phoneTextField.getText()));
student.setsImage(photoImageView);
if (studentService.insertStudentData(student)) {
AlertPopUp.insertSuccesfully("Student");
loadData();
searchTable();
clearFields(event);
} else
AlertPopUp.insertionFailed("Student");
} else
studentValidationMessage();
}
@FXML
void updateStudent(ActionEvent event) {
clearLabels();
if (studentValidation()) {
Student student = new Student();
StudentService studentService = new StudentService();
student.setsNIC(selectedStudent.getsNIC());
student.setsName(nameTextField.getText());
student.setsAddress(addressTextField.getText());
student.setsPhone(Integer.valueOf(phoneTextField.getText()));
student.setsImage(photoImageView);
if (studentService.updateStudentData(student)) {
AlertPopUp.updateSuccesfully("Student");
loadData();
searchTable();
clearFields(event);
} else
AlertPopUp.updateFailed("Student");
} else
studentValidationMessage();
}
@FXML
private void deleteStudent(ActionEvent event) {
if (selectedStudent != null) {
StudentService studentService = new StudentService();
Optional<ButtonType> action = AlertPopUp.deleteConfirmation("Student");
if (action.get() == ButtonType.OK) {
if (studentService.deleteStudentData((selectedStudent.getsNIC()))) {
AlertPopUp.deleteSuccesfull("Student");
loadData();
searchTable();
clearFields(event);
} else
AlertPopUp.deleteFailed("Student");
} else
loadData();
} else {
AlertPopUp.selectRowToDelete("Student");
}
}
@FXML
void setSelectedStudentDataToFields(MouseEvent event) {
try {
clearLabels();
addButton.setVisible(false);
updateButton.setVisible(true);
nicTextField.setEditable(false);
selectedStudent = studentTable.getSelectionModel().getSelectedItem();
nicTextField.setText(selectedStudent.getsNIC());
nameTextField.setText(selectedStudent.getsName());
addressTextField.setText(selectedStudent.getsAddress());
phoneTextField.setText("0" + selectedStudent.getsPhone().toString());
photoImageView.setImage(selectedStudent.getsImage().getImage());
} catch (NullPointerException exception) {
}
}
@FXML
void clearFields(ActionEvent event) {
nicTextField.setText("");
nameTextField.setText("");
addressTextField.setText("");
phoneTextField.setText("");
photoImageView.setImage(null);
resetComponents();
clearLabels();
selectedStudent = null;
}
private void clearLabels() {
nicLabel.setText("");
nameLabel.setText("");
addressLabel.setText("");
phoneLabel.setText("");
phoneLabel.setText("");
}
private boolean studentValidation() {
return DataValidation.TextFieldNotEmpty(nicTextField.getText())
&& DataValidation.TextFieldNotEmpty(nameTextField.getText())
&& DataValidation.TextFieldNotEmpty(addressTextField.getText())
&& DataValidation.TextFieldNotEmpty(phoneTextField.getText())
&& DataValidation.ImageFieldNotEmpty(photoImageView)
&& DataValidation.isValidMaximumLength(nameTextField.getText(), 45)
&& DataValidation.isValidMaximumLength(addressTextField.getText(), 400)
&& DataValidation.isValidNIC(nicTextField)
&& DataValidation.isValidPhoneNo(phoneTextField.getText());
}
private void studentValidationMessage() {
ObservableList<Student> modelList = studentTable.getItems();
ArrayList<String> studentList = new ArrayList<>();
for (Student student : modelList) {
studentList.add(student.getsNIC().toLowerCase());
}
if (!(DataValidation.TextFieldNotEmpty(nicTextField.getText())
&& DataValidation.TextFieldNotEmpty(nameTextField.getText())
&& DataValidation.TextFieldNotEmpty(addressTextField.getText())
&& DataValidation.TextFieldNotEmpty(phoneTextField.getText())
&& DataValidation.ImageFieldNotEmpty(photoImageView))) {
DataValidation.TextFieldNotEmpty(nicTextField.getText(), nicLabel, "Student's NIC Required!");
DataValidation.TextFieldNotEmpty(nameTextField.getText(), nameLabel, "Student's Name Required!");
DataValidation.TextFieldNotEmpty(addressTextField.getText(), addressLabel, "Student's address Required!");
DataValidation.TextFieldNotEmpty(phoneTextField.getText(), phoneLabel, "Student's Contact No Required!");
DataValidation.ImageFieldNotEmpty(photoImageView, photoLabel, "Select a Image");
}
if (!(DataValidation.isValidMaximumLength(nameTextField.getText(), 45)
&& DataValidation.isValidMaximumLength(addressTextField.getText(), 400))) {
DataValidation.isValidMaximumLength(nameTextField.getText(), 45, nameLabel, "Field Limit 45 Exceeded!");
DataValidation.isValidMaximumLength(addressTextField.getText(), 400, addressLabel, "Field Limit 400 Exceeded!");
}
if (!(DataValidation.isValidNIC(nicTextField)
&& DataValidation.isValidPhoneNo(phoneTextField.getText()))) {
DataValidation.isValidNIC(nicTextField, nicLabel, "Invalid NIC Number!!");
DataValidation.isValidPhoneNo(phoneTextField.getText(), phoneLabel, "Invalid Phone Number!!");
}
if (!UtilityMethod.checkDataAvailability(studentList, nicTextField.getText().toLowerCase())) {
checkStudentNICAvailability();
}
}
@FXML
private void checkStudentNICAvailability() {
ObservableList<Student> modelList = studentTable.getItems();
ArrayList<String> studentList = new ArrayList<>();
for (Student student : modelList) {
studentList.add(student.getsNIC().toLowerCase());
}
if (nicTextField.getText().isEmpty()) {
nicLabel.setStyle("-fx-text-fill: #ff0000 ");
nicLabel.setText("NIC Cannot be empty");
} else if (UtilityMethod.checkDataAvailability(studentList, nicTextField.getText().toLowerCase()) && DataValidation.isValidNIC(nicTextField)) {
nicLabel.setStyle("-fx-text-fill: #ff0000 ");
nicLabel.setText("Student with NIC Already exist!!");
} else {
if (DataValidation.isValidNIC(nicTextField)) {
nicLabel.setStyle("-fx-text-fill: #00B605 ");
nicLabel.setText("NIC Available");
} else {
nicLabel.setStyle("-fx-text-fill: #ff0000 ");
nicLabel.setText("Invalid NIC Address!!");
}
}
}
private void resetComponents() {
addButton.setVisible(true);
updateButton.setVisible(false);
nicTextField.setEditable(true);
}
@FXML
private void chooseImage(ActionEvent event){
photoLabel.setText("");
FileChooser fileChooser = new FileChooser();
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Image Files","*.jpg"));
File file = fileChooser.showOpenDialog(null);
if(file != null){
staticFile = file;
Image image = new Image(file.toURI().toString());
photoImageView.setImage(image);
}
}
}
| [
"[email protected]"
]
| |
1e4249fa81d3be0600d4bf904f44f895b4d450de | ad5dca70e657e9cf8747a80e035eff59aa559f0e | /src/main/java/bootsamples/controller/SeanceController.java | a8081d12f59a768af8bfcf76f286b8bef6a43792 | []
| no_license | Andrei86/greatTheater | 2efdbb29a0583bde1bc692f506c4713d1c06673c | 28d1e59d22847ceaac07cb469b85ecf7ba5ea0ee | refs/heads/master | 2021-04-30T05:55:27.622495 | 2018-03-15T20:43:47 | 2018-03-15T20:43:47 | 121,430,474 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 6,348 | java | package bootsamples.controller;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import bootsamples.model.Seance;
import bootsamples.service.CinemaService;
import bootsamples.service.MovieService;
import bootsamples.service.SeanceService;
import bootsamples.dto.SeanceDTO;
import bootsamples.exceptions.dateException.MyDateFormatException;
import bootsamples.exceptions.notFound.MyResourceNotFoundException;
@RestController
@RequestMapping("/seances")
public class SeanceController {
@Autowired
SeanceService seanceService;
@Autowired
CinemaService cinemaService;
@Autowired
MovieService movieService;
private DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
private DateFormat df2 = new SimpleDateFormat("dd-MM-yyyy HH:mm");
private Pattern patt = Pattern.compile("\\d{2}-\\d{2}-\\d{4}");
private Pattern patt2 = Pattern.compile("\\d{2}-\\d{2}-\\d{4} \\d{2}:\\d{2}");
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<?> getSeanceBy(@RequestParam(required=false) String movieTitle,
@RequestParam(required=false) String cinemaName, @RequestParam(required=false) String date){ // переименовать метод
// все-таки можно сделать seanceFilter, но надо разобраться как это сделать в spring boot
System.out.println(date);
Date utilDate = null; // date for query
List<Seance> seances = null;
List<SeanceDTO> seanceDTO = new ArrayList<SeanceDTO>();
if(date == null)
utilDate = new Date();
else{
try
{
if(!(patt.matcher(date).matches()))
throw new MyDateFormatException("Please, insert date in format dd-mm-yyyy");
System.out.println(date);
utilDate = df.parse(date);
}
catch(Exception e){}
}
if(movieTitle != null)
seances = seanceService.findSeanceByMovieDate(movieTitle, utilDate);
// можно сдесь написать сообщение о неправильном названии фильма?
else if(cinemaName != null)
seances = seanceService.findSeanceByCinemaDate(cinemaName, utilDate);
// можно сдесь написать сообщение о неправильном названии кинотеатра?
else
seances = seanceService.findSeanceByDate(utilDate);
if (seances.isEmpty()) {
throw new MyResourceNotFoundException("seances not found");
}
for(Seance seance : seances)
{
seanceDTO.add(entity2dto(seance));
}
return new ResponseEntity<List<SeanceDTO>>(seanceDTO, HttpStatus.OK);
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public ResponseEntity<?> getSeanceById(@PathVariable("id") Integer id)
{
Seance seance = seanceService.findSeanceById(id);
SeanceDTO seanceDTO = entity2dto(seance);
return new ResponseEntity<SeanceDTO>(seanceDTO, HttpStatus.OK);
}
@RequestMapping(value = "/{id}",method = RequestMethod.DELETE)
public ResponseEntity<?> deleteSeanceById(@PathVariable("id") Integer id){
seanceService.deleteSeanceById(id);
return new ResponseEntity<Seance>(HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<?> createSeance(@Valid @RequestBody SeanceDTO seanceDTO){
if (!patt2.matcher(seanceDTO.getDate()).matches())
throw new MyDateFormatException("Please, insert seance date in format \"dd-mm-yyyy hh:mm\"");
Seance seance = dto2entity(seanceDTO);
seanceService.createSeance(seance);
return new ResponseEntity<Integer>(seance.getId(), HttpStatus.CREATED);
}
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public ResponseEntity<?> updateSeance(@PathVariable("id") Integer id, @RequestBody SeanceDTO seanceDTO){
// плохо гонять туда-сюда entity2 dto and dto2entity и ОТРЕФАКТОРИТЬ
Seance seanceDB = seanceService.findSeanceById(id);
SeanceDTO seanceDBDTO = entity2dto(seanceDB);
Boolean boolDate = false;
if(seanceDTO.getDate() != null && patt2.matcher(seanceDTO.getDate()).matches())
boolDate = true;//patt2.matcher(seanceDTO.getDate()).matches();
else
throw new MyDateFormatException("Please, insert seance date in format \"dd-mm-yyyy hh:mm\"");
seanceDBDTO.setCinemaName(
seanceDTO.getCinemaName() != null ? seanceDTO.getCinemaName() : seanceDBDTO.getCinemaName());
seanceDBDTO.setMovieTitle(
seanceDTO.getMovieTitle() != null ? seanceDTO.getMovieTitle() : seanceDBDTO.getMovieTitle());
seanceDBDTO.setDate(boolDate ? seanceDTO.getDate() : seanceDBDTO.getDate());
Seance seanceNew = dto2entity(seanceDBDTO);
seanceService.updateSeance(seanceNew);
return new ResponseEntity<SeanceDTO>(seanceDBDTO, HttpStatus.OK);
}
private Seance dto2entity(SeanceDTO seanceDTO) {
String dateString = null;
Seance seance = new Seance();
if (seanceDTO.getId() != null)
seance.setId(seanceDTO.getId());
seance.setCinema(cinemaService.findCinemaByName(seanceDTO.getCinemaName())); // findByName cinema add method
seance.setMovie(movieService.findMovieByTitle(seanceDTO.getMovieTitle()));
try {
dateString = seanceDTO.getDate();
seance.setDate(df2.parse(dateString));
} catch (Exception e) {
}
return seance;
}
private SeanceDTO entity2dto(Seance seance) {
String dateString = null;
SeanceDTO seanceDTO = new SeanceDTO();
seanceDTO.setId(seance.getId());
seanceDTO.setCinemaName(seance.getCinema().getName());
seanceDTO.setMovieTitle(seance.getMovie().getTitle());
dateString = df2/*df*/.format(seance.getDate());
seanceDTO.setDate(dateString);
//seanceDTO.setTime(dateString.substring(11));
return seanceDTO;
}
}
| [
"[email protected]"
]
| |
56f36f9def3caf3cda0a0d4aa77cbf994b5a569b | 9e11e06ad42033593a5f00e4c67cc46c0e09319f | /app/src/main/java/com/ankrish/firebaseauthentication/LoginActivity.java | 267a20b0e3fe72f0cb08aba0db4b84b9ffa89bfc | []
| no_license | ankrishx96/FirebaseAuthentication | 20098161ffe6069445239bf61707bd43f86fec85 | e292bc13c3f878442f700d6a5c8720c9beaab09b | refs/heads/master | 2021-09-08T14:29:04.438235 | 2017-10-02T18:10:25 | 2017-10-02T18:10:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,384 | java | package com.ankrish.firebaseauthentication;
import android.app.ProgressDialog;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
public class LoginActivity extends AppCompatActivity {
private EditText login_email,login_password;
private Button login;
private TextView signup;
private ProgressDialog pd;
private FirebaseAuth auth;
FirebaseUser user;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
login_email= (EditText) findViewById(R.id.login_email);
login_password= (EditText) findViewById(R.id.login_password);
login= (Button) findViewById(R.id.login);
signup= (TextView) findViewById(R.id.signup);
pd=new ProgressDialog(this);
auth = FirebaseAuth.getInstance();
if(auth.getCurrentUser()!=null)
{
startActivity(new Intent(LoginActivity.this,ProfileActivity.class));
finish();
}
signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
startActivity(new Intent(LoginActivity.this,MainActivity.class));
}
});
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email=login_email.getText().toString().trim();
String password=login_password.getText().toString().trim();
if(TextUtils.isEmpty(email))
{
Toast.makeText(LoginActivity.this,"Please Enter Email Id",Toast.LENGTH_SHORT).show();
return;
}
if(TextUtils.isEmpty(password))
{
Toast.makeText(LoginActivity.this,"Please Enter Password",Toast.LENGTH_SHORT).show();
return;
}
pd.setMessage("Log In");
pd.show();
auth.signInWithEmailAndPassword(email,password).addOnCompleteListener(LoginActivity.this,new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
pd.dismiss();
if(task.isSuccessful())
{
finish();
startActivity(new Intent(LoginActivity.this,ProfileActivity.class));
}
else
{
pd.dismiss();
Toast.makeText(LoginActivity.this,"Wrong Email/ Password",Toast.LENGTH_SHORT).show();
}
}
});
}
});
}
}
| [
"[email protected]"
]
| |
2dbcc409325e387268e5e1fa4c372f2da8e032cd | f24cb1e30ab8be1cedd72a00f6ac0a0ac297f316 | /amanager/src/com/example/timeselect/OnWheelScrollListener.java | fe4140e814f3c5af2f5a2b678d36c4ce61a2d78c | []
| no_license | xueyuleiT/-app | b3ce8a73c41600e234b0e7e5e038ca741cfaed20 | 5f0f69ef46b1abe0e52aa57bb4041561f5d44620 | refs/heads/master | 2020-04-08T06:25:25.325204 | 2018-11-26T02:05:21 | 2018-11-26T02:05:21 | 159,096,019 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,063 | java | /*
* Copyright 2010 Yuri Kanivets
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.timeselect;
/**
* Wheel scrolled listener interface.
*/
public interface OnWheelScrollListener {
/**
* Callback method to be invoked when scrolling started.
* @param wheel the wheel view whose state has changed.
*/
void onScrollingStarted(WheelView wheel);
/**
* Callback method to be invoked when scrolling ended.
* @param wheel the wheel view whose state has changed.
*/
void onScrollingFinished(WheelView wheel);
}
| [
"[email protected]"
]
| |
53eaf892a5439394643d37459beb58aed582377f | 538fdc05f38193aa53f597ed3a4d66b5b1e67c6f | /gfs-mobile-client/app/src/main/java/com/example/hackyeah2019/ui/home/HomeFragment.java | 7c478a11999ed5d66752bc8177d69545e3cd9608 | []
| no_license | MichalSzewczyk/hackyeah-GFS | d20e024fbd7d04045937013888e765fb6f188815 | f39f52be2736be05a9d71e6e39a250c85b5025e0 | refs/heads/master | 2022-12-21T13:21:15.589506 | 2019-09-15T09:11:31 | 2019-09-15T09:11:31 | 208,565,928 | 1 | 0 | null | 2022-12-10T05:44:59 | 2019-09-15T08:46:18 | Java | UTF-8 | Java | false | false | 1,525 | java | package com.example.hackyeah2019.ui.home;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProviders;
import com.example.hackyeah2019.R;
import com.google.zxing.integration.android.IntentIntegrator;
public class HomeFragment extends Fragment {
private HomeViewModel homeViewModel;
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
homeViewModel = ViewModelProviders.of(this).get(HomeViewModel.class);
View root = inflater.inflate(R.layout.fragment_home, container, false);
// final TextView textView = root.findViewById(R.id.text_home);
// homeViewModel.getText().observe(this, s -> textView.setText(s));
Button button = root.findViewById(R.id.scanButton);
final Activity activity = this.getActivity();
button.setOnClickListener(v -> {
IntentIntegrator integrator = new IntentIntegrator(activity);
integrator.setDesiredBarcodeFormats(IntentIntegrator.ALL_CODE_TYPES);
integrator.setPrompt("Scan");
integrator.setCameraId(0);
integrator.setBeepEnabled(false);
integrator.setBarcodeImageEnabled(false);
integrator.initiateScan();
});
return root;
}
}
| [
"[email protected]"
]
| |
c1fd263c97fe22c4861581cec5309b6c8dc01792 | 07f56fd503327d43a3745d80a2eb71b87038751c | /src/test/java/com/example/rublerateapp/TestingOfRateChangingBetweenTwoDates.java | 0d4a40ff288e5543aa37cc242681a5998d374d9f | []
| no_license | novikevichd/springboot-ruble-rate-app | 9d439138669cd46288dbb16acbd5657ea65b525b | 9fbaac735b88e230f181f8905a00aac9e02dbe42 | refs/heads/master | 2023-02-14T00:53:18.138495 | 2021-01-06T06:32:02 | 2021-01-06T06:32:02 | 327,220,969 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,466 | java | package com.example.rublerateapp;
import com.example.rublerateapp.rate.Rate;
import com.example.rublerateapp.rate.RateChangingBetweenTwoDates;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.json.JacksonTester;
// Тесты для проверки класса который высчитывает разницу курса выбранной валюты к Рублю
// При работе сервиса высчитывается разница курса сегодня и вчера,
// в тестах между 1 и 20 декабря 2020 из Json файлов сохраненных локально test/resources
public class TestingOfRateChangingBetweenTwoDates {
private JacksonTester<Rate> jacksonTester;
@Test
public void firstRateTest() throws Exception {
ObjectMapper objectMapper = new ObjectMapper();
JacksonTester.initFields(this, objectMapper);
Rate rateOfFirstDecember = this.jacksonTester.read("/01-12-2020.json").getObject();
Rate rateOfTwentyNineDecember = this.jacksonTester.read("/29-12-2020.json").getObject();
RateChangingBetweenTwoDates rateChanging =
new RateChangingBetweenTwoDates(rateOfTwentyNineDecember, rateOfFirstDecember);
// Для расчета разницы к рублю выбираем доллар США(код валюты "USD")
float answerUSD = rateChanging.calculateChangeOfRating("USD");
// 29.12 - Курс к доллару 74.0564,
// 01.12 - Курс к доллару 75.9935
// Курс даллара к рублю стал меньше, соответственно метод высчитывающий разницу курсов
// должен вернуть значение больше нуля
Assertions.assertTrue(answerUSD > 0);
// Для расчета разницы к рублю выбираем биткоин("BTC")
float answerBTC = rateChanging.calculateChangeOfRating("BTC");
// Курс биткоина на последний месяц значительно вырос, соответственно метод высчитывающий разницу курсов
// должен вернуть значение меньше нуля
Assertions.assertTrue(answerBTC < 0);
}
}
| [
"[email protected]"
]
| |
ff078ac5a1646923a9ebf39e22847b8f0f5149e7 | 723cf05f2d3a95bbf8e9a5e736fcda2af36363cf | /app/src/androidTest/java/com/example/ds/homeproject/ExampleInstrumentedTest.java | b292ca964912cf2664709dca4c08b43458baecae | []
| no_license | 6v6/mi_in | baa4a2ef3a67ec92d118aab969ba802d5b6dca38 | 0de6988cd3dfb3561310a2b8377b9ceef36b3c85 | refs/heads/master | 2021-06-04T16:29:59.978472 | 2020-03-02T07:01:23 | 2020-03-02T07:01:23 | 135,699,367 | 0 | 2 | null | 2020-03-02T07:01:24 | 2018-06-01T09:41:23 | Java | UTF-8 | Java | false | false | 753 | java | package com.example.ds.homeproject;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.ds.homeproject", appContext.getPackageName());
}
}
| [
"[email protected]"
]
| |
0cc9ddbe907938527c83d8a3341ba2d2a7a704a5 | aef0d8b6f871cc5ef375c2cdd6c9f13fa5f291e0 | /exercises/java/Puzzles.java | f24576e05357442974dcaba02a8524f99a8ebdb8 | []
| no_license | kamarulaw/competitive-programming | e2b95dd74883f8ae80f6b0b0c2e1d40a024f10d1 | 2f36fa6e5a7e04cb10ec0eabbc7b0bd400e7c268 | refs/heads/master | 2023-09-03T15:18:15.661776 | 2023-08-28T21:57:00 | 2023-08-28T21:57:00 | 162,459,171 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,785 | java | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.StringTokenizer;
import java.util.Arrays;
public class Puzzles {
public void solve() throws IOException {
int n = ni();
int m = ni();
int INF = Integer.MAX_VALUE;
int[] f = new int[m + 1];
int[] memo = new int[m - n + 2];
for (int i = 1; i <= m; i++)
f[i] = ni();
Arrays.sort(f);
Arrays.fill(memo, INF);
for (int i = 1; i <= m - n + 1; i++) {
for (int j = i + n - 1; j <= m; j++) {
memo[i] = Math.min(f[j] - f[i], memo[i]);
}
}
int ans = INF;
for (int i = 1; i <= m - n + 1; i++) //unnecessary for loop
ans = Math.min(ans, memo[i]);
System.out.println(ans);
}
public BufferedReader br;
public StringTokenizer st;
public PrintWriter out;
public String nextToken() throws IOException {
while(st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public String nextLine() throws IOException {
return br.readLine();
}
public int ni() throws IOException {
return Integer.parseInt(nextToken());
}
public long nl() throws IOException {
return Long.parseLong(nextToken());
}
public double nd() throws IOException {
return Double.parseDouble(nextToken());
}
public void run() throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(new OutputStreamWriter(System.out));
solve();
}
public static void main(String args[]) throws IOException {
new Puzzles().run();
}
}
| [
"[email protected]"
]
| |
856ae777d813f04083b3153595114a1b813877e1 | 71f2fbd214a56cbbb9c927b4deb5b6a415d31e50 | /jdk/src/main/java/multithread/synchronizedDemo/LockObjectTest.java | c291f7bb703a38379b519ddbcd4961b121524bc0 | []
| no_license | lanourain/java-demo | ee54ed517031b201a6b9eb5c05118d8cf41e1add | 09faf728fe20ff9b5447a44a4c801c9a116f8c8e | refs/heads/master | 2022-12-20T21:46:20.964494 | 2021-04-10T15:33:03 | 2021-04-10T15:33:03 | 100,092,862 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,158 | java | package multithread.synchronizedDemo;
import org.junit.Test;
public class LockObjectTest {
@Test
public void test_1() throws InterruptedException {
Account account = new Account("zhang san", 10000.0f);
AccountOperator accountOperator = new AccountOperator(account);
AccountPrint accountPrint = new AccountPrint(account);
new Thread(accountPrint, "Thread_print").start();
for (int i = 0; i < 5; i++) {
new Thread(accountOperator, "Thread" + i).start();
}
Thread.sleep(20000);
}
/**
* 银行账户类
*/
class Account {
String name;
float amount;
public Account(String name, float amount) {
this.name = name;
this.amount = amount;
}
//存钱
public void deposit(float amt) {
amount += amt;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
//取钱
public void withdraw(float amt) {
amount -= amt;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public float getBalance() {
return amount;
}
}
/**
* 账户操作类
*/
class AccountOperator implements Runnable {
private Account account;
public AccountOperator(Account account) {
this.account = account;
}
public void run() {
// 对一个对象加锁,表示当前线程获取该对象的锁,别的线程访问会受阻
/**
* 当一个线程访问account对象时,其他试图访问account对象的线程将会阻塞,
* 直到该线程访问account对象结束。也就是说谁拿到那个锁谁就可以运行它所控制的那段代码。
*/
synchronized (account) {
//while (true) {
for (int i = 0; i < 10; i++) {
account.deposit(500);
System.out
.println(Thread.currentThread().getName() + ":" + account.getBalance());
account.withdraw(500);
System.out
.println(Thread.currentThread().getName() + ":" + account.getBalance());
}
}
}
}
/**
* 账户打印类
*/
class AccountPrint implements Runnable {
private Account account;
public AccountPrint(Account account) {
this.account = account;
}
public void run() {
while (true) {
// 这边的访问相当于访问非synchronized区域,可以和上述的并发访问,不会被上面的阻塞
float balance = account.getBalance();
if (balance != 10000.0f) {
System.out.println(Thread.currentThread().getName() + ":" + balance);
}
}
}
}
}
| [
"[email protected]"
]
| |
e05db1245304844f21e6d61ff64a94ab4f585b46 | 36189dce655c7f550e0c50d214a6c5132669e813 | /keyboardlibrary/src/main/java/cn/qingsong/car/keyboardlibrary/neighbor/NeighborManager.java | 87559d1ea93766a1b21934da11287382cfd72fea | [
"Apache-2.0"
]
| permissive | qingsong-xu/licencePlateKeyboard | 01ade6634634729f8150272c6c5fd8545993572b | f2515e7549463895f2b7b644d48dfa62135661a1 | refs/heads/master | 2023-06-27T06:13:15.514263 | 2021-08-02T09:52:30 | 2021-08-02T09:52:30 | 386,243,686 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 6,075 | java | package cn.qingsong.car.keyboardlibrary.neighbor;
import android.text.TextUtils;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* @author 陈哈哈 ([email protected])
*/
public class NeighborManager {
private final Set<Province> mProvinces = new HashSet<>(32);
public NeighborManager() {
final Province beijing = new Province("北京市", "京");
final Province tianjin = new Province("天津市", "津");
final Province shanxi = new Province("山西省", "晋");
final Province hebei = new Province("河北省", "冀");
final Province neimenggu = new Province("内蒙古自治区", "蒙");
final Province liaoning = new Province("辽宁省", "辽");
final Province jilin = new Province("吉林省", "吉");
final Province heilongjiang = new Province("黑龙江省", "黑");
final Province shanghai = new Province("上海市", "沪");
final Province jiangsu = new Province("江苏省", "苏");
final Province zhejiang = new Province("浙江省", "浙");
final Province anhui = new Province("安徽省", "皖");
final Province fujian = new Province("福建省", "闽");
final Province jiangxi = new Province("江西省", "赣");
final Province shandong = new Province("山东省", "鲁");
final Province henan = new Province("河南省", "豫");
final Province hubei = new Province("湖北省", "鄂");
final Province hunan = new Province("湖南省", "湘");
final Province guangdong = new Province("广东省", "粤");
final Province guangxi = new Province("广西壮族自治区", "桂");
final Province hainan = new Province("海南省", "琼");
final Province chongqing = new Province("重庆市", "渝");
final Province sichuan = new Province("四川省", "川");
final Province guizhou = new Province("贵州省", "贵");
final Province yunnan = new Province("云南省", "云");
final Province xizang = new Province("西藏自治区", "藏");
final Province shannxi = new Province("陕西省", "陕");
final Province gansu = new Province("甘肃省", "甘");
final Province qinghai = new Province("青海省", "青");
final Province ningxia = new Province("宁夏回族自治区", "宁");
final Province xinjiang = new Province("新疆维吾尔自治区", "新");
final Province taiwan = new Province("台湾省", "台");
xinjiang.link(xizang)
.link(qinghai)
.link(gansu)
.link(neimenggu);
xizang.link(qinghai)
.link(sichuan)
.link(yunnan);
qinghai.link(gansu)
.link(sichuan)
.link(shanxi);
gansu.link(neimenggu)
.link(shannxi)
.link(sichuan)
.link(chongqing)
.link(ningxia);
ningxia.link(shannxi)
.link(gansu);
neimenggu.link(heilongjiang)
.link(jilin)
.link(liaoning)
.link(hebei)
.link(beijing)
.link(tianjin)
.link(shanxi)
.link(shannxi)
.link(ningxia);
shannxi.link(shanxi)
.link(henan)
.link(hubei)
.link(chongqing)
.link(sichuan);
sichuan.link(yunnan)
.link(guizhou)
.link(chongqing);
yunnan.link(guizhou)
.link(guangxi);
guizhou.link(hunan)
.link(guangxi)
.link(chongqing)
.link(hubei);
chongqing.link(hubei)
.link(hunan);
hubei.link(hunan)
.link(henan)
.link(anhui)
.link(jiangxi);
hunan.link(jiangxi)
.link(guangxi)
.link(guangdong);
guangxi.link(guangdong)
.link(hainan);
guangdong.link(hainan)
.link(fujian)
.link(jiangxi);
jiangxi.link(fujian)
.link(anhui)
.link(zhejiang);
fujian.link(zhejiang);
//fujian.link(taiwan);
zhejiang.link(shanghai)
.link(anhui)
.link(jiangsu);
anhui.link(jiangsu)
.link(shanghai)
.link(shandong);
jiangsu.link(shandong)
.link(shanghai);
shandong.link(hebei)
.link(beijing)
.link(tianjin);
shanxi.link(hebei)
.link(henan);
hebei.link(beijing)
.link(tianjin)
.link(shandong)
.link(liaoning);
beijing.link(tianjin)
.link(liaoning)
.link(shandong);
liaoning.link(jilin);
jilin.link(liaoning)
.link(heilongjiang);
this.bind(beijing, tianjin, shanxi, hebei, neimenggu, liaoning, jilin, heilongjiang, shanghai,
jiangsu, zhejiang, anhui, fujian, jiangxi, shandong, henan, hubei, hunan, guangdong,
guangxi, hainan, chongqing, sichuan, guizhou, yunnan, xizang, shannxi, gansu, qinghai,
ningxia, xinjiang);
}
/**
* 获取省份名称对应的省份对象
*
* @param provinceName 省分名称
* @return Province
*/
public Province getLocation(String provinceName) {
if (TextUtils.isEmpty(provinceName)) {
return new Province("", "");
}
provinceName = provinceName.replace("省", "");
for (Province p : mProvinces) {
if (p.name.contains(provinceName)) {
return p;
}
}
return new Province("", "");
}
private void bind(Province... provinces) {
this.mProvinces.addAll(Arrays.asList(provinces));
}
}
| [
"[email protected]"
]
| |
7a7620f759e49ddc77b5afaf7b50e328fb762f52 | d8cc81a1a34b4004974f6f9cf5e47023f25f2409 | /src/main/java/com/example/ecomarket/domain/User.java | 64a756205e33892f30cb5fd0101152dba4577468 | []
| no_license | FoPQer/EkoMarket | 5e2127456359c3b4e4a7816857f5962c6a1028ad | ebf4f29e7afb235a842b3e1ede7deed0d6740902 | refs/heads/master | 2023-08-14T18:46:25.419288 | 2021-10-17T17:27:52 | 2021-10-17T17:27:52 | 372,596,801 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,651 | java | package com.example.ecomarket.domain;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
@Entity
@Table(name = "usrs")
public class User implements UserDetails {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String username;
private String password;
private String name;
private String lastName;
private String birthDay;
private final boolean active;
@ManyToMany(fetch = FetchType.EAGER)
private List<Product> products;
@ElementCollection(targetClass = Role.class, fetch = FetchType.EAGER)
@CollectionTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id"))
@Enumerated(EnumType.STRING)
private Set<Role> roles;
public User(){
this.setProducts(new ArrayList<>());
this.active = true;
}
public List<Product> getProducts() {
return products;
}
public void setProducts(List<Product> products) {
this.products = products;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUsername() {
return username;
}
@Override
public boolean isAccountNonExpired() {
return false;
}
@Override
public boolean isAccountNonLocked() {
return false;
}
@Override
public boolean isCredentialsNonExpired() {
return false;
}
@Override
public boolean isEnabled() {
return true;
}
public void setUsername(String username) {
this.username = username;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return getRoles();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getBirthDay() {
return birthDay;
}
public void setBirthDay(String birthDay) {
this.birthDay = birthDay;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Set<Role> getRoles() {
return roles;
}
public void setRoles(Set<Role> roles) {
this.roles = roles;
}
}
| [
"[email protected]"
]
| |
0488017623fde997dca32a1a8ad6cb93766e3b23 | 74f5e4c91378d63523093455d82c9f346fc3b6d3 | /src/main/java/com/naman/oj/dto/ResponseDto.java | 9dd42d0ee062ee4d133b5c9ed5fbfa515f52c046 | []
| no_license | namansahni/user-service | ceb9183bef2a9014b1e37a1fa78c7d5b9bdcea1a | 9dd3ddbbbb580ba51846634fca037261dd658a3b | refs/heads/master | 2022-11-22T06:29:40.959804 | 2020-07-25T18:04:15 | 2020-07-25T18:04:15 | 282,498,805 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 333 | java | package com.naman.oj.dto;
import lombok.Getter;
import lombok.Setter;
import org.springframework.http.HttpStatus;
@Getter
@Setter
public class ResponseDto<T> {
private T data;
private HttpStatus status;
public ResponseDto(HttpStatus status, T data) {
this.data = data;
this.status = status;
}
}
| [
"[email protected]"
]
| |
1acb9e979dd9df5d06787c68f69147abfabaf214 | 7686922c6a47c87910cc8926442a0f2bf70a2753 | /src/com/sssp/controller/HelloSSSP.java | a47952104e026e66cd8eb5a5efd1ba3172055ef0 | []
| no_license | RickUniverse/SSSP | e1cd0ba41f69e8b34385a1b54850d07b6b351889 | 6e4488d32b19698cf32b3a9d1a9fc187f9658c0c | refs/heads/master | 2023-02-06T09:45:57.449309 | 2020-12-29T15:36:59 | 2020-12-29T15:36:59 | 325,322,498 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,009 | java | package com.sssp.controller;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.sql.DataSource;
import java.sql.SQLException;
/**
* @author lijichen
* @date 2020/12/2 - 21:54
*/
@Controller
public class HelloSSSP implements ApplicationContextAware {
private ApplicationContext applicationContext;
@ResponseBody
@RequestMapping("/hello")
public String hello() throws SQLException {
DataSource bean = applicationContext.getBean(DataSource.class);
return bean.getConnection().toString();
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}
| [
"[email protected]"
]
| |
d2f51d86ac00ce1a3a1634dfbddb801aab988770 | b38d85b36d0216324c3d5cfae61dd823236d7da7 | /src/main/java/com/shkj/bean/ResponseBean.java | bf985193163af2224ba3402947f829c9e54a6919 | []
| no_license | wanwansys/DailyCollectionWeb | 715c6664729731a427840d55f1092c211c255bd3 | 08afa89ca5a9d4e099993bb4e441e396e38fc109 | refs/heads/master | 2022-12-27T05:57:37.079490 | 2020-09-20T14:48:28 | 2020-09-20T14:48:28 | 294,675,159 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 749 | java | package com.shkj.bean;
public class ResponseBean {
private String retCode;
private String message;
private String result;
public ResponseBean(String retCode, String message, String result) {
this.retCode = retCode;
this.message = message;
this.result = result;
}
public String getRetCode() {
return retCode;
}
public void setRetCode(String retCode) {
this.retCode = retCode;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
}
| [
"[email protected]"
]
| |
e53f8ca9656f59bc2add611ced333c10808c1360 | 49ffd34522af7e0beea2a7a0a23daea4211c59fc | /src/main/java/com/yundao/workflow/auto/all/CreateModel.java | 237f30ba2f1de1a6e44713dc0778001ea4aea178 | []
| no_license | wucaiqiang/yundao-workflow | a77b108ef455927b0bfa10cf3307f42d76614adb | fe78efee08b5b5139ec9b5327fa84d9d77407ce6 | refs/heads/master | 2021-08-30T20:51:41.556451 | 2017-12-19T11:38:31 | 2017-12-19T11:38:31 | 114,626,840 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,649 | java | package com.yundao.workflow.auto.all;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* MyBatis模板代码生成工具model生成类
* @author
* 创建时间:2012-07-03
*/
public class CreateModel {
public List<String> colClassList;//类中字段名--类型
public String className;//类名
public String classPackageName;//类所在包名
public String parentPackageName;//上层类名
public String pk = "";//主键名
public String dbpk = "";//数据库中主键名
static List<String> continiuStr = new ArrayList<String>();
static {
continiuStr.add("createUserId");
continiuStr.add("createDate");
continiuStr.add("updateUserId");
continiuStr.add("updateDate");
continiuStr.add("isEnabled");
continiuStr.add("isDelete");
}
public CreateModel(List<String> colClassList,String className,String classPackageName,String parentPackageName,String pk,String dbpk) {
this.colClassList = colClassList;
this.className = className;
this.classPackageName = classPackageName;
this.parentPackageName = parentPackageName;
this.pk = pk;
this.dbpk = dbpk;
}
/**
* 创建实体类
* @param util
* @throws Exception
*/
public void createModelJava(Util util) throws Exception{
List<String> fileStrList = new ArrayList<String>();
fileStrList.add("");
fileStrList.add("package "+classPackageName+".dto."+className.toLowerCase()+";");
fileStrList.add("");
fileStrList.add("import java.util.Date;");
fileStrList.add("import com.yundao.core.code.config.CommonCode;");
fileStrList.add("import com.yundao.core.validator.group.Update;");
fileStrList.add("import io.swagger.annotations.ApiModelProperty;");
fileStrList.add("import com.yundao.core.validator.number.Number;");
fileStrList.add("");
// fileStrList.add( "public class "+className+"Model extends AbstractModel{");
fileStrList.add( "public class "+className+"ReqDto{");
fileStrList.add(" private static final long serialVersionUID = 1L;");
Map<String,String> columnComment = util.getColumnComment();
//获取字段说明
for (String s:colClassList) {
String[] ss = s.split("--");
if(continiuStr.indexOf(ss[0]) > -1){
continue;
}
// if(columnComment.containsKey(ss[0])){
// fileStrList.add(" /**");
// fileStrList.add(" * " + columnComment.get(ss[0]));
// fileStrList.add(" */");
// }
if("id".equals(ss[0])){
fileStrList.add(" @ApiModelProperty(value = \"新增不需要传\")");
fileStrList.add(" @Number(isBlank = false, message = \"{\" + CommonCode.COMMON_1079+ \"}\", groups = {Update.class})");
}else {
fileStrList.add(" @ApiModelProperty(value = \""+columnComment.get(ss[0])+"\")");
}
if(ss[1].equalsIgnoreCase("long")){
fileStrList.add(" private Long "+ss[0]+";");
}else if(ss[1].equalsIgnoreCase("integer")){
fileStrList.add(" private Integer "+ss[0]+";");
}else if(ss[1].equalsIgnoreCase("short")){
fileStrList.add(" private Short "+ss[0]+";");
}else if(ss[1].equalsIgnoreCase("double")){
fileStrList.add(" private Double "+ss[0]+";");
}else if(ss[1].equalsIgnoreCase("byte")){
fileStrList.add(" private Byte "+ss[0]+";");
}else if(ss[1].equalsIgnoreCase("byte[]")){
fileStrList.add(" private Byte[] "+ss[0]+";");
}else if(ss[1].equalsIgnoreCase("Date")){
fileStrList.add(" private Date "+ss[0]+";");
}else{
// fileStrList.add(" @Length(min = 1,max = 32,message = \"{\" + + \"}\"))");
fileStrList.add(" private String "+ss[0]+";");
}
fileStrList.add("");
}
fileStrList.add("");
//get,set方法
for (String s:colClassList) {
String[] ss = s.split("--");
if(continiuStr.indexOf(ss[0]) > -1){
continue;
}
if(ss[1].equalsIgnoreCase("long")){
fileStrList.add(" public Long get"+util.formatStr(ss[0])+" (){");
fileStrList.add(" return "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
fileStrList.add(" public void set"+util.formatStr(ss[0])+" (Long "+ss[0]+"){");
fileStrList.add(" this."+ss[0]+" = "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
}else if(ss[1].equalsIgnoreCase("integer")){
fileStrList.add(" public Integer get"+util.formatStr(ss[0])+" (){");
fileStrList.add(" return "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
fileStrList.add(" public void set"+util.formatStr(ss[0])+" (Integer "+ss[0]+"){");
fileStrList.add(" this."+ss[0]+" = "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
}else if(ss[1].equalsIgnoreCase("short")){
fileStrList.add(" public Short get"+util.formatStr(ss[0])+" (){");
fileStrList.add(" return "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
fileStrList.add(" public void set"+util.formatStr(ss[0])+" (Short "+ss[0]+"){");
fileStrList.add(" this."+ss[0]+" = "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
}else if(ss[1].equalsIgnoreCase("double")){
fileStrList.add(" public Double get"+util.formatStr(ss[0])+" (){");
fileStrList.add(" return "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
fileStrList.add(" public void set"+util.formatStr(ss[0])+" (Double "+ss[0]+"){");
fileStrList.add(" this."+ss[0]+" = "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
}else if(ss[1].equalsIgnoreCase("byte")){
fileStrList.add(" public Byte get"+util.formatStr(ss[0])+" (){");
fileStrList.add(" return "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
fileStrList.add(" public void set"+util.formatStr(ss[0])+" (Byte "+ss[0]+"){");
fileStrList.add(" this."+ss[0]+" = "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
}else if(ss[1].equalsIgnoreCase("Byte[]")){
fileStrList.add(" public Byte[] get"+util.formatStr(ss[0])+" (){");
fileStrList.add(" return "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
fileStrList.add(" public void set"+util.formatStr(ss[0])+" (Byte[] "+ss[0]+"){");
fileStrList.add(" this."+ss[0]+" = "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
}else if(ss[1].equalsIgnoreCase("Date")){
fileStrList.add(" public Date get"+util.formatStr(ss[0])+" (){");
fileStrList.add(" return "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
fileStrList.add(" public void set"+util.formatStr(ss[0])+" (Date "+ss[0]+"){");
fileStrList.add(" this."+ss[0]+" = "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
}else{
fileStrList.add(" public String get"+util.formatStr(ss[0])+" (){");
fileStrList.add(" return "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
fileStrList.add(" public void set"+util.formatStr(ss[0])+" (String "+ss[0]+"){");
fileStrList.add(" this."+ss[0]+" = "+ss[0]+";");
fileStrList.add(" }");
fileStrList.add("");
}
}
fileStrList.add("}");
util.writeFile(fileStrList, "dto/"+util.toLower(className)+"/", className+"ReqDto.java");
}
public void createMysqlSqlmapXML(Util util) throws Exception {
String insert = "insert"+className;
String updateByPK = "update"+className+"ByPK";
String deleteByPK = "delete"+className+"ByPK";
String getByPK = "get"+className+"ByPK";
String getByCond = "get"+className+"ListByCond";
String queryPage = "queryPageInfo";
String queryCount = "queryPageCount";
String resultMap = className+"Result";
String where = className+"_Where_Clause";
String parameterType = classPackageName+".model.base." +className + "Model";
String extend = classPackageName+".mapper.base." + className + "ModelMapper.BaseResultMap";
List<String> fileStrList = new ArrayList<String>();
fileStrList.add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
fileStrList.add("<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\" >");
fileStrList.add("");
fileStrList.add("<mapper namespace=\""+classPackageName+".mapper."+util.toLower(className)+"."+className+"Mapper\">");
fileStrList.add("");
fileStrList.add(" <resultMap id=\""+resultMap+"\" type=\""+parameterType+"\" extends=\""+extend+"\"> ");
// List<String> coltablelist = util.getColtablelist();
// for (int i=0;i<colClassList.size();i++) {
// String s1 = colClassList.get(i);
// String[] ss1 = s1.split("--");
// String s2 = coltablelist.get(i);
// String[] ss2 = s2.split("--");
// fileStrList.add(" <result column=\""+ss2[0]+"\" property=\""+ss1[0]+"\" />");
// }
fileStrList.add(" </resultMap>");
// fileStrList.add("");
// //where条件
// fileStrList.add(" <sql id=\""+where+"\">");
// fileStrList.add(" is_delete != 1");
// for (int i = 0; i < colClassList.size(); i++) {
// String s1 = colClassList.get(i);
// String[] ss1 = s1.split("--");
// String s2 = coltablelist.get(i);
// String[] ss2 = s2.split("--");
// if("is_delete".equals(ss2[0]))continue;
// if(ss1[1].equalsIgnoreCase("long") || ss1[1].equalsIgnoreCase("integer") || ss1[1].equalsIgnoreCase("Date")
// || ss1[1].equalsIgnoreCase("double") || ss1[1].equalsIgnoreCase("byte") || ss1[1].equalsIgnoreCase("short")){
// fileStrList.add(" <if test=\""+ss1[0]+"!=null\">");
// }else{
// fileStrList.add(" <if test=\""+ss1[0]+"!=null and ''!="+ss1[0]+"\">");
// }
// fileStrList.add(" AND "+ss2[0]+" = #{"+ss1[0]+"}");
// fileStrList.add(" </if>");
// }
// fileStrList.add(" </sql>");
// fileStrList.add("");
//
// //insert
// if(!pk.equals("")){
// fileStrList.add(" <insert id=\""+insert+"\" parameterType=\""+parameterType+"\">");
// fileStrList.add(" insert into "+util.getTableName()+" ( "+dbpk+" ");
// for (int i = 0; i < colClassList.size(); i++) {
// String temp = colClassList.get(i);
// String[] ss1 = temp.split("--");
// String s2 = coltablelist.get(i);
// String[] ss2 = s2.split("--");
// if("is_delete".equals(ss2[0]))continue;
// if(!pk.equals(ss1[0])){
// if(ss1[1].equalsIgnoreCase("long") || ss1[1].equalsIgnoreCase("integer") || ss1[1].equalsIgnoreCase("Date")
// || ss1[1].equalsIgnoreCase("double") || ss1[1].equalsIgnoreCase("byte") || ss1[1].equalsIgnoreCase("short")){
// fileStrList.add(" <if test=\""+ss1[0]+"!=null\">");
// }else{
// fileStrList.add(" <if test=\""+ss1[0]+"!=null and ''!="+ss1[0]+"\">");
// }
// fileStrList.add(" ,"+ss2[0]);
// fileStrList.add(" </if>");
// }
// }
// fileStrList.add(" ,is_delete");
// fileStrList.add(" )values( #{"+pk+"}");
// for (int i = 0; i < colClassList.size(); i++) {
// String temp = colClassList.get(i);
// String[] ss1 = temp.split("--");
// if("isDelete".equals(ss1[0]))continue;
// if(!pk.equals(ss1[0])){
// if(ss1[1].equalsIgnoreCase("long") || ss1[1].equalsIgnoreCase("integer") || ss1[1].equalsIgnoreCase("Date")
// || ss1[1].equalsIgnoreCase("double") || ss1[1].equalsIgnoreCase("byte") || ss1[1].equalsIgnoreCase("short")){
// fileStrList.add(" <if test=\""+ss1[0]+"!=null\">");
// }else{
// fileStrList.add(" <if test=\""+ss1[0]+"!=null and ''!="+ss1[0]+"\">");
// }
// fileStrList.add(" ,#{"+ss1[0]+"}");
// fileStrList.add(" </if>");
// }
// }
// fileStrList.add(" ,0");
// fileStrList.add(" )");
// fileStrList.add(" </insert>");
// fileStrList.add("");
// }
//
// //update By pk
// if(!pk.equals("")){
// fileStrList.add(" <update id=\""+updateByPK+"\" parameterType=\""+parameterType+"\">");
// fileStrList.add(" update "+util.getTableName()+" set "+dbpk+" = #{"+pk+"}");
// for (int i = 0; i < colClassList.size(); i++) {
// String temp = colClassList.get(i);
// String[] ss1 = temp.split("--");
// String s2 = coltablelist.get(i);
// String[] ss2 = s2.split("--");
// if("is_delete".equals(ss2[0]))continue;
// if(!pk.equals(ss1[0])){
// if(ss1[1].equalsIgnoreCase("long") || ss1[1].equalsIgnoreCase("integer") || ss1[1].equalsIgnoreCase("Date")
// || ss1[1].equalsIgnoreCase("double") || ss1[1].equalsIgnoreCase("byte") || ss1[1].equalsIgnoreCase("short")){
// fileStrList.add(" <if test=\""+ss1[0]+"!=null\">");
// }else{
// fileStrList.add(" <if test=\""+ss1[0]+"!=null and ''!="+ss1[0]+"\">");
// }
// fileStrList.add(" ,"+ss2[0]+" = #{"+ss1[0]+"}");
// fileStrList.add(" </if>");
// }
// }
// fileStrList.add(" where "+dbpk+" = #{"+pk+"}");
// fileStrList.add(" </update>");
// fileStrList.add("");
// }
//
// //delete by cond
// fileStrList.add(" <update id=\""+deleteByPK+"\" parameterType=\""+parameterType+"\">");
// fileStrList.add(" update "+util.getTableName()+" set is_delete = 1");
// fileStrList.add(" where "+dbpk+" = #{"+pk+"}");
//// fileStrList.add(" <where><include refid=\""+where+"\" /></where>");
// fileStrList.add(" </update>");
// fileStrList.add("");
//
// String temp1 = "";
// for (int i = 0; i < util.getColtablelist().size(); i++) {
// temp1 += coltablelist.get(i).split("--")[0]+",";
// }
// temp1 = temp1.substring(0,temp1.length()-1);
//
// //getBy pk
// if(!pk.equals("")){
// fileStrList.add(" <select id=\""+getByPK+"\" parameterType=\""+parameterType+"\" resultMap=\""+resultMap+"\">");
// fileStrList.add(" select "+temp1+" from "+util.getTableName()+" where "+dbpk+" = #{"+pk+"} and is_delete != 1");
// fileStrList.add(" </select>");
// fileStrList.add("");
// }
//
// //getBy cond
// fileStrList.add(" <select id=\""+getByCond+"\" parameterType=\""+parameterType+"\" resultMap=\""+resultMap+"\">");
// fileStrList.add(" select "+temp1+" from "+util.getTableName());
// fileStrList.add(" <where><include refid=\""+where+"\" /></where>");
//// fileStrList.add(" <dynamic prepend=\"order by\">");
//// fileStrList.add(" <if test=\"order!=null and ''!=order\">");
//// fileStrList.add(" order by $order$");
//// fileStrList.add(" </if>");
//// fileStrList.add(" </dynamic>");
// fileStrList.add(" </select>");
// fileStrList.add("");
//
// //query page
// fileStrList.add(" <select id=\""+queryPage+"\" parameterType=\""+parameterType+"\" resultMap=\""+resultMap+"\">");
// fileStrList.add(" select "+temp1+" from "+util.getTableName());
// fileStrList.add(" <where><include refid=\""+where+"\" /></where>");
//// fileStrList.add(" <if test=\"order!=null and ''!=order\">");
//// fileStrList.add(" order by ${order}");
//// fileStrList.add(" </if>");
// fileStrList.add(" limit #{offset},#{pageSize}");
// fileStrList.add(" </select>");
// fileStrList.add("");
//
// //query count
// fileStrList.add(" <select id=\""+queryCount+"\" parameterType=\""+parameterType+"\" resultType=\"java.lang.Integer\">");
// fileStrList.add(" select count(*) from "+util.getTableName());
// fileStrList.add(" <where><include refid=\""+where+"\" /></where>");
// fileStrList.add(" </select>");
// fileStrList.add("");
fileStrList.add("</mapper>");
util.writeXmlFile(fileStrList, "config/mybatis/"+util.toLower(className)+"/", className+"Mapper.xml");
}
}
| [
"[email protected]"
]
| |
417ea9ec9e4a3fff38f5c4dbe4e91382fa3996d1 | 28c2c50d8aced8a64c5fb4a2d1e8b9a5af5fcdc3 | /0723/web0722(t)/src/guestbook/ServiceImpl.java | 93c564497a954f1d32a3ea0a6a491759a4834766 | []
| no_license | PlayWithAI101/WebNote | e6a989805000e2d51b7e7a495be03e1fd679758f | fe83524fb16690caa5181007985f5793d8bd5fc8 | refs/heads/master | 2022-12-11T23:21:41.995043 | 2020-09-08T16:51:40 | 2020-09-08T16:51:40 | 293,717,669 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 638 | java | package guestbook;
import java.util.ArrayList;
public class ServiceImpl implements Service {
private Dao dao;
public ServiceImpl() {
dao = new DaoImpl();
}
@Override
public void addArticle(Article a) {
dao.insert(a);
}
@Override
public Article getArticle(int num) {
return dao.select(num);
}
@Override
public ArrayList<Article> getAll() {
// TODO Auto-generated method stub
return dao.selectAll();
}
@Override
public void editArticle(Article a) {
// TODO Auto-generated method stub
dao.update(a);
}
@Override
public void delArticle(int num) {
// TODO Auto-generated method stub
dao.delete(num);
}
}
| [
"[email protected]"
]
| |
29024ba634bacd5a666c308c62674cedcbb13c04 | bbf2cbbef631caff0c88c53649385e77ffb82197 | /src/main/java/com/sidecar/customer/dto/response/ErrorDto.java | c0ed6178b7937121dfc6f9009437669b9a20f06a | []
| no_license | pmiglani4/customer-service | df6688b5623982ddb368455e8e71f14db7a664e2 | d1ea274b598a0235e2516730dbae481120207c0c | refs/heads/master | 2022-10-21T01:16:52.155217 | 2020-06-11T06:14:16 | 2020-06-11T06:14:16 | 271,464,894 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 381 | java | package com.sidecar.customer.dto.response;
import lombok.*;
import org.springframework.http.HttpStatus;
import java.time.OffsetDateTime;
import java.util.List;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ErrorDto{
private String errorMessage;
private String errorCode;
private HttpStatus status;
private OffsetDateTime time;
}
| [
"[email protected]"
]
| |
0f06e3f2972647e9e59e38027795f3eca54283f0 | 7522a9a02adb29f3093d31d00fc56b758891b46a | /src/automobiles/DBUtil.java | fdc4289ca97c0a1818d410eaaafc901ff0ccafe0 | []
| no_license | karthikdaya/Auto-Inventory | 6d009d2b2d8e062515c91e8e3945aeeb58e7d8d1 | 4ef98d5fad53fcf7f8aae3ad9fd445154324f32c | refs/heads/master | 2020-03-19T18:09:09.991615 | 2018-06-10T12:38:55 | 2018-06-10T12:38:55 | 136,724,592 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,337 | java | package automobiles;
import java.sql.*;
import javafx.scene.control.Alert;
public class DBUtil {
private static Connection conn = null;
private static final String user = "root";
private static final String pass = "root123";
private static final String conString = "jdbc:mysql://localhost:3306/inventory";
public static Connection dbConnect() {
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(conString, user, pass);
System.out.print("Database is connected !");
} catch (ClassNotFoundException | SQLException e) {
System.out.print("Do not connect to DB - Error:" + e);
}
return conn;
}
public static void dbDisconnect(Connection con) throws SQLException {
try {
if (con != null && !con.isClosed()) {
con.close();
}
} catch (SQLException e) {
throw e;
}
}
public static void infoBox(String infoMessage, String titleBar, String headerMessage) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle(titleBar);
alert.setHeaderText(headerMessage);
alert.setContentText(infoMessage);
alert.showAndWait();
}
}
| [
"[email protected]"
]
| |
4e3b790a51cb53cabea5bc76b2b05c0c446705cf | c16cdbdea03d9a40ac41c0ca4217d2a38154c035 | /android-19/android/graphics/Bitmap_Delegate.java | ec284ac3cfed85c3bd96958e499374ecdd20834b | []
| no_license | lingzhuzi/android-sources | 191e724cc46e6769689075ac6265ffee0fda9d99 | 26f46c6c8ababfef1cfc4ad5e72af440978066d0 | refs/heads/master | 2021-01-15T21:44:28.991305 | 2014-06-21T05:20:56 | 2014-06-21T05:20:56 | 20,685,285 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 22,514 | java | /*
* Copyright (C) 2010 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 android.graphics;
import com.android.ide.common.rendering.api.LayoutLog;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.impl.DelegateManager;
import com.android.resources.Density;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
import android.graphics.Bitmap.Config;
import android.os.Parcel;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.Buffer;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Set;
import javax.imageio.ImageIO;
/**
* Delegate implementing the native methods of android.graphics.Bitmap
*
* Through the layoutlib_create tool, the original native methods of Bitmap have been replaced
* by calls to methods of the same name in this delegate class.
*
* This class behaves like the original native implementation, but in Java, keeping previously
* native data into its own objects and mapping them to int that are sent back and forth between
* it and the original Bitmap class.
*
* @see DelegateManager
*
*/
public final class Bitmap_Delegate {
public enum BitmapCreateFlags {
PREMULTIPLIED, MUTABLE
}
// ---- delegate manager ----
private static final DelegateManager<Bitmap_Delegate> sManager =
new DelegateManager<Bitmap_Delegate>(Bitmap_Delegate.class);
// ---- delegate helper data ----
// ---- delegate data ----
private final Config mConfig;
private BufferedImage mImage;
private boolean mHasAlpha = true;
private boolean mHasMipMap = false; // TODO: check the default.
private int mGenerationId = 0;
// ---- Public Helper methods ----
/**
* Returns the native delegate associated to a given {@link Bitmap_Delegate} object.
*/
public static Bitmap_Delegate getDelegate(Bitmap bitmap) {
return sManager.getDelegate(bitmap.mNativeBitmap);
}
/**
* Returns the native delegate associated to a given an int referencing a {@link Bitmap} object.
*/
public static Bitmap_Delegate getDelegate(int native_bitmap) {
return sManager.getDelegate(native_bitmap);
}
/**
* Creates and returns a {@link Bitmap} initialized with the given file content.
*
* @param input the file from which to read the bitmap content
* @param isMutable whether the bitmap is mutable
* @param density the density associated with the bitmap
*
* @see Bitmap#isMutable()
* @see Bitmap#getDensity()
*/
public static Bitmap createBitmap(File input, boolean isMutable, Density density)
throws IOException {
return createBitmap(input, getPremultipliedBitmapCreateFlags(isMutable), density);
}
/**
* Creates and returns a {@link Bitmap} initialized with the given file content.
*
* @param input the file from which to read the bitmap content
* @param density the density associated with the bitmap
*
* @see Bitmap#isPremultiplied()
* @see Bitmap#isMutable()
* @see Bitmap#getDensity()
*/
public static Bitmap createBitmap(File input, Set<BitmapCreateFlags> createFlags,
Density density) throws IOException {
// create a delegate with the content of the file.
Bitmap_Delegate delegate = new Bitmap_Delegate(ImageIO.read(input), Config.ARGB_8888);
return createBitmap(delegate, createFlags, density.getDpiValue());
}
/**
* Creates and returns a {@link Bitmap} initialized with the given stream content.
*
* @param input the stream from which to read the bitmap content
* @param isMutable whether the bitmap is mutable
* @param density the density associated with the bitmap
*
* @see Bitmap#isMutable()
* @see Bitmap#getDensity()
*/
public static Bitmap createBitmap(InputStream input, boolean isMutable, Density density)
throws IOException {
return createBitmap(input, getPremultipliedBitmapCreateFlags(isMutable), density);
}
/**
* Creates and returns a {@link Bitmap} initialized with the given stream content.
*
* @param input the stream from which to read the bitmap content
* @param createFlags
* @param density the density associated with the bitmap
*
* @see Bitmap#isPremultiplied()
* @see Bitmap#isMutable()
* @see Bitmap#getDensity()
*/
public static Bitmap createBitmap(InputStream input, Set<BitmapCreateFlags> createFlags,
Density density) throws IOException {
// create a delegate with the content of the stream.
Bitmap_Delegate delegate = new Bitmap_Delegate(ImageIO.read(input), Config.ARGB_8888);
return createBitmap(delegate, createFlags, density.getDpiValue());
}
/**
* Creates and returns a {@link Bitmap} initialized with the given {@link BufferedImage}
*
* @param image the bitmap content
* @param isMutable whether the bitmap is mutable
* @param density the density associated with the bitmap
*
* @see Bitmap#isMutable()
* @see Bitmap#getDensity()
*/
public static Bitmap createBitmap(BufferedImage image, boolean isMutable,
Density density) throws IOException {
return createBitmap(image, getPremultipliedBitmapCreateFlags(isMutable), density);
}
/**
* Creates and returns a {@link Bitmap} initialized with the given {@link BufferedImage}
*
* @param image the bitmap content
* @param createFlags
* @param density the density associated with the bitmap
*
* @see Bitmap#isPremultiplied()
* @see Bitmap#isMutable()
* @see Bitmap#getDensity()
*/
public static Bitmap createBitmap(BufferedImage image, Set<BitmapCreateFlags> createFlags,
Density density) throws IOException {
// create a delegate with the given image.
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.ARGB_8888);
return createBitmap(delegate, createFlags, density.getDpiValue());
}
/**
* Returns the {@link BufferedImage} used by the delegate of the given {@link Bitmap}.
*/
public static BufferedImage getImage(Bitmap bitmap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(bitmap.mNativeBitmap);
if (delegate == null) {
return null;
}
return delegate.mImage;
}
public static int getBufferedImageType(int nativeBitmapConfig) {
switch (Config.nativeToConfig(nativeBitmapConfig)) {
case ALPHA_8:
return BufferedImage.TYPE_INT_ARGB;
case RGB_565:
return BufferedImage.TYPE_INT_ARGB;
case ARGB_4444:
return BufferedImage.TYPE_INT_ARGB;
case ARGB_8888:
return BufferedImage.TYPE_INT_ARGB;
}
return BufferedImage.TYPE_INT_ARGB;
}
/**
* Returns the {@link BufferedImage} used by the delegate of the given {@link Bitmap}.
*/
public BufferedImage getImage() {
return mImage;
}
/**
* Returns the Android bitmap config. Note that this not the config of the underlying
* Java2D bitmap.
*/
public Config getConfig() {
return mConfig;
}
/**
* Returns the hasAlpha rendering hint
* @return true if the bitmap alpha should be used at render time
*/
public boolean hasAlpha() {
return mHasAlpha && mConfig != Config.RGB_565;
}
public boolean hasMipMap() {
// TODO: check if more checks are required as in hasAlpha.
return mHasMipMap;
}
/**
* Update the generationId.
*
* @see Bitmap#getGenerationId()
*/
public void change() {
mGenerationId++;
}
// ---- native methods ----
@LayoutlibDelegate
/*package*/ static Bitmap nativeCreate(int[] colors, int offset, int stride, int width,
int height, int nativeConfig, boolean isMutable) {
int imageType = getBufferedImageType(nativeConfig);
// create the image
BufferedImage image = new BufferedImage(width, height, imageType);
if (colors != null) {
image.setRGB(0, 0, width, height, colors, offset, stride);
}
// create a delegate with the content of the stream.
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
return createBitmap(delegate, getPremultipliedBitmapCreateFlags(isMutable),
Bitmap.getDefaultDensity());
}
@LayoutlibDelegate
/*package*/ static Bitmap nativeCopy(int srcBitmap, int nativeConfig, boolean isMutable) {
Bitmap_Delegate srcBmpDelegate = sManager.getDelegate(srcBitmap);
if (srcBmpDelegate == null) {
return null;
}
BufferedImage srcImage = srcBmpDelegate.getImage();
int width = srcImage.getWidth();
int height = srcImage.getHeight();
int imageType = getBufferedImageType(nativeConfig);
// create the image
BufferedImage image = new BufferedImage(width, height, imageType);
// copy the source image into the image.
int[] argb = new int[width * height];
srcImage.getRGB(0, 0, width, height, argb, 0, width);
image.setRGB(0, 0, width, height, argb, 0, width);
// create a delegate with the content of the stream.
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
return createBitmap(delegate, getPremultipliedBitmapCreateFlags(isMutable),
Bitmap.getDefaultDensity());
}
@LayoutlibDelegate
/*package*/ static void nativeDestructor(int nativeBitmap) {
sManager.removeJavaReferenceFor(nativeBitmap);
}
@LayoutlibDelegate
/*package*/ static void nativeRecycle(int nativeBitmap) {
sManager.removeJavaReferenceFor(nativeBitmap);
}
@LayoutlibDelegate
/*package*/ static boolean nativeCompress(int nativeBitmap, int format, int quality,
OutputStream stream, byte[] tempStorage) {
Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
"Bitmap.compress() is not supported", null /*data*/);
return true;
}
@LayoutlibDelegate
/*package*/ static void nativeErase(int nativeBitmap, int color) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return;
}
BufferedImage image = delegate.mImage;
Graphics2D g = image.createGraphics();
try {
g.setColor(new java.awt.Color(color, true));
g.fillRect(0, 0, image.getWidth(), image.getHeight());
} finally {
g.dispose();
}
}
@LayoutlibDelegate
/*package*/ static int nativeWidth(int nativeBitmap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return 0;
}
return delegate.mImage.getWidth();
}
@LayoutlibDelegate
/*package*/ static int nativeHeight(int nativeBitmap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return 0;
}
return delegate.mImage.getHeight();
}
@LayoutlibDelegate
/*package*/ static int nativeRowBytes(int nativeBitmap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return 0;
}
return delegate.mImage.getWidth();
}
@LayoutlibDelegate
/*package*/ static int nativeConfig(int nativeBitmap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return 0;
}
return delegate.mConfig.nativeInt;
}
@LayoutlibDelegate
/*package*/ static boolean nativeHasAlpha(int nativeBitmap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return true;
}
return delegate.mHasAlpha;
}
@LayoutlibDelegate
/*package*/ static boolean nativeHasMipMap(int nativeBitmap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return true;
}
return delegate.mHasMipMap;
}
@LayoutlibDelegate
/*package*/ static int nativeGetPixel(int nativeBitmap, int x, int y) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return 0;
}
return delegate.mImage.getRGB(x, y);
}
@LayoutlibDelegate
/*package*/ static void nativeGetPixels(int nativeBitmap, int[] pixels, int offset,
int stride, int x, int y, int width, int height) {
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return;
}
delegate.getImage().getRGB(x, y, width, height, pixels, offset, stride);
}
@LayoutlibDelegate
/*package*/ static void nativeSetPixel(int nativeBitmap, int x, int y, int color) {
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return;
}
delegate.getImage().setRGB(x, y, color);
}
@LayoutlibDelegate
/*package*/ static void nativeSetPixels(int nativeBitmap, int[] colors, int offset,
int stride, int x, int y, int width, int height) {
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return;
}
delegate.getImage().setRGB(x, y, width, height, colors, offset, stride);
}
@LayoutlibDelegate
/*package*/ static void nativeCopyPixelsToBuffer(int nativeBitmap, Buffer dst) {
// FIXME implement native delegate
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Bitmap.copyPixelsToBuffer is not supported.", null, null /*data*/);
}
@LayoutlibDelegate
/*package*/ static void nativeCopyPixelsFromBuffer(int nb, Buffer src) {
// FIXME implement native delegate
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Bitmap.copyPixelsFromBuffer is not supported.", null, null /*data*/);
}
@LayoutlibDelegate
/*package*/ static int nativeGenerationId(int nativeBitmap) {
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return 0;
}
return delegate.mGenerationId;
}
@LayoutlibDelegate
/*package*/ static Bitmap nativeCreateFromParcel(Parcel p) {
// This is only called by Bitmap.CREATOR (Parcelable.Creator<Bitmap>), which is only
// used during aidl call so really this should not be called.
Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
"AIDL is not suppored, and therefore Bitmaps cannot be created from parcels.",
null /*data*/);
return null;
}
@LayoutlibDelegate
/*package*/ static boolean nativeWriteToParcel(int nativeBitmap, boolean isMutable,
int density, Parcel p) {
// This is only called when sending a bitmap through aidl, so really this should not
// be called.
Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
"AIDL is not suppored, and therefore Bitmaps cannot be written to parcels.",
null /*data*/);
return false;
}
@LayoutlibDelegate
/*package*/ static Bitmap nativeExtractAlpha(int nativeBitmap, int nativePaint,
int[] offsetXY) {
Bitmap_Delegate bitmap = sManager.getDelegate(nativeBitmap);
if (bitmap == null) {
return null;
}
// get the paint which can be null if nativePaint is 0.
Paint_Delegate paint = Paint_Delegate.getDelegate(nativePaint);
if (paint != null && paint.getMaskFilter() != null) {
Bridge.getLog().fidelityWarning(LayoutLog.TAG_MASKFILTER,
"MaskFilter not supported in Bitmap.extractAlpha",
null, null /*data*/);
}
int alpha = paint != null ? paint.getAlpha() : 0xFF;
BufferedImage image = createCopy(bitmap.getImage(), BufferedImage.TYPE_INT_ARGB, alpha);
// create the delegate. The actual Bitmap config is only an alpha channel
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.ALPHA_8);
// the density doesn't matter, it's set by the Java method.
return createBitmap(delegate, EnumSet.of(BitmapCreateFlags.MUTABLE),
Density.DEFAULT_DENSITY /*density*/);
}
@LayoutlibDelegate
/*package*/ static void nativePrepareToDraw(int nativeBitmap) {
// nothing to be done here.
}
@LayoutlibDelegate
/*package*/ static void nativeSetHasAlpha(int nativeBitmap, boolean hasAlpha) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return;
}
delegate.mHasAlpha = hasAlpha;
}
@LayoutlibDelegate
/*package*/ static void nativeSetHasMipMap(int nativeBitmap, boolean hasMipMap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return;
}
delegate.mHasMipMap = hasMipMap;
}
@LayoutlibDelegate
/*package*/ static boolean nativeSameAs(int nb0, int nb1) {
Bitmap_Delegate delegate1 = sManager.getDelegate(nb0);
if (delegate1 == null) {
return false;
}
Bitmap_Delegate delegate2 = sManager.getDelegate(nb1);
if (delegate2 == null) {
return false;
}
BufferedImage image1 = delegate1.getImage();
BufferedImage image2 = delegate2.getImage();
if (delegate1.mConfig != delegate2.mConfig ||
image1.getWidth() != image2.getWidth() ||
image1.getHeight() != image2.getHeight()) {
return false;
}
// get the internal data
int w = image1.getWidth();
int h = image2.getHeight();
int[] argb1 = new int[w*h];
int[] argb2 = new int[w*h];
image1.getRGB(0, 0, w, h, argb1, 0, w);
image2.getRGB(0, 0, w, h, argb2, 0, w);
// compares
if (delegate1.mConfig == Config.ALPHA_8) {
// in this case we have to manually compare the alpha channel as the rest is garbage.
final int length = w*h;
for (int i = 0 ; i < length ; i++) {
if ((argb1[i] & 0xFF000000) != (argb2[i] & 0xFF000000)) {
return false;
}
}
return true;
}
return Arrays.equals(argb1, argb2);
}
// ---- Private delegate/helper methods ----
private Bitmap_Delegate(BufferedImage image, Config config) {
mImage = image;
mConfig = config;
}
private static Bitmap createBitmap(Bitmap_Delegate delegate,
Set<BitmapCreateFlags> createFlags, int density) {
// get its native_int
int nativeInt = sManager.addNewDelegate(delegate);
int width = delegate.mImage.getWidth();
int height = delegate.mImage.getHeight();
boolean isMutable = createFlags.contains(BitmapCreateFlags.MUTABLE);
boolean isPremultiplied = createFlags.contains(BitmapCreateFlags.PREMULTIPLIED);
// and create/return a new Bitmap with it
return new Bitmap(nativeInt, null /* buffer */, width, height, density, isMutable,
isPremultiplied, null /*ninePatchChunk*/, null /* layoutBounds */);
}
private static Set<BitmapCreateFlags> getPremultipliedBitmapCreateFlags(boolean isMutable) {
Set<BitmapCreateFlags> createFlags = EnumSet.of(BitmapCreateFlags.PREMULTIPLIED);
if (isMutable) {
createFlags.add(BitmapCreateFlags.MUTABLE);
}
return createFlags;
}
/**
* Creates and returns a copy of a given BufferedImage.
* <p/>
* if alpha is different than 255, then it is applied to the alpha channel of each pixel.
*
* @param image the image to copy
* @param imageType the type of the new image
* @param alpha an optional alpha modifier
* @return a new BufferedImage
*/
/*package*/ static BufferedImage createCopy(BufferedImage image, int imageType, int alpha) {
int w = image.getWidth();
int h = image.getHeight();
BufferedImage result = new BufferedImage(w, h, imageType);
int[] argb = new int[w * h];
image.getRGB(0, 0, image.getWidth(), image.getHeight(), argb, 0, image.getWidth());
if (alpha != 255) {
final int length = argb.length;
for (int i = 0 ; i < length; i++) {
int a = (argb[i] >>> 24 * alpha) / 255;
argb[i] = (a << 24) | (argb[i] & 0x00FFFFFF);
}
}
result.setRGB(0, 0, w, h, argb, 0, w);
return result;
}
}
| [
"[email protected]"
]
| |
6c2b663ad3415044249aea38b460483a5cf561da | 62686e671c2e970e64dd3dd027231ee407abb995 | /src/com/company/lab6/Logic.java | 0be071967ed628694eedeaf78e559b5cd0ce0d4a | []
| no_license | SebastianMarie/JAVAPROJECT | 7830d0549f0e9ffc71ddf3a5dd8cb71e190cdeb4 | fcf5085d211f28b7984c61fdb0235f22bb487efb | refs/heads/master | 2023-08-05T15:52:27.012678 | 2021-09-20T20:01:51 | 2021-09-20T20:01:51 | 319,424,906 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,164 | java | package com.company.lab6;
import java.util.List;
public class Logic {
//TEMA LISTS
//1. Scrieti o metoda Java, care sa primeasca parametru o Lista, si sa afiseze, pe rand, toate
// valorile din lista, fiecare pe rand nou.
public void printList(List<Integer> myList) {
for (int i = 0; i < myList.size(); i++) {
System.out.println(myList.get(i));
}
}
//2. Scrieti o metoda Java, care sa primeasca doi parametrii: un parametru sa fie o lista de numere,
// si celalalt un numar (real sau intreg). Metoda sa adauge numarul primit ca si parametru la final de lista.
public List addNumberToList(List<Integer> myList, int number) {
myList.add(number);
return myList;
}
//3. Scrieti o metoda Java, care sa primeasca doi parametrii: un parametru de tip Lista,
// iar celalalt un numar intreg. Sa se parcurga lista si sa afiseze, pe rand,
// toate valorile din lista, fiecare pe rand nou, pornind de la numarul intreg primit ca si parametru.
public void printListFromGivenNumber(List<Integer> myList, int number) {
for (int i = number; i < myList.size(); i++) {
System.out.println(myList.get(i));
}
}
//4. Scrieti o metoda Java, care sa primeasca parametru o Lista, si sa afiseze, pe rand, toate valorile
// din lista, dar invers(de la capat la inceput).
public void printListBackwords2(List<Integer> myList) {
System.out.print("Backwords list: ");
for (int i = myList.size()-1; i >=0; i--) {
System.out.print(myList.get(i)+" ");
}
}
//5. Scrieti o metoda Java, care sa primeasca trei parametrii: unul de tip Lista de String-uri,
// unul de tip intreg, si unul de tip String. Metoda sa adauge parametrul de tip String in lista primita,
// iar parametrul de tip intreg reprezinta pozitia la care sa fie pus acel String.
public void addStringToList(List<String> myList, int index, String text) {
myList.add(index,text);
}
//6. Scrieti o metoda Java, care sa primeasca doi parametrii. Primul dintre ei va fi o Lista, iar metoda
// sa ia al doilea parametru si sa il adauge pe prima pozitie din lista.
public void addNumberToFirstIndex(List<String> myList, String number) {
myList.add(0, number);
}
//7. Scrieti o metoda Java care sa primeasca parametru o Lista, si sa afiseze ce valori are lista, si pe ce
// ce pozitie. (Ex: “Pe pozitia 1 valoare este 4”).
public void showListDescription(List<Integer> myList){
for (int i=0; i<myList.size();i++){
System.out.print("Pe pozitia "+i);
System.out.print(" valoarea este "+myList.get(i));
System.out.println();
}
}
//8. Scrieti o metoda Java care sa primeasca o Lista si sa returneze cel mai mare numar din ea.
public int printLowestNumberFromList(List<Integer> myList){
int lowest = myList.get(0);
for(int i=0; i<myList.size();i++){
if (myList.get(i)<lowest){
lowest = myList.get(i);
}
}
System.out.print("Lowest number from list is: ");
return lowest;
}
}
| [
"[email protected]"
]
| |
efa6a43c90b2192092095941b964e82e5357bea8 | 0f817ec28d2604fc32ad12074d0345d4d83052e6 | /Activity/activity10_hp.java | 2e451745a8fb346eddc72521bb76f794817c71c8 | []
| no_license | HarrisonPierce/Java-2-Files | ea1c2ff612e1e0c961fb971b33d41473875799da | 4c831168a3240882d3332b69841f2bf87ab68c30 | refs/heads/master | 2022-06-04T19:03:58.196934 | 2020-05-03T01:32:43 | 2020-05-03T01:32:43 | 260,803,372 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,247 | java | /**
* Harrison Pierce
* 10/25/17
* This program calculates the average of each of 5 classes with the given grades using a ragged array and nested for loops.
*/
public class activity10_hp
{
public static void main(String[] args)
{
double average;
int j,i; //counter variables
double[][] ragged = new double[5][]; //raggeed array object created with 5 columns
ragged[0] = new double[10]; //set ragged array rows
ragged[1] = new double[2];
ragged[2] = new double[6];
ragged[3] = new double[5];
ragged[4] = new double[2];
ragged[0][0] = 100.0; //set ragged array data
ragged[0][1] = 85.5;
ragged[0][2] = 25.4;
ragged[0][3] = 30.3;
ragged[0][4] = 75.5;
ragged[0][5] = 100.0;
ragged[0][6] = 88.7;
ragged[0][7] = 95.6;
ragged[0][8] = 97.8;
ragged[0][9] = 55.8;
ragged[1][0] = 50.0;
ragged[1][1] = 60.0;
ragged[2][0] = 70.5;
ragged[2][1] = 90.0;
ragged[2][2] = 99.9;
ragged[2][3] = 65.0;
ragged[2][4] = 44.5;
ragged[2][5] = 82.3;
ragged[3][0] = 39.5;
ragged[3][1] = 68.4;
ragged[3][2] = 96.9;
ragged[3][3] = 100.0;
ragged[3][4] = 28.7;
ragged[4][0] = 55.9;
ragged[4][1] = 100.0;
for(i = 0;i < ragged.length;i++) //outter loop, counts columns(class)
{
average = 0; //resets the average to 0 once a class average has been printed
for(j = 0; j < ragged[i].length; j++) //inner loop, counts the number of rows and calculates the average once the end of the array has been met
{
average = average + ragged[i][j]; //calculates the class total from the class number and appropriate grade
}
average = average / j; //divides the class total by the number of scores in that class to find the average
System.out.printf("The average of class "+ i + " is %.2f\n", average); //print final average for that class
}
}
} | [
"[email protected]"
]
| |
a9b929a2b976d97cb38a253e5f2f002b03374c68 | 0f2dc1bb38499316893082df2750537e2395fbf8 | /src/main/customActors/Marble.java | a722834e4c2f79670c7b46bec53399aa3963ca4d | []
| no_license | TimonLomberg/TinyMachineSe4 | 42d618d78c5737e01be9e0ee2838d3fae87f70ae | f0e65a7e00c03aebeba4c4dd05e749a95018f013 | refs/heads/master | 2022-11-15T15:29:11.892488 | 2020-05-19T13:38:07 | 2020-05-19T13:38:07 | 264,464,349 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,122 | java | package main.customActors;
import enums.CollisionObjectType;
import main.Actor;
import main.MovementComponent;
import main.Simulation;
import misc.Vec3d;
public class Marble extends Actor {
Simulation simulation;
public Marble(Simulation simulation, double mass, double diameter, Vec3d position, Vec3d movementVector, Vec3d accelerationDirection) {
super(simulation, CollisionObjectType.Sphere);
this.simulation = simulation;
super.setMovementComponent( new MovementComponent(this, position,
movementVector, accelerationDirection));
super.getMovementComponent().setMass(mass);
super.getMovementComponent().setDiameter(diameter);
}
public Marble(Simulation simulation, double mass, double diameter, Vec3d position) {
super(simulation, CollisionObjectType.Sphere);
this.simulation = simulation;
super.setMovementComponent(new MovementComponent(this, position, new Vec3d(0,0,0), new Vec3d(0,0,0)));
super.getMovementComponent().setMass(mass);
super.getMovementComponent().setDiameter(diameter);
}
}
| [
"[email protected]"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.